@vertesia/client 0.51.0 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/LICENSE +3 -3
  2. package/package.json +27 -12
  3. package/src/AccountApi.ts +14 -2
  4. package/src/AccountsApi.ts +4 -0
  5. package/src/ApiKeysApi.ts +1 -1
  6. package/src/EnvironmentsApi.ts +2 -2
  7. package/src/InteractionBase.ts +1 -1
  8. package/src/InteractionsApi.ts +29 -7
  9. package/src/PluginsApi.ts +28 -0
  10. package/src/ProjectsApi.ts +10 -2
  11. package/src/PromptsApi.ts +1 -1
  12. package/src/RunsApi.ts +67 -30
  13. package/src/client.test.ts +94 -0
  14. package/src/client.ts +86 -13
  15. package/src/execute.ts +14 -8
  16. package/src/index.ts +2 -3
  17. package/src/nodejs/NodeStreamSource.ts +43 -0
  18. package/src/nodejs/index.ts +1 -0
  19. package/src/store/AnalyzeDocApi.ts +29 -9
  20. package/src/store/CommandsApi.ts +6 -33
  21. package/src/store/EmbeddingsApi.ts +39 -0
  22. package/src/store/FilesApi.ts +4 -0
  23. package/src/store/ObjectsApi.ts +179 -86
  24. package/src/store/TypesApi.ts +2 -1
  25. package/src/store/WorkflowsApi.ts +127 -25
  26. package/src/store/client.ts +2 -0
  27. package/lib/cjs/AccountApi.js +0 -74
  28. package/lib/cjs/AccountApi.js.map +0 -1
  29. package/lib/cjs/AccountsApi.js +0 -13
  30. package/lib/cjs/AccountsApi.js.map +0 -1
  31. package/lib/cjs/AnalyticsApi.js +0 -13
  32. package/lib/cjs/AnalyticsApi.js.map +0 -1
  33. package/lib/cjs/ApiKeysApi.js +0 -63
  34. package/lib/cjs/ApiKeysApi.js.map +0 -1
  35. package/lib/cjs/CommandsApi.js +0 -19
  36. package/lib/cjs/CommandsApi.js.map +0 -1
  37. package/lib/cjs/EnvironmentsApi.js +0 -58
  38. package/lib/cjs/EnvironmentsApi.js.map +0 -1
  39. package/lib/cjs/IamApi.js +0 -51
  40. package/lib/cjs/IamApi.js.map +0 -1
  41. package/lib/cjs/InteractionBase.js +0 -44
  42. package/lib/cjs/InteractionBase.js.map +0 -1
  43. package/lib/cjs/InteractionsApi.js +0 -192
  44. package/lib/cjs/InteractionsApi.js.map +0 -1
  45. package/lib/cjs/ProjectsApi.js +0 -48
  46. package/lib/cjs/ProjectsApi.js.map +0 -1
  47. package/lib/cjs/PromptsApi.js +0 -133
  48. package/lib/cjs/PromptsApi.js.map +0 -1
  49. package/lib/cjs/RefsApi.js +0 -14
  50. package/lib/cjs/RefsApi.js.map +0 -1
  51. package/lib/cjs/RunsApi.js +0 -80
  52. package/lib/cjs/RunsApi.js.map +0 -1
  53. package/lib/cjs/StreamSource.js +0 -17
  54. package/lib/cjs/StreamSource.js.map +0 -1
  55. package/lib/cjs/TrainingApi.js +0 -54
  56. package/lib/cjs/TrainingApi.js.map +0 -1
  57. package/lib/cjs/UsersApi.js +0 -13
  58. package/lib/cjs/UsersApi.js.map +0 -1
  59. package/lib/cjs/client.js +0 -161
  60. package/lib/cjs/client.js.map +0 -1
  61. package/lib/cjs/execute.js +0 -146
  62. package/lib/cjs/execute.js.map +0 -1
  63. package/lib/cjs/index.js +0 -22
  64. package/lib/cjs/index.js.map +0 -1
  65. package/lib/cjs/package.json +0 -3
  66. package/lib/cjs/store/AgentsApi.js +0 -16
  67. package/lib/cjs/store/AgentsApi.js.map +0 -1
  68. package/lib/cjs/store/AnalyzeDocApi.js +0 -37
  69. package/lib/cjs/store/AnalyzeDocApi.js.map +0 -1
  70. package/lib/cjs/store/CollectionsApi.js +0 -77
  71. package/lib/cjs/store/CollectionsApi.js.map +0 -1
  72. package/lib/cjs/store/CommandsApi.js +0 -33
  73. package/lib/cjs/store/CommandsApi.js.map +0 -1
  74. package/lib/cjs/store/FilesApi.js +0 -122
  75. package/lib/cjs/store/FilesApi.js.map +0 -1
  76. package/lib/cjs/store/ObjectsApi.js +0 -189
  77. package/lib/cjs/store/ObjectsApi.js.map +0 -1
  78. package/lib/cjs/store/TypesApi.js +0 -56
  79. package/lib/cjs/store/TypesApi.js.map +0 -1
  80. package/lib/cjs/store/WorkflowsApi.js +0 -92
  81. package/lib/cjs/store/WorkflowsApi.js.map +0 -1
  82. package/lib/cjs/store/client.js +0 -53
  83. package/lib/cjs/store/client.js.map +0 -1
  84. package/lib/cjs/store/errors.js +0 -11
  85. package/lib/cjs/store/errors.js.map +0 -1
  86. package/lib/cjs/store/index.js +0 -22
  87. package/lib/cjs/store/index.js.map +0 -1
  88. package/lib/esm/AccountApi.js +0 -71
  89. package/lib/esm/AccountApi.js.map +0 -1
  90. package/lib/esm/AccountsApi.js +0 -10
  91. package/lib/esm/AccountsApi.js.map +0 -1
  92. package/lib/esm/AnalyticsApi.js +0 -10
  93. package/lib/esm/AnalyticsApi.js.map +0 -1
  94. package/lib/esm/ApiKeysApi.js +0 -59
  95. package/lib/esm/ApiKeysApi.js.map +0 -1
  96. package/lib/esm/CommandsApi.js +0 -16
  97. package/lib/esm/CommandsApi.js.map +0 -1
  98. package/lib/esm/EnvironmentsApi.js +0 -55
  99. package/lib/esm/EnvironmentsApi.js.map +0 -1
  100. package/lib/esm/IamApi.js +0 -45
  101. package/lib/esm/IamApi.js.map +0 -1
  102. package/lib/esm/InteractionBase.js +0 -40
  103. package/lib/esm/InteractionBase.js.map +0 -1
  104. package/lib/esm/InteractionsApi.js +0 -189
  105. package/lib/esm/InteractionsApi.js.map +0 -1
  106. package/lib/esm/ProjectsApi.js +0 -45
  107. package/lib/esm/ProjectsApi.js.map +0 -1
  108. package/lib/esm/PromptsApi.js +0 -130
  109. package/lib/esm/PromptsApi.js.map +0 -1
  110. package/lib/esm/RefsApi.js +0 -10
  111. package/lib/esm/RefsApi.js.map +0 -1
  112. package/lib/esm/RunsApi.js +0 -76
  113. package/lib/esm/RunsApi.js.map +0 -1
  114. package/lib/esm/StreamSource.js +0 -13
  115. package/lib/esm/StreamSource.js.map +0 -1
  116. package/lib/esm/TrainingApi.js +0 -51
  117. package/lib/esm/TrainingApi.js.map +0 -1
  118. package/lib/esm/UsersApi.js +0 -10
  119. package/lib/esm/UsersApi.js.map +0 -1
  120. package/lib/esm/client.js +0 -154
  121. package/lib/esm/client.js.map +0 -1
  122. package/lib/esm/execute.js +0 -108
  123. package/lib/esm/execute.js.map +0 -1
  124. package/lib/esm/index.js +0 -6
  125. package/lib/esm/index.js.map +0 -1
  126. package/lib/esm/store/AgentsApi.js +0 -12
  127. package/lib/esm/store/AgentsApi.js.map +0 -1
  128. package/lib/esm/store/AnalyzeDocApi.js +0 -33
  129. package/lib/esm/store/AnalyzeDocApi.js.map +0 -1
  130. package/lib/esm/store/CollectionsApi.js +0 -73
  131. package/lib/esm/store/CollectionsApi.js.map +0 -1
  132. package/lib/esm/store/CommandsApi.js +0 -28
  133. package/lib/esm/store/CommandsApi.js.map +0 -1
  134. package/lib/esm/store/FilesApi.js +0 -117
  135. package/lib/esm/store/FilesApi.js.map +0 -1
  136. package/lib/esm/store/ObjectsApi.js +0 -185
  137. package/lib/esm/store/ObjectsApi.js.map +0 -1
  138. package/lib/esm/store/TypesApi.js +0 -52
  139. package/lib/esm/store/TypesApi.js.map +0 -1
  140. package/lib/esm/store/WorkflowsApi.js +0 -86
  141. package/lib/esm/store/WorkflowsApi.js.map +0 -1
  142. package/lib/esm/store/client.js +0 -49
  143. package/lib/esm/store/client.js.map +0 -1
  144. package/lib/esm/store/errors.js +0 -7
  145. package/lib/esm/store/errors.js.map +0 -1
  146. package/lib/esm/store/index.js +0 -6
  147. package/lib/esm/store/index.js.map +0 -1
  148. package/lib/tsconfig.tsbuildinfo +0 -1
  149. package/lib/types/AccountApi.d.ts +0 -53
  150. package/lib/types/AccountApi.d.ts.map +0 -1
  151. package/lib/types/AccountsApi.d.ts +0 -7
  152. package/lib/types/AccountsApi.d.ts.map +0 -1
  153. package/lib/types/AnalyticsApi.d.ts +0 -7
  154. package/lib/types/AnalyticsApi.d.ts.map +0 -1
  155. package/lib/types/ApiKeysApi.d.ts +0 -43
  156. package/lib/types/ApiKeysApi.d.ts.map +0 -1
  157. package/lib/types/CommandsApi.d.ts +0 -11
  158. package/lib/types/CommandsApi.d.ts.map +0 -1
  159. package/lib/types/EnvironmentsApi.d.ts +0 -31
  160. package/lib/types/EnvironmentsApi.d.ts.map +0 -1
  161. package/lib/types/IamApi.d.ts +0 -40
  162. package/lib/types/IamApi.d.ts.map +0 -1
  163. package/lib/types/InteractionBase.d.ts +0 -23
  164. package/lib/types/InteractionBase.d.ts.map +0 -1
  165. package/lib/types/InteractionsApi.d.ts +0 -136
  166. package/lib/types/InteractionsApi.d.ts.map +0 -1
  167. package/lib/types/ProjectsApi.d.ts +0 -18
  168. package/lib/types/ProjectsApi.d.ts.map +0 -1
  169. package/lib/types/PromptsApi.d.ts +0 -107
  170. package/lib/types/PromptsApi.d.ts.map +0 -1
  171. package/lib/types/RefsApi.d.ts +0 -7
  172. package/lib/types/RefsApi.d.ts.map +0 -1
  173. package/lib/types/RunsApi.d.ts +0 -64
  174. package/lib/types/RunsApi.d.ts.map +0 -1
  175. package/lib/types/StreamSource.d.ts +0 -8
  176. package/lib/types/StreamSource.d.ts.map +0 -1
  177. package/lib/types/TrainingApi.d.ts +0 -28
  178. package/lib/types/TrainingApi.d.ts.map +0 -1
  179. package/lib/types/UsersApi.d.ts +0 -7
  180. package/lib/types/UsersApi.d.ts.map +0 -1
  181. package/lib/types/client.d.ts +0 -86
  182. package/lib/types/client.d.ts.map +0 -1
  183. package/lib/types/execute.d.ts +0 -33
  184. package/lib/types/execute.d.ts.map +0 -1
  185. package/lib/types/index.d.ts +0 -9
  186. package/lib/types/index.d.ts.map +0 -1
  187. package/lib/types/store/AgentsApi.d.ts +0 -7
  188. package/lib/types/store/AgentsApi.d.ts.map +0 -1
  189. package/lib/types/store/AnalyzeDocApi.d.ts +0 -17
  190. package/lib/types/store/AnalyzeDocApi.d.ts.map +0 -1
  191. package/lib/types/store/CollectionsApi.d.ts +0 -38
  192. package/lib/types/store/CollectionsApi.d.ts.map +0 -1
  193. package/lib/types/store/CommandsApi.d.ts +0 -14
  194. package/lib/types/store/CommandsApi.d.ts.map +0 -1
  195. package/lib/types/store/FilesApi.d.ts +0 -42
  196. package/lib/types/store/FilesApi.d.ts.map +0 -1
  197. package/lib/types/store/ObjectsApi.d.ts +0 -79
  198. package/lib/types/store/ObjectsApi.d.ts.map +0 -1
  199. package/lib/types/store/TypesApi.d.ts +0 -23
  200. package/lib/types/store/TypesApi.d.ts.map +0 -1
  201. package/lib/types/store/WorkflowsApi.d.ts +0 -40
  202. package/lib/types/store/WorkflowsApi.d.ts.map +0 -1
  203. package/lib/types/store/client.d.ts +0 -28
  204. package/lib/types/store/client.d.ts.map +0 -1
  205. package/lib/types/store/errors.d.ts +0 -5
  206. package/lib/types/store/errors.d.ts.map +0 -1
  207. package/lib/types/store/index.d.ts +0 -6
  208. package/lib/types/store/index.d.ts.map +0 -1
