@metad/contracts 0.0.1 → 3.6.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 (204) hide show
  1. package/.babelrc +5 -0
  2. package/.eslintrc.json +18 -0
  3. package/README.md +3 -1
  4. package/babel.config.json +1 -0
  5. package/jest.config.ts +16 -0
  6. package/package.json +5 -5
  7. package/project.json +46 -0
  8. package/src/agent/ai-model.ts +9 -0
  9. package/src/agent/graph.ts +272 -0
  10. package/src/agent/index.ts +5 -0
  11. package/src/agent/token.ts +23 -0
  12. package/src/agent/utils.spec.ts +283 -0
  13. package/src/agent/utils.ts +122 -0
  14. package/src/agent/variables.ts +21 -0
  15. package/src/ai/ai-model.model.ts +228 -0
  16. package/src/ai/ai-provider.model.ts +53 -0
  17. package/src/ai/ai.model.ts +87 -0
  18. package/src/ai/chat-message-feedback.model.ts +31 -0
  19. package/src/ai/chat-message.model.ts +277 -0
  20. package/src/ai/chat.model.ts +207 -0
  21. package/src/ai/copilot-checkpoint.model.ts +25 -0
  22. package/src/ai/copilot-example.model.ts +23 -0
  23. package/src/ai/copilot-model.model.ts +31 -0
  24. package/src/ai/copilot-organization.model.ts +21 -0
  25. package/src/ai/copilot-provider.model.ts +46 -0
  26. package/src/ai/copilot-role.model.ts +48 -0
  27. package/src/ai/copilot-store.model.ts +34 -0
  28. package/src/ai/copilot-user.model.ts +24 -0
  29. package/src/ai/copilot.model.ts +47 -0
  30. package/src/ai/environment.model.ts +18 -0
  31. package/src/ai/feature.model.ts +6 -0
  32. package/src/ai/index.ts +37 -0
  33. package/src/ai/knowledge-doc-page.model.ts +20 -0
  34. package/src/ai/knowledge-doc.model.ts +217 -0
  35. package/src/ai/knowledge-pipeline.ts +106 -0
  36. package/src/ai/knowledge-retrieval-log.model.ts +19 -0
  37. package/src/ai/knowledgebase-task.model.ts +42 -0
  38. package/src/ai/knowledgebase.model.ts +173 -0
  39. package/src/ai/rag-web.ts +54 -0
  40. package/src/ai/rag.ts +24 -0
  41. package/src/ai/role-permissions.ts +13 -0
  42. package/src/ai/types.ts +83 -0
  43. package/src/ai/xpert-agent-execution.model.ts +115 -0
  44. package/src/ai/xpert-agent.model.ts +258 -0
  45. package/src/ai/xpert-project.model.ts +103 -0
  46. package/src/ai/xpert-task.model.ts +32 -0
  47. package/src/ai/xpert-template.model.ts +53 -0
  48. package/src/ai/xpert-tool-mcp.model.ts +72 -0
  49. package/src/ai/xpert-tool.model.ts +211 -0
  50. package/src/ai/xpert-toolset.model.ts +220 -0
  51. package/src/ai/xpert-workflow-task.prompt.ts +71 -0
  52. package/src/ai/xpert-workflow.model.ts +449 -0
  53. package/src/ai/xpert-workspace.model.ts +42 -0
  54. package/src/ai/xpert.model.ts +781 -0
  55. package/src/analytics/ai.ts +79 -0
  56. package/src/analytics/approval-policy.model.ts +40 -0
  57. package/src/analytics/business-area-user.model.ts +43 -0
  58. package/src/analytics/business-area.ts +20 -0
  59. package/src/analytics/certification.model.ts +12 -0
  60. package/src/analytics/chatbi-conversation.model.ts +16 -0
  61. package/src/analytics/chatbi-model.model.ts +22 -0
  62. package/src/analytics/collection.model.ts +8 -0
  63. package/src/analytics/comment.model.ts +14 -0
  64. package/src/analytics/data-source-type.ts +19 -0
  65. package/src/analytics/data-source.ts +72 -0
  66. package/src/analytics/favorite.ts +18 -0
  67. package/src/analytics/features.ts +19 -0
  68. package/src/analytics/feed-model.ts +15 -0
  69. package/src/analytics/gateway.ts +30 -0
  70. package/src/analytics/index.ts +39 -0
  71. package/src/analytics/indicator-app.ts +49 -0
  72. package/{analytics/indicator-market.d.ts → src/analytics/indicator-market.ts} +8 -4
  73. package/src/analytics/indicator.ts +127 -0
  74. package/src/analytics/model-query-log.model.ts +45 -0
  75. package/src/analytics/model-query.ts +22 -0
  76. package/{analytics/notification-destination.d.ts → src/analytics/notification-destination.ts} +14 -10
  77. package/src/analytics/permission-approval-user.model.ts +12 -0
  78. package/src/analytics/permission-approval.model.ts +58 -0
  79. package/src/analytics/project.model.ts +56 -0
  80. package/src/analytics/role-permissions.ts +36 -0
  81. package/src/analytics/schema.ts +300 -0
  82. package/src/analytics/screenshot.model.ts +28 -0
  83. package/src/analytics/semantic-model-entity.ts +49 -0
  84. package/src/analytics/semantic-model-member.ts +45 -0
  85. package/src/analytics/semantic-model.ts +227 -0
  86. package/{analytics/story-point.d.ts → src/analytics/story-point.ts} +16 -10
  87. package/src/analytics/story-template.model.ts +34 -0
  88. package/src/analytics/story-widget.ts +15 -0
  89. package/src/analytics/story.ts +109 -0
  90. package/src/analytics/subscription.ts +43 -0
  91. package/src/analytics/visit.model.ts +39 -0
  92. package/src/analytics/webSocket.ts +53 -0
  93. package/src/api-key.model.ts +11 -0
  94. package/src/base-entity.model.ts +33 -0
  95. package/src/contact.model.ts +45 -0
  96. package/src/core.model.ts +103 -0
  97. package/{country.model.d.ts → src/country.model.ts} +6 -5
  98. package/src/currency.model.ts +582 -0
  99. package/src/custom-smtp.model.ts +27 -0
  100. package/src/date-picker.model.ts +5 -0
  101. package/src/email-template.model.ts +50 -0
  102. package/src/email.model.ts +46 -0
  103. package/src/employee.model.ts +199 -0
  104. package/src/entity-with-members.model.ts +16 -0
  105. package/src/feature.model.ts +108 -0
  106. package/src/file-provider.ts +37 -0
  107. package/src/help-center-article.model.ts +35 -0
  108. package/src/help-center.model.ts +33 -0
  109. package/src/http-status.enum.ts +58 -0
  110. package/src/import-export.model.ts +42 -0
  111. package/src/index.ts +60 -0
  112. package/src/integration/dify.ts +31 -0
  113. package/src/integration/dingtalk.ts +16 -0
  114. package/src/integration/fastgpt.ts +32 -0
  115. package/src/integration/firecrawl.ts +46 -0
  116. package/src/integration/github.ts +149 -0
  117. package/src/integration/index.ts +19 -0
  118. package/src/integration/lark.ts +79 -0
  119. package/src/integration/ragflow.ts +32 -0
  120. package/src/integration/wecom.ts +16 -0
  121. package/src/integration.model.ts +118 -0
  122. package/src/invite.model.ts +144 -0
  123. package/src/language.model.ts +22 -0
  124. package/src/organization-contact.model.ts +84 -0
  125. package/src/organization-department.model.ts +26 -0
  126. package/src/organization-language.model.ts +24 -0
  127. package/src/organization-projects.model.ts +99 -0
  128. package/src/organization-team-employee-model.ts +14 -0
  129. package/src/organization-team-model.ts +25 -0
  130. package/src/organization.model.ts +266 -0
  131. package/src/password-reset.model.ts +24 -0
  132. package/src/plain-object.model.ts +13 -0
  133. package/src/plugin.ts +15 -0
  134. package/src/role-permission.model.ts +123 -0
  135. package/src/role.model.ts +31 -0
  136. package/src/schedule.ts +71 -0
  137. package/src/secret-token.model.ts +15 -0
  138. package/src/seed.model.ts +50 -0
  139. package/src/storage-file.model.ts +46 -0
  140. package/src/tag-entity.model.ts +23 -0
  141. package/src/tenant.model.ts +52 -0
  142. package/src/tools/index.ts +1 -0
  143. package/src/tools/sandbox.ts +5 -0
  144. package/src/translation.model.ts +37 -0
  145. package/src/types.ts +276 -0
  146. package/src/user-organization.model.ts +31 -0
  147. package/src/user.model.ts +147 -0
  148. package/src/visibility.model.ts +6 -0
  149. package/tsconfig.json +22 -0
  150. package/tsconfig.lib.json +10 -0
  151. package/tsconfig.spec.json +9 -0
  152. package/analytics/business-area-user.model.d.ts +0 -29
  153. package/analytics/business-area.d.ts +0 -16
  154. package/analytics/business-group.d.ts +0 -12
  155. package/analytics/data-source-type.d.ts +0 -12
  156. package/analytics/data-source.d.ts +0 -43
  157. package/analytics/favorite.d.ts +0 -14
  158. package/analytics/features.d.ts +0 -19
  159. package/analytics/feed-model.d.ts +0 -13
  160. package/analytics/index.d.ts +0 -20
  161. package/analytics/indicator.d.ts +0 -31
  162. package/analytics/insight-model.d.ts +0 -14
  163. package/analytics/model-query.d.ts +0 -12
  164. package/analytics/role-permissions.d.ts +0 -19
  165. package/analytics/semantic-model.d.ts +0 -42
  166. package/analytics/story-widget.d.ts +0 -11
  167. package/analytics/story.d.ts +0 -18
  168. package/analytics/subscription.d.ts +0 -38
  169. package/analytics/user-business-group.model.d.ts +0 -29
  170. package/analytics/visit.model.d.ts +0 -27
  171. package/analytics/webSocket.d.ts +0 -40
  172. package/base-entity.model.d.ts +0 -21
  173. package/contact.model.d.ts +0 -41
  174. package/core.model.d.ts +0 -25
  175. package/currency.model.d.ts +0 -579
  176. package/email-template.model.d.ts +0 -47
  177. package/email.model.d.ts +0 -36
  178. package/employee.model.d.ts +0 -128
  179. package/entity-with-members.model.d.ts +0 -13
  180. package/feature.model.d.ts +0 -134
  181. package/file-provider.d.ts +0 -31
  182. package/help-center-article.model.d.ts +0 -27
  183. package/help-center.model.d.ts +0 -28
  184. package/http-status.enum.d.ts +0 -57
  185. package/import-export.model.d.ts +0 -36
  186. package/index.cjs +0 -1283
  187. package/index.d.ts +0 -33
  188. package/index.js +0 -1272
  189. package/language.model.d.ts +0 -19
  190. package/organization-contact.model.d.ts +0 -73
  191. package/organization-department.model.d.ts +0 -20
  192. package/organization-language.model.d.ts +0 -18
  193. package/organization-team-employee-model.d.ts +0 -12
  194. package/organization-team-model.d.ts +0 -19
  195. package/organization.model.d.ts +0 -227
  196. package/role-permission.model.d.ts +0 -63
  197. package/role.model.d.ts +0 -21
  198. package/seed.model.d.ts +0 -38
  199. package/tag-entity.model.d.ts +0 -10
  200. package/tenant.model.d.ts +0 -24
  201. package/translation.model.d.ts +0 -20
  202. package/user-organization.model.d.ts +0 -24
  203. package/user.model.d.ts +0 -117
  204. package/visibility.model.d.ts +0 -5
