@vertesia/client 1.0.0-dev.20260305.083323Z → 1.0.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 (113) hide show
  1. package/lib/cjs/InteractionBase.js +3 -3
  2. package/lib/cjs/InteractionBase.js.map +1 -1
  3. package/lib/cjs/InteractionsApi.js.map +1 -1
  4. package/lib/cjs/MCPOAuthApi.js +14 -7
  5. package/lib/cjs/MCPOAuthApi.js.map +1 -1
  6. package/lib/cjs/OAuthAppsApi.js +72 -0
  7. package/lib/cjs/OAuthAppsApi.js.map +1 -0
  8. package/lib/cjs/PromptsApi.js +2 -0
  9. package/lib/cjs/PromptsApi.js.map +1 -1
  10. package/lib/cjs/RunsApi.js +15 -0
  11. package/lib/cjs/RunsApi.js.map +1 -1
  12. package/lib/cjs/client.js +10 -0
  13. package/lib/cjs/client.js.map +1 -1
  14. package/lib/cjs/execute.js +38 -36
  15. package/lib/cjs/execute.js.map +1 -1
  16. package/lib/cjs/store/AgentsApi.js +639 -0
  17. package/lib/cjs/store/AgentsApi.js.map +1 -0
  18. package/lib/cjs/store/FilesApi.js +49 -2
  19. package/lib/cjs/store/FilesApi.js.map +1 -1
  20. package/lib/cjs/store/IndexingApi.js +47 -10
  21. package/lib/cjs/store/IndexingApi.js.map +1 -1
  22. package/lib/cjs/store/ObjectsApi.js +28 -5
  23. package/lib/cjs/store/ObjectsApi.js.map +1 -1
  24. package/lib/cjs/store/WorkflowsApi.js +234 -263
  25. package/lib/cjs/store/WorkflowsApi.js.map +1 -1
  26. package/lib/cjs/store/client.js +2 -0
  27. package/lib/cjs/store/client.js.map +1 -1
  28. package/lib/cjs/store/index.js +1 -0
  29. package/lib/cjs/store/index.js.map +1 -1
  30. package/lib/cjs/store/version.js +1 -1
  31. package/lib/esm/InteractionBase.js +3 -3
  32. package/lib/esm/InteractionBase.js.map +1 -1
  33. package/lib/esm/InteractionsApi.js.map +1 -1
  34. package/lib/esm/MCPOAuthApi.js +14 -7
  35. package/lib/esm/MCPOAuthApi.js.map +1 -1
  36. package/lib/esm/OAuthAppsApi.js +69 -0
  37. package/lib/esm/OAuthAppsApi.js.map +1 -0
  38. package/lib/esm/PromptsApi.js +2 -0
  39. package/lib/esm/PromptsApi.js.map +1 -1
  40. package/lib/esm/RunsApi.js +15 -0
  41. package/lib/esm/RunsApi.js.map +1 -1
  42. package/lib/esm/client.js +10 -0
  43. package/lib/esm/client.js.map +1 -1
  44. package/lib/esm/execute.js +38 -36
  45. package/lib/esm/execute.js.map +1 -1
  46. package/lib/esm/store/AgentsApi.js +635 -0
  47. package/lib/esm/store/AgentsApi.js.map +1 -0
  48. package/lib/esm/store/FilesApi.js +49 -2
  49. package/lib/esm/store/FilesApi.js.map +1 -1
  50. package/lib/esm/store/IndexingApi.js +47 -10
  51. package/lib/esm/store/IndexingApi.js.map +1 -1
  52. package/lib/esm/store/ObjectsApi.js +28 -5
  53. package/lib/esm/store/ObjectsApi.js.map +1 -1
  54. package/lib/esm/store/WorkflowsApi.js +234 -263
  55. package/lib/esm/store/WorkflowsApi.js.map +1 -1
  56. package/lib/esm/store/client.js +2 -0
  57. package/lib/esm/store/client.js.map +1 -1
  58. package/lib/esm/store/index.js +1 -0
  59. package/lib/esm/store/index.js.map +1 -1
  60. package/lib/esm/store/version.js +1 -1
  61. package/lib/tsconfig.tsbuildinfo +1 -1
  62. package/lib/types/InteractionBase.d.ts +1 -1
  63. package/lib/types/InteractionBase.d.ts.map +1 -1
  64. package/lib/types/InteractionsApi.d.ts +1 -0
  65. package/lib/types/InteractionsApi.d.ts.map +1 -1
  66. package/lib/types/MCPOAuthApi.d.ts +10 -5
  67. package/lib/types/MCPOAuthApi.d.ts.map +1 -1
  68. package/lib/types/OAuthAppsApi.d.ts +51 -0
  69. package/lib/types/OAuthAppsApi.d.ts.map +1 -0
  70. package/lib/types/PromptsApi.d.ts +1 -1
  71. package/lib/types/PromptsApi.d.ts.map +1 -1
  72. package/lib/types/RunsApi.d.ts +17 -0
  73. package/lib/types/RunsApi.d.ts.map +1 -1
  74. package/lib/types/client.d.ts +6 -0
  75. package/lib/types/client.d.ts.map +1 -1
  76. package/lib/types/execute.d.ts +2 -4
  77. package/lib/types/execute.d.ts.map +1 -1
  78. package/lib/types/store/AgentsApi.d.ts +231 -0
  79. package/lib/types/store/AgentsApi.d.ts.map +1 -0
  80. package/lib/types/store/FilesApi.d.ts +20 -1
  81. package/lib/types/store/FilesApi.d.ts.map +1 -1
  82. package/lib/types/store/IndexingApi.d.ts +25 -4
  83. package/lib/types/store/IndexingApi.d.ts.map +1 -1
  84. package/lib/types/store/ObjectsApi.d.ts +14 -4
  85. package/lib/types/store/ObjectsApi.d.ts.map +1 -1
  86. package/lib/types/store/WorkflowsApi.d.ts +34 -84
  87. package/lib/types/store/WorkflowsApi.d.ts.map +1 -1
  88. package/lib/types/store/client.d.ts +2 -0
  89. package/lib/types/store/client.d.ts.map +1 -1
  90. package/lib/types/store/index.d.ts +1 -0
  91. package/lib/types/store/index.d.ts.map +1 -1
  92. package/lib/types/store/version.d.ts +1 -1
  93. package/lib/vertesia-client.js +1 -1
  94. package/lib/vertesia-client.js.map +1 -1
  95. package/package.json +8 -5
  96. package/src/InteractionBase.ts +3 -3
  97. package/src/InteractionsApi.ts +3 -1
  98. package/src/MCPOAuthApi.ts +14 -7
  99. package/src/OAuthAppsApi.ts +87 -0
  100. package/src/PromptsApi.ts +3 -1
  101. package/src/RunsApi.ts +17 -0
  102. package/src/client.test.ts +38 -0
  103. package/src/client.ts +11 -0
  104. package/src/execute.ts +37 -34
  105. package/src/store/AgentsApi.ts +765 -0
  106. package/src/store/FilesApi.ts +62 -2
  107. package/src/store/IndexingApi.ts +56 -12
  108. package/src/store/ObjectsApi.ts +45 -8
  109. package/src/store/WorkflowsApi.ts +250 -334
  110. package/src/store/client.ts +2 -0
  111. package/src/store/index.ts +1 -0
  112. package/src/store/version.ts +1 -1
  113. package/tsconfig.dist.json +1 -1
