@xpert-ai/chatkit-types 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @xpert-ai/chatkit-types
2
+
3
+ ## Publishing
4
+
5
+ Quick local publish (interactive)
6
+
7
+ ```bash
8
+ cd packages/chatkit
9
+ # (optional) generate/verify type declarations
10
+ pnpm run types
11
+ # increment version (optional but recommended)
12
+ pnpm version patch
13
+ # publish (scoped packages require --access public)
14
+ npm publish --access public --otp=
15
+ ```
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './types/index.d'
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@xpert-ai/chatkit-types",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "Type definitions for the ChatKit Web Component.",
6
+ "sideEffects": false,
7
+ "files": [
8
+ "types",
9
+ "README.md",
10
+ "index.js"
11
+ ],
12
+ "types": "./types/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./types/index.d.ts",
16
+ "import": "./index.js",
17
+ "default": "./index.js"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "types": "tsc",
22
+ "clean": "rimraf dist"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "provenance": false
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/xpert-ai/chatkit-js"
31
+ },
32
+ "license": "MIT",
33
+ "peerDependencies": {
34
+ "@langchain/core": "^1.0.2",
35
+ "@langchain/langgraph-sdk": "^1.0.0"
36
+ }
37
+ }
@@ -0,0 +1,193 @@
1
+ export enum ChatMessageTypeEnum {
2
+ // LOG = 'log',
3
+ MESSAGE = 'message',
4
+ EVENT = 'event'
5
+ }
6
+
7
+ /**
8
+ * https://js.langchain.com/docs/how_to/streaming/#event-reference
9
+ */
10
+ export enum ChatMessageEventTypeEnum {
11
+ ON_CONVERSATION_START = 'on_conversation_start',
12
+ ON_CONVERSATION_END = 'on_conversation_end',
13
+ ON_MESSAGE_START = 'on_message_start',
14
+ ON_MESSAGE_END = 'on_message_end',
15
+ ON_TOOL_START = 'on_tool_start',
16
+ ON_TOOL_END = 'on_tool_end',
17
+ ON_TOOL_ERROR = 'on_tool_error',
18
+ /**
19
+ * Step message in tool call
20
+ */
21
+ ON_TOOL_MESSAGE = 'on_tool_message',
22
+ ON_AGENT_START = 'on_agent_start',
23
+ ON_AGENT_END = 'on_agent_end',
24
+ ON_RETRIEVER_START = 'on_retriever_start',
25
+ ON_RETRIEVER_END = 'on_retriever_end',
26
+ ON_RETRIEVER_ERROR = 'on_retriever_error',
27
+ ON_INTERRUPT = 'on_interrupt',
28
+ ON_ERROR = 'on_error',
29
+ ON_CHAT_EVENT = 'on_chat_event',
30
+ }
31
+
32
+ /**
33
+ * Category of step message: determines the display components of computer use
34
+ */
35
+ export enum ChatMessageStepCategory {
36
+ /**
37
+ * List of items: urls, files, etc.
38
+ */
39
+ List = 'list',
40
+ /**
41
+ * Websearch results
42
+ */
43
+ WebSearch = 'web_search',
44
+ /**
45
+ * Files list
46
+ */
47
+ Files = 'files',
48
+ /**
49
+ * View a file
50
+ */
51
+ File = 'file',
52
+ /**
53
+ * Program Execution
54
+ */
55
+ Program = 'program',
56
+ /**
57
+ * Iframe
58
+ */
59
+ Iframe = 'iframe',
60
+
61
+ Memory = 'memory',
62
+
63
+ Tasks = 'tasks',
64
+
65
+ /**
66
+ * Knowledges (knowledge base retriever results)
67
+ */
68
+ Knowledges = 'knowledges'
69
+ }
70
+
71
+ /**
72
+ * Step message type, in canvas and ai message.
73
+ */
74
+ export type TChatMessageStep<T = any> = TMessageComponent<TMessageComponentStep<T>>
75
+
76
+ export type ImageDetail = "auto" | "low" | "high";
77
+ export type MessageContentText = {
78
+ type: "text";
79
+ text: string;
80
+ };
81
+ export type MessageContentImageUrl = {
82
+ type: "image_url";
83
+ image_url: string | {
84
+ url: string;
85
+ detail?: ImageDetail;
86
+ };
87
+ };
88
+
89
+ /**
90
+ * Similar to {@link MessageContentText} | {@link MessageContentImageUrl}, which together form {@link MessageContentComplex}
91
+ */
92
+ export type TMessageContentComponent<T extends object = object> = {
93
+ id: string
94
+ type: 'component'
95
+ data: TMessageComponent<T>
96
+ xpertName?: string
97
+ agentKey?: string;
98
+ }
99
+
100
+ /**
101
+ * Defines the data type of the sub-message of `component` type in the message `content` {@link MessageContentComplex}
102
+ */
103
+ export type TMessageComponent<T extends object = object> = T & {
104
+ id?: string
105
+ category: 'Dashboard' | 'Computer' | 'Tool'
106
+ type?: string
107
+ created_date?: Date | string
108
+ }
109
+
110
+ export type TMessageContentText = {
111
+ id?: string
112
+ xpertName?: string
113
+ agentKey?: string
114
+ type: "text";
115
+ text: string;
116
+ };
117
+ export type TMessageContentMemory = {
118
+ id?: string
119
+ agentKey?: string
120
+ type: "memory";
121
+ data: any[];
122
+ };
123
+ export type TMessageContentReasoning = {
124
+ id?: string
125
+ xpertName?: string
126
+ agentKey?: string
127
+ type: "reasoning";
128
+ text: string;
129
+ };
130
+ /**
131
+ * Enhance {@link MessageContentComplex} in Langchain.js
132
+ */
133
+ export type TMessageContentComplex = (TMessageContentText | TMessageContentReasoning | MessageContentImageUrl | TMessageContentComponent | TMessageContentMemory | (Record<string, any> & {
134
+ type?: "text" | "image_url" | string;
135
+ }) | (Record<string, any> & {
136
+ type?: never;
137
+ })) & {
138
+ id?: string
139
+ xpertName?: string
140
+ agentKey?: string;
141
+ created_date?: Date | string
142
+ }
143
+ /**
144
+ * Enhance {@link MessageContent} in Langchain.js
145
+ */
146
+ export type TMessageContent = string | TMessageContentComplex[];
147
+
148
+ export type TMessageComponentIframe = {
149
+ type: 'iframe'
150
+ title: string
151
+ url?: string
152
+ data?: {
153
+ url?: string
154
+ }
155
+ }
156
+
157
+ export type TMessageComponentStep<T = unknown> = {
158
+ type: ChatMessageStepCategory
159
+ toolset: string
160
+ toolset_id: string
161
+ tool?: string
162
+ title: string
163
+ message: string
164
+ status: 'success' | 'fail' | 'running'
165
+ created_date: Date | string
166
+ end_date: Date | string
167
+ error?: string
168
+ data?: T
169
+ input?: any
170
+ output?: string
171
+ artifact?: any
172
+ }
173
+
174
+ /**
175
+ * Data type for chat event message
176
+ */
177
+ export type TChatEventMessage = {
178
+ type?: string
179
+ title?: string
180
+ message?: string
181
+ status?: 'success' | 'fail' | 'running'
182
+ created_date?: Date | string
183
+ end_date?: Date | string
184
+ error?: string
185
+ }
186
+
187
+ export interface ChatkitMessage {
188
+ status?: string
189
+ content: TMessageContent
190
+ reasoning?: TMessageContentReasoning[]
191
+ type: 'user' | 'assistant' | 'system' | 'tool' | 'event'
192
+ id: string
193
+ }