package/.babelrc ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "presets": [
3
+ "@nrwl/js/babel"
4
+ ]
5
+ }
package/.eslintrc.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": ["../../.eslintrc.json"],
3
+ "ignorePatterns": ["!**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
+ "rules": {}
8
+ },
9
+ {
10
+ "files": ["*.ts", "*.tsx"],
11
+ "rules": {}
12
+ },
13
+ {
14
+ "files": ["*.js", "*.jsx"],
15
+ "rules": {}
16
+ }
17
+ ]
18
+ }
package/README.md CHANGED
@@ -1 +1,3 @@
1
- # Pangolin
1
+ # contracts
2
+
3
+ Contacts is a package that contains all the types used in the ocap project.
@@ -0,0 +1 @@
1
+ {}
package/jest.config.ts ADDED
@@ -0,0 +1,16 @@
1
+ /* eslint-disable */
2
+ export default {
3
+ displayName: 'contracts',
4
+ preset: '../../jest.preset.js',
5
+ globals: {},
6
+ transform: {
7
+ '^.+\\.[tj]s$': [
8
+ 'ts-jest',
9
+ {
10
+ tsconfig: '<rootDir>/tsconfig.spec.json'
11
+ }
12
+ ]
13
+ },
14
+ moduleFileExtensions: ['ts', 'js', 'html'],
15
+ coverageDirectory: '../../coverage/packages/contracts'
16
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@metad/contracts",
3
- "version": "0.0.1",
4
- "module": "./index.js",
5
- "main": "./index.cjs",
6
- "type": "module",
7
- "types": "./index.d.ts"
3
+ "version": "3.6.0-beta.1",
4
+ "license": "AGPL-3.0",
5
+ "scripts": {
6
+ "docs": "yarn typedoc --out ./.docs"
7
+ }
8
8
  }
