@copilotkit/shared 0.0.0-0.0.0-max-changeset-10101010101010-20260109191632

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.
Files changed (185) hide show
  1. package/CHANGELOG.md +1800 -0
  2. package/LICENSE +21 -0
  3. package/README.md +141 -0
  4. package/dist/chunk-2OJ5OJ2D.mjs +1 -0
  5. package/dist/chunk-2OJ5OJ2D.mjs.map +1 -0
  6. package/dist/chunk-5YXKLIUO.mjs +38 -0
  7. package/dist/chunk-5YXKLIUO.mjs.map +1 -0
  8. package/dist/chunk-64DYJ27R.mjs +201 -0
  9. package/dist/chunk-64DYJ27R.mjs.map +1 -0
  10. package/dist/chunk-6QGXWNS5.mjs +34 -0
  11. package/dist/chunk-6QGXWNS5.mjs.map +1 -0
  12. package/dist/chunk-6W2UEO2M.mjs +94 -0
  13. package/dist/chunk-6W2UEO2M.mjs.map +1 -0
  14. package/dist/chunk-BOKE4OKY.mjs +41 -0
  15. package/dist/chunk-BOKE4OKY.mjs.map +1 -0
  16. package/dist/chunk-FCCOSO5L.mjs +1 -0
  17. package/dist/chunk-FCCOSO5L.mjs.map +1 -0
  18. package/dist/chunk-GYZIHHE6.mjs +13 -0
  19. package/dist/chunk-GYZIHHE6.mjs.map +1 -0
  20. package/dist/chunk-IAFBVORQ.mjs +1 -0
  21. package/dist/chunk-IAFBVORQ.mjs.map +1 -0
  22. package/dist/chunk-MSUB6DGR.mjs +1 -0
  23. package/dist/chunk-MSUB6DGR.mjs.map +1 -0
  24. package/dist/chunk-N5EP5OD5.mjs +1 -0
  25. package/dist/chunk-N5EP5OD5.mjs.map +1 -0
  26. package/dist/chunk-NAFEBKSO.mjs +1 -0
  27. package/dist/chunk-NAFEBKSO.mjs.map +1 -0
  28. package/dist/chunk-NBLG4PC5.mjs +426 -0
  29. package/dist/chunk-NBLG4PC5.mjs.map +1 -0
  30. package/dist/chunk-P7STFMPO.mjs +1 -0
  31. package/dist/chunk-P7STFMPO.mjs.map +1 -0
  32. package/dist/chunk-PL5WNHFZ.mjs +50 -0
  33. package/dist/chunk-PL5WNHFZ.mjs.map +1 -0
  34. package/dist/chunk-UYARLQNA.mjs +1 -0
  35. package/dist/chunk-UYARLQNA.mjs.map +1 -0
  36. package/dist/chunk-WUPFNPXO.mjs +107 -0
  37. package/dist/chunk-WUPFNPXO.mjs.map +1 -0
  38. package/dist/chunk-XEMZTHQZ.mjs +67 -0
  39. package/dist/chunk-XEMZTHQZ.mjs.map +1 -0
  40. package/dist/chunk-XTHC46M2.mjs +1 -0
  41. package/dist/chunk-XTHC46M2.mjs.map +1 -0
  42. package/dist/constants/index.d.ts +6 -0
  43. package/dist/constants/index.js +40 -0
  44. package/dist/constants/index.js.map +1 -0
  45. package/dist/constants/index.mjs +13 -0
  46. package/dist/constants/index.mjs.map +1 -0
  47. package/dist/index.d.ts +25 -0
  48. package/dist/index.js +1098 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/index.mjs +124 -0
  51. package/dist/index.mjs.map +1 -0
  52. package/dist/telemetry/events.d.ts +45 -0
  53. package/dist/telemetry/events.js +19 -0
  54. package/dist/telemetry/events.js.map +1 -0
  55. package/dist/telemetry/events.mjs +1 -0
  56. package/dist/telemetry/events.mjs.map +1 -0
  57. package/dist/telemetry/index.d.ts +3 -0
  58. package/dist/telemetry/index.js +188 -0
  59. package/dist/telemetry/index.js.map +1 -0
  60. package/dist/telemetry/index.mjs +12 -0
  61. package/dist/telemetry/index.mjs.map +1 -0
  62. package/dist/telemetry/scarf-client.d.ts +7 -0
  63. package/dist/telemetry/scarf-client.js +59 -0
  64. package/dist/telemetry/scarf-client.js.map +1 -0
  65. package/dist/telemetry/scarf-client.mjs +7 -0
  66. package/dist/telemetry/scarf-client.mjs.map +1 -0
  67. package/dist/telemetry/security-check.d.ts +2 -0
  68. package/dist/telemetry/security-check.js +2 -0
  69. package/dist/telemetry/security-check.js.map +1 -0
  70. package/dist/telemetry/security-check.mjs +1 -0
  71. package/dist/telemetry/security-check.mjs.map +1 -0
  72. package/dist/telemetry/telemetry-client.d.ts +40 -0
  73. package/dist/telemetry/telemetry-client.js +186 -0
  74. package/dist/telemetry/telemetry-client.js.map +1 -0
  75. package/dist/telemetry/telemetry-client.mjs +11 -0
  76. package/dist/telemetry/telemetry-client.mjs.map +1 -0
  77. package/dist/telemetry/utils.d.ts +8 -0
  78. package/dist/telemetry/utils.js +69 -0
  79. package/dist/telemetry/utils.js.map +1 -0
  80. package/dist/telemetry/utils.mjs +9 -0
  81. package/dist/telemetry/utils.mjs.map +1 -0
  82. package/dist/types/action.d.ts +59 -0
  83. package/dist/types/action.js +19 -0
  84. package/dist/types/action.js.map +1 -0
  85. package/dist/types/action.mjs +2 -0
  86. package/dist/types/action.mjs.map +1 -0
  87. package/dist/types/copilot-cloud-config.d.ts +13 -0
  88. package/dist/types/copilot-cloud-config.js +19 -0
  89. package/dist/types/copilot-cloud-config.js.map +1 -0
  90. package/dist/types/copilot-cloud-config.mjs +2 -0
  91. package/dist/types/copilot-cloud-config.mjs.map +1 -0
  92. package/dist/types/error.d.ts +55 -0
  93. package/dist/types/error.js +19 -0
  94. package/dist/types/error.js.map +1 -0
  95. package/dist/types/error.mjs +2 -0
  96. package/dist/types/error.mjs.map +1 -0
  97. package/dist/types/index.d.ts +7 -0
  98. package/dist/types/index.js +19 -0
  99. package/dist/types/index.js.map +1 -0
  100. package/dist/types/index.mjs +8 -0
  101. package/dist/types/index.mjs.map +1 -0
  102. package/dist/types/message.d.ts +26 -0
  103. package/dist/types/message.js +19 -0
  104. package/dist/types/message.js.map +1 -0
  105. package/dist/types/message.mjs +2 -0
  106. package/dist/types/message.mjs.map +1 -0
  107. package/dist/types/openai-assistant.d.ts +53 -0
  108. package/dist/types/openai-assistant.js +19 -0
  109. package/dist/types/openai-assistant.js.map +1 -0
  110. package/dist/types/openai-assistant.mjs +2 -0
  111. package/dist/types/openai-assistant.mjs.map +1 -0
  112. package/dist/types/utility.d.ts +6 -0
  113. package/dist/types/utility.js +19 -0
  114. package/dist/types/utility.js.map +1 -0
  115. package/dist/types/utility.mjs +2 -0
  116. package/dist/types/utility.mjs.map +1 -0
  117. package/dist/utils/conditions.d.ts +26 -0
  118. package/dist/utils/conditions.js +74 -0
  119. package/dist/utils/conditions.js.map +1 -0
  120. package/dist/utils/conditions.mjs +7 -0
  121. package/dist/utils/conditions.mjs.map +1 -0
  122. package/dist/utils/console-styling.d.ts +84 -0
  123. package/dist/utils/console-styling.js +123 -0
  124. package/dist/utils/console-styling.js.map +1 -0
  125. package/dist/utils/console-styling.mjs +17 -0
  126. package/dist/utils/console-styling.mjs.map +1 -0
  127. package/dist/utils/errors.d.ts +280 -0
  128. package/dist/utils/errors.js +443 -0
  129. package/dist/utils/errors.js.map +1 -0
  130. package/dist/utils/errors.mjs +65 -0
  131. package/dist/utils/errors.mjs.map +1 -0
  132. package/dist/utils/index.d.ts +32 -0
  133. package/dist/utils/index.js +927 -0
  134. package/dist/utils/index.js.map +1 -0
  135. package/dist/utils/index.mjs +108 -0
  136. package/dist/utils/index.mjs.map +1 -0
  137. package/dist/utils/json-schema.d.ts +34 -0
  138. package/dist/utils/json-schema.js +228 -0
  139. package/dist/utils/json-schema.js.map +1 -0
  140. package/dist/utils/json-schema.mjs +13 -0
  141. package/dist/utils/json-schema.mjs.map +1 -0
  142. package/dist/utils/random-id.d.ts +6 -0
  143. package/dist/utils/random-id.js +68 -0
  144. package/dist/utils/random-id.js.map +1 -0
  145. package/dist/utils/random-id.mjs +13 -0
  146. package/dist/utils/random-id.mjs.map +1 -0
  147. package/dist/utils/requests.d.ts +10 -0
  148. package/dist/utils/requests.js +91 -0
  149. package/dist/utils/requests.js.map +1 -0
  150. package/dist/utils/requests.mjs +7 -0
  151. package/dist/utils/requests.mjs.map +1 -0
  152. package/dist/utils/types.d.ts +20 -0
  153. package/dist/utils/types.js +19 -0
  154. package/dist/utils/types.js.map +1 -0
  155. package/dist/utils/types.mjs +2 -0
  156. package/dist/utils/types.mjs.map +1 -0
  157. package/jest.config.js +5 -0
  158. package/package.json +68 -0
  159. package/src/constants/index.ts +4 -0
  160. package/src/index.ts +7 -0
  161. package/src/telemetry/events.ts +41 -0
  162. package/src/telemetry/index.ts +1 -0
  163. package/src/telemetry/scarf-client.ts +39 -0
  164. package/src/telemetry/security-check.ts +0 -0
  165. package/src/telemetry/telemetry-client.ts +142 -0
  166. package/src/telemetry/utils.ts +39 -0
  167. package/src/types/action.ts +129 -0
  168. package/src/types/copilot-cloud-config.ts +11 -0
  169. package/src/types/error.ts +70 -0
  170. package/src/types/index.ts +6 -0
  171. package/src/types/message.ts +37 -0
  172. package/src/types/openai-assistant.ts +62 -0
  173. package/src/types/utility.ts +2 -0
  174. package/src/utils/conditions.ts +98 -0
  175. package/src/utils/console-styling.ts +124 -0
  176. package/src/utils/errors.ts +525 -0
  177. package/src/utils/index.ts +49 -0
  178. package/src/utils/json-schema.test.ts +383 -0
  179. package/src/utils/json-schema.ts +258 -0
  180. package/src/utils/random-id.ts +42 -0
  181. package/src/utils/requests.ts +77 -0
  182. package/src/utils/types.ts +22 -0
  183. package/tsconfig.json +9 -0
  184. package/tsup.config.ts +11 -0
  185. package/typedoc.json +4 -0
