@xpert-ai/chatkit-types 0.0.7 → 0.0.9

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,15 +1,9 @@
1
- # @xpert-ai/chatkit-types
1
+ # ChatKit Types
2
2
 
3
- ## Publishing
3
+ This package is the type-definition library for ChatKit, providing unified, reusable API types for the ChatKit project.
4
4
 
5
- Quick local publish (interactive)
5
+ ## Role in the ChatKit project
6
6
 
7
- ```bash
8
- cd packages/chatkit
9
- # (optional) generate/verify type declarations
10
- pnpm run build
11
- # increment version (optional but recommended)
12
- pnpm version patch
13
- # publish (scoped packages require --access public)
14
- npm publish --access public --otp=
15
- ```
7
+ - Exposes the interface signatures and event types of `XpertAIChatKit`, ensuring consistency between integrators and internal implementation.
8
+ - Aggregates core chat-related types (such as `ChatKitOptions`, messages, attachments, widgets, interrupts) for reuse by the UI package and business side.
9
+ - Serves as a standalone types package so that the ChatKit Web Component and the XpertAI platform can obtain type hints and validation without bringing in implementation code.
package/dist/index.d.ts CHANGED
@@ -587,6 +587,12 @@ declare type CustomApiConfig = {
587
587
  * How attachments will be uploaded to your server. Required when attachments are enabled.
588
588
  */
589
589
  uploadStrategy?: FileUploadStrategy;
590
+ /**
591
+ * The base URL for the XpertAI platform hosted API. Used for accessing xpert agents
592
+ * and other platform features.
593
+ */
594
+ apiUrl: string;
595
+ xpertId?: string;
590
596
  };
591
597
 
