@vertesia/client 0.51.0 → 0.53.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.
- package/lib/cjs/AccountApi.js +11 -1
- package/lib/cjs/AccountApi.js.map +1 -1
- package/lib/cjs/AccountsApi.js +3 -0
- package/lib/cjs/AccountsApi.js.map +1 -1
- package/lib/cjs/InteractionsApi.js +17 -0
- package/lib/cjs/InteractionsApi.js.map +1 -1
- package/lib/cjs/RunsApi.js +33 -8
- package/lib/cjs/RunsApi.js.map +1 -1
- package/lib/cjs/client.js +65 -10
- package/lib/cjs/client.js.map +1 -1
- package/lib/cjs/execute.js +6 -0
- package/lib/cjs/execute.js.map +1 -1
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/nodejs/NodeStreamSource.js +45 -0
- package/lib/cjs/nodejs/NodeStreamSource.js.map +1 -0
- package/lib/cjs/nodejs/index.js +18 -0
- package/lib/cjs/nodejs/index.js.map +1 -0
- package/lib/cjs/store/AnalyzeDocApi.js +25 -6
- package/lib/cjs/store/AnalyzeDocApi.js.map +1 -1
- package/lib/cjs/store/CommandsApi.js +7 -23
- package/lib/cjs/store/CommandsApi.js.map +1 -1
- package/lib/cjs/store/EmbeddingsApi.js +29 -0
- package/lib/cjs/store/EmbeddingsApi.js.map +1 -0
- package/lib/cjs/store/FilesApi.js +6 -0
- package/lib/cjs/store/FilesApi.js.map +1 -1
- package/lib/cjs/store/TypesApi.js +1 -0
- package/lib/cjs/store/TypesApi.js.map +1 -1
- package/lib/cjs/store/WorkflowsApi.js +90 -8
- 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/esm/AccountApi.js +11 -1
- package/lib/esm/AccountApi.js.map +1 -1
- package/lib/esm/AccountsApi.js +3 -0
- package/lib/esm/AccountsApi.js.map +1 -1
- package/lib/esm/InteractionsApi.js +18 -1
- package/lib/esm/InteractionsApi.js.map +1 -1
- package/lib/esm/RunsApi.js +33 -8
- package/lib/esm/RunsApi.js.map +1 -1
- package/lib/esm/client.js +65 -10
- package/lib/esm/client.js.map +1 -1
- package/lib/esm/execute.js +5 -0
- package/lib/esm/execute.js.map +1 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/nodejs/NodeStreamSource.js +41 -0
- package/lib/esm/nodejs/NodeStreamSource.js.map +1 -0
- package/lib/esm/nodejs/index.js +2 -0
- package/lib/esm/nodejs/index.js.map +1 -0
- package/lib/esm/store/AnalyzeDocApi.js +25 -6
- package/lib/esm/store/AnalyzeDocApi.js.map +1 -1
- package/lib/esm/store/CommandsApi.js +6 -21
- package/lib/esm/store/CommandsApi.js.map +1 -1
- package/lib/esm/store/EmbeddingsApi.js +25 -0
- package/lib/esm/store/EmbeddingsApi.js.map +1 -0
- package/lib/esm/store/FilesApi.js +6 -0
- package/lib/esm/store/FilesApi.js.map +1 -1
- package/lib/esm/store/TypesApi.js +1 -0
- package/lib/esm/store/TypesApi.js.map +1 -1
- package/lib/esm/store/WorkflowsApi.js +91 -9
- 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/tsconfig.tsbuildinfo +1 -1
- package/lib/types/AccountApi.d.ts +8 -3
- package/lib/types/AccountApi.d.ts.map +1 -1
- package/lib/types/AccountsApi.d.ts +1 -1
- package/lib/types/AccountsApi.d.ts.map +1 -1
- package/lib/types/AnalyticsApi.d.ts +0 -1
- package/lib/types/ApiKeysApi.d.ts +0 -1
- package/lib/types/CommandsApi.d.ts +0 -1
- package/lib/types/EnvironmentsApi.d.ts +0 -1
- package/lib/types/IamApi.d.ts +0 -1
- package/lib/types/InteractionBase.d.ts +0 -1
- package/lib/types/InteractionsApi.d.ts +17 -3
- package/lib/types/InteractionsApi.d.ts.map +1 -1
- package/lib/types/ProjectsApi.d.ts +0 -1
- package/lib/types/PromptsApi.d.ts +0 -1
- package/lib/types/RefsApi.d.ts +0 -1
- package/lib/types/RunsApi.d.ts +15 -2
- package/lib/types/RunsApi.d.ts.map +1 -1
- package/lib/types/StreamSource.d.ts +0 -1
- package/lib/types/TrainingApi.d.ts +0 -1
- package/lib/types/UsersApi.d.ts +0 -1
- package/lib/types/client.d.ts +20 -5
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/execute.d.ts +7 -4
- package/lib/types/execute.d.ts.map +1 -1
- package/lib/types/index.d.ts +2 -4
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/nodejs/NodeStreamSource.d.ts +9 -0
- package/lib/types/nodejs/NodeStreamSource.d.ts.map +1 -0
- package/lib/types/nodejs/index.d.ts +1 -0
- package/lib/types/nodejs/index.d.ts.map +1 -0
- package/lib/types/store/AgentsApi.d.ts +0 -1
- package/lib/types/store/AnalyzeDocApi.d.ts +4 -4
- package/lib/types/store/AnalyzeDocApi.d.ts.map +1 -1
- package/lib/types/store/CollectionsApi.d.ts +0 -1
- package/lib/types/store/CommandsApi.d.ts +5 -9
- package/lib/types/store/CommandsApi.d.ts.map +1 -1
- package/lib/types/store/EmbeddingsApi.d.ts +12 -0
- package/lib/types/store/EmbeddingsApi.d.ts.map +1 -0
- package/lib/types/store/FilesApi.d.ts +0 -1
- package/lib/types/store/FilesApi.d.ts.map +1 -1
- package/lib/types/store/ObjectsApi.d.ts +0 -1
- package/lib/types/store/TypesApi.d.ts +2 -2
- package/lib/types/store/TypesApi.d.ts.map +1 -1
- package/lib/types/store/WorkflowsApi.d.ts +16 -9
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -1
- package/lib/types/store/client.d.ts +2 -1
- package/lib/types/store/client.d.ts.map +1 -1
- package/lib/types/store/errors.d.ts +0 -1
- package/lib/types/store/index.d.ts +0 -1
- package/package.json +25 -10
- package/src/AccountApi.ts +14 -2
- package/src/AccountsApi.ts +4 -0
- package/src/InteractionsApi.ts +25 -3
- package/src/RunsApi.ts +67 -30
- package/src/client.test.ts +94 -0
- package/src/client.ts +84 -13
- package/src/execute.ts +9 -3
- package/src/index.ts +2 -3
- package/src/nodejs/NodeStreamSource.ts +43 -0
- package/src/nodejs/index.ts +1 -0
- package/src/store/AnalyzeDocApi.ts +29 -9
- package/src/store/CommandsApi.ts +6 -33
- package/src/store/EmbeddingsApi.ts +39 -0
- package/src/store/FilesApi.ts +4 -0
- package/src/store/TypesApi.ts +2 -1
- package/src/store/WorkflowsApi.ts +127 -25
- package/src/store/client.ts +2 -0
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import { ApiTopic, ClientBase } from
|
|
2
|
-
import {
|
|
1
|
+
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
+
import {
|
|
3
|
+
ActivityCatalog,
|
|
4
|
+
AgentMessage,
|
|
5
|
+
AgentMessageType,
|
|
6
|
+
CreateWorkflowRulePayload,
|
|
7
|
+
DSLWorkflowDefinition,
|
|
8
|
+
DSLWorkflowSpec,
|
|
9
|
+
ExecuteWorkflowPayload,
|
|
10
|
+
ListWorkflowRunsPayload,
|
|
11
|
+
ListWorkflowRunsResponse,
|
|
12
|
+
WorkflowDefinitionRef,
|
|
13
|
+
WorkflowRule,
|
|
14
|
+
WorkflowRuleItem,
|
|
15
|
+
WorkflowRunWithDetails,
|
|
16
|
+
} from "@vertesia/common";
|
|
17
|
+
import { VertesiaClient } from "../client.js";
|
|
18
|
+
import { EventSourceProvider } from "../execute.js";
|
|
3
19
|
|
|
4
20
|
export class WorkflowsApi extends ApiTopic {
|
|
5
|
-
|
|
6
21
|
constructor(parent: ClientBase) {
|
|
7
22
|
super(parent, "/api/v1/workflows");
|
|
8
23
|
}
|
|
@@ -19,53 +34,142 @@ export class WorkflowsApi extends ApiTopic {
|
|
|
19
34
|
return this.post(`/runs`, { payload: payload });
|
|
20
35
|
}
|
|
21
36
|
|
|
37
|
+
sendSignal(workflowId: string, runId: string, signal: string, payload?: any): Promise<{ message: string }> {
|
|
38
|
+
return this.post(`/runs/${workflowId}/${runId}/signal/${signal}`, { payload });
|
|
39
|
+
}
|
|
40
|
+
|
|
22
41
|
getRunDetails(runId: string, workflowId: string): Promise<WorkflowRunWithDetails> {
|
|
23
|
-
return this.get(`/runs/${workflowId}/${runId}
|
|
42
|
+
return this.get(`/runs/${workflowId}/${runId}`);
|
|
24
43
|
}
|
|
25
44
|
|
|
26
45
|
terminate(workflowId: string, runId: string, reason?: string): Promise<{ message: string }> {
|
|
27
|
-
return this.post(`/runs/${workflowId}/${runId}/terminate`, { payload: { reason } });
|
|
46
|
+
return this.post(`/runs/${workflowId}/${runId}/actions/terminate`, { payload: { reason } });
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
cancel(workflowId: string, runId: string, reason?: string): Promise<{ message: string }> {
|
|
31
|
-
return this.post(`/runs/${workflowId}/${runId}/cancel`, { payload: { reason } });
|
|
50
|
+
return this.post(`/runs/${workflowId}/${runId}/actions/cancel`, { payload: { reason } });
|
|
32
51
|
}
|
|
33
52
|
|
|
34
|
-
execute(
|
|
53
|
+
execute(
|
|
54
|
+
name: string,
|
|
55
|
+
payload: ExecuteWorkflowPayload = {},
|
|
56
|
+
): Promise<({ run_id: string; workflow_id: string } | undefined)[]> {
|
|
35
57
|
return this.post(`/execute/${name}`, { payload });
|
|
36
58
|
}
|
|
37
59
|
|
|
60
|
+
postMessage(runId: string, message: string, type?: AgentMessageType, details?: any): Promise<void> {
|
|
61
|
+
if (!runId) {
|
|
62
|
+
throw new Error("runId is required");
|
|
63
|
+
}
|
|
64
|
+
const payload = {
|
|
65
|
+
message,
|
|
66
|
+
type,
|
|
67
|
+
details,
|
|
68
|
+
};
|
|
69
|
+
return this.post(`/runs/${runId}/updates`, { payload });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
retrieveMessages(runId: string, since?: number): Promise<AgentMessage[]> {
|
|
73
|
+
const query = {
|
|
74
|
+
since,
|
|
75
|
+
};
|
|
76
|
+
return this.get(`/runs/${runId}/updates`, { query });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
streamMessages(runId: string, onMessage?: (message: AgentMessage) => void, since?: number): Promise<void> {
|
|
80
|
+
return new Promise(async (resolve, reject) => {
|
|
81
|
+
try {
|
|
82
|
+
const EventSourceImpl = await EventSourceProvider();
|
|
83
|
+
const client = this.client as VertesiaClient;
|
|
84
|
+
const streamUrl = new URL(client.workflows.baseUrl + "/runs/" + runId + "/stream");
|
|
85
|
+
|
|
86
|
+
if (since) {
|
|
87
|
+
streamUrl.searchParams.set("since", since.toString());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const bearerToken = client._auth ? await client._auth() : undefined;
|
|
91
|
+
if (!bearerToken) return reject(new Error("No auth token available"));
|
|
92
|
+
|
|
93
|
+
const token = bearerToken.split(" ")[1];
|
|
94
|
+
streamUrl.searchParams.set("access_token", token);
|
|
95
|
+
|
|
96
|
+
const sse = new EventSourceImpl(streamUrl.href);
|
|
97
|
+
let isClosed = false;
|
|
98
|
+
|
|
99
|
+
sse.onmessage = (ev: MessageEvent) => {
|
|
100
|
+
if (!ev.data || ev.data.startsWith(":")) {
|
|
101
|
+
console.log("Received comment or heartbeat; ignoring it.: ", ev.data);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const message = JSON.parse(ev.data) as AgentMessage;
|
|
107
|
+
if (onMessage) onMessage(message);
|
|
108
|
+
|
|
109
|
+
if (message.type === AgentMessageType.COMPLETE) {
|
|
110
|
+
sse.close();
|
|
111
|
+
isClosed = true;
|
|
112
|
+
resolve();
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
console.error("Failed to parse SSE message:", err, ev.data);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
sse.onerror = (err: any) => {
|
|
120
|
+
if (!isClosed) {
|
|
121
|
+
console.error("SSE stream error:", err);
|
|
122
|
+
sse.close();
|
|
123
|
+
reject(err);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Prevent Node from exiting prematurely
|
|
128
|
+
const interval = setInterval(() => { }, 1000);
|
|
129
|
+
|
|
130
|
+
// Cleanup when stream resolves
|
|
131
|
+
const cleanup = () => {
|
|
132
|
+
clearInterval(interval);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// Attach cleanup
|
|
136
|
+
sse.addEventListener("close", () => {
|
|
137
|
+
isClosed = true;
|
|
138
|
+
cleanup();
|
|
139
|
+
resolve();
|
|
140
|
+
});
|
|
141
|
+
} catch (err) {
|
|
142
|
+
reject(err);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
38
147
|
rules = new WorkflowsRulesApi(this);
|
|
39
148
|
definitions = new WorkflowsDefinitionApi(this);
|
|
40
|
-
|
|
41
149
|
}
|
|
42
150
|
|
|
43
|
-
|
|
44
151
|
export class WorkflowsRulesApi extends ApiTopic {
|
|
45
|
-
|
|
46
152
|
constructor(parent: WorkflowsApi) {
|
|
47
153
|
super(parent, "/rules");
|
|
48
154
|
}
|
|
49
155
|
|
|
50
|
-
|
|
51
156
|
list(): Promise<WorkflowRuleItem[]> {
|
|
52
157
|
return this.get("/");
|
|
53
158
|
}
|
|
54
159
|
|
|
55
|
-
|
|
56
160
|
retrieve(id: string): Promise<WorkflowRule> {
|
|
57
161
|
return this.get(`/${id}`);
|
|
58
162
|
}
|
|
59
163
|
|
|
60
164
|
update(id: string, payload: any): Promise<WorkflowRule> {
|
|
61
165
|
return this.put(`/${id}`, {
|
|
62
|
-
payload
|
|
166
|
+
payload,
|
|
63
167
|
});
|
|
64
168
|
}
|
|
65
169
|
|
|
66
170
|
create(payload: CreateWorkflowRulePayload): Promise<WorkflowRule> {
|
|
67
171
|
return this.post("/", {
|
|
68
|
-
payload
|
|
172
|
+
payload,
|
|
69
173
|
});
|
|
70
174
|
}
|
|
71
175
|
|
|
@@ -73,19 +177,20 @@ export class WorkflowsRulesApi extends ApiTopic {
|
|
|
73
177
|
return this.del(`/${id}`);
|
|
74
178
|
}
|
|
75
179
|
|
|
76
|
-
|
|
77
|
-
|
|
180
|
+
execute(
|
|
181
|
+
id: string,
|
|
182
|
+
objectIds?: string[],
|
|
183
|
+
vars?: Record<string, any>,
|
|
184
|
+
): Promise<({ run_id: string; workflow_id: string } | undefined)[]> {
|
|
78
185
|
const payload: ExecuteWorkflowPayload = {
|
|
79
186
|
objectIds,
|
|
80
|
-
vars
|
|
187
|
+
vars,
|
|
81
188
|
};
|
|
82
189
|
return this.post(`/${id}/execute`, { payload });
|
|
83
190
|
}
|
|
84
|
-
|
|
85
191
|
}
|
|
86
192
|
|
|
87
193
|
export class WorkflowsDefinitionApi extends ApiTopic {
|
|
88
|
-
|
|
89
194
|
//model: DSLWorkflowDefinition;
|
|
90
195
|
|
|
91
196
|
constructor(parent: WorkflowsApi) {
|
|
@@ -96,26 +201,23 @@ export class WorkflowsDefinitionApi extends ApiTopic {
|
|
|
96
201
|
return this.get("/");
|
|
97
202
|
}
|
|
98
203
|
|
|
99
|
-
|
|
100
204
|
retrieve(id: string): Promise<DSLWorkflowDefinition> {
|
|
101
205
|
return this.get(`/${id}`);
|
|
102
206
|
}
|
|
103
207
|
|
|
104
208
|
update(id: string, payload: any): Promise<DSLWorkflowDefinition> {
|
|
105
209
|
return this.put(`/${id}`, {
|
|
106
|
-
payload
|
|
210
|
+
payload,
|
|
107
211
|
});
|
|
108
212
|
}
|
|
109
213
|
|
|
110
214
|
create(payload: DSLWorkflowSpec): Promise<DSLWorkflowDefinition> {
|
|
111
215
|
return this.post("/", {
|
|
112
|
-
payload
|
|
216
|
+
payload,
|
|
113
217
|
});
|
|
114
218
|
}
|
|
115
219
|
|
|
116
220
|
delete(id: string) {
|
|
117
221
|
return this.del(`/${id}`);
|
|
118
222
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
223
|
+
}
|
package/src/store/client.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { AbstractFetchClient, RequestError } from "@vertesia/api-fetch-client";
|
|
|
2
2
|
import { BulkOperationPayload, BulkOperationResult } from "@vertesia/common";
|
|
3
3
|
import { AgentsApi } from "./AgentsApi.js";
|
|
4
4
|
import { CommandsApi } from "./CommandsApi.js";
|
|
5
|
+
import { EmbeddingsApi } from "./EmbeddingsApi.js";
|
|
5
6
|
import { ZenoClientNotFoundError } from "./errors.js";
|
|
6
7
|
import { FilesApi } from "./FilesApi.js";
|
|
7
8
|
import { ObjectsApi } from "./ObjectsApi.js";
|
|
@@ -62,4 +63,5 @@ export class ZenoClient extends AbstractFetchClient<ZenoClient> {
|
|
|
62
63
|
commands = new CommandsApi(this);
|
|
63
64
|
agents = new AgentsApi(this);
|
|
64
65
|
collections = new CollectionsApi(this);
|
|
66
|
+
embeddings = new EmbeddingsApi(this);
|
|
65
67
|
}
|