@@ -0,0 +1,123 @@
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/console-styling.ts
21
+ var console_styling_exports = {};
22
+ __export(console_styling_exports, {
23
+ ConsoleColors: () => ConsoleColors,
24
+ ConsoleStyles: () => ConsoleStyles,
25
+ logCopilotKitPlatformMessage: () => logCopilotKitPlatformMessage,
26
+ logStyled: () => logStyled,
27
+ publicApiKeyRequired: () => publicApiKeyRequired,
28
+ styledConsole: () => styledConsole
29
+ });
30
+ module.exports = __toCommonJS(console_styling_exports);
31
+ var ConsoleColors = {
32
+ /** Primary brand blue - for titles and links */
33
+ primary: "#007acc",
34
+ /** Success green - for positive messaging */
35
+ success: "#22c55e",
36
+ /** Purple - for feature highlights */
37
+ feature: "#a855f7",
38
+ /** Red - for calls-to-action */
39
+ cta: "#ef4444",
40
+ /** Cyan - for closing statements */
41
+ info: "#06b6d4",
42
+ /** Inherit console default - for body text */
43
+ inherit: "inherit",
44
+ /** Warning style */
45
+ warning: "#f59e0b"
46
+ };
47
+ var ConsoleStyles = {
48
+ /** Large header style */
49
+ header: `color: ${ConsoleColors.warning}; font-weight: bold; font-size: 16px;`,
50
+ /** Section header style */
51
+ section: `color: ${ConsoleColors.success}; font-weight: bold;`,
52
+ /** Feature highlight style */
53
+ highlight: `color: ${ConsoleColors.feature}; font-weight: bold;`,
54
+ /** Call-to-action style */
55
+ cta: `color: ${ConsoleColors.success}; font-weight: bold;`,
56
+ /** Info style */
57
+ info: `color: ${ConsoleColors.info}; font-weight: bold;`,
58
+ /** Link style */
59
+ link: `color: ${ConsoleColors.primary}; text-decoration: underline;`,
60
+ /** Body text - inherits console theme */
61
+ body: `color: ${ConsoleColors.inherit};`,
62
+ /** Warning style */
63
+ warning: `color: ${ConsoleColors.cta}; font-weight: bold;`
64
+ };
65
+ function logCopilotKitPlatformMessage() {
66
+ console.log(
67
+ `%cCopilotKit Warning%c
68
+
69
+ useCopilotChatHeadless_c provides full compatibility with CopilotKit's newly released Headless UI feature set. To enable this premium feature, add your public license key, available for free at:
70
+
71
+ %chttps://cloud.copilotkit.ai%c
72
+
73
+ Alternatively, useCopilotChat is available for basic programmatic control, and does not require an API key.
74
+
75
+ To learn more about premium features, read the documentation here:
76
+
77
+ %chttps://docs.copilotkit.ai/premium%c`,
78
+ ConsoleStyles.header,
79
+ ConsoleStyles.body,
80
+ ConsoleStyles.cta,
81
+ ConsoleStyles.body,
82
+ ConsoleStyles.link,
83
+ ConsoleStyles.body
84
+ );
85
+ }
86
+ function publicApiKeyRequired(feature) {
87
+ console.log(
88
+ `
89
+ %cCopilotKit Warning%c
90
+
91
+ In order to use ${feature}, you need to add your CopilotKit API key, available for free at https://cloud.copilotkit.ai.
92
+ `.trim(),
93
+ ConsoleStyles.header,
94
+ ConsoleStyles.body
95
+ );
96
+ }
97
+ function logStyled(template, styles) {
98
+ console.log(template, ...styles);
99
+ }
100
+ var styledConsole = {
101
+ /** Log a success message */
102
+ success: (message) => logStyled(`%c\u2705 ${message}`, [ConsoleStyles.section]),
103
+ /** Log an info message */
104
+ info: (message) => logStyled(`%c\u2139\uFE0F ${message}`, [ConsoleStyles.info]),
105
+ /** Log a feature highlight */
106
+ feature: (message) => logStyled(`%c\u2728 ${message}`, [ConsoleStyles.highlight]),
107
+ /** Log a call-to-action */
108
+ cta: (message) => logStyled(`%c\u{1F680} ${message}`, [ConsoleStyles.cta]),
109
+ /** Log the CopilotKit platform promotion */
110
+ logCopilotKitPlatformMessage,
111
+ /** Log a `publicApiKeyRequired` warning */
112
+ publicApiKeyRequired
113
+ };
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ ConsoleColors,
117
+ ConsoleStyles,
118
+ logCopilotKitPlatformMessage,
119
+ logStyled,
120
+ publicApiKeyRequired,
121
+ styledConsole
122
+ });
123
+ //# sourceMappingURL=console-styling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/console-styling.ts"],"sourcesContent":["/**\n * Console styling utilities for CopilotKit branded messages\n * Provides consistent, readable colors across light and dark console themes\n */\n\n/**\n * Color palette optimized for console readability\n */\nexport const ConsoleColors = {\n /** Primary brand blue - for titles and links */\n primary: \"#007acc\",\n /** Success green - for positive messaging */\n success: \"#22c55e\",\n /** Purple - for feature highlights */\n feature: \"#a855f7\",\n /** Red - for calls-to-action */\n cta: \"#ef4444\",\n /** Cyan - for closing statements */\n info: \"#06b6d4\",\n /** Inherit console default - for body text */\n inherit: \"inherit\",\n /** Warning style */\n warning: \"#f59e0b\",\n} as const;\n\n/**\n * Console style templates for common patterns\n */\nexport const ConsoleStyles = {\n /** Large header style */\n header: `color: ${ConsoleColors.warning}; font-weight: bold; font-size: 16px;`,\n /** Section header style */\n section: `color: ${ConsoleColors.success}; font-weight: bold;`,\n /** Feature highlight style */\n highlight: `color: ${ConsoleColors.feature}; font-weight: bold;`,\n /** Call-to-action style */\n cta: `color: ${ConsoleColors.success}; font-weight: bold;`,\n /** Info style */\n info: `color: ${ConsoleColors.info}; font-weight: bold;`,\n /** Link style */\n link: `color: ${ConsoleColors.primary}; text-decoration: underline;`,\n /** Body text - inherits console theme */\n body: `color: ${ConsoleColors.inherit};`,\n /** Warning style */\n warning: `color: ${ConsoleColors.cta}; font-weight: bold;`,\n} as const;\n\n/**\n * Styled console message for CopilotKit Platform promotion\n * Displays a beautiful, branded advertisement in the console\n */\nexport function logCopilotKitPlatformMessage() {\n console.log(\n `%cCopilotKit Warning%c\n\nuseCopilotChatHeadless_c provides full compatibility with CopilotKit's newly released Headless UI feature set. To enable this premium feature, add your public license key, available for free at:\n\n%chttps://cloud.copilotkit.ai%c\n\nAlternatively, useCopilotChat is available for basic programmatic control, and does not require an API key.\n\nTo learn more about premium features, read the documentation here:\n\n%chttps://docs.copilotkit.ai/premium%c`,\n ConsoleStyles.header,\n ConsoleStyles.body,\n ConsoleStyles.cta,\n ConsoleStyles.body,\n ConsoleStyles.link,\n ConsoleStyles.body,\n );\n}\n\nexport function publicApiKeyRequired(feature: string) {\n console.log(\n `\n%cCopilotKit Warning%c \\n\nIn order to use ${feature}, you need to add your CopilotKit API key, available for free at https://cloud.copilotkit.ai.\n `.trim(),\n ConsoleStyles.header,\n ConsoleStyles.body,\n );\n}\n\n/**\n * Create a styled console message with custom content\n *\n * @param template - Template string with %c placeholders\n * @param styles - Array of style strings matching the %c placeholders\n *\n * @example\n * ```typescript\n * logStyled(\n * '%cCopilotKit%c Welcome to the platform!',\n * [ConsoleStyles.header, ConsoleStyles.body]\n * );\n * ```\n */\nexport function logStyled(template: string, styles: string[]) {\n console.log(template, ...styles);\n}\n\n/**\n * Quick styled console methods for common use cases\n */\nexport const styledConsole = {\n /** Log a success message */\n success: (message: string) => logStyled(`%c✅ ${message}`, [ConsoleStyles.section]),\n\n /** Log an info message */\n info: (message: string) => logStyled(`%cℹ️ ${message}`, [ConsoleStyles.info]),\n\n /** Log a feature highlight */\n feature: (message: string) => logStyled(`%c✨ ${message}`, [ConsoleStyles.highlight]),\n\n /** Log a call-to-action */\n cta: (message: string) => logStyled(`%c🚀 ${message}`, [ConsoleStyles.cta]),\n\n /** Log the CopilotKit platform promotion */\n logCopilotKitPlatformMessage: logCopilotKitPlatformMessage,\n\n /** Log a `publicApiKeyRequired` warning */\n publicApiKeyRequired: publicApiKeyRequired,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,IAAM,gBAAgB;AAAA;AAAA,EAE3B,SAAS;AAAA;AAAA,EAET,SAAS;AAAA;AAAA,EAET,SAAS;AAAA;AAAA,EAET,KAAK;AAAA;AAAA,EAEL,MAAM;AAAA;AAAA,EAEN,SAAS;AAAA;AAAA,EAET,SAAS;AACX;AAKO,IAAM,gBAAgB;AAAA;AAAA,EAE3B,QAAQ,UAAU,cAAc;AAAA;AAAA,EAEhC,SAAS,UAAU,cAAc;AAAA;AAAA,EAEjC,WAAW,UAAU,cAAc;AAAA;AAAA,EAEnC,KAAK,UAAU,cAAc;AAAA;AAAA,EAE7B,MAAM,UAAU,cAAc;AAAA;AAAA,EAE9B,MAAM,UAAU,cAAc;AAAA;AAAA,EAE9B,MAAM,UAAU,cAAc;AAAA;AAAA,EAE9B,SAAS,UAAU,cAAc;AACnC;AAMO,SAAS,+BAA+B;AAC7C,UAAQ;AAAA,IACN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,EAChB;AACF;AAEO,SAAS,qBAAqB,SAAiB;AACpD,UAAQ;AAAA,IACN;AAAA;AAAA;AAAA,kBAEc;AAAA,MACZ,KAAK;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,EAChB;AACF;AAgBO,SAAS,UAAU,UAAkB,QAAkB;AAC5D,UAAQ,IAAI,UAAU,GAAG,MAAM;AACjC;AAKO,IAAM,gBAAgB;AAAA;AAAA,EAE3B,SAAS,CAAC,YAAoB,UAAU,YAAO,WAAW,CAAC,cAAc,OAAO,CAAC;AAAA;AAAA,EAGjF,MAAM,CAAC,YAAoB,UAAU,kBAAQ,WAAW,CAAC,cAAc,IAAI,CAAC;AAAA;AAAA,EAG5E,SAAS,CAAC,YAAoB,UAAU,YAAO,WAAW,CAAC,cAAc,SAAS,CAAC;AAAA;AAAA,EAGnF,KAAK,CAAC,YAAoB,UAAU,eAAQ,WAAW,CAAC,cAAc,GAAG,CAAC;AAAA;AAAA,EAG1E;AAAA;AAAA,EAGA;AACF;","names":[]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ ConsoleColors,
3
+ ConsoleStyles,
4
+ logCopilotKitPlatformMessage,
5
+ logStyled,
6
+ publicApiKeyRequired,
7
+ styledConsole
8
+ } from "../chunk-6W2UEO2M.mjs";
9
+ export {
10
+ ConsoleColors,
11
+ ConsoleStyles,
12
+ logCopilotKitPlatformMessage,
13
+ logStyled,
14
+ publicApiKeyRequired,
15
+ styledConsole
16
+ };
17
+ //# sourceMappingURL=console-styling.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,280 @@
1
+ import { GraphQLError } from 'graphql';
2
+
3
+ declare enum Severity {
4
+ CRITICAL = "critical",// Critical errors that block core functionality
5
+ WARNING = "warning",// Configuration/setup issues that need attention
6
+ INFO = "info"
7
+ }
8
+ declare enum ErrorVisibility {
9
+ BANNER = "banner",// Critical errors shown as fixed banners
10
+ TOAST = "toast",// Regular errors shown as dismissible toasts
11
+ SILENT = "silent",// Errors logged but not shown to user
12
+ DEV_ONLY = "dev_only"
13
+ }
14
+ declare const ERROR_NAMES: {
15
+ readonly COPILOT_ERROR: "CopilotError";
16
+ readonly COPILOT_API_DISCOVERY_ERROR: "CopilotApiDiscoveryError";
17
+ readonly COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError";
18
+ readonly COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError";
19
+ readonly COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError";
20
+ readonly COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError";
21
+ readonly RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError";
22
+ readonly CONFIGURATION_ERROR: "ConfigurationError";
23
+ readonly MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError";
24
+ readonly UPGRADE_REQUIRED_ERROR: "UpgradeRequiredError";
25
+ };
26
+ declare const BANNER_ERROR_NAMES: ("CopilotApiDiscoveryError" | "CopilotKitRemoteEndpointDiscoveryError" | "CopilotKitAgentDiscoveryError" | "ConfigurationError" | "MissingPublicApiKeyError" | "UpgradeRequiredError")[];
27
+ declare const COPILOT_CLOUD_ERROR_NAMES: ("CopilotApiDiscoveryError" | "CopilotKitRemoteEndpointDiscoveryError" | "CopilotKitAgentDiscoveryError" | "ConfigurationError" | "MissingPublicApiKeyError" | "UpgradeRequiredError")[];
28
+ declare enum CopilotKitErrorCode {
29
+ NETWORK_ERROR = "NETWORK_ERROR",
30
+ NOT_FOUND = "NOT_FOUND",
31
+ AGENT_NOT_FOUND = "AGENT_NOT_FOUND",
32
+ API_NOT_FOUND = "API_NOT_FOUND",
33
+ REMOTE_ENDPOINT_NOT_FOUND = "REMOTE_ENDPOINT_NOT_FOUND",
34
+ AUTHENTICATION_ERROR = "AUTHENTICATION_ERROR",
35
+ MISUSE = "MISUSE",
36
+ UNKNOWN = "UNKNOWN",
37
+ VERSION_MISMATCH = "VERSION_MISMATCH",
38
+ CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
39
+ MISSING_PUBLIC_API_KEY_ERROR = "MISSING_PUBLIC_API_KEY_ERROR",
40
+ UPGRADE_REQUIRED_ERROR = "UPGRADE_REQUIRED_ERROR"
41
+ }
42
+ declare const ERROR_CONFIG: {
43
+ NETWORK_ERROR: {
44
+ statusCode: number;
45
+ troubleshootingUrl: string;
46
+ visibility: ErrorVisibility;
47
+ severity: Severity;
48
+ };
49
+ NOT_FOUND: {
50
+ statusCode: number;
51
+ troubleshootingUrl: string;
52
+ visibility: ErrorVisibility;
53
+ severity: Severity;
54
+ };
55
+ AGENT_NOT_FOUND: {
56
+ statusCode: number;
57
+ troubleshootingUrl: string;
58
+ visibility: ErrorVisibility;
59
+ severity: Severity;
60
+ };
61
+ API_NOT_FOUND: {
62
+ statusCode: number;
63
+ troubleshootingUrl: string;
64
+ visibility: ErrorVisibility;
65
+ severity: Severity;
66
+ };
67
+ REMOTE_ENDPOINT_NOT_FOUND: {
68
+ statusCode: number;
69
+ troubleshootingUrl: string;
70
+ visibility: ErrorVisibility;
71
+ severity: Severity;
72
+ };
73
+ AUTHENTICATION_ERROR: {
74
+ statusCode: number;
75
+ troubleshootingUrl: string;
76
+ visibility: ErrorVisibility;
77
+ severity: Severity;
78
+ };
79
+ MISUSE: {
80
+ statusCode: number;
81
+ troubleshootingUrl: null;
82
+ visibility: ErrorVisibility;
83
+ severity: Severity;
84
+ };
85
+ UNKNOWN: {
86
+ statusCode: number;
87
+ visibility: ErrorVisibility;
88
+ severity: Severity;
89
+ };
90
+ CONFIGURATION_ERROR: {
91
+ statusCode: number;
92
+ troubleshootingUrl: null;
93
+ severity: Severity;
94
+ visibility: ErrorVisibility;
95
+ };
96
+ MISSING_PUBLIC_API_KEY_ERROR: {
97
+ statusCode: number;
98
+ troubleshootingUrl: null;
99
+ severity: Severity;
100
+ visibility: ErrorVisibility;
101
+ };
102
+ UPGRADE_REQUIRED_ERROR: {
103
+ statusCode: number;
104
+ troubleshootingUrl: null;
105
+ severity: Severity;
106
+ visibility: ErrorVisibility;
107
+ };
108
+ VERSION_MISMATCH: {
109
+ statusCode: number;
110
+ troubleshootingUrl: null;
111
+ visibility: ErrorVisibility;
112
+ severity: Severity;
113
+ };
114
+ };
115
+ declare class CopilotKitError extends GraphQLError {
116
+ code: CopilotKitErrorCode;
117
+ statusCode: number;
118
+ severity?: Severity;
119
+ visibility: ErrorVisibility;
120
+ constructor({ message, code, severity, visibility, }: {
121
+ message?: string;
122
+ code: CopilotKitErrorCode;
123
+ severity?: Severity;
124
+ visibility?: ErrorVisibility;
125
+ });
126
+ }
127
+ /**
128
+ * Error thrown when we can identify wrong usage of our components.
129
+ * This helps us notify the developer before real errors can happen
130
+ *
131
+ * @extends CopilotKitError
132
+ */
133
+ declare class CopilotKitMisuseError extends CopilotKitError {
134
+ constructor({ message, code, }: {
135
+ message: string;
136
+ code?: CopilotKitErrorCode;
137
+ });
138
+ }
139
+ /**
140
+ * Error thrown when CPK versions does not match
141
+ *
142
+ * @extends CopilotKitError
143
+ */
144
+ declare class CopilotKitVersionMismatchError extends CopilotKitError {
145
+ constructor({ reactCoreVersion, runtimeVersion, runtimeClientGqlVersion, }: VersionMismatchResponse);
146
+ }
147
+ /**
148
+ * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.
149
+ * This typically occurs when:
150
+ * - The API endpoint URL is invalid or misconfigured
151
+ * - The API service is not running at the expected location
152
+ * - There are network/firewall issues preventing access
153
+ *
154
+ * @extends CopilotKitError
155
+ */
156
+ declare class CopilotKitApiDiscoveryError extends CopilotKitError {
157
+ constructor(params?: {
158
+ message?: string;
159
+ code?: CopilotKitErrorCode.API_NOT_FOUND | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;
160
+ url?: string;
161
+ });
162
+ }
163
+ /**
164
+ * This error is used for endpoints specified in runtime's remote endpoints. If they cannot be contacted
165
+ * This typically occurs when:
166
+ * - The API endpoint URL is invalid or misconfigured
167
+ * - The API service is not running at the expected location
168
+ *
169
+ * @extends CopilotKitApiDiscoveryError
170
+ */
171
+ declare class CopilotKitRemoteEndpointDiscoveryError extends CopilotKitApiDiscoveryError {
172
+ constructor(params?: {
173
+ message?: string;
174
+ url?: string;
175
+ });
176
+ }
177
+ /**
178
+ * Error thrown when a LangGraph agent cannot be found or accessed.
179
+ * This typically occurs when:
180
+ * - The specified agent name does not exist in the deployment
181
+ * - The agent configuration is invalid or missing
182
+ * - The agent service is not properly deployed or initialized
183
+ *
184
+ * @extends CopilotKitError
185
+ */
186
+ declare class CopilotKitAgentDiscoveryError extends CopilotKitError {
187
+ constructor(params: {
188
+ agentName?: string;
189
+ availableAgents: {
190
+ name: string;
191
+ id: string;
192
+ }[];
193
+ });
194
+ }
195
+ /**
196
+ * Handles low-level networking errors that occur before a request reaches the server.
197
+ * These errors arise from issues in the underlying communication infrastructure rather than
198
+ * application-level logic or server responses. Typically used to handle "fetch failed" errors
199
+ * where no HTTP status code is available.
200
+ *
201
+ * Common scenarios include:
202
+ * - Connection failures (ECONNREFUSED) when server is down/unreachable
203
+ * - DNS resolution failures (ENOTFOUND) when domain can't be resolved
204
+ * - Timeouts (ETIMEDOUT) when request takes too long
205
+ * - Protocol/transport layer errors like SSL/TLS issues
206
+ */
207
+ declare class CopilotKitLowLevelError extends CopilotKitError {
208
+ constructor({ error, url, message }: {
209
+ error: Error;
210
+ url: string;
211
+ message?: string;
212
+ });
213
+ }
214
+ /**
215
+ * Generic catch-all error handler for HTTP responses from the CopilotKit API where a status code is available.
216
+ * Used when we receive an HTTP error status and wish to handle broad range of them
217
+ *
218
+ * This differs from CopilotKitLowLevelError in that:
219
+ * - ResolvedCopilotKitError: Server was reached and returned an HTTP status
220
+ * - CopilotKitLowLevelError: Error occurred before reaching server (e.g. network failure)
221
+ *
222
+ * @param status - The HTTP status code received from the API response
223
+ * @param message - Optional error message to include
224
+ * @param code - Optional specific CopilotKitErrorCode to override default behavior
225
+ *
226
+ * Default behavior:
227
+ * - 400 Bad Request: Maps to CopilotKitApiDiscoveryError
228
+ * - All other status codes: Maps to UNKNOWN error code if no specific code provided
229
+ */
230
+ declare class ResolvedCopilotKitError extends CopilotKitError {
231
+ constructor({ status, message, code, isRemoteEndpoint, url, }: {
232
+ status: number;
233
+ message?: string;
234
+ code?: CopilotKitErrorCode;
235
+ isRemoteEndpoint?: boolean;
236
+ url?: string;
237
+ });
238
+ }
239
+ declare class ConfigurationError extends CopilotKitError {
240
+ constructor(message: string);
241
+ }
242
+ declare class MissingPublicApiKeyError extends ConfigurationError {
243
+ constructor(message: string);
244
+ }
245
+ declare class UpgradeRequiredError extends ConfigurationError {
246
+ constructor(message: string);
247
+ }
248
+ /**
249
+ * Checks if an error is already a structured CopilotKit error.
250
+ * This utility centralizes the logic for detecting structured errors across the codebase.
251
+ *
252
+ * @param error - The error to check
253
+ * @returns true if the error is already structured, false otherwise
254
+ */
255
+ declare function isStructuredCopilotKitError(error: any): boolean;
256
+ /**
257
+ * Returns the error as-is if it's already structured, otherwise converts it using the provided converter function.
258
+ * This utility centralizes the pattern of preserving structured errors while converting unstructured ones.
259
+ *
260
+ * @param error - The error to process
261
+ * @param converter - Function to convert unstructured errors to structured ones
262
+ * @returns The structured error
263
+ */
264
+ declare function ensureStructuredError<T extends CopilotKitError>(error: any, converter: (error: any) => T): T | any;
265
+ interface VersionMismatchResponse {
266
+ runtimeVersion?: string;
267
+ runtimeClientGqlVersion: string;
268
+ reactCoreVersion: string;
269
+ }
270
+ declare function getPossibleVersionMismatch({ runtimeVersion, runtimeClientGqlVersion, }: {
271
+ runtimeVersion?: string;
272
+ runtimeClientGqlVersion: string;
273
+ }): Promise<{
274
+ runtimeVersion: string;
275
+ runtimeClientGqlVersion: string;
276
+ reactCoreVersion: string;
277
+ message: string;
278
+ } | undefined>;
279
+
280
+ export { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError };