@vertesia/client 0.76.0 → 0.78.0-dev-9372725

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 (226) hide show
  1. package/package.json +59 -54
  2. package/src/AppsApi.ts +10 -1
  3. package/src/InteractionBase.ts +3 -3
  4. package/src/InteractionsApi.ts +19 -9
  5. package/src/RunsApi.ts +9 -2
  6. package/src/client.test.ts +2 -0
  7. package/src/client.ts +134 -56
  8. package/src/execute.ts +11 -5
  9. package/src/store/FilesApi.ts +2 -2
  10. package/src/store/ObjectsApi.ts +43 -13
  11. package/src/store/WorkflowsApi.ts +172 -4
  12. package/src/store/client.ts +8 -0
  13. package/lib/cjs/AccountApi.js +0 -85
  14. package/lib/cjs/AccountApi.js.map +0 -1
  15. package/lib/cjs/AccountsApi.js +0 -16
  16. package/lib/cjs/AccountsApi.js.map +0 -1
  17. package/lib/cjs/AnalyticsApi.js +0 -13
  18. package/lib/cjs/AnalyticsApi.js.map +0 -1
  19. package/lib/cjs/ApiKeysApi.js +0 -63
  20. package/lib/cjs/ApiKeysApi.js.map +0 -1
  21. package/lib/cjs/AppsApi.js +0 -111
  22. package/lib/cjs/AppsApi.js.map +0 -1
  23. package/lib/cjs/CommandsApi.js +0 -19
  24. package/lib/cjs/CommandsApi.js.map +0 -1
  25. package/lib/cjs/EnvironmentsApi.js +0 -58
  26. package/lib/cjs/EnvironmentsApi.js.map +0 -1
  27. package/lib/cjs/GroupsApi.js +0 -78
  28. package/lib/cjs/GroupsApi.js.map +0 -1
  29. package/lib/cjs/IamApi.js +0 -53
  30. package/lib/cjs/IamApi.js.map +0 -1
  31. package/lib/cjs/InteractionBase.js +0 -44
  32. package/lib/cjs/InteractionBase.js.map +0 -1
  33. package/lib/cjs/InteractionsApi.js +0 -209
  34. package/lib/cjs/InteractionsApi.js.map +0 -1
  35. package/lib/cjs/ProjectsApi.js +0 -48
  36. package/lib/cjs/ProjectsApi.js.map +0 -1
  37. package/lib/cjs/PromptsApi.js +0 -133
  38. package/lib/cjs/PromptsApi.js.map +0 -1
  39. package/lib/cjs/RefsApi.js +0 -14
  40. package/lib/cjs/RefsApi.js.map +0 -1
  41. package/lib/cjs/RunsApi.js +0 -105
  42. package/lib/cjs/RunsApi.js.map +0 -1
  43. package/lib/cjs/StreamSource.js +0 -17
  44. package/lib/cjs/StreamSource.js.map +0 -1
  45. package/lib/cjs/TrainingApi.js +0 -54
  46. package/lib/cjs/TrainingApi.js.map +0 -1
  47. package/lib/cjs/UsersApi.js +0 -13
  48. package/lib/cjs/UsersApi.js.map +0 -1
  49. package/lib/cjs/client.js +0 -263
  50. package/lib/cjs/client.js.map +0 -1
  51. package/lib/cjs/execute.js +0 -152
  52. package/lib/cjs/execute.js.map +0 -1
  53. package/lib/cjs/index.js +0 -21
  54. package/lib/cjs/index.js.map +0 -1
  55. package/lib/cjs/nodejs/NodeStreamSource.js +0 -45
  56. package/lib/cjs/nodejs/NodeStreamSource.js.map +0 -1
  57. package/lib/cjs/nodejs/index.js +0 -18
  58. package/lib/cjs/nodejs/index.js.map +0 -1
  59. package/lib/cjs/package.json +0 -3
  60. package/lib/cjs/store/AgentsApi.js +0 -16
  61. package/lib/cjs/store/AgentsApi.js.map +0 -1
  62. package/lib/cjs/store/AnalyzeDocApi.js +0 -56
  63. package/lib/cjs/store/AnalyzeDocApi.js.map +0 -1
  64. package/lib/cjs/store/CollectionsApi.js +0 -101
  65. package/lib/cjs/store/CollectionsApi.js.map +0 -1
  66. package/lib/cjs/store/CommandsApi.js +0 -17
  67. package/lib/cjs/store/CommandsApi.js.map +0 -1
  68. package/lib/cjs/store/EmbeddingsApi.js +0 -29
  69. package/lib/cjs/store/EmbeddingsApi.js.map +0 -1
  70. package/lib/cjs/store/FilesApi.js +0 -147
  71. package/lib/cjs/store/FilesApi.js.map +0 -1
  72. package/lib/cjs/store/ObjectsApi.js +0 -264
  73. package/lib/cjs/store/ObjectsApi.js.map +0 -1
  74. package/lib/cjs/store/TypesApi.js +0 -57
  75. package/lib/cjs/store/TypesApi.js.map +0 -1
  76. package/lib/cjs/store/WorkflowsApi.js +0 -263
  77. package/lib/cjs/store/WorkflowsApi.js.map +0 -1
  78. package/lib/cjs/store/client.js +0 -55
  79. package/lib/cjs/store/client.js.map +0 -1
  80. package/lib/cjs/store/errors.js +0 -11
  81. package/lib/cjs/store/errors.js.map +0 -1
  82. package/lib/cjs/store/index.js +0 -22
  83. package/lib/cjs/store/index.js.map +0 -1
  84. package/lib/esm/AccountApi.js +0 -82
  85. package/lib/esm/AccountApi.js.map +0 -1
  86. package/lib/esm/AccountsApi.js +0 -13
  87. package/lib/esm/AccountsApi.js.map +0 -1
  88. package/lib/esm/AnalyticsApi.js +0 -10
  89. package/lib/esm/AnalyticsApi.js.map +0 -1
  90. package/lib/esm/ApiKeysApi.js +0 -59
  91. package/lib/esm/ApiKeysApi.js.map +0 -1
  92. package/lib/esm/AppsApi.js +0 -108
  93. package/lib/esm/AppsApi.js.map +0 -1
  94. package/lib/esm/CommandsApi.js +0 -16
  95. package/lib/esm/CommandsApi.js.map +0 -1
  96. package/lib/esm/EnvironmentsApi.js +0 -55
  97. package/lib/esm/EnvironmentsApi.js.map +0 -1
  98. package/lib/esm/GroupsApi.js +0 -74
  99. package/lib/esm/GroupsApi.js.map +0 -1
  100. package/lib/esm/IamApi.js +0 -47
  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 -206
  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 -101
  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 -254
  121. package/lib/esm/client.js.map +0 -1
  122. package/lib/esm/execute.js +0 -113
  123. package/lib/esm/execute.js.map +0 -1
  124. package/lib/esm/index.js +0 -5
  125. package/lib/esm/index.js.map +0 -1
  126. package/lib/esm/nodejs/NodeStreamSource.js +0 -41
  127. package/lib/esm/nodejs/NodeStreamSource.js.map +0 -1
  128. package/lib/esm/nodejs/index.js +0 -2
  129. package/lib/esm/nodejs/index.js.map +0 -1
  130. package/lib/esm/store/AgentsApi.js +0 -12
  131. package/lib/esm/store/AgentsApi.js.map +0 -1
  132. package/lib/esm/store/AnalyzeDocApi.js +0 -52
  133. package/lib/esm/store/AnalyzeDocApi.js.map +0 -1
  134. package/lib/esm/store/CollectionsApi.js +0 -97
  135. package/lib/esm/store/CollectionsApi.js.map +0 -1
  136. package/lib/esm/store/CommandsApi.js +0 -13
  137. package/lib/esm/store/CommandsApi.js.map +0 -1
  138. package/lib/esm/store/EmbeddingsApi.js +0 -25
  139. package/lib/esm/store/EmbeddingsApi.js.map +0 -1
  140. package/lib/esm/store/FilesApi.js +0 -142
  141. package/lib/esm/store/FilesApi.js.map +0 -1
  142. package/lib/esm/store/ObjectsApi.js +0 -260
  143. package/lib/esm/store/ObjectsApi.js.map +0 -1
  144. package/lib/esm/store/TypesApi.js +0 -53
  145. package/lib/esm/store/TypesApi.js.map +0 -1
  146. package/lib/esm/store/WorkflowsApi.js +0 -257
  147. package/lib/esm/store/WorkflowsApi.js.map +0 -1
  148. package/lib/esm/store/client.js +0 -51
  149. package/lib/esm/store/client.js.map +0 -1
  150. package/lib/esm/store/errors.js +0 -7
  151. package/lib/esm/store/errors.js.map +0 -1
  152. package/lib/esm/store/index.js +0 -6
  153. package/lib/esm/store/index.js.map +0 -1
  154. package/lib/tsconfig.tsbuildinfo +0 -1
  155. package/lib/types/AccountApi.d.ts +0 -59
  156. package/lib/types/AccountApi.d.ts.map +0 -1
  157. package/lib/types/AccountsApi.d.ts +0 -7
  158. package/lib/types/AccountsApi.d.ts.map +0 -1
  159. package/lib/types/AnalyticsApi.d.ts +0 -6
  160. package/lib/types/AnalyticsApi.d.ts.map +0 -1
  161. package/lib/types/ApiKeysApi.d.ts +0 -42
  162. package/lib/types/ApiKeysApi.d.ts.map +0 -1
  163. package/lib/types/AppsApi.d.ts +0 -59
  164. package/lib/types/AppsApi.d.ts.map +0 -1
  165. package/lib/types/CommandsApi.d.ts +0 -10
  166. package/lib/types/CommandsApi.d.ts.map +0 -1
  167. package/lib/types/EnvironmentsApi.d.ts +0 -30
  168. package/lib/types/EnvironmentsApi.d.ts.map +0 -1
  169. package/lib/types/GroupsApi.d.ts +0 -65
  170. package/lib/types/GroupsApi.d.ts.map +0 -1
  171. package/lib/types/IamApi.d.ts +0 -41
  172. package/lib/types/IamApi.d.ts.map +0 -1
  173. package/lib/types/InteractionBase.d.ts +0 -22
  174. package/lib/types/InteractionBase.d.ts.map +0 -1
  175. package/lib/types/InteractionsApi.d.ts +0 -150
  176. package/lib/types/InteractionsApi.d.ts.map +0 -1
  177. package/lib/types/ProjectsApi.d.ts +0 -17
  178. package/lib/types/ProjectsApi.d.ts.map +0 -1
  179. package/lib/types/PromptsApi.d.ts +0 -106
  180. package/lib/types/PromptsApi.d.ts.map +0 -1
  181. package/lib/types/RefsApi.d.ts +0 -6
  182. package/lib/types/RefsApi.d.ts.map +0 -1
  183. package/lib/types/RunsApi.d.ts +0 -77
  184. package/lib/types/RunsApi.d.ts.map +0 -1
  185. package/lib/types/StreamSource.d.ts +0 -7
  186. package/lib/types/StreamSource.d.ts.map +0 -1
  187. package/lib/types/TrainingApi.d.ts +0 -27
  188. package/lib/types/TrainingApi.d.ts.map +0 -1
  189. package/lib/types/UsersApi.d.ts +0 -6
  190. package/lib/types/UsersApi.d.ts.map +0 -1
  191. package/lib/types/client.d.ts +0 -114
  192. package/lib/types/client.d.ts.map +0 -1
  193. package/lib/types/execute.d.ts +0 -36
  194. package/lib/types/execute.d.ts.map +0 -1
  195. package/lib/types/index.d.ts +0 -8
  196. package/lib/types/index.d.ts.map +0 -1
  197. package/lib/types/nodejs/NodeStreamSource.d.ts +0 -9
  198. package/lib/types/nodejs/NodeStreamSource.d.ts.map +0 -1
  199. package/lib/types/nodejs/index.d.ts +0 -1
  200. package/lib/types/nodejs/index.d.ts.map +0 -1
  201. package/lib/types/store/AgentsApi.d.ts +0 -6
  202. package/lib/types/store/AgentsApi.d.ts.map +0 -1
  203. package/lib/types/store/AnalyzeDocApi.d.ts +0 -17
  204. package/lib/types/store/AnalyzeDocApi.d.ts.map +0 -1
  205. package/lib/types/store/CollectionsApi.d.ts +0 -66
  206. package/lib/types/store/CollectionsApi.d.ts.map +0 -1
  207. package/lib/types/store/CommandsApi.d.ts +0 -10
  208. package/lib/types/store/CommandsApi.d.ts.map +0 -1
  209. package/lib/types/store/EmbeddingsApi.d.ts +0 -12
  210. package/lib/types/store/EmbeddingsApi.d.ts.map +0 -1
  211. package/lib/types/store/FilesApi.d.ts +0 -47
  212. package/lib/types/store/FilesApi.d.ts.map +0 -1
  213. package/lib/types/store/ObjectsApi.d.ts +0 -118
  214. package/lib/types/store/ObjectsApi.d.ts.map +0 -1
  215. package/lib/types/store/TypesApi.d.ts +0 -23
  216. package/lib/types/store/TypesApi.d.ts.map +0 -1
  217. package/lib/types/store/WorkflowsApi.d.ts +0 -50
  218. package/lib/types/store/WorkflowsApi.d.ts.map +0 -1
  219. package/lib/types/store/client.d.ts +0 -29
  220. package/lib/types/store/client.d.ts.map +0 -1
  221. package/lib/types/store/errors.d.ts +0 -4
  222. package/lib/types/store/errors.d.ts.map +0 -1
  223. package/lib/types/store/index.d.ts +0 -5
  224. package/lib/types/store/index.d.ts.map +0 -1
  225. package/lib/vertesia-client.js +0 -2
  226. package/lib/vertesia-client.js.map +0 -1