package/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
- Copyright 2024 Composable
1
+ Copyright 2024 Composable Prompts
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
5
5
  You may obtain a copy of the License at
6
6
 
7
- http://www.apache.org/licenses/LICENSE-2.0
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
8
 
9
9
  Unless required by applicable law or agreed to in writing, software
10
10
  distributed under the License is distributed on an "AS IS" BASIS,
11
11
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  See the License for the specific language governing permissions and
13
- limitations under the License.
13
+ limitations under the License.
package/package.json CHANGED
@@ -1,36 +1,51 @@
1
1
  {
2
2
  "name": "@vertesia/client",
3
- "version": "0.51.0",
3
+ "version": "0.54.0",
4
4
  "type": "module",
5
5
  "types": "./lib/types/index.d.ts",
6
6
  "files": [
7
7
  "lib",
8
8
  "src"
9
9
  ],
10
+ "license": "Apache-2.0",
10
11
  "devDependencies": {
11
- "@types/eventsource": "^1.1.14",
12
- "@types/node": "^20.8.9",
12
+ "@types/node": "^22.13.5",
13
13
  "ts-dual-module": "^0.6.3",
14
14
  "typescript": "^5.0.2",
15
- "vitest": "^2.1.9"
15
+ "vitest": "^3.0.9"
16
16
  },
17
17
  "dependencies": {
18
- "eventsource": "^2.0.2",
19
- "@llumiverse/core": "0.15.0",
20
- "@vertesia/api-fetch-client": "0.51.0",
21
- "@vertesia/common": "0.51.0"
18
+ "eventsource": "^3.0.6",
19
+ "@vertesia/common": "0.54.0",
20
+ "@llumiverse/core": "0.17.0",
21
+ "@vertesia/api-fetch-client": "0.54.0"
22
22
  },
23
23
  "ts_dual_module": {
24
24
  "outDir": "lib"
25
25
  },
26
26
  "exports": {
27
- "types": "./lib/types/index.d.ts",
28
- "import": "./lib/esm/index.js",
29
- "require": "./lib/cjs/index.js"
27
+ ".": {
28
+ "types": "./lib/types/index.d.ts",
29
+ "import": "./lib/esm/index.js",
30
+ "require": "./lib/cjs/index.js"
31
+ },
32
+ "./node": {
33
+ "types": "./lib/types/nodejs/index.d.ts",
34
+ "import": "./lib/esm/nodejs/index.js",
35
+ "require": "./lib/cjs/nodejs/index.js"
36
+ }
37
+ },
38
+ "typesVersions": {
39
+ "*": {
40
+ "node": [
41
+ "./lib/types/nodejs/index.d.ts"
42
+ ]
43
+ }
30
44
  },
31
45
  "scripts": {
32
46
  "eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
33
47
  "build": "pnpm exec tsmod build",
34
- "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
48
+ "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo",
49
+ "test": "vitest run"
35
50
  }
36
51
  }
