@copilotkit/shared 1.5.15-next.3 → 1.5.15-next.5
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 +10 -0
- package/dist/chunk-HGLO5LDS.mjs +1 -0
- package/dist/chunk-PL5WNHFZ.mjs +50 -0
- package/dist/chunk-PL5WNHFZ.mjs.map +1 -0
- package/dist/chunk-VNNKZIFB.mjs +24 -0
- package/dist/chunk-VNNKZIFB.mjs.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +56 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utility.d.ts +4 -1
- package/dist/types/utility.js.map +1 -1
- package/dist/utils/conditions.d.ts +26 -0
- package/dist/utils/conditions.js +74 -0
- package/dist/utils/conditions.js.map +1 -0
- package/dist/utils/conditions.mjs +7 -0
- package/dist/utils/conditions.mjs.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +55 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +8 -2
- package/dist/utils/random-id.d.ts +2 -1
- package/dist/utils/random-id.js +7 -0
- package/dist/utils/random-id.js.map +1 -1
- package/dist/utils/random-id.mjs +3 -1
- package/package.json +1 -1
- package/src/types/utility.ts +1 -0
- package/src/utils/conditions.ts +98 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/random-id.ts +8 -1
- package/dist/chunk-53DC2JUS.mjs +0 -18
- package/dist/chunk-53DC2JUS.mjs.map +0 -1
- package/dist/chunk-GED6IT3S.mjs +0 -1
- /package/dist/{chunk-GED6IT3S.mjs.map → chunk-HGLO5LDS.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @copilotkit/shared
|
|
2
2
|
|
|
3
|
+
## 1.5.15-next.5
|
|
4
|
+
|
|
5
|
+
## 1.5.15-next.4
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- 7b3141d: - feat(interrupt): support LG interrupt with useLangGraphInterrupt hook
|
|
10
|
+
- chore(interrupt): add e2e test to interrupt functionality
|
|
11
|
+
- feat(interrupt): add support for multiple interrupts and conditions
|
|
12
|
+
|
|
3
13
|
## 1.5.15-next.3
|
|
4
14
|
|
|
5
15
|
## 1.5.15-next.2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-HGLO5LDS.mjs.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/utils/conditions.ts
|
|
2
|
+
function executeConditions({
|
|
3
|
+
conditions,
|
|
4
|
+
value
|
|
5
|
+
}) {
|
|
6
|
+
if (!(conditions == null ? void 0 : conditions.length))
|
|
7
|
+
return true;
|
|
8
|
+
return conditions.every((condition) => executeCondition(condition, value));
|
|
9
|
+
}
|
|
10
|
+
function executeCondition(condition, value) {
|
|
11
|
+
const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
|
|
12
|
+
switch (condition.rule) {
|
|
13
|
+
case "AND":
|
|
14
|
+
return condition.conditions.every((c) => executeCondition(c, value));
|
|
15
|
+
case "OR":
|
|
16
|
+
return condition.conditions.some((c) => executeCondition(c, value));
|
|
17
|
+
case "NOT":
|
|
18
|
+
return !condition.conditions.every((c) => executeCondition(c, value));
|
|
19
|
+
case "EQUALS":
|
|
20
|
+
return targetValue === condition.value;
|
|
21
|
+
case "NOT_EQUALS":
|
|
22
|
+
return targetValue !== condition.value;
|
|
23
|
+
case "GREATER_THAN":
|
|
24
|
+
return targetValue > condition.value;
|
|
25
|
+
case "LESS_THAN":
|
|
26
|
+
return targetValue < condition.value;
|
|
27
|
+
case "CONTAINS":
|
|
28
|
+
return Array.isArray(targetValue) && targetValue.includes(condition.value);
|
|
29
|
+
case "NOT_CONTAINS":
|
|
30
|
+
return Array.isArray(targetValue) && !targetValue.includes(condition.value);
|
|
31
|
+
case "MATCHES":
|
|
32
|
+
return new RegExp(condition.value).test(String(targetValue));
|
|
33
|
+
case "STARTS_WITH":
|
|
34
|
+
return String(targetValue).startsWith(condition.value);
|
|
35
|
+
case "ENDS_WITH":
|
|
36
|
+
return String(targetValue).endsWith(condition.value);
|
|
37
|
+
case "EXISTS":
|
|
38
|
+
return targetValue !== void 0 && targetValue !== null;
|
|
39
|
+
case "NOT_EXISTS":
|
|
40
|
+
return targetValue === void 0 || targetValue === null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function getValueFromPath(obj, path) {
|
|
44
|
+
return path.split(".").reduce((acc, part) => acc == null ? void 0 : acc[part], obj);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
executeConditions
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-PL5WNHFZ.mjs.map
|
|
@@ -0,0 +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 = ComparisonCondition | LogicalCondition | 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 ? getValueFromPath(value, condition.path) : value;\n\n switch (condition.rule) {\n // Logical\n case \"AND\":\n return (condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));\n case \"OR\":\n return (condition as LogicalCondition).conditions.some((c) => executeCondition(c, value));\n case \"NOT\":\n return !(condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));\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) && 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(String(targetValue));\n case \"STARTS_WITH\":\n return String(targetValue).startsWith((condition as ComparisonCondition).value);\n case \"ENDS_WITH\":\n return String(targetValue).endsWith((condition as ComparisonCondition).value);\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":";AAoCO,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,cAA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idv4, validate, v5 as uuidv5 } from "uuid";
|
|
3
|
+
function randomId() {
|
|
4
|
+
return "ck-" + uuidv4();
|
|
5
|
+
}
|
|
6
|
+
function randomUUID() {
|
|
7
|
+
return uuidv4();
|
|
8
|
+
}
|
|
9
|
+
function dataToUUID(input, namespace) {
|
|
10
|
+
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
|
|
11
|
+
const boundNamespace = namespace ? uuidv5(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
|
|
12
|
+
return uuidv5(input, boundNamespace);
|
|
13
|
+
}
|
|
14
|
+
function isValidUUID(uuid) {
|
|
15
|
+
return validate(uuid);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
randomId,
|
|
20
|
+
randomUUID,
|
|
21
|
+
dataToUUID,
|
|
22
|
+
isValidUUID
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-VNNKZIFB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/random-id.ts"],"sourcesContent":["import { v4 as uuidv4, validate, v5 as uuidv5 } from \"uuid\";\n\nexport function randomId() {\n return \"ck-\" + uuidv4();\n}\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function dataToUUID(input: string, namespace?: string): string {\n const BASE_NAMESPACE = \"e4b01160-ff74-4c6e-9b27-d53cd930fe8e\";\n // Since namespace needs to be a uuid, we are creating a uuid for it.\n const boundNamespace = namespace ? uuidv5(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;\n return uuidv5(input, boundNamespace);\n}\n\nexport function isValidUUID(uuid: string) {\n return validate(uuid);\n}\n"],"mappings":";AAAA,SAAS,MAAM,QAAQ,UAAU,MAAM,cAAc;AAE9C,SAAS,WAAW;AACzB,SAAO,QAAQ,OAAO;AACxB;AAEO,SAAS,aAAa;AAC3B,SAAO,OAAO;AAChB;AAEO,SAAS,WAAW,OAAe,WAA4B;AACpE,QAAM,iBAAiB;AAEvB,QAAM,iBAAiB,YAAY,OAAO,WAAW,cAAc,IAAI;AACvE,SAAO,OAAO,OAAO,cAAc;AACrC;AAEO,SAAS,YAAY,MAAc;AACxC,SAAO,SAAS,IAAI;AACtB;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { AssistantMessage, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, JSONValue, ToolDefinition } from './types/openai-assistant.js';
|
|
2
2
|
export { Action, MappedParameterTypes, Parameter } from './types/action.js';
|
|
3
3
|
export { CopilotCloudConfig } from './types/copilot-cloud-config.js';
|
|
4
|
-
export { PartialBy } from './types/utility.js';
|
|
4
|
+
export { PartialBy, RequiredBy } from './types/utility.js';
|
|
5
|
+
export { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions } from './utils/conditions.js';
|
|
5
6
|
export { ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, ERROR_CONFIG, ERROR_NAMES, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError } from './utils/errors.js';
|
|
6
7
|
export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema, convertJsonSchemaToZodSchema } from './utils/json-schema.js';
|
|
7
|
-
export { isValidUUID, randomId, randomUUID } from './utils/random-id.js';
|
|
8
|
+
export { dataToUUID, isValidUUID, randomId, randomUUID } from './utils/random-id.js';
|
|
8
9
|
export { COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION } from './constants/index.js';
|
|
9
10
|
export { TelemetryClient } from './telemetry/telemetry-client.js';
|
|
10
11
|
import 'graphql';
|
package/dist/index.js
CHANGED
|
@@ -52,12 +52,60 @@ __export(src_exports, {
|
|
|
52
52
|
UpgradeRequiredError: () => UpgradeRequiredError,
|
|
53
53
|
actionParametersToJsonSchema: () => actionParametersToJsonSchema,
|
|
54
54
|
convertJsonSchemaToZodSchema: () => convertJsonSchemaToZodSchema,
|
|
55
|
+
dataToUUID: () => dataToUUID,
|
|
56
|
+
executeConditions: () => executeConditions,
|
|
55
57
|
isValidUUID: () => isValidUUID,
|
|
56
58
|
randomId: () => randomId,
|
|
57
59
|
randomUUID: () => randomUUID
|
|
58
60
|
});
|
|
59
61
|
module.exports = __toCommonJS(src_exports);
|
|
60
62
|
|
|
63
|
+
// src/utils/conditions.ts
|
|
64
|
+
function executeConditions({
|
|
65
|
+
conditions,
|
|
66
|
+
value
|
|
67
|
+
}) {
|
|
68
|
+
if (!(conditions == null ? void 0 : conditions.length))
|
|
69
|
+
return true;
|
|
70
|
+
return conditions.every((condition) => executeCondition(condition, value));
|
|
71
|
+
}
|
|
72
|
+
function executeCondition(condition, value) {
|
|
73
|
+
const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
|
|
74
|
+
switch (condition.rule) {
|
|
75
|
+
case "AND":
|
|
76
|
+
return condition.conditions.every((c) => executeCondition(c, value));
|
|
77
|
+
case "OR":
|
|
78
|
+
return condition.conditions.some((c) => executeCondition(c, value));
|
|
79
|
+
case "NOT":
|
|
80
|
+
return !condition.conditions.every((c) => executeCondition(c, value));
|
|
81
|
+
case "EQUALS":
|
|
82
|
+
return targetValue === condition.value;
|
|
83
|
+
case "NOT_EQUALS":
|
|
84
|
+
return targetValue !== condition.value;
|
|
85
|
+
case "GREATER_THAN":
|
|
86
|
+
return targetValue > condition.value;
|
|
87
|
+
case "LESS_THAN":
|
|
88
|
+
return targetValue < condition.value;
|
|
89
|
+
case "CONTAINS":
|
|
90
|
+
return Array.isArray(targetValue) && targetValue.includes(condition.value);
|
|
91
|
+
case "NOT_CONTAINS":
|
|
92
|
+
return Array.isArray(targetValue) && !targetValue.includes(condition.value);
|
|
93
|
+
case "MATCHES":
|
|
94
|
+
return new RegExp(condition.value).test(String(targetValue));
|
|
95
|
+
case "STARTS_WITH":
|
|
96
|
+
return String(targetValue).startsWith(condition.value);
|
|
97
|
+
case "ENDS_WITH":
|
|
98
|
+
return String(targetValue).endsWith(condition.value);
|
|
99
|
+
case "EXISTS":
|
|
100
|
+
return targetValue !== void 0 && targetValue !== null;
|
|
101
|
+
case "NOT_EXISTS":
|
|
102
|
+
return targetValue === void 0 || targetValue === null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function getValueFromPath(obj, path) {
|
|
106
|
+
return path.split(".").reduce((acc, part) => acc == null ? void 0 : acc[part], obj);
|
|
107
|
+
}
|
|
108
|
+
|
|
61
109
|
// src/utils/errors.ts
|
|
62
110
|
var import_graphql = require("graphql");
|
|
63
111
|
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
@@ -396,6 +444,11 @@ function randomId() {
|
|
|
396
444
|
function randomUUID() {
|
|
397
445
|
return (0, import_uuid.v4)();
|
|
398
446
|
}
|
|
447
|
+
function dataToUUID(input, namespace) {
|
|
448
|
+
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
|
|
449
|
+
const boundNamespace = namespace ? (0, import_uuid.v5)(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
|
|
450
|
+
return (0, import_uuid.v5)(input, boundNamespace);
|
|
451
|
+
}
|
|
399
452
|
function isValidUUID(uuid) {
|
|
400
453
|
return (0, import_uuid.validate)(uuid);
|
|
401
454
|
}
|
|
@@ -511,7 +564,7 @@ var TelemetryClient = class {
|
|
|
511
564
|
};
|
|
512
565
|
|
|
513
566
|
// package.json
|
|
514
|
-
var version = "1.5.15-next.
|
|
567
|
+
var version = "1.5.15-next.5";
|
|
515
568
|
|
|
516
569
|
// src/index.ts
|
|
517
570
|
var COPILOTKIT_VERSION = version;
|
|
@@ -539,6 +592,8 @@ var COPILOTKIT_VERSION = version;
|
|
|
539
592
|
UpgradeRequiredError,
|
|
540
593
|
actionParametersToJsonSchema,
|
|
541
594
|
convertJsonSchemaToZodSchema,
|
|
595
|
+
dataToUUID,
|
|
596
|
+
executeConditions,
|
|
542
597
|
isValidUUID,
|
|
543
598
|
randomId,
|
|
544
599
|
randomUUID
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/errors.ts","../src/utils/json-schema.ts","../src/utils/random-id.ts","../src/constants/index.ts","../src/telemetry/telemetry-client.ts","../src/telemetry/utils.ts","../package.json"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n","import { GraphQLError } from \"graphql\";\n\nexport enum Severity {\n Error = \"error\",\n}\n\nexport const ERROR_NAMES = {\n COPILOT_ERROR: \"CopilotError\",\n COPILOT_API_DISCOVERY_ERROR: \"CopilotApiDiscoveryError\",\n COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: \"CopilotKitRemoteEndpointDiscoveryError\",\n COPILOT_KIT_AGENT_DISCOVERY_ERROR: \"CopilotKitAgentDiscoveryError\",\n COPILOT_KIT_LOW_LEVEL_ERROR: \"CopilotKitLowLevelError\",\n RESOLVED_COPILOT_KIT_ERROR: \"ResolvedCopilotKitError\",\n CONFIGURATION_ERROR: \"ConfigurationError\",\n MISSING_PUBLIC_API_KEY_ERROR: \"MissingPublicApiKeyError\",\n UPGRADE_REQUIRED_ERROR: \"UpgradeRequiredError\",\n} as const;\n\nexport enum CopilotKitErrorCode {\n NETWORK_ERROR = \"NETWORK_ERROR\",\n NOT_FOUND = \"NOT_FOUND\",\n AGENT_NOT_FOUND = \"AGENT_NOT_FOUND\",\n API_NOT_FOUND = \"API_NOT_FOUND\",\n REMOTE_ENDPOINT_NOT_FOUND = \"REMOTE_ENDPOINT_NOT_FOUND\",\n MISUSE = \"MISUSE\",\n UNKNOWN = \"UNKNOWN\",\n CONFIGURATION_ERROR = \"CONFIGURATION_ERROR\",\n MISSING_PUBLIC_API_KEY_ERROR = \"MISSING_PUBLIC_API_KEY_ERROR\",\n UPGRADE_REQUIRED_ERROR = \"UPGRADE_REQUIRED_ERROR\",\n}\n\nconst BASE_URL = \"https://docs.copilotkit.ai\";\n\nconst getSeeMoreMarkdown = (link: string) => `See more: [${link}](${link})`;\n\nexport const ERROR_CONFIG = {\n [CopilotKitErrorCode.NETWORK_ERROR]: {\n statusCode: 503,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,\n },\n [CopilotKitErrorCode.API_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,\n },\n [CopilotKitErrorCode.MISUSE]: {\n statusCode: 400,\n troubleshootingUrl: null,\n },\n [CopilotKitErrorCode.UNKNOWN]: {\n statusCode: 500,\n },\n [CopilotKitErrorCode.CONFIGURATION_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR]: {\n statusCode: 402,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n};\n\nexport class CopilotKitError extends GraphQLError {\n code: CopilotKitErrorCode;\n statusCode: number;\n severity?: Severity;\n constructor({\n message = \"Unknown error occurred\",\n code,\n severity,\n }: {\n message?: string;\n code: CopilotKitErrorCode;\n severity?: Severity;\n }) {\n const name = ERROR_NAMES.COPILOT_ERROR;\n const { statusCode } = ERROR_CONFIG[code];\n\n super(message, {\n extensions: {\n name,\n statusCode,\n },\n });\n this.code = code;\n this.name = name;\n this.statusCode = statusCode;\n this.severity = severity;\n }\n}\n\n/**\n * Error thrown when we can identify wrong usage of our components.\n * This helps us notify the developer before real errors can happen\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitMisuseError extends CopilotKitError {\n constructor({\n message,\n code = CopilotKitErrorCode.MISUSE,\n }: {\n message: string;\n code?: CopilotKitErrorCode;\n }) {\n const docsLink =\n \"troubleshootingUrl\" in ERROR_CONFIG[code]\n ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl as string)\n : null;\n const finalMessage = docsLink ? `${message}.\\n\\n${docsLink}` : message;\n super({ message: finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n * - There are network/firewall issues preventing access\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitApiDiscoveryError extends CopilotKitError {\n constructor(\n params: {\n message?: string;\n code?: CopilotKitErrorCode.API_NOT_FOUND | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n } = {},\n ) {\n const message = params.message ?? \"Failed to find CopilotKit API endpoint\";\n const code = params.code ?? CopilotKitErrorCode.API_NOT_FOUND;\n const errorMessage = `${message}.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: errorMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * This error is used for endpoints specified in runtime's remote endpoints. If they cannot be contacted\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n *\n * @extends CopilotKitApiDiscoveryError\n */\nexport class CopilotKitRemoteEndpointDiscoveryError extends CopilotKitApiDiscoveryError {\n constructor(params?: { message?: string }) {\n const message = params?.message ?? \"Failed to find or contact remote endpoint\";\n const code = CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n super({ message, code });\n this.name = ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when a LangGraph agent cannot be found or accessed.\n * This typically occurs when:\n * - The specified agent name does not exist in the deployment\n * - The agent configuration is invalid or missing\n * - The agent service is not properly deployed or initialized\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitAgentDiscoveryError extends CopilotKitError {\n constructor(params?: { agentName?: string }) {\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n const baseMessage = \"Failed to find agent\";\n const configMessage = \"Please verify the agent name exists and is properly configured.\";\n const finalMessage = params?.agentName\n ? `${baseMessage} '${params.agentName}'. ${configMessage}\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`\n : `${baseMessage}. ${configMessage}\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: finalMessage || finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Handles low-level networking errors that occur before a request reaches the server.\n * These errors arise from issues in the underlying communication infrastructure rather than\n * application-level logic or server responses. Typically used to handle \"fetch failed\" errors\n * where no HTTP status code is available.\n *\n * Common scenarios include:\n * - Connection failures (ECONNREFUSED) when server is down/unreachable\n * - DNS resolution failures (ENOTFOUND) when domain can't be resolved\n * - Timeouts (ETIMEDOUT) when request takes too long\n * - Protocol/transport layer errors like SSL/TLS issues\n */\nexport class CopilotKitLowLevelError extends CopilotKitError {\n constructor({ error, url, message }: { error: Error; url: string; message?: string }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n const getMessageByCode = (errorCode?: string) => {\n const troubleshootingLink = ERROR_CONFIG[code].troubleshootingUrl;\n switch (errorCode) {\n case \"ECONNREFUSED\":\n return `Connection to ${url} was refused. Ensure the server is running and accessible.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n case \"ENOTFOUND\":\n return `The server on ${url} could not be found. Check the URL or your network configuration.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[CopilotKitErrorCode.NOT_FOUND].troubleshootingUrl)}`;\n case \"ETIMEDOUT\":\n return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n default:\n return `Failed to fetch from url ${url}.\n\nPossible reasons:\n- -The server might be down or unreachable\n- -There might be a network issue (e.g., DNS failure, connection timeout) \n- -The URL might be incorrect\n- -The server is not running on the specified port\n\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n }\n };\n // @ts-expect-error -- code may exist\n const errorMessage = message ?? getMessageByCode(error.code as string);\n\n super({ message: errorMessage, code });\n\n this.name = ERROR_NAMES.COPILOT_KIT_LOW_LEVEL_ERROR;\n }\n}\n\n/**\n * Generic catch-all error handler for HTTP responses from the CopilotKit API where a status code is available.\n * Used when we receive an HTTP error status and wish to handle broad range of them\n *\n * This differs from CopilotKitLowLevelError in that:\n * - ResolvedCopilotKitError: Server was reached and returned an HTTP status\n * - CopilotKitLowLevelError: Error occurred before reaching server (e.g. network failure)\n *\n * @param status - The HTTP status code received from the API response\n * @param message - Optional error message to include\n * @param code - Optional specific CopilotKitErrorCode to override default behavior\n *\n * Default behavior:\n * - 400 Bad Request: Maps to CopilotKitApiDiscoveryError\n * - All other status codes: Maps to UNKNOWN error code if no specific code provided\n */\nexport class ResolvedCopilotKitError extends CopilotKitError {\n constructor({\n status,\n message,\n code,\n isRemoteEndpoint,\n }: {\n status: number;\n message?: string;\n code?: CopilotKitErrorCode;\n isRemoteEndpoint?: boolean;\n }) {\n let resolvedCode = code;\n if (!resolvedCode) {\n switch (status) {\n case 400:\n throw new CopilotKitApiDiscoveryError({ message });\n case 404:\n throw isRemoteEndpoint\n ? new CopilotKitRemoteEndpointDiscoveryError({ message })\n : new CopilotKitApiDiscoveryError({ message });\n default:\n resolvedCode = CopilotKitErrorCode.UNKNOWN;\n super({ message, code: resolvedCode });\n }\n } else {\n super({ message, code: resolvedCode });\n }\n this.name = ERROR_NAMES.RESOLVED_COPILOT_KIT_ERROR;\n }\n}\n\nexport class ConfigurationError extends CopilotKitError {\n constructor(message: string) {\n super({ message, code: CopilotKitErrorCode.CONFIGURATION_ERROR });\n this.name = ERROR_NAMES.CONFIGURATION_ERROR;\n this.severity = Severity.Error;\n }\n}\n\nexport class MissingPublicApiKeyError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR;\n this.severity = Severity.Error;\n }\n}\n\nexport class UpgradeRequiredError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.UPGRADE_REQUIRED_ERROR;\n this.severity = Severity.Error;\n }\n}\n","import { z } from \"zod\";\nimport { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n\nexport function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean): z.ZodSchema {\n if (jsonSchema.type === \"object\") {\n const spec: { [key: string]: z.ZodSchema } = {};\n\n if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {\n return !required ? z.object(spec).optional() : z.object(spec);\n }\n\n for (const [key, value] of Object.entries(jsonSchema.properties)) {\n spec[key] = convertJsonSchemaToZodSchema(\n value,\n jsonSchema.required ? jsonSchema.required.includes(key) : false,\n );\n }\n let schema = z.object(spec).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n let schema = z.string().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\") {\n let schema = z.number().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"boolean\") {\n let schema = z.boolean().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"array\") {\n let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);\n let schema = z.array(itemSchema).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n throw new Error(\"Invalid JSON schema\");\n}\n","import { v4 as uuidv4, validate } from \"uuid\";\n\nexport function randomId() {\n return \"ck-\" + uuidv4();\n}\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function isValidUUID(uuid: string) {\n return validate(uuid);\n}\n","export const COPILOT_CLOUD_API_URL = \"https://api.cloud.copilotkit.ai\";\nexport const COPILOT_CLOUD_VERSION = \"v1\";\nexport const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;\nexport const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = \"X-CopilotCloud-Public-Api-Key\";\n","import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject, printSecurityNotice } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\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 =\n telemetryDisabled ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as any).DO_NOT_TRACK === \"true\" ||\n (process.env as any).DO_NOT_TRACK === \"1\";\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\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 });\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.5.15-next.3\",\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 \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean\",\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 },\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 \"zod-to-json-schema\": \"^3.23.5\"\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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A,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,IACvC,CAAC;AAAA,EACH;AACF;;;AElHE,cAAW;;;APLN,IAAM,qBAAiC;","names":["Severity","CopilotKitErrorCode","uuidv4","import_uuid","uuidv4"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/conditions.ts","../src/utils/errors.ts","../src/utils/json-schema.ts","../src/utils/random-id.ts","../src/constants/index.ts","../src/telemetry/telemetry-client.ts","../src/telemetry/utils.ts","../package.json"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n","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 = ComparisonCondition | LogicalCondition | 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 ? getValueFromPath(value, condition.path) : value;\n\n switch (condition.rule) {\n // Logical\n case \"AND\":\n return (condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));\n case \"OR\":\n return (condition as LogicalCondition).conditions.some((c) => executeCondition(c, value));\n case \"NOT\":\n return !(condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));\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) && 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(String(targetValue));\n case \"STARTS_WITH\":\n return String(targetValue).startsWith((condition as ComparisonCondition).value);\n case \"ENDS_WITH\":\n return String(targetValue).endsWith((condition as ComparisonCondition).value);\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","import { GraphQLError } from \"graphql\";\n\nexport enum Severity {\n Error = \"error\",\n}\n\nexport const ERROR_NAMES = {\n COPILOT_ERROR: \"CopilotError\",\n COPILOT_API_DISCOVERY_ERROR: \"CopilotApiDiscoveryError\",\n COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: \"CopilotKitRemoteEndpointDiscoveryError\",\n COPILOT_KIT_AGENT_DISCOVERY_ERROR: \"CopilotKitAgentDiscoveryError\",\n COPILOT_KIT_LOW_LEVEL_ERROR: \"CopilotKitLowLevelError\",\n RESOLVED_COPILOT_KIT_ERROR: \"ResolvedCopilotKitError\",\n CONFIGURATION_ERROR: \"ConfigurationError\",\n MISSING_PUBLIC_API_KEY_ERROR: \"MissingPublicApiKeyError\",\n UPGRADE_REQUIRED_ERROR: \"UpgradeRequiredError\",\n} as const;\n\nexport enum CopilotKitErrorCode {\n NETWORK_ERROR = \"NETWORK_ERROR\",\n NOT_FOUND = \"NOT_FOUND\",\n AGENT_NOT_FOUND = \"AGENT_NOT_FOUND\",\n API_NOT_FOUND = \"API_NOT_FOUND\",\n REMOTE_ENDPOINT_NOT_FOUND = \"REMOTE_ENDPOINT_NOT_FOUND\",\n MISUSE = \"MISUSE\",\n UNKNOWN = \"UNKNOWN\",\n CONFIGURATION_ERROR = \"CONFIGURATION_ERROR\",\n MISSING_PUBLIC_API_KEY_ERROR = \"MISSING_PUBLIC_API_KEY_ERROR\",\n UPGRADE_REQUIRED_ERROR = \"UPGRADE_REQUIRED_ERROR\",\n}\n\nconst BASE_URL = \"https://docs.copilotkit.ai\";\n\nconst getSeeMoreMarkdown = (link: string) => `See more: [${link}](${link})`;\n\nexport const ERROR_CONFIG = {\n [CopilotKitErrorCode.NETWORK_ERROR]: {\n statusCode: 503,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,\n },\n [CopilotKitErrorCode.API_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,\n },\n [CopilotKitErrorCode.MISUSE]: {\n statusCode: 400,\n troubleshootingUrl: null,\n },\n [CopilotKitErrorCode.UNKNOWN]: {\n statusCode: 500,\n },\n [CopilotKitErrorCode.CONFIGURATION_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR]: {\n statusCode: 402,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n};\n\nexport class CopilotKitError extends GraphQLError {\n code: CopilotKitErrorCode;\n statusCode: number;\n severity?: Severity;\n constructor({\n message = \"Unknown error occurred\",\n code,\n severity,\n }: {\n message?: string;\n code: CopilotKitErrorCode;\n severity?: Severity;\n }) {\n const name = ERROR_NAMES.COPILOT_ERROR;\n const { statusCode } = ERROR_CONFIG[code];\n\n super(message, {\n extensions: {\n name,\n statusCode,\n },\n });\n this.code = code;\n this.name = name;\n this.statusCode = statusCode;\n this.severity = severity;\n }\n}\n\n/**\n * Error thrown when we can identify wrong usage of our components.\n * This helps us notify the developer before real errors can happen\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitMisuseError extends CopilotKitError {\n constructor({\n message,\n code = CopilotKitErrorCode.MISUSE,\n }: {\n message: string;\n code?: CopilotKitErrorCode;\n }) {\n const docsLink =\n \"troubleshootingUrl\" in ERROR_CONFIG[code]\n ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl as string)\n : null;\n const finalMessage = docsLink ? `${message}.\\n\\n${docsLink}` : message;\n super({ message: finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n * - There are network/firewall issues preventing access\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitApiDiscoveryError extends CopilotKitError {\n constructor(\n params: {\n message?: string;\n code?: CopilotKitErrorCode.API_NOT_FOUND | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n } = {},\n ) {\n const message = params.message ?? \"Failed to find CopilotKit API endpoint\";\n const code = params.code ?? CopilotKitErrorCode.API_NOT_FOUND;\n const errorMessage = `${message}.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: errorMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * This error is used for endpoints specified in runtime's remote endpoints. If they cannot be contacted\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n *\n * @extends CopilotKitApiDiscoveryError\n */\nexport class CopilotKitRemoteEndpointDiscoveryError extends CopilotKitApiDiscoveryError {\n constructor(params?: { message?: string }) {\n const message = params?.message ?? \"Failed to find or contact remote endpoint\";\n const code = CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n super({ message, code });\n this.name = ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when a LangGraph agent cannot be found or accessed.\n * This typically occurs when:\n * - The specified agent name does not exist in the deployment\n * - The agent configuration is invalid or missing\n * - The agent service is not properly deployed or initialized\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitAgentDiscoveryError extends CopilotKitError {\n constructor(params?: { agentName?: string }) {\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n const baseMessage = \"Failed to find agent\";\n const configMessage = \"Please verify the agent name exists and is properly configured.\";\n const finalMessage = params?.agentName\n ? `${baseMessage} '${params.agentName}'. ${configMessage}\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`\n : `${baseMessage}. ${configMessage}\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: finalMessage || finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Handles low-level networking errors that occur before a request reaches the server.\n * These errors arise from issues in the underlying communication infrastructure rather than\n * application-level logic or server responses. Typically used to handle \"fetch failed\" errors\n * where no HTTP status code is available.\n *\n * Common scenarios include:\n * - Connection failures (ECONNREFUSED) when server is down/unreachable\n * - DNS resolution failures (ENOTFOUND) when domain can't be resolved\n * - Timeouts (ETIMEDOUT) when request takes too long\n * - Protocol/transport layer errors like SSL/TLS issues\n */\nexport class CopilotKitLowLevelError extends CopilotKitError {\n constructor({ error, url, message }: { error: Error; url: string; message?: string }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n const getMessageByCode = (errorCode?: string) => {\n const troubleshootingLink = ERROR_CONFIG[code].troubleshootingUrl;\n switch (errorCode) {\n case \"ECONNREFUSED\":\n return `Connection to ${url} was refused. Ensure the server is running and accessible.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n case \"ENOTFOUND\":\n return `The server on ${url} could not be found. Check the URL or your network configuration.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[CopilotKitErrorCode.NOT_FOUND].troubleshootingUrl)}`;\n case \"ETIMEDOUT\":\n return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n default:\n return `Failed to fetch from url ${url}.\n\nPossible reasons:\n- -The server might be down or unreachable\n- -There might be a network issue (e.g., DNS failure, connection timeout) \n- -The URL might be incorrect\n- -The server is not running on the specified port\n\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n }\n };\n // @ts-expect-error -- code may exist\n const errorMessage = message ?? getMessageByCode(error.code as string);\n\n super({ message: errorMessage, code });\n\n this.name = ERROR_NAMES.COPILOT_KIT_LOW_LEVEL_ERROR;\n }\n}\n\n/**\n * Generic catch-all error handler for HTTP responses from the CopilotKit API where a status code is available.\n * Used when we receive an HTTP error status and wish to handle broad range of them\n *\n * This differs from CopilotKitLowLevelError in that:\n * - ResolvedCopilotKitError: Server was reached and returned an HTTP status\n * - CopilotKitLowLevelError: Error occurred before reaching server (e.g. network failure)\n *\n * @param status - The HTTP status code received from the API response\n * @param message - Optional error message to include\n * @param code - Optional specific CopilotKitErrorCode to override default behavior\n *\n * Default behavior:\n * - 400 Bad Request: Maps to CopilotKitApiDiscoveryError\n * - All other status codes: Maps to UNKNOWN error code if no specific code provided\n */\nexport class ResolvedCopilotKitError extends CopilotKitError {\n constructor({\n status,\n message,\n code,\n isRemoteEndpoint,\n }: {\n status: number;\n message?: string;\n code?: CopilotKitErrorCode;\n isRemoteEndpoint?: boolean;\n }) {\n let resolvedCode = code;\n if (!resolvedCode) {\n switch (status) {\n case 400:\n throw new CopilotKitApiDiscoveryError({ message });\n case 404:\n throw isRemoteEndpoint\n ? new CopilotKitRemoteEndpointDiscoveryError({ message })\n : new CopilotKitApiDiscoveryError({ message });\n default:\n resolvedCode = CopilotKitErrorCode.UNKNOWN;\n super({ message, code: resolvedCode });\n }\n } else {\n super({ message, code: resolvedCode });\n }\n this.name = ERROR_NAMES.RESOLVED_COPILOT_KIT_ERROR;\n }\n}\n\nexport class ConfigurationError extends CopilotKitError {\n constructor(message: string) {\n super({ message, code: CopilotKitErrorCode.CONFIGURATION_ERROR });\n this.name = ERROR_NAMES.CONFIGURATION_ERROR;\n this.severity = Severity.Error;\n }\n}\n\nexport class MissingPublicApiKeyError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR;\n this.severity = Severity.Error;\n }\n}\n\nexport class UpgradeRequiredError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.UPGRADE_REQUIRED_ERROR;\n this.severity = Severity.Error;\n }\n}\n","import { z } from \"zod\";\nimport { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n\nexport function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean): z.ZodSchema {\n if (jsonSchema.type === \"object\") {\n const spec: { [key: string]: z.ZodSchema } = {};\n\n if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {\n return !required ? z.object(spec).optional() : z.object(spec);\n }\n\n for (const [key, value] of Object.entries(jsonSchema.properties)) {\n spec[key] = convertJsonSchemaToZodSchema(\n value,\n jsonSchema.required ? jsonSchema.required.includes(key) : false,\n );\n }\n let schema = z.object(spec).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n let schema = z.string().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\") {\n let schema = z.number().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"boolean\") {\n let schema = z.boolean().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"array\") {\n let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);\n let schema = z.array(itemSchema).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n throw new Error(\"Invalid JSON schema\");\n}\n","import { v4 as uuidv4, validate, v5 as uuidv5 } from \"uuid\";\n\nexport function randomId() {\n return \"ck-\" + uuidv4();\n}\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function dataToUUID(input: string, namespace?: string): string {\n const BASE_NAMESPACE = \"e4b01160-ff74-4c6e-9b27-d53cd930fe8e\";\n // Since namespace needs to be a uuid, we are creating a uuid for it.\n const boundNamespace = namespace ? uuidv5(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;\n return uuidv5(input, boundNamespace);\n}\n\nexport function isValidUUID(uuid: string) {\n return validate(uuid);\n}\n","export const COPILOT_CLOUD_API_URL = \"https://api.cloud.copilotkit.ai\";\nexport const COPILOT_CLOUD_VERSION = \"v1\";\nexport const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;\nexport const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = \"X-CopilotCloud-Public-Api-Key\";\n","import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject, printSecurityNotice } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\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 =\n telemetryDisabled ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as any).DO_NOT_TRACK === \"true\" ||\n (process.env as any).DO_NOT_TRACK === \"1\";\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\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 });\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.5.15-next.5\",\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 \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean\",\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 },\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 \"zod-to-json-schema\": \"^3.23.5\"\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoCO,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,SA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AG,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,IACvC,CAAC;AAAA,EACH;AACF;;;AElHE,cAAW;;;ARLN,IAAM,qBAAiC;","names":["Severity","CopilotKitErrorCode","uuidv4","uuidv5","import_uuid","uuidv4"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,12 +2,16 @@ import "./chunk-BANDZXMP.mjs";
|
|
|
2
2
|
import "./chunk-MSUB6DGR.mjs";
|
|
3
3
|
import "./chunk-IAFBVORQ.mjs";
|
|
4
4
|
import "./chunk-FCCOSO5L.mjs";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-HGLO5LDS.mjs";
|
|
6
6
|
import {
|
|
7
|
+
dataToUUID,
|
|
7
8
|
isValidUUID,
|
|
8
9
|
randomId,
|
|
9
10
|
randomUUID
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VNNKZIFB.mjs";
|
|
12
|
+
import {
|
|
13
|
+
executeConditions
|
|
14
|
+
} from "./chunk-PL5WNHFZ.mjs";
|
|
11
15
|
import {
|
|
12
16
|
ConfigurationError,
|
|
13
17
|
CopilotKitAgentDiscoveryError,
|
|
@@ -42,7 +46,7 @@ import "./chunk-6QGXWNS5.mjs";
|
|
|
42
46
|
import "./chunk-NAFEBKSO.mjs";
|
|
43
47
|
|
|
44
48
|
// package.json
|
|
45
|
-
var version = "1.5.15-next.
|
|
49
|
+
var version = "1.5.15-next.5";
|
|
46
50
|
|
|
47
51
|
// src/index.ts
|
|
48
52
|
var COPILOTKIT_VERSION = version;
|
|
@@ -69,6 +73,8 @@ export {
|
|
|
69
73
|
UpgradeRequiredError,
|
|
70
74
|
actionParametersToJsonSchema,
|
|
71
75
|
convertJsonSchemaToZodSchema,
|
|
76
|
+
dataToUUID,
|
|
77
|
+
executeConditions,
|
|
72
78
|
isValidUUID,
|
|
73
79
|
randomId,
|
|
74
80
|
randomUUID
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\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.5.15-next.
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\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.5.15-next.5\",\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 \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean\",\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 },\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 \"zod-to-json-schema\": \"^3.23.5\"\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","export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWE,cAAW;;;ACLN,IAAM,qBAAiC;","names":[]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { AssistantMessage, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, JSONValue, ToolDefinition } from './openai-assistant.js';
|
|
2
2
|
export { Action, MappedParameterTypes, Parameter } from './action.js';
|
|
3
3
|
export { CopilotCloudConfig } from './copilot-cloud-config.js';
|
|
4
|
-
export { PartialBy } from './utility.js';
|
|
4
|
+
export { PartialBy, RequiredBy } from './utility.js';
|
package/dist/types/utility.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/utility.ts"],"sourcesContent":["export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/utility.ts"],"sourcesContent":["export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\nexport type RequiredBy<T, K extends keyof T> = T & { [P in K]-?: T[P] };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type ComparisonRule = "EQUALS" | "NOT_EQUALS" | "GREATER_THAN" | "LESS_THAN" | "CONTAINS" | "NOT_CONTAINS" | "MATCHES" | "STARTS_WITH" | "ENDS_WITH";
|
|
2
|
+
type LogicalRule = "AND" | "OR" | "NOT";
|
|
3
|
+
type ExistenceRule = "EXISTS" | "NOT_EXISTS";
|
|
4
|
+
type Rule = ComparisonRule | LogicalRule | ExistenceRule;
|
|
5
|
+
interface BaseCondition {
|
|
6
|
+
rule: Rule;
|
|
7
|
+
path?: string;
|
|
8
|
+
}
|
|
9
|
+
interface ComparisonCondition extends BaseCondition {
|
|
10
|
+
rule: ComparisonRule;
|
|
11
|
+
value: any;
|
|
12
|
+
}
|
|
13
|
+
interface LogicalCondition extends BaseCondition {
|
|
14
|
+
rule: LogicalRule;
|
|
15
|
+
conditions: Condition[];
|
|
16
|
+
}
|
|
17
|
+
interface ExistenceCondition extends BaseCondition {
|
|
18
|
+
rule: ExistenceRule;
|
|
19
|
+
}
|
|
20
|
+
type Condition = ComparisonCondition | LogicalCondition | ExistenceCondition;
|
|
21
|
+
declare function executeConditions({ conditions, value, }: {
|
|
22
|
+
conditions?: Condition[];
|
|
23
|
+
value: any;
|
|
24
|
+
}): boolean;
|
|
25
|
+
|
|
26
|
+
export { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/conditions.ts
|
|
21
|
+
var conditions_exports = {};
|
|
22
|
+
__export(conditions_exports, {
|
|
23
|
+
executeConditions: () => executeConditions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(conditions_exports);
|
|
26
|
+
function executeConditions({
|
|
27
|
+
conditions,
|
|
28
|
+
value
|
|
29
|
+
}) {
|
|
30
|
+
if (!(conditions == null ? void 0 : conditions.length))
|
|
31
|
+
return true;
|
|
32
|
+
return conditions.every((condition) => executeCondition(condition, value));
|
|
33
|
+
}
|
|
34
|
+
function executeCondition(condition, value) {
|
|
35
|
+
const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
|
|
36
|
+
switch (condition.rule) {
|
|
37
|
+
case "AND":
|
|
38
|
+
return condition.conditions.every((c) => executeCondition(c, value));
|
|
39
|
+
case "OR":
|
|
40
|
+
return condition.conditions.some((c) => executeCondition(c, value));
|
|
41
|
+
case "NOT":
|
|
42
|
+
return !condition.conditions.every((c) => executeCondition(c, value));
|
|
43
|
+
case "EQUALS":
|
|
44
|
+
return targetValue === condition.value;
|
|
45
|
+
case "NOT_EQUALS":
|
|
46
|
+
return targetValue !== condition.value;
|
|
47
|
+
case "GREATER_THAN":
|
|
48
|
+
return targetValue > condition.value;
|
|
49
|
+
case "LESS_THAN":
|
|
50
|
+
return targetValue < condition.value;
|
|
51
|
+
case "CONTAINS":
|
|
52
|
+
return Array.isArray(targetValue) && targetValue.includes(condition.value);
|
|
53
|
+
case "NOT_CONTAINS":
|
|
54
|
+
return Array.isArray(targetValue) && !targetValue.includes(condition.value);
|
|
55
|
+
case "MATCHES":
|
|
56
|
+
return new RegExp(condition.value).test(String(targetValue));
|
|
57
|
+
case "STARTS_WITH":
|
|
58
|
+
return String(targetValue).startsWith(condition.value);
|
|
59
|
+
case "ENDS_WITH":
|
|
60
|
+
return String(targetValue).endsWith(condition.value);
|
|
61
|
+
case "EXISTS":
|
|
62
|
+
return targetValue !== void 0 && targetValue !== null;
|
|
63
|
+
case "NOT_EXISTS":
|
|
64
|
+
return targetValue === void 0 || targetValue === null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function getValueFromPath(obj, path) {
|
|
68
|
+
return path.split(".").reduce((acc, part) => acc == null ? void 0 : acc[part], obj);
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
executeConditions
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +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 = ComparisonCondition | LogicalCondition | 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 ? getValueFromPath(value, condition.path) : value;\n\n switch (condition.rule) {\n // Logical\n case \"AND\":\n return (condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));\n case \"OR\":\n return (condition as LogicalCondition).conditions.some((c) => executeCondition(c, value));\n case \"NOT\":\n return !(condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));\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) && 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(String(targetValue));\n case \"STARTS_WITH\":\n return String(targetValue).startsWith((condition as ComparisonCondition).value);\n case \"ENDS_WITH\":\n return String(targetValue).endsWith((condition as ComparisonCondition).value);\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;AAoCO,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,OAAO,iBAAiB,OAAO,UAAU,IAAI,IAAI;AAE/E,UAAQ,UAAU,MAAM;AAAA,IAEtB,KAAK;AACH,aAAQ,UAA+B,WAAW,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAAA,IAC3F,KAAK;AACH,aAAQ,UAA+B,WAAW,KAAK,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAAA,IAC1F,KAAK;AACH,aAAO,CAAE,UAA+B,WAAW,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAAA,IAG5F,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,KAAK,YAAY,SAAU,UAAkC,KAAK;AAAA,IAE/F,KAAK;AACH,aACE,MAAM,QAAQ,WAAW,KACzB,CAAC,YAAY,SAAU,UAAkC,KAAK;AAAA,IAElE,KAAK;AACH,aAAO,IAAI,OAAQ,UAAkC,KAAK,EAAE,KAAK,OAAO,WAAW,CAAC;AAAA,IACtF,KAAK;AACH,aAAO,OAAO,WAAW,EAAE,WAAY,UAAkC,KAAK;AAAA,IAChF,KAAK;AACH,aAAO,OAAO,WAAW,EAAE,SAAU,UAAkC,KAAK;AAAA,IAG9E,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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions } from './conditions.js';
|
|
1
2
|
export { ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, ERROR_CONFIG, ERROR_NAMES, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError } from './errors.js';
|
|
2
3
|
export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema, convertJsonSchemaToZodSchema } from './json-schema.js';
|
|
3
|
-
export { isValidUUID, randomId, randomUUID } from './random-id.js';
|
|
4
|
+
export { dataToUUID, isValidUUID, randomId, randomUUID } from './random-id.js';
|
|
4
5
|
import 'graphql';
|
|
5
6
|
import 'zod';
|
|
6
7
|
import '../types/action.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -36,12 +36,60 @@ __export(utils_exports, {
|
|
|
36
36
|
UpgradeRequiredError: () => UpgradeRequiredError,
|
|
37
37
|
actionParametersToJsonSchema: () => actionParametersToJsonSchema,
|
|
38
38
|
convertJsonSchemaToZodSchema: () => convertJsonSchemaToZodSchema,
|
|
39
|
+
dataToUUID: () => dataToUUID,
|
|
40
|
+
executeConditions: () => executeConditions,
|
|
39
41
|
isValidUUID: () => isValidUUID,
|
|
40
42
|
randomId: () => randomId,
|
|
41
43
|
randomUUID: () => randomUUID
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(utils_exports);
|
|
44
46
|
|
|
47
|
+
// src/utils/conditions.ts
|
|
48
|
+
function executeConditions({
|
|
49
|
+
conditions,
|
|
50
|
+
value
|
|
51
|
+
}) {
|
|
52
|
+
if (!(conditions == null ? void 0 : conditions.length))
|
|
53
|
+
return true;
|
|
54
|
+
return conditions.every((condition) => executeCondition(condition, value));
|
|
55
|
+
}
|
|
56
|
+
function executeCondition(condition, value) {
|
|
57
|
+
const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
|
|
58
|
+
switch (condition.rule) {
|
|
59
|
+
case "AND":
|
|
60
|
+
return condition.conditions.every((c) => executeCondition(c, value));
|
|
61
|
+
case "OR":
|
|
62
|
+
return condition.conditions.some((c) => executeCondition(c, value));
|
|
63
|
+
case "NOT":
|
|
64
|
+
return !condition.conditions.every((c) => executeCondition(c, value));
|
|
65
|
+
case "EQUALS":
|
|
66
|
+
return targetValue === condition.value;
|
|
67
|
+
case "NOT_EQUALS":
|
|
68
|
+
return targetValue !== condition.value;
|
|
69
|
+
case "GREATER_THAN":
|
|
70
|
+
return targetValue > condition.value;
|
|
71
|
+
case "LESS_THAN":
|
|
72
|
+
return targetValue < condition.value;
|
|
73
|
+
case "CONTAINS":
|
|
74
|
+
return Array.isArray(targetValue) && targetValue.includes(condition.value);
|
|
75
|
+
case "NOT_CONTAINS":
|
|
76
|
+
return Array.isArray(targetValue) && !targetValue.includes(condition.value);
|
|
77
|
+
case "MATCHES":
|
|
78
|
+
return new RegExp(condition.value).test(String(targetValue));
|
|
79
|
+
case "STARTS_WITH":
|
|
80
|
+
return String(targetValue).startsWith(condition.value);
|
|
81
|
+
case "ENDS_WITH":
|
|
82
|
+
return String(targetValue).endsWith(condition.value);
|
|
83
|
+
case "EXISTS":
|
|
84
|
+
return targetValue !== void 0 && targetValue !== null;
|
|
85
|
+
case "NOT_EXISTS":
|
|
86
|
+
return targetValue === void 0 || targetValue === null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function getValueFromPath(obj, path) {
|
|
90
|
+
return path.split(".").reduce((acc, part) => acc == null ? void 0 : acc[part], obj);
|
|
91
|
+
}
|
|
92
|
+
|
|
45
93
|
// src/utils/errors.ts
|
|
46
94
|
var import_graphql = require("graphql");
|
|
47
95
|
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
@@ -380,6 +428,11 @@ function randomId() {
|
|
|
380
428
|
function randomUUID() {
|
|
381
429
|
return (0, import_uuid.v4)();
|
|
382
430
|
}
|
|
431
|
+
function dataToUUID(input, namespace) {
|
|
432
|
+
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
|
|
433
|
+
const boundNamespace = namespace ? (0, import_uuid.v5)(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
|
|
434
|
+
return (0, import_uuid.v5)(input, boundNamespace);
|
|
435
|
+
}
|
|
383
436
|
function isValidUUID(uuid) {
|
|
384
437
|
return (0, import_uuid.validate)(uuid);
|
|
385
438
|
}
|
|
@@ -401,6 +454,8 @@ function isValidUUID(uuid) {
|
|
|
401
454
|
UpgradeRequiredError,
|
|
402
455
|
actionParametersToJsonSchema,
|
|
403
456
|
convertJsonSchemaToZodSchema,
|
|
457
|
+
dataToUUID,
|
|
458
|
+
executeConditions,
|
|
404
459
|
isValidUUID,
|
|
405
460
|
randomId,
|
|
406
461
|
randomUUID
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts","../../src/utils/errors.ts","../../src/utils/json-schema.ts","../../src/utils/random-id.ts"],"sourcesContent":["export * from \"./errors\";\nexport * from \"./json-schema\";\nexport * from \"./random-id\";\n","import { GraphQLError } from \"graphql\";\n\nexport enum Severity {\n Error = \"error\",\n}\n\nexport const ERROR_NAMES = {\n COPILOT_ERROR: \"CopilotError\",\n COPILOT_API_DISCOVERY_ERROR: \"CopilotApiDiscoveryError\",\n COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: \"CopilotKitRemoteEndpointDiscoveryError\",\n COPILOT_KIT_AGENT_DISCOVERY_ERROR: \"CopilotKitAgentDiscoveryError\",\n COPILOT_KIT_LOW_LEVEL_ERROR: \"CopilotKitLowLevelError\",\n RESOLVED_COPILOT_KIT_ERROR: \"ResolvedCopilotKitError\",\n CONFIGURATION_ERROR: \"ConfigurationError\",\n MISSING_PUBLIC_API_KEY_ERROR: \"MissingPublicApiKeyError\",\n UPGRADE_REQUIRED_ERROR: \"UpgradeRequiredError\",\n} as const;\n\nexport enum CopilotKitErrorCode {\n NETWORK_ERROR = \"NETWORK_ERROR\",\n NOT_FOUND = \"NOT_FOUND\",\n AGENT_NOT_FOUND = \"AGENT_NOT_FOUND\",\n API_NOT_FOUND = \"API_NOT_FOUND\",\n REMOTE_ENDPOINT_NOT_FOUND = \"REMOTE_ENDPOINT_NOT_FOUND\",\n MISUSE = \"MISUSE\",\n UNKNOWN = \"UNKNOWN\",\n CONFIGURATION_ERROR = \"CONFIGURATION_ERROR\",\n MISSING_PUBLIC_API_KEY_ERROR = \"MISSING_PUBLIC_API_KEY_ERROR\",\n UPGRADE_REQUIRED_ERROR = \"UPGRADE_REQUIRED_ERROR\",\n}\n\nconst BASE_URL = \"https://docs.copilotkit.ai\";\n\nconst getSeeMoreMarkdown = (link: string) => `See more: [${link}](${link})`;\n\nexport const ERROR_CONFIG = {\n [CopilotKitErrorCode.NETWORK_ERROR]: {\n statusCode: 503,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,\n },\n [CopilotKitErrorCode.API_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,\n },\n [CopilotKitErrorCode.MISUSE]: {\n statusCode: 400,\n troubleshootingUrl: null,\n },\n [CopilotKitErrorCode.UNKNOWN]: {\n statusCode: 500,\n },\n [CopilotKitErrorCode.CONFIGURATION_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR]: {\n statusCode: 402,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n};\n\nexport class CopilotKitError extends GraphQLError {\n code: CopilotKitErrorCode;\n statusCode: number;\n severity?: Severity;\n constructor({\n message = \"Unknown error occurred\",\n code,\n severity,\n }: {\n message?: string;\n code: CopilotKitErrorCode;\n severity?: Severity;\n }) {\n const name = ERROR_NAMES.COPILOT_ERROR;\n const { statusCode } = ERROR_CONFIG[code];\n\n super(message, {\n extensions: {\n name,\n statusCode,\n },\n });\n this.code = code;\n this.name = name;\n this.statusCode = statusCode;\n this.severity = severity;\n }\n}\n\n/**\n * Error thrown when we can identify wrong usage of our components.\n * This helps us notify the developer before real errors can happen\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitMisuseError extends CopilotKitError {\n constructor({\n message,\n code = CopilotKitErrorCode.MISUSE,\n }: {\n message: string;\n code?: CopilotKitErrorCode;\n }) {\n const docsLink =\n \"troubleshootingUrl\" in ERROR_CONFIG[code]\n ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl as string)\n : null;\n const finalMessage = docsLink ? `${message}.\\n\\n${docsLink}` : message;\n super({ message: finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n * - There are network/firewall issues preventing access\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitApiDiscoveryError extends CopilotKitError {\n constructor(\n params: {\n message?: string;\n code?: CopilotKitErrorCode.API_NOT_FOUND | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n } = {},\n ) {\n const message = params.message ?? \"Failed to find CopilotKit API endpoint\";\n const code = params.code ?? CopilotKitErrorCode.API_NOT_FOUND;\n const errorMessage = `${message}.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: errorMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * This error is used for endpoints specified in runtime's remote endpoints. If they cannot be contacted\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n *\n * @extends CopilotKitApiDiscoveryError\n */\nexport class CopilotKitRemoteEndpointDiscoveryError extends CopilotKitApiDiscoveryError {\n constructor(params?: { message?: string }) {\n const message = params?.message ?? \"Failed to find or contact remote endpoint\";\n const code = CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n super({ message, code });\n this.name = ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when a LangGraph agent cannot be found or accessed.\n * This typically occurs when:\n * - The specified agent name does not exist in the deployment\n * - The agent configuration is invalid or missing\n * - The agent service is not properly deployed or initialized\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitAgentDiscoveryError extends CopilotKitError {\n constructor(params?: { agentName?: string }) {\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n const baseMessage = \"Failed to find agent\";\n const configMessage = \"Please verify the agent name exists and is properly configured.\";\n const finalMessage = params?.agentName\n ? `${baseMessage} '${params.agentName}'. ${configMessage}\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`\n : `${baseMessage}. ${configMessage}\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: finalMessage || finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Handles low-level networking errors that occur before a request reaches the server.\n * These errors arise from issues in the underlying communication infrastructure rather than\n * application-level logic or server responses. Typically used to handle \"fetch failed\" errors\n * where no HTTP status code is available.\n *\n * Common scenarios include:\n * - Connection failures (ECONNREFUSED) when server is down/unreachable\n * - DNS resolution failures (ENOTFOUND) when domain can't be resolved\n * - Timeouts (ETIMEDOUT) when request takes too long\n * - Protocol/transport layer errors like SSL/TLS issues\n */\nexport class CopilotKitLowLevelError extends CopilotKitError {\n constructor({ error, url, message }: { error: Error; url: string; message?: string }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n const getMessageByCode = (errorCode?: string) => {\n const troubleshootingLink = ERROR_CONFIG[code].troubleshootingUrl;\n switch (errorCode) {\n case \"ECONNREFUSED\":\n return `Connection to ${url} was refused. Ensure the server is running and accessible.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n case \"ENOTFOUND\":\n return `The server on ${url} could not be found. Check the URL or your network configuration.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[CopilotKitErrorCode.NOT_FOUND].troubleshootingUrl)}`;\n case \"ETIMEDOUT\":\n return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n default:\n return `Failed to fetch from url ${url}.\n\nPossible reasons:\n- -The server might be down or unreachable\n- -There might be a network issue (e.g., DNS failure, connection timeout) \n- -The URL might be incorrect\n- -The server is not running on the specified port\n\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n }\n };\n // @ts-expect-error -- code may exist\n const errorMessage = message ?? getMessageByCode(error.code as string);\n\n super({ message: errorMessage, code });\n\n this.name = ERROR_NAMES.COPILOT_KIT_LOW_LEVEL_ERROR;\n }\n}\n\n/**\n * Generic catch-all error handler for HTTP responses from the CopilotKit API where a status code is available.\n * Used when we receive an HTTP error status and wish to handle broad range of them\n *\n * This differs from CopilotKitLowLevelError in that:\n * - ResolvedCopilotKitError: Server was reached and returned an HTTP status\n * - CopilotKitLowLevelError: Error occurred before reaching server (e.g. network failure)\n *\n * @param status - The HTTP status code received from the API response\n * @param message - Optional error message to include\n * @param code - Optional specific CopilotKitErrorCode to override default behavior\n *\n * Default behavior:\n * - 400 Bad Request: Maps to CopilotKitApiDiscoveryError\n * - All other status codes: Maps to UNKNOWN error code if no specific code provided\n */\nexport class ResolvedCopilotKitError extends CopilotKitError {\n constructor({\n status,\n message,\n code,\n isRemoteEndpoint,\n }: {\n status: number;\n message?: string;\n code?: CopilotKitErrorCode;\n isRemoteEndpoint?: boolean;\n }) {\n let resolvedCode = code;\n if (!resolvedCode) {\n switch (status) {\n case 400:\n throw new CopilotKitApiDiscoveryError({ message });\n case 404:\n throw isRemoteEndpoint\n ? new CopilotKitRemoteEndpointDiscoveryError({ message })\n : new CopilotKitApiDiscoveryError({ message });\n default:\n resolvedCode = CopilotKitErrorCode.UNKNOWN;\n super({ message, code: resolvedCode });\n }\n } else {\n super({ message, code: resolvedCode });\n }\n this.name = ERROR_NAMES.RESOLVED_COPILOT_KIT_ERROR;\n }\n}\n\nexport class ConfigurationError extends CopilotKitError {\n constructor(message: string) {\n super({ message, code: CopilotKitErrorCode.CONFIGURATION_ERROR });\n this.name = ERROR_NAMES.CONFIGURATION_ERROR;\n this.severity = Severity.Error;\n }\n}\n\nexport class MissingPublicApiKeyError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR;\n this.severity = Severity.Error;\n }\n}\n\nexport class UpgradeRequiredError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.UPGRADE_REQUIRED_ERROR;\n this.severity = Severity.Error;\n }\n}\n","import { z } from \"zod\";\nimport { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n\nexport function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean): z.ZodSchema {\n if (jsonSchema.type === \"object\") {\n const spec: { [key: string]: z.ZodSchema } = {};\n\n if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {\n return !required ? z.object(spec).optional() : z.object(spec);\n }\n\n for (const [key, value] of Object.entries(jsonSchema.properties)) {\n spec[key] = convertJsonSchemaToZodSchema(\n value,\n jsonSchema.required ? jsonSchema.required.includes(key) : false,\n );\n }\n let schema = z.object(spec).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n let schema = z.string().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\") {\n let schema = z.number().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"boolean\") {\n let schema = z.boolean().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"array\") {\n let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);\n let schema = z.array(itemSchema).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n throw new Error(\"Invalid JSON schema\");\n}\n","import { v4 as uuidv4, validate } from \"uuid\";\n\nexport function randomId() {\n return \"ck-\" + uuidv4();\n}\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function isValidUUID(uuid: string) {\n return validate(uuid);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA6B;AAEtB,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,WAAQ;AADE,SAAAA;AAAA,GAAA;AAIL,IAAM,cAAc;AAAA,EACzB,eAAe;AAAA,EACf,6BAA6B;AAAA,EAC7B,yCAAyC;AAAA,EACzC,mCAAmC;AAAA,EACnC,6BAA6B;AAAA,EAC7B,4BAA4B;AAAA,EAC5B,qBAAqB;AAAA,EACrB,8BAA8B;AAAA,EAC9B,wBAAwB;AAC1B;AAEO,IAAK,sBAAL,kBAAKC,yBAAL;AACL,EAAAA,qBAAA,mBAAgB;AAChB,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,qBAAkB;AAClB,EAAAA,qBAAA,mBAAgB;AAChB,EAAAA,qBAAA,+BAA4B;AAC5B,EAAAA,qBAAA,YAAS;AACT,EAAAA,qBAAA,aAAU;AACV,EAAAA,qBAAA,yBAAsB;AACtB,EAAAA,qBAAA,kCAA+B;AAC/B,EAAAA,qBAAA,4B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O,IAAI;AAAA,IAC9D;AAEA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,UAAU,GAAG;AAChE,WAAK,GAAG,IAAI;AAAA,QACV;AAAA,QACA,WAAW,WAAW,WAAW,SAAS,SAAS,GAAG,IAAI;AAAA,MAC5D;AAAA,IACF;AACA,QAAI,SAAS,aAAE,OAAO,IAAI,EAAE,SAAS,WAAW,WAAW;AAC3D,WAAO,WAAW,SAAS,OAAO,SAAS;AAAA,EAC7C,WAAW,WAAW,SAAS,UAAU;AACvC,QAAI,SAAS,aAAE,OAAO,EAAE,SAAS,WAAW,WAAW;AACvD,WAAO,WAAW,SAAS,OAAO,SAAS;AAAA,EAC7C,WAAW,WAAW,SAAS,UAAU;AACvC,QAAI,SAAS,aAAE,OAAO,EAAE,SAAS,WAAW,WAAW;AACvD,WAAO,WAAW,SAAS,OAAO,SAAS;AAAA,EAC7C,WAAW,WAAW,SAAS,WAAW;AACxC,QAAI,SAAS,aAAE,QAAQ,EAAE,SAAS,WAAW,WAAW;AACxD,WAAO,WAAW,SAAS,OAAO,SAAS;AAAA,EAC7C,WAAW,WAAW,SAAS,SAAS;AACtC,QAAI,aAAa,6BAA6B,WAAW,OAAO,IAAI;AACpE,QAAI,SAAS,aAAE,MAAM,UAAU,EAAE,SAAS,WAAW,WAAW;AAChE,WAAO,WAAW,SAAS,OAAO,SAAS;AAAA,EAC7C;AACA,QAAM,IAAI,MAAM,qBAAqB;AACvC;;;ACzJA,kBAAuC;AAEhC,SAAS,WAAW;AACzB,SAAO,YAAQ,YAAAC,IAAO;AACxB;AAEO,SAAS,aAAa;AAC3B,aAAO,YAAAA,IAAO;AAChB;AAEO,SAAS,YAAY,MAAc;AACxC,aAAO,sBAAS,IAAI;AACtB;","names":["Severity","CopilotKitErrorCode","uuidv4"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts","../../src/utils/conditions.ts","../../src/utils/errors.ts","../../src/utils/json-schema.ts","../../src/utils/random-id.ts"],"sourcesContent":["export * from \"./conditions\";\nexport * from \"./errors\";\nexport * from \"./json-schema\";\nexport * from \"./random-id\";\n","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 = ComparisonCondition | LogicalCondition | 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 ? getValueFromPath(value, condition.path) : value;\n\n switch (condition.rule) {\n // Logical\n case \"AND\":\n return (condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));\n case \"OR\":\n return (condition as LogicalCondition).conditions.some((c) => executeCondition(c, value));\n case \"NOT\":\n return !(condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));\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) && 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(String(targetValue));\n case \"STARTS_WITH\":\n return String(targetValue).startsWith((condition as ComparisonCondition).value);\n case \"ENDS_WITH\":\n return String(targetValue).endsWith((condition as ComparisonCondition).value);\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","import { GraphQLError } from \"graphql\";\n\nexport enum Severity {\n Error = \"error\",\n}\n\nexport const ERROR_NAMES = {\n COPILOT_ERROR: \"CopilotError\",\n COPILOT_API_DISCOVERY_ERROR: \"CopilotApiDiscoveryError\",\n COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: \"CopilotKitRemoteEndpointDiscoveryError\",\n COPILOT_KIT_AGENT_DISCOVERY_ERROR: \"CopilotKitAgentDiscoveryError\",\n COPILOT_KIT_LOW_LEVEL_ERROR: \"CopilotKitLowLevelError\",\n RESOLVED_COPILOT_KIT_ERROR: \"ResolvedCopilotKitError\",\n CONFIGURATION_ERROR: \"ConfigurationError\",\n MISSING_PUBLIC_API_KEY_ERROR: \"MissingPublicApiKeyError\",\n UPGRADE_REQUIRED_ERROR: \"UpgradeRequiredError\",\n} as const;\n\nexport enum CopilotKitErrorCode {\n NETWORK_ERROR = \"NETWORK_ERROR\",\n NOT_FOUND = \"NOT_FOUND\",\n AGENT_NOT_FOUND = \"AGENT_NOT_FOUND\",\n API_NOT_FOUND = \"API_NOT_FOUND\",\n REMOTE_ENDPOINT_NOT_FOUND = \"REMOTE_ENDPOINT_NOT_FOUND\",\n MISUSE = \"MISUSE\",\n UNKNOWN = \"UNKNOWN\",\n CONFIGURATION_ERROR = \"CONFIGURATION_ERROR\",\n MISSING_PUBLIC_API_KEY_ERROR = \"MISSING_PUBLIC_API_KEY_ERROR\",\n UPGRADE_REQUIRED_ERROR = \"UPGRADE_REQUIRED_ERROR\",\n}\n\nconst BASE_URL = \"https://docs.copilotkit.ai\";\n\nconst getSeeMoreMarkdown = (link: string) => `See more: [${link}](${link})`;\n\nexport const ERROR_CONFIG = {\n [CopilotKitErrorCode.NETWORK_ERROR]: {\n statusCode: 503,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,\n },\n [CopilotKitErrorCode.API_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,\n },\n [CopilotKitErrorCode.MISUSE]: {\n statusCode: 400,\n troubleshootingUrl: null,\n },\n [CopilotKitErrorCode.UNKNOWN]: {\n statusCode: 500,\n },\n [CopilotKitErrorCode.CONFIGURATION_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR]: {\n statusCode: 402,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n};\n\nexport class CopilotKitError extends GraphQLError {\n code: CopilotKitErrorCode;\n statusCode: number;\n severity?: Severity;\n constructor({\n message = \"Unknown error occurred\",\n code,\n severity,\n }: {\n message?: string;\n code: CopilotKitErrorCode;\n severity?: Severity;\n }) {\n const name = ERROR_NAMES.COPILOT_ERROR;\n const { statusCode } = ERROR_CONFIG[code];\n\n super(message, {\n extensions: {\n name,\n statusCode,\n },\n });\n this.code = code;\n this.name = name;\n this.statusCode = statusCode;\n this.severity = severity;\n }\n}\n\n/**\n * Error thrown when we can identify wrong usage of our components.\n * This helps us notify the developer before real errors can happen\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitMisuseError extends CopilotKitError {\n constructor({\n message,\n code = CopilotKitErrorCode.MISUSE,\n }: {\n message: string;\n code?: CopilotKitErrorCode;\n }) {\n const docsLink =\n \"troubleshootingUrl\" in ERROR_CONFIG[code]\n ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl as string)\n : null;\n const finalMessage = docsLink ? `${message}.\\n\\n${docsLink}` : message;\n super({ message: finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n * - There are network/firewall issues preventing access\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitApiDiscoveryError extends CopilotKitError {\n constructor(\n params: {\n message?: string;\n code?: CopilotKitErrorCode.API_NOT_FOUND | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n } = {},\n ) {\n const message = params.message ?? \"Failed to find CopilotKit API endpoint\";\n const code = params.code ?? CopilotKitErrorCode.API_NOT_FOUND;\n const errorMessage = `${message}.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: errorMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * This error is used for endpoints specified in runtime's remote endpoints. If they cannot be contacted\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n *\n * @extends CopilotKitApiDiscoveryError\n */\nexport class CopilotKitRemoteEndpointDiscoveryError extends CopilotKitApiDiscoveryError {\n constructor(params?: { message?: string }) {\n const message = params?.message ?? \"Failed to find or contact remote endpoint\";\n const code = CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n super({ message, code });\n this.name = ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when a LangGraph agent cannot be found or accessed.\n * This typically occurs when:\n * - The specified agent name does not exist in the deployment\n * - The agent configuration is invalid or missing\n * - The agent service is not properly deployed or initialized\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitAgentDiscoveryError extends CopilotKitError {\n constructor(params?: { agentName?: string }) {\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n const baseMessage = \"Failed to find agent\";\n const configMessage = \"Please verify the agent name exists and is properly configured.\";\n const finalMessage = params?.agentName\n ? `${baseMessage} '${params.agentName}'. ${configMessage}\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`\n : `${baseMessage}. ${configMessage}\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: finalMessage || finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Handles low-level networking errors that occur before a request reaches the server.\n * These errors arise from issues in the underlying communication infrastructure rather than\n * application-level logic or server responses. Typically used to handle \"fetch failed\" errors\n * where no HTTP status code is available.\n *\n * Common scenarios include:\n * - Connection failures (ECONNREFUSED) when server is down/unreachable\n * - DNS resolution failures (ENOTFOUND) when domain can't be resolved\n * - Timeouts (ETIMEDOUT) when request takes too long\n * - Protocol/transport layer errors like SSL/TLS issues\n */\nexport class CopilotKitLowLevelError extends CopilotKitError {\n constructor({ error, url, message }: { error: Error; url: string; message?: string }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n const getMessageByCode = (errorCode?: string) => {\n const troubleshootingLink = ERROR_CONFIG[code].troubleshootingUrl;\n switch (errorCode) {\n case \"ECONNREFUSED\":\n return `Connection to ${url} was refused. Ensure the server is running and accessible.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n case \"ENOTFOUND\":\n return `The server on ${url} could not be found. Check the URL or your network configuration.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[CopilotKitErrorCode.NOT_FOUND].troubleshootingUrl)}`;\n case \"ETIMEDOUT\":\n return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n default:\n return `Failed to fetch from url ${url}.\n\nPossible reasons:\n- -The server might be down or unreachable\n- -There might be a network issue (e.g., DNS failure, connection timeout) \n- -The URL might be incorrect\n- -The server is not running on the specified port\n\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n }\n };\n // @ts-expect-error -- code may exist\n const errorMessage = message ?? getMessageByCode(error.code as string);\n\n super({ message: errorMessage, code });\n\n this.name = ERROR_NAMES.COPILOT_KIT_LOW_LEVEL_ERROR;\n }\n}\n\n/**\n * Generic catch-all error handler for HTTP responses from the CopilotKit API where a status code is available.\n * Used when we receive an HTTP error status and wish to handle broad range of them\n *\n * This differs from CopilotKitLowLevelError in that:\n * - ResolvedCopilotKitError: Server was reached and returned an HTTP status\n * - CopilotKitLowLevelError: Error occurred before reaching server (e.g. network failure)\n *\n * @param status - The HTTP status code received from the API response\n * @param message - Optional error message to include\n * @param code - Optional specific CopilotKitErrorCode to override default behavior\n *\n * Default behavior:\n * - 400 Bad Request: Maps to CopilotKitApiDiscoveryError\n * - All other status codes: Maps to UNKNOWN error code if no specific code provided\n */\nexport class ResolvedCopilotKitError extends CopilotKitError {\n constructor({\n status,\n message,\n code,\n isRemoteEndpoint,\n }: {\n status: number;\n message?: string;\n code?: CopilotKitErrorCode;\n isRemoteEndpoint?: boolean;\n }) {\n let resolvedCode = code;\n if (!resolvedCode) {\n switch (status) {\n case 400:\n throw new CopilotKitApiDiscoveryError({ message });\n case 404:\n throw isRemoteEndpoint\n ? new CopilotKitRemoteEndpointDiscoveryError({ message })\n : new CopilotKitApiDiscoveryError({ message });\n default:\n resolvedCode = CopilotKitErrorCode.UNKNOWN;\n super({ message, code: resolvedCode });\n }\n } else {\n super({ message, code: resolvedCode });\n }\n this.name = ERROR_NAMES.RESOLVED_COPILOT_KIT_ERROR;\n }\n}\n\nexport class ConfigurationError extends CopilotKitError {\n constructor(message: string) {\n super({ message, code: CopilotKitErrorCode.CONFIGURATION_ERROR });\n this.name = ERROR_NAMES.CONFIGURATION_ERROR;\n this.severity = Severity.Error;\n }\n}\n\nexport class MissingPublicApiKeyError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR;\n this.severity = Severity.Error;\n }\n}\n\nexport class UpgradeRequiredError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.UPGRADE_REQUIRED_ERROR;\n this.severity = Severity.Error;\n }\n}\n","import { z } from \"zod\";\nimport { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n\nexport function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean): z.ZodSchema {\n if (jsonSchema.type === \"object\") {\n const spec: { [key: string]: z.ZodSchema } = {};\n\n if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {\n return !required ? z.object(spec).optional() : z.object(spec);\n }\n\n for (const [key, value] of Object.entries(jsonSchema.properties)) {\n spec[key] = convertJsonSchemaToZodSchema(\n value,\n jsonSchema.required ? jsonSchema.required.includes(key) : false,\n );\n }\n let schema = z.object(spec).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n let schema = z.string().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\") {\n let schema = z.number().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"boolean\") {\n let schema = z.boolean().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"array\") {\n let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);\n let schema = z.array(itemSchema).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n throw new Error(\"Invalid JSON schema\");\n}\n","import { v4 as uuidv4, validate, v5 as uuidv5 } from \"uuid\";\n\nexport function randomId() {\n return \"ck-\" + uuidv4();\n}\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function dataToUUID(input: string, namespace?: string): string {\n const BASE_NAMESPACE = \"e4b01160-ff74-4c6e-9b27-d53cd930fe8e\";\n // Since namespace needs to be a uuid, we are creating a uuid for it.\n const boundNamespace = namespace ? uuidv5(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;\n return uuidv5(input, boundNamespace);\n}\n\nexport function isValidUUID(uuid: string) {\n return validate(uuid);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoCO,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,WA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,OAAO,SAAS;AAAA,EAC7C,WAAW,WAAW,SAAS,SAAS;AACtC,QAAI,aAAa,6BAA6B,WAAW,OAAO,IAAI;AACpE,QAAI,SAAS,aAAE,MAAM,UAAU,EAAE,SAAS,WAAW,WAAW;AAChE,WAAO,WAAW,SAAS,OAAO,SAAS;AAAA,EAC7C;AACA,QAAM,IAAI,MAAM,qBAAqB;AACvC;;;ACzJA,kBAAqD;AAE9C,SAAS,WAAW;AACzB,SAAO,YAAQ,YAAAC,IAAO;AACxB;AAEO,SAAS,aAAa;AAC3B,aAAO,YAAAA,IAAO;AAChB;AAEO,SAAS,WAAW,OAAe,WAA4B;AACpE,QAAM,iBAAiB;AAEvB,QAAM,iBAAiB,gBAAY,YAAAC,IAAO,WAAW,cAAc,IAAI;AACvE,aAAO,YAAAA,IAAO,OAAO,cAAc;AACrC;AAEO,SAAS,YAAY,MAAc;AACxC,aAAO,sBAAS,IAAI;AACtB;","names":["Severity","CopilotKitErrorCode","uuidv4","uuidv5"]}
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-HGLO5LDS.mjs";
|
|
2
2
|
import {
|
|
3
|
+
dataToUUID,
|
|
3
4
|
isValidUUID,
|
|
4
5
|
randomId,
|
|
5
6
|
randomUUID
|
|
6
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-VNNKZIFB.mjs";
|
|
8
|
+
import {
|
|
9
|
+
executeConditions
|
|
10
|
+
} from "../chunk-PL5WNHFZ.mjs";
|
|
7
11
|
import {
|
|
8
12
|
ConfigurationError,
|
|
9
13
|
CopilotKitAgentDiscoveryError,
|
|
@@ -41,6 +45,8 @@ export {
|
|
|
41
45
|
UpgradeRequiredError,
|
|
42
46
|
actionParametersToJsonSchema,
|
|
43
47
|
convertJsonSchemaToZodSchema,
|
|
48
|
+
dataToUUID,
|
|
49
|
+
executeConditions,
|
|
44
50
|
isValidUUID,
|
|
45
51
|
randomId,
|
|
46
52
|
randomUUID
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare function randomId(): string;
|
|
2
2
|
declare function randomUUID(): string;
|
|
3
|
+
declare function dataToUUID(input: string, namespace?: string): string;
|
|
3
4
|
declare function isValidUUID(uuid: string): boolean;
|
|
4
5
|
|
|
5
|
-
export { isValidUUID, randomId, randomUUID };
|
|
6
|
+
export { dataToUUID, isValidUUID, randomId, randomUUID };
|
package/dist/utils/random-id.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/utils/random-id.ts
|
|
21
21
|
var random_id_exports = {};
|
|
22
22
|
__export(random_id_exports, {
|
|
23
|
+
dataToUUID: () => dataToUUID,
|
|
23
24
|
isValidUUID: () => isValidUUID,
|
|
24
25
|
randomId: () => randomId,
|
|
25
26
|
randomUUID: () => randomUUID
|
|
@@ -32,11 +33,17 @@ function randomId() {
|
|
|
32
33
|
function randomUUID() {
|
|
33
34
|
return (0, import_uuid.v4)();
|
|
34
35
|
}
|
|
36
|
+
function dataToUUID(input, namespace) {
|
|
37
|
+
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
|
|
38
|
+
const boundNamespace = namespace ? (0, import_uuid.v5)(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
|
|
39
|
+
return (0, import_uuid.v5)(input, boundNamespace);
|
|
40
|
+
}
|
|
35
41
|
function isValidUUID(uuid) {
|
|
36
42
|
return (0, import_uuid.validate)(uuid);
|
|
37
43
|
}
|
|
38
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
45
|
0 && (module.exports = {
|
|
46
|
+
dataToUUID,
|
|
40
47
|
isValidUUID,
|
|
41
48
|
randomId,
|
|
42
49
|
randomUUID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/random-id.ts"],"sourcesContent":["import { v4 as uuidv4, validate } from \"uuid\";\n\nexport function randomId() {\n return \"ck-\" + uuidv4();\n}\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function isValidUUID(uuid: string) {\n return validate(uuid);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/random-id.ts"],"sourcesContent":["import { v4 as uuidv4, validate, v5 as uuidv5 } from \"uuid\";\n\nexport function randomId() {\n return \"ck-\" + uuidv4();\n}\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function dataToUUID(input: string, namespace?: string): string {\n const BASE_NAMESPACE = \"e4b01160-ff74-4c6e-9b27-d53cd930fe8e\";\n // Since namespace needs to be a uuid, we are creating a uuid for it.\n const boundNamespace = namespace ? uuidv5(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;\n return uuidv5(input, boundNamespace);\n}\n\nexport function isValidUUID(uuid: string) {\n return validate(uuid);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqD;AAE9C,SAAS,WAAW;AACzB,SAAO,YAAQ,YAAAA,IAAO;AACxB;AAEO,SAAS,aAAa;AAC3B,aAAO,YAAAA,IAAO;AAChB;AAEO,SAAS,WAAW,OAAe,WAA4B;AACpE,QAAM,iBAAiB;AAEvB,QAAM,iBAAiB,gBAAY,YAAAC,IAAO,WAAW,cAAc,IAAI;AACvE,aAAO,YAAAA,IAAO,OAAO,cAAc;AACrC;AAEO,SAAS,YAAY,MAAc;AACxC,aAAO,sBAAS,IAAI;AACtB;","names":["uuidv4","uuidv5"]}
|
package/dist/utils/random-id.mjs
CHANGED
package/package.json
CHANGED
package/src/types/utility.ts
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export type ComparisonRule =
|
|
2
|
+
| "EQUALS"
|
|
3
|
+
| "NOT_EQUALS"
|
|
4
|
+
| "GREATER_THAN"
|
|
5
|
+
| "LESS_THAN"
|
|
6
|
+
| "CONTAINS"
|
|
7
|
+
| "NOT_CONTAINS"
|
|
8
|
+
| "MATCHES"
|
|
9
|
+
| "STARTS_WITH"
|
|
10
|
+
| "ENDS_WITH";
|
|
11
|
+
export type LogicalRule = "AND" | "OR" | "NOT";
|
|
12
|
+
export type ExistenceRule = "EXISTS" | "NOT_EXISTS";
|
|
13
|
+
|
|
14
|
+
export type Rule = ComparisonRule | LogicalRule | ExistenceRule;
|
|
15
|
+
|
|
16
|
+
export interface BaseCondition {
|
|
17
|
+
rule: Rule;
|
|
18
|
+
path?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ComparisonCondition extends BaseCondition {
|
|
22
|
+
rule: ComparisonRule;
|
|
23
|
+
value: any;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface LogicalCondition extends BaseCondition {
|
|
27
|
+
rule: LogicalRule;
|
|
28
|
+
conditions: Condition[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ExistenceCondition extends BaseCondition {
|
|
32
|
+
rule: ExistenceRule;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type Condition = ComparisonCondition | LogicalCondition | ExistenceCondition;
|
|
36
|
+
|
|
37
|
+
export function executeConditions({
|
|
38
|
+
conditions,
|
|
39
|
+
value,
|
|
40
|
+
}: {
|
|
41
|
+
conditions?: Condition[];
|
|
42
|
+
value: any;
|
|
43
|
+
}): boolean {
|
|
44
|
+
// If no conditions, consider it a pass
|
|
45
|
+
if (!conditions?.length) return true;
|
|
46
|
+
|
|
47
|
+
// Run all conditions (implicit AND)
|
|
48
|
+
return conditions.every((condition) => executeCondition(condition, value));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function executeCondition(condition: Condition, value: any): boolean {
|
|
52
|
+
const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
|
|
53
|
+
|
|
54
|
+
switch (condition.rule) {
|
|
55
|
+
// Logical
|
|
56
|
+
case "AND":
|
|
57
|
+
return (condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));
|
|
58
|
+
case "OR":
|
|
59
|
+
return (condition as LogicalCondition).conditions.some((c) => executeCondition(c, value));
|
|
60
|
+
case "NOT":
|
|
61
|
+
return !(condition as LogicalCondition).conditions.every((c) => executeCondition(c, value));
|
|
62
|
+
|
|
63
|
+
// Comparison
|
|
64
|
+
case "EQUALS":
|
|
65
|
+
return targetValue === (condition as ComparisonCondition).value;
|
|
66
|
+
case "NOT_EQUALS":
|
|
67
|
+
return targetValue !== (condition as ComparisonCondition).value;
|
|
68
|
+
case "GREATER_THAN":
|
|
69
|
+
return targetValue > (condition as ComparisonCondition).value;
|
|
70
|
+
case "LESS_THAN":
|
|
71
|
+
return targetValue < (condition as ComparisonCondition).value;
|
|
72
|
+
case "CONTAINS":
|
|
73
|
+
return (
|
|
74
|
+
Array.isArray(targetValue) && targetValue.includes((condition as ComparisonCondition).value)
|
|
75
|
+
);
|
|
76
|
+
case "NOT_CONTAINS":
|
|
77
|
+
return (
|
|
78
|
+
Array.isArray(targetValue) &&
|
|
79
|
+
!targetValue.includes((condition as ComparisonCondition).value)
|
|
80
|
+
);
|
|
81
|
+
case "MATCHES":
|
|
82
|
+
return new RegExp((condition as ComparisonCondition).value).test(String(targetValue));
|
|
83
|
+
case "STARTS_WITH":
|
|
84
|
+
return String(targetValue).startsWith((condition as ComparisonCondition).value);
|
|
85
|
+
case "ENDS_WITH":
|
|
86
|
+
return String(targetValue).endsWith((condition as ComparisonCondition).value);
|
|
87
|
+
|
|
88
|
+
// Existence
|
|
89
|
+
case "EXISTS":
|
|
90
|
+
return targetValue !== undefined && targetValue !== null;
|
|
91
|
+
case "NOT_EXISTS":
|
|
92
|
+
return targetValue === undefined || targetValue === null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getValueFromPath(obj: any, path: string): any {
|
|
97
|
+
return path.split(".").reduce((acc, part) => acc?.[part], obj);
|
|
98
|
+
}
|
package/src/utils/index.ts
CHANGED
package/src/utils/random-id.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v4 as uuidv4, validate } from "uuid";
|
|
1
|
+
import { v4 as uuidv4, validate, v5 as uuidv5 } from "uuid";
|
|
2
2
|
|
|
3
3
|
export function randomId() {
|
|
4
4
|
return "ck-" + uuidv4();
|
|
@@ -8,6 +8,13 @@ export function randomUUID() {
|
|
|
8
8
|
return uuidv4();
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export function dataToUUID(input: string, namespace?: string): string {
|
|
12
|
+
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
|
|
13
|
+
// Since namespace needs to be a uuid, we are creating a uuid for it.
|
|
14
|
+
const boundNamespace = namespace ? uuidv5(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
|
|
15
|
+
return uuidv5(input, boundNamespace);
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
export function isValidUUID(uuid: string) {
|
|
12
19
|
return validate(uuid);
|
|
13
20
|
}
|
package/dist/chunk-53DC2JUS.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// src/utils/random-id.ts
|
|
2
|
-
import { v4 as uuidv4, validate } from "uuid";
|
|
3
|
-
function randomId() {
|
|
4
|
-
return "ck-" + uuidv4();
|
|
5
|
-
}
|
|
6
|
-
function randomUUID() {
|
|
7
|
-
return uuidv4();
|
|
8
|
-
}
|
|
9
|
-
function isValidUUID(uuid) {
|
|
10
|
-
return validate(uuid);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
randomId,
|
|
15
|
-
randomUUID,
|
|
16
|
-
isValidUUID
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=chunk-53DC2JUS.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/random-id.ts"],"sourcesContent":["import { v4 as uuidv4, validate } from \"uuid\";\n\nexport function randomId() {\n return \"ck-\" + uuidv4();\n}\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function isValidUUID(uuid: string) {\n return validate(uuid);\n}\n"],"mappings":";AAAA,SAAS,MAAM,QAAQ,gBAAgB;AAEhC,SAAS,WAAW;AACzB,SAAO,QAAQ,OAAO;AACxB;AAEO,SAAS,aAAa;AAC3B,SAAO,OAAO;AAChB;AAEO,SAAS,YAAY,MAAc;AACxC,SAAO,SAAS,IAAI;AACtB;","names":[]}
|
package/dist/chunk-GED6IT3S.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-GED6IT3S.mjs.map
|
|
File without changes
|