@metad/contracts 3.6.0-beta.0 → 3.6.0-beta.2

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 (284) hide show
  1. package/index.cjs.d.ts +1 -0
  2. package/index.cjs.js +3968 -0
  3. package/index.esm.d.ts +1 -0
  4. package/index.esm.js +3873 -0
  5. package/package.json +4 -2
  6. package/src/agent/{ai-model.ts → ai-model.d.ts} +2 -2
  7. package/src/agent/graph.d.ts +148 -0
  8. package/src/agent/index.d.ts +5 -0
  9. package/src/agent/token.d.ts +21 -0
  10. package/src/agent/utils.d.ts +19 -0
  11. package/src/agent/variables.d.ts +14 -0
  12. package/src/ai/ai-model.model.d.ts +195 -0
  13. package/src/ai/ai-provider.model.d.ts +43 -0
  14. package/src/ai/ai.model.d.ts +82 -0
  15. package/src/ai/chat-message-feedback.model.d.ts +24 -0
  16. package/src/ai/chat-message.model.d.ts +222 -0
  17. package/src/ai/chat.model.d.ts +189 -0
  18. package/src/ai/copilot-checkpoint.model.d.ts +23 -0
  19. package/src/ai/copilot-example.model.d.ts +19 -0
  20. package/src/ai/copilot-model.model.d.ts +26 -0
  21. package/src/ai/copilot-organization.model.d.ts +17 -0
  22. package/src/ai/copilot-provider.model.d.ts +31 -0
  23. package/src/ai/copilot-role.model.d.ts +43 -0
  24. package/src/ai/copilot-store.model.d.ts +29 -0
  25. package/src/ai/copilot-user.model.d.ts +20 -0
  26. package/src/ai/copilot.model.d.ts +36 -0
  27. package/src/ai/{environment.model.ts → environment.model.d.ts} +10 -12
  28. package/src/ai/feature.model.d.ts +6 -0
  29. package/src/ai/index.d.ts +37 -0
  30. package/src/ai/knowledge-doc-page.model.d.ts +15 -0
  31. package/src/ai/knowledge-doc.model.d.ts +177 -0
  32. package/src/ai/knowledge-pipeline.d.ts +81 -0
  33. package/src/ai/knowledge-retrieval-log.model.d.ts +10 -0
  34. package/src/ai/knowledgebase-task.model.d.ts +36 -0
  35. package/src/ai/knowledgebase.model.d.ts +145 -0
  36. package/src/ai/rag-web.d.ts +26 -0
  37. package/src/ai/rag.d.ts +24 -0
  38. package/src/ai/role-permissions.d.ts +13 -0
  39. package/src/ai/types.d.ts +39 -0
  40. package/src/ai/xpert-agent-execution.model.d.ts +96 -0
  41. package/src/ai/xpert-agent.model.d.ts +192 -0
  42. package/src/ai/xpert-project.model.d.ts +86 -0
  43. package/src/ai/xpert-task.model.d.ts +26 -0
  44. package/src/ai/xpert-template.model.d.ts +47 -0
  45. package/src/ai/xpert-tool-mcp.model.d.ts +67 -0
  46. package/src/ai/xpert-tool.model.d.ts +147 -0
  47. package/src/ai/xpert-toolset.model.d.ts +200 -0
  48. package/src/ai/xpert-workflow-task.prompt.d.ts +2 -0
  49. package/src/ai/xpert-workflow.model.d.ts +369 -0
  50. package/src/ai/xpert-workspace.model.d.ts +32 -0
  51. package/src/ai/xpert.model.d.ts +566 -0
  52. package/src/analytics/ai.d.ts +73 -0
  53. package/src/analytics/approval-policy.model.d.ts +30 -0
  54. package/src/analytics/business-area-user.model.d.ts +35 -0
  55. package/src/analytics/business-area.d.ts +17 -0
  56. package/src/analytics/certification.model.d.ts +11 -0
  57. package/src/analytics/chatbi-conversation.model.d.ts +15 -0
  58. package/src/analytics/chatbi-model.model.d.ts +18 -0
  59. package/src/analytics/collection.model.d.ts +6 -0
  60. package/src/analytics/comment.model.d.ts +10 -0
  61. package/src/analytics/data-source-type.d.ts +16 -0
  62. package/src/analytics/data-source.d.ts +62 -0
  63. package/src/analytics/favorite.d.ts +14 -0
  64. package/src/analytics/features.d.ts +19 -0
  65. package/src/analytics/feed-model.d.ts +13 -0
  66. package/src/analytics/gateway.d.ts +27 -0
  67. package/src/analytics/index.d.ts +38 -0
  68. package/src/analytics/indicator-app.d.ts +44 -0
  69. package/src/analytics/{indicator-market.ts → indicator-market.d.ts} +2 -6
  70. package/src/analytics/indicator.d.ts +106 -0
  71. package/src/analytics/model-query-log.model.d.ts +41 -0
  72. package/src/analytics/model-query.d.ts +21 -0
  73. package/src/analytics/{notification-destination.ts → notification-destination.d.ts} +5 -9
  74. package/src/analytics/{permission-approval-user.model.ts → permission-approval-user.model.d.ts} +8 -10
  75. package/src/analytics/permission-approval.model.d.ts +47 -0
  76. package/src/analytics/project.model.d.ts +50 -0
  77. package/src/analytics/role-permissions.d.ts +25 -0
  78. package/src/analytics/schema.d.ts +262 -0
  79. package/src/analytics/screenshot.model.d.ts +25 -0
  80. package/src/analytics/semantic-model-entity.d.ts +37 -0
  81. package/src/analytics/semantic-model-member.d.ts +24 -0
  82. package/src/analytics/semantic-model.d.ts +175 -0
  83. package/src/analytics/{story-point.ts → story-point.d.ts} +6 -11
  84. package/src/analytics/story-template.model.d.ts +28 -0
  85. package/src/analytics/story-widget.d.ts +12 -0
  86. package/src/analytics/story.d.ts +93 -0
  87. package/src/analytics/subscription.d.ts +38 -0
  88. package/src/analytics/visit.model.d.ts +34 -0
  89. package/src/analytics/webSocket.d.ts +48 -0
  90. package/src/api-key.model.d.ts +10 -0
  91. package/src/base-entity.model.d.ts +27 -0
  92. package/src/contact.model.d.ts +41 -0
  93. package/src/core.model.d.ts +97 -0
  94. package/src/{country.model.ts → country.model.d.ts} +2 -3
  95. package/src/currency.model.d.ts +579 -0
  96. package/src/{custom-smtp.model.ts → custom-smtp.model.d.ts} +17 -21
  97. package/src/date-picker.model.d.ts +5 -0
  98. package/src/email-template.model.d.ts +39 -0
  99. package/src/email.model.d.ts +36 -0
  100. package/src/employee.model.d.ts +128 -0
  101. package/src/entity-with-members.model.d.ts +13 -0
  102. package/src/feature.model.d.ts +93 -0
  103. package/src/file-provider.d.ts +33 -0
  104. package/src/help-center-article.model.d.ts +0 -0
  105. package/src/help-center.model.d.ts +0 -0
  106. package/src/http-status.enum.d.ts +57 -0
  107. package/src/import-export.model.d.ts +36 -0
  108. package/src/index.d.ts +48 -0
  109. package/src/integration/dify.d.ts +0 -0
  110. package/src/integration/dingtalk.d.ts +2 -0
  111. package/src/integration/fastgpt.d.ts +0 -0
  112. package/src/integration/firecrawl.d.ts +2 -0
  113. package/src/integration/github.d.ts +69 -0
  114. package/src/integration/index.d.ts +4 -0
  115. package/src/integration/lark.d.ts +11 -0
  116. package/src/integration/ragflow.d.ts +0 -0
  117. package/src/integration/wecom.d.ts +2 -0
  118. package/src/integration.model.d.ts +89 -0
  119. package/src/invite.model.d.ts +123 -0
  120. package/src/language.model.d.ts +19 -0
  121. package/src/organization-contact.model.d.ts +73 -0
  122. package/src/{organization-department.model.ts → organization-department.model.d.ts} +10 -16
  123. package/src/organization-language.model.d.ts +18 -0
  124. package/src/organization-projects.model.d.ts +80 -0
  125. package/src/organization-team-employee-model.d.ts +12 -0
  126. package/src/organization-team-model.d.ts +19 -0
  127. package/src/organization.model.d.ts +239 -0
  128. package/src/password-reset.model.d.ts +18 -0
  129. package/src/{plain-object.model.ts → plain-object.model.d.ts} +1 -1
  130. package/src/plugin.d.ts +13 -0
  131. package/src/role-permission.model.d.ts +61 -0
  132. package/src/role.model.d.ts +26 -0
  133. package/src/schedule.d.ts +27 -0
  134. package/src/secret-token.model.d.ts +11 -0
  135. package/src/seed.model.d.ts +37 -0
  136. package/src/storage-file.model.d.ts +40 -0
  137. package/src/tag-entity.model.d.ts +20 -0
  138. package/src/tenant.model.d.ts +40 -0
  139. package/src/tools/index.d.ts +1 -0
  140. package/src/tools/sandbox.d.ts +5 -0
  141. package/src/translation.model.d.ts +26 -0
  142. package/src/types.d.ts +240 -0
  143. package/src/user-organization.model.d.ts +24 -0
  144. package/src/user.model.d.ts +128 -0
  145. package/src/visibility.model.d.ts +6 -0
  146. package/.babelrc +0 -5
  147. package/.eslintrc.json +0 -18
  148. package/babel.config.json +0 -1
  149. package/jest.config.ts +0 -16
  150. package/project.json +0 -46
  151. package/src/agent/graph.ts +0 -272
  152. package/src/agent/index.ts +0 -5
  153. package/src/agent/token.ts +0 -23
  154. package/src/agent/utils.spec.ts +0 -283
  155. package/src/agent/utils.ts +0 -122
  156. package/src/agent/variables.ts +0 -21
  157. package/src/ai/ai-model.model.ts +0 -228
  158. package/src/ai/ai-provider.model.ts +0 -53
  159. package/src/ai/ai.model.ts +0 -87
  160. package/src/ai/chat-message-feedback.model.ts +0 -31
  161. package/src/ai/chat-message.model.ts +0 -277
  162. package/src/ai/chat.model.ts +0 -207
  163. package/src/ai/copilot-checkpoint.model.ts +0 -25
  164. package/src/ai/copilot-example.model.ts +0 -23
  165. package/src/ai/copilot-model.model.ts +0 -31
  166. package/src/ai/copilot-organization.model.ts +0 -21
  167. package/src/ai/copilot-provider.model.ts +0 -46
  168. package/src/ai/copilot-role.model.ts +0 -48
  169. package/src/ai/copilot-store.model.ts +0 -34
  170. package/src/ai/copilot-user.model.ts +0 -24
  171. package/src/ai/copilot.model.ts +0 -47
  172. package/src/ai/feature.model.ts +0 -6
  173. package/src/ai/index.ts +0 -37
  174. package/src/ai/knowledge-doc-page.model.ts +0 -20
  175. package/src/ai/knowledge-doc.model.ts +0 -217
  176. package/src/ai/knowledge-pipeline.ts +0 -106
  177. package/src/ai/knowledge-retrieval-log.model.ts +0 -19
  178. package/src/ai/knowledgebase-task.model.ts +0 -42
  179. package/src/ai/knowledgebase.model.ts +0 -173
  180. package/src/ai/rag-web.ts +0 -54
  181. package/src/ai/rag.ts +0 -24
  182. package/src/ai/role-permissions.ts +0 -13
  183. package/src/ai/types.ts +0 -83
  184. package/src/ai/xpert-agent-execution.model.ts +0 -115
  185. package/src/ai/xpert-agent.model.ts +0 -258
  186. package/src/ai/xpert-project.model.ts +0 -103
  187. package/src/ai/xpert-task.model.ts +0 -32
  188. package/src/ai/xpert-template.model.ts +0 -53
  189. package/src/ai/xpert-tool-mcp.model.ts +0 -72
  190. package/src/ai/xpert-tool.model.ts +0 -211
  191. package/src/ai/xpert-toolset.model.ts +0 -220
  192. package/src/ai/xpert-workflow-task.prompt.ts +0 -71
  193. package/src/ai/xpert-workflow.model.ts +0 -449
  194. package/src/ai/xpert-workspace.model.ts +0 -42
  195. package/src/ai/xpert.model.ts +0 -781
  196. package/src/analytics/ai.ts +0 -79
  197. package/src/analytics/approval-policy.model.ts +0 -40
  198. package/src/analytics/business-area-user.model.ts +0 -43
  199. package/src/analytics/business-area.ts +0 -20
  200. package/src/analytics/certification.model.ts +0 -12
  201. package/src/analytics/chatbi-conversation.model.ts +0 -16
  202. package/src/analytics/chatbi-model.model.ts +0 -22
  203. package/src/analytics/collection.model.ts +0 -8
  204. package/src/analytics/comment.model.ts +0 -14
  205. package/src/analytics/data-source-type.ts +0 -19
  206. package/src/analytics/data-source.ts +0 -72
  207. package/src/analytics/favorite.ts +0 -18
  208. package/src/analytics/features.ts +0 -19
  209. package/src/analytics/feed-model.ts +0 -15
  210. package/src/analytics/gateway.ts +0 -30
  211. package/src/analytics/index.ts +0 -39
  212. package/src/analytics/indicator-app.ts +0 -49
  213. package/src/analytics/indicator.ts +0 -127
  214. package/src/analytics/model-query-log.model.ts +0 -46
  215. package/src/analytics/model-query.ts +0 -22
  216. package/src/analytics/permission-approval.model.ts +0 -58
  217. package/src/analytics/project.model.ts +0 -56
  218. package/src/analytics/role-permissions.ts +0 -36
  219. package/src/analytics/schema.ts +0 -300
  220. package/src/analytics/screenshot.model.ts +0 -28
  221. package/src/analytics/semantic-model-entity.ts +0 -49
  222. package/src/analytics/semantic-model-member.ts +0 -45
  223. package/src/analytics/semantic-model.ts +0 -228
  224. package/src/analytics/story-template.model.ts +0 -34
  225. package/src/analytics/story-widget.ts +0 -15
  226. package/src/analytics/story.ts +0 -109
  227. package/src/analytics/subscription.ts +0 -43
  228. package/src/analytics/visit.model.ts +0 -39
  229. package/src/analytics/webSocket.ts +0 -53
  230. package/src/api-key.model.ts +0 -11
  231. package/src/base-entity.model.ts +0 -33
  232. package/src/contact.model.ts +0 -45
  233. package/src/core.model.ts +0 -103
  234. package/src/currency.model.ts +0 -582
  235. package/src/date-picker.model.ts +0 -5
  236. package/src/email-template.model.ts +0 -50
  237. package/src/email.model.ts +0 -46
  238. package/src/employee.model.ts +0 -199
  239. package/src/entity-with-members.model.ts +0 -16
  240. package/src/feature.model.ts +0 -108
  241. package/src/file-provider.ts +0 -37
  242. package/src/help-center-article.model.ts +0 -35
  243. package/src/help-center.model.ts +0 -33
  244. package/src/http-status.enum.ts +0 -58
  245. package/src/import-export.model.ts +0 -42
  246. package/src/index.ts +0 -60
  247. package/src/integration/dify.ts +0 -31
  248. package/src/integration/dingtalk.ts +0 -16
  249. package/src/integration/fastgpt.ts +0 -32
  250. package/src/integration/firecrawl.ts +0 -46
  251. package/src/integration/github.ts +0 -149
  252. package/src/integration/index.ts +0 -19
  253. package/src/integration/lark.ts +0 -79
  254. package/src/integration/ragflow.ts +0 -32
  255. package/src/integration/wecom.ts +0 -16
  256. package/src/integration.model.ts +0 -118
  257. package/src/invite.model.ts +0 -144
  258. package/src/language.model.ts +0 -22
  259. package/src/organization-contact.model.ts +0 -84
  260. package/src/organization-language.model.ts +0 -24
  261. package/src/organization-projects.model.ts +0 -99
  262. package/src/organization-team-employee-model.ts +0 -14
  263. package/src/organization-team-model.ts +0 -25
  264. package/src/organization.model.ts +0 -266
  265. package/src/password-reset.model.ts +0 -24
  266. package/src/plugin.ts +0 -15
  267. package/src/role-permission.model.ts +0 -123
  268. package/src/role.model.ts +0 -31
  269. package/src/schedule.ts +0 -71
  270. package/src/secret-token.model.ts +0 -15
  271. package/src/seed.model.ts +0 -50
  272. package/src/storage-file.model.ts +0 -46
  273. package/src/tag-entity.model.ts +0 -23
  274. package/src/tenant.model.ts +0 -52
  275. package/src/tools/index.ts +0 -1
  276. package/src/tools/sandbox.ts +0 -5
  277. package/src/translation.model.ts +0 -37
  278. package/src/types.ts +0 -276
  279. package/src/user-organization.model.ts +0 -31
  280. package/src/user.model.ts +0 -147
  281. package/src/visibility.model.ts +0 -6
  282. package/tsconfig.json +0 -22
  283. package/tsconfig.lib.json +0 -10
  284. package/tsconfig.spec.json +0 -9
@@ -1,781 +0,0 @@
1
- import { ToolCall as LToolCall } from '@langchain/core/dist/messages/tool'
2
- import { RunnableToolLike } from '@langchain/core/runnables'
3
- import { StructuredToolInterface } from '@langchain/core/tools'
4
- import { ITag } from '../tag-entity.model'
5
- import { IUser, LanguagesEnum } from '../user.model'
6
- import { ICopilotModel, TCopilotModel } from './copilot-model.model'
7
- import { IKnowledgebase, TKBRecallParams } from './knowledgebase.model'
8
- import { ChecklistItem, I18nObject, IPoint, ISize, TAvatar } from '../types'
9
- import { IXpertAgent } from './xpert-agent.model'
10
- import { IXpertToolset } from './xpert-toolset.model'
11
- import { IBasePerWorkspaceEntityModel } from './xpert-workspace.model'
12
- import { IIntegration } from '../integration.model'
13
- import { TChatFrom, TSensitiveOperation } from './chat.model'
14
- import { IWorkflowNode, TVariableAssigner, VariableOperationEnum } from './xpert-workflow.model'
15
- import { IEnvironment } from './environment.model'
16
- import { IStorageFile } from '../storage-file.model'
17
- import { STATE_VARIABLE_HUMAN, TInterruptCommand } from '../agent'
18
-
19
- export type ToolCall = LToolCall
20
-
21
- export enum XpertTypeEnum {
22
- /**
23
- * Chat Agents
24
- */
25
- Agent = 'agent',
26
-
27
- /**
28
- * Copilot in UI
29
- */
30
- Copilot = 'copilot',
31
-
32
- /**
33
- * Knowledge Workflow
34
- */
35
- Knowledge = 'knowledge',
36
- }
37
-
38
- export type TXpertFeatures = {
39
- opener: {
40
- enabled: boolean
41
- message: string
42
- questions: string[]
43
- }
44
-
45
- suggestion: {
46
- enabled: boolean
47
- prompt: string
48
- }
49
-
50
- textToSpeech: {
51
- enabled: boolean
52
- copilotModel?: TCopilotModel
53
- }
54
-
55
- speechToText: {
56
- enabled: boolean
57
- copilotModel?: TCopilotModel
58
- }
59
-
60
- /**
61
- * File upload feature
62
- */
63
- attachment?: TXpertAttachment
64
-
65
- /**
66
- * Reply with memory(Q&A)
67
- */
68
- memoryReply?: {
69
- enabled: boolean
70
- scoreThreshold?: number
71
- }
72
- }
73
-
74
- export type TXpert = {
75
- slug: string
76
- name: string
77
- type: XpertTypeEnum
78
- title?: string
79
- titleCN?: string
80
- description?: string
81
-
82
- active?: boolean
83
- avatar?: TAvatar
84
-
85
- /**
86
- * Conversation starters
87
- */
88
- starters?: string[]
89
-
90
- /**
91
- * More configuration
92
- */
93
- options?: TXpertOptions
94
- /**
95
- * Config for every agent
96
- */
97
- agentConfig?: TXpertAgentConfig
98
- /**
99
- * Config of summarize past conversations
100
- */
101
- summarize?: TSummarize
102
- /**
103
- * Long-term memory config
104
- */
105
- memory?: TLongTermMemory
106
-
107
- features?: TXpertFeatures
108
-
109
- /**
110
- * Version of role: '1' '2' '2.1' '2.2'...
111
- */
112
- version?: string
113
- /**
114
- * Is latest version
115
- */
116
- latest?: boolean
117
- /**
118
- * Release notes
119
- */
120
- releaseNotes?: string
121
-
122
- /**
123
- * Draft on current version
124
- * Draft on current version
125
- */
126
- draft?: TXpertTeamDraft
127
- graph?: TXpertGraph
128
-
129
- api?: TChatApi
130
- app?: TChatApp
131
- userId?: string
132
- user?: IUser
133
-
134
- agent?: IXpertAgent
135
-
136
- // Many to one
137
- // Used copilot model
138
- copilotModel?: ICopilotModel
139
- copilotModelId?: string
140
-
141
- // One to many
142
- agents?: IXpertAgent[]
143
-
144
- // Many to many relationships
145
-
146
- /**
147
- * Sub-experts, Digital experts who perform specific tasks, focus on completing the assigned work
148
- */
149
- executors?: IXpert[]
150
- /**
151
- * The task coordinator who called this expert
152
- */
153
- leaders?: IXpert[]
154
-
155
- knowledgebases?: IKnowledgebase[]
156
- toolsets?: IXpertToolset[]
157
-
158
- /**
159
- * The corresponding person in charge, whose has the authority to execute this digital expert
160
- */
161
- managers?: IUser[]
162
- /**
163
- * Integrations for this xpert
164
- */
165
- integrations?: IIntegration[]
166
-
167
- tags?: ITag[]
168
- }
169
-
170
- /**
171
- * Digital Expert
172
- */
173
- export interface IXpert extends IBasePerWorkspaceEntityModel, TXpert {
174
- environmentId?: string
175
- environment?: IEnvironment
176
- /**
177
- * When type is 'knowledge', it must binding a knowledgebase
178
- */
179
- knowledgebase?: IKnowledgebase
180
- }
181
-
182
- export type TXpertOptions = {
183
- knowledge?: Record<
184
- string,
185
- {
186
- position?: IPoint
187
- size?: ISize
188
- }
189
- >
190
- toolset?: Record<
191
- string,
192
- {
193
- position?: IPoint
194
- size?: ISize
195
- }
196
- >
197
- agent?: Record<
198
- string,
199
- {
200
- position?: IPoint
201
- size?: ISize
202
- }
203
- >
204
- xpert?: Record<
205
- string,
206
- {
207
- position?: IPoint
208
- size?: ISize
209
- }
210
- >
211
- position?: IPoint
212
- scale?: number
213
- }
214
-
215
- /**
216
- * Config for Agent execution (Langgraph.js)
217
- */
218
- export type TXpertAgentConfig = {
219
- /**
220
- * Maximum number of times a call can recurse. If not provided, defaults to 25.
221
- */
222
- recursionLimit?: number;
223
- /** Maximum number of parallel calls to make. */
224
- maxConcurrency?: number;
225
- /**
226
- * Timeout for this call in milliseconds.
227
- */
228
- timeout?: number;
229
-
230
- /**
231
- * Sensitive tools and agents
232
- */
233
- interruptBefore?: string[]
234
- /**
235
- * End nodes
236
- */
237
- endNodes?: string[]
238
-
239
- /**
240
- * Custom variables of graph state
241
- */
242
- stateVariables?: TStateVariable[]
243
-
244
- /**
245
- * Custom input parameters should be consistent with the start node or primary agent parameters.
246
- */
247
- parameters?: TXpertParameter[]
248
-
249
- /**
250
- * @deprecated use memories in tools
251
- */
252
- toolsMemory?: Record<string, TVariableAssigner[]>
253
-
254
- /**
255
- * Disable agent's output
256
- * @deprecated use `mute` instead
257
- */
258
- disableOutputs?: string[]
259
-
260
- /**
261
- * Mute nodes in the graph of agents: filter messages by tags of stream events
262
- */
263
- mute?: string[][]
264
-
265
- /**
266
- * Recall params
267
- */
268
- recalls?: Record<string, TKBRecallParams>
269
-
270
- /**
271
- * Summarize the title of the conversation
272
- */
273
- summarizeTitle?: {
274
- disable?: boolean
275
- instruction?: string
276
- }
277
-
278
- tools?: Record<string, {
279
- /**
280
- * Memory assigner for tool's results. (save result of tool call into state variable)
281
- */
282
- memories?: TVariableAssigner[]
283
- timeout?: number
284
- /**
285
- * Custom description for the tool
286
- */
287
- description?: string
288
- }>
289
- }
290
-
291
- export type TStateVariableType = XpertParameterTypeEnum | 'object' | 'array[string]' | 'array[number]' | 'array[object]'
292
- /**
293
- */
294
- export type TStateVariable<ValueType = any, UpdateType = ValueType> = TXpertParameter & {
295
- type: TStateVariableType
296
- default?: any
297
- reducer?: (a: ValueType, b: UpdateType) => ValueType
298
- operation?: VariableOperationEnum
299
- }
300
-
301
- /**
302
- * Config for summarizing past conversations
303
- */
304
- export type TSummarize = {
305
- enabled?: boolean
306
- /**
307
- * The system prompt guide how to summarize the conversation
308
- */
309
- prompt?: string
310
- /**
311
- * The maximum number of tolerated messages, otherwise it will be summarized.
312
- * Should be greater than the number of retained messages
313
- */
314
- maxMessages?: number
315
- /**
316
- * Number of retained messages
317
- */
318
- retainMessages?: number
319
- }
320
-
321
- export enum LongTermMemoryTypeEnum {
322
- PROFILE = 'profile',
323
- QA = 'qa',
324
- }
325
-
326
- export type TLongTermMemoryConfig = {
327
- enabled?: boolean
328
- /**
329
- * System prompt guide how to remember the key points of the conversation
330
- */
331
- prompt?: string
332
- }
333
- /**
334
- * Config of long-term memory
335
- */
336
- export type TLongTermMemory = {
337
- enabled?: boolean
338
- // type?: LongTermMemoryTypeEnum
339
- copilotModel?: TCopilotModel
340
- profile?: TLongTermMemoryConfig & {
341
- afterSeconds?: number
342
- }
343
- qa?: TLongTermMemoryConfig
344
- }
345
-
346
- export type TXpertAttachmentType = 'document' | 'image' | 'audio' | 'video' | 'others'
347
- export type TXpertAttachment = {
348
- enabled?: boolean
349
- type?: 'upload' | 'url' | 'all'
350
- maxNum?: number
351
- fileTypes?: Array<TXpertAttachmentType>
352
- }
353
-
354
- export enum XpertParameterTypeEnum {
355
- /**
356
- * @deprecated use string
357
- */
358
- TEXT = 'text',
359
- /**
360
- * @deprecated use string
361
- */
362
- PARAGRAPH = 'paragraph',
363
- STRING = 'string',
364
- NUMBER = 'number',
365
- OBJECT = 'object',
366
- SELECT = 'select',
367
- ARRAY_STRING = 'array[string]',
368
- ARRAY = 'array[object]',
369
- ARRAY_FILE = 'array[file]',
370
- ARRAY_DOCUMENT = 'array[document]',
371
-
372
- BOOLEAN = 'boolean',
373
- SECRET = 'secret',
374
- }
375
-
376
- export type TXpertParameter = {
377
- type: XpertParameterTypeEnum
378
- name: string
379
- /**
380
- * @deprecated use description and name only
381
- */
382
- title?: string
383
- description?: string | I18nObject
384
- optional?: boolean
385
- maximum?: number
386
- options?: string[]
387
- item?: TXpertParameter[]
388
- }
389
-
390
- export type TChatApp = {
391
- enabled?: boolean
392
- public?: boolean
393
- }
394
-
395
- export type TChatApi = {
396
- disabled?: boolean
397
- }
398
-
399
- // Xpert team draft types
400
- export type TXpertGraph = {
401
- nodes: TXpertTeamNode[]
402
- connections: TXpertTeamConnection[]
403
- }
404
-
405
- export type TXpertTeamDraft = TXpertGraph & {
406
- team: Partial<IXpert>
407
- savedAt?: Date
408
- checklist?: ChecklistItem[]
409
- }
410
-
411
- export type TXpertTeamNodeType = 'agent' | 'knowledge' | 'toolset' | 'xpert' | 'workflow'
412
-
413
- export type TXpertTeamNode = {
414
- key: string
415
- type: TXpertTeamNodeType
416
- position: IRect
417
- size?: ISize
418
- hash?: string
419
- parentId?: string
420
- readonly?: boolean
421
- } & (
422
- | {
423
- type: 'agent'
424
- entity: IXpertAgent
425
- }
426
- | {
427
- type: 'knowledge'
428
- entity: IKnowledgebase
429
- }
430
- | {
431
- type: 'toolset'
432
- entity: IXpertToolset
433
- }
434
- | {
435
- type: 'xpert'
436
- entity: IXpert
437
- nodes?: TXpertTeamNode[]
438
- connections?: TXpertTeamConnection[]
439
- expanded?: boolean
440
- }
441
- | {
442
- type: 'workflow'
443
- entity: IWorkflowNode
444
- }
445
- )
446
-
447
- export interface IRect extends IPoint, Partial<ISize> {
448
- gravityCenter?: IPoint
449
- }
450
-
451
- export type TXpertTeamGroup = {
452
- id: string
453
- title: string
454
- position: IPoint
455
- size?: ISize
456
- parentId?: string
457
- team: IXpert
458
- agent?: IXpertAgent
459
- }
460
-
461
- export interface TXpertTeamConnection {
462
- key: string
463
- from: string
464
- to: string
465
- /**
466
- * - edge: Horizontal Process, workflow
467
- * - others: Vertical Process, agent
468
- */
469
- type: 'edge' | TXpertTeamNodeType
470
-
471
- readonly?: boolean
472
- }
473
-
474
- export enum ChatMessageTypeEnum {
475
- // LOG = 'log',
476
- MESSAGE = 'message',
477
- EVENT = 'event'
478
- }
479
-
480
- /**
481
- * https://js.langchain.com/docs/how_to/streaming/#event-reference
482
- */
483
- export enum ChatMessageEventTypeEnum {
484
- ON_CONVERSATION_START = 'on_conversation_start',
485
- ON_CONVERSATION_END = 'on_conversation_end',
486
- ON_MESSAGE_START = 'on_message_start',
487
- ON_MESSAGE_END = 'on_message_end',
488
- ON_TOOL_START = 'on_tool_start',
489
- ON_TOOL_END = 'on_tool_end',
490
- ON_TOOL_ERROR = 'on_tool_error',
491
- /**
492
- * Step message in tool call
493
- */
494
- ON_TOOL_MESSAGE = 'on_tool_message',
495
- ON_AGENT_START = 'on_agent_start',
496
- ON_AGENT_END = 'on_agent_end',
497
- ON_RETRIEVER_START = 'on_retriever_start',
498
- ON_RETRIEVER_END = 'on_retriever_end',
499
- ON_RETRIEVER_ERROR = 'on_retriever_error',
500
- ON_INTERRUPT = 'on_interrupt',
501
- ON_ERROR = 'on_error',
502
- ON_CHAT_EVENT = 'on_chat_event',
503
- }
504
-
505
- /**
506
- * Human input message, include parameters and attachments
507
- */
508
- export type TChatRequestHuman = {
509
- input?: string
510
- files?: Partial<IStorageFile>[]
511
- [key: string]: unknown
512
- }
513
-
514
- export type TChatRequest = {
515
- /**
516
- * The human input, include parameters
517
- */
518
- input: TChatRequestHuman
519
- /**
520
- * Custom graph state
521
- */
522
- state?: {[STATE_VARIABLE_HUMAN]: TChatRequestHuman} & Record<string, any>
523
- xpertId: string
524
- agentKey?: string
525
- projectId?: string
526
- conversationId?: string
527
- environmentId?: string
528
- id?: string
529
- executionId?: string
530
- confirm?: boolean
531
- /**
532
- * Reject the sensitive tool calls
533
- */
534
- reject?: boolean
535
- /**
536
- * Message to update parameters of last tool call message
537
- * @deprecated use `command` instead
538
- */
539
- operation?: TSensitiveOperation
540
- command?: TInterruptCommand
541
- retry?: boolean
542
- }
543
-
544
- export type TChatOptions = {
545
- conversationId?: string
546
- knowledgebases?: string[]
547
- toolsets?: string[]
548
- /**
549
- * The language used by the current browser page
550
- */
551
- language?: LanguagesEnum
552
- /**
553
- * The browser's time zone
554
- */
555
- timeZone?: string
556
- /**
557
- * Call from
558
- */
559
- from?: TChatFrom
560
- /**
561
- * Whether to summarize the conversation title
562
- */
563
- summarizeTitle?: boolean
564
- /**
565
- * Project ID, identify the project where the xpert invoked
566
- */
567
- projectId?: string
568
- /**
569
- * Schedule task ID
570
- */
571
- taskId?: string
572
- /**
573
- * Specify environment with variables to run
574
- */
575
- environment?: IEnvironment
576
- /**
577
- * Specify additional tools
578
- */
579
- tools?: (StructuredToolInterface | RunnableToolLike)[]
580
- }
581
-
582
- // Helpers
583
- export function omitXpertRelations(xpert: Partial<IXpert>) {
584
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
585
- const { draft, agent, agents, executors, leaders, knowledgebases, toolsets, managers, ...rest } = xpert ?? {}
586
- return rest
587
- }
588
-
589
- export function figureOutXpert(xpert: IXpert, isDraft: boolean) {
590
- return (isDraft ? xpert.draft?.team : xpert) ?? xpert
591
- }
592
-
593
- export function xpertLabel(agent: Partial<IXpert>) {
594
- return agent.title || agent.name
595
- }
596
-
597
- export function createXpertGraph(xpert: IXpert, position: IPoint) {
598
- const graph = xpert.graph ?? xpert.draft
599
-
600
- const nodes = graph.nodes
601
-
602
- // Extract the area by positions of all nodes
603
- const positions = nodes.map((node) => node.position)
604
- const x0Positions = positions.map((pos) => pos.x)
605
- const x1Positions = nodes.map((node) => node.position.x + (node.size?.width ?? 240)) // Node width min 240
606
- const y0Positions = positions.map((pos) => pos.y)
607
- const y1Positions = nodes.map((node) => node.position.y + (node.size?.height ?? 70)) // Node height min 70
608
-
609
- const xRange = {
610
- min: Math.min(...x0Positions),
611
- max: Math.max(...x1Positions)
612
- }
613
-
614
- const yRange = {
615
- min: Math.min(...y0Positions),
616
- max: Math.max(...y1Positions)
617
- }
618
-
619
- const size = {
620
- width: xRange.max - xRange.min + 50,
621
- height: yRange.max - yRange.min + 80
622
- }
623
-
624
- nodes.forEach((node) => {
625
- node.position = {
626
- x: position.x + (node.position?.x ? node.position.x - xRange.min : 0) + 10,
627
- y: position.y + (node.position?.y ? node.position.y - yRange.min : 0) + 40,
628
- }
629
- })
630
-
631
- return { nodes, size, connections: graph.connections }
632
- }
633
-
634
- /**
635
- * Create all nodes of xpert and it's area size
636
- *
637
- * @param xpert
638
- * @returns
639
- */
640
- export function createXpertNodes(xpert: IXpert, position: IPoint) {
641
- const nodes: TXpertTeamNode[] = []
642
- const agents = []
643
- if (!xpert.agent.options?.hidden) {
644
- agents.push(xpert.agent)
645
- }
646
- if (xpert.agents?.length) {
647
- agents.push(...xpert.agents)
648
- }
649
- // Agents
650
- nodes.push(...agents.map((_) => {
651
- return {
652
- type: 'agent',
653
- key: _.key,
654
- position: xpert.options?.agent?.[_.key]?.position ?? {x: 0, y: 0},
655
- size: xpert.options?.agent?.[_.key]?.size,
656
- entity: _
657
- } as TXpertTeamNode
658
- }))
659
-
660
- // External experts
661
- xpert.executors?.forEach((executor) => {
662
- const position = xpert.options?.xpert?.[executor.id]?.position ?? {x: 0, y: 0}
663
- const executorGraph = createXpertNodes(executor, position)
664
- nodes.push({
665
- type: 'xpert',
666
- key: executor.id,
667
- position,
668
- size: executorGraph.size,
669
- entity: executor,
670
- nodes: executorGraph.nodes
671
- } as TXpertTeamNode)
672
- })
673
-
674
- // knowledgebases
675
- nodes.push(...(xpert.knowledgebases ?? []).map((x) => {
676
- return {
677
- key: x.id,
678
- type: 'knowledge',
679
- position: xpert.options?.knowledge?.[x.id]?.position ?? {x: 0, y: 0},
680
- size: xpert.options?.knowledge?.[x.id]?.size,
681
- entity: x,
682
- } as TXpertTeamNode
683
- }))
684
-
685
- // Toolsets
686
- nodes.push(...(xpert.toolsets ?? []).map((x) => {
687
- return {
688
- key: x.id,
689
- type: 'toolset',
690
- position: xpert.options?.toolset?.[x.id]?.position ?? {x: 0, y: 0},
691
- size: xpert.options?.toolset?.[x.id]?.size,
692
- entity: x,
693
- } as TXpertTeamNode
694
- }))
695
-
696
- // Extract the area by positions of all nodes
697
- const positions = nodes.map((node) => node.position)
698
- const x0Positions = positions.map((pos) => pos.x)
699
- const x1Positions = nodes.map((node) => node.position.x + (node.size?.width ?? 240)) // Node width min 240
700
- const y0Positions = positions.map((pos) => pos.y)
701
- const y1Positions = nodes.map((node) => node.position.y + (node.size?.height ?? 70)) // Node height min 70
702
-
703
- const xRange = {
704
- min: Math.min(...x0Positions),
705
- max: Math.max(...x1Positions)
706
- }
707
-
708
- const yRange = {
709
- min: Math.min(...y0Positions),
710
- max: Math.max(...y1Positions)
711
- }
712
-
713
- const size = {
714
- width: xRange.max - xRange.min + 50,
715
- height: yRange.max - yRange.min + 80
716
- }
717
-
718
- nodes.forEach((node) => {
719
- node.position = {
720
- x: position.x + (node.position?.x ? node.position.x - xRange.min : 0) + 10,
721
- y: position.y + (node.position?.y ? node.position.y - yRange.min : 0) + 40,
722
- }
723
- })
724
-
725
- return { nodes, size }
726
- }
727
-
728
- export function createAgentConnections(agent: IXpertAgent, collaborators: IXpert[]) {
729
- const connections = []
730
- const from = agent.leaderKey
731
- const to = agent.key
732
- if (from && to) {
733
- connections.push({
734
- type: 'agent',
735
- key: from + '/' + to,
736
- from,
737
- to
738
- })
739
- }
740
-
741
- // collaborators
742
- agent.collaboratorNames?.forEach((name) => {
743
- const collaborator = collaborators.find((_) => _.name === name)
744
- if (collaborator) {
745
- const from = agent.key
746
- const to = collaborator.id
747
- connections.push({
748
- type: 'xpert',
749
- key: from + '/' + to,
750
- from,
751
- to
752
- })
753
- }
754
- })
755
-
756
- // knowledgebases
757
- agent.knowledgebaseIds?.forEach((knowledgebaseId) => {
758
- const from = agent.key
759
- const to = knowledgebaseId
760
- connections.push({
761
- type: 'knowledge',
762
- key: from + '/' + to,
763
- from,
764
- to
765
- })
766
- })
767
-
768
- // toolsets
769
- agent.toolsetIds?.forEach((toolsetId) => {
770
- const from = agent.key
771
- const to = toolsetId
772
- connections.push({
773
- type: 'toolset',
774
- key: from + '/' + to,
775
- from,
776
- to
777
- })
778
- })
779
-
780
- return connections
781
- }