@xpert-ai/contracts 3.9.0-beta.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.
Files changed (157) hide show
  1. package/README.md +3 -0
  2. package/index.cjs.js +4945 -0
  3. package/index.d.ts +1 -0
  4. package/index.esm.js +4792 -0
  5. package/package.json +25 -0
  6. package/src/agent/ai-model.d.ts +9 -0
  7. package/src/agent/graph.d.ts +182 -0
  8. package/src/agent/index.d.ts +6 -0
  9. package/src/agent/interrupt.d.ts +51 -0
  10. package/src/agent/token.d.ts +21 -0
  11. package/src/agent/utils.d.ts +19 -0
  12. package/src/agent/variables.d.ts +16 -0
  13. package/src/ai/ai-model.model.d.ts +198 -0
  14. package/src/ai/ai-provider.model.d.ts +43 -0
  15. package/src/ai/ai.model.d.ts +82 -0
  16. package/src/ai/assistant-binding.model.d.ts +81 -0
  17. package/src/ai/chat-event.model.d.ts +8 -0
  18. package/src/ai/chat-message-feedback.model.d.ts +24 -0
  19. package/src/ai/chat-message.model.d.ts +93 -0
  20. package/src/ai/chat.model.d.ts +191 -0
  21. package/src/ai/copilot-checkpoint.model.d.ts +23 -0
  22. package/src/ai/copilot-example.model.d.ts +19 -0
  23. package/src/ai/copilot-model.model.d.ts +30 -0
  24. package/src/ai/copilot-organization.model.d.ts +17 -0
  25. package/src/ai/copilot-provider.model.d.ts +31 -0
  26. package/src/ai/copilot-role.model.d.ts +43 -0
  27. package/src/ai/copilot-store.model.d.ts +29 -0
  28. package/src/ai/copilot-user.model.d.ts +27 -0
  29. package/src/ai/copilot.model.d.ts +36 -0
  30. package/src/ai/environment.model.d.ts +16 -0
  31. package/src/ai/feature.model.d.ts +10 -0
  32. package/src/ai/index.d.ts +84 -0
  33. package/src/ai/knowledge-doc-chunk.model.d.ts +61 -0
  34. package/src/ai/knowledge-doc-page.model.d.ts +15 -0
  35. package/src/ai/knowledge-doc.model.d.ts +222 -0
  36. package/src/ai/knowledge-pipeline.d.ts +107 -0
  37. package/src/ai/knowledge-retrieval-log.model.d.ts +10 -0
  38. package/src/ai/knowledgebase-task.model.d.ts +39 -0
  39. package/src/ai/knowledgebase.model.d.ts +174 -0
  40. package/src/ai/message-content.utils.d.ts +58 -0
  41. package/src/ai/middleware.model.d.ts +24 -0
  42. package/src/ai/rag-web.d.ts +26 -0
  43. package/src/ai/rag.d.ts +24 -0
  44. package/src/ai/role-permissions.d.ts +13 -0
  45. package/src/ai/sandbox.d.ts +8 -0
  46. package/src/ai/skill.model.d.ts +241 -0
  47. package/src/ai/types.d.ts +77 -0
  48. package/src/ai/xpert-agent-execution.model.d.ts +105 -0
  49. package/src/ai/xpert-agent.model.d.ts +194 -0
  50. package/src/ai/xpert-chat.model.d.ts +66 -0
  51. package/src/ai/xpert-project.model.d.ts +89 -0
  52. package/src/ai/xpert-table.model.d.ts +84 -0
  53. package/src/ai/xpert-task.model.d.ts +26 -0
  54. package/src/ai/xpert-template.model.d.ts +47 -0
  55. package/src/ai/xpert-tool-mcp.model.d.ts +91 -0
  56. package/src/ai/xpert-tool.model.d.ts +154 -0
  57. package/src/ai/xpert-toolset.model.d.ts +200 -0
  58. package/src/ai/xpert-workflow-task.prompt.d.ts +2 -0
  59. package/src/ai/xpert-workflow.model.d.ts +445 -0
  60. package/src/ai/xpert-workspace.model.d.ts +37 -0
  61. package/src/ai/xpert.model.d.ts +513 -0
  62. package/src/ai/xpert.utils.d.ts +87 -0
  63. package/src/analytics/ai.d.ts +73 -0
  64. package/src/analytics/approval-policy.model.d.ts +30 -0
  65. package/src/analytics/business-area-user.model.d.ts +35 -0
  66. package/src/analytics/business-area.d.ts +17 -0
  67. package/src/analytics/certification.model.d.ts +11 -0
  68. package/src/analytics/chatbi-conversation.model.d.ts +15 -0
  69. package/src/analytics/chatbi-model.model.d.ts +18 -0
  70. package/src/analytics/collection.model.d.ts +6 -0
  71. package/src/analytics/comment.model.d.ts +10 -0
  72. package/src/analytics/data-source-type.d.ts +16 -0
  73. package/src/analytics/data-source.d.ts +62 -0
  74. package/src/analytics/favorite.d.ts +14 -0
  75. package/src/analytics/features.d.ts +19 -0
  76. package/src/analytics/feed-model.d.ts +13 -0
  77. package/src/analytics/gateway.d.ts +28 -0
  78. package/src/analytics/index.d.ts +38 -0
  79. package/src/analytics/indicator-app.d.ts +44 -0
  80. package/src/analytics/indicator-market.d.ts +4 -0
  81. package/src/analytics/indicator.d.ts +105 -0
  82. package/src/analytics/model-query-log.model.d.ts +41 -0
  83. package/src/analytics/model-query.d.ts +21 -0
  84. package/src/analytics/notification-destination.d.ts +10 -0
  85. package/src/analytics/permission-approval-user.model.d.ts +10 -0
  86. package/src/analytics/permission-approval.model.d.ts +47 -0
  87. package/src/analytics/project.model.d.ts +50 -0
  88. package/src/analytics/role-permissions.d.ts +25 -0
  89. package/src/analytics/schema.d.ts +262 -0
  90. package/src/analytics/screenshot.model.d.ts +24 -0
  91. package/src/analytics/semantic-model-entity.d.ts +38 -0
  92. package/src/analytics/semantic-model-member.d.ts +27 -0
  93. package/src/analytics/semantic-model.d.ts +183 -0
  94. package/src/analytics/story-point.d.ts +11 -0
  95. package/src/analytics/story-template.model.d.ts +28 -0
  96. package/src/analytics/story-widget.d.ts +12 -0
  97. package/src/analytics/story.d.ts +93 -0
  98. package/src/analytics/subscription.d.ts +38 -0
  99. package/src/analytics/visit.model.d.ts +34 -0
  100. package/src/analytics/webSocket.d.ts +48 -0
  101. package/src/api-key.model.d.ts +68 -0
  102. package/src/base-entity.model.d.ts +27 -0
  103. package/src/contact.model.d.ts +41 -0
  104. package/src/core.model.d.ts +97 -0
  105. package/src/country.model.d.ts +5 -0
  106. package/src/currency.model.d.ts +579 -0
  107. package/src/custom-smtp.model.d.ts +23 -0
  108. package/src/date-picker.model.d.ts +5 -0
  109. package/src/email-template.model.d.ts +39 -0
  110. package/src/email.model.d.ts +36 -0
  111. package/src/employee.model.d.ts +128 -0
  112. package/src/entity-with-members.model.d.ts +13 -0
  113. package/src/feature.model.d.ts +93 -0
  114. package/src/file-asset.model.d.ts +77 -0
  115. package/src/file-provider.d.ts +31 -0
  116. package/src/http-status.enum.d.ts +57 -0
  117. package/src/import-export.model.d.ts +36 -0
  118. package/src/index.d.ts +53 -0
  119. package/src/integration/dingtalk.d.ts +2 -0
  120. package/src/integration/firecrawl.d.ts +2 -0
  121. package/src/integration/github.d.ts +69 -0
  122. package/src/integration/index.d.ts +4 -0
  123. package/src/integration/lark.d.ts +5 -0
  124. package/src/integration/wecom.d.ts +2 -0
  125. package/src/integration.model.d.ts +92 -0
  126. package/src/invite.model.d.ts +125 -0
  127. package/src/language.model.d.ts +19 -0
  128. package/src/organization-contact.model.d.ts +72 -0
  129. package/src/organization-department.model.d.ts +20 -0
  130. package/src/organization-language.model.d.ts +18 -0
  131. package/src/organization-projects.model.d.ts +80 -0
  132. package/src/organization-team-employee-model.d.ts +12 -0
  133. package/src/organization-team-model.d.ts +19 -0
  134. package/src/organization.model.d.ts +238 -0
  135. package/src/password-reset.model.d.ts +18 -0
  136. package/src/plain-object.model.d.ts +13 -0
  137. package/src/plugin.d.ts +116 -0
  138. package/src/role-permission.model.d.ts +61 -0
  139. package/src/role.model.d.ts +25 -0
  140. package/src/schedule.d.ts +27 -0
  141. package/src/scope.model.d.ts +9 -0
  142. package/src/secret-token.model.d.ts +11 -0
  143. package/src/seed.model.d.ts +37 -0
  144. package/src/storage-file.model.d.ts +39 -0
  145. package/src/tag-entity.model.d.ts +20 -0
  146. package/src/tenant.model.d.ts +40 -0
  147. package/src/tools/index.d.ts +1 -0
  148. package/src/tools/sandbox.d.ts +5 -0
  149. package/src/translation.model.d.ts +26 -0
  150. package/src/types.d.ts +248 -0
  151. package/src/user-group.model.d.ts +7 -0
  152. package/src/user-me-context.model.d.ts +9 -0
  153. package/src/user-organization.model.d.ts +28 -0
  154. package/src/user.model.d.ts +131 -0
  155. package/src/view-extension/index.d.ts +1 -0
  156. package/src/view-extension/model.d.ts +183 -0
  157. package/src/visibility.model.d.ts +6 -0