package/package.json CHANGED
@@ -1,57 +1,62 @@
1
1
  {
2
- "name": "@vertesia/client",
3
- "version": "0.76.0",
4
- "type": "module",
5
- "types": "./lib/types/index.d.ts",
6
- "files": [
7
- "lib",
8
- "src",
9
- "tsconfig.dist.json"
10
- ],
11
- "license": "Apache-2.0",
12
- "devDependencies": {
13
- "@rollup/plugin-commonjs": "^28.0.3",
14
- "@rollup/plugin-node-resolve": "^16.0.1",
15
- "@rollup/plugin-typescript": "^12.1.2",
16
- "@types/node": "^22.13.5",
17
- "rollup": "^4.40.2",
18
- "rollup-plugin-terser": "^7.0.2",
19
- "ts-dual-module": "^0.6.3",
20
- "typescript": "^5.0.2",
21
- "vitest": "^3.0.9"
22
- },
23
- "dependencies": {
24
- "eventsource": "^3.0.6",
25
- "@llumiverse/common": "0.22.0",
26
- "@vertesia/common": "0.76.0",
27
- "@vertesia/api-fetch-client": "0.76.0"
28
- },
29
- "ts_dual_module": {
30
- "outDir": "lib"
31
- },
32
- "exports": {
33
- ".": {
34
- "types": "./lib/types/index.d.ts",
35
- "import": "./lib/esm/index.js",
36
- "require": "./lib/cjs/index.js"
2
+ "name": "@vertesia/client",
3
+ "version": "0.78.0-dev-9372725",
4
+ "type": "module",
5
+ "types": "./lib/types/index.d.ts",
6
+ "files": [
7
+ "lib",
8
+ "src",
9
+ "tsconfig.dist.json"
10
+ ],
11
+ "license": "Apache-2.0",
12
+ "scripts": {
13
+ "eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
14
+ "build": "pnpm exec tsmod build && pnpm exec rollup -c",
15
+ "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo",
16
+ "test": "vitest run"
37
17
  },
38
- "./node": {
39
- "types": "./lib/types/nodejs/index.d.ts",
40
- "import": "./lib/esm/nodejs/index.js",
41
- "require": "./lib/cjs/nodejs/index.js"
42
- }
43
- },
44
- "typesVersions": {
45
- "*": {
46
- "node": [
47
- "./lib/types/nodejs/index.d.ts"
48
- ]
18
+ "devDependencies": {
19
+ "@rollup/plugin-commonjs": "^28.0.3",
20
+ "@rollup/plugin-node-resolve": "^16.0.1",
21
+ "@rollup/plugin-typescript": "^12.1.2",
22
+ "@types/node": "^22.13.5",
23
+ "rollup": "^4.40.2",
24
+ "rollup-plugin-terser": "^7.0.2",
25
+ "ts-dual-module": "^0.6.3",
26
+ "typescript": "^5.0.2",
27
+ "vitest": "^3.0.9"
28
+ },
29
+ "dependencies": {
30
+ "@llumiverse/common": "workspace:*",
31
+ "@vertesia/api-fetch-client": "workspace:*",
32
+ "@vertesia/common": "workspace:*",
33
+ "eventsource": "^3.0.6"
34
+ },
35
+ "ts_dual_module": {
36
+ "outDir": "lib"
37
+ },
38
+ "exports": {
39
+ ".": {
40
+ "types": "./lib/types/index.d.ts",
41
+ "import": "./lib/esm/index.js",
42
+ "require": "./lib/cjs/index.js"
43
+ },
44
+ "./node": {
45
+ "types": "./lib/types/nodejs/index.d.ts",
46
+ "import": "./lib/esm/nodejs/index.js",
47
+ "require": "./lib/cjs/nodejs/index.js"
48
+ }
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "https://github.com/vertesia/composableai.git",
53
+ "directory": "packages/client"
54
+ },
55
+ "typesVersions": {
56
+ "*": {
57
+ "node": [
58
+ "./lib/types/nodejs/index.d.ts"
59
+ ]
60
+ }
49
61
  }
50
- },
51
- "scripts": {
52
- "eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
53
- "build": "pnpm exec tsmod build && pnpm exec rollup -c",
54
- "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo",
55
- "test": "vitest run"
56
- }
57
- }
62
+ }
package/src/AppsApi.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ApiTopic, ClientBase, ServerError } from "@vertesia/api-fetch-client";
2
- import type { AppInstallation, AppInstallationKind, AppInstallationPayload, AppInstallationWithManifest, AppManifest, AppManifestData, ProjectRef, RequireAtLeastOne } from "@vertesia/common";
2
+ import type { AppInstallation, AppInstallationKind, AppInstallationPayload, AppInstallationWithManifest, AppManifest, AppManifestData, AppToolCollection, ProjectRef, RequireAtLeastOne } from "@vertesia/common";
3
3
 