package/project.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "contracts",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/contracts/src",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "build": {
8
+ "executor": "@nx/rollup:rollup",
9
+ "outputs": ["{options.outputPath}"],
10
+ "options": {
11
+ "outputPath": "dist/packages/contracts",
12
+ "project": "packages/contracts/package.json",
13
+ "main": "packages/contracts/src/index.ts",
14
+ "tsConfig": "packages/contracts/tsconfig.lib.json",
15
+ "assets": [
16
+ {
17
+ "glob": "README.md",
18
+ "input": ".",
19
+ "output": "."
20
+ }
21
+ ],
22
+ "compiler": "swc",
23
+ "format": ["cjs", "esm"]
24
+ }
25
+ },
26
+ "publish": {
27
+ "command": "node tools/scripts/publish.mjs contracts {args.ver} {args.tag}",
28
+ "dependsOn": ["build"]
29
+ },
30
+ "lint": {
31
+ "executor": "@nx/eslint:lint",
32
+ "outputs": ["{options.outputFile}"],
33
+ "options": {
34
+ "lintFilePatterns": ["packages/contracts/**/*.ts", "packages/contracts/package.json"]
35
+ }
36
+ },
37
+ "test": {
38
+ "executor": "@nx/jest:jest",
39
+ "outputs": ["{workspaceRoot}/coverage/packages/contracts"],
40
+ "options": {
41
+ "jestConfig": "packages/contracts/jest.config.ts"
42
+ }
43
+ }
44
+ },
45
+ "tags": []
46
+ }
@@ -0,0 +1,9 @@
1
+ export enum AiModelTypeEnum {
2
+ LLM = "llm",
3
+ TEXT_EMBEDDING = "text-embedding",
4
+ RERANK = "rerank",
5
+ SPEECH2TEXT = "speech2text",
6
+ MODERATION = "moderation",
7
+ TTS = "tts",
8
+ TEXT2IMG = "text2img"
9
+ }
@@ -0,0 +1,272 @@
1
+ import { BaseMessage } from '@langchain/core/messages'
2
+ import { RunnableConfig } from '@langchain/core/runnables'
3
+ import { Subscriber } from 'rxjs'
4
+ import { IWFNTrigger, TWorkflowVarGroup, WorkflowNodeTypeEnum } from '../ai/xpert-workflow.model'
5
+ import { TMessageContentComplex } from '../ai/chat-message.model'
6
+ import { I18nObject } from '../types'
7
+ import { TStateVariable, TXpertGraph, TXpertParameter, TXpertTeamNode, XpertParameterTypeEnum } from '../ai/xpert.model'
8
+ import { agentLabel, IXpertAgent } from '../ai/xpert-agent.model'
9
+
10
+ /**
11
+ * @deprecated can use getCurrentTaskInput instead?
12
+ */
13
+ export const CONTEXT_VARIABLE_CURRENTSTATE = 'currentState'
14
+ export const STATE_VARIABLE_SYS = 'sys'
15
+ export const STATE_VARIABLE_HUMAN = 'human'
16
+ export const GRAPH_NODE_SUMMARIZE_CONVERSATION = 'summarize_conversation'
17
+ export const GRAPH_NODE_TITLE_CONVERSATION = 'title_conversation'
18
+ export const STATE_VARIABLE_FILES = 'files'
19
+ export const STATE_VARIABLE_INPUT = 'input'
20
+ export const STATE_VARIABLE_TITLE_CHANNEL = channelName('title')
21
+
22
+ export type TMessageChannel = {
23
+ system: string
24
+ messages: BaseMessage[]
25
+ summary?: string
26
+ error?: string | null
27
+ }
28
+
29
+ export type TAgentRunnableConfigurable = {
30
+ /**
31
+ * Thread id
32
+ */
33
+ thread_id: string
34
+ checkpoint_ns: string
35
+ checkpoint_id: string
36
+ tool_call_id?: string
37
+
38
+ // Custom configurable of invoke
39
+ tenantId: string
40
+ organizationId: string
41
+ language: string
42
+ userId: string
43
+ /**
44
+ * Xpert project id
45
+ */
46
+ projectId?: string
47
+ xpertId?: string
48
+ // Caller
49
+ agentKey: string
50
+ xpertName?: string
51
+ toolName?: string
52
+
53
+ subscriber: Subscriber<any>
54
+ /**
55
+ * Execution id of agent workflow node
56
+ */
57
+ executionId: string
58
+ // /**
59
+ // * Knowledge xpert's knowledgebase
60
+ // */
61
+ // knowledgebaseId?: string
62
+ // knowledgeTaskId?: string
63
+
64
+ signal?: AbortSignal
65
+ }
66
+
67
+ export type TToolCall = {
68
+ id?: string
69
+ name: string
70
+ type?: 'tool_call'
71
+ args: Record<string, any>
72
+ }
73
+
74
+ /**
75
+ *
76
+ * Example:
77
+ *
78
+ * ```typescript
79
+ * const result = interrupt<TInterruptMessage<{ name: string }>, { projectId: string }>({
80
+ * category: 'BI',
81
+ * type: 'switch_project',
82
+ * title: {
83
+ * en_US: 'Switch project',
84
+ * zh_Hans: '切换项目'
85
+ * },
86
+ * message: {
87
+ * en_US: 'Please select a project or create a new one',
88
+ * zh_Hans: '请选择或创建一个新的项目'
89
+ * },
90
+ * data: { name: '' }
91
+ * })
92
+ * ```
93
+ */
94
+ export type TInterruptMessage<T = unknown> = {
95
+ /**
96
+ * Major categories of interrupt components
97
+ */
98
+ category: 'BI'
99
+ /**
100
+ * The specific type of interactive component
101
+ */
102
+ type: string
103
+ /**
104
+ * Title of the interrupt component
105
+ */
106
+ title: string | I18nObject
107
+ /**
108
+ * Message content of the interrupt component
109
+ */
110
+ message: string | I18nObject
111
+ /**
112
+ * Additional data
113
+ */
114
+ data?: T
115
+ }
116
+
117
+ export type TInterruptCommand = {
118
+ resume?: any
119
+ update?: any
120
+ toolCalls?: TToolCall[]
121
+ agentKey?: string
122
+ }
123
+
124
+ // Helpers
125
+ export function channelName(name: string) {
126
+ return name.toLowerCase() + '_channel'
127
+ }
128
+
129
+ export function messageContentText(content: string | TMessageContentComplex) {
130
+ return typeof content === 'string' ? content : content.type === 'text' ? content.text : ''
131
+ }
132
+
133
+ export function getWorkspaceFromRunnable(configurable: TAgentRunnableConfigurable): {type?: 'project' | 'conversation'; id?: string} {
134
+ return configurable?.projectId ? {type: 'project', id: ''} :
135
+ configurable?.thread_id ? {
136
+ type: 'conversation',
137
+ id: configurable.thread_id
138
+ } : {}
139
+ }
140
+
141
+ export function getToolCallFromConfig(config): TToolCall {
142
+ return config?.toolCall || config?.configurable?.toolCall
143
+ }
144
+
145
+ export function getToolCallIdFromConfig(config): string {
146
+ return config.metadata?.tool_call_id || config?.configurable?.tool_call_id || getToolCallFromConfig(config)?.id
147
+ }
148
+
149
+ /**
150
+ * Compute long-term memory namespace:
151
+ * 1. When a user talks to a digital expert individually, use `ExpertId` + `UserId` to store memory
152
+ * 2. When talking to a digital expert in a project, all users and digital experts share `ProjectId` to store memory
153
+ *
154
+ * @param config
155
+ * @returns
156
+ */
157
+ export function getStoreNamespace(config: RunnableConfig): string[] {
158
+ const configurable = config.configurable as TAgentRunnableConfigurable
159
+ return configurableStoreNamespace(configurable)
160
+ }
161
+
162
+ export function configurableStoreNamespace(configurable: Partial<TAgentRunnableConfigurable>): string[] {
163
+ return configurable?.projectId ? [configurable?.projectId] : configurable?.userId ? [configurable.xpertId, configurable.userId] : []
164
+ }
165
+
166
+ /**
167
+ * Set value into variable of state.
168
+ *
169
+ * @param state
170
+ * @param varName
171
+ * @param value
172
+ * @returns
173
+ */
174
+ export function setStateVariable(state: Record<string, any>, varName: string, value: any) {
175
+ const [agentChannelName, variableName] = varName.split('.')
176
+ if (variableName) {
177
+ state[agentChannelName] = {
178
+ ...(state[agentChannelName] ?? {}),
179
+ [variableName]: value
180
+ }
181
+ } else {
182
+ state[agentChannelName] = value
183
+ }
184
+
185
+ return state
186
+ }
187
+
188
+ /**
189
+ * Get agent variable group from graph.
190
+ *
191
+ * @param key
192
+ * @param graph
193
+ * @returns
194
+ */
195
+ export function getAgentVarGroup(key: string, graph: TXpertGraph): TWorkflowVarGroup {
196
+ const node = graph.nodes.find((_) => _.type === 'agent' && _.key === key) as TXpertTeamNode & {type: 'agent'}
197
+
198
+ const variables: TXpertParameter[] = []
199
+ const varGroup: TWorkflowVarGroup = {
200
+ group: {
201
+ name: channelName(node.key),
202
+ description: {
203
+ en_US: agentLabel(node.entity)
204
+ },
205
+ },
206
+ variables
207
+ }
208
+
209
+ variables.push({
210
+ name: `messages`,
211
+ type: XpertParameterTypeEnum.ARRAY,
212
+ description: {
213
+ zh_Hans: `消息列表`,
214
+ en_US: `Message List`
215
+ }
216
+ })
217
+ variables.push({
218
+ name: `output`,
219
+ type: XpertParameterTypeEnum.STRING,
220
+ description: {
221
+ zh_Hans: `输出`,
222
+ en_US: `Output`
223
+ }
224
+ })
225
+ variables.push({
226
+ name: `error`,
227
+ type: XpertParameterTypeEnum.STRING,
228
+ description: {
229
+ zh_Hans: `错误`,
230
+ en_US: `Error`
231
+ }
232
+ })
233
+ const agent = <IXpertAgent>node.entity
234
+ if (agent.options?.structuredOutputMethod && agent.outputVariables) {
235
+ agent.outputVariables.forEach((variable) => {
236
+ variables.push({
237
+ name: variable.name || '',
238
+ type: variable.type as TStateVariable['type'],
239
+ description: variable.description,
240
+ item: variable.item
241
+ })
242
+ })
243
+ }
244
+
245
+ return varGroup
246
+ }
247
+
248
+
249
+ // Swarm
250
+ /**
251
+ * Get swarm partners of agent in team
252
+ *
253
+ * @param graph
254
+ * @param agentKey
255
+ */
256
+ export function getSwarmPartners(graph: TXpertGraph, agentKey: string, partners: string[], leaderKey?: string) {
257
+ const connections = graph.connections.filter((conn) => conn.type === 'agent' && conn.to === agentKey && (leaderKey ? conn.from !== leaderKey : true)
258
+ && graph.connections.some((_) => _.type === 'agent' && _.to === conn.from && _.from === agentKey))
259
+
260
+ connections.forEach((conn) => {
261
+ const key = conn.from
262
+ if (partners.indexOf(key) < 0) {
263
+ partners.push(key)
264
+ getSwarmPartners(graph, key, partners)
265
+ }
266
+ })
267
+ return partners
268
+ }
269
+
270
+ export function getWorkflowTriggers(graph: TXpertGraph, from: string) {
271
+ return graph.nodes.filter((node) => node.type === 'workflow' && node.entity.type === WorkflowNodeTypeEnum.TRIGGER && (<IWFNTrigger>node.entity).from === from)
272
+ }
@@ -0,0 +1,5 @@
1
+ export * from './ai-model'
2
+ export * from './token'
3
+ export * from './graph'
4
+ export * from './utils'
5
+ export * from './variables'
@@ -0,0 +1,23 @@
1
+ export type TTokenUsage = {
2
+ promptTokens: number
3
+ completionTokens: number
4
+ totalTokens: number
5
+ }
6
+
7
+ export interface IModelUsage {
8
+ totalTokens: number
9
+ totalPrice: number
10
+ currency: string
11
+ latency: number
12
+ }
13
+
14
+ export interface ILLMUsage extends IModelUsage {
15
+ promptTokens: number
16
+ promptUnitPrice: number
17
+ promptPriceUnit: number
18
+ promptPrice: number
19
+ completionTokens: number
20
+ completionUnitPrice: number
21
+ completionPriceUnit: number
22
+ completionPrice: number
23
+ }