@vertesia/client 1.1.0 → 1.1.1-dev.20260505.163000Z
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/AccountApi.js +3 -3
- package/lib/cjs/AccountApi.js.map +1 -1
- package/lib/cjs/ApiKeysApi.js +8 -10
- package/lib/cjs/ApiKeysApi.js.map +1 -1
- package/lib/cjs/AppsApi.js +3 -1
- package/lib/cjs/AppsApi.js.map +1 -1
- package/lib/cjs/EnvironmentsApi.js.map +1 -1
- package/lib/cjs/GroupsApi.js.map +1 -1
- package/lib/cjs/InteractionsApi.js +5 -7
- package/lib/cjs/InteractionsApi.js.map +1 -1
- package/lib/cjs/OAuthClientsApi.js.map +1 -1
- package/lib/cjs/OAuthProvidersApi.js.map +1 -1
- package/lib/cjs/ProjectsApi.js +10 -1
- package/lib/cjs/ProjectsApi.js.map +1 -1
- package/lib/cjs/execute.js.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/store/CollectionsApi.js.map +1 -1
- package/lib/cjs/store/CostApi.js +7 -1
- package/lib/cjs/store/CostApi.js.map +1 -1
- package/lib/cjs/store/DashboardApi.js.map +1 -1
- package/lib/cjs/store/DataApi.js +3 -0
- package/lib/cjs/store/DataApi.js.map +1 -1
- package/lib/cjs/store/FilesApi.js +4 -2
- package/lib/cjs/store/FilesApi.js.map +1 -1
- package/lib/cjs/store/IndexingApi.js.map +1 -1
- package/lib/cjs/store/ObjectsApi.js.map +1 -1
- package/lib/cjs/store/WorkflowsApi.js +29 -5
- package/lib/cjs/store/WorkflowsApi.js.map +1 -1
- package/lib/esm/AccountApi.js +3 -3
- package/lib/esm/AccountApi.js.map +1 -1
- package/lib/esm/ApiKeysApi.js +9 -11
- package/lib/esm/ApiKeysApi.js.map +1 -1
- package/lib/esm/AppsApi.js +3 -1
- package/lib/esm/AppsApi.js.map +1 -1
- package/lib/esm/EnvironmentsApi.js.map +1 -1
- package/lib/esm/GroupsApi.js.map +1 -1
- package/lib/esm/InteractionsApi.js +6 -8
- package/lib/esm/InteractionsApi.js.map +1 -1
- package/lib/esm/OAuthClientsApi.js.map +1 -1
- package/lib/esm/OAuthProvidersApi.js.map +1 -1
- package/lib/esm/ProjectsApi.js +10 -1
- package/lib/esm/ProjectsApi.js.map +1 -1
- package/lib/esm/execute.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/store/CollectionsApi.js.map +1 -1
- package/lib/esm/store/CostApi.js +7 -1
- package/lib/esm/store/CostApi.js.map +1 -1
- package/lib/esm/store/DashboardApi.js.map +1 -1
- package/lib/esm/store/DataApi.js +3 -0
- package/lib/esm/store/DataApi.js.map +1 -1
- package/lib/esm/store/FilesApi.js +4 -2
- package/lib/esm/store/FilesApi.js.map +1 -1
- package/lib/esm/store/IndexingApi.js.map +1 -1
- package/lib/esm/store/ObjectsApi.js.map +1 -1
- package/lib/esm/store/WorkflowsApi.js +29 -5
- package/lib/esm/store/WorkflowsApi.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/AccountApi.d.ts +6 -9
- package/lib/types/AccountApi.d.ts.map +1 -1
- package/lib/types/ApiKeysApi.d.ts +6 -3
- package/lib/types/ApiKeysApi.d.ts.map +1 -1
- package/lib/types/AppsApi.d.ts +3 -6
- package/lib/types/AppsApi.d.ts.map +1 -1
- package/lib/types/EnvironmentsApi.d.ts +1 -1
- package/lib/types/EnvironmentsApi.d.ts.map +1 -1
- package/lib/types/GroupsApi.d.ts +4 -6
- package/lib/types/GroupsApi.d.ts.map +1 -1
- package/lib/types/IamApi.d.ts +3 -8
- package/lib/types/IamApi.d.ts.map +1 -1
- package/lib/types/InteractionsApi.d.ts +8 -26
- package/lib/types/InteractionsApi.d.ts.map +1 -1
- package/lib/types/OAuthClientsApi.d.ts +2 -4
- package/lib/types/OAuthClientsApi.d.ts.map +1 -1
- package/lib/types/OAuthProvidersApi.d.ts +5 -11
- package/lib/types/OAuthProvidersApi.d.ts.map +1 -1
- package/lib/types/ProjectsApi.d.ts +4 -1
- package/lib/types/ProjectsApi.d.ts.map +1 -1
- package/lib/types/RunsApi.d.ts +1 -3
- package/lib/types/RunsApi.d.ts.map +1 -1
- package/lib/types/UsersApi.d.ts +2 -4
- package/lib/types/UsersApi.d.ts.map +1 -1
- package/lib/types/execute.d.ts +1 -2
- package/lib/types/execute.d.ts.map +1 -1
- package/lib/types/index.d.ts +5 -2
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/store/CollectionsApi.d.ts +4 -5
- package/lib/types/store/CollectionsApi.d.ts.map +1 -1
- package/lib/types/store/CostApi.d.ts +3 -6
- package/lib/types/store/CostApi.d.ts.map +1 -1
- package/lib/types/store/DashboardApi.d.ts +5 -16
- package/lib/types/store/DashboardApi.d.ts.map +1 -1
- package/lib/types/store/DataApi.d.ts +5 -41
- package/lib/types/store/DataApi.d.ts.map +1 -1
- package/lib/types/store/FilesApi.d.ts +6 -17
- package/lib/types/store/FilesApi.d.ts.map +1 -1
- package/lib/types/store/IndexingApi.d.ts +2 -8
- package/lib/types/store/IndexingApi.d.ts.map +1 -1
- package/lib/types/store/ObjectsApi.d.ts +7 -36
- package/lib/types/store/ObjectsApi.d.ts.map +1 -1
- package/lib/types/store/WorkflowsApi.d.ts +9 -18
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -1
- package/lib/types/store/client.d.ts +2 -2
- package/lib/types/store/client.d.ts.map +1 -1
- package/lib/vertesia-client.js +1 -1
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +5 -5
- package/src/AccountApi.ts +22 -7
- package/src/ApiKeysApi.ts +15 -9
- package/src/AppsApi.ts +21 -8
- package/src/EnvironmentsApi.ts +1 -1
- package/src/GroupsApi.ts +4 -4
- package/src/IamApi.ts +4 -4
- package/src/InteractionsApi.ts +11 -25
- package/src/OAuthClientsApi.ts +2 -1
- package/src/OAuthProvidersApi.ts +6 -4
- package/src/ProjectsApi.ts +14 -2
- package/src/RunsApi.ts +1 -1
- package/src/UsersApi.ts +2 -2
- package/src/execute.ts +2 -3
- package/src/index.ts +6 -2
- package/src/store/CollectionsApi.ts +16 -5
- package/src/store/CostApi.ts +15 -4
- package/src/store/DashboardApi.ts +8 -4
- package/src/store/DataApi.ts +13 -38
- package/src/store/FilesApi.ts +14 -13
- package/src/store/IndexingApi.ts +2 -7
- package/src/store/ObjectsApi.ts +13 -25
- package/src/store/WorkflowsApi.ts +48 -12
- package/src/store/client.ts +2 -2
package/src/store/DataApi.ts
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
2
|
import {
|
|
3
3
|
AlterTablePayload,
|
|
4
|
+
BatchQueryResult,
|
|
4
5
|
CreateDataStorePayload,
|
|
5
6
|
CreateSnapshotPayload,
|
|
6
7
|
CreateTablesPayload,
|
|
7
8
|
DataSchema,
|
|
8
9
|
DataSchemaForAI,
|
|
10
|
+
DataStoreArchiveResult,
|
|
9
11
|
DataStore,
|
|
10
12
|
DataStoreApiHeaders,
|
|
13
|
+
DataStoreDownloadInfo,
|
|
11
14
|
DataStoreItem,
|
|
12
15
|
DataStoreVersion,
|
|
13
16
|
DataTable,
|
|
17
|
+
DataStoreTableDetail,
|
|
18
|
+
DataStoreTableDropResult,
|
|
14
19
|
DataTableSummary,
|
|
15
20
|
ImportDataPayload,
|
|
16
21
|
ImportJob,
|
|
17
22
|
QueryPayload,
|
|
18
23
|
QueryResult,
|
|
24
|
+
QueryValidationResult,
|
|
19
25
|
UpdateSchemaPayload,
|
|
20
26
|
} from "@vertesia/common";
|
|
21
27
|
import { DashboardApi } from "./DashboardApi.js";
|
|
@@ -89,7 +95,7 @@ export class DataApi extends ApiTopic {
|
|
|
89
95
|
* @param id - Data store ID
|
|
90
96
|
* @returns Object with the archived store ID
|
|
91
97
|
*/
|
|
92
|
-
delete(id: string): Promise<
|
|
98
|
+
delete(id: string): Promise<DataStoreArchiveResult> {
|
|
93
99
|
return this.del(`/${id}`, { headers: this.storeHeaders(id) });
|
|
94
100
|
}
|
|
95
101
|
|
|
@@ -204,7 +210,7 @@ export class DataApi extends ApiTopic {
|
|
|
204
210
|
* @param sample - If true, includes sample rows
|
|
205
211
|
* @returns The table with metadata and optional sample data
|
|
206
212
|
*/
|
|
207
|
-
getTable(id: string, tableName: string, sample?: boolean): Promise<
|
|
213
|
+
getTable(id: string, tableName: string, sample?: boolean): Promise<DataStoreTableDetail> {
|
|
208
214
|
const query = sample ? '?sample=true' : '';
|
|
209
215
|
return this.get(`/${id}/tables/${tableName}${query}`, { headers: this.storeHeaders(id) });
|
|
210
216
|
}
|
|
@@ -227,7 +233,7 @@ export class DataApi extends ApiTopic {
|
|
|
227
233
|
* @param id - Data store ID
|
|
228
234
|
* @param tableName - Table name
|
|
229
235
|
*/
|
|
230
|
-
dropTable(id: string, tableName: string): Promise<
|
|
236
|
+
dropTable(id: string, tableName: string): Promise<DataStoreTableDropResult> {
|
|
231
237
|
return this.del(`/${id}/tables/${tableName}`, { headers: this.storeHeaders(id) });
|
|
232
238
|
}
|
|
233
239
|
|
|
@@ -383,6 +389,10 @@ export class DataApi extends ApiTopic {
|
|
|
383
389
|
return this.post(`/${id}/query`, { payload, headers: this.storeHeaders(id) });
|
|
384
390
|
}
|
|
385
391
|
|
|
392
|
+
queryBatch(id: string, queries: QueryPayload[]): Promise<BatchQueryResult> {
|
|
393
|
+
return this.post(`/${id}/query/batch`, { payload: { queries }, headers: this.storeHeaders(id) });
|
|
394
|
+
}
|
|
395
|
+
|
|
386
396
|
/**
|
|
387
397
|
* Validate SQL queries without executing them.
|
|
388
398
|
*
|
|
@@ -479,38 +489,3 @@ export class DataApi extends ApiTopic {
|
|
|
479
489
|
return new DashboardApi(this.client, storeId);
|
|
480
490
|
}
|
|
481
491
|
}
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* Response from the download endpoint.
|
|
485
|
-
*/
|
|
486
|
-
export interface DataStoreDownloadInfo {
|
|
487
|
-
/** Signed download URL (expires in 15 min) */
|
|
488
|
-
url: string;
|
|
489
|
-
/** GCS generation number for cache validation */
|
|
490
|
-
gcs_generation: number;
|
|
491
|
-
/** Schema version */
|
|
492
|
-
schema_version: string;
|
|
493
|
-
/** Store ID */
|
|
494
|
-
store_id: string;
|
|
495
|
-
/** Store name */
|
|
496
|
-
store_name: string;
|
|
497
|
-
/** List of table names */
|
|
498
|
-
tables: string[];
|
|
499
|
-
/** URL expiry time in seconds */
|
|
500
|
-
expires_in: number;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Result from SQL query validation.
|
|
505
|
-
*/
|
|
506
|
-
export interface QueryValidationResult {
|
|
507
|
-
/** Whether all queries are valid */
|
|
508
|
-
valid: boolean;
|
|
509
|
-
/** Validation errors (if any) */
|
|
510
|
-
errors: Array<{
|
|
511
|
-
/** Query name that failed validation */
|
|
512
|
-
query: string;
|
|
513
|
-
/** Error message describing the issue */
|
|
514
|
-
error: string;
|
|
515
|
-
}>;
|
|
516
|
-
}
|
package/src/store/FilesApi.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
|
2
2
|
import {
|
|
3
3
|
BulkUploadUrlsPayload,
|
|
4
4
|
BulkUploadUrlsResponse,
|
|
5
|
+
DeleteFileResult,
|
|
6
|
+
FileBucketResponse,
|
|
7
|
+
FileListResponse,
|
|
8
|
+
FileMetadataResponse,
|
|
9
|
+
FileMetadataUpdateResult,
|
|
5
10
|
GetFileUrlPayload,
|
|
6
11
|
GetFileUrlResponse,
|
|
7
12
|
GetUploadUrlPayload,
|
|
@@ -31,9 +36,8 @@ export class FilesApi extends ApiTopic {
|
|
|
31
36
|
super(parent, "/api/v1/files");
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
async deleteFile(path: string, prefix?: boolean): Promise<
|
|
35
|
-
|
|
36
|
-
return res.count;
|
|
39
|
+
async deleteFile(path: string, prefix?: boolean): Promise<DeleteFileResult> {
|
|
40
|
+
return this.delete(`/${path}`, { query: { prefix } });
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
/**
|
|
@@ -43,14 +47,7 @@ export class FilesApi extends ApiTopic {
|
|
|
43
47
|
* @param uri
|
|
44
48
|
* @returns
|
|
45
49
|
*/
|
|
46
|
-
getMetadata(uri: string): Promise<{
|
|
47
|
-
name: string;
|
|
48
|
-
size: number;
|
|
49
|
-
contentType: string;
|
|
50
|
-
contentDisposition?: string;
|
|
51
|
-
etag?: string;
|
|
52
|
-
customMetadata?: Record<string, string>;
|
|
53
|
-
}> {
|
|
50
|
+
getMetadata(uri: string): Promise<FileMetadataResponse> {
|
|
54
51
|
return this.get("/metadata", {
|
|
55
52
|
query: {
|
|
56
53
|
file: uri,
|
|
@@ -64,7 +61,7 @@ export class FilesApi extends ApiTopic {
|
|
|
64
61
|
* @param metadata - Custom metadata key-value pairs
|
|
65
62
|
* @returns Success status
|
|
66
63
|
*/
|
|
67
|
-
setFileMetadata(file: string, metadata: Record<string, string>): Promise<
|
|
64
|
+
setFileMetadata(file: string, metadata: Record<string, string>): Promise<FileMetadataUpdateResult> {
|
|
68
65
|
const payload: SetFileMetadataPayload = { file, metadata };
|
|
69
66
|
return this.put("/metadata", { payload });
|
|
70
67
|
}
|
|
@@ -74,10 +71,14 @@ export class FilesApi extends ApiTopic {
|
|
|
74
71
|
* The bucket URI is returned.
|
|
75
72
|
* @returns
|
|
76
73
|
*/
|
|
77
|
-
getOrCreateBucket(): Promise<
|
|
74
|
+
getOrCreateBucket(): Promise<FileBucketResponse> {
|
|
78
75
|
return this.post("/bucket");
|
|
79
76
|
}
|
|
80
77
|
|
|
78
|
+
list(prefix: string): Promise<FileListResponse> {
|
|
79
|
+
return this.get('/list', { query: { prefix } });
|
|
80
|
+
}
|
|
81
|
+
|
|
81
82
|
getUploadUrl(payload: GetUploadUrlPayload): Promise<GetFileUrlResponse> {
|
|
82
83
|
return this.post("/upload-url", {
|
|
83
84
|
payload,
|
package/src/store/IndexingApi.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
EnsureIndexResult,
|
|
17
17
|
AnalyzeDriftBatchResult,
|
|
18
18
|
DriftAnalysisStatusResponse,
|
|
19
|
+
StartProjectReindexPayload,
|
|
19
20
|
ComputeShardsRequest,
|
|
20
21
|
ComputeShardsResult,
|
|
21
22
|
IndexShardParams,
|
|
@@ -57,13 +58,7 @@ export class IndexingApi extends ApiTopic {
|
|
|
57
58
|
*
|
|
58
59
|
* @param options Optional workflow tuning parameters
|
|
59
60
|
*/
|
|
60
|
-
async reindex(options?: {
|
|
61
|
-
shard_size?: number;
|
|
62
|
-
parallel_shard_count?: number;
|
|
63
|
-
concurrency?: number;
|
|
64
|
-
bulk_size_bytes?: number;
|
|
65
|
-
bulk_concurrency?: number;
|
|
66
|
-
}): Promise<GenericCommandResponse> {
|
|
61
|
+
async reindex(options?: StartProjectReindexPayload): Promise<GenericCommandResponse> {
|
|
67
62
|
return this.post("/reindex", { payload: options });
|
|
68
63
|
}
|
|
69
64
|
|
package/src/store/ObjectsApi.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
BulkObjectDeleteResult,
|
|
5
5
|
BulkObjectUpdateResult,
|
|
6
6
|
canGenerateRendition,
|
|
7
|
+
Collection,
|
|
7
8
|
ComplexSearchPayload,
|
|
8
9
|
ComputeObjectFacetPayload,
|
|
9
10
|
ContentObject,
|
|
@@ -11,8 +12,12 @@ import {
|
|
|
11
12
|
ContentObjectItem,
|
|
12
13
|
ContentObjectProcessingPriority,
|
|
13
14
|
ContentSource,
|
|
15
|
+
ContentObjectTextResponse,
|
|
14
16
|
CreateContentObjectPayload,
|
|
17
|
+
DeleteContentObjectResult,
|
|
15
18
|
Embedding,
|
|
19
|
+
ObjectSearchResponse,
|
|
20
|
+
ComputedFacetResponse,
|
|
16
21
|
ExportPropertiesPayload,
|
|
17
22
|
ExportPropertiesResponse,
|
|
18
23
|
FindPayload,
|
|
@@ -25,6 +30,7 @@ import {
|
|
|
25
30
|
ListWorkflowRunsResponse,
|
|
26
31
|
ObjectSearchPayload,
|
|
27
32
|
ObjectSearchQuery,
|
|
33
|
+
SetObjectEmbeddingsResponse,
|
|
28
34
|
SupportedEmbeddingTypes,
|
|
29
35
|
} from "@vertesia/common";
|
|
30
36
|
|
|
@@ -36,24 +42,6 @@ import { StreamSource } from "../StreamSource.js";
|
|
|
36
42
|
import { AnalyzeDocApi } from "./AnalyzeDocApi.js";
|
|
37
43
|
import { ZenoClient } from "./client.js";
|
|
38
44
|
|
|
39
|
-
export interface ComputeFacetsResponse {
|
|
40
|
-
type?: { _id: string; count: number }[];
|
|
41
|
-
location?: { _id: string; count: number }[];
|
|
42
|
-
status?: { _id: string; count: number }[];
|
|
43
|
-
[key: string]:
|
|
44
|
-
| { _id: string; count: number }[]
|
|
45
|
-
| number
|
|
46
|
-
| undefined;
|
|
47
|
-
total?: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface SearchResponse {
|
|
51
|
-
results: ContentObjectItem[];
|
|
52
|
-
facets: ComputeFacetsResponse;
|
|
53
|
-
/** Raw ES aggregation results. Only present when aggs were requested and ES backend was used. */
|
|
54
|
-
aggregations?: Record<string, unknown>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
45
|
export class ObjectsApi extends ApiTopic {
|
|
58
46
|
declare client: ZenoClient;
|
|
59
47
|
|
|
@@ -112,7 +100,7 @@ export class ObjectsApi extends ApiTopic {
|
|
|
112
100
|
|
|
113
101
|
computeFacets(
|
|
114
102
|
query: ComputeObjectFacetPayload,
|
|
115
|
-
): Promise<
|
|
103
|
+
): Promise<ComputedFacetResponse> {
|
|
116
104
|
return this.post("/facets", {
|
|
117
105
|
payload: query,
|
|
118
106
|
});
|
|
@@ -137,7 +125,7 @@ export class ObjectsApi extends ApiTopic {
|
|
|
137
125
|
}
|
|
138
126
|
|
|
139
127
|
/** Search object — different from find because allow full text search */
|
|
140
|
-
search(payload: ComplexSearchPayload): Promise<
|
|
128
|
+
search(payload: ComplexSearchPayload): Promise<ObjectSearchResponse> {
|
|
141
129
|
return this.post("/search", {
|
|
142
130
|
payload,
|
|
143
131
|
});
|
|
@@ -151,7 +139,7 @@ export class ObjectsApi extends ApiTopic {
|
|
|
151
139
|
});
|
|
152
140
|
}
|
|
153
141
|
|
|
154
|
-
getObjectText(id: string): Promise<
|
|
142
|
+
getObjectText(id: string): Promise<ContentObjectTextResponse> {
|
|
155
143
|
return this.get(`/${id}/text`);
|
|
156
144
|
}
|
|
157
145
|
|
|
@@ -367,13 +355,13 @@ export class ObjectsApi extends ApiTopic {
|
|
|
367
355
|
* @param id The ID of the object
|
|
368
356
|
* @returns Array of collections containing this object (both static and dynamic)
|
|
369
357
|
*/
|
|
370
|
-
getCollections(id: string): Promise<
|
|
358
|
+
getCollections(id: string): Promise<Collection[]> {
|
|
371
359
|
return this.get(`/${id}/collections`);
|
|
372
360
|
}
|
|
373
361
|
|
|
374
|
-
delete(id: string): Promise<
|
|
362
|
+
delete(id: string): Promise<DeleteContentObjectResult>;
|
|
375
363
|
delete(ids: string[]): Promise<BulkObjectDeleteResult>;
|
|
376
|
-
delete(idOrIds: string | string[]): Promise<
|
|
364
|
+
delete(idOrIds: string | string[]): Promise<DeleteContentObjectResult | BulkObjectDeleteResult> {
|
|
377
365
|
if (Array.isArray(idOrIds)) {
|
|
378
366
|
return this.client.runOperation({
|
|
379
367
|
name: 'delete',
|
|
@@ -469,7 +457,7 @@ export class ObjectsApi extends ApiTopic {
|
|
|
469
457
|
id: string,
|
|
470
458
|
type: SupportedEmbeddingTypes,
|
|
471
459
|
payload: Embedding,
|
|
472
|
-
): Promise<
|
|
460
|
+
): Promise<SetObjectEmbeddingsResponse> {
|
|
473
461
|
return this.put(`/${id}/embeddings/${type}`, {
|
|
474
462
|
payload,
|
|
475
463
|
});
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
toAgentMessage,
|
|
20
20
|
PromptSizeAnalyticsResponse,
|
|
21
21
|
RunsByAgentAnalyticsResponse,
|
|
22
|
+
SignalAgentResponse,
|
|
22
23
|
TimeToFirstResponseAnalyticsResponse,
|
|
23
24
|
TokenUsageAnalyticsResponse,
|
|
24
25
|
ToolAnalyticsResponse,
|
|
@@ -31,11 +32,16 @@ import {
|
|
|
31
32
|
WorkflowAnalyticsSummaryQuery,
|
|
32
33
|
WorkflowAnalyticsSummaryResponse,
|
|
33
34
|
WorkflowAnalyticsTimeSeriesQuery,
|
|
35
|
+
WorkflowActionResponse,
|
|
34
36
|
WorkflowDefinitionRef,
|
|
37
|
+
WorkflowExecutionStartResult,
|
|
38
|
+
WorkflowQueryResult,
|
|
35
39
|
WorkflowRule,
|
|
36
40
|
WorkflowRuleItem,
|
|
41
|
+
WorkflowRunUpdatesResponse,
|
|
37
42
|
WorkflowRunWithDetails,
|
|
38
43
|
WorkflowToolParametersQuery,
|
|
44
|
+
WorkflowUpdatePublishResponse,
|
|
39
45
|
} from "@vertesia/common";
|
|
40
46
|
import { VertesiaClient } from "../client.js";
|
|
41
47
|
import { EventSourceProvider } from "../execute.js";
|
|
@@ -64,7 +70,7 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
64
70
|
return this.post(`/runs`, { payload: payload });
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
sendSignal(workflowId: string, runId: string, signal: string, payload?: any): Promise<
|
|
73
|
+
sendSignal(workflowId: string, runId: string, signal: string, payload?: any): Promise<SignalAgentResponse> {
|
|
68
74
|
return this.post(`/runs/${workflowId}/${runId}/signal/${signal}`, { payload });
|
|
69
75
|
}
|
|
70
76
|
|
|
@@ -95,12 +101,12 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
95
101
|
return this.get(`/runs/${workflowId}/${runId}/interaction`);
|
|
96
102
|
}
|
|
97
103
|
|
|
98
|
-
terminate(workflowId: string, runId: string, reason?: string): Promise<
|
|
104
|
+
terminate(workflowId: string, runId: string, reason?: string): Promise<WorkflowActionResponse> {
|
|
99
105
|
const payload: WorkflowActionPayload = { reason };
|
|
100
106
|
return this.post(`/runs/${workflowId}/${runId}/actions/terminate`, { payload });
|
|
101
107
|
}
|
|
102
108
|
|
|
103
|
-
cancel(workflowId: string, runId: string, reason?: string): Promise<
|
|
109
|
+
cancel(workflowId: string, runId: string, reason?: string): Promise<WorkflowActionResponse> {
|
|
104
110
|
const payload: WorkflowActionPayload = { reason };
|
|
105
111
|
return this.post(`/runs/${workflowId}/${runId}/actions/cancel`, { payload });
|
|
106
112
|
}
|
|
@@ -111,20 +117,20 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
111
117
|
* @param workflowId The workflow ID
|
|
112
118
|
* @param runId The run ID
|
|
113
119
|
* @param queryName The name of the query to execute (e.g., "BatchAgentProgress")
|
|
114
|
-
* @returns The query result
|
|
120
|
+
* @returns The workflow query result as a JSON value.
|
|
115
121
|
*/
|
|
116
|
-
query
|
|
122
|
+
query(workflowId: string, runId: string, queryName: string): Promise<WorkflowQueryResult> {
|
|
117
123
|
return this.get(`/runs/${workflowId}/${runId}/query/${queryName}`);
|
|
118
124
|
}
|
|
119
125
|
|
|
120
126
|
execute(
|
|
121
127
|
name: string,
|
|
122
128
|
payload: ExecuteWorkflowPayload = {},
|
|
123
|
-
): Promise<(
|
|
129
|
+
): Promise<(WorkflowExecutionStartResult | undefined)[]> {
|
|
124
130
|
return this.post(`/execute/${name}`, { payload });
|
|
125
131
|
}
|
|
126
132
|
|
|
127
|
-
postMessage(runId: string, msg: AgentMessage): Promise<
|
|
133
|
+
postMessage(runId: string, msg: AgentMessage): Promise<WorkflowUpdatePublishResponse> {
|
|
128
134
|
if (!runId) {
|
|
129
135
|
throw new Error("runId is required");
|
|
130
136
|
}
|
|
@@ -138,7 +144,7 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
138
144
|
*/
|
|
139
145
|
async retrieveMessages(workflowId: string, runId: string, since?: number): Promise<AgentMessage[]> {
|
|
140
146
|
const query = { since };
|
|
141
|
-
const response = await this.get(`/runs/${workflowId}/${runId}/updates`, { query }) as
|
|
147
|
+
const response = await this.get(`/runs/${workflowId}/${runId}/updates`, { query }) as WorkflowRunUpdatesResponse;
|
|
142
148
|
// Convert compact messages to AgentMessage for backward compatibility
|
|
143
149
|
return response.messages.map((m: CompactMessage) => toAgentMessage(m, runId));
|
|
144
150
|
}
|
|
@@ -152,13 +158,21 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
152
158
|
* This approach provides better performance for conversations with large historical messages
|
|
153
159
|
* since HTTP responses are compressed while SSE streams cannot be compressed.
|
|
154
160
|
*/
|
|
155
|
-
async streamMessages(
|
|
161
|
+
async streamMessages(
|
|
162
|
+
workflowId: string,
|
|
163
|
+
runId: string,
|
|
164
|
+
onMessage?: (message: AgentMessage, exitFn?: (payload: unknown) => void) => void,
|
|
165
|
+
since?: number,
|
|
166
|
+
signal?: AbortSignal,
|
|
167
|
+
): Promise<unknown> {
|
|
156
168
|
return new Promise<unknown>((resolve, reject) => {
|
|
157
169
|
let reconnectAttempts = 0;
|
|
158
170
|
let lastMessageTimestamp = since || 0;
|
|
159
171
|
let isClosed = false;
|
|
160
172
|
let currentSse: EventSource | null = null;
|
|
161
173
|
let interval: ReturnType<typeof setInterval> | null = null;
|
|
174
|
+
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
|
175
|
+
let abortHandler: (() => void) | null = null;
|
|
162
176
|
|
|
163
177
|
const maxReconnectAttempts = 10;
|
|
164
178
|
const baseDelay = 1000; // 1 second base delay
|
|
@@ -172,6 +186,10 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
172
186
|
};
|
|
173
187
|
|
|
174
188
|
const cleanup = () => {
|
|
189
|
+
if (reconnectTimer) {
|
|
190
|
+
clearTimeout(reconnectTimer);
|
|
191
|
+
reconnectTimer = null;
|
|
192
|
+
}
|
|
175
193
|
if (interval) {
|
|
176
194
|
clearInterval(interval);
|
|
177
195
|
interval = null;
|
|
@@ -180,6 +198,10 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
180
198
|
currentSse.close();
|
|
181
199
|
currentSse = null;
|
|
182
200
|
}
|
|
201
|
+
if (signal && abortHandler) {
|
|
202
|
+
signal.removeEventListener('abort', abortHandler);
|
|
203
|
+
abortHandler = null;
|
|
204
|
+
}
|
|
183
205
|
};
|
|
184
206
|
|
|
185
207
|
const exit = (payload: unknown) => {
|
|
@@ -190,6 +212,15 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
190
212
|
}
|
|
191
213
|
};
|
|
192
214
|
|
|
215
|
+
if (signal) {
|
|
216
|
+
if (signal.aborted) {
|
|
217
|
+
exit(null);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
abortHandler = () => exit(null);
|
|
221
|
+
signal.addEventListener('abort', abortHandler, { once: true });
|
|
222
|
+
}
|
|
223
|
+
|
|
193
224
|
// 2. Connect to SSE for real-time updates only (skipHistory=true)
|
|
194
225
|
const setupStream = async (isReconnect: boolean = false) => {
|
|
195
226
|
if (isClosed) return;
|
|
@@ -208,7 +239,10 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
208
239
|
streamUrl.searchParams.set("skipHistory", "true");
|
|
209
240
|
|
|
210
241
|
const bearerToken = client._auth ? await client._auth() : undefined;
|
|
242
|
+
if (isClosed) return;
|
|
211
243
|
if (!bearerToken) {
|
|
244
|
+
isClosed = true;
|
|
245
|
+
cleanup();
|
|
212
246
|
reject(new Error("No auth token available"));
|
|
213
247
|
return;
|
|
214
248
|
}
|
|
@@ -291,7 +325,8 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
291
325
|
console.log(`Attempting to reconnect in ${delay}ms (attempt ${reconnectAttempts + 1}/${maxReconnectAttempts})`);
|
|
292
326
|
|
|
293
327
|
reconnectAttempts++;
|
|
294
|
-
setTimeout(() => {
|
|
328
|
+
reconnectTimer = setTimeout(() => {
|
|
329
|
+
reconnectTimer = null;
|
|
295
330
|
if (!isClosed) {
|
|
296
331
|
setupStream(true);
|
|
297
332
|
}
|
|
@@ -307,7 +342,8 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
307
342
|
if (reconnectAttempts < maxReconnectAttempts) {
|
|
308
343
|
const delay = calculateBackoffDelay(reconnectAttempts);
|
|
309
344
|
reconnectAttempts++;
|
|
310
|
-
setTimeout(() => {
|
|
345
|
+
reconnectTimer = setTimeout(() => {
|
|
346
|
+
reconnectTimer = null;
|
|
311
347
|
if (!isClosed) {
|
|
312
348
|
setupStream(true);
|
|
313
349
|
}
|
|
@@ -332,7 +368,7 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
332
368
|
const streamIsOver = msg.type === AgentMessageType.TERMINATED ||
|
|
333
369
|
(msg.type === AgentMessageType.COMPLETE && workstreamId === 'main');
|
|
334
370
|
if (streamIsOver) {
|
|
335
|
-
|
|
371
|
+
exit(null);
|
|
336
372
|
return;
|
|
337
373
|
}
|
|
338
374
|
}
|
package/src/store/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractFetchClient, RequestError } from "@vertesia/api-fetch-client";
|
|
2
|
-
import { BulkOperationPayload,
|
|
2
|
+
import { BulkOperationPayload, BulkOperationResponse } from "@vertesia/common";
|
|
3
3
|
import { AgentsApi } from "./AgentsApi.js";
|
|
4
4
|
import { CollectionsApi } from "./CollectionsApi.js";
|
|
5
5
|
import { CostApi } from "./CostApi.js";
|
|
@@ -72,7 +72,7 @@ export class ZenoClient extends AbstractFetchClient<ZenoClient> {
|
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
runOperation(payload: BulkOperationPayload): Promise<
|
|
75
|
+
runOperation(payload: BulkOperationPayload): Promise<BulkOperationResponse> {
|
|
76
76
|
return this.post("/api/v1/operations", {
|
|
77
77
|
payload
|
|
78
78
|
});
|