4
4
  export interface OrphanedAppInstallation extends Omit<AppInstallation, 'manifest'> {
5
5
  manifest: null,
@@ -19,6 +19,15 @@ export default class AppsApi extends ApiTopic {
19
19
  return this.put(`/${id}`, { payload: manifest });
20
20
  }
21
21
 
22
+ /**
23
+ * Get the list if tools provided by the given app.
24
+ * @param appId
25
+ * @returns
26
+ */
27
+ listAppInstallationTools(appInstallId: string): Promise<AppToolCollection[]> {
28
+ return this.get(`/installations/${appInstallId}/tools`)
29
+ }
30
+
22
31
  /**
23
32
  * @param ids - ids to filter by
24
33
  * @returns the app manifests but without the agent.tool property which can be big.
@@ -2,7 +2,7 @@ import { ExecutionRun, InteractionUpdatePayload, InteractionExecutionPayload } f
2
2
  import { VertesiaClient, VertesiaClientProps } from "./client.js";
3
3
  import { executeInteraction } from "./execute.js";
4
4
 
5
- export class InteractionBase<P = any, R = any> {
5
+ export class InteractionBase<P = any> {
6
6
  client: VertesiaClient;
7
7
 
8
8
  constructor(public id: string, clientOrOpts: VertesiaClient | VertesiaClientProps) {
@@ -38,7 +38,7 @@ export class InteractionBase<P = any, R = any> {
38
38
  * @returns the resolved execution run as Promise<ExecutionRun>
39
39
  */
40
40
  async execute(payload: InteractionExecutionPayload = {},
41
- onChunk?: (chunk: string) => void): Promise<ExecutionRun<P, R>> {
42
- return executeInteraction<P, R>(this.client, this.id, payload, onChunk);
41
+ onChunk?: (chunk: string) => void): Promise<ExecutionRun<P>> {
42
+ return executeInteraction<P>(this.client, this.id, payload, onChunk);
43
43
  }
44
44
  }
