@copilotkit/shared 1.51.4-next.7 → 1.51.4-next.8
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/CHANGELOG.md +2 -0
- package/README.md +18 -12
- package/dist/{chunk-64DYJ27R.mjs → chunk-3DK3UMRW.mjs} +22 -6
- package/dist/chunk-3DK3UMRW.mjs.map +1 -0
- package/dist/{chunk-75UMJ5TV.mjs → chunk-7YHHOGQR.mjs} +14 -5
- package/dist/chunk-7YHHOGQR.mjs.map +1 -0
- package/dist/{chunk-BOKE4OKY.mjs → chunk-GS5BLXSZ.mjs} +1 -1
- package/dist/{chunk-BOKE4OKY.mjs.map → chunk-GS5BLXSZ.mjs.map} +1 -1
- package/dist/{chunk-6W2UEO2M.mjs → chunk-M2RJI5BZ.mjs} +1 -1
- package/dist/{chunk-6W2UEO2M.mjs.map → chunk-M2RJI5BZ.mjs.map} +1 -1
- package/dist/{chunk-QZG33TOC.mjs → chunk-QPTUDD4F.mjs} +2 -2
- package/dist/chunk-QPTUDD4F.mjs.map +1 -0
- package/dist/{chunk-PL5WNHFZ.mjs → chunk-V7BSERGI.mjs} +19 -7
- package/dist/chunk-V7BSERGI.mjs.map +1 -0
- package/dist/{chunk-XEMZTHQZ.mjs → chunk-WAZHII6M.mjs} +1 -1
- package/dist/chunk-WAZHII6M.mjs.map +1 -0
- package/dist/{chunk-DT2YLCPE.mjs → chunk-XYPFY2IY.mjs} +7 -4
- package/dist/chunk-XYPFY2IY.mjs.map +1 -0
- package/dist/{chunk-GYZIHHE6.mjs → chunk-ZIC6V6S5.mjs} +1 -1
- package/dist/{chunk-GYZIHHE6.mjs.map → chunk-ZIC6V6S5.mjs.map} +1 -1
- package/dist/{chunk-6QGXWNS5.mjs → chunk-ZUE2VR7D.mjs} +7 -3
- package/dist/chunk-ZUE2VR7D.mjs.map +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/index.mjs +1 -1
- package/dist/index.js +56 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/telemetry/events.js.map +1 -1
- package/dist/telemetry/index.js +5 -2
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/index.mjs +3 -3
- package/dist/telemetry/scarf-client.js +1 -1
- package/dist/telemetry/scarf-client.js.map +1 -1
- package/dist/telemetry/scarf-client.mjs +1 -1
- package/dist/telemetry/telemetry-client.js +5 -2
- package/dist/telemetry/telemetry-client.js.map +1 -1
- package/dist/telemetry/telemetry-client.mjs +3 -3
- package/dist/telemetry/utils.js +6 -2
- package/dist/telemetry/utils.js.map +1 -1
- package/dist/telemetry/utils.mjs +1 -1
- package/dist/types/action.js.map +1 -1
- package/dist/types/error.js.map +1 -1
- package/dist/types/openai-assistant.js.map +1 -1
- package/dist/utils/conditions.js +18 -6
- package/dist/utils/conditions.js.map +1 -1
- package/dist/utils/conditions.mjs +1 -1
- package/dist/utils/console-styling.js.map +1 -1
- package/dist/utils/console-styling.mjs +1 -1
- package/dist/utils/errors.d.ts +1 -1
- package/dist/utils/errors.js +13 -4
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/errors.mjs +10 -10
- package/dist/utils/index.js +52 -15
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +10 -10
- package/dist/utils/json-schema.js +21 -5
- package/dist/utils/json-schema.js.map +1 -1
- package/dist/utils/json-schema.mjs +1 -1
- package/dist/utils/random-id.js.map +1 -1
- package/dist/utils/random-id.mjs +1 -1
- package/dist/utils/requests.js.map +1 -1
- package/dist/utils/requests.mjs +1 -1
- package/dist/utils/types.d.ts +1 -1
- package/dist/utils/types.js.map +1 -1
- package/package.json +1 -2
- package/src/constants/index.ts +2 -1
- package/src/telemetry/events.ts +4 -1
- package/src/telemetry/telemetry-client.ts +17 -6
- package/src/telemetry/utils.ts +6 -2
- package/src/types/action.ts +9 -5
- package/src/types/error.ts +11 -2
- package/src/types/openai-assistant.ts +6 -2
- package/src/utils/conditions.ts +27 -9
- package/src/utils/console-styling.ts +4 -2
- package/src/utils/errors.ts +49 -16
- package/src/utils/json-schema.test.ts +29 -5
- package/src/utils/json-schema.ts +34 -9
- package/src/utils/random-id.ts +5 -2
- package/src/utils/requests.ts +3 -1
- package/src/utils/types.ts +5 -1
- package/tsconfig.json +1 -1
- package/tsup.config.ts +5 -1
- package/dist/chunk-64DYJ27R.mjs.map +0 -1
- package/dist/chunk-6QGXWNS5.mjs.map +0 -1
- package/dist/chunk-75UMJ5TV.mjs.map +0 -1
- package/dist/chunk-DT2YLCPE.mjs.map +0 -1
- package/dist/chunk-PL5WNHFZ.mjs.map +0 -1
- package/dist/chunk-QZG33TOC.mjs.map +0 -1
- package/dist/chunk-XEMZTHQZ.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/telemetry/events.ts"],"sourcesContent":["export type AnalyticsEvents = {\n \"oss.runtime.instance_created\": RuntimeInstanceCreatedInfo;\n \"oss.runtime.copilot_request_created\": {\n \"cloud.guardrails.enabled\": boolean;\n requestType: string;\n \"cloud.api_key_provided\": boolean;\n \"cloud.public_api_key\"?: string;\n \"cloud.base_url\"?: string;\n };\n \"oss.runtime.server_action_executed\": {};\n \"oss.runtime.remote_action_executed\": RemoteActionExecutionInfo;\n \"oss.runtime.agent_execution_stream_started\": { hashedLgcKey?: string };\n \"oss.runtime.agent_execution_stream_ended\": AgentExecutionResponseInfo;\n \"oss.runtime.agent_execution_stream_errored\": {
|
|
1
|
+
{"version":3,"sources":["../../src/telemetry/events.ts"],"sourcesContent":["export type AnalyticsEvents = {\n \"oss.runtime.instance_created\": RuntimeInstanceCreatedInfo;\n \"oss.runtime.copilot_request_created\": {\n \"cloud.guardrails.enabled\": boolean;\n requestType: string;\n \"cloud.api_key_provided\": boolean;\n \"cloud.public_api_key\"?: string;\n \"cloud.base_url\"?: string;\n };\n \"oss.runtime.server_action_executed\": {};\n \"oss.runtime.remote_action_executed\": RemoteActionExecutionInfo;\n \"oss.runtime.agent_execution_stream_started\": { hashedLgcKey?: string };\n \"oss.runtime.agent_execution_stream_ended\": AgentExecutionResponseInfo;\n \"oss.runtime.agent_execution_stream_errored\": {\n hashedLgcKey?: string;\n error?: string;\n };\n};\n\nexport interface RuntimeInstanceCreatedInfo {\n actionsAmount: number;\n endpointTypes: string[];\n hashedLgcKey?: string;\n endpointsAmount: number;\n agentsAmount?: number | null;\n \"cloud.api_key_provided\": boolean;\n \"cloud.public_api_key\"?: string;\n \"cloud.base_url\"?: string;\n}\n\nexport interface RemoteActionExecutionInfo {\n agentExecution: boolean;\n type: \"self-hosted\" | \"langgraph-platform\";\n agentsAmount?: number | null;\n hashedLgcKey?: string;\n}\n\nexport interface AgentExecutionResponseInfo {\n provider?: string;\n model?: string;\n langGraphHost?: string;\n langGraphVersion?: string;\n hashedLgcKey?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/telemetry/index.js
CHANGED
|
@@ -56,7 +56,7 @@ function flattenObject(obj, parentKey = "", res = {}) {
|
|
|
56
56
|
var import_uuid = require("uuid");
|
|
57
57
|
|
|
58
58
|
// package.json
|
|
59
|
-
var version = "1.51.4-next.
|
|
59
|
+
var version = "1.51.4-next.8";
|
|
60
60
|
|
|
61
61
|
// src/telemetry/scarf-client.ts
|
|
62
62
|
var SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${version}`;
|
|
@@ -152,7 +152,10 @@ var TelemetryClient = class {
|
|
|
152
152
|
}
|
|
153
153
|
setGlobalProperties(properties) {
|
|
154
154
|
const flattenedProperties = flattenObject(properties);
|
|
155
|
-
this.globalProperties = {
|
|
155
|
+
this.globalProperties = {
|
|
156
|
+
...this.globalProperties,
|
|
157
|
+
...flattenedProperties
|
|
158
|
+
};
|
|
156
159
|
}
|
|
157
160
|
setCloudConfiguration(properties) {
|
|
158
161
|
this.cloudConfiguration = properties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/telemetry/index.ts","../../src/telemetry/telemetry-client.ts","../../src/telemetry/utils.ts","../../package.json","../../src/telemetry/scarf-client.ts"],"sourcesContent":["export * from \"./telemetry-client\";\n","import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport scarfClient from \"./scarf-client\";\n\n/**\n * Checks if telemetry is disabled via environment variables.\n * Users can opt out by setting:\n * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1\n * - DO_NOT_TRACK=true or DO_NOT_TRACK=1\n */\nexport function isTelemetryDisabled(): boolean {\n return (\n (process.env as Record<string, string | undefined>).COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as Record<string, string | undefined>).COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as Record<string, string | undefined>).DO_NOT_TRACK === \"true\" ||\n (process.env as Record<string, string | undefined>).DO_NOT_TRACK === \"1\"\n );\n}\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n private sampleRate: 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 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 = process.env.COPILOTKIT_SEGMENT_WRITE_KEY || \"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 shouldSendEvent() {\n const randomNumber = Math.random();\n return randomNumber < this.sampleRate;\n }\n\n async capture<K extends keyof AnalyticsEvents>(event: K, properties: AnalyticsEvents[K]) {\n if (!this.shouldSendEvent() || !this.segment) {\n return;\n }\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal = {\n ...this.globalProperties,\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 this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n\n await scarfClient.logEvent({\n event,\n });\n }\n\n setGlobalProperties(properties: Record<string, any>) {\n const flattenedProperties = flattenObject(properties);\n this.globalProperties = { ...this.globalProperties, ...flattenedProperties };\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 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 if (_sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n this.setGlobalProperties({\n sampleRate: this.sampleRate,\n sampleRateAdjustmentFactor: 1 - this.sampleRate,\n sampleWeight: 1 / this.sampleRate,\n });\n }\n}\n","import chalk from \"chalk\";\n\nexport 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\nexport function printSecurityNotice(advisory: {\n advisory: string | null;\n message: string;\n severity: \"low\" | \"medium\" | \"high\" | \"none\";\n}) {\n const severityColor =\n {\n low: chalk.blue,\n medium: chalk.yellow,\n high: chalk.red,\n }[advisory.severity.toLowerCase()] || chalk.white;\n\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`);\n console.log();\n console.log(`${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);\n console.log();\n console.log(`${chalk.bold(advisory.message)}`);\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);\n}\n","{\n \"name\": \"@copilotkit/shared\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.51.4-next.7\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"unpkg\": \"./dist/index.umd.js\",\n \"jsdelivr\": \"./dist/index.umd.js\",\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean && rollup -c rollup.config.mjs\",\n \"dev\": \"tsup --watch --no-splitting\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/uuid\": \"^10.0.0\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-custom\": \"workspace:*\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.2.3\",\n \"zod-to-json-schema\": \"^3.23.5\"\n },\n \"dependencies\": {\n \"@segment/analytics-node\": \"^2.1.2\",\n \"chalk\": \"4.1.2\",\n \"graphql\": \"^16.8.1\",\n \"uuid\": \"^10.0.0\",\n \"zod\": \"^3.23.3\"\n },\n \"peerDependencies\": {\n \"@ag-ui/core\": \"^0.0.43\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n","import * as packageJson from \"../../package.json\";\n\nconst SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${packageJson.version}`;\n\nclass ScarfClient {\n constructor() {}\n\n async logEvent(properties: Record<string, any>): Promise<void> {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 3000);\n\n const queryParams = new URLSearchParams();\n\n Object.entries(properties).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n queryParams.append(key, String(value));\n }\n });\n\n const url = `${SCARF_BASE_URL}?${queryParams.toString()}`;\n\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n } catch {\n // Silently fail - telemetry should not break the application\n }\n }\n}\n\nexport default new ScarfClient();\n"],"mappings":";;;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aAAa,KAAK;AAAA,MAClB;AAAA,MACA,YAAY,EAAE,GAAG,4BAA4B;AAAA,IAC/C,CAAC;AAED,UAAM,qBAAY,SAAS;AAAA,MACzB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,oBAAoB,YAAiC;AACnD,UAAM,sBAAsB,cAAc,UAAU;AACpD,SAAK,mBAAmB,EAAE,GAAG,KAAK,kBAAkB,GAAG,oBAAoB;AAAA,EAC7E;AAAA,EAEA,sBAAsB,YAAuD;AAC3E,SAAK,qBAAqB;AAE1B,SAAK,oBAAoB;AAAA,MACvB,OAAO;AAAA,QACL,cAAc,WAAW;AAAA,QACzB,SAAS,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,YAAgC;AACpD,QAAI;AAEJ,kBAAc,cAAc;AAG5B,QAAI,QAAQ,IAAI,kCAAkC;AAEhD,oBAAc,WAAW,QAAQ,IAAI,gCAAgC;AAAA,IACvE;AAEA,QAAI,cAAc,KAAK,cAAc,GAAG;AACtC,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAEA,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,4BAA4B,IAAI,KAAK;AAAA,MACrC,cAAc,IAAI,KAAK;AAAA,IACzB,CAAC;AAAA,EACH;AACF;","names":["uuidv4"]}
|
|
1
|
+
{"version":3,"sources":["../../src/telemetry/index.ts","../../src/telemetry/telemetry-client.ts","../../src/telemetry/utils.ts","../../package.json","../../src/telemetry/scarf-client.ts"],"sourcesContent":["export * from \"./telemetry-client\";\n","import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport scarfClient from \"./scarf-client\";\n\n/**\n * Checks if telemetry is disabled via environment variables.\n * Users can opt out by setting:\n * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1\n * - DO_NOT_TRACK=true or DO_NOT_TRACK=1\n */\nexport function isTelemetryDisabled(): boolean {\n return (\n (process.env as Record<string, string | undefined>)\n .COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as Record<string, string | undefined>)\n .COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as Record<string, string | undefined>).DO_NOT_TRACK ===\n \"true\" ||\n (process.env as Record<string, string | undefined>).DO_NOT_TRACK === \"1\"\n );\n}\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n private sampleRate: 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 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 shouldSendEvent() {\n const randomNumber = Math.random();\n return randomNumber < this.sampleRate;\n }\n\n async capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ) {\n if (!this.shouldSendEvent() || !this.segment) {\n return;\n }\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal = {\n ...this.globalProperties,\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 this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n\n await scarfClient.logEvent({\n event,\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 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 if (_sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n this.setGlobalProperties({\n sampleRate: this.sampleRate,\n sampleRateAdjustmentFactor: 1 - this.sampleRate,\n sampleWeight: 1 / this.sampleRate,\n });\n }\n}\n","import chalk from \"chalk\";\n\nexport 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\nexport function printSecurityNotice(advisory: {\n advisory: string | null;\n message: string;\n severity: \"low\" | \"medium\" | \"high\" | \"none\";\n}) {\n const severityColor =\n {\n low: chalk.blue,\n medium: chalk.yellow,\n high: chalk.red,\n }[advisory.severity.toLowerCase()] || chalk.white;\n\n console.log();\n console.log(\n `━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`,\n );\n console.log();\n console.log(\n `${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`,\n );\n console.log();\n console.log(`${chalk.bold(advisory.message)}`);\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);\n}\n","{\n \"name\": \"@copilotkit/shared\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.51.4-next.8\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"unpkg\": \"./dist/index.umd.js\",\n \"jsdelivr\": \"./dist/index.umd.js\",\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean && rollup -c rollup.config.mjs\",\n \"dev\": \"tsup --watch --no-splitting\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/uuid\": \"^10.0.0\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-custom\": \"workspace:*\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.2.3\",\n \"zod-to-json-schema\": \"^3.23.5\"\n },\n \"dependencies\": {\n \"@segment/analytics-node\": \"^2.1.2\",\n \"chalk\": \"4.1.2\",\n \"graphql\": \"^16.8.1\",\n \"uuid\": \"^10.0.0\",\n \"zod\": \"^3.23.3\"\n },\n \"peerDependencies\": {\n \"@ag-ui/core\": \"^0.0.43\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n","import * as packageJson from \"../../package.json\";\n\nconst SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${packageJson.version}`;\n\nclass ScarfClient {\n constructor() {}\n\n async logEvent(properties: Record<string, any>): Promise<void> {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 3000);\n\n const queryParams = new URLSearchParams();\n\n Object.entries(properties).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n queryParams.append(key, String(value));\n }\n });\n\n const url = `${SCARF_BASE_URL}?${queryParams.toString()}`;\n\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n } catch {\n // Silently fail - telemetry should not break the application\n }\n }\n}\n\nexport default new ScarfClient();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,4BAA0B;;;ACA1B,mBAAkB;AAEX,SAAS,cACd,KACA,YAAY,IACZ,MAA2B,CAAC,GACP;AACrB,WAAS,OAAO,KAAK;AACnB,UAAM,WAAW,YAAY,GAAG,aAAa,QAAQ;AACrD,QAAI,OAAO,IAAI,GAAG,MAAM,YAAY,IAAI,GAAG,MAAM,MAAM;AACrD,oBAAc,IAAI,GAAG,GAAG,UAAU,GAAG;AAAA,IACvC,OAAO;AACL,UAAI,QAAQ,IAAI,IAAI,GAAG;AA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,QACzB,SAAS,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,YAAgC;AACpD,QAAI;AAEJ,kBAAc,cAAc;AAG5B,QAAI,QAAQ,IAAI,kCAAkC;AAEhD,oBAAc,WAAW,QAAQ,IAAI,gCAAgC;AAAA,IACvE;AAEA,QAAI,cAAc,KAAK,cAAc,GAAG;AACtC,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAEA,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,4BAA4B,IAAI,KAAK;AAAA,MACrC,cAAc,IAAI,KAAK;AAAA,IACzB,CAAC;AAAA,EACH;AACF;","names":["uuidv4"]}
|
package/dist/telemetry/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import "../chunk-P7STFMPO.mjs";
|
|
|
2
2
|
import {
|
|
3
3
|
TelemetryClient,
|
|
4
4
|
isTelemetryDisabled
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-XYPFY2IY.mjs";
|
|
6
|
+
import "../chunk-QPTUDD4F.mjs";
|
|
7
|
+
import "../chunk-ZUE2VR7D.mjs";
|
|
8
8
|
export {
|
|
9
9
|
TelemetryClient,
|
|
10
10
|
isTelemetryDisabled
|
|
@@ -25,7 +25,7 @@ __export(scarf_client_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(scarf_client_exports);
|
|
26
26
|
|
|
27
27
|
// package.json
|
|
28
|
-
var version = "1.51.4-next.
|
|
28
|
+
var version = "1.51.4-next.8";
|
|
29
29
|
|
|
30
30
|
// src/telemetry/scarf-client.ts
|
|
31
31
|
var SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${version}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/telemetry/scarf-client.ts","../../package.json"],"sourcesContent":["import * as packageJson from \"../../package.json\";\n\nconst SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${packageJson.version}`;\n\nclass ScarfClient {\n constructor() {}\n\n async logEvent(properties: Record<string, any>): Promise<void> {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 3000);\n\n const queryParams = new URLSearchParams();\n\n Object.entries(properties).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n queryParams.append(key, String(value));\n }\n });\n\n const url = `${SCARF_BASE_URL}?${queryParams.toString()}`;\n\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n } catch {\n // Silently fail - telemetry should not break the application\n }\n }\n}\n\nexport default new ScarfClient();\n","{\n \"name\": \"@copilotkit/shared\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.51.4-next.
|
|
1
|
+
{"version":3,"sources":["../../src/telemetry/scarf-client.ts","../../package.json"],"sourcesContent":["import * as packageJson from \"../../package.json\";\n\nconst SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${packageJson.version}`;\n\nclass ScarfClient {\n constructor() {}\n\n async logEvent(properties: Record<string, any>): Promise<void> {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 3000);\n\n const queryParams = new URLSearchParams();\n\n Object.entries(properties).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n queryParams.append(key, String(value));\n }\n });\n\n const url = `${SCARF_BASE_URL}?${queryParams.toString()}`;\n\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n } catch {\n // Silently fail - telemetry should not break the application\n }\n }\n}\n\nexport default new ScarfClient();\n","{\n \"name\": \"@copilotkit/shared\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.51.4-next.8\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"unpkg\": \"./dist/index.umd.js\",\n \"jsdelivr\": \"./dist/index.umd.js\",\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean && rollup -c rollup.config.mjs\",\n \"dev\": \"tsup --watch --no-splitting\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/uuid\": \"^10.0.0\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-custom\": \"workspace:*\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.2.3\",\n \"zod-to-json-schema\": \"^3.23.5\"\n },\n \"dependencies\": {\n \"@segment/analytics-node\": \"^2.1.2\",\n \"chalk\": \"4.1.2\",\n \"graphql\": \"^16.8.1\",\n \"uuid\": \"^10.0.0\",\n \"zod\": \"^3.23.3\"\n },\n \"peerDependencies\": {\n \"@ag-ui/core\": \"^0.0.43\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWE,cAAW;;;ADTb,IAAM,iBAAiB,uCAAmD;AAE1E,IAAM,cAAN,MAAkB;AAAA,EAChB,cAAc;AAAA,EAAC;AAAA,EAEf,MAAM,SAAS,YAAgD;AAC7D,QAAI;AACF,YAAM,aAAa,IAAI,gBAAgB;AACvC,YAAM,YAAY,WAAW,MAAM,WAAW,MAAM,GAAG,GAAI;AAE3D,YAAM,cAAc,IAAI,gBAAgB;AAExC,aAAO,QAAQ,UAAU,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACnD,YAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,sBAAY,OAAO,KAAK,OAAO,KAAK,CAAC;AAAA,QACvC;AAAA,MACF,CAAC;AAED,YAAM,MAAM,GAAG,kBAAkB,YAAY,SAAS;AAEtD,YAAM,WAAW,MAAM,MAAM,KAAK;AAAA,QAChC,QAAQ;AAAA,QACR,QAAQ,WAAW;AAAA,MACrB,CAAC;AAED,mBAAa,SAAS;AAEtB,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,uBAAuB,SAAS,QAAQ;AAAA,MAC1D;AAAA,IACF,QAAE;AAAA,IAEF;AAAA,EACF;AACF;AAEA,IAAO,uBAAQ,IAAI,YAAY;","names":[]}
|
|
@@ -54,7 +54,7 @@ function flattenObject(obj, parentKey = "", res = {}) {
|
|
|
54
54
|
var import_uuid = require("uuid");
|
|
55
55
|
|
|
56
56
|
// package.json
|
|
57
|
-
var version = "1.51.4-next.
|
|
57
|
+
var version = "1.51.4-next.8";
|
|
58
58
|
|
|
59
59
|
// src/telemetry/scarf-client.ts
|
|
60
60
|
var SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${version}`;
|
|
@@ -150,7 +150,10 @@ var TelemetryClient = class {
|
|
|
150
150
|
}
|
|
151
151
|
setGlobalProperties(properties) {
|
|
152
152
|
const flattenedProperties = flattenObject(properties);
|
|
153
|
-
this.globalProperties = {
|
|
153
|
+
this.globalProperties = {
|
|
154
|
+
...this.globalProperties,
|
|
155
|
+
...flattenedProperties
|
|
156
|
+
};
|
|
154
157
|
}
|
|
155
158
|
setCloudConfiguration(properties) {
|
|
156
159
|
this.cloudConfiguration = properties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/telemetry/telemetry-client.ts","../../src/telemetry/utils.ts","../../package.json","../../src/telemetry/scarf-client.ts"],"sourcesContent":["import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport scarfClient from \"./scarf-client\";\n\n/**\n * Checks if telemetry is disabled via environment variables.\n * Users can opt out by setting:\n * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1\n * - DO_NOT_TRACK=true or DO_NOT_TRACK=1\n */\nexport function isTelemetryDisabled(): boolean {\n return (\n (process.env as Record<string, string | undefined>).COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as Record<string, string | undefined>).COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as Record<string, string | undefined>).DO_NOT_TRACK === \"true\" ||\n (process.env as Record<string, string | undefined>).DO_NOT_TRACK === \"1\"\n );\n}\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n private sampleRate: 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 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 = process.env.COPILOTKIT_SEGMENT_WRITE_KEY || \"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 shouldSendEvent() {\n const randomNumber = Math.random();\n return randomNumber < this.sampleRate;\n }\n\n async capture<K extends keyof AnalyticsEvents>(event: K, properties: AnalyticsEvents[K]) {\n if (!this.shouldSendEvent() || !this.segment) {\n return;\n }\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal = {\n ...this.globalProperties,\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 this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n\n await scarfClient.logEvent({\n event,\n });\n }\n\n setGlobalProperties(properties: Record<string, any>) {\n const flattenedProperties = flattenObject(properties);\n this.globalProperties = { ...this.globalProperties, ...flattenedProperties };\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 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 if (_sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n this.setGlobalProperties({\n sampleRate: this.sampleRate,\n sampleRateAdjustmentFactor: 1 - this.sampleRate,\n sampleWeight: 1 / this.sampleRate,\n });\n }\n}\n","import chalk from \"chalk\";\n\nexport 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\nexport function printSecurityNotice(advisory: {\n advisory: string | null;\n message: string;\n severity: \"low\" | \"medium\" | \"high\" | \"none\";\n}) {\n const severityColor =\n {\n low: chalk.blue,\n medium: chalk.yellow,\n high: chalk.red,\n }[advisory.severity.toLowerCase()] || chalk.white;\n\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`);\n console.log();\n console.log(`${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);\n console.log();\n console.log(`${chalk.bold(advisory.message)}`);\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);\n}\n","{\n \"name\": \"@copilotkit/shared\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.51.4-next.7\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"unpkg\": \"./dist/index.umd.js\",\n \"jsdelivr\": \"./dist/index.umd.js\",\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean && rollup -c rollup.config.mjs\",\n \"dev\": \"tsup --watch --no-splitting\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/uuid\": \"^10.0.0\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-custom\": \"workspace:*\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.2.3\",\n \"zod-to-json-schema\": \"^3.23.5\"\n },\n \"dependencies\": {\n \"@segment/analytics-node\": \"^2.1.2\",\n \"chalk\": \"4.1.2\",\n \"graphql\": \"^16.8.1\",\n \"uuid\": \"^10.0.0\",\n \"zod\": \"^3.23.3\"\n },\n \"peerDependencies\": {\n \"@ag-ui/core\": \"^0.0.43\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n","import * as packageJson from \"../../package.json\";\n\nconst SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${packageJson.version}`;\n\nclass ScarfClient {\n constructor() {}\n\n async logEvent(properties: Record<string, any>): Promise<void> {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 3000);\n\n const queryParams = new URLSearchParams();\n\n Object.entries(properties).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n queryParams.append(key, String(value));\n }\n });\n\n const url = `${SCARF_BASE_URL}?${queryParams.toString()}`;\n\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n } catch {\n // Silently fail - telemetry should not break the application\n }\n }\n}\n\nexport default new ScarfClient();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA0B;;;ACA1B,mBAAkB;AAEX,SAAS,cACd,KACA,YAAY,IACZ,MAA2B,CAAC,GACP;AACrB,WAAS,OAAO,KAAK;AACnB,UAAM,WAAW,YAAY,GAAG,aAAa,QAAQ;AACrD,QAAI,OAAO,IAAI,GAAG,MAAM,YAAY,IAAI,GAAG,MAAM,MAAM;AACrD,oBAAc,IAAI,GAAG,GAAG,UAAU,GAAG;AAAA,IACvC,OAAO;AACL,UAAI,QAAQ,IAAI,IAAI,GAAG;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;;;ADbA,kBAA6B;;;AEQ3B,cAAW;;;ACTb,IAAM,iBAAiB,uCAAmD;AAE1E,IAAM,cAAN,MAAkB;AAAA,EAChB,cAAc;AAAA,EAAC;AAAA,EAEf,MAAM,SAAS,YAAgD;AAC7D,QAAI;AACF,YAAM,aAAa,IAAI,gBAAgB;AACvC,YAAM,YAAY,WAAW,MAAM,WAAW,MAAM,GAAG,GAAI;AAE3D,YAAM,cAAc,IAAI,gBAAgB;AAExC,aAAO,QAAQ,UAAU,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACnD,YAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,sBAAY,OAAO,KAAK,OAAO,KAAK,CAAC;AAAA,QACvC;AAAA,MACF,CAAC;AAED,YAAM,MAAM,GAAG,kBAAkB,YAAY,SAAS;AAEtD,YAAM,WAAW,MAAM,MAAM,KAAK;AAAA,QAChC,QAAQ;AAAA,QACR,QAAQ,WAAW;AAAA,MACrB,CAAC;AAED,mBAAa,SAA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AAK,oBAAoB,EACjE,KAAK,EACL;AAAA,MACC,CAAC,KAAK,QAAQ;AACZ,YAAI,GAAG,IAAI,qBAAqB,GAAG;AACnC,eAAO;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH;AAEF,SAAK,QAAQ,MAAM;AAAA,MACjB,aAAa,KAAK;AAAA,MAClB;AAAA,MACA,YAAY,EAAE,GAAG,4BAA4B;AAAA,IAC/C,CAAC;AAED,UAAM,qBAAY,SAAS;AAAA,MACzB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,oBAAoB,YAAiC;AACnD,UAAM,sBAAsB,cAAc,UAAU;AACpD,SAAK,mBAAmB,EAAE,GAAG,KAAK,kBAAkB,GAAG,oBAAoB;AAAA,EAC7E;AAAA,EAEA,sBAAsB,YAAuD;AAC3E,SAAK,qBAAqB;AAE1B,SAAK,oBAAoB;AAAA,MACvB,OAAO;AAAA,QACL,cAAc,WAAW;AAAA,QACzB,SAAS,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,YAAgC;AACpD,QAAI;AAEJ,kBAAc,cAAc;AAG5B,QAAI,QAAQ,IAAI,kCAAkC;AAEhD,oBAAc,WAAW,QAAQ,IAAI,gCAAgC;AAAA,IACvE;AAEA,QAAI,cAAc,KAAK,cAAc,GAAG;AACtC,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAEA,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,4BAA4B,IAAI,KAAK;AAAA,MACrC,cAAc,IAAI,KAAK;AAAA,IACzB,CAAC;AAAA,EACH;AACF;","names":["uuidv4"]}
|
|
1
|
+
{"version":3,"sources":["../../src/telemetry/telemetry-client.ts","../../src/telemetry/utils.ts","../../package.json","../../src/telemetry/scarf-client.ts"],"sourcesContent":["import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport scarfClient from \"./scarf-client\";\n\n/**\n * Checks if telemetry is disabled via environment variables.\n * Users can opt out by setting:\n * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1\n * - DO_NOT_TRACK=true or DO_NOT_TRACK=1\n */\nexport function isTelemetryDisabled(): boolean {\n return (\n (process.env as Record<string, string | undefined>)\n .COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as Record<string, string | undefined>)\n .COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as Record<string, string | undefined>).DO_NOT_TRACK ===\n \"true\" ||\n (process.env as Record<string, string | undefined>).DO_NOT_TRACK === \"1\"\n );\n}\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n private sampleRate: 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 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 shouldSendEvent() {\n const randomNumber = Math.random();\n return randomNumber < this.sampleRate;\n }\n\n async capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ) {\n if (!this.shouldSendEvent() || !this.segment) {\n return;\n }\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal = {\n ...this.globalProperties,\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 this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n\n await scarfClient.logEvent({\n event,\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 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 if (_sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n this.setGlobalProperties({\n sampleRate: this.sampleRate,\n sampleRateAdjustmentFactor: 1 - this.sampleRate,\n sampleWeight: 1 / this.sampleRate,\n });\n }\n}\n","import chalk from \"chalk\";\n\nexport 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\nexport function printSecurityNotice(advisory: {\n advisory: string | null;\n message: string;\n severity: \"low\" | \"medium\" | \"high\" | \"none\";\n}) {\n const severityColor =\n {\n low: chalk.blue,\n medium: chalk.yellow,\n high: chalk.red,\n }[advisory.severity.toLowerCase()] || chalk.white;\n\n console.log();\n console.log(\n `━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`,\n );\n console.log();\n console.log(\n `${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`,\n );\n console.log();\n console.log(`${chalk.bold(advisory.message)}`);\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);\n}\n","{\n \"name\": \"@copilotkit/shared\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.51.4-next.8\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"unpkg\": \"./dist/index.umd.js\",\n \"jsdelivr\": \"./dist/index.umd.js\",\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean && rollup -c rollup.config.mjs\",\n \"dev\": \"tsup --watch --no-splitting\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/uuid\": \"^10.0.0\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-custom\": \"workspace:*\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.2.3\",\n \"zod-to-json-schema\": \"^3.23.5\"\n },\n \"dependencies\": {\n \"@segment/analytics-node\": \"^2.1.2\",\n \"chalk\": \"4.1.2\",\n \"graphql\": \"^16.8.1\",\n \"uuid\": \"^10.0.0\",\n \"zod\": \"^3.23.3\"\n },\n \"peerDependencies\": {\n \"@ag-ui/core\": \"^0.0.43\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n","import * as packageJson from \"../../package.json\";\n\nconst SCARF_BASE_URL = `https://copilotkit.gateway.scarf.sh/${packageJson.version}`;\n\nclass ScarfClient {\n constructor() {}\n\n async logEvent(properties: Record<string, any>): Promise<void> {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 3000);\n\n const queryParams = new URLSearchParams();\n\n Object.entries(properties).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n queryParams.append(key, String(value));\n }\n });\n\n const url = `${SCARF_BASE_URL}?${queryParams.toString()}`;\n\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n } catch {\n // Silently fail - telemetry should not break the application\n }\n }\n}\n\nexport default new ScarfClient();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA0B;;;ACA1B,mBAAkB;AAEX,SAAS,cACd,KACA,YAAY,IACZ,MAA2B,CAAC,GACP;AACrB,WAAS,OAAO,KAAK;AACnB,UAAM,WAAW,YAAY,GAAG,aAAa,QAAQ;AACrD,QAAI,OAAO,I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R,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EAEA,sBAAsB,YAAuD;AAC3E,SAAK,qBAAqB;AAE1B,SAAK,oBAAoB;AAAA,MACvB,OAAO;AAAA,QACL,cAAc,WAAW;AAAA,QACzB,SAAS,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,YAAgC;AACpD,QAAI;AAEJ,kBAAc,cAAc;AAG5B,QAAI,QAAQ,IAAI,kCAAkC;AAEhD,oBAAc,WAAW,QAAQ,IAAI,gCAAgC;AAAA,IACvE;AAEA,QAAI,cAAc,KAAK,cAAc,GAAG;AACtC,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAEA,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,4BAA4B,IAAI,KAAK;AAAA,MACrC,cAAc,IAAI,KAAK;AAAA,IACzB,CAAC;AAAA,EACH;AACF;","names":["uuidv4"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TelemetryClient,
|
|
3
3
|
isTelemetryDisabled
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-XYPFY2IY.mjs";
|
|
5
|
+
import "../chunk-QPTUDD4F.mjs";
|
|
6
|
+
import "../chunk-ZUE2VR7D.mjs";
|
|
7
7
|
export {
|
|
8
8
|
TelemetryClient,
|
|
9
9
|
isTelemetryDisabled
|
package/dist/telemetry/utils.js
CHANGED
|
@@ -53,9 +53,13 @@ function printSecurityNotice(advisory) {
|
|
|
53
53
|
high: import_chalk.default.red
|
|
54
54
|
}[advisory.severity.toLowerCase()] || import_chalk.default.white;
|
|
55
55
|
console.log();
|
|
56
|
-
console.log(
|
|
56
|
+
console.log(
|
|
57
|
+
`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 ${import_chalk.default.bold(`CopilotKit`)} \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`
|
|
58
|
+
);
|
|
57
59
|
console.log();
|
|
58
|
-
console.log(
|
|
60
|
+
console.log(
|
|
61
|
+
`${import_chalk.default.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`
|
|
62
|
+
);
|
|
59
63
|
console.log();
|
|
60
64
|
console.log(`${import_chalk.default.bold(advisory.message)}`);
|
|
61
65
|
console.log();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/telemetry/utils.ts"],"sourcesContent":["import chalk from \"chalk\";\n\nexport 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\nexport function printSecurityNotice(advisory: {\n advisory: string | null;\n message: string;\n severity: \"low\" | \"medium\" | \"high\" | \"none\";\n}) {\n const severityColor =\n {\n low: chalk.blue,\n medium: chalk.yellow,\n high: chalk.red,\n }[advisory.severity.toLowerCase()] || chalk.white;\n\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)}
|
|
1
|
+
{"version":3,"sources":["../../src/telemetry/utils.ts"],"sourcesContent":["import chalk from \"chalk\";\n\nexport 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\nexport function printSecurityNotice(advisory: {\n advisory: string | null;\n message: string;\n severity: \"low\" | \"medium\" | \"high\" | \"none\";\n}) {\n const severityColor =\n {\n low: chalk.blue,\n medium: chalk.yellow,\n high: chalk.red,\n }[advisory.severity.toLowerCase()] || chalk.white;\n\n console.log();\n console.log(\n `━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`,\n );\n console.log();\n console.log(\n `${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`,\n );\n console.log();\n console.log(`${chalk.bold(advisory.message)}`);\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAEX,SAAS,cACd,KACA,YAAY,IACZ,MAA2B,CAAC,GACP;AACrB,WAAS,OAAO,KAAK;AACnB,UAAM,WAAW,YAAY,GAAG,aAAa,QAAQ;AACrD,QAAI,OAAO,IAAI,GAAG,MAAM,YAAY,IAAI,GAAG,MAAM,MAAM;AACrD,oBAAc,IAAI,GAAG,GAAG,UAAU,GAAG;AAAA,IACvC,OAAO;AACL,UAAI,QAAQ,IAAI,IAAI,GAAG;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,oBAAoB,UAIjC;AACD,QAAM,gBACJ;AAAA,IACE,KAAK,aAAAA,QAAM;AAAA,IACX,QAAQ,aAAAA,QAAM;AAAA,IACd,MAAM,aAAAA,QAAM;AAAA,EACd,EAAE,SAAS,SAAS,YAAY,CAAC,KAAK,aAAAA,QAAM;AAE9C,UAAQ,IAAI;AACZ,UAAQ;AAAA,IACN,gHAAsB,aAAAA,QAAM,KAAK,YAAY;AAAA,EAC/C;AACA,UAAQ,IAAI;AACZ,UAAQ;AAAA,IACN,GAAG,aAAAA,QAAM,KAAK,aAAa,cAAc,SAAS,SAAS,YAAY,CAAC,GAAG;AAAA,EAC7E;AACA,UAAQ,IAAI;AACZ,UAAQ,IAAI,GAAG,aAAAA,QAAM,KAAK,SAAS,OAAO,GAAG;AAC7C,UAAQ,IAAI;AACZ,UAAQ,IAAI,kSAAkD;AAChE;","names":["chalk"]}
|
package/dist/telemetry/utils.mjs
CHANGED
package/dist/types/action.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/action.ts"],"sourcesContent":["type TypeMap = {\n string: string;\n number: number;\n boolean: boolean;\n object: object;\n \"string[]\": string[];\n \"number[]\": number[];\n \"boolean[]\": boolean[];\n \"object[]\": object[];\n};\n\ntype AbstractParameter = {\n name: string;\n type?: keyof TypeMap;\n description?: string;\n required?: boolean;\n};\n\ninterface StringParameter extends AbstractParameter {\n type: \"string\";\n enum?: string[];\n}\n\ninterface ObjectParameter extends AbstractParameter {\n type: \"object\";\n attributes?: Parameter[];\n}\n\ninterface ObjectArrayParameter extends AbstractParameter {\n type: \"object[]\";\n attributes?: Parameter[];\n}\n\ntype SpecialParameters
|
|
1
|
+
{"version":3,"sources":["../../src/types/action.ts"],"sourcesContent":["type TypeMap = {\n string: string;\n number: number;\n boolean: boolean;\n object: object;\n \"string[]\": string[];\n \"number[]\": number[];\n \"boolean[]\": boolean[];\n \"object[]\": object[];\n};\n\ntype AbstractParameter = {\n name: string;\n type?: keyof TypeMap;\n description?: string;\n required?: boolean;\n};\n\ninterface StringParameter extends AbstractParameter {\n type: \"string\";\n enum?: string[];\n}\n\ninterface ObjectParameter extends AbstractParameter {\n type: \"object\";\n attributes?: Parameter[];\n}\n\ninterface ObjectArrayParameter extends AbstractParameter {\n type: \"object[]\";\n attributes?: Parameter[];\n}\n\ntype SpecialParameters =\n | StringParameter\n | ObjectParameter\n | ObjectArrayParameter;\ninterface BaseParameter extends AbstractParameter {\n type?: Exclude<AbstractParameter[\"type\"], SpecialParameters[\"type\"]>;\n}\n\nexport type Parameter = BaseParameter | SpecialParameters;\n\ntype OptionalParameterType<P extends AbstractParameter> =\n P[\"required\"] extends false ? undefined : never;\n\ntype StringParameterType<P> = P extends StringParameter\n ? P extends { enum?: Array<infer E> }\n ? E\n : string\n : never;\n\ntype ObjectParameterType<P> = P extends ObjectParameter\n ? P extends { attributes?: infer Attributes extends Parameter[] }\n ? MappedParameterTypes<Attributes>\n : object\n : never;\n\ntype ObjectArrayParameterType<P> = P extends ObjectArrayParameter\n ? P extends { attributes?: infer Attributes extends Parameter[] }\n ? MappedParameterTypes<Attributes>[]\n : any[]\n : never;\n\ntype MappedTypeOrString<T> = T extends keyof TypeMap ? TypeMap[T] : string;\ntype BaseParameterType<P extends AbstractParameter> = P extends {\n type: infer T;\n}\n ? T extends BaseParameter[\"type\"]\n ? MappedTypeOrString<T>\n : never\n : string;\n\nexport type MappedParameterTypes<T extends Parameter[] | [] = []> = T extends []\n ? Record<string, any>\n : {\n [P in T[number] as P[\"name\"]]:\n | OptionalParameterType<P>\n | StringParameterType<P>\n | ObjectParameterType<P>\n | ObjectArrayParameterType<P>\n | BaseParameterType<P>;\n };\n\nexport type Action<T extends Parameter[] | [] = []> = {\n name: string;\n description?: string;\n parameters?: T;\n handler?: T extends []\n ? () => any | Promise<any>\n : (args: MappedParameterTypes<T>) => any | Promise<any>;\n additionalConfig?: Record<string, any>;\n};\n\n// This is the original \"ceiling is being raised\" version of MappedParameterTypes.\n//\n// ceiling is being raised. cursor's copilot helped us write \"superhuman code\"\n// for a critical feature. We can read this code, but VERY few engineers out\n// there could write it from scratch.\n// Took lots of convincing too. \"come on, this must be possible, try harder\".\n// and obviously- done in parts.\n//\n// - https://twitter.com/ataiiam/status/1765089261374914957\n// (Mar 5, 2024)\n//\n// export type MappedParameterTypes<T extends Parameter[]> = {\n// // Check if the parameter has an 'enum' defined\n// [P in T[number] as P[\"name\"]]: P extends { enum: Array<infer E> }\n// ? E extends string // Ensure the enum values are strings\n// ? P[\"required\"] extends false // Check if the parameter is optional\n// ? E | undefined // If so, include 'undefined' in the type\n// : E // Otherwise, use the enum type directly\n// : never // This case should not occur since 'enum' implies string values\n// : // Handle parameters defined as 'object' with specified attributes\n// P extends { type: \"object\"; attributes: infer Attributes }\n// ? Attributes extends Parameter[]\n// ? MappedParameterTypes<Attributes> // Recursively map the attributes of the object\n// : never // If 'attributes' is not an array of Parameters, this is invalid\n// : // Handle parameters defined as 'object[]' without specified attributes\n// P extends { type: \"object[]\"; attributes?: never }\n// ? any[] // Default to 'any[]' for arrays of objects without specific attributes\n// : // Handle parameters defined as 'object[]' with specified attributes\n// P extends { type: \"object[]\"; attributes: infer Attributes }\n// ? Attributes extends Parameter[]\n// ? MappedParameterTypes<Attributes>[] // Recursively map each object in the array\n// : any[] // Default to 'any[]' if attributes are not properly defined\n// : // Handle all other parameter types\n// P[\"required\"] extends false\n// ? // Include 'undefined' for optional parameters\n// TypeMap[P[\"type\"] extends keyof TypeMap ? P[\"type\"] : \"string\"] | undefined\n// : // Use the direct mapping from 'TypeMap' for the parameter's type\n// TypeMap[P[\"type\"] extends keyof TypeMap ? P[\"type\"] : \"string\"];\n// };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/error.ts"],"sourcesContent":["export interface CopilotErrorEvent {\n type
|
|
1
|
+
{"version":3,"sources":["../../src/types/error.ts"],"sourcesContent":["export interface CopilotErrorEvent {\n type:\n | \"error\"\n | \"request\"\n | \"response\"\n | \"agent_state\"\n | \"action\"\n | \"message\"\n | \"performance\";\n timestamp: number;\n context: CopilotRequestContext;\n error?: any; // Present when type is 'error'\n}\n\nexport interface CopilotRequestContext {\n // Basic identifiers\n threadId?: string;\n runId?: string;\n source: \"runtime\" | \"ui\" | \"agent\" | \"network\";\n\n // Request details\n request?: {\n operation: string;\n method?: string;\n url?: string;\n path?: string;\n headers?: Record<string, string>;\n body?: any;\n startTime: number;\n };\n\n // Response details\n response?: {\n status?: number;\n statusText?: string;\n headers?: Record<string, string>;\n body?: any;\n endTime: number;\n latency: number;\n };\n\n // Agent context\n agent?: {\n name?: string;\n nodeName?: string;\n state?: any;\n };\n\n // Message flow context\n messages?: {\n input?: any[];\n output?: any[];\n messageCount?: number;\n };\n\n // Technical context\n technical?: {\n userAgent?: string;\n host?: string;\n environment?: string;\n version?: string;\n stackTrace?: string;\n };\n\n // Performance metrics\n performance?: {\n requestDuration?: number;\n streamingDuration?: number;\n actionExecutionTime?: number;\n memoryUsage?: number;\n };\n\n // Extensible metadata\n metadata?: Record<string, any>;\n}\n\nexport type CopilotErrorHandler = (\n errorEvent: CopilotErrorEvent,\n) => void | Promise<void>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/openai-assistant.ts"],"sourcesContent":["export interface FunctionDefinition {\n /**\n * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain\n * underscores and dashes, with a maximum length of 64.\n */\n name: string;\n /**\n * The parameters the functions accepts, described as a JSON Schema object. See the\n * [guide](/docs/guides/gpt/function-calling) for examples, and the\n * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for\n * documentation about the format.\n *\n * To describe a function that accepts no parameters, provide the value\n * `{\"type\": \"object\", \"properties\": {}}`.\n */\n parameters: Record<string, unknown>;\n /**\n * A description of what the function does, used by the model to choose when and\n * how to call the function.\n */\n description?: string;\n}\n\nexport interface ToolDefinition {\n type: \"function\";\n function: FunctionDefinition;\n}\n\nexport interface FunctionCallHandlerArguments {\n messages: any[];\n name: string;\n args: any;\n}\n\nexport type FunctionCallHandler = (args: FunctionCallHandlerArguments) => Promise<any>;\n\nexport type CoAgentStateRenderHandlerArguments = {\n name: string;\n nodeName: string;\n state: any;\n};\n\nexport type CoAgentStateRenderHandler = (args: CoAgentStateRenderHandlerArguments) => Promise<any>;\n\nexport type AssistantMessage = {\n id: string;\n role: \"assistant\";\n content: Array<{\n type: \"text\";\n text: {\n value: string;\n };\n }>;\n};\n\nexport type JSONValue =\n | null\n | string\n | number\n | boolean\n | { [x: string]: JSONValue }\n | Array<JSONValue>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/openai-assistant.ts"],"sourcesContent":["export interface FunctionDefinition {\n /**\n * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain\n * underscores and dashes, with a maximum length of 64.\n */\n name: string;\n /**\n * The parameters the functions accepts, described as a JSON Schema object. See the\n * [guide](/docs/guides/gpt/function-calling) for examples, and the\n * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for\n * documentation about the format.\n *\n * To describe a function that accepts no parameters, provide the value\n * `{\"type\": \"object\", \"properties\": {}}`.\n */\n parameters: Record<string, unknown>;\n /**\n * A description of what the function does, used by the model to choose when and\n * how to call the function.\n */\n description?: string;\n}\n\nexport interface ToolDefinition {\n type: \"function\";\n function: FunctionDefinition;\n}\n\nexport interface FunctionCallHandlerArguments {\n messages: any[];\n name: string;\n args: any;\n}\n\nexport type FunctionCallHandler = (\n args: FunctionCallHandlerArguments,\n) => Promise<any>;\n\nexport type CoAgentStateRenderHandlerArguments = {\n name: string;\n nodeName: string;\n state: any;\n};\n\nexport type CoAgentStateRenderHandler = (\n args: CoAgentStateRenderHandlerArguments,\n) => Promise<any>;\n\nexport type AssistantMessage = {\n id: string;\n role: \"assistant\";\n content: Array<{\n type: \"text\";\n text: {\n value: string;\n };\n }>;\n};\n\nexport type JSONValue =\n | null\n | string\n | number\n | boolean\n | { [x: string]: JSONValue }\n | Array<JSONValue>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/utils/conditions.js
CHANGED
|
@@ -35,11 +35,17 @@ function executeCondition(condition, value) {
|
|
|
35
35
|
const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
|
|
36
36
|
switch (condition.rule) {
|
|
37
37
|
case "AND":
|
|
38
|
-
return condition.conditions.every(
|
|
38
|
+
return condition.conditions.every(
|
|
39
|
+
(c) => executeCondition(c, value)
|
|
40
|
+
);
|
|
39
41
|
case "OR":
|
|
40
|
-
return condition.conditions.some(
|
|
42
|
+
return condition.conditions.some(
|
|
43
|
+
(c) => executeCondition(c, value)
|
|
44
|
+
);
|
|
41
45
|
case "NOT":
|
|
42
|
-
return !condition.conditions.every(
|
|
46
|
+
return !condition.conditions.every(
|
|
47
|
+
(c) => executeCondition(c, value)
|
|
48
|
+
);
|
|
43
49
|
case "EQUALS":
|
|
44
50
|
return targetValue === condition.value;
|
|
45
51
|
case "NOT_EQUALS":
|
|
@@ -53,11 +59,17 @@ function executeCondition(condition, value) {
|
|
|
53
59
|
case "NOT_CONTAINS":
|
|
54
60
|
return Array.isArray(targetValue) && !targetValue.includes(condition.value);
|
|
55
61
|
case "MATCHES":
|
|
56
|
-
return new RegExp(condition.value).test(
|
|
62
|
+
return new RegExp(condition.value).test(
|
|
63
|
+
String(targetValue)
|
|
64
|
+
);
|
|
57
65
|
case "STARTS_WITH":
|
|
58
|
-
return String(targetValue).startsWith(
|
|
66
|
+
return String(targetValue).startsWith(
|
|
67
|
+
condition.value
|
|
68
|
+
);
|
|
59
69
|
case "ENDS_WITH":
|
|
60
|
-
return String(targetValue).endsWith(
|
|
70
|
+
return String(targetValue).endsWith(
|
|
71
|
+
condition.value
|
|
72
|
+
);
|
|
61
73
|
case "EXISTS":
|
|
62
74
|
return targetValue !== void 0 && targetValue !== null;
|
|
63
75
|
case "NOT_EXISTS":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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
|
|
1
|
+
{"version":3,"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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAGY;AAEV,MAAI,EAAC,yCAAY;AAAQ,WAAO;AAGhC,SAAO,WAAW,MAAM,CAAC,cAAc,iBAAiB,WAAW,KAAK,CAAC;AAC3E;AAEA,SAAS,iBAAiB,WAAsB,OAAqB;AACnE,QAAM,cAAc,UAAU,OAC1B,iBAAiB,OAAO,UAAU,IAAI,IACtC;AAEJ,UAAQ,UAAU,MAAM;AAAA,IAEtB,KAAK;AACH,aAAQ,UAA+B,WAAW;AAAA,QAAM,CAAC,MACvD,iBAAiB,GAAG,KAAK;AAAA,MAC3B;AAAA,IACF,KAAK;AACH,aAAQ,UAA+B,WAAW;AAAA,QAAK,CAAC,MACtD,iBAAiB,GAAG,KAAK;AAAA,MAC3B;AAAA,IACF,KAAK;AACH,aAAO,CAAE,UAA+B,WAAW;AAAA,QAAM,CAAC,MACxD,iBAAiB,GAAG,KAAK;AAAA,MAC3B;AAAA,IAGF,KAAK;AACH,aAAO,gBAAiB,UAAkC;AAAA,IAC5D,KAAK;AACH,aAAO,gBAAiB,UAAkC;AAAA,IAC5D,KAAK;AACH,aAAO,cAAe,UAAkC;AAAA,IAC1D,KAAK;AACH,aAAO,cAAe,UAAkC;AAAA,IAC1D,KAAK;AACH,aACE,MAAM,QAAQ,WAAW,KACzB,YAAY,SAAU,UAAkC,KAAK;AAAA,IAEjE,KAAK;AACH,aACE,MAAM,QAAQ,WAAW,KACzB,CAAC,YAAY,SAAU,UAAkC,KAAK;AAAA,IAElE,KAAK;AACH,aAAO,IAAI,OAAQ,UAAkC,KAAK,EAAE;AAAA,QAC1D,OAAO,WAAW;AAAA,MACpB;AAAA,IACF,KAAK;AACH,aAAO,OAAO,WAAW,EAAE;AAAA,QACxB,UAAkC;AAAA,MACrC;AAAA,IACF,KAAK;AACH,aAAO,OAAO,WAAW,EAAE;AAAA,QACxB,UAAkC;AAAA,MACrC;AAAA,IAGF,KAAK;AACH,aAAO,gBAAgB,UAAa,gBAAgB;AAAA,IACtD,KAAK;AACH,aAAO,gBAAgB,UAAa,gBAAgB;AAAA,EACxD;AACF;AAEA,SAAS,iBAAiB,KAAU,MAAmB;AACrD,SAAO,KAAK,MAAM,GAAG,EAAE,OAAO,CAAC,KAAK,SAAS,2BAAM,OAAO,GAAG;AAC/D;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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. To enable this premium feature, add your public license key, available for free at:\n\n%chttps://cloud.copilotkit.ai%c\n\nAlternatively, useCopilotChat is available for basic programmatic control, and does not require an API key.\n\nTo learn more about premium features, read the documentation here:\n\n%chttps://docs.copilotkit.ai/premium%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 API key, available for free at https://cloud.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)
|
|
1
|
+
{"version":3,"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. To enable this premium feature, add your public license key, available for free at:\n\n%chttps://cloud.copilotkit.ai%c\n\nAlternatively, useCopilotChat is available for basic programmatic control, and does not require an API key.\n\nTo learn more about premium features, read the documentation here:\n\n%chttps://docs.copilotkit.ai/premium%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 API key, available for free at https://cloud.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: publicApiKeyR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C,cAAc,IAAI,CAAC;AAAA;AAAA,EAG5E,SAAS,CAAC,YACR,UAAU,YAAO,WAAW,CAAC,cAAc,SAAS,CAAC;AAAA;AAAA,EAGvD,KAAK,CAAC,YAAoB,UAAU,eAAQ,WAAW,CAAC,cAAc,GAAG,CAAC;AAAA;AAAA,EAG1E;AAAA;AAAA,EAGA;AACF;","names":[]}
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -205,7 +205,7 @@ declare class CopilotKitAgentDiscoveryError extends CopilotKitError {
|
|
|
205
205
|
* - Protocol/transport layer errors like SSL/TLS issues
|
|
206
206
|
*/
|
|
207
207
|
declare class CopilotKitLowLevelError extends CopilotKitError {
|
|
208
|
-
constructor({ error, url, message }: {
|
|
208
|
+
constructor({ error, url, message, }: {
|
|
209
209
|
error: Error;
|
|
210
210
|
url: string;
|
|
211
211
|
message?: string;
|
package/dist/utils/errors.js
CHANGED
|
@@ -46,7 +46,7 @@ module.exports = __toCommonJS(errors_exports);
|
|
|
46
46
|
var import_graphql = require("graphql");
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "1.51.4-next.
|
|
49
|
+
var version = "1.51.4-next.8";
|
|
50
50
|
|
|
51
51
|
// src/index.ts
|
|
52
52
|
var COPILOTKIT_VERSION = version;
|
|
@@ -299,7 +299,11 @@ ${seeMore}`;
|
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
var CopilotKitLowLevelError = class extends CopilotKitError {
|
|
302
|
-
constructor({
|
|
302
|
+
constructor({
|
|
303
|
+
error,
|
|
304
|
+
url,
|
|
305
|
+
message
|
|
306
|
+
}) {
|
|
303
307
|
let code = "NETWORK_ERROR" /* NETWORK_ERROR */;
|
|
304
308
|
const errorCode = error.code;
|
|
305
309
|
const errorMessage = message ?? resolveLowLevelErrorMessage({ errorCode, url });
|
|
@@ -379,7 +383,10 @@ async function getPossibleVersionMismatch({
|
|
|
379
383
|
}
|
|
380
384
|
return;
|
|
381
385
|
}
|
|
382
|
-
var resolveLowLevelErrorMessage = ({
|
|
386
|
+
var resolveLowLevelErrorMessage = ({
|
|
387
|
+
errorCode,
|
|
388
|
+
url
|
|
389
|
+
}) => {
|
|
383
390
|
const troubleshootingLink = ERROR_CONFIG["NETWORK_ERROR" /* NETWORK_ERROR */].troubleshootingUrl;
|
|
384
391
|
const genericMessage = (description = `Failed to fetch from url ${url}.`) => `${description}.
|
|
385
392
|
|
|
@@ -392,7 +399,9 @@ Possible reasons:
|
|
|
392
399
|
|
|
393
400
|
${getSeeMoreMarkdown(troubleshootingLink)}`;
|
|
394
401
|
if (url.includes("/info"))
|
|
395
|
-
return genericMessage(
|
|
402
|
+
return genericMessage(
|
|
403
|
+
`Failed to fetch CopilotKit agents/action information from url ${url}.`
|
|
404
|
+
);
|
|
396
405
|
if (url.includes("/actions/execute"))
|
|
397
406
|
return genericMessage(`Fetch call to ${url} to execute actions failed.`);
|
|
398
407
|
if (url.includes("/agents/state"))
|