@@ -47,21 +47,28 @@ export default class MCPOAuthApi extends ApiTopic {
47
47
  }
48
48
 
49
49
  /**
50
- * Disconnect OAuth authentication for an MCP server
51
- * @param mcpServerUrl - The MCP server URL
50
+ * Disconnect OAuth authentication for a specific collection
51
+ * @param appInstallId - The app installation ID
52
+ * @param collectionName - The collection name
52
53
  */
53
- disconnect(mcpServerUrl: string): Promise<void> {
54
- return this.del(`/disconnect/${encodeURIComponent(mcpServerUrl)}`);
54
+ disconnect(appInstallId: string, collectionName: string): Promise<void> {
55
+ return this.del(`/disconnect/${appInstallId}/${collectionName}`);
55
56
  }
56
57
 
57
58
  /**
58
- * Get or refresh OAuth token for an MCP server (internal use by workflows)
59
+ * Get or refresh OAuth token (internal use by workflows).
60
+ * When oauthAppName is provided, uses the generic OAuth Application flow
61
+ * (resolves by name in the caller's project).
62
+ * Otherwise falls back to legacy MCP server URL-based token retrieval.
59
63
  * @param mcpServerUrl - The MCP server URL
64
+ * @param oauthAppName - Optional OAuth Application name (from collection's oauth_app field)
60
65
  * @returns Access token
61
66
  */
62
- getToken(mcpServerUrl: string): Promise<{ access_token: string }> {
67
+ getToken(mcpServerUrl: string, oauthAppName?: string): Promise<{ access_token: string }> {
63
68
  return this.post('/token', {
64
- payload: { mcp_server_url: mcpServerUrl }
69
+ payload: oauthAppName
70
+ ? { oauth_app_name: oauthAppName }
71
+ : { mcp_server_url: mcpServerUrl }
65
72
  });
66
73
  }
67
74
  }
@@ -0,0 +1,87 @@
1
+ import { ApiTopic, ClientBase } from '@vertesia/api-fetch-client';
2
+ import type {
3
+ CreateOAuthApplicationPayload,
4
+ OAuthAppAuthStatus,
5
+ OAuthAppAuthorizeResponse,
6
+ OAuthApplication,
7
+ UpdateOAuthApplicationPayload,
8
+ } from '@vertesia/common';
9
+
10
+ export default class OAuthAppsApi extends ApiTopic {
11
+
12
+ constructor(parent: ClientBase) {
13
+ super(parent, '/api/v1/oauth-apps');
14
+ }
15
+
16
+ /**
17
+ * List all OAuth applications in the current project.
18
+ */
19
+ list(): Promise<OAuthApplication[]> {
20
+ return this.get('/');
21
+ }
22
+
23
+ /**
24
+ * Get a single OAuth application by ID (secret redacted).
25
+ */
26
+ retrieve(id: string): Promise<OAuthApplication> {
27
+ return this.get(`/${id}`);
28
+ }
29
+
30
+ /**
31
+ * Create a new OAuth application.
32
+ */
33
+ create(payload: CreateOAuthApplicationPayload): Promise<OAuthApplication> {
34
+ return this.post('/', { payload });
35
+ }
36
+
37
+ /**
38
+ * Update an OAuth application.
39
+ */
40
+ update(id: string, payload: UpdateOAuthApplicationPayload): Promise<OAuthApplication> {
41
+ return this.put(`/${id}`, { payload });
42
+ }
43
+
44
+ /**
45
+ * Delete an OAuth application.
46
+ */
47
+ remove(id: string): Promise<void> {
48
+ return this.del(`/${id}`);
49
+ }
50
+
51
+ /**
52
+ * Initiate OAuth 2.0 authorization flow for the current user.
53
+ * Returns an authorization URL to open in a popup/browser.
54
+ */
55
+ authorize(id: string): Promise<OAuthAppAuthorizeResponse> {
56
+ return this.get(`/${id}/authorize`);
57
+ }
58
+
59
+ /**
60
+ * Exchange an authorization code for tokens (called by UI callback).
61
+ */
62
+ exchange(code: string, state: string): Promise<{ success: boolean }> {
63
+ return this.post('/exchange', { payload: { code, state } });
64
+ }
65
+
66
+ /**
67
+ * Check the current user's authentication status for an OAuth application.
68
+ */
69
+ getStatus(id: string): Promise<OAuthAppAuthStatus> {
70
+ return this.get(`/${id}/status`);
71
+ }
72
+
73
+ /**
74
+ * Get a valid access token for an OAuth application (auto-refreshes).
75
+ * Primarily used by workflows/activities.
76
+ */
77
+ getToken(id: string): Promise<{ access_token: string }> {
78
+ return this.post(`/${id}/token`, { payload: {} });
79
+ }
80
+
81
+ /**
82
+ * Delete the current user's tokens for an OAuth application.
83
+ */
84
+ disconnect(id: string): Promise<void> {
85
+ return this.del(`/${id}/disconnect`);
86
+ }
87
+ }
package/src/PromptsApi.ts CHANGED
@@ -97,6 +97,7 @@ export default class PromptsApi extends ApiTopic {
97
97
  });