@@ -0,0 +1,81 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ import { IUser } from '../user.model';
3
+ export declare enum AssistantCode {
4
+ CHAT_COMMON = "chat_common",
5
+ XPERT_SHARED = "xpert_shared",
6
+ CHATBI = "chatbi",
7
+ CLAWXPERT = "clawxpert"
8
+ }
9
+ export declare enum AssistantBindingScope {
10
+ TENANT = "tenant",
11
+ ORGANIZATION = "organization",
12
+ USER = "user"
13
+ }
14
+ export declare enum AssistantBindingSourceScope {
15
+ NONE = "none",
16
+ TENANT = "tenant",
17
+ ORGANIZATION = "organization"
18
+ }
19
+ export type AssistantManagement = 'system' | 'user';
20
+ export interface IAssistantBindingToolsetPreference {
21
+ toolsetId?: string | null;
22
+ toolsetName: string;
23
+ disabledTools: string[];
24
+ }
25
+ export interface IAssistantBindingMiddlewarePreference {
26
+ provider: string;
27
+ disabledTools: string[];
28
+ }
29
+ export interface IAssistantBindingSkillPreference {
30
+ workspaceId: string;
31
+ disabledSkillIds: string[];
32
+ }
33
+ export interface IAssistantBindingConversationPreferences {
34
+ version: 1;
35
+ defaultThreadId?: string | null;
36
+ lastThreadId?: string | null;
37
+ }
38
+ export interface IAssistantBindingToolPreferences {
39
+ version: 1;
40
+ toolsets?: Record<string, IAssistantBindingToolsetPreference>;
41
+ middlewares?: Record<string, IAssistantBindingMiddlewarePreference>;
42
+ skills?: Record<string, IAssistantBindingSkillPreference>;
43
+ }
44
+ export interface IAssistantBinding extends IBasePerTenantAndOrganizationEntityModel {
45
+ code: AssistantCode;
46
+ scope: AssistantBindingScope;
47
+ assistantId?: string | null;
48
+ enabled?: boolean | null;
49
+ userId?: string | null;
50
+ user?: IUser;
51
+ preferences?: IAssistantBindingUserPreference[];
52
+ }
53
+ export interface IAssistantBindingUserPreference extends IBasePerTenantAndOrganizationEntityModel {
54
+ assistantBindingId: string;
55
+ assistantBinding?: IAssistantBinding;
56
+ userId?: string | null;
57
+ user?: IUser;
58
+ soul?: string | null;
59
+ profile?: string | null;
60
+ toolPreferences?: IAssistantBindingToolPreferences | null;
61
+ conversationPreferences?: IAssistantBindingConversationPreferences | null;
62
+ }
63
+ export interface IResolvedAssistantBinding extends IAssistantBinding {
64
+ sourceScope: AssistantBindingSourceScope;
65
+ }
66
+ export interface IAssistantBindingUpsertInput {
67
+ code: AssistantCode;
68
+ scope: AssistantBindingScope;
69
+ assistantId?: string | null;
70
+ enabled?: boolean;
71
+ }
72
+ export interface IAssistantBindingUserPreferenceUpsertInput {
73
+ scope: AssistantBindingScope;
74
+ soul?: string | null;
75
+ profile?: string | null;
76
+ toolPreferences?: IAssistantBindingToolPreferences | null;
77
+ conversationPreferences?: IAssistantBindingConversationPreferences | null;
78
+ }
79
+ export declare function getAssistantManagement(code: AssistantCode): AssistantManagement;
80
+ export declare function isUserManagedAssistant(code: AssistantCode): boolean;
81
+ export declare function isSystemManagedAssistant(code: AssistantCode): boolean;
@@ -0,0 +1,8 @@
1
+ import type { TChatEventMessage } from '@xpert-ai/chatkit-types';
2
+ export declare const CHAT_EVENT_TYPE_THREAD_CONTEXT_USAGE: "thread_context_usage";
3
+ export declare const CHAT_EVENT_TYPE_CONVERSATION_TITLE_SUMMARY: "conversation_title_summary";
4
+ export type TConversationTitleSummaryEvent = TChatEventMessage & {
5
+ id?: string;
6
+ type: typeof CHAT_EVENT_TYPE_CONVERSATION_TITLE_SUMMARY;
7
+ };
8
+ export declare function createConversationTitleSummaryEvent(event: Omit<TConversationTitleSummaryEvent, 'type'>): TConversationTitleSummaryEvent;
@@ -0,0 +1,24 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ import { IChatMessage } from './chat-message.model';
3
+ import { IChatConversation } from './chat.model';
4
+ export declare enum ChatMessageFeedbackRatingEnum {
5
+ LIKE = "like",
6
+ DISLIKE = "dislike"
7
+ }
8
+ /**
9
+ *
10
+ */
11
+ export interface IChatMessageFeedback extends IBasePerTenantAndOrganizationEntityModel {
12
+ rating: ChatMessageFeedbackRatingEnum;
13
+ content?: string;
14
+ /**
15
+ * Chat conversation
16
+ */
17
+ conversation?: IChatConversation;
18
+ conversationId?: string | null;
19
+ /**
20
+ * Chat conversation message
21
+ */
22
+ message?: IChatMessage;
23
+ messageId?: string | null;
24
+ }
@@ -0,0 +1,93 @@
1
+ import { MessageType } from '@langchain/core/messages';
2
+ import type { TChatMessageStep, TMessageContent, TMessageContentReasoning } from '@xpert-ai/chatkit-types';
3
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
4
+ import { IChatConversation } from './chat.model';
5
+ import { LongTermMemoryTypeEnum } from './xpert.model';
6
+ import { IXpertAgentExecution, XpertAgentExecutionStatusEnum } from './xpert-agent-execution.model';
7
+ import { JSONValue } from '../core.model';
8
+ import { IStorageFile } from '../storage-file.model';
9
+ export type TSummaryJob = Record<LongTermMemoryTypeEnum, {
10
+ jobId: number | string;
11
+ status: string;
12
+ progress?: number;
13
+ memoryKey?: string;
14
+ }>;
15
+ /**
16
+ * Chat message entity type
17
+ */
18
+ export interface IChatMessage extends IBasePerTenantAndOrganizationEntityModel, Omit<Omit<CopilotBaseMessage, 'createdAt'>, 'id'> {
19
+ parent?: IChatMessage | null;
20
+ children?: IChatMessage[];
21
+ parentId?: string | null;
22
+ /**
23
+ * Files
24
+ */
25
+ attachments?: IStorageFile[];
26
+ /**
27
+ * Job of summary
28
+ */
29
+ summaryJob?: TSummaryJob;
30
+ /**
31
+ * the third-party platform's message
32
+ */
33
+ thirdPartyMessage?: any;
34
+ /**
35
+ * Step messages from tools or others
36
+ */
37
+ events?: TChatMessageStep[];
38
+ /**
39
+ * Chat conversation
40
+ */
41
+ conversation?: IChatConversation;
42
+ conversationId?: string | null;
43
+ executionId?: string;
44
+ execution?: IXpertAgentExecution;
45
+ }
46
+ /**
47
+ * @deprecated
48
+ */
49
+ export type DeprecatedMessageType = 'assistant' | 'user' | 'info' | 'component';
50
+ export type CopilotMessageType = MessageType | DeprecatedMessageType;
51
+ export type ChatMessageStatusEnum = XpertAgentExecutionStatusEnum | 'thinking' | 'reasoning' | 'answering' | 'aborted';
52
+ /**
53
+ * BaseMessage or AIMessage in Langchain.js
54
+ */
55
+ export interface CopilotBaseMessage {
56
+ id?: string;
57
+ createdAt?: Date;
58
+ role: CopilotMessageType;
59
+ /**
60
+ * Status of the message:
61
+ */
62
+ status?: ChatMessageStatusEnum;
63
+ content?: string | TMessageContent;
64
+ /**
65
+ * Reasoning step messages
66
+ */
67
+ reasoning?: TMessageContentReasoning[];
68
+ /**
69
+ * Error info when status is error
70
+ */
71
+ error?: string;
72
+ }
73
+ export type CopilotChatMessage = CopilotBaseMessage & {
74
+ tool_call_id?: string;
75
+ /**
76
+ * If the message has a role of `function`, the `name` field is the name of the function.
77
+ * Otherwise, the name field should not be set.
78
+ */
79
+ name?: string;
80
+ data?: JSONValue;
81
+ messages?: Array<any>;
82
+ executionId?: string;
83
+ };
84
+ /**
85
+ * @deprecated use data attr in message (subMessages)
86
+ */
87
+ export interface CopilotMessageGroup extends CopilotBaseMessage {
88
+ messages?: CopilotChatMessage[];
89
+ }
90
+ /**
91
+ * @deprecated use content in message
92
+ */
93
+ export declare function isMessageGroup(message: CopilotBaseMessage): message is CopilotMessageGroup;
@@ -0,0 +1,191 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ import { IXpertAgentExecution } from './xpert-agent-execution.model';
3
+ import { IXpert } from './xpert.model';
4
+ import { I18nObject } from '../types';
5
+ import { CopilotChatMessage, CopilotMessageGroup, IChatMessage } from './chat-message.model';
6
+ import { IXpertAgent } from './xpert-agent.model';
7
+ import { IXpertProject } from './xpert-project.model';
8
+ import { IStorageFile } from '../storage-file.model';
9
+ import { IXpertTask } from './xpert-task.model';
10
+ import { TToolCall } from '../agent';
11
+ import { TInterrupt } from '../agent/interrupt';
12
+ import { IUser } from '../user.model';
13
+ export type TChatConversationOptions = {
14
+ parameters?: {
15
+ input?: string;
16
+ [key: string]: unknown;
17
+ };
18
+ knowledgebases?: string[];
19
+ toolsets?: string[];
20
+ features?: Array<'timeline' | 'sandbox' | 'files'>;
21
+ workspacePath?: string;
22
+ workspaceUrl?: string;
23
+ sandboxEnvironmentId?: string;
24
+ };
25
+ export type TChatConversationStatus = 'idle' | 'busy' | 'interrupted' | 'error';
26
+ export type TToolCallType = 'agent' | 'tool';
27
+ export type TChatFrom = 'platform' | 'webapp' | 'debugger' | 'knowledge' | 'job' | 'api' | 'feishu' | 'lark' | 'dingtalk' | 'wecom';
28
+ /**
29
+ * Operation for interrupt
30
+ */
31
+ export type TSensitiveOperation = {
32
+ messageId?: string;
33
+ tasks?: {
34
+ name: string;
35
+ interrupts: TInterrupt[];
36
+ type?: TToolCallType;
37
+ info?: {
38
+ name: string;
39
+ title?: string;
40
+ description: string;
41
+ };
42
+ parameters?: {
43
+ name: string;
44
+ title: I18nObject | string;
45
+ type: string;
46
+ description: I18nObject | string;
47
+ placeholder?: I18nObject | string;
48
+ }[];
49
+ call?: TToolCall;
50
+ agent?: IXpertAgent;
51
+ }[];
52
+ };
53
+ /**
54
+ * Chat conversation for xpert ai agent.
55
+ *
56
+ * Corresponds to the thread in the [Agent Protocol](https://github.com/langchain-ai/agent-protocol).
57
+ */
58
+ export interface IChatConversation extends IBasePerTenantAndOrganizationEntityModel {
59
+ /**
60
+ * Thread id for agent execution
61
+ */
62
+ threadId: string;
63
+ /**
64
+ * A short title summarizing the session
65
+ */
66
+ title?: string;
67
+ /**
68
+ * Current status of conversation
69
+ */
70
+ status?: TChatConversationStatus;
71
+ /**
72
+ * Options
73
+ */
74
+ options?: TChatConversationOptions;
75
+ /**
76
+ * Error message when status is error
77
+ */
78
+ error?: string;
79
+ /**
80
+ * ChatMessages in conversation
81
+ */
82
+ messages?: IChatMessage[] | null;
83
+ /**
84
+ * The last operation when interrupted
85
+ */
86
+ operation?: TSensitiveOperation;
87
+ /**
88
+ * Conversation source / user type
89
+ */
90
+ from: TChatFrom;
91
+ /**
92
+ * End anonymous user
93
+ */
94
+ fromEndUserId?: string;
95
+ /**
96
+ * Internal user matched by fromEndUserId when available
97
+ */
98
+ fromEndUser?: IUser;
99
+ /**
100
+ * Chat with Xpert
101
+ */
102
+ xpert?: IXpert;
103
+ xpertId?: string | null;
104
+ project?: IXpertProject;
105
+ projectId?: string | null;
106
+ task?: IXpertTask;
107
+ taskId?: string | null;
108
+ executions?: IXpertAgentExecution[];
109
+ /**
110
+ * Files
111
+ */
112
+ attachments?: IStorageFile[];
113
+ }
114
+ export type TChatConversationLog = IChatConversation & {
115
+ messageCount: number;
116
+ };
117
+ export type ChatMessage = {
118
+ conversationId: string;
119
+ id: string;
120
+ content: string;
121
+ };
122
+ export type ChatUserMessage = ChatMessage & {
123
+ language: string;
124
+ };
125
+ /**
126
+ * @deprecated use ChatMessageEventTypeEnum
127
+ */
128
+ export declare enum ChatGatewayEvent {
129
+ ACK = "ack",// acknowledgment for received message
130
+ ConversationCreated = "conversation_created",
131
+ Message = "message",
132
+ MessageStream = "message_stream",
133
+ StepStart = "step_start",
134
+ StepEnd = "step_end",
135
+ ToolStart = "tool_start",
136
+ ToolEnd = "tool_end",
137
+ ChainStart = "chain_start",
138
+ ChainEnd = "chain_end",
139
+ CancelChain = "cancel_chain",
140
+ ChainAborted = "chain_aborted",
141
+ Error = "error",
142
+ Agent = "agent"
143
+ }
144
+ /**
145
+ * @deprecated use ChatMessageEventTypeEnum
146
+ */
147
+ export type ChatGatewayMessage = {
148
+ organizationId?: string;
149
+ xpert?: {
150
+ id: string;
151
+ knowledgebases?: string[];
152
+ toolsets: string[] | null;
153
+ };
154
+ } & ({
155
+ event: ChatGatewayEvent.CancelChain;
156
+ data: {
157
+ conversationId: string;
158
+ };
159
+ } | {
160
+ event: ChatGatewayEvent.ChainAborted;
161
+ data: {
162
+ conversationId: string;
163
+ id?: string;
164
+ };
165
+ } | {
166
+ event: ChatGatewayEvent.ConversationCreated;
167
+ data: IChatConversation;
168
+ } | {
169
+ event: ChatGatewayEvent.MessageStream;
170
+ data: ChatUserMessage;
171
+ } | {
172
+ event: ChatGatewayEvent.ToolStart | ChatGatewayEvent.ToolEnd;
173
+ data: CopilotMessageGroup | CopilotMessageGroup[];
174
+ } | {
175
+ event: ChatGatewayEvent.ChainStart | ChatGatewayEvent.ChainEnd;
176
+ data: {
177
+ id: string;
178
+ };
179
+ } | {
180
+ event: ChatGatewayEvent.StepStart | ChatGatewayEvent.StepEnd;
181
+ data: CopilotChatMessage;
182
+ } | {
183
+ event: ChatGatewayEvent.Message | ChatGatewayEvent.Error;
184
+ data: CopilotChatMessage;
185
+ } | {
186
+ event: ChatGatewayEvent.Agent;
187
+ data: {
188
+ id: string;
189
+ message: CopilotChatMessage;
190
+ };
191
+ });
@@ -0,0 +1,23 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ /**
3
+ * Checkpoints for copilot, for langgraph framework
4
+ */
5
+ export interface ICopilotCheckpoint extends IBasePerTenantAndOrganizationEntityModel {
6
+ thread_id: string;
7
+ checkpoint_ns: string;
8
+ checkpoint_id: string;
9
+ parent_id?: string;
10
+ type?: string;
11
+ checkpoint: Uint8Array;
12
+ metadata: Uint8Array;
13
+ }
14
+ export interface ICopilotCheckpointWrites extends IBasePerTenantAndOrganizationEntityModel {
15
+ thread_id: string;
16
+ checkpoint_ns: string;
17
+ checkpoint_id: string;
18
+ task_id?: string;
19
+ idx?: number;
20
+ channel?: string;
21
+ type?: string;
22
+ value: Uint8Array;
23
+ }
@@ -0,0 +1,19 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ import { AiProvider } from './ai.model';
3
+ import { IXpert } from './xpert.model';
4
+ /**
5
+ * Examples for copilot, which is used to few shot user question
6
+ */
7
+ export interface ICopilotKnowledge extends IBasePerTenantAndOrganizationEntityModel {
8
+ provider?: AiProvider | string;
9
+ /**
10
+ * The name of xpert (copilot type)
11
+ */
12
+ role?: string;
13
+ command?: string;
14
+ input?: string;
15
+ output?: string;
16
+ vector?: boolean;
17
+ xpert?: IXpert;
18
+ xpertId?: string;
19
+ }
@@ -0,0 +1,30 @@
1
+ import { AiModelTypeEnum } from '../agent';
2
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
3
+ import { ICopilot } from './copilot.model';
4
+ export interface ICopilotModel extends TCopilotModel, IBasePerTenantAndOrganizationEntityModel {
5
+ }
6
+ export type TCopilotModel = {
7
+ /**
8
+ * Use a separate copilot
9
+ */
10
+ copilot?: ICopilot;
11
+ copilotId?: string;
12
+ /**
13
+ * Referenced copilot model if not using a separate copilot
14
+ */
15
+ referencedModel?: ICopilotModel;
16
+ referencedId?: string;
17
+ modelType?: AiModelTypeEnum;
18
+ model?: string;
19
+ /**
20
+ * Details config for ai model
21
+ */
22
+ options?: TCopilotModelOptions;
23
+ };
24
+ export type TCopilotModelOptions = {
25
+ /**
26
+ * Max input context size of selected model
27
+ */
28
+ context_size?: number;
29
+ [key: string]: any;
30
+ };
@@ -0,0 +1,17 @@
1
+ import { IBasePerTenantEntityModel } from '../base-entity.model';
2
+ import { IOrganization } from '../organization.model';
3
+ import { AiProvider } from './ai.model';
4
+ import { ICopilot, TCopilotTokenUsage } from './copilot.model';
5
+ /**
6
+ * Organization token usage of global copilot
7
+ */
8
+ export interface ICopilotOrganization extends IBasePerTenantEntityModel, TCopilotTokenUsage {
9
+ organizationId?: string;
10
+ organization?: IOrganization;
11
+ copilotId?: string;
12
+ copilot?: ICopilot;
13
+ provider?: AiProvider | string;
14
+ model?: string;
15
+ tokenTotalUsed?: number;
16
+ priceTotalUsed?: number;
17
+ }
@@ -0,0 +1,31 @@
1
+ import { AiModelTypeEnum } from '../agent';
2
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
3
+ import { IAiProviderEntity } from './ai-model.model';
4
+ import { ICopilot } from './copilot.model';
5
+ export interface ICopilotProvider extends IBasePerTenantAndOrganizationEntityModel {
6
+ providerName?: string;
7
+ providerType?: string;
8
+ credentials?: Record<string, any>;
9
+ isValid?: boolean;
10
+ lastUsed?: Date;
11
+ quotaType?: string;
12
+ quotaLimit?: number;
13
+ quotaUsed?: number;
14
+ /**
15
+ */
16
+ options?: any;
17
+ copilot?: ICopilot;
18
+ copilotId?: string;
19
+ models?: ICopilotProviderModel[];
20
+ provider?: IAiProviderEntity;
21
+ }
22
+ export interface ICopilotProviderModel extends IBasePerTenantAndOrganizationEntityModel {
23
+ providerName?: string;
24
+ modelName?: string;
25
+ modelType?: AiModelTypeEnum;
26
+ modelProperties?: Record<string, any>;
27
+ isValid?: boolean;
28
+ provider?: ICopilotProvider;
29
+ providerId?: string;
30
+ }
31
+ export type TCopilotProviderPublicDto = Omit<ICopilotProvider, 'credentials'>;
@@ -0,0 +1,43 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ import { IXpertToolset } from './xpert-toolset.model';
3
+ import { IKnowledgebase } from './knowledgebase.model';
4
+ /**
5
+ * @deprecated use Xpert
6
+ *
7
+ * Copilot role, business role for the copilot
8
+ */
9
+ export interface ICopilotRole extends IBasePerTenantAndOrganizationEntityModel {
10
+ name: string;
11
+ title?: string;
12
+ titleCN?: string;
13
+ description?: string;
14
+ /**
15
+ * 系统提示语
16
+ */
17
+ prompt?: string;
18
+ /**
19
+ * 对话开场白
20
+ */
21
+ starters?: string[];
22
+ active?: boolean;
23
+ avatar?: string;
24
+ toolsets?: IXpertToolset[];
25
+ /**
26
+ * More configuration
27
+ */
28
+ options?: TCopilotRoleOptions;
29
+ knowledgebases?: IKnowledgebase[];
30
+ }
31
+ /**
32
+ * @deprecated use XpertRole
33
+ */
34
+ export type TCopilotRoleOptions = {
35
+ context?: Record<string, any>;
36
+ toolsets: {
37
+ [id: string]: {
38
+ [tool: string]: {
39
+ defaultArgs: Record<string, any>;
40
+ };
41
+ };
42
+ };
43
+ };
@@ -0,0 +1,29 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ export interface ICopilotStore extends TCopilotStore, IBasePerTenantAndOrganizationEntityModel {
3
+ }
4
+ export interface ICopilotStoreVector extends TCopilotStoreVector, IBasePerTenantAndOrganizationEntityModel {
5
+ }
6
+ export type TCopilotStore = {
7
+ prefix: string;
8
+ key?: string;
9
+ value: any;
10
+ };
11
+ export type TCopilotStoreVector = {
12
+ prefix: string;
13
+ key: string;
14
+ field_name: any;
15
+ embedding: number[];
16
+ };
17
+ export declare const MEMORY_QA_PROMPT = "Summarize the experience of the above conversation and output a short question and answer.";
18
+ export declare const MEMORY_PROFILE_PROMPT = "Extract new user profile information from the above conversation in one short sentence. If no new information is available, return nothing.";
19
+ export type TMemory = {
20
+ memoryId?: string;
21
+ };
22
+ export type TMemoryUserProfile = TMemory & {
23
+ profile: string;
24
+ context?: string;
25
+ };
26
+ export type TMemoryQA = TMemory & {
27
+ question: string;
28
+ answer: string;
29
+ };
@@ -0,0 +1,27 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ import { IOrganization } from '../organization.model';
3
+ import { IUser } from '../user.model';
4
+ import { AiProvider } from './ai.model';
5
+ import { ICopilot, TCopilotTokenUsage } from './copilot.model';
6
+ export declare const USAGE_HOUR_FORMAT = "yyyy-MM-dd HH";
7
+ /**
8
+ *
9
+ */
10
+ export interface ICopilotUser extends IBasePerTenantAndOrganizationEntityModel, TCopilotTokenUsage {
11
+ orgId?: string;
12
+ org?: IOrganization;
13
+ copilotId?: string;
14
+ copilot?: ICopilot;
15
+ userId?: string;
16
+ user?: IUser;
17
+ xpertId?: string;
18
+ /**
19
+ * Usage hour in format 'yyyy-MM-dd HH' {@link USAGE_HOUR_FORMAT}
20
+ */
21
+ usageHour: string;
22
+ threadId: string;
23
+ provider?: AiProvider | string;
24
+ model?: string;
25
+ tokenTotalUsed?: number;
26
+ priceTotalUsed?: number;
27
+ }
@@ -0,0 +1,36 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ import { ICopilotModel } from './copilot-model.model';
3
+ import { ICopilotProvider } from './copilot-provider.model';
4
+ export interface ICopilot extends IBasePerTenantAndOrganizationEntityModel {
5
+ name?: string;
6
+ role: AiProviderRole;
7
+ enabled?: boolean;
8
+ showTokenizer?: boolean;
9
+ /**
10
+ * Balance of Token
11
+ */
12
+ tokenBalance?: number;
13
+ /**
14
+ * Details config for openai api
15
+ */
16
+ options?: any;
17
+ modelProvider?: ICopilotProvider;
18
+ copilotModel?: ICopilotModel;
19
+ usage?: TCopilotTokenUsage;
20
+ }
21
+ /**
22
+ * The order of priority is: `Embedding`, `Secondary`, `Primary`
23
+ */
24
+ export declare enum AiProviderRole {
25
+ Primary = "primary",
26
+ Secondary = "secondary",
27
+ Embedding = "embedding",
28
+ Reasoning = "reasoning"
29
+ }
30
+ export type TCopilotTokenUsage = {
31
+ tokenLimit?: number;
32
+ priceLimit?: number;
33
+ tokenUsed?: number;
34
+ priceUsed?: number;
35
+ currency?: string;
36
+ };
@@ -0,0 +1,16 @@
1
+ import { IBasePerWorkspaceEntityModel } from "./xpert-workspace.model";
2
+ export type TEnvironmentVariable = {
3
+ name: string;
4
+ value: string;
5
+ type: 'default' | 'secret';
6
+ /**
7
+ * Has owner, private variable
8
+ */
9
+ owner?: string;
10
+ };
11
+ export interface IEnvironment extends IBasePerWorkspaceEntityModel {
12
+ name: string;
13
+ isDefault?: boolean;
14
+ isArchived?: boolean;
15
+ variables: TEnvironmentVariable[];
16
+ }