@athenaintel/sdk 4.3.2166 → 4.3.2168
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 +1 -1
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/api/resources/aop/client/Client.d.ts +65 -8
- package/dist/cjs/api/resources/aop/client/Client.js +213 -11
- package/dist/cjs/api/resources/aop/client/requests/AopBatchExecuteRequestIn.d.ts +34 -0
- package/dist/cjs/api/resources/aop/client/requests/AopBatchExecuteRequestIn.js +3 -0
- package/dist/cjs/api/resources/aop/client/requests/ExecuteAsyncAopRequest.d.ts +22 -0
- package/dist/cjs/api/resources/aop/client/requests/ExecuteAsyncAopRequest.js +3 -0
- package/dist/cjs/api/resources/aop/client/requests/GetBatchStatusAopRequest.d.ts +18 -0
- package/dist/cjs/api/resources/aop/client/requests/GetBatchStatusAopRequest.js +3 -0
- package/dist/cjs/api/resources/aop/client/requests/index.d.ts +3 -0
- package/dist/cjs/api/resources/threads/client/Client.d.ts +17 -0
- package/dist/cjs/api/resources/threads/client/Client.js +81 -0
- package/dist/cjs/api/resources/threads/client/requests/ThreadStatusBatchRequestIn.d.ts +10 -0
- package/dist/cjs/api/resources/threads/client/requests/ThreadStatusBatchRequestIn.js +3 -0
- package/dist/cjs/api/resources/threads/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/types/AopAsyncExecuteResponseOut.d.ts +2 -0
- package/dist/cjs/api/types/AopBatchExecuteResponseOut.d.ts +16 -0
- package/dist/cjs/api/types/AopBatchExecuteResponseOut.js +3 -0
- package/dist/cjs/api/types/AopBatchRunIn.d.ts +13 -0
- package/dist/cjs/api/types/AopBatchRunIn.js +3 -0
- package/dist/cjs/api/types/AopBatchRunLaunchOut.d.ts +17 -0
- package/dist/cjs/api/types/AopBatchRunLaunchOut.js +3 -0
- package/dist/cjs/api/types/AopBatchRunStatusOut.d.ts +21 -0
- package/dist/cjs/api/types/AopBatchRunStatusOut.js +3 -0
- package/dist/cjs/api/types/AopBatchStatusCountsOut.d.ts +12 -0
- package/dist/cjs/api/types/AopBatchStatusCountsOut.js +3 -0
- package/dist/cjs/api/types/AopBatchStatusResponseOut.d.ts +20 -0
- package/dist/cjs/api/types/AopBatchStatusResponseOut.js +3 -0
- package/dist/cjs/api/types/ThreadStatusBatchItemOut.d.ts +27 -0
- package/dist/cjs/api/types/ThreadStatusBatchItemOut.js +3 -0
- package/dist/cjs/api/types/ThreadStatusBatchResponseOut.d.ts +20 -0
- package/dist/cjs/api/types/ThreadStatusBatchResponseOut.js +3 -0
- package/dist/cjs/api/types/index.d.ts +8 -0
- package/dist/cjs/api/types/index.js +8 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/api/resources/aop/client/Client.d.mts +65 -8
- package/dist/esm/api/resources/aop/client/Client.mjs +214 -12
- package/dist/esm/api/resources/aop/client/requests/AopBatchExecuteRequestIn.d.mts +34 -0
- package/dist/esm/api/resources/aop/client/requests/AopBatchExecuteRequestIn.mjs +2 -0
- package/dist/esm/api/resources/aop/client/requests/ExecuteAsyncAopRequest.d.mts +22 -0
- package/dist/esm/api/resources/aop/client/requests/ExecuteAsyncAopRequest.mjs +2 -0
- package/dist/esm/api/resources/aop/client/requests/GetBatchStatusAopRequest.d.mts +18 -0
- package/dist/esm/api/resources/aop/client/requests/GetBatchStatusAopRequest.mjs +2 -0
- package/dist/esm/api/resources/aop/client/requests/index.d.mts +3 -0
- package/dist/esm/api/resources/threads/client/Client.d.mts +17 -0
- package/dist/esm/api/resources/threads/client/Client.mjs +81 -0
- package/dist/esm/api/resources/threads/client/requests/ThreadStatusBatchRequestIn.d.mts +10 -0
- package/dist/esm/api/resources/threads/client/requests/ThreadStatusBatchRequestIn.mjs +2 -0
- package/dist/esm/api/resources/threads/client/requests/index.d.mts +1 -0
- package/dist/esm/api/types/AopAsyncExecuteResponseOut.d.mts +2 -0
- package/dist/esm/api/types/AopBatchExecuteResponseOut.d.mts +16 -0
- package/dist/esm/api/types/AopBatchExecuteResponseOut.mjs +2 -0
- package/dist/esm/api/types/AopBatchRunIn.d.mts +13 -0
- package/dist/esm/api/types/AopBatchRunIn.mjs +2 -0
- package/dist/esm/api/types/AopBatchRunLaunchOut.d.mts +17 -0
- package/dist/esm/api/types/AopBatchRunLaunchOut.mjs +2 -0
- package/dist/esm/api/types/AopBatchRunStatusOut.d.mts +21 -0
- package/dist/esm/api/types/AopBatchRunStatusOut.mjs +2 -0
- package/dist/esm/api/types/AopBatchStatusCountsOut.d.mts +12 -0
- package/dist/esm/api/types/AopBatchStatusCountsOut.mjs +2 -0
- package/dist/esm/api/types/AopBatchStatusResponseOut.d.mts +20 -0
- package/dist/esm/api/types/AopBatchStatusResponseOut.mjs +2 -0
- package/dist/esm/api/types/ThreadStatusBatchItemOut.d.mts +27 -0
- package/dist/esm/api/types/ThreadStatusBatchItemOut.mjs +2 -0
- package/dist/esm/api/types/ThreadStatusBatchResponseOut.d.mts +20 -0
- package/dist/esm/api/types/ThreadStatusBatchResponseOut.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +8 -0
- package/dist/esm/api/types/index.mjs +8 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +220 -6
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
23
|
-
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
23
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
|
|
24
24
|
import * as core from "../../../../core/index.mjs";
|
|
25
25
|
import * as environments from "../../../../environments.mjs";
|
|
26
26
|
import * as errors from "../../../../errors/index.mjs";
|
|
@@ -29,6 +29,100 @@ export class AopClient {
|
|
|
29
29
|
constructor(options = {}) {
|
|
30
30
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Aggregate lifecycle status of every run launched under a batch handle from `POST /aop/execute-batch`: counts per canonical run status, an `is_complete` flag, and a cursor-paged list of runs. Poll this once per batch instead of `GET /threads/{thread_id}/status` per thread; fetch a run's messages from the thread status endpoint only once it is terminal. This read never loads transcripts.
|
|
34
|
+
*
|
|
35
|
+
* @param {AthenaIntelligence.GetBatchStatusAopRequest} request
|
|
36
|
+
* @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
37
|
+
*
|
|
38
|
+
* @throws {@link AthenaIntelligence.BadRequestError}
|
|
39
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
40
|
+
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
41
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* await client.aop.getBatchStatus({
|
|
45
|
+
* batch_id: "batch_0f4c3c3e-1c1a-4a3e-9a5f-0d3f1a2b3c4d",
|
|
46
|
+
* status: "terminal",
|
|
47
|
+
* limit: 200
|
|
48
|
+
* })
|
|
49
|
+
*/
|
|
50
|
+
getBatchStatus(request, requestOptions) {
|
|
51
|
+
return core.HttpResponsePromise.fromPromise(this.__getBatchStatus(request, requestOptions));
|
|
52
|
+
}
|
|
53
|
+
__getBatchStatus(request, requestOptions) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
56
|
+
const { batch_id: batchId, status, cursor, limit } = request;
|
|
57
|
+
const _queryParams = {};
|
|
58
|
+
if (status != null) {
|
|
59
|
+
_queryParams.status = status;
|
|
60
|
+
}
|
|
61
|
+
if (cursor !== undefined) {
|
|
62
|
+
_queryParams.cursor = cursor;
|
|
63
|
+
}
|
|
64
|
+
if (limit != null) {
|
|
65
|
+
_queryParams.limit = limit.toString();
|
|
66
|
+
}
|
|
67
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
68
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
69
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
70
|
+
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.AthenaIntelligenceEnvironment.Production, `api/v0/aop/batches/${core.url.encodePathParam(batchId)}`),
|
|
71
|
+
method: "GET",
|
|
72
|
+
headers: _headers,
|
|
73
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
74
|
+
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
75
|
+
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
76
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
77
|
+
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
78
|
+
logging: this._options.logging,
|
|
79
|
+
});
|
|
80
|
+
if (_response.ok) {
|
|
81
|
+
return {
|
|
82
|
+
data: _response.body,
|
|
83
|
+
rawResponse: _response.rawResponse,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (_response.error.reason === "status-code") {
|
|
87
|
+
switch (_response.error.statusCode) {
|
|
88
|
+
case 400:
|
|
89
|
+
throw new AthenaIntelligence.BadRequestError(_response.error.body, _response.rawResponse);
|
|
90
|
+
case 401:
|
|
91
|
+
throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
92
|
+
case 404:
|
|
93
|
+
throw new AthenaIntelligence.NotFoundError(_response.error.body, _response.rawResponse);
|
|
94
|
+
case 422:
|
|
95
|
+
throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
96
|
+
default:
|
|
97
|
+
throw new errors.AthenaIntelligenceError({
|
|
98
|
+
statusCode: _response.error.statusCode,
|
|
99
|
+
body: _response.error.body,
|
|
100
|
+
rawResponse: _response.rawResponse,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
switch (_response.error.reason) {
|
|
105
|
+
case "non-json":
|
|
106
|
+
throw new errors.AthenaIntelligenceError({
|
|
107
|
+
statusCode: _response.error.statusCode,
|
|
108
|
+
body: _response.error.rawBody,
|
|
109
|
+
rawResponse: _response.rawResponse,
|
|
110
|
+
});
|
|
111
|
+
case "body-is-null":
|
|
112
|
+
throw new errors.AthenaIntelligenceError({
|
|
113
|
+
statusCode: _response.error.statusCode,
|
|
114
|
+
rawResponse: _response.rawResponse,
|
|
115
|
+
});
|
|
116
|
+
case "timeout":
|
|
117
|
+
throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling GET /api/v0/aop/batches/{batch_id}.");
|
|
118
|
+
case "unknown":
|
|
119
|
+
throw new errors.AthenaIntelligenceError({
|
|
120
|
+
message: _response.error.errorMessage,
|
|
121
|
+
rawResponse: _response.rawResponse,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
32
126
|
/**
|
|
33
127
|
* Create a new AOP (Agent Operating Procedure) asset with the given configuration. The created AOP can then be executed via /aop/execute-async, inspected via /aop/{asset_id}/config, and updated via PUT /aop/{asset_id}/config. Use [[ placeholder ]] syntax in the prompt for user inputs supplied at execution time.
|
|
34
128
|
*
|
|
@@ -219,40 +313,148 @@ export class AopClient {
|
|
|
219
313
|
});
|
|
220
314
|
}
|
|
221
315
|
/**
|
|
222
|
-
* Start execution of an Agent Operating Procedure (AOP) asset asynchronously. Returns immediately with a thread_id for tracking execution progress without waiting for completion.
|
|
316
|
+
* Start execution of an Agent Operating Procedure (AOP) asset asynchronously. Returns immediately with a thread_id for tracking execution progress without waiting for completion. Send an `Idempotency-Key` header to make the launch safe to retry: if the response is lost, repeating the identical request with the same key returns the original `thread_id` (with `deduplicated: true`) instead of starting a second run. Keys are private to your account; reusing a key with different parameters is rejected with 422, and a retry that races the first attempt gets 409.
|
|
223
317
|
*
|
|
224
|
-
* @param {AthenaIntelligence.
|
|
318
|
+
* @param {AthenaIntelligence.ExecuteAsyncAopRequest} request
|
|
225
319
|
* @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
226
320
|
*
|
|
227
321
|
* @throws {@link AthenaIntelligence.BadRequestError}
|
|
228
322
|
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
229
323
|
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
324
|
+
* @throws {@link AthenaIntelligence.ConflictError}
|
|
230
325
|
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
231
326
|
* @throws {@link AthenaIntelligence.InternalServerError}
|
|
232
327
|
*
|
|
233
328
|
* @example
|
|
234
329
|
* await client.aop.executeAsync({
|
|
330
|
+
* body: {
|
|
331
|
+
* asset_id: "asset_9249292-d118-42d3-95b4-00eccfe0754f",
|
|
332
|
+
* run_budget: {
|
|
333
|
+
* max_cost_usd: 30,
|
|
334
|
+
* max_model_calls: 80
|
|
335
|
+
* },
|
|
336
|
+
* user_inputs: {
|
|
337
|
+
* "company": "Acme Corp",
|
|
338
|
+
* "quarter": "Q1 2024"
|
|
339
|
+
* }
|
|
340
|
+
* }
|
|
341
|
+
* })
|
|
342
|
+
*/
|
|
343
|
+
executeAsync(request, requestOptions) {
|
|
344
|
+
return core.HttpResponsePromise.fromPromise(this.__executeAsync(request, requestOptions));
|
|
345
|
+
}
|
|
346
|
+
__executeAsync(request, requestOptions) {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
349
|
+
const { "Idempotency-Key": idempotencyKey, body: _body } = request;
|
|
350
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
351
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "Idempotency-Key": idempotencyKey !== undefined ? idempotencyKey : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
352
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
353
|
+
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.AthenaIntelligenceEnvironment.Production, "api/v0/aop/execute-async"),
|
|
354
|
+
method: "POST",
|
|
355
|
+
headers: _headers,
|
|
356
|
+
contentType: "application/json",
|
|
357
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
358
|
+
requestType: "json",
|
|
359
|
+
body: _body,
|
|
360
|
+
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
361
|
+
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
362
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
363
|
+
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
364
|
+
logging: this._options.logging,
|
|
365
|
+
});
|
|
366
|
+
if (_response.ok) {
|
|
367
|
+
return {
|
|
368
|
+
data: _response.body,
|
|
369
|
+
rawResponse: _response.rawResponse,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
if (_response.error.reason === "status-code") {
|
|
373
|
+
switch (_response.error.statusCode) {
|
|
374
|
+
case 400:
|
|
375
|
+
throw new AthenaIntelligence.BadRequestError(_response.error.body, _response.rawResponse);
|
|
376
|
+
case 401:
|
|
377
|
+
throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
378
|
+
case 404:
|
|
379
|
+
throw new AthenaIntelligence.NotFoundError(_response.error.body, _response.rawResponse);
|
|
380
|
+
case 409:
|
|
381
|
+
throw new AthenaIntelligence.ConflictError(_response.error.body, _response.rawResponse);
|
|
382
|
+
case 422:
|
|
383
|
+
throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
384
|
+
case 500:
|
|
385
|
+
throw new AthenaIntelligence.InternalServerError(_response.error.body, _response.rawResponse);
|
|
386
|
+
default:
|
|
387
|
+
throw new errors.AthenaIntelligenceError({
|
|
388
|
+
statusCode: _response.error.statusCode,
|
|
389
|
+
body: _response.error.body,
|
|
390
|
+
rawResponse: _response.rawResponse,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
switch (_response.error.reason) {
|
|
395
|
+
case "non-json":
|
|
396
|
+
throw new errors.AthenaIntelligenceError({
|
|
397
|
+
statusCode: _response.error.statusCode,
|
|
398
|
+
body: _response.error.rawBody,
|
|
399
|
+
rawResponse: _response.rawResponse,
|
|
400
|
+
});
|
|
401
|
+
case "body-is-null":
|
|
402
|
+
throw new errors.AthenaIntelligenceError({
|
|
403
|
+
statusCode: _response.error.statusCode,
|
|
404
|
+
rawResponse: _response.rawResponse,
|
|
405
|
+
});
|
|
406
|
+
case "timeout":
|
|
407
|
+
throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/aop/execute-async.");
|
|
408
|
+
case "unknown":
|
|
409
|
+
throw new errors.AthenaIntelligenceError({
|
|
410
|
+
message: _response.error.errorMessage,
|
|
411
|
+
rawResponse: _response.rawResponse,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Start many Agent Operating Procedure (AOP) runs under one batch handle. Each run is queued exactly like `POST /aop/execute-async`; the response returns a `batch_id` so the caller polls `GET /aop/batches/{batch_id}` once per batch instead of once per thread. Pass the `batch_id` back to append more runs to the same batch. Runs are launched independently: a run that fails to launch is reported with an error and does not stop the others. Runs are idempotent within a batch: a run whose `idempotency_key` (or, when omitted, `client_ref`) was already launched into the same batch with the same parameters is not started again; its original outcome is replayed with `deduplicated: true`.
|
|
418
|
+
*
|
|
419
|
+
* @param {AthenaIntelligence.AopBatchExecuteRequestIn} request
|
|
420
|
+
* @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
421
|
+
*
|
|
422
|
+
* @throws {@link AthenaIntelligence.BadRequestError}
|
|
423
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
424
|
+
* @throws {@link AthenaIntelligence.NotFoundError}
|
|
425
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
426
|
+
* @throws {@link AthenaIntelligence.InternalServerError}
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* await client.aop.executeBatch({
|
|
235
430
|
* asset_id: "asset_9249292-d118-42d3-95b4-00eccfe0754f",
|
|
236
431
|
* run_budget: {
|
|
237
432
|
* max_cost_usd: 30,
|
|
238
433
|
* max_model_calls: 80
|
|
239
434
|
* },
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
435
|
+
* runs: [{
|
|
436
|
+
* client_ref: "row-1",
|
|
437
|
+
* user_inputs: {
|
|
438
|
+
* "company": "Acme Corp"
|
|
439
|
+
* }
|
|
440
|
+
* }, {
|
|
441
|
+
* client_ref: "row-2",
|
|
442
|
+
* user_inputs: {
|
|
443
|
+
* "company": "Globex"
|
|
444
|
+
* }
|
|
445
|
+
* }]
|
|
244
446
|
* })
|
|
245
447
|
*/
|
|
246
|
-
|
|
247
|
-
return core.HttpResponsePromise.fromPromise(this.
|
|
448
|
+
executeBatch(request, requestOptions) {
|
|
449
|
+
return core.HttpResponsePromise.fromPromise(this.__executeBatch(request, requestOptions));
|
|
248
450
|
}
|
|
249
|
-
|
|
451
|
+
__executeBatch(request, requestOptions) {
|
|
250
452
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
453
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
252
454
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
253
455
|
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
254
456
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
255
|
-
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.AthenaIntelligenceEnvironment.Production, "api/v0/aop/execute-
|
|
457
|
+
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.AthenaIntelligenceEnvironment.Production, "api/v0/aop/execute-batch"),
|
|
256
458
|
method: "POST",
|
|
257
459
|
headers: _headers,
|
|
258
460
|
contentType: "application/json",
|
|
@@ -304,7 +506,7 @@ export class AopClient {
|
|
|
304
506
|
rawResponse: _response.rawResponse,
|
|
305
507
|
});
|
|
306
508
|
case "timeout":
|
|
307
|
-
throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/aop/execute-
|
|
509
|
+
throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/aop/execute-batch.");
|
|
308
510
|
case "unknown":
|
|
309
511
|
throw new errors.AthenaIntelligenceError({
|
|
310
512
|
message: _response.error.errorMessage,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type * as AthenaIntelligence from "../../../../index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* {
|
|
5
|
+
* asset_id: "asset_9249292-d118-42d3-95b4-00eccfe0754f",
|
|
6
|
+
* run_budget: {
|
|
7
|
+
* max_cost_usd: 30,
|
|
8
|
+
* max_model_calls: 80
|
|
9
|
+
* },
|
|
10
|
+
* runs: [{
|
|
11
|
+
* client_ref: "row-1",
|
|
12
|
+
* user_inputs: {
|
|
13
|
+
* "company": "Acme Corp"
|
|
14
|
+
* }
|
|
15
|
+
* }, {
|
|
16
|
+
* client_ref: "row-2",
|
|
17
|
+
* user_inputs: {
|
|
18
|
+
* "company": "Globex"
|
|
19
|
+
* }
|
|
20
|
+
* }]
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
export interface AopBatchExecuteRequestIn {
|
|
24
|
+
/** Default AOP asset ID for runs that omit their own `asset_id` */
|
|
25
|
+
asset_id?: string | null;
|
|
26
|
+
/** Existing batch to append these runs to (returned by a previous execute-batch call). Omit to start a new batch. */
|
|
27
|
+
batch_id?: string | null;
|
|
28
|
+
/** Execute every run in dry-run mode: side-effectful tool calls are validated and captured instead of executed. */
|
|
29
|
+
dry_run?: boolean;
|
|
30
|
+
/** Per-run spend cap (max_model_calls / max_cost_usd) applied to every run in the request. */
|
|
31
|
+
run_budget?: AthenaIntelligence.RunBudget | null;
|
|
32
|
+
/** Runs to launch (1-100 per request). Launch more into the same batch by repeating the call with the returned `batch_id`. */
|
|
33
|
+
runs: AthenaIntelligence.AopBatchRunIn[];
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type * as AthenaIntelligence from "../../../../index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* {
|
|
5
|
+
* body: {
|
|
6
|
+
* asset_id: "asset_9249292-d118-42d3-95b4-00eccfe0754f",
|
|
7
|
+
* run_budget: {
|
|
8
|
+
* max_cost_usd: 30,
|
|
9
|
+
* max_model_calls: 80
|
|
10
|
+
* },
|
|
11
|
+
* user_inputs: {
|
|
12
|
+
* "company": "Acme Corp",
|
|
13
|
+
* "quarter": "Q1 2024"
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export interface ExecuteAsyncAopRequest {
|
|
19
|
+
/** Optional caller-chosen key that makes this launch safe to retry. Repeating the identical request with the same key replays the original response instead of starting another run. */
|
|
20
|
+
"Idempotency-Key"?: string | null;
|
|
21
|
+
body: AthenaIntelligence.AopExecuteRequestIn;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* batch_id: "batch_0f4c3c3e-1c1a-4a3e-9a5f-0d3f1a2b3c4d",
|
|
5
|
+
* status: "terminal",
|
|
6
|
+
* limit: 200
|
|
7
|
+
* }
|
|
8
|
+
*/
|
|
9
|
+
export interface GetBatchStatusAopRequest {
|
|
10
|
+
/** Batch handle returned by execute-batch */
|
|
11
|
+
batch_id: string;
|
|
12
|
+
/** Which runs to list: `terminal` (completed/failed/canceled), `active` (everything else) or `all`. Counts always cover the whole batch. */
|
|
13
|
+
status?: string;
|
|
14
|
+
/** `next_cursor` from the previous page */
|
|
15
|
+
cursor?: string | null;
|
|
16
|
+
/** Maximum runs to return in this page */
|
|
17
|
+
limit?: number;
|
|
18
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export type { AopBatchExecuteRequestIn } from "./AopBatchExecuteRequestIn.mjs";
|
|
1
2
|
export type { AopConfigUpdateRequestIn } from "./AopConfigUpdateRequestIn.mjs";
|
|
2
3
|
export type { AopCreateRequestIn } from "./AopCreateRequestIn.mjs";
|
|
4
|
+
export type { ExecuteAsyncAopRequest } from "./ExecuteAsyncAopRequest.mjs";
|
|
5
|
+
export type { GetBatchStatusAopRequest } from "./GetBatchStatusAopRequest.mjs";
|
|
3
6
|
export type { GetConfigAopRequest } from "./GetConfigAopRequest.mjs";
|
|
@@ -28,6 +28,23 @@ export declare class ThreadsClient {
|
|
|
28
28
|
*/
|
|
29
29
|
batchStopByAssetId(request: AthenaIntelligence.ThreadBatchStopRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.ThreadBatchStopResponseOut>;
|
|
30
30
|
private __batchStopByAssetId;
|
|
31
|
+
/**
|
|
32
|
+
* Read the lifecycle status of up to 200 threads in one call, whether they were started by `POST /aop/execute-async` or `POST /aop/execute-batch`. Returns aggregate counts plus one compact entry per thread (status, terminal flag, output availability, timestamps) without loading any messages; fetch results with `GET /threads/{thread_id}/status` once `output_available` is true. Only threads you launched are returned: unknown IDs and other users' threads are listed in `not_found` and are indistinguishable.
|
|
33
|
+
*
|
|
34
|
+
* @param {AthenaIntelligence.ThreadStatusBatchRequestIn} request
|
|
35
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
36
|
+
*
|
|
37
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
38
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
39
|
+
* @throws {@link AthenaIntelligence.InternalServerError}
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* await client.threads.getStatusBatch({
|
|
43
|
+
* thread_ids: ["thread_12345-6789-abcd-efgh", "thread_22345-6789-abcd-efgh"]
|
|
44
|
+
* })
|
|
45
|
+
*/
|
|
46
|
+
getStatusBatch(request: AthenaIntelligence.ThreadStatusBatchRequestIn, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.ThreadStatusBatchResponseOut>;
|
|
47
|
+
private __getStatusBatch;
|
|
31
48
|
/**
|
|
32
49
|
* Stop multiple running thread executions in a single request. This endpoint accepts thread IDs (the same IDs used with the single-thread stop endpoint). Each thread is stopped independently - failures for individual threads do not affect other threads in the batch.
|
|
33
50
|
*
|
|
@@ -99,6 +99,87 @@ export class ThreadsClient {
|
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Read the lifecycle status of up to 200 threads in one call, whether they were started by `POST /aop/execute-async` or `POST /aop/execute-batch`. Returns aggregate counts plus one compact entry per thread (status, terminal flag, output availability, timestamps) without loading any messages; fetch results with `GET /threads/{thread_id}/status` once `output_available` is true. Only threads you launched are returned: unknown IDs and other users' threads are listed in `not_found` and are indistinguishable.
|
|
104
|
+
*
|
|
105
|
+
* @param {AthenaIntelligence.ThreadStatusBatchRequestIn} request
|
|
106
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
107
|
+
*
|
|
108
|
+
* @throws {@link AthenaIntelligence.UnauthorizedError}
|
|
109
|
+
* @throws {@link AthenaIntelligence.UnprocessableEntityError}
|
|
110
|
+
* @throws {@link AthenaIntelligence.InternalServerError}
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* await client.threads.getStatusBatch({
|
|
114
|
+
* thread_ids: ["thread_12345-6789-abcd-efgh", "thread_22345-6789-abcd-efgh"]
|
|
115
|
+
* })
|
|
116
|
+
*/
|
|
117
|
+
getStatusBatch(request, requestOptions) {
|
|
118
|
+
return core.HttpResponsePromise.fromPromise(this.__getStatusBatch(request, requestOptions));
|
|
119
|
+
}
|
|
120
|
+
__getStatusBatch(request, requestOptions) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
123
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
124
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
125
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
126
|
+
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.AthenaIntelligenceEnvironment.Production, "api/v0/threads/status-batch"),
|
|
127
|
+
method: "POST",
|
|
128
|
+
headers: _headers,
|
|
129
|
+
contentType: "application/json",
|
|
130
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
131
|
+
requestType: "json",
|
|
132
|
+
body: request,
|
|
133
|
+
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
134
|
+
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
135
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
136
|
+
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
137
|
+
logging: this._options.logging,
|
|
138
|
+
});
|
|
139
|
+
if (_response.ok) {
|
|
140
|
+
return {
|
|
141
|
+
data: _response.body,
|
|
142
|
+
rawResponse: _response.rawResponse,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (_response.error.reason === "status-code") {
|
|
146
|
+
switch (_response.error.statusCode) {
|
|
147
|
+
case 401:
|
|
148
|
+
throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
149
|
+
case 422:
|
|
150
|
+
throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
151
|
+
case 500:
|
|
152
|
+
throw new AthenaIntelligence.InternalServerError(_response.error.body, _response.rawResponse);
|
|
153
|
+
default:
|
|
154
|
+
throw new errors.AthenaIntelligenceError({
|
|
155
|
+
statusCode: _response.error.statusCode,
|
|
156
|
+
body: _response.error.body,
|
|
157
|
+
rawResponse: _response.rawResponse,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
switch (_response.error.reason) {
|
|
162
|
+
case "non-json":
|
|
163
|
+
throw new errors.AthenaIntelligenceError({
|
|
164
|
+
statusCode: _response.error.statusCode,
|
|
165
|
+
body: _response.error.rawBody,
|
|
166
|
+
rawResponse: _response.rawResponse,
|
|
167
|
+
});
|
|
168
|
+
case "body-is-null":
|
|
169
|
+
throw new errors.AthenaIntelligenceError({
|
|
170
|
+
statusCode: _response.error.statusCode,
|
|
171
|
+
rawResponse: _response.rawResponse,
|
|
172
|
+
});
|
|
173
|
+
case "timeout":
|
|
174
|
+
throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/threads/status-batch.");
|
|
175
|
+
case "unknown":
|
|
176
|
+
throw new errors.AthenaIntelligenceError({
|
|
177
|
+
message: _response.error.errorMessage,
|
|
178
|
+
rawResponse: _response.rawResponse,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
102
183
|
/**
|
|
103
184
|
* Stop multiple running thread executions in a single request. This endpoint accepts thread IDs (the same IDs used with the single-thread stop endpoint). Each thread is stopped independently - failures for individual threads do not affect other threads in the batch.
|
|
104
185
|
*
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* thread_ids: ["thread_12345-6789-abcd-efgh", "thread_22345-6789-abcd-efgh"]
|
|
5
|
+
* }
|
|
6
|
+
*/
|
|
7
|
+
export interface ThreadStatusBatchRequestIn {
|
|
8
|
+
/** Thread IDs to check (1-200 per request), from `POST /aop/execute-async` or `POST /aop/execute-batch`. Duplicates are collapsed. */
|
|
9
|
+
thread_ids: string[];
|
|
10
|
+
}
|
|
@@ -10,6 +10,8 @@ export interface AopAsyncExecuteResponseOut {
|
|
|
10
10
|
aop_title: string;
|
|
11
11
|
/** Base prompt of the AOP before user inputs were added */
|
|
12
12
|
base_prompt: string;
|
|
13
|
+
/** True when this response replays an earlier launch with the same `Idempotency-Key`; no new run was started. */
|
|
14
|
+
deduplicated?: boolean;
|
|
13
15
|
/** Final prompt used for execution including user inputs */
|
|
14
16
|
final_prompt: string;
|
|
15
17
|
/** Status message about the async execution */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as AthenaIntelligence from "../index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Response model for launching a batch of AOP runs.
|
|
4
|
+
*/
|
|
5
|
+
export interface AopBatchExecuteResponseOut {
|
|
6
|
+
/** Batch handle. Poll `GET /aop/batches/{batch_id}` for the whole batch instead of every thread, and pass it back to `POST /aop/execute-batch` to append more runs. Null when a new batch launched no runs: there is nothing to poll or append to, so no handle is issued. */
|
|
7
|
+
batch_id?: string | null;
|
|
8
|
+
/** Runs in this request that replayed an earlier launch (same `idempotency_key` / `client_ref` in this batch) instead of starting */
|
|
9
|
+
deduplicated?: number;
|
|
10
|
+
/** Runs in this request that could not be launched */
|
|
11
|
+
failed: number;
|
|
12
|
+
/** Runs accepted and queued in this request */
|
|
13
|
+
launched: number;
|
|
14
|
+
/** Per-run launch outcome, in request order */
|
|
15
|
+
runs: AthenaIntelligence.AopBatchRunLaunchOut[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One AOP run inside an execute-batch request.
|
|
3
|
+
*/
|
|
4
|
+
export interface AopBatchRunIn {
|
|
5
|
+
/** ID of the AOP asset to execute for this run. Defaults to the batch-level `asset_id` when omitted. */
|
|
6
|
+
asset_id?: string | null;
|
|
7
|
+
/** Caller-supplied correlation key (e.g. a row id) echoed back on the run in the batch status response. Unique within a batch: a later run with the same `client_ref` in the same batch is not launched again; its outcome is replayed with `deduplicated: true`. */
|
|
8
|
+
client_ref?: string | null;
|
|
9
|
+
/** Optional per-run idempotency key, scoped to your account and the batch. Repeating a run with the same key (and same parameters) replays the original launch outcome instead of starting a duplicate. Defaults to `client_ref` when omitted. */
|
|
10
|
+
idempotency_key?: string | null;
|
|
11
|
+
/** Optional user inputs to append to the AOP's prompt as key-value pairs */
|
|
12
|
+
user_inputs?: Record<string, string | null> | null;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome of launching one run of an execute-batch request.
|
|
3
|
+
*/
|
|
4
|
+
export interface AopBatchRunLaunchOut {
|
|
5
|
+
/** ID of the AOP asset the run executes */
|
|
6
|
+
aop_asset_id?: string | null;
|
|
7
|
+
/** Caller-supplied correlation key from the request */
|
|
8
|
+
client_ref?: string | null;
|
|
9
|
+
/** True when this run replays an earlier launch with the same `idempotency_key` / `client_ref` in this batch; no new run was started. */
|
|
10
|
+
deduplicated?: boolean;
|
|
11
|
+
/** Why the run could not be launched; null on success */
|
|
12
|
+
error?: string | null;
|
|
13
|
+
/** Position of the run in the request's `runs` list */
|
|
14
|
+
index: number;
|
|
15
|
+
/** Thread ID of the launched run; null when the launch failed */
|
|
16
|
+
thread_id?: string | null;
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle status of one run in a batch (no messages).
|
|
3
|
+
*/
|
|
4
|
+
export interface AopBatchRunStatusOut {
|
|
5
|
+
/** ID of the AOP asset the run executes */
|
|
6
|
+
aop_asset_id?: string | null;
|
|
7
|
+
/** Caller-supplied correlation key from the launch request */
|
|
8
|
+
client_ref?: string | null;
|
|
9
|
+
/** ISO timestamp when the run reached a terminal state */
|
|
10
|
+
completed_at?: string | null;
|
|
11
|
+
/** When the run was queued */
|
|
12
|
+
created_at?: string | null;
|
|
13
|
+
/** Error message when the run failed */
|
|
14
|
+
error?: string | null;
|
|
15
|
+
/** True once the run is completed, failed or canceled */
|
|
16
|
+
is_terminal: boolean;
|
|
17
|
+
/** Canonical run status: scheduled, queued, running, needs_input, completed, failed or canceled */
|
|
18
|
+
status: string;
|
|
19
|
+
/** Thread ID; use `GET /threads/{thread_id}/status` for the result */
|
|
20
|
+
thread_id: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run counts of a batch by canonical run status.
|
|
3
|
+
*/
|
|
4
|
+
export interface AopBatchStatusCountsOut {
|
|
5
|
+
canceled?: number;
|
|
6
|
+
completed?: number;
|
|
7
|
+
failed?: number;
|
|
8
|
+
needs_input?: number;
|
|
9
|
+
queued?: number;
|
|
10
|
+
running?: number;
|
|
11
|
+
scheduled?: number;
|
|
12
|
+
}
|