roe-typescript 0.1.2 → 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.
- package/README.md +48 -7
- package/dist/api/agents.d.ts +40 -27
- package/dist/api/agents.js +222 -112
- package/dist/api/policies.d.ts +15 -9
- package/dist/api/policies.js +75 -31
- package/dist/api/users.d.ts +18 -0
- package/dist/api/users.js +17 -0
- package/dist/client.d.ts +6 -2
- package/dist/client.js +17 -5
- package/dist/exceptions.js +8 -0
- package/dist/generated/client.d.ts +12 -0
- package/dist/generated/client.js +55 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +9 -5
- package/dist/models/file.d.ts +17 -0
- package/dist/models/file.js +36 -0
- package/dist/models/job.d.ts +30 -6
- package/dist/models/job.js +130 -37
- package/dist/utils/dynamicInputs.d.ts +30 -0
- package/dist/utils/dynamicInputs.js +114 -0
- package/dist/utils/middleware.d.ts +6 -0
- package/dist/utils/middleware.js +80 -0
- package/package.json +6 -6
- package/dist/models/agent.d.ts +0 -78
- package/dist/models/agent.js +0 -40
- package/dist/models/policy.d.ts +0 -19
- package/dist/models/policy.js +0 -1
- package/dist/models/responses.d.ts +0 -71
- package/dist/models/responses.js +0 -36
- package/dist/models/user.d.ts +0 -6
- package/dist/models/user.js +0 -1
- package/dist/utils/httpClient.d.ts +0 -30
- package/dist/utils/httpClient.js +0 -229
package/dist/api/agents.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { PaginationHelper } from "../utils/pagination.js";
|
|
2
1
|
import { isUuidString } from "../utils/fileDetection.js";
|
|
2
|
+
import { postDynamicInputs } from "../utils/dynamicInputs.js";
|
|
3
3
|
import { BadRequestError, RoeAPIException } from "../exceptions.js";
|
|
4
|
-
import { AgentVersionWithApi, BaseAgentWithApi, } from "../models/agent.js";
|
|
5
4
|
import { Job, JobBatch } from "../models/job.js";
|
|
6
|
-
/**
|
|
7
|
-
* Validates that a value is a valid UUID string.
|
|
8
|
-
* @throws BadRequestError if the value is not a valid UUID
|
|
9
|
-
*/
|
|
10
5
|
function validateUuid(value, fieldName) {
|
|
11
6
|
if (!isUuidString(value)) {
|
|
12
7
|
throw new BadRequestError(`Invalid ${fieldName}: "${value}" is not a valid UUID`, 400);
|
|
@@ -16,88 +11,137 @@ export class AgentVersionsAPI {
|
|
|
16
11
|
constructor(agentsApi) {
|
|
17
12
|
this.agentsApi = agentsApi;
|
|
18
13
|
}
|
|
19
|
-
get
|
|
20
|
-
return this.agentsApi.
|
|
14
|
+
get raw() {
|
|
15
|
+
return this.agentsApi.raw;
|
|
16
|
+
}
|
|
17
|
+
get organizationId() {
|
|
18
|
+
return this.agentsApi.config.organizationId;
|
|
21
19
|
}
|
|
22
20
|
async list(agentId) {
|
|
23
21
|
validateUuid(agentId, "agentId");
|
|
24
|
-
const data = await this.
|
|
25
|
-
|
|
22
|
+
const { data } = await this.raw.GET("/v1/agents/{agent_id}/versions/", {
|
|
23
|
+
params: {
|
|
24
|
+
path: { agent_id: agentId },
|
|
25
|
+
query: { organization_id: this.organizationId },
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return (data ?? []);
|
|
26
29
|
}
|
|
27
30
|
async retrieve(agentId, versionId, getSupportsEval) {
|
|
28
31
|
validateUuid(agentId, "agentId");
|
|
29
32
|
validateUuid(versionId, "versionId");
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const query = { organization_id: this.organizationId };
|
|
34
|
+
if (getSupportsEval !== undefined)
|
|
35
|
+
query.get_supports_eval = String(getSupportsEval).toLowerCase();
|
|
36
|
+
const { data } = await this.raw.GET("/v1/agents/{agent_id}/versions/{agent_version_id}/", {
|
|
37
|
+
params: {
|
|
38
|
+
path: { agent_id: agentId, agent_version_id: versionId },
|
|
39
|
+
query: query,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return data;
|
|
33
43
|
}
|
|
34
44
|
async retrieveCurrent(agentId) {
|
|
35
45
|
validateUuid(agentId, "agentId");
|
|
36
|
-
const data = await this.
|
|
37
|
-
|
|
46
|
+
const { data } = await this.raw.GET("/v1/agents/{agent_id}/versions/current/", {
|
|
47
|
+
params: {
|
|
48
|
+
path: { agent_id: agentId },
|
|
49
|
+
query: { organization_id: this.organizationId },
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return data;
|
|
38
53
|
}
|
|
39
54
|
async create(params) {
|
|
40
55
|
validateUuid(params.agentId, "agentId");
|
|
41
|
-
const
|
|
42
|
-
input_definitions: params.inputDefinitions ?? [],
|
|
43
|
-
engine_config: params.engineConfig ?? {},
|
|
56
|
+
const body = {
|
|
57
|
+
input_definitions: (params.inputDefinitions ?? []),
|
|
58
|
+
engine_config: (params.engineConfig ?? {}),
|
|
44
59
|
};
|
|
45
60
|
if (params.versionName !== undefined)
|
|
46
|
-
|
|
61
|
+
body.version_name = params.versionName;
|
|
47
62
|
if (params.description !== undefined)
|
|
48
|
-
|
|
49
|
-
const data = await this.
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
body.description = params.description;
|
|
64
|
+
const { data } = await this.raw.POST("/v1/agents/{agent_id}/versions/", {
|
|
65
|
+
params: {
|
|
66
|
+
path: { agent_id: params.agentId },
|
|
67
|
+
query: { organization_id: this.organizationId },
|
|
68
|
+
},
|
|
69
|
+
body,
|
|
52
70
|
});
|
|
71
|
+
if (!data?.id) {
|
|
72
|
+
throw new RoeAPIException(`Unexpected response from server: ${JSON.stringify(data)}`);
|
|
73
|
+
}
|
|
74
|
+
// POST returns a partial create payload; re-fetch to get the full version.
|
|
53
75
|
return this.retrieve(params.agentId, data.id);
|
|
54
76
|
}
|
|
55
77
|
async update(agentId, versionId, updates) {
|
|
56
78
|
validateUuid(agentId, "agentId");
|
|
57
79
|
validateUuid(versionId, "versionId");
|
|
58
|
-
const
|
|
80
|
+
const body = {};
|
|
59
81
|
if (updates.versionName !== undefined)
|
|
60
|
-
|
|
82
|
+
body.version_name = updates.versionName;
|
|
61
83
|
if (updates.description !== undefined)
|
|
62
|
-
|
|
63
|
-
await this.
|
|
84
|
+
body.description = updates.description;
|
|
85
|
+
await this.raw.PATCH("/v1/agents/{agent_id}/versions/{agent_version_id}/", {
|
|
86
|
+
params: {
|
|
87
|
+
path: { agent_id: agentId, agent_version_id: versionId },
|
|
88
|
+
query: { organization_id: this.organizationId },
|
|
89
|
+
},
|
|
90
|
+
body,
|
|
91
|
+
});
|
|
64
92
|
}
|
|
65
93
|
async delete(agentId, versionId) {
|
|
66
94
|
validateUuid(agentId, "agentId");
|
|
67
95
|
validateUuid(versionId, "versionId");
|
|
68
|
-
await this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
96
|
+
await this.raw.DELETE("/v1/agents/{agent_id}/versions/{agent_version_id}/", {
|
|
97
|
+
params: {
|
|
98
|
+
path: { agent_id: agentId, agent_version_id: versionId },
|
|
99
|
+
query: { organization_id: this.organizationId },
|
|
100
|
+
},
|
|
101
|
+
});
|
|
74
102
|
}
|
|
75
103
|
}
|
|
76
104
|
export class AgentJobsAPI {
|
|
77
105
|
constructor(agentsApi) {
|
|
78
106
|
this.agentsApi = agentsApi;
|
|
79
107
|
}
|
|
80
|
-
get
|
|
81
|
-
return this.agentsApi.
|
|
108
|
+
get raw() {
|
|
109
|
+
return this.agentsApi.raw;
|
|
110
|
+
}
|
|
111
|
+
get organizationId() {
|
|
112
|
+
return this.agentsApi.config.organizationId;
|
|
82
113
|
}
|
|
83
114
|
async retrieveStatus(jobId) {
|
|
84
115
|
validateUuid(jobId, "jobId");
|
|
85
|
-
|
|
116
|
+
const { data } = await this.raw.GET("/v1/agents/jobs/{job_id}/status/", {
|
|
117
|
+
params: {
|
|
118
|
+
path: { job_id: jobId },
|
|
119
|
+
query: { organization_id: this.organizationId },
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
return data;
|
|
86
123
|
}
|
|
87
124
|
async retrieveResult(jobId) {
|
|
88
125
|
validateUuid(jobId, "jobId");
|
|
89
|
-
|
|
126
|
+
const { data } = await this.raw.GET("/v1/agents/jobs/{agent_job_id}/result/", {
|
|
127
|
+
params: {
|
|
128
|
+
path: { agent_job_id: jobId },
|
|
129
|
+
query: { organization_id: this.organizationId },
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
return data;
|
|
90
133
|
}
|
|
91
134
|
async retrieveStatusMany(jobIds) {
|
|
92
135
|
const results = [];
|
|
93
136
|
for (const chunk of this.iterChunks(jobIds, AgentJobsAPI.MAX_BATCH_SIZE)) {
|
|
94
137
|
if (!chunk.length)
|
|
95
138
|
continue;
|
|
96
|
-
const data = await this.
|
|
97
|
-
|
|
98
|
-
|
|
139
|
+
const { data } = await this.raw.POST("/v1/agents/jobs/statuses/", {
|
|
140
|
+
params: { query: { organization_id: this.organizationId } },
|
|
141
|
+
body: { job_ids: chunk },
|
|
99
142
|
});
|
|
100
|
-
|
|
143
|
+
if (data)
|
|
144
|
+
results.push(...data);
|
|
101
145
|
}
|
|
102
146
|
return results;
|
|
103
147
|
}
|
|
@@ -106,25 +150,64 @@ export class AgentJobsAPI {
|
|
|
106
150
|
for (const chunk of this.iterChunks(jobIds, AgentJobsAPI.MAX_BATCH_SIZE)) {
|
|
107
151
|
if (!chunk.length)
|
|
108
152
|
continue;
|
|
109
|
-
const data = await this.
|
|
110
|
-
|
|
111
|
-
|
|
153
|
+
const { data } = await this.raw.POST("/v1/agents/jobs/results/", {
|
|
154
|
+
params: { query: { organization_id: this.organizationId } },
|
|
155
|
+
body: { job_ids: chunk },
|
|
112
156
|
});
|
|
113
|
-
|
|
157
|
+
if (Array.isArray(data)) {
|
|
158
|
+
results.push(...data);
|
|
159
|
+
}
|
|
160
|
+
else if (data?.results) {
|
|
161
|
+
results.push(...data.results);
|
|
162
|
+
}
|
|
114
163
|
}
|
|
115
164
|
return results;
|
|
116
165
|
}
|
|
117
166
|
async downloadReference(jobId, resourceId, asAttachment = false) {
|
|
118
167
|
validateUuid(jobId, "jobId");
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
168
|
+
// The endpoint streams binary; openapi-fetch's typed GET expects a JSON
|
|
169
|
+
// response per the spec, so we use parseAs:"arrayBuffer" to skip JSON
|
|
170
|
+
// parsing and read raw bytes.
|
|
171
|
+
const query = { organization_id: this.organizationId };
|
|
172
|
+
if (asAttachment)
|
|
173
|
+
query.download = "true";
|
|
174
|
+
const result = await this.raw.GET("/v1/agents/jobs/{agent_job_id}/references/{resource_id}/", {
|
|
175
|
+
params: {
|
|
176
|
+
path: { agent_job_id: jobId, resource_id: resourceId },
|
|
177
|
+
query,
|
|
178
|
+
},
|
|
179
|
+
parseAs: "arrayBuffer",
|
|
180
|
+
});
|
|
181
|
+
const buf = result.data ?? new ArrayBuffer(0);
|
|
182
|
+
return Buffer.from(buf);
|
|
183
|
+
}
|
|
184
|
+
async cancel(jobId) {
|
|
185
|
+
validateUuid(jobId, "jobId");
|
|
186
|
+
await this.raw.POST("/v1/agents/jobs/{job_id}/cancel/", {
|
|
187
|
+
params: {
|
|
188
|
+
path: { job_id: jobId },
|
|
189
|
+
query: { organization_id: this.organizationId },
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async cancelAll(agentId) {
|
|
194
|
+
validateUuid(agentId, "agentId");
|
|
195
|
+
await this.raw.POST("/v1/agents/{agent_id}/jobs/cancel-all/", {
|
|
196
|
+
params: {
|
|
197
|
+
path: { agent_id: agentId },
|
|
198
|
+
query: { organization_id: this.organizationId },
|
|
199
|
+
},
|
|
200
|
+
});
|
|
122
201
|
}
|
|
123
202
|
async deleteData(jobId) {
|
|
124
203
|
validateUuid(jobId, "jobId");
|
|
125
|
-
|
|
126
|
-
|
|
204
|
+
const { data } = await this.raw.POST("/v1/agents/jobs/{job_id}/delete-data/", {
|
|
205
|
+
params: {
|
|
206
|
+
path: { job_id: jobId },
|
|
207
|
+
query: { organization_id: this.organizationId },
|
|
208
|
+
},
|
|
127
209
|
});
|
|
210
|
+
return data;
|
|
128
211
|
}
|
|
129
212
|
*iterChunks(items, size) {
|
|
130
213
|
for (let i = 0; i < items.length; i += size) {
|
|
@@ -134,77 +217,93 @@ export class AgentJobsAPI {
|
|
|
134
217
|
}
|
|
135
218
|
AgentJobsAPI.MAX_BATCH_SIZE = 1000;
|
|
136
219
|
export class AgentsAPI {
|
|
137
|
-
constructor(config,
|
|
220
|
+
constructor(config, raw) {
|
|
138
221
|
this.config = config;
|
|
139
|
-
this.
|
|
222
|
+
this.raw = raw;
|
|
140
223
|
this.versions = new AgentVersionsAPI(this);
|
|
141
224
|
this.jobs = new AgentJobsAPI(this);
|
|
142
225
|
}
|
|
143
|
-
wrapBase(data) {
|
|
144
|
-
const obj = new BaseAgentWithApi(data);
|
|
145
|
-
obj.setAgentsApi(this);
|
|
146
|
-
return obj;
|
|
147
|
-
}
|
|
148
226
|
async list(params) {
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
227
|
+
const { data } = await this.raw.GET("/v1/agents/", {
|
|
228
|
+
params: {
|
|
229
|
+
query: {
|
|
230
|
+
organization_id: this.config.organizationId,
|
|
231
|
+
page: params?.page,
|
|
232
|
+
page_size: params?.pageSize,
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
return data;
|
|
153
237
|
}
|
|
154
238
|
async retrieve(agentId) {
|
|
155
239
|
validateUuid(agentId, "agentId");
|
|
156
|
-
const data = await this.
|
|
157
|
-
|
|
240
|
+
const { data } = await this.raw.GET("/v1/agents/{agent_id}/", {
|
|
241
|
+
params: {
|
|
242
|
+
path: { agent_id: agentId },
|
|
243
|
+
query: { organization_id: this.config.organizationId },
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
return data;
|
|
158
247
|
}
|
|
159
248
|
async create(params) {
|
|
160
|
-
const
|
|
249
|
+
const body = {
|
|
161
250
|
name: params.name,
|
|
162
251
|
engine_class_id: params.engineClassId,
|
|
163
252
|
organization_id: this.config.organizationId,
|
|
164
|
-
input_definitions: params.inputDefinitions ?? [],
|
|
165
|
-
engine_config: params.engineConfig ?? {},
|
|
253
|
+
input_definitions: (params.inputDefinitions ?? []),
|
|
254
|
+
engine_config: (params.engineConfig ?? {}),
|
|
166
255
|
};
|
|
167
256
|
if (params.versionName !== undefined)
|
|
168
|
-
|
|
257
|
+
body.version_name = params.versionName;
|
|
169
258
|
if (params.description !== undefined)
|
|
170
|
-
|
|
171
|
-
const data = await this.
|
|
172
|
-
|
|
259
|
+
body.description = params.description;
|
|
260
|
+
const { data } = await this.raw.POST("/v1/agents/", {
|
|
261
|
+
params: { query: { organization_id: this.config.organizationId } },
|
|
262
|
+
body,
|
|
263
|
+
});
|
|
264
|
+
return data;
|
|
173
265
|
}
|
|
174
266
|
async update(agentId, updates) {
|
|
175
267
|
validateUuid(agentId, "agentId");
|
|
176
|
-
const
|
|
268
|
+
const body = {};
|
|
177
269
|
if (updates.name !== undefined)
|
|
178
|
-
|
|
270
|
+
body.name = updates.name;
|
|
179
271
|
if (updates.disableCache !== undefined)
|
|
180
|
-
|
|
272
|
+
body.disable_cache = updates.disableCache;
|
|
181
273
|
if (updates.cacheFailedJobs !== undefined)
|
|
182
|
-
|
|
183
|
-
const data = await this.
|
|
184
|
-
|
|
274
|
+
body.cache_failed_jobs = updates.cacheFailedJobs;
|
|
275
|
+
const { data } = await this.raw.PATCH("/v1/agents/{agent_id}/", {
|
|
276
|
+
params: {
|
|
277
|
+
path: { agent_id: agentId },
|
|
278
|
+
query: { organization_id: this.config.organizationId },
|
|
279
|
+
},
|
|
280
|
+
body,
|
|
281
|
+
});
|
|
282
|
+
return data;
|
|
185
283
|
}
|
|
186
284
|
async delete(agentId) {
|
|
187
285
|
validateUuid(agentId, "agentId");
|
|
188
|
-
await this.
|
|
286
|
+
await this.raw.DELETE("/v1/agents/{agent_id}/", {
|
|
287
|
+
params: {
|
|
288
|
+
path: { agent_id: agentId },
|
|
289
|
+
query: { organization_id: this.config.organizationId },
|
|
290
|
+
},
|
|
291
|
+
});
|
|
189
292
|
}
|
|
190
293
|
async duplicate(agentId) {
|
|
191
294
|
validateUuid(agentId, "agentId");
|
|
192
|
-
const data = await this.
|
|
193
|
-
|
|
295
|
+
const { data } = await this.raw.POST("/v1/agents/{agent_id}/duplicate/", {
|
|
296
|
+
params: {
|
|
297
|
+
path: { agent_id: agentId },
|
|
298
|
+
query: { organization_id: this.config.organizationId },
|
|
299
|
+
},
|
|
194
300
|
});
|
|
195
|
-
return
|
|
301
|
+
return data;
|
|
196
302
|
}
|
|
197
303
|
async run(params) {
|
|
198
304
|
validateUuid(params.agentId, "agentId");
|
|
199
|
-
const response = await this.
|
|
200
|
-
|
|
201
|
-
const jobId = typeof response === "string" ? response : response?.job_id;
|
|
202
|
-
if (!jobId || typeof jobId !== "string") {
|
|
203
|
-
throw new RoeAPIException(`Invalid job ID returned from API: ${JSON.stringify(response)}`);
|
|
204
|
-
}
|
|
205
|
-
if (!isUuidString(jobId)) {
|
|
206
|
-
throw new RoeAPIException(`Invalid job ID format returned from API: ${jobId}`);
|
|
207
|
-
}
|
|
305
|
+
const response = await postDynamicInputs(this.raw, "/v1/agents/run/{agent_id}/async/", { agent_id: params.agentId }, { organization_id: this.config.organizationId }, params.inputs, params.metadata, this.config.maxRetries);
|
|
306
|
+
const jobId = this.extractJobId(response);
|
|
208
307
|
return new Job({ agentsApi: this, jobId, timeoutSeconds: params.timeoutSeconds });
|
|
209
308
|
}
|
|
210
309
|
async runMany(params) {
|
|
@@ -213,46 +312,57 @@ export class AgentsAPI {
|
|
|
213
312
|
for (const chunk of this.iterChunks(params.batchInputs, AgentsAPI.MAX_BATCH_SIZE)) {
|
|
214
313
|
if (!chunk.length)
|
|
215
314
|
continue;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
315
|
+
// Generated request type only models { inputs }, but the backend also
|
|
316
|
+
// accepts a sibling `metadata` field — attach it via a serializer cast.
|
|
317
|
+
const body = { inputs: chunk };
|
|
318
|
+
if (params.metadata !== undefined)
|
|
319
|
+
body.metadata = params.metadata;
|
|
320
|
+
const { data } = await this.raw.POST("/v1/agents/run/{agent_id}/async/many/", {
|
|
321
|
+
params: {
|
|
322
|
+
path: { agent_id: params.agentId },
|
|
323
|
+
query: { organization_id: this.config.organizationId },
|
|
324
|
+
},
|
|
325
|
+
body: body,
|
|
219
326
|
});
|
|
220
|
-
|
|
221
|
-
for (const jobId of
|
|
222
|
-
if (
|
|
327
|
+
const ids = Array.isArray(data) ? data : [];
|
|
328
|
+
for (const jobId of ids) {
|
|
329
|
+
if (typeof jobId !== "string" || !isUuidString(jobId)) {
|
|
223
330
|
throw new RoeAPIException(`Invalid job ID returned from batch API: ${JSON.stringify(jobId)}`);
|
|
224
331
|
}
|
|
225
|
-
if (!isUuidString(jobId)) {
|
|
226
|
-
throw new RoeAPIException(`Invalid job ID format returned from batch API: ${jobId}`);
|
|
227
|
-
}
|
|
228
332
|
allJobIds.push(jobId);
|
|
229
333
|
}
|
|
230
334
|
}
|
|
231
335
|
return new JobBatch({ agentsApi: this, jobIds: allJobIds, timeoutSeconds: params.timeoutSeconds });
|
|
232
336
|
}
|
|
233
|
-
async runSync(agentId, inputs) {
|
|
337
|
+
async runSync(agentId, inputs, metadata) {
|
|
234
338
|
validateUuid(agentId, "agentId");
|
|
235
|
-
|
|
236
|
-
return resp;
|
|
339
|
+
return postDynamicInputs(this.raw, "/v1/agents/run/{agent_id}/", { agent_id: agentId }, { organization_id: this.config.organizationId }, inputs, metadata, this.config.maxRetries);
|
|
237
340
|
}
|
|
238
341
|
async runVersion(params) {
|
|
239
342
|
validateUuid(params.agentId, "agentId");
|
|
240
343
|
validateUuid(params.versionId, "versionId");
|
|
241
|
-
const response = await this.
|
|
242
|
-
|
|
243
|
-
const jobId = typeof response === "string" ? response : response?.job_id;
|
|
244
|
-
if (!jobId || typeof jobId !== "string") {
|
|
245
|
-
throw new RoeAPIException(`Invalid job ID returned from API: ${JSON.stringify(response)}`);
|
|
246
|
-
}
|
|
247
|
-
if (!isUuidString(jobId)) {
|
|
248
|
-
throw new RoeAPIException(`Invalid job ID format returned from API: ${jobId}`);
|
|
249
|
-
}
|
|
344
|
+
const response = await postDynamicInputs(this.raw, "/v1/agents/run/{agent_id}/versions/{agent_version_id}/async/", { agent_id: params.agentId, agent_version_id: params.versionId }, { organization_id: this.config.organizationId }, params.inputs, params.metadata, this.config.maxRetries);
|
|
345
|
+
const jobId = this.extractJobId(response);
|
|
250
346
|
return new Job({ agentsApi: this, jobId, timeoutSeconds: params.timeoutSeconds });
|
|
251
347
|
}
|
|
252
|
-
async runVersionSync(agentId, versionId, inputs) {
|
|
348
|
+
async runVersionSync(agentId, versionId, inputs, metadata) {
|
|
253
349
|
validateUuid(agentId, "agentId");
|
|
254
350
|
validateUuid(versionId, "versionId");
|
|
255
|
-
return this.
|
|
351
|
+
return postDynamicInputs(this.raw, "/v1/agents/run/{agent_id}/versions/{agent_version_id}/", { agent_id: agentId, agent_version_id: versionId }, { organization_id: this.config.organizationId }, inputs, metadata, this.config.maxRetries);
|
|
352
|
+
}
|
|
353
|
+
extractJobId(response) {
|
|
354
|
+
let jobId;
|
|
355
|
+
if (typeof response === "string") {
|
|
356
|
+
jobId = response;
|
|
357
|
+
}
|
|
358
|
+
else if (response && typeof response === "object") {
|
|
359
|
+
const obj = response;
|
|
360
|
+
jobId = obj.job_id ?? obj.id;
|
|
361
|
+
}
|
|
362
|
+
if (typeof jobId !== "string" || !isUuidString(jobId)) {
|
|
363
|
+
throw new RoeAPIException(`Invalid job ID returned from API: ${JSON.stringify(response)}`);
|
|
364
|
+
}
|
|
365
|
+
return jobId;
|
|
256
366
|
}
|
|
257
367
|
*iterChunks(items, size) {
|
|
258
368
|
for (let i = 0; i < items.length; i += size) {
|
package/dist/api/policies.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { RoeConfig } from "../config.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import type { RoeRawClient } from "../generated/client.js";
|
|
3
|
+
import type { components } from "../generated/schema.js";
|
|
4
|
+
type Policy = components["schemas"]["Policy"];
|
|
5
|
+
type CreatePolicy = components["schemas"]["CreatePolicy"];
|
|
6
|
+
type UpdatePolicy = components["schemas"]["UpdatePolicy"];
|
|
7
|
+
type PolicyVersion = components["schemas"]["PolicyVersion"];
|
|
8
|
+
type PaginatedPolicyList = components["schemas"]["PaginatedPolicyList"];
|
|
5
9
|
export declare class PolicyVersionsAPI {
|
|
6
10
|
private readonly policiesApi;
|
|
7
11
|
constructor(policiesApi: PoliciesAPI);
|
|
8
|
-
private get
|
|
12
|
+
private get raw();
|
|
13
|
+
private get organizationId();
|
|
9
14
|
list(policyId: string): Promise<PolicyVersion[]>;
|
|
10
15
|
retrieve(policyId: string, versionId: string): Promise<PolicyVersion>;
|
|
11
16
|
create(params: {
|
|
@@ -17,23 +22,24 @@ export declare class PolicyVersionsAPI {
|
|
|
17
22
|
}
|
|
18
23
|
export declare class PoliciesAPI {
|
|
19
24
|
readonly config: RoeConfig;
|
|
20
|
-
readonly
|
|
25
|
+
readonly raw: RoeRawClient;
|
|
21
26
|
readonly versions: PolicyVersionsAPI;
|
|
22
|
-
constructor(config: RoeConfig,
|
|
27
|
+
constructor(config: RoeConfig, raw: RoeRawClient);
|
|
23
28
|
list(params?: {
|
|
24
29
|
page?: number;
|
|
25
30
|
pageSize?: number;
|
|
26
|
-
}): Promise<
|
|
31
|
+
}): Promise<PaginatedPolicyList>;
|
|
27
32
|
retrieve(policyId: string): Promise<Policy>;
|
|
28
33
|
create(params: {
|
|
29
34
|
name: string;
|
|
30
35
|
content: Record<string, unknown>;
|
|
31
36
|
description?: string;
|
|
32
37
|
versionName?: string;
|
|
33
|
-
}): Promise<
|
|
38
|
+
}): Promise<CreatePolicy>;
|
|
34
39
|
update(policyId: string, updates: {
|
|
35
40
|
name?: string;
|
|
36
41
|
description?: string;
|
|
37
|
-
}): Promise<
|
|
42
|
+
}): Promise<UpdatePolicy>;
|
|
38
43
|
delete(policyId: string): Promise<void>;
|
|
39
44
|
}
|
|
45
|
+
export {};
|