@@ -1,7 +1,8 @@
1
1
  import { ApiTopic, ClientBase, ServerError } from "@vertesia/api-fetch-client";
2
- import { AsyncExecutionPayload, ComputeInteractionFacetPayload, ExecutionRun, GenerateInteractionPayload, GenerateTestDataPayload, ImprovePromptPayload, Interaction, InteractionCreatePayload, InteractionEndpoint, InteractionEndpointQuery, InteractionExecutionPayload, InteractionExecutionResult, InteractionForkPayload, InteractionPublishPayload, InteractionRef, InteractionRefWithSchema, InteractionSearchPayload, InteractionSearchQuery, InteractionUpdatePayload, InteractionsExportPayload } from "@vertesia/common";
2
+ import { AsyncExecutionPayload, ComputeInteractionFacetPayload, ExecutionRun, GenerateInteractionPayload, GenerateTestDataPayload, ImprovePromptPayload, Interaction, InteractionCreatePayload, InteractionEndpoint, InteractionEndpointQuery, InteractionExecutionPayload, InteractionExecutionResult, InteractionForkPayload, InteractionPublishPayload, InteractionRef, InteractionRefWithSchema, InteractionSearchPayload, InteractionSearchQuery, InteractionUpdatePayload, InteractionsExportPayload, RateLimitRequestPayload, RateLimitRequestResponse } from "@vertesia/common";
3
+ import { CompletionResult } from "@llumiverse/common";
3
4
  import { VertesiaClient } from "./client.js";
4
- import { executeInteraction, executeInteractionAsync, executeInteractionByName } from "./execute.js";
5
+ import { checkRateLimit, executeInteraction, executeInteractionAsync, executeInteractionByName } from "./execute.js";
5
6
 