98
98
  }
99
99
 
100
+ //TODO - Does this exist?
100
101
  /**
101
102
  * Render a prompt template
102
103
  * @param id of the prompt template to render
@@ -107,12 +108,13 @@ export default class PromptsApi extends ApiTopic {
107
108
  * @throws 400 if payload is invalid
108
109
  * @throws 500 if render fails
109
110
  **/
110
- render(id: string, payload: {}): Promise<PromptTemplate> {
111
+ render(id: string, payload: object): Promise<PromptTemplate> {
111
112
  return this.post(`/${id}/render`, {
112
113
  payload
113
114
  });
114
115
  }
115
116
 
117
+ //TODO - Does this exist?
116
118
  /**
117
119
  * Get options for a field
118
120
  * @param field name to get options for
package/src/RunsApi.ts CHANGED
@@ -141,4 +141,21 @@ export class RunsApi extends ApiTopic {
141
141
  payload,
142
142
  });
143
143
  }
144
+
145
+ /**
146
+ * Restart a failed/terminated conversation workflow.
147
+ * Loads conversation history from the old run and starts a new workflow
148
+ * running the latest code.
149
+ */
150
+ restart(runId: string): Promise<{ runId: string; workflowId: string }> {
151
+ return this.post(`/${runId}/restart`, {});
152
+ }
153
+
154
+ /**
155
+ * Fork a conversation workflow — works even if the original is still running.
156
+ * Creates a new workflow with the conversation history from the source run.
157
+ */
158
+ fork(runId: string): Promise<{ runId: string; workflowId: string }> {
159
+ return this.post(`/${runId}/fork`, {});
160
+ }
144
161
  }
