roe-typescript 0.1.3 → 1.0.79
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 +30 -14
- package/dist/api/agents.d.ts +33 -25
- package/dist/api/agents.js +213 -114
- 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 +28 -4
- package/dist/models/job.js +39 -21
- 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 -81
- package/dist/models/responses.js +0 -48
- 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 -232
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,33 +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);
|
|
122
183
|
}
|
|
123
184
|
async cancel(jobId) {
|
|
124
185
|
validateUuid(jobId, "jobId");
|
|
125
|
-
await this.
|
|
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
|
+
});
|
|
126
192
|
}
|
|
127
193
|
async cancelAll(agentId) {
|
|
128
194
|
validateUuid(agentId, "agentId");
|
|
129
|
-
await this.
|
|
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
|
+
});
|
|
130
201
|
}
|
|
131
202
|
async deleteData(jobId) {
|
|
132
203
|
validateUuid(jobId, "jobId");
|
|
133
|
-
|
|
134
|
-
|
|
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
|
+
},
|
|
135
209
|
});
|
|
210
|
+
return data;
|
|
136
211
|
}
|
|
137
212
|
*iterChunks(items, size) {
|
|
138
213
|
for (let i = 0; i < items.length; i += size) {
|
|
@@ -142,77 +217,93 @@ export class AgentJobsAPI {
|
|
|
142
217
|
}
|
|
143
218
|
AgentJobsAPI.MAX_BATCH_SIZE = 1000;
|
|
144
219
|
export class AgentsAPI {
|
|
145
|
-
constructor(config,
|
|
220
|
+
constructor(config, raw) {
|
|
146
221
|
this.config = config;
|
|
147
|
-
this.
|
|
222
|
+
this.raw = raw;
|
|
148
223
|
this.versions = new AgentVersionsAPI(this);
|
|
149
224
|
this.jobs = new AgentJobsAPI(this);
|
|
150
225
|
}
|
|
151
|
-
wrapBase(data) {
|
|
152
|
-
const obj = new BaseAgentWithApi(data);
|
|
153
|
-
obj.setAgentsApi(this);
|
|
154
|
-
return obj;
|
|
155
|
-
}
|
|
156
226
|
async list(params) {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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;
|
|
161
237
|
}
|
|
162
238
|
async retrieve(agentId) {
|
|
163
239
|
validateUuid(agentId, "agentId");
|
|
164
|
-
const data = await this.
|
|
165
|
-
|
|
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;
|
|
166
247
|
}
|
|
167
248
|
async create(params) {
|
|
168
|
-
const
|
|
249
|
+
const body = {
|
|
169
250
|
name: params.name,
|
|
170
251
|
engine_class_id: params.engineClassId,
|
|
171
252
|
organization_id: this.config.organizationId,
|
|
172
|
-
input_definitions: params.inputDefinitions ?? [],
|
|
173
|
-
engine_config: params.engineConfig ?? {},
|
|
253
|
+
input_definitions: (params.inputDefinitions ?? []),
|
|
254
|
+
engine_config: (params.engineConfig ?? {}),
|
|
174
255
|
};
|
|
175
256
|
if (params.versionName !== undefined)
|
|
176
|
-
|
|
257
|
+
body.version_name = params.versionName;
|
|
177
258
|
if (params.description !== undefined)
|
|
178
|
-
|
|
179
|
-
const data = await this.
|
|
180
|
-
|
|
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;
|
|
181
265
|
}
|
|
182
266
|
async update(agentId, updates) {
|
|
183
267
|
validateUuid(agentId, "agentId");
|
|
184
|
-
const
|
|
268
|
+
const body = {};
|
|
185
269
|
if (updates.name !== undefined)
|
|
186
|
-
|
|
270
|
+
body.name = updates.name;
|
|
187
271
|
if (updates.disableCache !== undefined)
|
|
188
|
-
|
|
272
|
+
body.disable_cache = updates.disableCache;
|
|
189
273
|
if (updates.cacheFailedJobs !== undefined)
|
|
190
|
-
|
|
191
|
-
const data = await this.
|
|
192
|
-
|
|
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;
|
|
193
283
|
}
|
|
194
284
|
async delete(agentId) {
|
|
195
285
|
validateUuid(agentId, "agentId");
|
|
196
|
-
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
|
+
});
|
|
197
292
|
}
|
|
198
293
|
async duplicate(agentId) {
|
|
199
294
|
validateUuid(agentId, "agentId");
|
|
200
|
-
const data = await this.
|
|
201
|
-
|
|
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
|
+
},
|
|
202
300
|
});
|
|
203
|
-
return
|
|
301
|
+
return data;
|
|
204
302
|
}
|
|
205
303
|
async run(params) {
|
|
206
304
|
validateUuid(params.agentId, "agentId");
|
|
207
|
-
const response = await this.
|
|
208
|
-
|
|
209
|
-
const jobId = typeof response === "string" ? response : response?.job_id;
|
|
210
|
-
if (!jobId || typeof jobId !== "string") {
|
|
211
|
-
throw new RoeAPIException(`Invalid job ID returned from API: ${JSON.stringify(response)}`);
|
|
212
|
-
}
|
|
213
|
-
if (!isUuidString(jobId)) {
|
|
214
|
-
throw new RoeAPIException(`Invalid job ID format returned from API: ${jobId}`);
|
|
215
|
-
}
|
|
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);
|
|
216
307
|
return new Job({ agentsApi: this, jobId, timeoutSeconds: params.timeoutSeconds });
|
|
217
308
|
}
|
|
218
309
|
async runMany(params) {
|
|
@@ -221,21 +312,23 @@ export class AgentsAPI {
|
|
|
221
312
|
for (const chunk of this.iterChunks(params.batchInputs, AgentsAPI.MAX_BATCH_SIZE)) {
|
|
222
313
|
if (!chunk.length)
|
|
223
314
|
continue;
|
|
224
|
-
|
|
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 };
|
|
225
318
|
if (params.metadata !== undefined)
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
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,
|
|
230
326
|
});
|
|
231
|
-
|
|
232
|
-
for (const jobId of
|
|
233
|
-
if (
|
|
327
|
+
const ids = Array.isArray(data) ? data : [];
|
|
328
|
+
for (const jobId of ids) {
|
|
329
|
+
if (typeof jobId !== "string" || !isUuidString(jobId)) {
|
|
234
330
|
throw new RoeAPIException(`Invalid job ID returned from batch API: ${JSON.stringify(jobId)}`);
|
|
235
331
|
}
|
|
236
|
-
if (!isUuidString(jobId)) {
|
|
237
|
-
throw new RoeAPIException(`Invalid job ID format returned from batch API: ${jobId}`);
|
|
238
|
-
}
|
|
239
332
|
allJobIds.push(jobId);
|
|
240
333
|
}
|
|
241
334
|
}
|
|
@@ -243,27 +336,33 @@ export class AgentsAPI {
|
|
|
243
336
|
}
|
|
244
337
|
async runSync(agentId, inputs, metadata) {
|
|
245
338
|
validateUuid(agentId, "agentId");
|
|
246
|
-
|
|
247
|
-
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);
|
|
248
340
|
}
|
|
249
341
|
async runVersion(params) {
|
|
250
342
|
validateUuid(params.agentId, "agentId");
|
|
251
343
|
validateUuid(params.versionId, "versionId");
|
|
252
|
-
const response = await this.
|
|
253
|
-
|
|
254
|
-
const jobId = typeof response === "string" ? response : response?.job_id;
|
|
255
|
-
if (!jobId || typeof jobId !== "string") {
|
|
256
|
-
throw new RoeAPIException(`Invalid job ID returned from API: ${JSON.stringify(response)}`);
|
|
257
|
-
}
|
|
258
|
-
if (!isUuidString(jobId)) {
|
|
259
|
-
throw new RoeAPIException(`Invalid job ID format returned from API: ${jobId}`);
|
|
260
|
-
}
|
|
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);
|
|
261
346
|
return new Job({ agentsApi: this, jobId, timeoutSeconds: params.timeoutSeconds });
|
|
262
347
|
}
|
|
263
348
|
async runVersionSync(agentId, versionId, inputs, metadata) {
|
|
264
349
|
validateUuid(agentId, "agentId");
|
|
265
350
|
validateUuid(versionId, "versionId");
|
|
266
|
-
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;
|
|
267
366
|
}
|
|
268
367
|
*iterChunks(items, size) {
|
|
269
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 {};
|