@vertesia/client 1.0.0-dev.20260305.083323Z → 1.0.0-dev.20260331.091034Z
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.
- package/lib/cjs/InteractionBase.js +3 -3
- package/lib/cjs/InteractionBase.js.map +1 -1
- package/lib/cjs/InteractionsApi.js.map +1 -1
- package/lib/cjs/MCPOAuthApi.js +14 -7
- package/lib/cjs/MCPOAuthApi.js.map +1 -1
- package/lib/cjs/OAuthAppsApi.js +72 -0
- package/lib/cjs/OAuthAppsApi.js.map +1 -0
- package/lib/cjs/PromptsApi.js +2 -0
- package/lib/cjs/PromptsApi.js.map +1 -1
- package/lib/cjs/RunsApi.js +7 -0
- package/lib/cjs/RunsApi.js.map +1 -1
- package/lib/cjs/client.js +29 -35
- package/lib/cjs/client.js.map +1 -1
- package/lib/cjs/execute.js +38 -36
- package/lib/cjs/execute.js.map +1 -1
- package/lib/cjs/store/AgentsApi.js +639 -0
- package/lib/cjs/store/AgentsApi.js.map +1 -0
- package/lib/cjs/store/FilesApi.js +49 -2
- package/lib/cjs/store/FilesApi.js.map +1 -1
- package/lib/cjs/store/IndexingApi.js +47 -10
- package/lib/cjs/store/IndexingApi.js.map +1 -1
- package/lib/cjs/store/ObjectsApi.js +28 -5
- package/lib/cjs/store/ObjectsApi.js.map +1 -1
- package/lib/cjs/store/WorkflowsApi.js +234 -263
- package/lib/cjs/store/WorkflowsApi.js.map +1 -1
- package/lib/cjs/store/client.js +2 -0
- package/lib/cjs/store/client.js.map +1 -1
- package/lib/cjs/store/index.js +1 -0
- package/lib/cjs/store/index.js.map +1 -1
- package/lib/cjs/store/version.js +1 -1
- package/lib/esm/InteractionBase.js +3 -3
- package/lib/esm/InteractionBase.js.map +1 -1
- package/lib/esm/InteractionsApi.js.map +1 -1
- package/lib/esm/MCPOAuthApi.js +14 -7
- package/lib/esm/MCPOAuthApi.js.map +1 -1
- package/lib/esm/OAuthAppsApi.js +69 -0
- package/lib/esm/OAuthAppsApi.js.map +1 -0
- package/lib/esm/PromptsApi.js +2 -0
- package/lib/esm/PromptsApi.js.map +1 -1
- package/lib/esm/RunsApi.js +7 -0
- package/lib/esm/RunsApi.js.map +1 -1
- package/lib/esm/client.js +29 -35
- package/lib/esm/client.js.map +1 -1
- package/lib/esm/execute.js +38 -36
- package/lib/esm/execute.js.map +1 -1
- package/lib/esm/store/AgentsApi.js +635 -0
- package/lib/esm/store/AgentsApi.js.map +1 -0
- package/lib/esm/store/FilesApi.js +49 -2
- package/lib/esm/store/FilesApi.js.map +1 -1
- package/lib/esm/store/IndexingApi.js +47 -10
- package/lib/esm/store/IndexingApi.js.map +1 -1
- package/lib/esm/store/ObjectsApi.js +28 -5
- package/lib/esm/store/ObjectsApi.js.map +1 -1
- package/lib/esm/store/WorkflowsApi.js +234 -263
- package/lib/esm/store/WorkflowsApi.js.map +1 -1
- package/lib/esm/store/client.js +2 -0
- package/lib/esm/store/client.js.map +1 -1
- package/lib/esm/store/index.js +1 -0
- package/lib/esm/store/index.js.map +1 -1
- package/lib/esm/store/version.js +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/InteractionBase.d.ts +1 -1
- package/lib/types/InteractionBase.d.ts.map +1 -1
- package/lib/types/InteractionsApi.d.ts +1 -0
- package/lib/types/InteractionsApi.d.ts.map +1 -1
- package/lib/types/MCPOAuthApi.d.ts +10 -5
- package/lib/types/MCPOAuthApi.d.ts.map +1 -1
- package/lib/types/OAuthAppsApi.d.ts +51 -0
- package/lib/types/OAuthAppsApi.d.ts.map +1 -0
- package/lib/types/PromptsApi.d.ts +1 -1
- package/lib/types/PromptsApi.d.ts.map +1 -1
- package/lib/types/RunsApi.d.ts +6 -1
- package/lib/types/RunsApi.d.ts.map +1 -1
- package/lib/types/client.d.ts +9 -3
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/execute.d.ts +2 -4
- package/lib/types/execute.d.ts.map +1 -1
- package/lib/types/store/AgentsApi.d.ts +231 -0
- package/lib/types/store/AgentsApi.d.ts.map +1 -0
- package/lib/types/store/FilesApi.d.ts +20 -1
- package/lib/types/store/FilesApi.d.ts.map +1 -1
- package/lib/types/store/IndexingApi.d.ts +25 -4
- package/lib/types/store/IndexingApi.d.ts.map +1 -1
- package/lib/types/store/ObjectsApi.d.ts +14 -4
- package/lib/types/store/ObjectsApi.d.ts.map +1 -1
- package/lib/types/store/WorkflowsApi.d.ts +34 -84
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -1
- package/lib/types/store/client.d.ts +2 -0
- package/lib/types/store/client.d.ts.map +1 -1
- package/lib/types/store/index.d.ts +1 -0
- package/lib/types/store/index.d.ts.map +1 -1
- package/lib/types/store/version.d.ts +1 -1
- package/lib/vertesia-client.js +1 -1
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +8 -5
- package/src/InteractionBase.ts +3 -3
- package/src/InteractionsApi.ts +3 -1
- package/src/MCPOAuthApi.ts +14 -7
- package/src/OAuthAppsApi.ts +87 -0
- package/src/PromptsApi.ts +3 -1
- package/src/RunsApi.ts +10 -0
- package/src/client.test.ts +41 -5
- package/src/client.ts +39 -32
- package/src/execute.ts +37 -34
- package/src/store/AgentsApi.ts +765 -0
- package/src/store/FilesApi.ts +62 -2
- package/src/store/IndexingApi.ts +56 -12
- package/src/store/ObjectsApi.ts +45 -8
- package/src/store/WorkflowsApi.ts +250 -334
- package/src/store/client.ts +2 -0
- package/src/store/index.ts +1 -0
- package/src/store/version.ts +1 -1
- package/tsconfig.dist.json +1 -1
package/src/MCPOAuthApi.ts
CHANGED
|
@@ -47,21 +47,28 @@ export default class MCPOAuthApi extends ApiTopic {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Disconnect OAuth authentication for
|
|
51
|
-
* @param
|
|
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(
|
|
54
|
-
return this.del(`/disconnect/${
|
|
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
|
|
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:
|
|
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:
|
|
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
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
FindPayload,
|
|
8
8
|
PopulatedExecutionRun,
|
|
9
9
|
RunCreatePayload,
|
|
10
|
+
ExecutionRunDocRef,
|
|
11
|
+
RunClonePayload,
|
|
10
12
|
RunListingFilters,
|
|
11
13
|
RunListingQueryOptions,
|
|
12
14
|
RunSearchPayload,
|
|
@@ -141,4 +143,12 @@ export class RunsApi extends ApiTopic {
|
|
|
141
143
|
payload,
|
|
142
144
|
});
|
|
143
145
|
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Clone an existing ExecutionRun for fork workflows.
|
|
149
|
+
* Creates a new run with the same interaction/config but fresh status.
|
|
150
|
+
*/
|
|
151
|
+
clone(payload: RunClonePayload): Promise<ExecutionRunDocRef> {
|
|
152
|
+
return this.post('/clone', { payload });
|
|
153
|
+
}
|
|
144
154
|
}
|
package/src/client.test.ts
CHANGED
|
@@ -62,15 +62,51 @@ describe('Test Vertesia Client', () => {
|
|
|
62
62
|
expect(client.tokenServerUrl).toBe('https://sts.vertesia.io');
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
test('Initialization with site api
|
|
65
|
+
test('Initialization with site api.dev1.vertesia.io', () => {
|
|
66
66
|
const client = new VertesiaClient({
|
|
67
|
-
site: 'api
|
|
67
|
+
site: 'api.dev1.vertesia.io',
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
expect(client).toBeDefined();
|
|
71
|
-
expect(client.baseUrl).toBe('https://api
|
|
72
|
-
expect(client.storeUrl).toBe('https://api
|
|
73
|
-
expect(client.tokenServerUrl).toBe('https://sts
|
|
71
|
+
expect(client.baseUrl).toBe('https://api.dev1.vertesia.io');
|
|
72
|
+
expect(client.storeUrl).toBe('https://api.dev1.vertesia.io');
|
|
73
|
+
expect(client.tokenServerUrl).toBe('https://sts.dev1.vertesia.io');
|
|
74
|
+
});
|
|
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
|
+
expect(client.tokenServerUrl).toBe('https://sts.us1.vertesia.io');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('Initialization with regional serverUrl (api.eu1)', () => {
|
|
89
|
+
const client = new VertesiaClient({
|
|
90
|
+
serverUrl: 'https://api.eu1.vertesia.io',
|
|
91
|
+
storeUrl: 'https://api.eu1.vertesia.io',
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(client).toBeDefined();
|
|
95
|
+
expect(client.baseUrl).toBe('https://api.eu1.vertesia.io');
|
|
96
|
+
expect(client.storeUrl).toBe('https://api.eu1.vertesia.io');
|
|
97
|
+
expect(client.tokenServerUrl).toBe('https://sts.eu1.vertesia.io');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('Initialization with regional preview serverUrl (api-preview.us1)', () => {
|
|
101
|
+
const client = new VertesiaClient({
|
|
102
|
+
serverUrl: 'https://api-preview.us1.vertesia.io',
|
|
103
|
+
storeUrl: 'https://api-preview.us1.vertesia.io',
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(client).toBeDefined();
|
|
107
|
+
expect(client.baseUrl).toBe('https://api-preview.us1.vertesia.io');
|
|
108
|
+
// preview strips -preview., then api → sts: sts.us1.vertesia.io
|
|
109
|
+
expect(client.tokenServerUrl).toBe('https://sts.us1.vertesia.io');
|
|
74
110
|
});
|
|
75
111
|
|
|
76
112
|
test('Initialization with site localhost', () => {
|
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";
|
|
@@ -35,15 +36,21 @@ export type VertesiaClientProps = {
|
|
|
35
36
|
* advanced configurations, use `serverUrl` and `storeUrl` instead.
|
|
36
37
|
*
|
|
37
38
|
* @example api.vertesia.io
|
|
38
|
-
* @example api
|
|
39
|
-
* @example api-
|
|
39
|
+
* @example api.us1.vertesia.io
|
|
40
|
+
* @example api-preview.eu1.vertesia.io
|
|
40
41
|
* @default api.vertesia.io
|
|
41
42
|
* @since 0.52.0
|
|
42
43
|
*/
|
|
43
44
|
site?:
|
|
44
45
|
| "api.vertesia.io"
|
|
45
46
|
| "api-preview.vertesia.io"
|
|
46
|
-
| "api
|
|
47
|
+
| "api.us1.vertesia.io"
|
|
48
|
+
| "api-preview.us1.vertesia.io"
|
|
49
|
+
| "api.eu1.vertesia.io"
|
|
50
|
+
| "api-preview.eu1.vertesia.io"
|
|
51
|
+
| "api.jp1.vertesia.io"
|
|
52
|
+
| "api-preview.jp1.vertesia.io"
|
|
53
|
+
| "api.dev1.vertesia.io";
|
|
47
54
|
serverUrl?: string;
|
|
48
55
|
storeUrl?: string;
|
|
49
56
|
tokenServerUrl?: string;
|
|
@@ -135,45 +142,35 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
|
|
|
135
142
|
if (opts.tokenServerUrl) {
|
|
136
143
|
this.tokenServerUrl = opts.tokenServerUrl;
|
|
137
144
|
} else if (opts.site) {
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
// Strip -preview (preview uses the same STS as production for the same region),
|
|
146
|
+
// then replace api prefix with sts.
|
|
147
|
+
// Examples:
|
|
148
|
+
// api.vertesia.io -> sts.vertesia.io
|
|
149
|
+
// api-preview.vertesia.io -> sts.vertesia.io
|
|
150
|
+
// api.us1.vertesia.io -> sts.us1.vertesia.io
|
|
151
|
+
// api-preview.eu1.vertesia.io -> sts.eu1.vertesia.io
|
|
152
|
+
const stsHost = opts.site.replace('api-preview.', 'api.').replace(/^api/, 'sts');
|
|
153
|
+
this.tokenServerUrl = `https://${stsHost}`;
|
|
144
154
|
} else if (opts.serverUrl || opts.storeUrl) {
|
|
145
155
|
// Determine STS URL based on environment in serverUrl or storeUrl
|
|
146
156
|
const urlToCheck = opts.serverUrl || opts.storeUrl || "";
|
|
147
157
|
try {
|
|
148
158
|
const url = new URL(urlToCheck);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
//
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this.tokenServerUrl =
|
|
156
|
-
} else if (url.hostname === "api.vertesia.io") {
|
|
157
|
-
this.tokenServerUrl = "https://sts.vertesia.io";
|
|
158
|
-
} else if (url.hostname === "api-preview.vertesia.io") {
|
|
159
|
-
this.tokenServerUrl = "https://sts.vertesia.io";
|
|
160
|
-
} else if (url.hostname === "api-staging.vertesia.io") {
|
|
161
|
-
this.tokenServerUrl = "https://sts-staging.vertesia.io";
|
|
162
|
-
} else if (url.hostname.startsWith("api")) {
|
|
163
|
-
// Generic api.* pattern replacement
|
|
164
|
-
url.hostname = url.hostname.replace(/^api/, "sts");
|
|
165
|
-
this.tokenServerUrl = url.toString();
|
|
159
|
+
if (url.hostname.startsWith("api")) {
|
|
160
|
+
// Strip -preview and replace api with sts.
|
|
161
|
+
// api.us1.vertesia.io -> sts.us1.vertesia.io
|
|
162
|
+
// api-preview.us1.vertesia.io -> sts.us1.vertesia.io
|
|
163
|
+
// api.vertesia.io -> sts.vertesia.io
|
|
164
|
+
const stsHost = url.hostname.replace('api-preview.', 'api.').replace(/^api/, 'sts');
|
|
165
|
+
this.tokenServerUrl = `https://${stsHost}`;
|
|
166
166
|
} else {
|
|
167
|
-
|
|
168
|
-
this.tokenServerUrl = "https://sts-staging.vertesia.io";
|
|
167
|
+
this.tokenServerUrl = "https://sts.dev1.vertesia.io";
|
|
169
168
|
}
|
|
170
169
|
} catch (e) {
|
|
171
|
-
|
|
172
|
-
this.tokenServerUrl = "https://sts-staging.vertesia.io";
|
|
170
|
+
this.tokenServerUrl = "https://sts.dev1.vertesia.io";
|
|
173
171
|
}
|
|
174
172
|
} else {
|
|
175
|
-
|
|
176
|
-
this.tokenServerUrl = "https://sts-staging.vertesia.io";
|
|
173
|
+
this.tokenServerUrl = "https://sts.dev1.vertesia.io";
|
|
177
174
|
}
|
|
178
175
|
|
|
179
176
|
this.store = new ZenoClient({
|
|
@@ -256,6 +253,13 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
|
|
|
256
253
|
return jwt?.account || null;
|
|
257
254
|
}
|
|
258
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Alias for store.agents
|
|
258
|
+
*/
|
|
259
|
+
get agents() {
|
|
260
|
+
return this.store.agents;
|
|
261
|
+
}
|
|
262
|
+
|
|
259
263
|
/**
|
|
260
264
|
* Alias for store.workflows
|
|
261
265
|
*/
|
|
@@ -342,6 +346,7 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
|
|
|
342
346
|
commands = new CommandsApi(this);
|
|
343
347
|
apps = new AppsApi(this);
|
|
344
348
|
mcpOAuth = new MCPOAuthApi(this);
|
|
349
|
+
oauthApps = new OAuthAppsApi(this);
|
|
345
350
|
}
|
|
346
351
|
|
|
347
352
|
function isApiKey(apiKey: string) {
|
|
@@ -412,6 +417,8 @@ function getEndpointsFromDomain(domain: string) {
|
|
|
412
417
|
};
|
|
413
418
|
} else {
|
|
414
419
|
const url = `https://${domain}`;
|
|
420
|
+
// Supports both dot-separated (api.us1.vertesia.io → sts.us1.vertesia.io)
|
|
421
|
+
// and legacy (api.vertesia.io → sts.vertesia.io)
|
|
415
422
|
return {
|
|
416
423
|
studio: url,
|
|
417
424
|
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(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}
|
|
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<
|
|
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
|
});
|