package/src/AccountApi.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
- import { Account, InviteUserRequestPayload, InviteUserResponsePayload, OnboardingProgress, ProjectRef, TransientToken, UpdateAccountPayload, User, UserInviteTokenData } from "@vertesia/common";
2
+ import { Account, InviteUserRequestPayload, InviteUserResponsePayload, OnboardingProgress, ProjectRef, StripeBillingStatusResponse, TransientToken, UpdateAccountPayload, User, UserInviteTokenData } from "@vertesia/common";
3
3
 
4
4
  export default class AccountApi extends ApiTopic {
5
5
 
@@ -42,13 +42,21 @@ export default class AccountApi extends ApiTopic {
42
42
  }
43
43
 
44
44
  /**
45
- * Fetch Invites for account
45
+ * Fetch Invites for Principal
46
46
  * @returns UserInviteTokenData[]
47
47
  * */
48
48
  listInvites(): Promise<TransientToken<UserInviteTokenData>[]> {
49
49
  return this.get('/invites');
50
50
  }
51
51
 
52
+ /**
53
+ * Fetch Invites for Account
54
+ * @returns UserInviteTokenData[]
55
+ * */
56
+ listAccountInvitation(id: string): Promise<TransientToken<UserInviteTokenData>[]> {
57
+ return this.get(`/invites/${id}`);
58
+ }
59
+
52
60
  /**
53
61
  * Accept Invite for account
54
62
  * @returns UserInviteTokenData
@@ -81,4 +89,8 @@ export default class AccountApi extends ApiTopic {
81
89
  return this.get('/google-token');
82
90
  }
83
91
 
92
+ getStripeBillingStatus(): Promise<StripeBillingStatusResponse> {
93
+ return this.get('/stripe-billing-status')
94
+ }
95
+
84
96
  }
@@ -11,6 +11,10 @@ export default class AccountsApi extends ApiTopic {
11
11
  return this.post('/', { payload: { name } });
12
12
  }
13
13
 
14
+ list(): Promise<Account[]> {
15
+ return this.get('/');
16
+ }
17
+
14
18
 
15
19
 
16
20
 
package/src/ApiKeysApi.ts CHANGED
@@ -50,7 +50,7 @@ export class ApiKeysApi extends ApiTopic {
50
50
  }
51
51
 
52
52
  /**
53
- * get or create a temporary public key which can be used from browser to browse and execute itneractions.
53
+ * get or create a temporary public key which can be used from browser to browse and execute interactions.
54
54
  * If a public key already exists for the given project (or for the current organization) then it is returned, otherwise a new one is created.
55
55
  * The payload object can contain the following properties:
56
56
  * - name: the name of the public key. If not specified a random name is generated.
@@ -34,8 +34,8 @@ export default class EnvironmentsApi extends ApiTopic {
34
34
  }
35
35
 
36
36
  /**
37
- * udpate enabled models and / or config. If enabled_models is not provided, the existing enabled models will not change.
38
- * Same, if config is not provioded the exiting config is not changed.
37
+ * Update enabled models and / or config. If enabled_models is not provided, the existing enabled models will not change.
38
+ * Same, if config is not provided the exiting config is not changed.
39
39
  * If the config is provided then it will be updated without removing fields that are not provided.
40
40
  *
41
41
  * @param id
@@ -31,7 +31,7 @@ export class InteractionBase<P = any, R = any> {
31
31
  * the run completes or fails.
32
32
  * If the onChunk callback is passed then the streaming of the result is enabled.
33
33
  * The onChunk callback with be called with the next chunk of the result as soon as it is available.
34
- * When all chunks are received the fucntion will return the resolved promise
34
+ * When all chunks are received the function will return the resolved promise
35
35
  * @param id of the interaction to execute
36
36
  * @param payload InteractionExecutionPayload
37
37
  * @param onChunk callback to be called when the next chunk of the response is available
@@ -1,7 +1,7 @@
1
- import { ComputeInteractionFacetPayload, ExecutionRun, GenerateInteractionPayload, GenerateTestDataPayload, ImprovePromptPayload, Interaction, InteractionCreatePayload, InteractionExecutionPayload, InteractionForkPayload, InteractionPublishPayload, InteractionRef, InteractionRefWithSchema, InteractionUpdatePayload, InteractionsExportPayload, InteractionSearchPayload, InteractionSearchQuery } from "@vertesia/common";
2
1
  import { ApiTopic, ClientBase, ServerError } from "@vertesia/api-fetch-client";
2
+ import { AsyncExecutionPayload, ComputeInteractionFacetPayload, ExecutionRun, GenerateInteractionPayload, GenerateTestDataPayload, ImprovePromptPayload, Interaction, InteractionCreatePayload, InteractionEndpointQuery, InteractionExecutionPayload, InteractionExecutionResult, InteractionForkPayload, InteractionPublishPayload, InteractionRef, InteractionRefWithSchema, InteractionSearchPayload, InteractionSearchQuery, InteractionUpdatePayload, InteractionsExportPayload } from "@vertesia/common";
3
3
  import { VertesiaClient } from "./client.js";
4
- import { executeInteraction, executeInteractionByName } from "./execute.js";
4
+ import { executeInteraction, executeInteractionAsync, executeInteractionByName } from "./execute.js";
5
5
 
6
6
  export interface ComputeInteractionFacetsResponse {
7
7
  tags?: { _id: string, count: number }[];
@@ -9,6 +9,10 @@ export interface ComputeInteractionFacetsResponse {
9
9
  total?: { count: number }[];
10
10
  }
11
11
 
12
+ export interface AsyncExecutionResult {
13
+ runId: string, workflowId: string
14
+ }
15
+
12
16
  export default class InteractionsApi extends ApiTopic {
13
17
  constructor(parent: ClientBase) {
14
18
  super(parent, "/api/v1/interactions");
@@ -27,6 +31,15 @@ export default class InteractionsApi extends ApiTopic {
27
31
  }
28
32
  });
29
33
  }
34
+ /**
35
+ * Find interactions given a mongo match query.
36
+ * You can also specify if prompts schemas are included in the result
37
+ */
38
+ listEndpoints(payload: InteractionEndpointQuery): Promise<InteractionRef[]> {
39
+ return this.post("/endpoints", {
40
+ payload
41
+ });
42
+ }
30
43
 
31
44
  /**
32
45
  * List all interaction versions in the project having the given endpoint name.
@@ -79,7 +92,7 @@ export default class InteractionsApi extends ApiTopic {
79
92
  }
80
93
 
81
94
  /**
82
- * Retrieve an existing interaction definiton
95
+ * Retrieve an existing interaction definition
83
96
  * @param id of the interaction to retrieve
84
97
  * @returns Interaction
85
98
  **/
@@ -88,7 +101,7 @@ export default class InteractionsApi extends ApiTopic {
88
101
  }
89
102
 
90
103
  /**
91
- * Update an existing interaction definiton
104
+ * Update an existing interaction definition
92
105
  * @param id of the interaction to update
93
106
  * @param payload InteractionUpdatePayload
94
107
  * @returns Interaction
@@ -108,7 +121,7 @@ export default class InteractionsApi extends ApiTopic {
108
121
  * the run completes or fails.
109
122
  * If the onChunk callback is passed then the streaming of the result is enabled.
110
123
  * The onChunk callback with be called with the next chunk of the result as soon as it is available.
111
- * When all chunks are received the fucntion will return the resolved promise
124
+ * When all chunks are received the function will return the resolved promise
112
125
  * @param id of the interaction to execute
113
126
  * @param payload InteractionExecutionPayload
114
127
  * @param onChunk callback to be called when the next chunk of the response is available
@@ -133,7 +146,7 @@ export default class InteractionsApi extends ApiTopic {
133
146
  /**
134
147
  * Same as execute but uses the interaction name selector instead of the id.
135
148
  *
136
- * A name selector is the interaction endpoint name suffuxed with an optional tag or version wich is starting with a `@` character.
149
+ * A name selector is the interaction endpoint name suffixed with an optional tag or version which is starting with a `@` character.
137
150
  * The special `draft` tag is used to select the draft version of the interaction. If no tag or version is specified then the latest version is selected.
138
151
  * Examples of selectors:
139
152
  * - `ReviewContract` - select the latest version of the ReviewContract interaction
@@ -146,7 +159,7 @@ export default class InteractionsApi extends ApiTopic {
146
159
  * @returns
147
160
  */
148
161
  executeByName<P = any, R = any>(nameWithTag: string, payload: InteractionExecutionPayload = {},
149
- onChunk?: (chunk: string) => void): Promise<ExecutionRun<P, R>> {
162
+ onChunk?: (chunk: string) => void): Promise<InteractionExecutionResult<P, R>> {
150
163
  return executeInteractionByName(this.client as VertesiaClient, nameWithTag, payload, onChunk).catch(err => {
151
164
  if (err instanceof ServerError && err.payload?.id) {
152
165
  throw err.updateDetails({ run_id: err.payload.id });
@@ -156,6 +169,15 @@ export default class InteractionsApi extends ApiTopic {
156
169
  });
157
170
  }
158
171
 
172
+ /**
173
+ * Execute an interaction in an workflow
174
+ * @param payload
175
+ * @returns
176
+ */
177
+ executeAsync(payload: AsyncExecutionPayload): Promise<AsyncExecutionResult> {
178
+ return executeInteractionAsync(this.client as VertesiaClient, payload);
179
+ }
180
+
159
181
  publish(id: string, payload: InteractionPublishPayload): Promise<Interaction> {
160
182
  return this.post(`/${id}/publish`, {
161
183
  payload
@@ -0,0 +1,28 @@
1
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
+ import type { PluginManifest } from "@vertesia/common";
3
+
4
+ export default class PluginsApi extends ApiTopic {
5
+
6
+ constructor(parent: ClientBase) {
7
+ super(parent, "/api/v1/plugins")
8
+ }
9
+
10
+ create(manifest: Omit<PluginManifest, 'id'>): Promise<PluginManifest> {
11
+ return this.post('/', { payload: manifest });
12
+ }
13
+
14
+ update(manifest: PluginManifest) {
15
+ return this.put(`/${manifest.id}`, { payload: manifest });
16
+ }
17
+
18
+ /**
19
+ * If a project ID is specified through the project query param
20
+ * then only the plugins that are enabled on the project are returned.
21
+ * @param query
22
+ * @returns
23
+ */
24
+ list(): Promise<PluginManifest[]> {
25
+ return this.get('/');
26
+ }
27
+
28
+ }
@@ -1,5 +1,5 @@
1
1
  import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
- import { AwsConfiguration, GithubConfiguration, GladiaConfiguration, ICreateProjectPayload, MacgicPdfConfiguration, Project, ProjectIntegrationListEntry, ProjectRef, SupportedIntegrations } from "@vertesia/common";
2
+ import { AwsConfiguration, GithubConfiguration, GladiaConfiguration, ICreateProjectPayload, MagicPdfConfiguration, PluginManifest, Project, ProjectIntegrationListEntry, ProjectRef, SupportedIntegrations } from "@vertesia/common";
3
3
 
4
4
  export default class ProjectsApi extends ApiTopic {
5
5
  constructor(parent: ClientBase) {
@@ -26,6 +26,14 @@ export default class ProjectsApi extends ApiTopic {
26
26
  });
27
27
  }
28
28
 
29
+ listPlugins(projectId: string): Promise<PluginManifest[]> {
30
+ return this.get(`/${projectId}/plugins`);
31
+ }
32
+
33
+ setPlugins(projectId: string, pluginIds: string[]): Promise<{ count: number }> {
34
+ return this.post(`/${projectId}/plugins`, { payload: { plugins: pluginIds } });
35
+ }
36
+
29
37
  integrations: IntegrationsConfigurationApi = new IntegrationsConfigurationApi(this);
30
38
 
31
39
  }
@@ -40,7 +48,7 @@ class IntegrationsConfigurationApi extends ApiTopic {
40
48
  return this.get(`/${projectId}/integrations`).then(res => res.integrations);
41
49
  }
42
50
 
43
- retrieve(projectId: string, integrationId: SupportedIntegrations): Promise<GladiaConfiguration | GithubConfiguration | AwsConfiguration | MacgicPdfConfiguration | undefined> {
51
+ retrieve(projectId: string, integrationId: SupportedIntegrations): Promise<GladiaConfiguration | GithubConfiguration | AwsConfiguration | MagicPdfConfiguration | undefined> {
44
52
  return this.get(`/${projectId}/integrations/${integrationId}`).catch(err => {
45
53
  if (err.status === 404) {
46
54
  return undefined;
package/src/PromptsApi.ts CHANGED
@@ -123,7 +123,7 @@ export default class PromptsApi extends ApiTopic {
123
123
  }
124
124
 
125
125
  /**
126
- * List the versions of the prompt template. Returens an empty array if no versions are found
126
+ * List the versions of the prompt template. Returns an empty array if no versions are found
127
127
  * @param id
128
128
  * @returns the versions list or an empty array if no versions are found
129
129
  */
package/src/RunsApi.ts CHANGED
@@ -1,26 +1,38 @@
1
1
  import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
- import { ComputeRunFacetPayload, ExecutionRun, ExecutionRunRef, FindPayload, RunCreatePayload, RunListingFilters, RunListingQueryOptions, RunSearchPayload } from "@vertesia/common";
2
+ import {
3
+ CheckpointConversationPayload,
4
+ ComputeRunFacetPayload,
5
+ ExecutionRun,
6
+ ExecutionRunRef,
7
+ FindPayload,
8
+ RunCreatePayload,
9
+ RunListingFilters,
10
+ RunListingQueryOptions,
11
+ RunSearchPayload,
12
+ ToolResultsPayload,
13
+ UserMessagePayload,
14
+ } from "@vertesia/common";
3
15
  import { VertesiaClient } from "./client.js";
16
+ import { ExecutionResponse } from "@llumiverse/core";
4
17
 
5
18
  export interface FilterOption {
6
- id: string,
7
- name: string,
8
- count: number
19
+ id: string;
20
+ name: string;
21
+ count: number;
9
22
  }
10
23
 
11
24
  export interface ComputeRunFacetsResponse {
12
- environments?: { _id: string, count: number }[];
13
- interactions?: { _id: string, count: number }[];
14
- models?: { _id: string, count: number }[];
15
- tags?: { _id: string, count: number }[];
16
- status?: { _id: string, count: number }[];
25
+ environments?: { _id: string; count: number }[];
26
+ interactions?: { _id: string; count: number }[];
27
+ models?: { _id: string; count: number }[];
28
+ tags?: { _id: string; count: number }[];
29
+ status?: { _id: string; count: number }[];
17
30
  total?: { count: number }[];
18
31
  }
19
32
 
20
33
  export class RunsApi extends ApiTopic {
21
-
22
34
  constructor(parent: ClientBase) {
23
- super(parent, "/api/v1/runs")
35
+ super(parent, "/api/v1/runs");
24
36
  }
25
37
 
26
38
  /**
@@ -30,30 +42,29 @@ export class RunsApi extends ApiTopic {
30
42
  * @returns InteractionResult[]
31
43
  **/
32
44
  list({ limit, offset, filters }: RunListingQueryOptions): Promise<ExecutionRunRef[]> {
33
-
34
45
  const query = {
35
46
  limit,
36
47
  offset,
37
- ...filters
38
- }
48
+ ...filters,
49
+ };
39
50
 
40
- return this.get('/', { query: query });
51
+ return this.get("/", { query: query });
41
52
  }
42
53
 
43
54
  find(payload: FindPayload): Promise<ExecutionRun[]> {
44
55
  return this.post("/find", {
45
- payload
56
+ payload,
46
57
  });
47
58
  }
48
59
 
49
60
  /**
50
61
  * Get a run by id
51
- *
62
+ *
52
63
  * @param id
53
64
  * @returns InteractionResult
54
65
  **/
55
- retrieve<P=any, R=any>(id: string): Promise<ExecutionRun<P, R>> {
56
- return this.get('/' + id);
66
+ retrieve<P = any, R = any>(id: string): Promise<ExecutionRun<P, R>> {
67
+ return this.get("/" + id);
57
68
  }
58
69
 
59
70
  /**
@@ -62,10 +73,9 @@ export class RunsApi extends ApiTopic {
62
73
  */
63
74
  filterOptions(field: string, filters: RunListingFilters): Promise<FilterOption[]> {
64
75
  const query = {
65
- ...filters
66
- }
76
+ ...filters,
77
+ };
67
78
  return this.get(`/filter-options/${field}`, { query });
68
-
69
79
  }
70
80
 
71
81
  create(payload: RunCreatePayload): Promise<ExecutionRun> {
@@ -73,14 +83,42 @@ export class RunsApi extends ApiTopic {
73
83
  if (sessionTags) {
74
84
  let tags = Array.isArray(sessionTags) ? sessionTags : [sessionTags];
75
85
  if (Array.isArray(payload.tags)) {
76
- tags = tags.concat(payload.tags)
86
+ tags = tags.concat(payload.tags);
77
87
  } else if (payload.tags) {
78
- tags = tags.concat([payload.tags])
88
+ tags = tags.concat([payload.tags]);
79
89
  }
80
- payload = { ...payload, tags }
90
+ payload = { ...payload, tags };
81
91
  }
82
92
  return this.post("/", {
83
- payload
93
+ payload,
94
+ });
95
+ }
96
+
97
+ /**
98
+ * Send tool results and continues the conversation
99
+ * @param payload
100
+ * @returns
101
+ */
102
+ sendToolResults(payload: ToolResultsPayload): Promise<ExecutionResponse> {
103
+ return this.post(`/tool-results`, {
104
+ payload,
105
+ });
106
+ }
107
+
108
+ /**
109
+ *
110
+ * @param payload
111
+ * @returns
112
+ */
113
+ sendUserMessage(payload: UserMessagePayload): Promise<ExecutionResponse> {
114
+ return this.post(`/user-message`, {
115
+ payload,
116
+ });
117
+ }
118
+
119
+ createCheckpoint(payload: CheckpointConversationPayload): Promise<ExecutionResponse> {
120
+ return this.post(`/checkpoint`, {
121
+ payload,
84
122
  });
85
123
  }
86
124
 
@@ -91,14 +129,13 @@ export class RunsApi extends ApiTopic {
91
129
  **/
92
130
  computeFacets(query: ComputeRunFacetPayload): Promise<ComputeRunFacetsResponse> {
93
131
  return this.post("/facets", {
94
- payload: query
132
+ payload: query,
95
133
  });
96
134
  }
97
135
 
98
136
  search(payload: RunSearchPayload): Promise<ExecutionRunRef[]> {
99
137
  return this.post("/search", {
100
- payload
138
+ payload,
101
139
  });
102
140
  }
103
-
104
- }
141
+ }
@@ -0,0 +1,94 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { VertesiaClient } from "./client";
3
+
4
+ describe('Test Vertesia Client', () => {
5
+ test('Initialization with studio and zeno URLs', () => {
6
+ const client = new VertesiaClient({
7
+ serverUrl: 'https://api.vertesia.io',
8
+ storeUrl: 'https://api.vertesia.io',
9
+ apikey: '1234',
10
+ });
11
+ expect(client).toBeDefined();
12
+ });
13
+
14
+ test('Initialization with studio URL only', () => {
15
+ expect(() => {
16
+ new VertesiaClient({
17
+ serverUrl: 'https://api.vertesia.io',
18
+ storeUrl: '',
19
+ });
20
+ }).toThrowError("Parameter 'site' or 'storeUrl' is required for VertesiaClient");
21
+ });
22
+
23
+ test('Initialization with zeno URL only', () => {
24
+ expect(() => {
25
+ new VertesiaClient({
26
+ serverUrl: '',
27
+ storeUrl: 'https://api.vertesia.io',
28
+ });
29
+ }).toThrowError("Parameter 'site' or 'serverUrl' is required for VertesiaClient");
30
+ });
31
+
32
+ test('Initialization with same site', () => {
33
+ const client = new VertesiaClient({
34
+ serverUrl: 'https://api.vertesia.io',
35
+ storeUrl: 'https://api.vertesia.io',
36
+ site: 'api.vertesia.io',
37
+ });
38
+
39
+ expect(client).toBeDefined();
40
+ expect(client.baseUrl).toBe('https://api.vertesia.io');
41
+ expect(client.storeUrl).toBe('https://api.vertesia.io');
42
+ });
43
+
44
+ test('Initialization with default parameters', () => {
45
+ const client = new VertesiaClient();
46
+
47
+ expect(client).toBeDefined();
48
+ expect(client.baseUrl).toBe('https://api.vertesia.io');
49
+ expect(client.storeUrl).toBe('https://api.vertesia.io');
50
+ });
51
+
52
+ test('Initialization with site api-preview.vertesia.io', () => {
53
+ const client = new VertesiaClient({
54
+ site: 'api-preview.vertesia.io',
55
+ });
56
+
57
+ expect(client).toBeDefined();
58
+ expect(client.baseUrl).toBe('https://api-preview.vertesia.io');
59
+ expect(client.storeUrl).toBe('https://api-preview.vertesia.io');
60
+ });
61
+
62
+ test('Initialization with site api-staging.vertesia.io', () => {
63
+ const client = new VertesiaClient({
64
+ site: 'api-staging.vertesia.io',
65
+ });
66
+
67
+ expect(client).toBeDefined();
68
+ expect(client.baseUrl).toBe('https://api-staging.vertesia.io');
69
+ expect(client.storeUrl).toBe('https://api-staging.vertesia.io');
70
+ });
71
+
72
+ test('Initialization with site localhost', () => {
73
+ const client = new VertesiaClient({
74
+ serverUrl: 'http://localhost:8091',
75
+ storeUrl: 'http://localhost:8092',
76
+ });
77
+
78
+ expect(client).toBeDefined();
79
+ expect(client.baseUrl).toBe('http://localhost:8091');
80
+ expect(client.storeUrl).toBe('http://localhost:8092');
81
+ });
82
+
83
+ test('Initialization with overrides', () => {
84
+ const client = new VertesiaClient({
85
+ serverUrl: 'https://studio-server-production.api.becomposable.com',
86
+ storeUrl: 'https://zeno-server-production.api.becomposable.com',
87
+ site: 'api.vertesia.io',
88
+ });
89
+
90
+ expect(client).toBeDefined();
91
+ expect(client.baseUrl).toBe('https://studio-server-production.api.becomposable.com');
92
+ expect(client.storeUrl).toBe('https://zeno-server-production.api.becomposable.com');
93
+ });
94
+ });