592
598
  export declare type DatePicker = {
@@ -661,27 +667,6 @@ export declare type FileUploadStrategy = {
661
667
  uploadUrl: string;
662
668
  };
663
669
 
664
- /**
665
- * Filter out only the allowed options from a Playground config
666
- *
667
- * @param options - Full config copied from the playground
668
- * @returns An object containing only whitelisted options
669
- *
670
- * @example
671
- * ```ts
672
- * // Config copied from the playground
673
- * const playgroundConfig = {
674
- * theme: { colorScheme: 'light', radius: 'pill' },
675
- * threadItemActions: { feedback: true }, // will be filtered out
676
- * startScreen: { greeting: 'Hello!' },
677
- * };
678
- *
679
- * const filtered = filterPlaygroundOptions(playgroundConfig);
680
- * // Result: { theme: { colorScheme: 'light', radius: 'pill' }, startScreen: { greeting: 'Hello!' } }
681
- * ```
682
- */
683
- export declare function filterPlaygroundOptions<T extends Partial<ChatKitOptions>>(options: T): PlaygroundAllowedOptions;
684
-
685
670
  export declare type FontObject = {
686
671
  family: string;
687
672
  src: string;
@@ -712,6 +697,12 @@ declare type HostedApiConfig = {
712
697
  * Function to get a client token or refresh if the current token is expired.
713
698
  */
714
699
  getClientSecret: (currentClientSecret: string | null) => Promise<string>;
700
+ /**
701
+ * The base URL for the XpertAI platform hosted API. Used for accessing xpert agents
702
+ * and other platform features.
703
+ */
704
+ apiUrl: string;
705
+ xpertId?: string;
715
706
  };
716
707
 
717
708
  export declare type Icon = {
@@ -853,33 +844,6 @@ export declare type Markdown = {
853
844
  streaming?: boolean;
854
845
  };
855
846
 
856
- /**
857
- * Merge Playground config with local config
858
- * Playground config overrides matching items in local config (whitelist only)
859
- *
860
- * @param localOptions - Base config in the local project (can include onClientTool, header, etc.)
861
- * @param playgroundOptions - Config copied from the playground
862
- * @returns Merged config
863
- *
864
- * @example
865
- * ```ts
866
- * const localConfig = {
867
- * api: { getClientSecret: async () => '...' },
868
- * onClientTool: async () => { ... }, // kept
869
- * header: { enabled: true }, // kept
870
- * };
871
- *
872
- * const playgroundConfig = {
873
- * theme: { colorScheme: 'dark' },
874
- * threadItemActions: { feedback: true }, // filtered out
875
- * };
876
- *
877
- * const merged = mergeWithPlaygroundOptions(localConfig, playgroundConfig);
878
- * // Result: { api, onClientTool, header, theme }
879
- * ```
880
- */
881
- export declare function mergeWithPlaygroundOptions<T extends Partial<ChatKitOptions>>(localOptions: T, playgroundOptions: Partial<ChatKitOptions>): T & PlaygroundAllowedOptions;
882
-
883
847
  export declare type MessageContentImageUrl = {
884
848
  type: "image_url";
885
849
  image_url: string | {
@@ -906,20 +870,6 @@ export declare type ModelOption = {
906
870
  default?: boolean;
907
871
  };
908
872
 
909
- /**
910
- * Playground configuration whitelist - only allow these options to take effect when copied from the playground
911
- * Filters out: locale, initialThread, header, history, threadItemActions, disclaimer, entities, widgets, onClientTool
912
- */
913
- /**
914
- * Options allowed to be configured from Playground
915
- */
916
- export declare type PlaygroundAllowedOptions = {
917
- api?: ChatKitOptions['api'];
918
- theme?: ColorScheme | ChatKitTheme;
919
- composer?: ChatKitOptions['composer'];
920
- startScreen?: ChatKitOptions['startScreen'];
921
- };
922
-
923
873
  export declare type RadioGroup = {
924
874
  type: 'RadioGroup';
925
875
  key?: string;
@@ -966,6 +916,14 @@ export declare type Select = {
966
916
  disabled?: boolean;
967
917
  };
968
918
 
919
+ export declare type SendUserMessageParams = {
920
+ text: string;
921
+ state?: Record<string, any>;
922
+ reply?: string;
923
+ attachments?: Attachment[];
924
+ newThread?: boolean;
925
+ };
926
+
969
927
  export declare type Spacer = {
970
928
  type: 'Spacer';
971
929
  key?: string;
@@ -994,7 +952,7 @@ export declare const STATE_VARIABLE_HUMAN = "human";
994
952
  * All locales that are accepted by ChatKit without falling back to English.
995
953
  * Includes language codes that are resolved by ChatKit to a translated locale.
996
954
  */
997
- export declare type SupportedLocale = TranslatedLocale | 'bg' | 'bn' | 'bs' | 'ca' | 'cs' | 'da' | 'de' | 'el' | 'es' | 'et' | 'fi' | 'fr' | 'gu' | 'hi' | 'hr' | 'hu' | 'hy' | 'id' | 'is' | 'it' | 'ja' | 'ka' | 'kn' | 'ko' | 'lv' | 'mk' | 'mr' | 'ms' | 'my' | 'nb' | 'nl' | 'pl' | 'pt' | 'ro' | 'ru' | 'sk' | 'sl' | 'so' | 'sq' | 'sr' | 'sv' | 'sw' | 'ta' | 'te' | 'th' | 'tr' | 'uk' | 'vi' | 'zh' | 'zh-Hant' | 'en';
955
+ export declare type SupportedLocale = TranslatedLocale | 'bg' | 'bn' | 'bs' | 'ca' | 'cs' | 'da' | 'de' | 'el' | 'es' | 'et' | 'fi' | 'fr' | 'gu' | 'hi' | 'hr' | 'hu' | 'hy' | 'id' | 'is' | 'it' | 'ja' | 'ka' | 'kn' | 'ko' | 'lv' | 'mk' | 'mr' | 'ms' | 'my' | 'nb' | 'nl' | 'pl' | 'pt' | 'ro' | 'ru' | 'sk' | 'sl' | 'so' | 'sq' | 'sr' | 'sv' | 'sw' | 'ta' | 'te' | 'th' | 'tr' | 'uk' | 'vi' | 'zh' | 'zh-Hans' | 'zh-CN' | 'zh-Hant' | 'en';
998
956
 
999
957
  export declare type SurfaceColors = {
1000
958
  background: string;
@@ -1367,12 +1325,7 @@ export declare interface XpertAIChatKit extends HTMLElement {
1367
1325
  */
1368
1326
  itemId?: string): Promise<void>;
1369
1327
  /** Sends a user message. */
1370
- sendUserMessage(params: {
1371
- text: string;
1372
- reply?: string;
1373
- attachments?: Attachment[];
1374
- newThread?: boolean;
1375
- }): Promise<void>;
1328
+ sendUserMessage(params: SendUserMessageParams): Promise<void>;
1376
1329
  /** Sets the composer's content without sending a message. */
1377
1330
  setComposerValue(params: {
1378
1331
  text: string;
package/dist/index.js CHANGED
@@ -41,35 +41,11 @@ var ChatMessageStepCategory = /* @__PURE__ */ ((ChatMessageStepCategory2) => {
41
41
  return ChatMessageStepCategory2;
42
42
  })(ChatMessageStepCategory || {});
43
43
  const STATE_VARIABLE_HUMAN = "human";
44
- const ALLOWED_KEYS = [
45
- "api",
46
- "theme",
47
- "composer",
48
- "startScreen"
49
- ];
50
- function filterPlaygroundOptions(options) {
51
- const filtered = {};
52
- for (const key of ALLOWED_KEYS) {
53
- if (key in options && options[key] !== void 0) {
54
- filtered[key] = options[key];
55
- }
56
- }
57
- return filtered;
58
- }
59
- function mergeWithPlaygroundOptions(localOptions, playgroundOptions) {
60
- const filteredPlayground = filterPlaygroundOptions(playgroundOptions);
61
- return {
62
- ...localOptions,
63
- ...filteredPlayground
64
- };
65
- }
66
44
  export {
67
45
  ChatMessageEventTypeEnum,
68
46
  ChatMessageStepCategory,
69
47
  ChatMessageTypeEnum,
70
48
  STATE_VARIABLE_HUMAN,
71
- filterPlaygroundOptions,
72
- isClientToolRequest,
73
- mergeWithPlaygroundOptions
49
+ isClientToolRequest
74
50
  };
75
51
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/interrupt.ts","../src/message.ts","../src/filterPlaygroundOptions.ts"],"sourcesContent":["import { type ToolCall } from '@langchain/core/messages/tool';\n\n/**\n * When an interrupt occurs during task execution, the system generates an InterruptPayload.\n```json\n{\n \"type\": \"event\",\n \"event\": \"on_interrupt\",\n \"data\": {\n \"tasks\": [\n {\n \"id\": \"9c4d2ac5-8808-5b6f-855c-4d48aa3d77a7\",\n \"name\": \"Middleware_wPzR2bIXqE_after_model\",\n \"path\": [\"__pregel_pull\", \"Middleware_wPzR2bIXqE_after_model\"],\n \"interrupts\": [\n {\n \"id\": \"b42f7887d65e57ed11cf08b8927763db\",\n \"value\": {\n \"toolCalls\": [\n {\n \"name\": \"getUserStation\",\n \"args\": {\n \"input\": \"Query the site selected by the user\"\n },\n \"id\": \"call_00_swcaUjIaACXOHHaZyNmQB3Vm\",\n \"type\": \"tool_call\"\n }\n ]\n }\n }\n ]\n }\n ]\n }\n}\n```\n */\nexport interface InterruptPayload {\n tasks: Array<{\n id: string;\n name: string;\n path: string[];\n interrupts: Array<{\n id: string;\n value: ClientToolRequest\n }>;\n }>;\n}\n\nexport interface ClientToolRequest {\n clientToolCalls: ToolCall[];\n}\n\nexport interface ClientToolMessageInput {\n content: unknown\n name?: string\n tool_call_id?: string\n status?: 'success' | 'error'\n artifact?: unknown\n}\n\nexport interface ClientToolResponse {\n toolMessages: ClientToolMessageInput[]\n}\n\nexport function isClientToolRequest(value: any): value is ClientToolRequest {\n return (\n value &&\n Array.isArray(value.clientToolCalls)\n );\n}","import type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { Types } from '@a2ui/lit/0.8';\n\nexport enum ChatMessageTypeEnum {\n // LOG = 'log',\n MESSAGE = 'message',\n EVENT = 'event'\n}\n\n/**\n * https://js.langchain.com/docs/how_to/streaming/#event-reference\n */\nexport enum ChatMessageEventTypeEnum {\n ON_CONVERSATION_START = 'on_conversation_start',\n ON_CONVERSATION_END = 'on_conversation_end',\n ON_MESSAGE_START = 'on_message_start',\n ON_MESSAGE_END = 'on_message_end',\n ON_TOOL_START = 'on_tool_start',\n ON_TOOL_END = 'on_tool_end',\n ON_TOOL_ERROR = 'on_tool_error',\n /**\n * Step message in tool call\n */\n ON_TOOL_MESSAGE = 'on_tool_message',\n ON_AGENT_START = 'on_agent_start',\n ON_AGENT_END = 'on_agent_end',\n ON_RETRIEVER_START = 'on_retriever_start',\n ON_RETRIEVER_END = 'on_retriever_end',\n ON_RETRIEVER_ERROR = 'on_retriever_error',\n ON_INTERRUPT = 'on_interrupt',\n ON_ERROR = 'on_error',\n ON_CHAT_EVENT = 'on_chat_event',\n\n ON_CLIENT_EFFECT = 'on_client_effect',\n}\n\n/**\n * Category of step message: determines the display components of computer use\n */\nexport enum ChatMessageStepCategory {\n /**\n * List of items: urls, files, etc.\n */\n List = 'list',\n /**\n * Websearch results\n */\n WebSearch = 'web_search',\n /**\n * Files list\n */\n Files = 'files',\n /**\n * View a file\n */\n File = 'file',\n /**\n * Program Execution\n */\n Program = 'program',\n /**\n * Iframe\n */\n Iframe = 'iframe',\n\n Memory = 'memory',\n\n Tasks = 'tasks',\n\n /**\n * Knowledges (knowledge base retriever results)\n */\n Knowledges = 'knowledges'\n}\n\n/**\n * Step message type, in canvas and ai message.\n */\nexport type TChatMessageStep<T = any> = TMessageComponent<TMessageComponentStep<T>>\n\nexport type ImageDetail = \"auto\" | \"low\" | \"high\";\nexport type MessageContentText = {\n type: \"text\";\n text: string;\n};\nexport type MessageContentImageUrl = {\n type: \"image_url\";\n image_url: string | {\n url: string;\n detail?: ImageDetail;\n };\n};\n\n/**\n * Similar to {@link MessageContentText} | {@link MessageContentImageUrl}, which together form {@link MessageContentComplex}\n */\nexport type TMessageContentComponent<T extends object = object> = {\n id: string\n type: 'component'\n data: TMessageComponent<T>\n xpertName?: string\n agentKey?: string;\n}\n\n/**\n * Defines the data type of the sub-message of `component` type in the message `content` {@link MessageContentComplex}\n */\nexport type TMessageComponent<T extends object = object> = T & {\n id?: string\n category: 'Dashboard' | 'Computer' | 'Tool'\n type?: string\n created_date?: Date | string\n}\n\nexport type TMessageComponentWidgetItem = {\n name: string\n config: Types.Surface\n values?: Record<string, unknown>\n}\n\nexport type TMessageComponentWidgetData = {\n type: 'Widget'\n mode?: string\n widgets: TMessageComponentWidgetItem[]\n executionId?: string\n}\n\nexport type TMessageComponentWidget = TMessageComponent<TMessageComponentWidgetData>\n\nexport type TMessageContentWidget = TMessageContentComponent<TMessageComponentWidgetData>\n\nexport type TMessageContentText = {\n id?: string\n xpertName?: string\n agentKey?: string\n type: \"text\";\n text: string;\n};\nexport type TMessageContentMemory = {\n id?: string\n agentKey?: string\n type: \"memory\";\n data: any[];\n};\nexport type TMessageContentReasoning = {\n id?: string\n xpertName?: string\n agentKey?: string\n type: \"reasoning\";\n text: string;\n};\n/**\n * Enhance {@link MessageContentComplex} in Langchain.js\n */\nexport type TMessageContentComplex = (TMessageContentText | TMessageContentReasoning | MessageContentImageUrl | TMessageContentComponent | TMessageContentMemory | (Record<string, any> & {\n type?: \"text\" | \"image_url\" | string;\n}) | (Record<string, any> & {\n type?: never;\n})) & {\n id?: string\n xpertName?: string\n agentKey?: string;\n created_date?: Date | string\n}\n\n/**\n * Enhance {@link MessageContent} in Langchain.js\n * \n * @deprecated use {@link TMessageItems} instead\n */\nexport type TMessageContent = string | TMessageContentComplex[];\n\nexport type TMessageComponentIframe = {\n type: 'iframe'\n title: string\n url?: string\n data?: {\n url?: string\n }\n}\n\nexport type TMessageComponentStep<T = unknown> = {\n type: ChatMessageStepCategory\n toolset: string\n toolset_id: string\n tool?: string\n title: string\n message: string\n status: 'success' | 'fail' | 'running'\n created_date: Date | string\n end_date: Date | string\n error?: string\n data?: T\n input?: any\n output?: string\n artifact?: any\n}\n\n/**\n * Data type for chat event message\n */\nexport type TChatEventMessage = {\n type?: string\n title?: string\n message?: string\n status?: 'success' | 'fail' | 'running'\n created_date?: Date | string\n end_date?: Date | string\n error?: string\n}\n\nexport interface ChatkitMessage {\n status?: string\n content: TMessageItems\n reasoning?: TMessageContentReasoning[]\n type: 'user' | 'assistant' | 'system' | 'tool' | 'event'\n id: string\n}\n\nexport type TMessageItems = TMessageContentComplex[];\n\n\nexport const STATE_VARIABLE_HUMAN = 'human'\n\n/**\n * Human input message, include parameters and attachments\n */\nexport type TChatRequestHuman = {\n input?: string\n files?: Partial<File>[]\n [key: string]: unknown\n}\n\n/**\n * Command to resume with streaming after human decision\n */\nexport type TInterruptCommand = {\n resume?: any\n update?: any\n toolCalls?: ToolCall[]\n agentKey?: string\n}\n\nexport type TChatRequest = {\n /**\n * The human input, include parameters\n */\n input: TChatRequestHuman\n /**\n * Custom graph state\n */\n state?: {[STATE_VARIABLE_HUMAN]: TChatRequestHuman} & Record<string, any>\n agentKey?: string\n projectId?: string\n conversationId?: string\n environmentId?: string\n id?: string\n executionId?: string\n confirm?: boolean\n command?: TInterruptCommand\n retry?: boolean\n}\n\n/**\n * Data type for client effect message\n */\nexport type TClientEeffectMessage = {\n name: string\n args: Record<string, any>\n tool_call_id?: string\n agentKey?: string;\n created_date?: Date | string\n}\n","import type { ChatKitOptions, ChatKitTheme, ColorScheme } from './options';\n\n/**\n * Playground configuration whitelist - only allow these options to take effect when copied from the playground\n * Filters out: locale, initialThread, header, history, threadItemActions, disclaimer, entities, widgets, onClientTool\n */\n\n/**\n * Options allowed to be configured from Playground\n */\nexport type PlaygroundAllowedOptions = {\n api?: ChatKitOptions['api'];\n theme?: ColorScheme | ChatKitTheme;\n composer?: ChatKitOptions['composer'];\n startScreen?: ChatKitOptions['startScreen'];\n};\n\n/**\n * Whitelist of allowed option keys\n */\nconst ALLOWED_KEYS: (keyof PlaygroundAllowedOptions)[] = [\n 'api',\n 'theme',\n 'composer',\n 'startScreen',\n];\n\n/**\n * Filter out only the allowed options from a Playground config\n *\n * @param options - Full config copied from the playground\n * @returns An object containing only whitelisted options\n *\n * @example\n * ```ts\n * // Config copied from the playground\n * const playgroundConfig = {\n * theme: { colorScheme: 'light', radius: 'pill' },\n * threadItemActions: { feedback: true }, // will be filtered out\n * startScreen: { greeting: 'Hello!' },\n * };\n *\n * const filtered = filterPlaygroundOptions(playgroundConfig);\n * // Result: { theme: { colorScheme: 'light', radius: 'pill' }, startScreen: { greeting: 'Hello!' } }\n * ```\n */\nexport function filterPlaygroundOptions<T extends Partial<ChatKitOptions>>(\n options: T\n): PlaygroundAllowedOptions {\n const filtered: PlaygroundAllowedOptions = {};\n\n for (const key of ALLOWED_KEYS) {\n if (key in options && options[key] !== undefined) {\n // @ts-expect-error - dynamic assignment\n filtered[key] = options[key];\n }\n }\n\n // fontSources is preserved - user must provide their own font URLs\n\n return filtered;\n}\n\n/**\n * Merge Playground config with local config\n * Playground config overrides matching items in local config (whitelist only)\n *\n * @param localOptions - Base config in the local project (can include onClientTool, header, etc.)\n * @param playgroundOptions - Config copied from the playground\n * @returns Merged config\n *\n * @example\n * ```ts\n * const localConfig = {\n * api: { getClientSecret: async () => '...' },\n * onClientTool: async () => { ... }, // kept\n * header: { enabled: true }, // kept\n * };\n *\n * const playgroundConfig = {\n * theme: { colorScheme: 'dark' },\n * threadItemActions: { feedback: true }, // filtered out\n * };\n *\n * const merged = mergeWithPlaygroundOptions(localConfig, playgroundConfig);\n * // Result: { api, onClientTool, header, theme }\n * ```\n */\nexport function mergeWithPlaygroundOptions<T extends Partial<ChatKitOptions>>(\n localOptions: T,\n playgroundOptions: Partial<ChatKitOptions>\n): T & PlaygroundAllowedOptions {\n const filteredPlayground = filterPlaygroundOptions(playgroundOptions);\n\n return {\n ...localOptions,\n ...filteredPlayground,\n };\n}\n"],"names":["ChatMessageTypeEnum","ChatMessageEventTypeEnum","ChatMessageStepCategory"],"mappings":";;AAiEO,SAAS,oBAAoB,OAAwC;AAC1E,SACE,SACA,MAAM,QAAQ,MAAM,eAAe;AAEvC;ACnEO,IAAK,wCAAAA,yBAAL;AAELA,uBAAA,SAAA,IAAU;AACVA,uBAAA,OAAA,IAAQ;AAHE,SAAAA;AAAA,GAAA,uBAAA,CAAA,CAAA;AASL,IAAK,6CAAAC,8BAAL;AACLA,4BAAA,uBAAA,IAAwB;AACxBA,4BAAA,qBAAA,IAAsB;AACtBA,4BAAA,kBAAA,IAAmB;AACnBA,4BAAA,gBAAA,IAAiB;AACjBA,4BAAA,eAAA,IAAgB;AAChBA,4BAAA,aAAA,IAAc;AACdA,4BAAA,eAAA,IAAgB;AAIhBA,4BAAA,iBAAA,IAAkB;AAClBA,4BAAA,gBAAA,IAAiB;AACjBA,4BAAA,cAAA,IAAe;AACfA,4BAAA,oBAAA,IAAqB;AACrBA,4BAAA,kBAAA,IAAmB;AACnBA,4BAAA,oBAAA,IAAqB;AACrBA,4BAAA,cAAA,IAAe;AACfA,4BAAA,UAAA,IAAW;AACXA,4BAAA,eAAA,IAAgB;AAEhBA,4BAAA,kBAAA,IAAmB;AArBT,SAAAA;AAAA,GAAA,4BAAA,CAAA,CAAA;AA2BL,IAAK,4CAAAC,6BAAL;AAILA,2BAAA,MAAA,IAAO;AAIPA,2BAAA,WAAA,IAAY;AAIZA,2BAAA,OAAA,IAAQ;AAIRA,2BAAA,MAAA,IAAO;AAIPA,2BAAA,SAAA,IAAU;AAIVA,2BAAA,QAAA,IAAS;AAETA,2BAAA,QAAA,IAAS;AAETA,2BAAA,OAAA,IAAQ;AAKRA,2BAAA,YAAA,IAAa;AAjCH,SAAAA;AAAA,GAAA,2BAAA,CAAA,CAAA;AAuLL,MAAM,uBAAuB;AC1MpC,MAAM,eAAmD;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAqBO,SAAS,wBACd,SAC0B;AAC1B,QAAM,WAAqC,CAAA;AAE3C,aAAW,OAAO,cAAc;AAC9B,QAAI,OAAO,WAAW,QAAQ,GAAG,MAAM,QAAW;AAEhD,eAAS,GAAG,IAAI,QAAQ,GAAG;AAAA,IAC7B;AAAA,EACF;AAIA,SAAO;AACT;AA2BO,SAAS,2BACd,cACA,mBAC8B;AAC9B,QAAM,qBAAqB,wBAAwB,iBAAiB;AAEpE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAEP;"}
1
+ {"version":3,"file":"index.js","sources":["../src/interrupt.ts","../src/message.ts"],"sourcesContent":["import { type ToolCall } from '@langchain/core/messages/tool';\n\n/**\n * When an interrupt occurs during task execution, the system generates an InterruptPayload.\n```json\n{\n \"type\": \"event\",\n \"event\": \"on_interrupt\",\n \"data\": {\n \"tasks\": [\n {\n \"id\": \"9c4d2ac5-8808-5b6f-855c-4d48aa3d77a7\",\n \"name\": \"Middleware_wPzR2bIXqE_after_model\",\n \"path\": [\"__pregel_pull\", \"Middleware_wPzR2bIXqE_after_model\"],\n \"interrupts\": [\n {\n \"id\": \"b42f7887d65e57ed11cf08b8927763db\",\n \"value\": {\n \"toolCalls\": [\n {\n \"name\": \"getUserStation\",\n \"args\": {\n \"input\": \"Query the site selected by the user\"\n },\n \"id\": \"call_00_swcaUjIaACXOHHaZyNmQB3Vm\",\n \"type\": \"tool_call\"\n }\n ]\n }\n }\n ]\n }\n ]\n }\n}\n```\n */\nexport interface InterruptPayload {\n tasks: Array<{\n id: string;\n name: string;\n path: string[];\n interrupts: Array<{\n id: string;\n value: ClientToolRequest\n }>;\n }>;\n}\n\nexport interface ClientToolRequest {\n clientToolCalls: ToolCall[];\n}\n\nexport interface ClientToolMessageInput {\n content: unknown\n name?: string\n tool_call_id?: string\n status?: 'success' | 'error'\n artifact?: unknown\n}\n\nexport interface ClientToolResponse {\n toolMessages: ClientToolMessageInput[]\n}\n\nexport function isClientToolRequest(value: any): value is ClientToolRequest {\n return (\n value &&\n Array.isArray(value.clientToolCalls)\n );\n}","import type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { Types } from '@a2ui/lit/0.8';\n\nexport enum ChatMessageTypeEnum {\n // LOG = 'log',\n MESSAGE = 'message',\n EVENT = 'event'\n}\n\n/**\n * https://js.langchain.com/docs/how_to/streaming/#event-reference\n */\nexport enum ChatMessageEventTypeEnum {\n ON_CONVERSATION_START = 'on_conversation_start',\n ON_CONVERSATION_END = 'on_conversation_end',\n ON_MESSAGE_START = 'on_message_start',\n ON_MESSAGE_END = 'on_message_end',\n ON_TOOL_START = 'on_tool_start',\n ON_TOOL_END = 'on_tool_end',\n ON_TOOL_ERROR = 'on_tool_error',\n /**\n * Step message in tool call\n */\n ON_TOOL_MESSAGE = 'on_tool_message',\n ON_AGENT_START = 'on_agent_start',\n ON_AGENT_END = 'on_agent_end',\n ON_RETRIEVER_START = 'on_retriever_start',\n ON_RETRIEVER_END = 'on_retriever_end',\n ON_RETRIEVER_ERROR = 'on_retriever_error',\n ON_INTERRUPT = 'on_interrupt',\n ON_ERROR = 'on_error',\n ON_CHAT_EVENT = 'on_chat_event',\n\n ON_CLIENT_EFFECT = 'on_client_effect',\n}\n\n/**\n * Category of step message: determines the display components of computer use\n */\nexport enum ChatMessageStepCategory {\n /**\n * List of items: urls, files, etc.\n */\n List = 'list',\n /**\n * Websearch results\n */\n WebSearch = 'web_search',\n /**\n * Files list\n */\n Files = 'files',\n /**\n * View a file\n */\n File = 'file',\n /**\n * Program Execution\n */\n Program = 'program',\n /**\n * Iframe\n */\n Iframe = 'iframe',\n\n Memory = 'memory',\n\n Tasks = 'tasks',\n\n /**\n * Knowledges (knowledge base retriever results)\n */\n Knowledges = 'knowledges'\n}\n\n/**\n * Step message type, in canvas and ai message.\n */\nexport type TChatMessageStep<T = any> = TMessageComponent<TMessageComponentStep<T>>\n\nexport type ImageDetail = \"auto\" | \"low\" | \"high\";\nexport type MessageContentText = {\n type: \"text\";\n text: string;\n};\nexport type MessageContentImageUrl = {\n type: \"image_url\";\n image_url: string | {\n url: string;\n detail?: ImageDetail;\n };\n};\n\n/**\n * Similar to {@link MessageContentText} | {@link MessageContentImageUrl}, which together form {@link MessageContentComplex}\n */\nexport type TMessageContentComponent<T extends object = object> = {\n id: string\n type: 'component'\n data: TMessageComponent<T>\n xpertName?: string\n agentKey?: string;\n}\n\n/**\n * Defines the data type of the sub-message of `component` type in the message `content` {@link MessageContentComplex}\n */\nexport type TMessageComponent<T extends object = object> = T & {\n id?: string\n category: 'Dashboard' | 'Computer' | 'Tool'\n type?: string\n created_date?: Date | string\n}\n\nexport type TMessageComponentWidgetItem = {\n name: string\n config: Types.Surface\n values?: Record<string, unknown>\n}\n\nexport type TMessageComponentWidgetData = {\n type: 'Widget'\n mode?: string\n widgets: TMessageComponentWidgetItem[]\n executionId?: string\n}\n\nexport type TMessageComponentWidget = TMessageComponent<TMessageComponentWidgetData>\n\nexport type TMessageContentWidget = TMessageContentComponent<TMessageComponentWidgetData>\n\nexport type TMessageContentText = {\n id?: string\n xpertName?: string\n agentKey?: string\n type: \"text\";\n text: string;\n};\nexport type TMessageContentMemory = {\n id?: string\n agentKey?: string\n type: \"memory\";\n data: any[];\n};\nexport type TMessageContentReasoning = {\n id?: string\n xpertName?: string\n agentKey?: string\n type: \"reasoning\";\n text: string;\n};\n/**\n * Enhance {@link MessageContentComplex} in Langchain.js\n */\nexport type TMessageContentComplex = (TMessageContentText | TMessageContentReasoning | MessageContentImageUrl | TMessageContentComponent | TMessageContentMemory | (Record<string, any> & {\n type?: \"text\" | \"image_url\" | string;\n}) | (Record<string, any> & {\n type?: never;\n})) & {\n id?: string\n xpertName?: string\n agentKey?: string;\n created_date?: Date | string\n}\n\n/**\n * Enhance {@link MessageContent} in Langchain.js\n * \n * @deprecated use {@link TMessageItems} instead\n */\nexport type TMessageContent = string | TMessageContentComplex[];\n\nexport type TMessageComponentIframe = {\n type: 'iframe'\n title: string\n url?: string\n data?: {\n url?: string\n }\n}\n\nexport type TMessageComponentStep<T = unknown> = {\n type: ChatMessageStepCategory\n toolset: string\n toolset_id: string\n tool?: string\n title: string\n message: string\n status: 'success' | 'fail' | 'running'\n created_date: Date | string\n end_date: Date | string\n error?: string\n data?: T\n input?: any\n output?: string\n artifact?: any\n}\n\n/**\n * Data type for chat event message\n */\nexport type TChatEventMessage = {\n type?: string\n title?: string\n message?: string\n status?: 'success' | 'fail' | 'running'\n created_date?: Date | string\n end_date?: Date | string\n error?: string\n}\n\nexport interface ChatkitMessage {\n status?: string\n content: TMessageItems\n reasoning?: TMessageContentReasoning[]\n type: 'user' | 'assistant' | 'system' | 'tool' | 'event'\n id: string\n}\n\nexport type TMessageItems = TMessageContentComplex[];\n\n\nexport const STATE_VARIABLE_HUMAN = 'human'\n\n/**\n * Human input message, include parameters and attachments\n */\nexport type TChatRequestHuman = {\n input?: string\n files?: Partial<File>[]\n [key: string]: unknown\n}\n\n/**\n * Command to resume with streaming after human decision\n */\nexport type TInterruptCommand = {\n resume?: any\n update?: any\n toolCalls?: ToolCall[]\n agentKey?: string\n}\n\nexport type TChatRequest = {\n /**\n * The human input, include parameters\n */\n input: TChatRequestHuman\n /**\n * Custom graph state\n */\n state?: {[STATE_VARIABLE_HUMAN]: TChatRequestHuman} & Record<string, any>\n agentKey?: string\n projectId?: string\n conversationId?: string\n environmentId?: string\n id?: string\n executionId?: string\n confirm?: boolean\n command?: TInterruptCommand\n retry?: boolean\n}\n\n/**\n * Data type for client effect message\n */\nexport type TClientEeffectMessage = {\n name: string\n args: Record<string, any>\n tool_call_id?: string\n agentKey?: string;\n created_date?: Date | string\n}\n"],"names":["ChatMessageTypeEnum","ChatMessageEventTypeEnum","ChatMessageStepCategory"],"mappings":";;AAiEO,SAAS,oBAAoB,OAAwC;AAC1E,SACE,SACA,MAAM,QAAQ,MAAM,eAAe;AAEvC;ACnEO,IAAK,wCAAAA,yBAAL;AAELA,uBAAA,SAAA,IAAU;AACVA,uBAAA,OAAA,IAAQ;AAHE,SAAAA;AAAA,GAAA,uBAAA,CAAA,CAAA;AASL,IAAK,6CAAAC,8BAAL;AACLA,4BAAA,uBAAA,IAAwB;AACxBA,4BAAA,qBAAA,IAAsB;AACtBA,4BAAA,kBAAA,IAAmB;AACnBA,4BAAA,gBAAA,IAAiB;AACjBA,4BAAA,eAAA,IAAgB;AAChBA,4BAAA,aAAA,IAAc;AACdA,4BAAA,eAAA,IAAgB;AAIhBA,4BAAA,iBAAA,IAAkB;AAClBA,4BAAA,gBAAA,IAAiB;AACjBA,4BAAA,cAAA,IAAe;AACfA,4BAAA,oBAAA,IAAqB;AACrBA,4BAAA,kBAAA,IAAmB;AACnBA,4BAAA,oBAAA,IAAqB;AACrBA,4BAAA,cAAA,IAAe;AACfA,4BAAA,UAAA,IAAW;AACXA,4BAAA,eAAA,IAAgB;AAEhBA,4BAAA,kBAAA,IAAmB;AArBT,SAAAA;AAAA,GAAA,4BAAA,CAAA,CAAA;AA2BL,IAAK,4CAAAC,6BAAL;AAILA,2BAAA,MAAA,IAAO;AAIPA,2BAAA,WAAA,IAAY;AAIZA,2BAAA,OAAA,IAAQ;AAIRA,2BAAA,MAAA,IAAO;AAIPA,2BAAA,SAAA,IAAU;AAIVA,2BAAA,QAAA,IAAS;AAETA,2BAAA,QAAA,IAAS;AAETA,2BAAA,OAAA,IAAQ;AAKRA,2BAAA,YAAA,IAAa;AAjCH,SAAAA;AAAA,GAAA,2BAAA,CAAA,CAAA;AAuLL,MAAM,uBAAuB;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xpert-ai/chatkit-types",
3
- "version": "0.0.7",
4
- "description": "Type definitions for the ChatKit Web Component.",
3
+ "version": "0.0.9",
4
+ "description": "Type definitions for the ChatKit.",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -20,11 +20,6 @@
20
20
  "README.md",
21
21
  "!**/*.tsbuildinfo"
22
22
  ],
23
- "scripts": {
24
- "build": "vite build",
25
- "types": "tsc",
26
- "clean": "rimraf dist"
27
- },
28
23
  "publishConfig": {
29
24
  "access": "public",
30
25
  "provenance": false
@@ -33,7 +28,6 @@
33
28
  "type": "git",
34
29
  "url": "https://github.com/xpert-ai/chatkit-js"
35
30
  },
36
- "license": "MIT",
37
31
  "peerDependencies": {
38
32
  "@a2ui/lit": "^0.8.1",
39
33
  "@langchain/core": "^1.0.2",
@@ -42,5 +36,10 @@
42
36
  "devDependencies": {
43
37
  "vite": "^5.0.0",
44
38
  "vite-plugin-dts": "^3.7.0"
39
+ },
40
+ "scripts": {
41
+ "build": "vite build",
42
+ "types": "tsc",
43
+ "clean": "rimraf dist"
45
44
  }
46
- }
45
+ }