@xpert-ai/chatkit-types 0.0.17 → 0.1.0
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/dist/index.d.ts +61 -9
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -169,6 +169,8 @@ declare type CardAction = {
|
|
|
169
169
|
action: ActionConfig;
|
|
170
170
|
};
|
|
171
171
|
|
|
172
|
+
export declare const CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED: "follow_up_consumed";
|
|
173
|
+
|
|
172
174
|
/**
|
|
173
175
|
* Encapsulate multi-agent message events
|
|
174
176
|
*/
|
|
@@ -186,6 +188,15 @@ export declare type ChatKitClientSecretObject = {
|
|
|
186
188
|
|
|
187
189
|
export declare type ChatKitClientSecretResult = string | ChatKitClientSecretObject;
|
|
188
190
|
|
|
191
|
+
export declare type ChatKitCodeReference = ChatKitReferenceBase & {
|
|
192
|
+
type: 'code';
|
|
193
|
+
path: string;
|
|
194
|
+
startLine: number;
|
|
195
|
+
endLine: number;
|
|
196
|
+
language?: string;
|
|
197
|
+
taskId?: string;
|
|
198
|
+
};
|
|
199
|
+
|
|
189
200
|
export declare interface ChatKitElementEventMap {
|
|
190
201
|
'chatkit.error': CustomEvent<{
|
|
191
202
|
error: Error;
|
|
@@ -245,6 +256,10 @@ export declare interface ChatkitMessage {
|
|
|
245
256
|
reasoning?: TMessageContentReasoning[];
|
|
246
257
|
type: 'user' | 'assistant' | 'system' | 'tool' | 'event';
|
|
247
258
|
id: string;
|
|
259
|
+
followUpMode?: FollowUpBehavior;
|
|
260
|
+
followUpStatus?: 'pending' | 'consumed' | 'canceled';
|
|
261
|
+
targetExecutionId?: string | null;
|
|
262
|
+
visibleAt?: string | Date | null;
|
|
248
263
|
}
|
|
249
264
|
|
|
250
265
|
export declare type ChatKitOptions = {
|
|
@@ -438,6 +453,22 @@ export declare type ChatKitOptions = {
|
|
|
438
453
|
};
|
|
439
454
|
};
|
|
440
455
|
|
|
456
|
+
export declare type ChatKitQuoteReference = ChatKitReferenceBase & {
|
|
457
|
+
type: 'quote';
|
|
458
|
+
messageId?: string;
|
|
459
|
+
source?: string;
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
export declare type ChatKitReference = ChatKitCodeReference | ChatKitQuoteReference;
|
|
463
|
+
|
|
464
|
+
export declare type ChatKitReferenceBase = {
|
|
465
|
+
id?: string;
|
|
466
|
+
label?: string;
|
|
467
|
+
text: string;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
export declare type ChatKitReferenceCompositionMode = 'compose' | 'preserve';
|
|
471
|
+
|
|
441
472
|
export declare type ChatKitRequestContext = {
|
|
442
473
|
/**
|
|
443
474
|
* Request-scoped runtime env overrides.
|
|
@@ -721,6 +752,8 @@ export declare type FileUploadStrategy = {
|
|
|
721
752
|
uploadUrl: string;
|
|
722
753
|
};
|
|
723
754
|
|
|
755
|
+
export declare type FollowUpBehavior = 'queue' | 'steer';
|
|
756
|
+
|
|
724
757
|
export declare type FontObject = {
|
|
725
758
|
family: string;
|
|
726
759
|
src: string;
|
|
@@ -787,7 +820,7 @@ declare type Image_2 = {
|
|
|
787
820
|
} & BlockProps;
|
|
788
821
|
export { Image_2 as Image }
|
|
789
822
|
|
|
790
|
-
export declare type ImageDetail =
|
|
823
|
+
export declare type ImageDetail = 'auto' | 'low' | 'high';
|
|
791
824
|
|
|
792
825
|
export declare type Input = {
|
|
793
826
|
type: 'Input';
|
|
@@ -901,7 +934,7 @@ export declare type Markdown = {
|
|
|
901
934
|
};
|
|
902
935
|
|
|
903
936
|
export declare type MessageContentImageUrl = {
|
|
904
|
-
type:
|
|
937
|
+
type: 'image_url';
|
|
905
938
|
image_url: string | {
|
|
906
939
|
url: string;
|
|
907
940
|
detail?: ImageDetail;
|
|
@@ -909,7 +942,7 @@ export declare type MessageContentImageUrl = {
|
|
|
909
942
|
};
|
|
910
943
|
|
|
911
944
|
export declare type MessageContentText = {
|
|
912
|
-
type:
|
|
945
|
+
type: 'text';
|
|
913
946
|
text: string;
|
|
914
947
|
};
|
|
915
948
|
|
|
@@ -973,11 +1006,14 @@ export declare type Select = {
|
|
|
973
1006
|
};
|
|
974
1007
|
|
|
975
1008
|
export declare type SendUserMessageParams = {
|
|
976
|
-
text
|
|
1009
|
+
text?: string;
|
|
977
1010
|
state?: Record<string, any>;
|
|
978
1011
|
reply?: string;
|
|
979
1012
|
attachments?: Attachment[];
|
|
980
1013
|
newThread?: boolean;
|
|
1014
|
+
references?: ChatKitReference[];
|
|
1015
|
+
referenceComposition?: ChatKitReferenceCompositionMode;
|
|
1016
|
+
followUpMode?: 'default' | FollowUpBehavior;
|
|
981
1017
|
};
|
|
982
1018
|
|
|
983
1019
|
export declare type Spacer = {
|
|
@@ -1053,6 +1089,7 @@ export declare type TChatRequest = {
|
|
|
1053
1089
|
confirm?: boolean;
|
|
1054
1090
|
command?: TInterruptCommand;
|
|
1055
1091
|
retry?: boolean;
|
|
1092
|
+
followUpMode?: FollowUpBehavior;
|
|
1056
1093
|
/**
|
|
1057
1094
|
* PRO: Sandbox Environment Id
|
|
1058
1095
|
* PRO: @description Sandbox environment ID to force using the specified container.
|
|
@@ -1066,6 +1103,8 @@ export declare type TChatRequest = {
|
|
|
1066
1103
|
export declare type TChatRequestHuman = {
|
|
1067
1104
|
input?: string;
|
|
1068
1105
|
files?: Partial<File>[];
|
|
1106
|
+
references?: ChatKitReference[];
|
|
1107
|
+
referenceComposition?: ChatKitReferenceCompositionMode;
|
|
1069
1108
|
[key: string]: unknown;
|
|
1070
1109
|
};
|
|
1071
1110
|
|
|
@@ -1128,6 +1167,15 @@ export declare type TextComponent = {
|
|
|
1128
1167
|
|
|
1129
1168
|
declare type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
1130
1169
|
|
|
1170
|
+
export declare type TFollowUpConsumedEvent = TChatEventMessage & {
|
|
1171
|
+
type: typeof CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED;
|
|
1172
|
+
mode: 'queue' | 'steer';
|
|
1173
|
+
messageIds: string[];
|
|
1174
|
+
clientMessageIds?: string[];
|
|
1175
|
+
executionId?: string | null;
|
|
1176
|
+
visibleAt?: string | null;
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1131
1179
|
declare type ThemeColor = {
|
|
1132
1180
|
dark: string;
|
|
1133
1181
|
light: string;
|
|
@@ -1214,7 +1262,7 @@ export declare type TMessageContent = string | TMessageContentComplex[];
|
|
|
1214
1262
|
* Enhance {@link MessageContentComplex} in Langchain.js
|
|
1215
1263
|
*/
|
|
1216
1264
|
export declare type TMessageContentComplex = (TMessageContentText | TMessageContentReasoning | MessageContentImageUrl | TMessageContentComponent | TMessageContentMemory | (Record<string, any> & {
|
|
1217
|
-
type?:
|
|
1265
|
+
type?: 'text' | 'image_url' | string;
|
|
1218
1266
|
}) | (Record<string, any> & {
|
|
1219
1267
|
type?: never;
|
|
1220
1268
|
})) & {
|
|
@@ -1238,7 +1286,7 @@ export declare type TMessageContentComponent<T extends object = object> = {
|
|
|
1238
1286
|
export declare type TMessageContentMemory = {
|
|
1239
1287
|
id?: string;
|
|
1240
1288
|
agentKey?: string;
|
|
1241
|
-
type:
|
|
1289
|
+
type: 'memory';
|
|
1242
1290
|
data: any[];
|
|
1243
1291
|
};
|
|
1244
1292
|
|
|
@@ -1246,7 +1294,7 @@ export declare type TMessageContentReasoning = {
|
|
|
1246
1294
|
id?: string;
|
|
1247
1295
|
xpertName?: string;
|
|
1248
1296
|
agentKey?: string;
|
|
1249
|
-
type:
|
|
1297
|
+
type: 'reasoning';
|
|
1250
1298
|
text: string;
|
|
1251
1299
|
};
|
|
1252
1300
|
|
|
@@ -1254,7 +1302,7 @@ export declare type TMessageContentText = {
|
|
|
1254
1302
|
id?: string;
|
|
1255
1303
|
xpertName?: string;
|
|
1256
1304
|
agentKey?: string;
|
|
1257
|
-
type:
|
|
1305
|
+
type: 'text';
|
|
1258
1306
|
text: string;
|
|
1259
1307
|
};
|
|
1260
1308
|
|
|
@@ -1408,9 +1456,13 @@ export declare interface XpertAIChatKit extends HTMLElement {
|
|
|
1408
1456
|
sendUserMessage(params: SendUserMessageParams): Promise<void>;
|
|
1409
1457
|
/** Sets the composer's content without sending a message. */
|
|
1410
1458
|
setComposerValue(params: {
|
|
1411
|
-
text
|
|
1459
|
+
text?: string;
|
|
1412
1460
|
reply?: string;
|
|
1413
1461
|
attachments?: Attachment[];
|
|
1462
|
+
references?: ChatKitReference[];
|
|
1463
|
+
appendReferences?: boolean;
|
|
1464
|
+
selectedToolId?: string | null;
|
|
1465
|
+
selectedModelId?: string | null;
|
|
1414
1466
|
}): Promise<void>;
|
|
1415
1467
|
/**
|
|
1416
1468
|
* Manually fetches updates from the server.
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,9 @@ var ChatMessageStepCategory = /* @__PURE__ */ ((ChatMessageStepCategory2) => {
|
|
|
41
41
|
return ChatMessageStepCategory2;
|
|
42
42
|
})(ChatMessageStepCategory || {});
|
|
43
43
|
const STATE_VARIABLE_HUMAN = "human";
|
|
44
|
+
const CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED = "follow_up_consumed";
|
|
44
45
|
export {
|
|
46
|
+
CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED,
|
|
45
47
|
ChatMessageEventTypeEnum,
|
|
46
48
|
ChatMessageStepCategory,
|
|
47
49
|
ChatMessageTypeEnum,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 * Encapsulate multi-agent message events\n */\nexport interface ChatEventEnvelope<T = unknown> {\n type: ChatMessageTypeEnum\n event?: ChatMessageEventTypeEnum\n tags: string[]\n\tdata: T\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 | string\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 * PRO: Sandbox Environment Id\n * PRO: @description Sandbox environment ID to force using the specified container.\n */\n sandboxEnvironmentId?: string;\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\n// Thread context usage\nexport type TThreadContextUsageMetrics = {\n contextTokens: number\n inputTokens: number\n outputTokens: number\n totalTokens: number\n embedTokens?: number\n totalPrice?: number\n currency?: string | null\n}\n\nexport type TThreadContextUsageEvent = {\n type: 'thread_context_usage'\n threadId: string\n runId: string | null\n agentKey: string\n updatedAt: string\n usage: TThreadContextUsageMetrics\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;AAqCL,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;"}
|
|
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';\nimport type { FollowUpBehavior } from './options';\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 * Encapsulate multi-agent message events\n */\nexport interface ChatEventEnvelope<T = unknown> {\n type: ChatMessageTypeEnum;\n event?: ChatMessageEventTypeEnum;\n tags: string[];\n data: T;\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<\n TMessageComponentStep<T>\n>;\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:\n | string\n | {\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 =\n TMessageComponent<TMessageComponentWidgetData>;\n\nexport type TMessageContentWidget =\n 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 = (\n | TMessageContentText\n | TMessageContentReasoning\n | MessageContentImageUrl\n | TMessageContentComponent\n | TMessageContentMemory\n | (Record<string, any> & {\n type?: 'text' | 'image_url' | string;\n })\n | (Record<string, any> & {\n type?: never;\n })\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 | string;\n reasoning?: TMessageContentReasoning[];\n type: 'user' | 'assistant' | 'system' | 'tool' | 'event';\n id: string;\n followUpMode?: FollowUpBehavior;\n followUpStatus?: 'pending' | 'consumed' | 'canceled';\n targetExecutionId?: string | null;\n visibleAt?: string | Date | null;\n}\n\nexport type TMessageItems = TMessageContentComplex[];\n\nexport type ChatKitReferenceBase = {\n id?: string;\n label?: string;\n text: string;\n};\n\nexport type ChatKitCodeReference = ChatKitReferenceBase & {\n type: 'code';\n path: string;\n startLine: number;\n endLine: number;\n language?: string;\n taskId?: string;\n};\n\nexport type ChatKitQuoteReference = ChatKitReferenceBase & {\n type: 'quote';\n messageId?: string;\n source?: string;\n};\n\nexport type ChatKitReference = ChatKitCodeReference | ChatKitQuoteReference;\n\nexport type ChatKitReferenceCompositionMode = 'compose' | 'preserve';\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 references?: ChatKitReference[];\n referenceComposition?: ChatKitReferenceCompositionMode;\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 followUpMode?: FollowUpBehavior;\n /**\n * PRO: Sandbox Environment Id\n * PRO: @description Sandbox environment ID to force using the specified container.\n */\n sandboxEnvironmentId?: string;\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\n// Thread context usage\nexport type TThreadContextUsageMetrics = {\n contextTokens: number;\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n embedTokens?: number;\n totalPrice?: number;\n currency?: string | null;\n};\n\nexport type TThreadContextUsageEvent = {\n type: 'thread_context_usage';\n threadId: string;\n runId: string | null;\n agentKey: string;\n updatedAt: string;\n usage: TThreadContextUsageMetrics;\n};\n\nexport const CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED = 'follow_up_consumed' as const;\n\nexport type TFollowUpConsumedEvent = TChatEventMessage & {\n type: typeof CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED;\n mode: 'queue' | 'steer';\n messageIds: string[];\n clientMessageIds?: string[];\n executionId?: string | null;\n visibleAt?: string | null;\n};\n"],"names":["ChatMessageTypeEnum","ChatMessageEventTypeEnum","ChatMessageStepCategory"],"mappings":";;AAiEO,SAAS,oBAAoB,OAAwC;AAC1E,SACE,SACA,MAAM,QAAQ,MAAM,eAAe;AAEvC;AClEO,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;AAqCL,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;AAiOL,MAAM,uBAAuB;AAgF7B,MAAM,qCAAqC;"}
|