6
7
  export interface ComputeInteractionFacetsResponse {
7
8
  tags?: { _id: string, count: number }[];
@@ -132,9 +133,9 @@ export default class InteractionsApi extends ApiTopic {
132
133
  * @throws 500 if interaction execution fails
133
134
  * @throws 500 if interaction execution times out
134
135
  **/
135
- execute<P = any, R = any>(id: string, payload: InteractionExecutionPayload = {},
136
- onChunk?: (chunk: string) => void): Promise<ExecutionRun<P, R>> {
137
- return executeInteraction(this.client as VertesiaClient, id, payload, onChunk).catch(err => {
136
+ execute<P = any>(id: string, payload: InteractionExecutionPayload = {},
137
+ onChunk?: (chunk: string) => void): Promise<ExecutionRun<P>> {
138
+ return executeInteraction<P>(this.client as VertesiaClient, id, payload, onChunk).catch(err => {
138
139
  if (err instanceof ServerError && err.payload?.id) {
139
140
  throw err.updateDetails({ run_id: err.payload.id });
140
141
  } else {
@@ -158,9 +159,9 @@ export default class InteractionsApi extends ApiTopic {
158
159
  * @param onChunk
159
160
  * @returns
160
161
  */
161
- executeByName<P = any, R = any>(nameWithTag: string, payload: InteractionExecutionPayload = {},
162
- onChunk?: (chunk: string) => void): Promise<InteractionExecutionResult<P, R>> {
163
- return executeInteractionByName(this.client as VertesiaClient, nameWithTag, payload, onChunk).catch(err => {
162
+ executeByName<P = any>(nameWithTag: string, payload: InteractionExecutionPayload = {},
163
+ onChunk?: (chunk: string) => void): Promise<InteractionExecutionResult<P>> {
164
+ return executeInteractionByName<P>(this.client as VertesiaClient, nameWithTag, payload, onChunk).catch(err => {
164
165
  if (err instanceof ServerError && err.payload?.id) {
165
166
  throw err.updateDetails({ run_id: err.payload.id });
166
167
  } else {
@@ -214,7 +215,7 @@ export default class InteractionsApi extends ApiTopic {
214
215
  /**
215
216
  * Suggest Improvement for a prompt
216
217
  */
217
- suggestImprovements(id: string, payload: ImprovePromptPayload): Promise<{ result: string; }> {
218
+ suggestImprovements(id: string, payload: ImprovePromptPayload): Promise<{ result: CompletionResult[]; }> {
218
219
  return this.post(`${id}/suggest-prompt-improvements`, {
219
220
  payload
220
221
  });
@@ -238,4 +239,13 @@ export default class InteractionsApi extends ApiTopic {
238
239
  return this.get(`/${id}/forks`);
239
240
  }
240
241
 
242
+ /**
243
+ * Request a time slot to execute an interaction with a given environment / model
244
+ * @param payload RateLimitRequestPayload
245
+ * @returns RateLimitRequestResponse with delay_ms
246
+ */
247
+ requestSlot(payload: RateLimitRequestPayload): Promise<RateLimitRequestResponse> {
248
+ return checkRateLimit(this.client as VertesiaClient, payload);
249
+ }
250
+
241
251
  }
package/src/RunsApi.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ExecutionResponse } from "@llumiverse/common";
1
2
  import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
3
  import {
3
4
  CheckpointConversationPayload,
@@ -5,6 +6,7 @@ import {
5
6
  ExecutionRun,
6
7
  ExecutionRunRef,
7
8
  FindPayload,
9
+ PopulatedExecutionRun,
8
10
  RunCreatePayload,
9
11
  RunListingFilters,
10
12
  RunListingQueryOptions,
@@ -13,7 +15,6 @@ import {
13
15
  UserMessagePayload,
14
16
  } from "@vertesia/common";
15
17
  import { VertesiaClient } from "./client.js";
16
- import type { ExecutionResponse } from "@llumiverse/common";
17
18
 
18
19
  export interface FilterOption {
19
20
  id: string;
@@ -63,10 +64,16 @@ export class RunsApi extends ApiTopic {
63
64
  * @param id
64
65
  * @returns InteractionResult
65
66
  **/
66
- retrieve<P = any, R = any>(id: string): Promise<ExecutionRun<P, R>> {
67
+ retrieve<P = any>(id: string): Promise<ExecutionRun<P>> {
67
68
  return this.get("/" + id);
68
69
  }
69
70
 
71
+ retrievePopulated<P = any>(id: string): Promise<PopulatedExecutionRun<P>> {
72
+ return this.get("/" + id, {
73
+ query: { populate: "true" },
74
+ });
75
+ }
76
+
70
77
  /**
71
78
  * Get filter options for a field
72
79
  * return FilterOption[]
@@ -6,6 +6,7 @@ describe('Test Vertesia Client', () => {
6
6
  const client = new VertesiaClient({
7
7
  serverUrl: 'https://api.vertesia.io',
8
8
  storeUrl: 'https://api.vertesia.io',
9
+ tokenServerUrl: 'https://sts.vertesia.io',
9
10
  apikey: '1234',
10
11
  });
11
12
  expect(client).toBeDefined();
@@ -73,6 +74,7 @@ describe('Test Vertesia Client', () => {
73
74
  const client = new VertesiaClient({
74
75
  serverUrl: 'http://localhost:8091',
75
76
  storeUrl: 'http://localhost:8092',
77
+ tokenServerUrl: 'http://localhost:8093',
76
78
  });
77
79
 
78
80
  expect(client).toBeDefined();
package/src/client.ts CHANGED
@@ -35,18 +35,21 @@ export type VertesiaClientProps = {
35
35
  * @default api.vertesia.io
36
36
  * @since 0.52.0
37
37
  */
38
- site?: 'api.vertesia.io' | 'api-preview.vertesia.io' | 'api-staging.vertesia.io';
38
+ site?:
39
+ | "api.vertesia.io"
40
+ | "api-preview.vertesia.io"
41
+ | "api-staging.vertesia.io";
39
42
  serverUrl?: string;
40
43
  storeUrl?: string;
44
+ tokenServerUrl?: string;
41
45
  apikey?: string;
42
46
  projectId?: string;
43
47
  sessionTags?: string | string[];
44
48
  onRequest?: (request: Request) => void;
45
49
  onResponse?: (response: Response) => void;
46
- }
50
+ };
47
51
 
48
52
  export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
49
-
50
53
  /**
51
54
  * The JWT token linked to the API KEY (sk or pk)
52
55
  */
@@ -62,11 +65,15 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
62
65
  */
63
66
  sessionTags?: string | string[];
64
67
 
68
+ /**
69
+ * tokenServerUrl
70
+ */
71
+ tokenServerUrl: string;
65
72
 
66
73
  /**
67
- * Create a client from the given token.
74
+ * Create a client from the given token.
68
75
  * If you already have the decoded token you can pass it as the second argument to avoid decodinf it again.
69
- *
76
+ *
70
77
  * @param token the raw JWT token
71
78
  * @param payload the decoded JWT token as an AuthTokenPayload - optional
72
79
  */
@@ -74,21 +81,21 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
74
81
  if (!payload) {
75
82
  payload = decodeJWT(token);
76
83
  }
77
- const endpoints = decodeEndpoints(payload!.endpoints);
84
+
85
+ const endpoints = decodeEndpoints(payload.endpoints);
78
86
  return await new VertesiaClient({
79
87
  serverUrl: endpoints.studio,
80
- storeUrl: endpoints.store
88
+ storeUrl: endpoints.store,
89
+ tokenServerUrl: payload.iss,
81
90
  }).withApiKey(token);
82
91
  }
83
92
 
84
- static decodeEndpoints() {
85
-
86
- }
93
+ static decodeEndpoints() {}
87
94
 
88
95
  constructor(
89
96
  opts: VertesiaClientProps = {
90
- site: 'api.vertesia.io',
91
- }
97
+ site: "api.vertesia.io",
98
+ },
92
99
  ) {
93
100
  let studioServerUrl: string;
94
101
  let zenoServerUrl: string;
@@ -98,7 +105,9 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
98
105
  } else if (opts.site) {
99
106
  studioServerUrl = `https://${opts.site}`;
100
107
  } else {
101
- throw new Error("Parameter 'site' or 'serverUrl' is required for VertesiaClient");
108
+ throw new Error(
109
+ "Parameter 'site' or 'serverUrl' is required for VertesiaClient",
110
+ );
102
111
  }
103
112
 
104
113
  if (opts.storeUrl) {
@@ -106,25 +115,67 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
106
115
  } else if (opts.site) {
107
116
  zenoServerUrl = `https://${opts.site}`;
108
117
  } else {
109
- throw new Error("Parameter 'site' or 'storeUrl' is required for VertesiaClient");
118
+ throw new Error(
119
+ "Parameter 'site' or 'storeUrl' is required for VertesiaClient",
120
+ );
110
121
  }
111
122
 
112
123
  super(studioServerUrl);
113
124
 
125
+ if (opts.tokenServerUrl) {
126
+ this.tokenServerUrl = opts.tokenServerUrl;
127
+ } else if (opts.site) {
128
+ this.tokenServerUrl = `https://${opts.site.replace(/^api/, "sts")}`;
129
+ } else if (opts.serverUrl || opts.storeUrl) {
130
+ // Determine STS URL based on environment in serverUrl or storeUrl
131
+ const urlToCheck = opts.serverUrl || opts.storeUrl || "";
132
+ try {
133
+ const url = new URL(urlToCheck);
134
+ // Check for environment patterns
135
+ if (url.hostname.includes("-production.")) {
136
+ // zeno-server-production.api.vertesia.io -> sts.vertesia.io
137
+ this.tokenServerUrl = "https://sts.vertesia.io";
138
+ } else if (url.hostname.includes("-preview.")) {
139
+ // zeno-server-preview.api.vertesia.io -> sts-preview.vertesia.io
140
+ this.tokenServerUrl = "https://sts-preview.vertesia.io";
141
+ } else if (url.hostname === "api.vertesia.io") {
142
+ // api.vertesia.io -> sts.vertesia.io
143
+ this.tokenServerUrl = "https://sts.vertesia.io";
144
+ } else if (url.hostname === "api-preview.vertesia.io") {
145
+ // api-preview.vertesia.io -> sts-preview.vertesia.io
146
+ this.tokenServerUrl = "https://sts-preview.vertesia.io";
147
+ } else if (url.hostname === "api-staging.vertesia.io") {
148
+ // api-staging.vertesia.io -> sts-staging.vertesia.io
149
+ this.tokenServerUrl = "https://sts-staging.vertesia.io";
150
+ } else if (url.hostname.startsWith("api")) {
151
+ // Generic api.* pattern replacement
152
+ url.hostname = url.hostname.replace(/^api/, "sts");
153
+ this.tokenServerUrl = url.toString();
154
+ } else {
155
+ // Default to staging for everything else
156
+ this.tokenServerUrl = "https://sts-staging.vertesia.io";
157
+ }
158
+ } catch (e) {
159
+ // Default to staging if URL parsing fails
160
+ this.tokenServerUrl = "https://sts-staging.vertesia.io";
161
+ }
162
+ } else {
163
+ // Default to staging if no URL provided
164
+ this.tokenServerUrl = "https://sts-staging.vertesia.io";
165
+ }
166
+
114
167
  this.store = new ZenoClient({
115
168
  serverUrl: zenoServerUrl,
169
+ tokenServerUrl: this.tokenServerUrl,
116
170
  apikey: opts.apikey,
117
171
  onRequest: opts.onRequest,
118
- onResponse: opts.onResponse
172
+ onResponse: opts.onResponse,
119
173
  });
120
174
 
121
175
  if (opts.apikey) {
122
176
  this.withApiKey(opts.apikey);
123
177
  }
124
- //TODO: this is no more used, remove in next major version
125
- if (opts.projectId) {
126
- this.headers["x-project-id"] = opts.projectId;
127
- }
178
+
128
179
  this.onRequest = opts.onRequest;
129
180
  this.onResponse = opts.onResponse;
130
181
  this.sessionTags = opts.sessionTags;
@@ -142,25 +193,28 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
142
193
 
143
194
  async withApiKey(apiKey: string | null) {
144
195
  return this.withAuthCallback(
145
- apiKey ? async () => {
146
- if (!isApiKey(apiKey)) {
147
- return `Bearer ${apiKey}`
148
- }
149
-
150
- if (isTokenExpired(this._jwt)) {
151
- const jwt = await this.getAuthToken(apiKey);
152
- this._jwt = jwt.token;
153
- }
154
- return `Bearer ${this._jwt}`
155
- } : undefined
196
+ apiKey
197
+ ? async () => {
198
+ if (!isApiKey(apiKey)) {
199
+ return `Bearer ${apiKey}`;
200
+ }
201
+
202
+ if (isTokenExpired(this._jwt)) {
203
+ const jwt = await this.getAuthToken(apiKey);
204
+ this._jwt = jwt.token;
205
+ }
206
+ return `Bearer ${this._jwt}`;
207
+ }
208
+ : undefined,
156
209
  );
157
210
  }
158
211
 
159
212
  async getRawJWT() {
160
213
  if (!this._jwt && this._auth) {
161
214
  const auth = await this._auth();
162
- if (!this._jwt) { // the _jwt may be set by the auth callback
163
- this._jwt = auth.trim().split(' ')[1]; // remove Bearer prefix
215
+ if (!this._jwt) {
216
+ // the _jwt may be set by the auth callback
217
+ this._jwt = auth.trim().split(" ")[1]; // remove Bearer prefix
164
218
  }
165
219
  }
166
220
  return this._jwt || null;
@@ -210,21 +264,36 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
210
264
  return this.store.baseUrl;
211
265
  }
212
266
 
213
-
214
267
  /**
215
268
  *
216
- * Generate a token for use with other Composable's services
269
+ * Generate a token for use with other Vertesia's services
217
270
  *
218
- * @param accountId: selected account to generate the token for
219
271
  * @returns AuthTokenResponse
220
272
  */
221
- async getAuthToken(token?: string, accountId?: string): Promise<AuthTokenResponse> {
222
- const query = {
223
- accountId,
224
- token
225
- };
273
+ async getAuthToken(token?: string): Promise<AuthTokenResponse> {
274
+ return fetch(`${this.tokenServerUrl}/token/issue`, {
275
+ method: "POST",
276
+ headers: {
277
+ "Content-Type": "application/json",
278
+ Authorization: `Bearer ${token}`,
279
+ },
280
+ })
281
+ .then((response) => response.json())
282
+ .then((data) => data as AuthTokenResponse)
283
+ .catch((error) => {
284
+ console.error(
285
+ `Error fetching token from ${this.tokenServerUrl}:`,
286
+ { error },
287
+ );
288
+ throw error;
289
+ });
290
+ }
226
291
 
227
- return this.get('/auth/token', { query: query, headers: { "authorization": undefined } as any });
292
+ get initialHeaders() {
293
+ return {
294
+ ...super.initialHeaders,
295
+ 'X-Api-Version': '20250925' // YYYYMMDD, client versioning for API endpoints. Increment manually for breaking changes
296
+ }
228
297
  }
229
298
 
230
299
  projects = new ProjectsApi(this);
@@ -245,7 +314,7 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
245
314
  }
246
315
 
247
316
  function isApiKey(apiKey: string) {
248
- return (apiKey.startsWith('pk-') || apiKey.startsWith('sk-'));
317
+ return apiKey.startsWith("pk-") || apiKey.startsWith("sk-");
249
318
  }
250
319
 
251
320
  function isTokenExpired(token: string | null) {
@@ -256,38 +325,45 @@ function isTokenExpired(token: string | null) {
256
325
  const decoded = decodeJWT(token);
257
326
  const exp = decoded.exp;
258
327
  const currentTime = Date.now();
259
- return (currentTime <= exp * 1000 - EXPIRATION_THRESHOLD);
328
+ return currentTime <= exp * 1000 - EXPIRATION_THRESHOLD;
260
329
  }
261
330
 
262
331
  export function decodeJWT(jwt: string): AuthTokenPayload {
263
- const payloadBase64 = jwt.split('.')[1];
332
+ const payloadBase64 = jwt.split(".")[1];
264
333
  const decodedJson = base64UrlDecode(payloadBase64);
265
- return JSON.parse(decodedJson)
334
+ return JSON.parse(decodedJson);
266
335
  }
267
336
 
268
337
  function base64UrlDecode(input: string): string {
269
338
  // Convert base64url to base64
270
- const base64 = input.replace(/-/g, '+').replace(/_/g, '/')
339
+ const base64 = input
340
+ .replace(/-/g, "+")
341
+ .replace(/_/g, "/")
271
342
  // Pad with '=' to make length a multiple of 4
272
- .padEnd(Math.ceil(input.length / 4) * 4, '=');
343
+ .padEnd(Math.ceil(input.length / 4) * 4, "=");
273
344
 
274
- if (typeof Buffer !== 'undefined') {
345
+ if (typeof Buffer !== "undefined") {
275
346
  // Node.js
276
- return Buffer.from(base64, 'base64').toString('utf-8');
277
- } else if (typeof atob !== 'undefined' && typeof TextDecoder !== 'undefined') {
347
+ return Buffer.from(base64, "base64").toString("utf-8");
348
+ } else if (
349
+ typeof atob !== "undefined" &&
350
+ typeof TextDecoder !== "undefined"
351
+ ) {
278
352
  // Browser
279
353
  const binary = atob(base64);
280
- const bytes = Uint8Array.from(binary, c => c.charCodeAt(0));
354
+ const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
281
355
  // decode to utf8
282
356
  return new TextDecoder().decode(bytes);
283
357
  } else {
284
- throw new Error('No base64 decoder available');
358
+ throw new Error("No base64 decoder available");
285
359
  }
286
360
  }
287
361
 
288
- export function decodeEndpoints(endpoints: string | Record<string, string> | undefined): Record<string, string> {
362
+ export function decodeEndpoints(
363
+ endpoints: string | Record<string, string> | undefined,
364
+ ): Record<string, string> {
289
365
  if (!endpoints) {
290
- return getEndpointsFromDomain("api.vertesia.io")
366
+ return getEndpointsFromDomain("api.vertesia.io");
291
367
  }
292
368
  if (typeof endpoints === "string") {
293
369
  return getEndpointsFromDomain(endpoints);
@@ -301,12 +377,14 @@ function getEndpointsFromDomain(domain: string) {
301
377
  return {
302
378
  studio: `http://localhost:8091`,
303
379
  store: `http://localhost:8092`,
304
- }
380
+ token: process.env.STS_URL ?? "https://sts-staging.vertesia.io",
381
+ };
305
382
  } else {
306
383
  const url = `https://${domain}`;
307
384
  return {
308
385
  studio: url,
309
386
  store: url,
310
- }
387
+ token: url.replace("api", "sts"),
388
+ };
311
389
  }
312
390
  }
package/src/execute.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AsyncExecutionPayload, ExecutionRunStatus, InteractionExecutionPayload, InteractionExecutionResult, NamedInteractionExecutionPayload } from '@vertesia/common';
1
+ import { AsyncExecutionPayload, ExecutionRunStatus, InteractionExecutionPayload, InteractionExecutionResult, NamedInteractionExecutionPayload, RateLimitRequestPayload, RateLimitRequestResponse } from '@vertesia/common';
2
2
  import { VertesiaClient } from './client.js';
3
3
 
4
4
  export async function EventSourceProvider(): Promise<typeof EventSource> {
@@ -19,10 +19,10 @@ export async function EventSourceProvider(): Promise<typeof EventSource> {
19
19
  * @param payload InteractionExecutionPayload
20
20
  * @param onChunk callback to be called when the next chunk of the response is available
21
21
  */
22
- export async function executeInteraction<P = any, R = any>(client: VertesiaClient,
22
+ export async function executeInteraction<P = any>(client: VertesiaClient,
23
23
  interactionId: string,
24
24
  payload: InteractionExecutionPayload = {},
25
- onChunk?: (chunk: string) => void): Promise<InteractionExecutionResult<P, R>> {
25
+ onChunk?: (chunk: string) => void): Promise<InteractionExecutionResult<P>> {
26
26
  const stream = !!onChunk;
27
27
  const response = await client.runs.create({
28
28
  ...payload, interaction: interactionId, stream
@@ -52,10 +52,10 @@ export async function executeInteraction<P = any, R = any>(client: VertesiaClien
52
52
  * @param onChunk
53
53
  * @returns
54
54
  */
55
- export async function executeInteractionByName<P = any, R = any>(client: VertesiaClient,
55
+ export async function executeInteractionByName<P = any>(client: VertesiaClient,
56
56
  interaction: string,
57
57
  payload: InteractionExecutionPayload = {},
58
- onChunk?: (chunk: string) => void): Promise<InteractionExecutionResult<P, R>> {
58
+ onChunk?: (chunk: string) => void): Promise<InteractionExecutionResult<P>> {
59
59
  const stream = !!onChunk;
60
60
  const response = await client.post('/api/v1/execute', {
61
61
  payload: {
@@ -117,4 +117,10 @@ export async function executeInteractionAsync(client: VertesiaClient, payload: A
117
117
  return await client.post('/api/v1/execute/async', {
118
118
  payload,
119
119
  });
120
+ }
121
+
122
+ export async function checkRateLimit(client: VertesiaClient, payload: RateLimitRequestPayload): Promise<RateLimitRequestResponse> {
123
+ return await client.post('/api/v1/execute/rate-limit/request', {
124
+ payload
125
+ });
120
126
  }
@@ -120,9 +120,9 @@ export class FilesApi extends ApiTopic {
120
120
  if (res.ok) {
121
121
  return res;
122
122
  } else if (res.status === 404) {
123
- throw new Error(`File ${location} not found`); //TODO: type fetch error better with a fetch error class
123
+ throw new Error(`File at ${url} not found`); //TODO: type fetch error better with a fetch error class
124
124
  } else if (res.status === 403) {
125
- throw new Error(`File ${location} is forbidden`);
125
+ throw new Error(`File at ${url} is forbidden`);
126
126
  } else {
127
127
  console.log(res);
128
128
  throw new Error(