@@ -73,6 +73,44 @@ describe('Test Vertesia Client', () => {
73
73
  expect(client.tokenServerUrl).toBe('https://sts-staging.vertesia.io');
74
74
  });
75
75
 
76
+ test('Initialization with regional serverUrl (api.us1)', () => {
77
+ const client = new VertesiaClient({
78
+ serverUrl: 'https://api.us1.vertesia.io',
79
+ storeUrl: 'https://api.us1.vertesia.io',
80
+ });
81
+
82
+ expect(client).toBeDefined();
83
+ expect(client.baseUrl).toBe('https://api.us1.vertesia.io');
84
+ expect(client.storeUrl).toBe('https://api.us1.vertesia.io');
85
+ // api.us1 → hostname startsWith("api") → replace api→sts → sts.us1.vertesia.io
86
+ // URL.toString() adds trailing /
87
+ expect(client.tokenServerUrl).toBe('https://sts.us1.vertesia.io/');
88
+ });
89
+
90
+ test('Initialization with regional serverUrl (api.eu1)', () => {
91
+ const client = new VertesiaClient({
92
+ serverUrl: 'https://api.eu1.vertesia.io',
93
+ storeUrl: 'https://api.eu1.vertesia.io',
94
+ });
95
+
96
+ expect(client).toBeDefined();
97
+ expect(client.baseUrl).toBe('https://api.eu1.vertesia.io');
98
+ expect(client.storeUrl).toBe('https://api.eu1.vertesia.io');
99
+ expect(client.tokenServerUrl).toBe('https://sts.eu1.vertesia.io/');
100
+ });
101
+
102
+ test('Initialization with regional preview serverUrl (api-preview.us1)', () => {
103
+ const client = new VertesiaClient({
104
+ serverUrl: 'https://api-preview.us1.vertesia.io',
105
+ storeUrl: 'https://api-preview.us1.vertesia.io',
106
+ });
107
+
108
+ expect(client).toBeDefined();
109
+ expect(client.baseUrl).toBe('https://api-preview.us1.vertesia.io');
110
+ // hostname includes "-preview." → routes to production STS (preview uses prod STS)
111
+ expect(client.tokenServerUrl).toBe('https://sts.vertesia.io');
112
+ });
113
+
76
114
  test('Initialization with site localhost', () => {
77
115
  const client = new VertesiaClient({
78
116
  serverUrl: 'http://localhost:8091',
package/src/client.ts CHANGED
@@ -11,6 +11,7 @@ import EnvironmentsApi from "./EnvironmentsApi.js";
11
11
  import { IamApi } from "./IamApi.js";
12
12
  import InteractionsApi from "./InteractionsApi.js";
13
13
  import MCPOAuthApi from "./MCPOAuthApi.js";
14
+ import OAuthAppsApi from "./OAuthAppsApi.js";
14
15
  import ProjectsApi from "./ProjectsApi.js";
15
16
  import SkillsApi from "./SkillsApi.js";
16
17
  import PromptsApi from "./PromptsApi.js";
@@ -256,6 +257,13 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
256
257
  return jwt?.account || null;
257
258
  }
258
259
 
260
+ /**
261
+ * Alias for store.agents
262
+ */
263
+ get agents() {
264
+ return this.store.agents;
265
+ }
266
+
259
267
  /**
260
268
  * Alias for store.workflows
261
269
  */
@@ -342,6 +350,7 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
342
350
  commands = new CommandsApi(this);
343
351
  apps = new AppsApi(this);
344
352
  mcpOAuth = new MCPOAuthApi(this);
353
+ oauthApps = new OAuthAppsApi(this);
345
354
  }
346
355
 
347
356
  function isApiKey(apiKey: string) {
@@ -412,6 +421,8 @@ function getEndpointsFromDomain(domain: string) {
412
421
  };
413
422
  } else {
414
423
  const url = `https://${domain}`;
424
+ // Supports both dot-separated (api.us1.vertesia.io → sts.us1.vertesia.io)
425
+ // and legacy (api.vertesia.io → sts.vertesia.io)
415
426
  return {
416
427
  studio: url,
417
428
  store: url,
package/src/execute.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AsyncExecutionPayload, ExecutionRunStatus, InteractionExecutionPayload, InteractionExecutionResult, NamedInteractionExecutionPayload, RateLimitRequestPayload, RateLimitRequestResponse } from '@vertesia/common';
2
2
  import { VertesiaClient } from './client.js';
3
+ import type { AsyncExecutionResult } from './InteractionsApi.js';
3
4
 
4
5
  export async function EventSourceProvider(): Promise<typeof EventSource> {
5
6
  if (typeof globalThis.EventSource === 'function') {
@@ -74,46 +75,48 @@ export async function executeInteractionByName<P = any>(client: VertesiaClient,
74
75
  }
75
76
 
76
77
  function handleStreaming(client: VertesiaClient, runId: string, onChunk: (chunk: string) => void) {
77
- return new Promise(async (resolve, reject) => {
78
- try {
79
- const EventSourceImpl = await EventSourceProvider();
80
- const streamUrl = new URL(client.runs.baseUrl + '/' + runId + '/stream');
81
- const bearerToken = client._auth ? await client._auth() : undefined;
78
+ return new Promise((resolve, reject) => {
79
+ (async () => {
80
+ try {
81
+ const EventSourceImpl = await EventSourceProvider();
82
+ const streamUrl = new URL(client.runs.baseUrl + '/' + runId + '/stream');
83
+ const bearerToken = client._auth ? await client._auth() : undefined;
82
84
 
83
- if (bearerToken) {
84
- const token = bearerToken.split(' ')[1];
85
- streamUrl.searchParams.set('access_token', token);
86
- } else {
87
- throw new Error('No auth token available');
88
- }
85
+ if (bearerToken) {
86
+ const token = bearerToken.split(' ')[1];
87
+ streamUrl.searchParams.set('access_token', token);
88
+ } else {
89
+ throw new Error('No auth token available');
90
+ }
89
91
 
90
- const sse = new EventSourceImpl(streamUrl.href);
91
- sse.addEventListener("message", ev => {
92
- try {
93
- const data = JSON.parse(ev.data);
94
- if (data) {
95
- onChunk && onChunk(data);
92
+ const sse = new EventSourceImpl(streamUrl.href);
93
+ sse.addEventListener("message", ev => {
94
+ try {
95
+ const data = JSON.parse(ev.data);
96
+ if (data) {
97
+ onChunk && onChunk(data);
98
+ }
99
+ } catch (err) {
100
+ reject(err);
96
101
  }
97
- } catch (err) {
98
- reject(err);
99
- }
100
- });
101
- sse.addEventListener("close", (ev) => {
102
- try {
103
- sse.close();
104
- const msg = JSON.parse(ev.data)
105
- resolve(msg);
106
- } catch (err) {
107
- reject(err);
108
- }
109
- });
110
- } catch (err) {
111
- reject(err);
112
- }
102
+ });
103
+ sse.addEventListener("close", (ev) => {
104
+ try {
105
+ sse.close();
106
+ const msg = JSON.parse(ev.data)
107
+ resolve(msg);
108
+ } catch (err) {
109
+ reject(err);
110
+ }
111
+ });
112
+ } catch (err) {
113
+ reject(err);
114
+ }
115
+ })();
113
116
  });
114
117
  }
115
118
 
116
- export async function executeInteractionAsync(client: VertesiaClient, payload: AsyncExecutionPayload): Promise<{ runId: string, workflowId: string }> {
119
+ export async function executeInteractionAsync(client: VertesiaClient, payload: AsyncExecutionPayload): Promise<AsyncExecutionResult> {
117
120
  return await client.post('/api/v1/execute/async', {
118
121
  payload,
119
122
  });