@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
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { isTelemetryDisabled } from "./telemetry-disabled.mjs";
|
|
2
|
-
import { TELEMETRY_EMITTER_V1, TELEMETRY_SURFACE_V1, UNSAMPLED_RATE, computeSamplingMeta } from "./sampling.mjs";
|
|
3
|
-
import { firstNonBlankTelemetryId, lambdaClient, parseAndWarnTelemetryId } from "./lambda-client.mjs";
|
|
4
|
-
import { flattenObject } from "./utils.mjs";
|
|
5
|
-
import { v4 } from "uuid";
|
|
6
|
-
import { Analytics } from "@segment/analytics-node";
|
|
7
|
-
|
|
8
|
-
//#region src/telemetry/telemetry-client.ts
|
|
9
|
-
var TelemetryClient = class {
|
|
10
|
-
constructor({ packageName, packageVersion, telemetryDisabled, telemetryBaseUrl, sampleRate }) {
|
|
11
|
-
this.globalProperties = {};
|
|
12
|
-
this.cloudConfiguration = null;
|
|
13
|
-
this.licenseToken = null;
|
|
14
|
-
this.telemetryId = null;
|
|
15
|
-
this.licenseTelemetryId = null;
|
|
16
|
-
this.telemetryDisabled = false;
|
|
17
|
-
this.segmentSampleRate = .05;
|
|
18
|
-
this.anonymousId = `anon_${v4()}`;
|
|
19
|
-
this.packageName = packageName;
|
|
20
|
-
this.packageVersion = packageVersion;
|
|
21
|
-
this.telemetryDisabled = telemetryDisabled || isTelemetryDisabled();
|
|
22
|
-
if (this.telemetryDisabled) return;
|
|
23
|
-
this.setSampleRate(sampleRate);
|
|
24
|
-
this.segment = new Analytics({ writeKey: process.env.COPILOTKIT_SEGMENT_WRITE_KEY || "n7XAZtQCGS2v1vvBy3LgBCv2h3Y8whja" });
|
|
25
|
-
this.setGlobalProperties({
|
|
26
|
-
"copilotkit.package.name": packageName,
|
|
27
|
-
"copilotkit.package.version": packageVersion
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
shouldSendToSegment() {
|
|
31
|
-
return Math.random() < this.segmentSampleRate;
|
|
32
|
-
}
|
|
33
|
-
async capture(event, properties) {
|
|
34
|
-
return this.captureWithIdentity(event, properties, {
|
|
35
|
-
telemetryId: this.telemetryId,
|
|
36
|
-
licenseToken: this.licenseToken,
|
|
37
|
-
licenseTelemetryId: this.licenseTelemetryId
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async captureWithIdentity(event, properties, identity) {
|
|
41
|
-
if (this.telemetryDisabled || isTelemetryDisabled()) return;
|
|
42
|
-
const sendToSegment = Boolean(identity.licenseTelemetryId) || this.shouldSendToSegment();
|
|
43
|
-
const lambdaSamplingMeta = computeSamplingMeta({
|
|
44
|
-
telemetryId: identity.licenseTelemetryId,
|
|
45
|
-
sampleRate: UNSAMPLED_RATE
|
|
46
|
-
});
|
|
47
|
-
const segmentSamplingMeta = computeSamplingMeta({
|
|
48
|
-
telemetryId: identity.licenseTelemetryId,
|
|
49
|
-
sampleRate: this.segmentSampleRate
|
|
50
|
-
});
|
|
51
|
-
const eventMeta = {
|
|
52
|
-
telemetry_emitter: TELEMETRY_EMITTER_V1,
|
|
53
|
-
telemetry_surface: TELEMETRY_SURFACE_V1,
|
|
54
|
-
telemetry_event_id: v4()
|
|
55
|
-
};
|
|
56
|
-
const flattenedProperties = flattenObject(properties);
|
|
57
|
-
const propertiesWithGlobal = {
|
|
58
|
-
...this.globalProperties,
|
|
59
|
-
...eventMeta,
|
|
60
|
-
...segmentSamplingMeta,
|
|
61
|
-
telemetry_transport: "segment",
|
|
62
|
-
...flattenedProperties
|
|
63
|
-
};
|
|
64
|
-
const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal).sort().reduce((obj, key) => {
|
|
65
|
-
obj[key] = propertiesWithGlobal[key];
|
|
66
|
-
return obj;
|
|
67
|
-
}, {});
|
|
68
|
-
await lambdaClient.send({
|
|
69
|
-
event,
|
|
70
|
-
properties: flattenedProperties,
|
|
71
|
-
globalProperties: {
|
|
72
|
-
...this.globalProperties,
|
|
73
|
-
...eventMeta,
|
|
74
|
-
...lambdaSamplingMeta,
|
|
75
|
-
telemetry_transport: "lambda"
|
|
76
|
-
},
|
|
77
|
-
packageName: this.packageName,
|
|
78
|
-
packageVersion: this.packageVersion,
|
|
79
|
-
telemetryId: identity.telemetryId ?? void 0,
|
|
80
|
-
licenseToken: identity.licenseToken ?? void 0
|
|
81
|
-
});
|
|
82
|
-
if (this.segment && sendToSegment) this.segment.track({
|
|
83
|
-
anonymousId: this.anonymousId,
|
|
84
|
-
event,
|
|
85
|
-
properties: { ...orderedPropertiesWithGlobal }
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
setGlobalProperties(properties) {
|
|
89
|
-
const flattenedProperties = flattenObject(properties);
|
|
90
|
-
this.globalProperties = {
|
|
91
|
-
...this.globalProperties,
|
|
92
|
-
...flattenedProperties
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
setCloudConfiguration(properties) {
|
|
96
|
-
this.cloudConfiguration = properties;
|
|
97
|
-
this.setGlobalProperties({ cloud: {
|
|
98
|
-
publicApiKey: properties.publicApiKey,
|
|
99
|
-
baseUrl: properties.baseUrl
|
|
100
|
-
} });
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Atomically configure standalone, legacy, or anonymous telemetry identity.
|
|
104
|
-
*
|
|
105
|
-
* A standalone id takes transport precedence over a supplied legacy license
|
|
106
|
-
* token, but only a license-derived id grants sampling authority. Neither
|
|
107
|
-
* value is added to event properties.
|
|
108
|
-
*
|
|
109
|
-
* @param identity - One standalone id, one legacy license token, or neither.
|
|
110
|
-
*/
|
|
111
|
-
setTelemetryIdentity(identity) {
|
|
112
|
-
const resolvedIdentity = this.resolveTelemetryIdentity(identity);
|
|
113
|
-
this.telemetryId = resolvedIdentity.telemetryId;
|
|
114
|
-
this.licenseToken = resolvedIdentity.licenseToken;
|
|
115
|
-
this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Configure legacy license-derived telemetry identity.
|
|
119
|
-
*
|
|
120
|
-
* @param licenseToken - License token whose telemetry claim identifies sends.
|
|
121
|
-
*/
|
|
122
|
-
setLicenseToken(licenseToken) {
|
|
123
|
-
this.setTelemetryIdentity({ licenseToken });
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Create an immutable capture scope for one runtime.
|
|
127
|
-
*
|
|
128
|
-
* The scope shares this client's sinks, process-wide opt-out, global
|
|
129
|
-
* properties, and Segment sampling rate, but snapshots transport identity and
|
|
130
|
-
* license-derived sampling authority. Constructing another runtime cannot
|
|
131
|
-
* rewrite an existing scope.
|
|
132
|
-
*
|
|
133
|
-
* @param identity - The runtime's construction-time telemetry identity.
|
|
134
|
-
* @returns A capture-only client bound to that identity.
|
|
135
|
-
*/
|
|
136
|
-
createScope(identity) {
|
|
137
|
-
const resolvedIdentity = this.resolveTelemetryIdentity(identity);
|
|
138
|
-
return { capture: (event, properties) => this.captureWithIdentity(event, properties, resolvedIdentity) };
|
|
139
|
-
}
|
|
140
|
-
resolveTelemetryIdentity(identity) {
|
|
141
|
-
const telemetryId = firstNonBlankTelemetryId(identity.telemetryId);
|
|
142
|
-
if (telemetryId !== void 0) return {
|
|
143
|
-
telemetryId,
|
|
144
|
-
licenseToken: null,
|
|
145
|
-
licenseTelemetryId: null
|
|
146
|
-
};
|
|
147
|
-
return {
|
|
148
|
-
telemetryId: null,
|
|
149
|
-
licenseToken: identity.licenseToken ?? null,
|
|
150
|
-
licenseTelemetryId: identity.licenseToken ? parseAndWarnTelemetryId(identity.licenseToken) : null
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
setSampleRate(sampleRate) {
|
|
154
|
-
let _sampleRate;
|
|
155
|
-
_sampleRate = sampleRate ?? .05;
|
|
156
|
-
if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);
|
|
157
|
-
if (Number.isNaN(_sampleRate) || _sampleRate < 0 || _sampleRate > 1) throw new Error("Sample rate must be between 0 and 1");
|
|
158
|
-
this.segmentSampleRate = _sampleRate;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
//#endregion
|
|
163
|
-
export { TelemetryClient };
|
|
164
|
-
//# sourceMappingURL=telemetry-client.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-client.mjs","names":["uuidv4"],"sources":["../../src/telemetry/telemetry-client.ts"],"sourcesContent":["import { Analytics } from \"@segment/analytics-node\";\nimport type { AnalyticsEvents } from \"./events\";\nimport { flattenObject } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport {\n firstNonBlankTelemetryId,\n lambdaClient,\n parseAndWarnTelemetryId,\n} from \"./lambda-client\";\nimport {\n computeSamplingMeta,\n TELEMETRY_EMITTER_V1,\n TELEMETRY_SURFACE_V1,\n UNSAMPLED_RATE,\n} from \"./sampling\";\nimport { isTelemetryDisabled } from \"./telemetry-disabled\";\n\nexport { isTelemetryDisabled };\n\n/** Transport identity and sampling authority resolved for one runtime. */\nexport interface TelemetryIdentity {\n telemetryId?: string;\n licenseToken?: string;\n}\n\n/** Capture-only telemetry client bound to one runtime identity. */\nexport interface TelemetryCapture {\n capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void>;\n}\n\ninterface ResolvedTelemetryIdentity {\n telemetryId: string | null;\n licenseToken: string | null;\n licenseTelemetryId: string | null;\n}\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n // EIP / Intelligence license token (Ed25519-signed JWT). The lambda\n // client decodes its payload to extract telemetry_id. Customer API\n // keys are NOT used here — they flow only into Segment.\n private licenseToken: string | null = null;\n // Standalone analytics identity. This stays separate from the effective\n // identity so legacy callers continue sending only their license token to\n // the Lambda transport.\n private telemetryId: string | null = null;\n // License-derived identity used only as sampling authority. A standalone\n // telemetry id remains a transport claim and does not bypass the\n // Segment gate.\n private licenseTelemetryId: string | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n // Client-side sampling rate for anonymous events on the Segment wire\n // only. The lambda sink is ours and takes every event; Segment is\n // billed per event, so the anonymous population stays capped there.\n // Identified events (those whose license token yielded a telemetry_id)\n // bypass the gate on both wires.\n private segmentSampleRate: number = 0.05;\n private anonymousId = `anon_${uuidv4()}`;\n\n constructor({\n packageName,\n packageVersion,\n telemetryDisabled,\n telemetryBaseUrl,\n sampleRate,\n }: {\n packageName: string;\n packageVersion: string;\n telemetryDisabled?: boolean;\n telemetryBaseUrl?: string;\n // Anonymous sampling rate for the Segment wire. Named without the\n // prefix for backward compatibility; the lambda sink ignores it.\n sampleRate?: number;\n }) {\n this.packageName = packageName;\n this.packageVersion = packageVersion;\n this.telemetryDisabled = telemetryDisabled || isTelemetryDisabled();\n\n if (this.telemetryDisabled) {\n return;\n }\n\n this.setSampleRate(sampleRate);\n\n // eslint-disable-next-line\n const writeKey =\n process.env.COPILOTKIT_SEGMENT_WRITE_KEY ||\n \"n7XAZtQCGS2v1vvBy3LgBCv2h3Y8whja\";\n\n this.segment = new Analytics({\n writeKey,\n });\n\n this.setGlobalProperties({\n \"copilotkit.package.name\": packageName,\n \"copilotkit.package.version\": packageVersion,\n });\n }\n\n private shouldSendToSegment() {\n const randomNumber = Math.random();\n return randomNumber < this.segmentSampleRate;\n }\n\n async capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void> {\n return this.captureWithIdentity(event, properties, {\n telemetryId: this.telemetryId,\n licenseToken: this.licenseToken,\n licenseTelemetryId: this.licenseTelemetryId,\n });\n }\n\n private async captureWithIdentity<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n identity: ResolvedTelemetryIdentity,\n ): Promise<void> {\n // Re-read the environment: an opt-out set after import (for example a\n // dotenv call below the imports) must still stop events.\n if (this.telemetryDisabled || isTelemetryDisabled()) {\n return;\n }\n\n // The two wires are gated separately. The lambda sink takes every\n // event: it is CopilotKit-owned, so anonymous volume costs nothing\n // per event there and a real count beats one extrapolated from 5% of\n // the population. Segment is billed per event, so it keeps the gate —\n // callers without license-derived sampling authority are dropped from\n // that copy at segmentSampleRate. Legacy license tokens with a\n // telemetry_id send on both wires: the volume is bounded by\n // paying-customer count and full fidelity per identified customer is\n // worth the marginal cost.\n const sendToSegment =\n Boolean(identity.licenseTelemetryId) || this.shouldSendToSegment();\n\n // Sampling metadata is computed in ./sampling so this client and the\n // v2 runtime client can't drift apart again — see the note there.\n // One call per wire, because the two wires were gated differently and\n // a shared block would overweight the lambda copy by 1/sampleRate.\n const lambdaSamplingMeta = computeSamplingMeta({\n telemetryId: identity.licenseTelemetryId,\n sampleRate: UNSAMPLED_RATE,\n });\n const segmentSamplingMeta = computeSamplingMeta({\n telemetryId: identity.licenseTelemetryId,\n sampleRate: this.segmentSampleRate,\n });\n\n // Everything below travels identically on both copies of this event.\n // The event id is what makes the dual-write dedupable downstream:\n // one capture() produces one id, stamped on the lambda copy and the\n // Segment copy alike, so consumers no longer have to infer the\n // duplication from $lib or from which fields happen to be present\n // (OSS-1019).\n const eventMeta = {\n telemetry_emitter: TELEMETRY_EMITTER_V1,\n telemetry_surface: TELEMETRY_SURFACE_V1,\n telemetry_event_id: uuidv4(),\n };\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal: Record<string, any> = {\n ...this.globalProperties,\n ...eventMeta,\n ...segmentSamplingMeta,\n telemetry_transport: \"segment\",\n ...flattenedProperties,\n };\n const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal)\n .sort()\n .reduce(\n (obj, key) => {\n obj[key] = propertiesWithGlobal[key];\n return obj;\n },\n {} as Record<string, any>,\n );\n\n await lambdaClient.send({\n event,\n properties: flattenedProperties,\n globalProperties: {\n ...this.globalProperties,\n ...eventMeta,\n ...lambdaSamplingMeta,\n telemetry_transport: \"lambda\",\n },\n packageName: this.packageName,\n packageVersion: this.packageVersion,\n telemetryId: identity.telemetryId ?? undefined,\n licenseToken: identity.licenseToken ?? undefined,\n });\n\n if (this.segment && sendToSegment) {\n this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n }\n }\n\n setGlobalProperties(properties: Record<string, any>) {\n const flattenedProperties = flattenObject(properties);\n this.globalProperties = {\n ...this.globalProperties,\n ...flattenedProperties,\n };\n }\n\n setCloudConfiguration(properties: { publicApiKey: string; baseUrl: string }) {\n this.cloudConfiguration = properties;\n\n this.setGlobalProperties({\n cloud: {\n publicApiKey: properties.publicApiKey,\n baseUrl: properties.baseUrl,\n },\n });\n }\n\n /**\n * Atomically configure standalone, legacy, or anonymous telemetry identity.\n *\n * A standalone id takes transport precedence over a supplied legacy license\n * token, but only a license-derived id grants sampling authority. Neither\n * value is added to event properties.\n *\n * @param identity - One standalone id, one legacy license token, or neither.\n */\n setTelemetryIdentity(identity: {\n telemetryId?: string;\n licenseToken?: string;\n }): void {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n this.telemetryId = resolvedIdentity.telemetryId;\n this.licenseToken = resolvedIdentity.licenseToken;\n this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;\n }\n\n /**\n * Configure legacy license-derived telemetry identity.\n *\n * @param licenseToken - License token whose telemetry claim identifies sends.\n */\n setLicenseToken(licenseToken: string) {\n this.setTelemetryIdentity({ licenseToken });\n }\n\n /**\n * Create an immutable capture scope for one runtime.\n *\n * The scope shares this client's sinks, process-wide opt-out, global\n * properties, and Segment sampling rate, but snapshots transport identity and\n * license-derived sampling authority. Constructing another runtime cannot\n * rewrite an existing scope.\n *\n * @param identity - The runtime's construction-time telemetry identity.\n * @returns A capture-only client bound to that identity.\n */\n createScope(identity: TelemetryIdentity): TelemetryCapture {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n\n return {\n capture: <K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ) => this.captureWithIdentity(event, properties, resolvedIdentity),\n };\n }\n\n private resolveTelemetryIdentity(\n identity: TelemetryIdentity,\n ): ResolvedTelemetryIdentity {\n const telemetryId = firstNonBlankTelemetryId(identity.telemetryId);\n if (telemetryId !== undefined) {\n return {\n telemetryId,\n licenseToken: null,\n licenseTelemetryId: null,\n };\n }\n\n return {\n telemetryId: null,\n licenseToken: identity.licenseToken ?? null,\n licenseTelemetryId: identity.licenseToken\n ? parseAndWarnTelemetryId(identity.licenseToken)\n : null,\n };\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 0.05;\n\n // eslint-disable-next-line\n if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n // eslint-disable-next-line\n _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n // Number.isNaN guards against parseFloat(\"nonsense\") slipping past the\n // range check (all NaN comparisons are false), which would silently\n // drop every anonymous Segment event with no signal.\n if (Number.isNaN(_sampleRate) || _sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.segmentSampleRate = _sampleRate;\n // Per-event sampling metadata (sampleRate/sampleRateAdjustmentFactor/\n // sampleWeight) is computed per capture() in ./sampling, once per\n // wire. Only license-authorized events get effectiveSampleRate=1 on\n // the Segment copy; standalone transport identity stays in the\n // sampled population there. The lambda copy is always unsampled.\n }\n}\n"],"mappings":";;;;;;;;AAuCA,IAAa,kBAAb,MAA6B;CA2B3B,YAAY,EACV,aACA,gBACA,mBACA,kBACA,cASC;0BAvCqC,EAAE;4BAC6B;sBAIjC;qBAID;4BAIO;2BAGP;2BAMD;qBACd,QAAQA,IAAQ;AAiBpC,OAAK,cAAc;AACnB,OAAK,iBAAiB;AACtB,OAAK,oBAAoB,qBAAqB,qBAAqB;AAEnE,MAAI,KAAK,kBACP;AAGF,OAAK,cAAc,WAAW;AAO9B,OAAK,UAAU,IAAI,UAAU,EAC3B,UAJA,QAAQ,IAAI,gCACZ,oCAID,CAAC;AAEF,OAAK,oBAAoB;GACvB,2BAA2B;GAC3B,8BAA8B;GAC/B,CAAC;;CAGJ,AAAQ,sBAAsB;AAE5B,SADqB,KAAK,QAAQ,GACZ,KAAK;;CAG7B,MAAM,QACJ,OACA,YACe;AACf,SAAO,KAAK,oBAAoB,OAAO,YAAY;GACjD,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB,oBAAoB,KAAK;GAC1B,CAAC;;CAGJ,MAAc,oBACZ,OACA,YACA,UACe;AAGf,MAAI,KAAK,qBAAqB,qBAAqB,CACjD;EAYF,MAAM,gBACJ,QAAQ,SAAS,mBAAmB,IAAI,KAAK,qBAAqB;EAMpE,MAAM,qBAAqB,oBAAoB;GAC7C,aAAa,SAAS;GACtB,YAAY;GACb,CAAC;EACF,MAAM,sBAAsB,oBAAoB;GAC9C,aAAa,SAAS;GACtB,YAAY,KAAK;GAClB,CAAC;EAQF,MAAM,YAAY;GAChB,mBAAmB;GACnB,mBAAmB;GACnB,oBAAoBA,IAAQ;GAC7B;EAED,MAAM,sBAAsB,cAAc,WAAW;EACrD,MAAM,uBAA4C;GAChD,GAAG,KAAK;GACR,GAAG;GACH,GAAG;GACH,qBAAqB;GACrB,GAAG;GACJ;EACD,MAAM,8BAA8B,OAAO,KAAK,qBAAqB,CAClE,MAAM,CACN,QACE,KAAK,QAAQ;AACZ,OAAI,OAAO,qBAAqB;AAChC,UAAO;KAET,EAAE,CACH;AAEH,QAAM,aAAa,KAAK;GACtB;GACA,YAAY;GACZ,kBAAkB;IAChB,GAAG,KAAK;IACR,GAAG;IACH,GAAG;IACH,qBAAqB;IACtB;GACD,aAAa,KAAK;GAClB,gBAAgB,KAAK;GACrB,aAAa,SAAS,eAAe;GACrC,cAAc,SAAS,gBAAgB;GACxC,CAAC;AAEF,MAAI,KAAK,WAAW,cAClB,MAAK,QAAQ,MAAM;GACjB,aAAa,KAAK;GAClB;GACA,YAAY,EAAE,GAAG,6BAA6B;GAC/C,CAAC;;CAIN,oBAAoB,YAAiC;EACnD,MAAM,sBAAsB,cAAc,WAAW;AACrD,OAAK,mBAAmB;GACtB,GAAG,KAAK;GACR,GAAG;GACJ;;CAGH,sBAAsB,YAAuD;AAC3E,OAAK,qBAAqB;AAE1B,OAAK,oBAAoB,EACvB,OAAO;GACL,cAAc,WAAW;GACzB,SAAS,WAAW;GACrB,EACF,CAAC;;;;;;;;;;;CAYJ,qBAAqB,UAGZ;EACP,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,OAAK,cAAc,iBAAiB;AACpC,OAAK,eAAe,iBAAiB;AACrC,OAAK,qBAAqB,iBAAiB;;;;;;;CAQ7C,gBAAgB,cAAsB;AACpC,OAAK,qBAAqB,EAAE,cAAc,CAAC;;;;;;;;;;;;;CAc7C,YAAY,UAA+C;EACzD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAEhE,SAAO,EACL,UACE,OACA,eACG,KAAK,oBAAoB,OAAO,YAAY,iBAAiB,EACnE;;CAGH,AAAQ,yBACN,UAC2B;EAC3B,MAAM,cAAc,yBAAyB,SAAS,YAAY;AAClE,MAAI,gBAAgB,OAClB,QAAO;GACL;GACA,cAAc;GACd,oBAAoB;GACrB;AAGH,SAAO;GACL,aAAa;GACb,cAAc,SAAS,gBAAgB;GACvC,oBAAoB,SAAS,eACzB,wBAAwB,SAAS,aAAa,GAC9C;GACL;;CAGH,AAAQ,cAAc,YAAgC;EACpD,IAAI;AAEJ,gBAAc,cAAc;AAG5B,MAAI,QAAQ,IAAI,iCAEd,eAAc,WAAW,QAAQ,IAAI,iCAAiC;AAMxE,MAAI,OAAO,MAAM,YAAY,IAAI,cAAc,KAAK,cAAc,EAChE,OAAM,IAAI,MAAM,sCAAsC;AAGxD,OAAK,oBAAoB"}
|
package/dist/telemetry/utils.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/telemetry/utils.ts
|
|
3
|
-
function flattenObject(obj, parentKey = "", res = {}) {
|
|
4
|
-
for (let key in obj) {
|
|
5
|
-
const propName = parentKey ? `${parentKey}.${key}` : key;
|
|
6
|
-
if (typeof obj[key] === "object" && obj[key] !== null) flattenObject(obj[key], propName, res);
|
|
7
|
-
else res[propName] = obj[key];
|
|
8
|
-
}
|
|
9
|
-
return res;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
exports.flattenObject = flattenObject;
|
|
14
|
-
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../../src/telemetry/utils.ts"],"sourcesContent":["export function flattenObject(\n obj: Record<string, any>,\n parentKey = \"\",\n res: Record<string, any> = {},\n): Record<string, any> {\n for (let key in obj) {\n const propName = parentKey ? `${parentKey}.${key}` : key;\n if (typeof obj[key] === \"object\" && obj[key] !== null) {\n flattenObject(obj[key], propName, res);\n } else {\n res[propName] = obj[key];\n }\n }\n return res;\n}\n"],"mappings":";;AAAA,SAAgB,cACd,KACA,YAAY,IACZ,MAA2B,EAAE,EACR;AACrB,MAAK,IAAI,OAAO,KAAK;EACnB,MAAM,WAAW,YAAY,GAAG,UAAU,GAAG,QAAQ;AACrD,MAAI,OAAO,IAAI,SAAS,YAAY,IAAI,SAAS,KAC/C,eAAc,IAAI,MAAM,UAAU,IAAI;MAEtC,KAAI,YAAY,IAAI;;AAGxB,QAAO"}
|
package/dist/telemetry/utils.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/telemetry/utils.ts
|
|
2
|
-
function flattenObject(obj, parentKey = "", res = {}) {
|
|
3
|
-
for (let key in obj) {
|
|
4
|
-
const propName = parentKey ? `${parentKey}.${key}` : key;
|
|
5
|
-
if (typeof obj[key] === "object" && obj[key] !== null) flattenObject(obj[key], propName, res);
|
|
6
|
-
else res[propName] = obj[key];
|
|
7
|
-
}
|
|
8
|
-
return res;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
export { flattenObject };
|
|
13
|
-
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/telemetry/utils.ts"],"sourcesContent":["export function flattenObject(\n obj: Record<string, any>,\n parentKey = \"\",\n res: Record<string, any> = {},\n): Record<string, any> {\n for (let key in obj) {\n const propName = parentKey ? `${parentKey}.${key}` : key;\n if (typeof obj[key] === \"object\" && obj[key] !== null) {\n flattenObject(obj[key], propName, res);\n } else {\n res[propName] = obj[key];\n }\n }\n return res;\n}\n"],"mappings":";AAAA,SAAgB,cACd,KACA,YAAY,IACZ,MAA2B,EAAE,EACR;AACrB,MAAK,IAAI,OAAO,KAAK;EACnB,MAAM,WAAW,YAAY,GAAG,UAAU,GAAG,QAAQ;AACrD,MAAI,OAAO,IAAI,SAAS,YAAY,IAAI,SAAS,KAC/C,eAAc,IAAI,MAAM,UAAU,IAAI;MAEtC,KAAI,YAAY,IAAI;;AAGxB,QAAO"}
|
|
@@ -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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console-styling.d.cts","names":[],"sources":["../../src/utils/console-styling.ts"],"mappings":";;AAQA;;;;;;cAAa,aAAA;;;+BAoBA;EAAA;;;;;;;;cAAA,aAAA;mGAuB+B;EAAA,wDAAA;EAAA,0DAsB5B;EAAA;uDAAoC;EAAA,8DAyB3B;EAAA,kCAAC;EAAA;;;;;;iBA/CV,4BAAA,CAAA;AAAA,iBAsBA,oBAAA,CAAqB,OAAA;;;;;;;;;;;;;;;iBAyBrB,SAAA,CAAU,QAAA,UAAkB,MAAA;;;;cAO/B,aAAA;;;;;gDAoBH,4BAAA;wCAAA,oBAAA;AAAA"}
|
|
@@ -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.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console-styling.d.mts","names":[],"sources":["../../src/utils/console-styling.ts"],"mappings":";;AAQA;;;;;;cAAa,aAAA;;;+BAoBA;EAAA;;;;;;;;cAAA,aAAA;mGAuB+B;EAAA,wDAAA;EAAA,0DAsB5B;EAAA;uDAAoC;EAAA,8DAyB3B;EAAA,kCAAC;EAAA;;;;;;iBA/CV,4BAAA,CAAA;AAAA,iBAsBA,oBAAA,CAAqB,OAAA;;;;;;;;;;;;;;;iBAyBrB,SAAA,CAAU,QAAA,UAAkB,MAAA;;;;cAO/B,aAAA;;;;;gDAoBH,4BAAA;wCAAA,oBAAA;AAAA"}
|