@xpert-ai/chatkit-types 0.0.17 → 0.1.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/dist/index.d.ts +73 -10
- 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;
|
|
@@ -239,12 +250,27 @@ export declare type ChatKitEvents = {
|
|
|
239
250
|
}>;
|
|
240
251
|
};
|
|
241
252
|
|
|
253
|
+
export declare type ChatKitImageReference = ChatKitReferenceBase & {
|
|
254
|
+
type: 'image';
|
|
255
|
+
fileId?: string;
|
|
256
|
+
url?: string;
|
|
257
|
+
mimeType?: string;
|
|
258
|
+
name?: string;
|
|
259
|
+
size?: number;
|
|
260
|
+
width?: number;
|
|
261
|
+
height?: number;
|
|
262
|
+
};
|
|
263
|
+
|
|
242
264
|
export declare interface ChatkitMessage {
|
|
243
265
|
status?: string;
|
|
244
266
|
content: TMessageItems | string;
|
|
245
267
|
reasoning?: TMessageContentReasoning[];
|
|
246
268
|
type: 'user' | 'assistant' | 'system' | 'tool' | 'event';
|
|
247
269
|
id: string;
|
|
270
|
+
followUpMode?: FollowUpBehavior;
|
|
271
|
+
followUpStatus?: 'pending' | 'consumed' | 'canceled';
|
|
272
|
+
targetExecutionId?: string | null;
|
|
273
|
+
visibleAt?: string | Date | null;
|
|
248
274
|
}
|
|
249
275
|
|
|
250
276
|
export declare type ChatKitOptions = {
|
|
@@ -438,6 +464,22 @@ export declare type ChatKitOptions = {
|
|
|
438
464
|
};
|
|
439
465
|
};
|
|
440
466
|
|
|
467
|
+
export declare type ChatKitQuoteReference = ChatKitReferenceBase & {
|
|
468
|
+
type: 'quote';
|
|
469
|
+
messageId?: string;
|
|
470
|
+
source?: string;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
export declare type ChatKitReference = ChatKitCodeReference | ChatKitQuoteReference | ChatKitImageReference;
|
|
474
|
+
|
|
475
|
+
export declare type ChatKitReferenceBase = {
|
|
476
|
+
id?: string;
|
|
477
|
+
label?: string;
|
|
478
|
+
text: string;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
export declare type ChatKitReferenceCompositionMode = 'compose' | 'preserve';
|
|
482
|
+
|
|
441
483
|
export declare type ChatKitRequestContext = {
|
|
442
484
|
/**
|
|
443
485
|
* Request-scoped runtime env overrides.
|
|
@@ -721,6 +763,8 @@ export declare type FileUploadStrategy = {
|
|
|
721
763
|
uploadUrl: string;
|
|
722
764
|
};
|
|
723
765
|
|
|
766
|
+
export declare type FollowUpBehavior = 'queue' | 'steer';
|
|
767
|
+
|
|
724
768
|
export declare type FontObject = {
|
|
725
769
|
family: string;
|
|
726
770
|
src: string;
|
|
@@ -787,7 +831,7 @@ declare type Image_2 = {
|
|
|
787
831
|
} & BlockProps;
|
|
788
832
|
export { Image_2 as Image }
|
|
789
833
|
|
|
790
|
-
export declare type ImageDetail =
|
|
834
|
+
export declare type ImageDetail = 'auto' | 'low' | 'high';
|
|
791
835
|
|
|
792
836
|
export declare type Input = {
|
|
793
837
|
type: 'Input';
|
|
@@ -901,7 +945,7 @@ export declare type Markdown = {
|
|
|
901
945
|
};
|
|
902
946
|
|
|
903
947
|
export declare type MessageContentImageUrl = {
|
|
904
|
-
type:
|
|
948
|
+
type: 'image_url';
|
|
905
949
|
image_url: string | {
|
|
906
950
|
url: string;
|
|
907
951
|
detail?: ImageDetail;
|
|
@@ -909,7 +953,7 @@ export declare type MessageContentImageUrl = {
|
|
|
909
953
|
};
|
|
910
954
|
|
|
911
955
|
export declare type MessageContentText = {
|
|
912
|
-
type:
|
|
956
|
+
type: 'text';
|
|
913
957
|
text: string;
|
|
914
958
|
};
|
|
915
959
|
|
|
@@ -973,11 +1017,14 @@ export declare type Select = {
|
|
|
973
1017
|
};
|
|
974
1018
|
|
|
975
1019
|
export declare type SendUserMessageParams = {
|
|
976
|
-
text
|
|
1020
|
+
text?: string;
|
|
977
1021
|
state?: Record<string, any>;
|
|
978
1022
|
reply?: string;
|
|
979
1023
|
attachments?: Attachment[];
|
|
980
1024
|
newThread?: boolean;
|
|
1025
|
+
references?: ChatKitReference[];
|
|
1026
|
+
referenceComposition?: ChatKitReferenceCompositionMode;
|
|
1027
|
+
followUpMode?: 'default' | FollowUpBehavior;
|
|
981
1028
|
};
|
|
982
1029
|
|
|
983
1030
|
export declare type Spacer = {
|
|
@@ -1053,6 +1100,7 @@ export declare type TChatRequest = {
|
|
|
1053
1100
|
confirm?: boolean;
|
|
1054
1101
|
command?: TInterruptCommand;
|
|
1055
1102
|
retry?: boolean;
|
|
1103
|
+
followUpMode?: FollowUpBehavior;
|
|
1056
1104
|
/**
|
|
1057
1105
|
* PRO: Sandbox Environment Id
|
|
1058
1106
|
* PRO: @description Sandbox environment ID to force using the specified container.
|
|
@@ -1066,6 +1114,8 @@ export declare type TChatRequest = {
|
|
|
1066
1114
|
export declare type TChatRequestHuman = {
|
|
1067
1115
|
input?: string;
|
|
1068
1116
|
files?: Partial<File>[];
|
|
1117
|
+
references?: ChatKitReference[];
|
|
1118
|
+
referenceComposition?: ChatKitReferenceCompositionMode;
|
|
1069
1119
|
[key: string]: unknown;
|
|
1070
1120
|
};
|
|
1071
1121
|
|
|
@@ -1128,6 +1178,15 @@ export declare type TextComponent = {
|
|
|
1128
1178
|
|
|
1129
1179
|
declare type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
1130
1180
|
|
|
1181
|
+
export declare type TFollowUpConsumedEvent = TChatEventMessage & {
|
|
1182
|
+
type: typeof CHAT_EVENT_TYPE_FOLLOW_UP_CONSUMED;
|
|
1183
|
+
mode: 'queue' | 'steer';
|
|
1184
|
+
messageIds: string[];
|
|
1185
|
+
clientMessageIds?: string[];
|
|
1186
|
+
executionId?: string | null;
|
|
1187
|
+
visibleAt?: string | null;
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1131
1190
|
declare type ThemeColor = {
|
|
1132
1191
|
dark: string;
|
|
1133
1192
|
light: string;
|
|
@@ -1184,7 +1243,7 @@ export declare type TMessageComponentStep<T = unknown> = {
|
|
|
1184
1243
|
error?: string;
|
|
1185
1244
|
data?: T;
|
|
1186
1245
|
input?: any;
|
|
1187
|
-
output?:
|
|
1246
|
+
output?: unknown;
|
|
1188
1247
|
artifact?: any;
|
|
1189
1248
|
};
|
|
1190
1249
|
|
|
@@ -1214,7 +1273,7 @@ export declare type TMessageContent = string | TMessageContentComplex[];
|
|
|
1214
1273
|
* Enhance {@link MessageContentComplex} in Langchain.js
|
|
1215
1274
|
*/
|
|
1216
1275
|
export declare type TMessageContentComplex = (TMessageContentText | TMessageContentReasoning | MessageContentImageUrl | TMessageContentComponent | TMessageContentMemory | (Record<string, any> & {
|
|
1217
|
-
type?:
|
|
1276
|
+
type?: 'text' | 'image_url' | string;
|
|
1218
1277
|
}) | (Record<string, any> & {
|
|
1219
1278
|
type?: never;
|
|
1220
1279
|
})) & {
|
|
@@ -1238,7 +1297,7 @@ export declare type TMessageContentComponent<T extends object = object> = {
|
|
|
1238
1297
|
export declare type TMessageContentMemory = {
|
|
1239
1298
|
id?: string;
|
|
1240
1299
|
agentKey?: string;
|
|
1241
|
-
type:
|
|
1300
|
+
type: 'memory';
|
|
1242
1301
|
data: any[];
|
|
1243
1302
|
};
|
|
1244
1303
|
|
|
@@ -1246,7 +1305,7 @@ export declare type TMessageContentReasoning = {
|
|
|
1246
1305
|
id?: string;
|
|
1247
1306
|
xpertName?: string;
|
|
1248
1307
|
agentKey?: string;
|
|
1249
|
-
type:
|
|
1308
|
+
type: 'reasoning';
|
|
1250
1309
|
text: string;
|
|
1251
1310
|
};
|
|
1252
1311
|
|
|
@@ -1254,7 +1313,7 @@ export declare type TMessageContentText = {
|
|
|
1254
1313
|
id?: string;
|
|
1255
1314
|
xpertName?: string;
|
|
1256
1315
|
agentKey?: string;
|
|
1257
|
-
type:
|
|
1316
|
+
type: 'text';
|
|
1258
1317
|
text: string;
|
|
1259
1318
|
};
|
|
1260
1319
|
|
|
@@ -1408,9 +1467,13 @@ export declare interface XpertAIChatKit extends HTMLElement {
|
|
|
1408
1467
|
sendUserMessage(params: SendUserMessageParams): Promise<void>;
|
|
1409
1468
|
/** Sets the composer's content without sending a message. */
|
|
1410
1469
|
setComposerValue(params: {
|
|
1411
|
-
text
|
|
1470
|
+
text?: string;
|
|
1412
1471
|
reply?: string;
|
|
1413
1472
|
attachments?: Attachment[];
|
|
1473
|
+
references?: ChatKitReference[];
|
|
1474
|
+
appendReferences?: boolean;
|
|
1475
|
+
selectedToolId?: string | null;
|
|
1476
|
+
selectedModelId?: string | null;
|
|
1414
1477
|
}): Promise<void>;
|
|
1415
1478
|
/**
|
|
1416
1479
|
* 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?: unknown;\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 ChatKitImageReference = ChatKitReferenceBase & {\n type: 'image';\n fileId?: string;\n url?: string;\n mimeType?: string;\n name?: string;\n size?: number;\n width?: number;\n height?: number;\n};\n\nexport type ChatKitReference =\n | ChatKitCodeReference\n | ChatKitQuoteReference\n | ChatKitImageReference;\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;AA+OL,MAAM,uBAAuB;AAgF7B,MAAM,qCAAqC;"}
|