@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.
Files changed (75) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/api/resources/aop/client/Client.d.ts +65 -8
  4. package/dist/cjs/api/resources/aop/client/Client.js +213 -11
  5. package/dist/cjs/api/resources/aop/client/requests/AopBatchExecuteRequestIn.d.ts +34 -0
  6. package/dist/cjs/api/resources/aop/client/requests/AopBatchExecuteRequestIn.js +3 -0
  7. package/dist/cjs/api/resources/aop/client/requests/ExecuteAsyncAopRequest.d.ts +22 -0
  8. package/dist/cjs/api/resources/aop/client/requests/ExecuteAsyncAopRequest.js +3 -0
  9. package/dist/cjs/api/resources/aop/client/requests/GetBatchStatusAopRequest.d.ts +18 -0
  10. package/dist/cjs/api/resources/aop/client/requests/GetBatchStatusAopRequest.js +3 -0
  11. package/dist/cjs/api/resources/aop/client/requests/index.d.ts +3 -0
  12. package/dist/cjs/api/resources/threads/client/Client.d.ts +17 -0
  13. package/dist/cjs/api/resources/threads/client/Client.js +81 -0
  14. package/dist/cjs/api/resources/threads/client/requests/ThreadStatusBatchRequestIn.d.ts +10 -0
  15. package/dist/cjs/api/resources/threads/client/requests/ThreadStatusBatchRequestIn.js +3 -0
  16. package/dist/cjs/api/resources/threads/client/requests/index.d.ts +1 -0
  17. package/dist/cjs/api/types/AopAsyncExecuteResponseOut.d.ts +2 -0
  18. package/dist/cjs/api/types/AopBatchExecuteResponseOut.d.ts +16 -0
  19. package/dist/cjs/api/types/AopBatchExecuteResponseOut.js +3 -0
  20. package/dist/cjs/api/types/AopBatchRunIn.d.ts +13 -0
  21. package/dist/cjs/api/types/AopBatchRunIn.js +3 -0
  22. package/dist/cjs/api/types/AopBatchRunLaunchOut.d.ts +17 -0
  23. package/dist/cjs/api/types/AopBatchRunLaunchOut.js +3 -0
  24. package/dist/cjs/api/types/AopBatchRunStatusOut.d.ts +21 -0
  25. package/dist/cjs/api/types/AopBatchRunStatusOut.js +3 -0
  26. package/dist/cjs/api/types/AopBatchStatusCountsOut.d.ts +12 -0
  27. package/dist/cjs/api/types/AopBatchStatusCountsOut.js +3 -0
  28. package/dist/cjs/api/types/AopBatchStatusResponseOut.d.ts +20 -0
  29. package/dist/cjs/api/types/AopBatchStatusResponseOut.js +3 -0
  30. package/dist/cjs/api/types/ThreadStatusBatchItemOut.d.ts +27 -0
  31. package/dist/cjs/api/types/ThreadStatusBatchItemOut.js +3 -0
  32. package/dist/cjs/api/types/ThreadStatusBatchResponseOut.d.ts +20 -0
  33. package/dist/cjs/api/types/ThreadStatusBatchResponseOut.js +3 -0
  34. package/dist/cjs/api/types/index.d.ts +8 -0
  35. package/dist/cjs/api/types/index.js +8 -0
  36. package/dist/cjs/version.d.ts +1 -1
  37. package/dist/cjs/version.js +1 -1
  38. package/dist/esm/BaseClient.mjs +2 -2
  39. package/dist/esm/api/resources/aop/client/Client.d.mts +65 -8
  40. package/dist/esm/api/resources/aop/client/Client.mjs +214 -12
  41. package/dist/esm/api/resources/aop/client/requests/AopBatchExecuteRequestIn.d.mts +34 -0
  42. package/dist/esm/api/resources/aop/client/requests/AopBatchExecuteRequestIn.mjs +2 -0
  43. package/dist/esm/api/resources/aop/client/requests/ExecuteAsyncAopRequest.d.mts +22 -0
  44. package/dist/esm/api/resources/aop/client/requests/ExecuteAsyncAopRequest.mjs +2 -0
  45. package/dist/esm/api/resources/aop/client/requests/GetBatchStatusAopRequest.d.mts +18 -0
  46. package/dist/esm/api/resources/aop/client/requests/GetBatchStatusAopRequest.mjs +2 -0
  47. package/dist/esm/api/resources/aop/client/requests/index.d.mts +3 -0
  48. package/dist/esm/api/resources/threads/client/Client.d.mts +17 -0
  49. package/dist/esm/api/resources/threads/client/Client.mjs +81 -0
  50. package/dist/esm/api/resources/threads/client/requests/ThreadStatusBatchRequestIn.d.mts +10 -0
  51. package/dist/esm/api/resources/threads/client/requests/ThreadStatusBatchRequestIn.mjs +2 -0
  52. package/dist/esm/api/resources/threads/client/requests/index.d.mts +1 -0
  53. package/dist/esm/api/types/AopAsyncExecuteResponseOut.d.mts +2 -0
  54. package/dist/esm/api/types/AopBatchExecuteResponseOut.d.mts +16 -0
  55. package/dist/esm/api/types/AopBatchExecuteResponseOut.mjs +2 -0
  56. package/dist/esm/api/types/AopBatchRunIn.d.mts +13 -0
  57. package/dist/esm/api/types/AopBatchRunIn.mjs +2 -0
  58. package/dist/esm/api/types/AopBatchRunLaunchOut.d.mts +17 -0
  59. package/dist/esm/api/types/AopBatchRunLaunchOut.mjs +2 -0
  60. package/dist/esm/api/types/AopBatchRunStatusOut.d.mts +21 -0
  61. package/dist/esm/api/types/AopBatchRunStatusOut.mjs +2 -0
  62. package/dist/esm/api/types/AopBatchStatusCountsOut.d.mts +12 -0
  63. package/dist/esm/api/types/AopBatchStatusCountsOut.mjs +2 -0
  64. package/dist/esm/api/types/AopBatchStatusResponseOut.d.mts +20 -0
  65. package/dist/esm/api/types/AopBatchStatusResponseOut.mjs +2 -0
  66. package/dist/esm/api/types/ThreadStatusBatchItemOut.d.mts +27 -0
  67. package/dist/esm/api/types/ThreadStatusBatchItemOut.mjs +2 -0
  68. package/dist/esm/api/types/ThreadStatusBatchResponseOut.d.mts +20 -0
  69. package/dist/esm/api/types/ThreadStatusBatchResponseOut.mjs +2 -0
  70. package/dist/esm/api/types/index.d.mts +8 -0
  71. package/dist/esm/api/types/index.mjs +8 -0
  72. package/dist/esm/version.d.mts +1 -1
  73. package/dist/esm/version.mjs +1 -1
  74. package/package.json +1 -1
  75. package/reference.md +220 -6
package/README.md CHANGED
@@ -61,7 +61,7 @@ following namespace:
61
61
  ```typescript
62
62
  import { AthenaIntelligence } from "@athenaintel/sdk";
63
63
 
64
- const request: AthenaIntelligence.AopCreateRequestIn = {
64
+ const request: AthenaIntelligence.GetBatchStatusAopRequest = {
65
65
  ...
66
66
  };
67
67
  ```
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "@athenaintel/sdk",
46
- "X-Fern-SDK-Version": "4.3.2166",
47
- "User-Agent": "@athenaintel/sdk/4.3.2166",
46
+ "X-Fern-SDK-Version": "4.3.2168",
47
+ "User-Agent": "@athenaintel/sdk/4.3.2168",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -11,6 +11,26 @@ export declare namespace AopClient {
11
11
  export declare class AopClient {
12
12
  protected readonly _options: NormalizedClientOptionsWithAuth<AopClient.Options>;
13
13
  constructor(options?: AopClient.Options);
14
+ /**
15
+ * 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.
16
+ *
17
+ * @param {AthenaIntelligence.GetBatchStatusAopRequest} request
18
+ * @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
19
+ *
20
+ * @throws {@link AthenaIntelligence.BadRequestError}
21
+ * @throws {@link AthenaIntelligence.UnauthorizedError}
22
+ * @throws {@link AthenaIntelligence.NotFoundError}
23
+ * @throws {@link AthenaIntelligence.UnprocessableEntityError}
24
+ *
25
+ * @example
26
+ * await client.aop.getBatchStatus({
27
+ * batch_id: "batch_0f4c3c3e-1c1a-4a3e-9a5f-0d3f1a2b3c4d",
28
+ * status: "terminal",
29
+ * limit: 200
30
+ * })
31
+ */
32
+ getBatchStatus(request: AthenaIntelligence.GetBatchStatusAopRequest, requestOptions?: AopClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.AopBatchStatusResponseOut>;
33
+ private __getBatchStatus;
14
34
  /**
15
35
  * 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.
16
36
  *
@@ -65,32 +85,69 @@ export declare class AopClient {
65
85
  execute(request: AthenaIntelligence.AopExecuteRequestIn, requestOptions?: AopClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.AopExecuteResponseOut>;
66
86
  private __execute;
67
87
  /**
68
- * Start execution of an Agent Operating Procedure (AOP) asset asynchronously. Returns immediately with a thread_id for tracking execution progress without waiting for completion.
88
+ * 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.
69
89
  *
70
- * @param {AthenaIntelligence.AopExecuteRequestIn} request
90
+ * @param {AthenaIntelligence.ExecuteAsyncAopRequest} request
71
91
  * @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
72
92
  *
73
93
  * @throws {@link AthenaIntelligence.BadRequestError}
74
94
  * @throws {@link AthenaIntelligence.UnauthorizedError}
75
95
  * @throws {@link AthenaIntelligence.NotFoundError}
96
+ * @throws {@link AthenaIntelligence.ConflictError}
76
97
  * @throws {@link AthenaIntelligence.UnprocessableEntityError}
77
98
  * @throws {@link AthenaIntelligence.InternalServerError}
78
99
  *
79
100
  * @example
80
101
  * await client.aop.executeAsync({
102
+ * body: {
103
+ * asset_id: "asset_9249292-d118-42d3-95b4-00eccfe0754f",
104
+ * run_budget: {
105
+ * max_cost_usd: 30,
106
+ * max_model_calls: 80
107
+ * },
108
+ * user_inputs: {
109
+ * "company": "Acme Corp",
110
+ * "quarter": "Q1 2024"
111
+ * }
112
+ * }
113
+ * })
114
+ */
115
+ executeAsync(request: AthenaIntelligence.ExecuteAsyncAopRequest, requestOptions?: AopClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.AopAsyncExecuteResponseOut>;
116
+ private __executeAsync;
117
+ /**
118
+ * 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`.
119
+ *
120
+ * @param {AthenaIntelligence.AopBatchExecuteRequestIn} request
121
+ * @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
122
+ *
123
+ * @throws {@link AthenaIntelligence.BadRequestError}
124
+ * @throws {@link AthenaIntelligence.UnauthorizedError}
125
+ * @throws {@link AthenaIntelligence.NotFoundError}
126
+ * @throws {@link AthenaIntelligence.UnprocessableEntityError}
127
+ * @throws {@link AthenaIntelligence.InternalServerError}
128
+ *
129
+ * @example
130
+ * await client.aop.executeBatch({
81
131
  * asset_id: "asset_9249292-d118-42d3-95b4-00eccfe0754f",
82
132
  * run_budget: {
83
133
  * max_cost_usd: 30,
84
134
  * max_model_calls: 80
85
135
  * },
86
- * user_inputs: {
87
- * "company": "Acme Corp",
88
- * "quarter": "Q1 2024"
89
- * }
136
+ * runs: [{
137
+ * client_ref: "row-1",
138
+ * user_inputs: {
139
+ * "company": "Acme Corp"
140
+ * }
141
+ * }, {
142
+ * client_ref: "row-2",
143
+ * user_inputs: {
144
+ * "company": "Globex"
145
+ * }
146
+ * }]
90
147
  * })
91
148
  */
92
- executeAsync(request: AthenaIntelligence.AopExecuteRequestIn, requestOptions?: AopClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.AopAsyncExecuteResponseOut>;
93
- private __executeAsync;
149
+ executeBatch(request: AthenaIntelligence.AopBatchExecuteRequestIn, requestOptions?: AopClient.RequestOptions): core.HttpResponsePromise<AthenaIntelligence.AopBatchExecuteResponseOut>;
150
+ private __executeBatch;
94
151
  /**
95
152
  * Retrieve the full configuration of an AOP asset by its ID. Returns prompt, agent config, structured output schema, and other settings.
96
153
  *
@@ -65,6 +65,100 @@ class AopClient {
65
65
  constructor(options = {}) {
66
66
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
67
67
  }
68
+ /**
69
+ * 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.
70
+ *
71
+ * @param {AthenaIntelligence.GetBatchStatusAopRequest} request
72
+ * @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
73
+ *
74
+ * @throws {@link AthenaIntelligence.BadRequestError}
75
+ * @throws {@link AthenaIntelligence.UnauthorizedError}
76
+ * @throws {@link AthenaIntelligence.NotFoundError}
77
+ * @throws {@link AthenaIntelligence.UnprocessableEntityError}
78
+ *
79
+ * @example
80
+ * await client.aop.getBatchStatus({
81
+ * batch_id: "batch_0f4c3c3e-1c1a-4a3e-9a5f-0d3f1a2b3c4d",
82
+ * status: "terminal",
83
+ * limit: 200
84
+ * })
85
+ */
86
+ getBatchStatus(request, requestOptions) {
87
+ return core.HttpResponsePromise.fromPromise(this.__getBatchStatus(request, requestOptions));
88
+ }
89
+ __getBatchStatus(request, requestOptions) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
92
+ const { batch_id: batchId, status, cursor, limit } = request;
93
+ const _queryParams = {};
94
+ if (status != null) {
95
+ _queryParams.status = status;
96
+ }
97
+ if (cursor !== undefined) {
98
+ _queryParams.cursor = cursor;
99
+ }
100
+ if (limit != null) {
101
+ _queryParams.limit = limit.toString();
102
+ }
103
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
104
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
105
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
106
+ 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)}`),
107
+ method: "GET",
108
+ headers: _headers,
109
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
110
+ 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,
111
+ 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,
112
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
113
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
114
+ logging: this._options.logging,
115
+ });
116
+ if (_response.ok) {
117
+ return {
118
+ data: _response.body,
119
+ rawResponse: _response.rawResponse,
120
+ };
121
+ }
122
+ if (_response.error.reason === "status-code") {
123
+ switch (_response.error.statusCode) {
124
+ case 400:
125
+ throw new AthenaIntelligence.BadRequestError(_response.error.body, _response.rawResponse);
126
+ case 401:
127
+ throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
128
+ case 404:
129
+ throw new AthenaIntelligence.NotFoundError(_response.error.body, _response.rawResponse);
130
+ case 422:
131
+ throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
132
+ default:
133
+ throw new errors.AthenaIntelligenceError({
134
+ statusCode: _response.error.statusCode,
135
+ body: _response.error.body,
136
+ rawResponse: _response.rawResponse,
137
+ });
138
+ }
139
+ }
140
+ switch (_response.error.reason) {
141
+ case "non-json":
142
+ throw new errors.AthenaIntelligenceError({
143
+ statusCode: _response.error.statusCode,
144
+ body: _response.error.rawBody,
145
+ rawResponse: _response.rawResponse,
146
+ });
147
+ case "body-is-null":
148
+ throw new errors.AthenaIntelligenceError({
149
+ statusCode: _response.error.statusCode,
150
+ rawResponse: _response.rawResponse,
151
+ });
152
+ case "timeout":
153
+ throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling GET /api/v0/aop/batches/{batch_id}.");
154
+ case "unknown":
155
+ throw new errors.AthenaIntelligenceError({
156
+ message: _response.error.errorMessage,
157
+ rawResponse: _response.rawResponse,
158
+ });
159
+ }
160
+ });
161
+ }
68
162
  /**
69
163
  * 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.
70
164
  *
@@ -255,40 +349,148 @@ class AopClient {
255
349
  });
256
350
  }
257
351
  /**
258
- * Start execution of an Agent Operating Procedure (AOP) asset asynchronously. Returns immediately with a thread_id for tracking execution progress without waiting for completion.
352
+ * 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.
259
353
  *
260
- * @param {AthenaIntelligence.AopExecuteRequestIn} request
354
+ * @param {AthenaIntelligence.ExecuteAsyncAopRequest} request
261
355
  * @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
262
356
  *
263
357
  * @throws {@link AthenaIntelligence.BadRequestError}
264
358
  * @throws {@link AthenaIntelligence.UnauthorizedError}
265
359
  * @throws {@link AthenaIntelligence.NotFoundError}
360
+ * @throws {@link AthenaIntelligence.ConflictError}
266
361
  * @throws {@link AthenaIntelligence.UnprocessableEntityError}
267
362
  * @throws {@link AthenaIntelligence.InternalServerError}
268
363
  *
269
364
  * @example
270
365
  * await client.aop.executeAsync({
366
+ * body: {
367
+ * asset_id: "asset_9249292-d118-42d3-95b4-00eccfe0754f",
368
+ * run_budget: {
369
+ * max_cost_usd: 30,
370
+ * max_model_calls: 80
371
+ * },
372
+ * user_inputs: {
373
+ * "company": "Acme Corp",
374
+ * "quarter": "Q1 2024"
375
+ * }
376
+ * }
377
+ * })
378
+ */
379
+ executeAsync(request, requestOptions) {
380
+ return core.HttpResponsePromise.fromPromise(this.__executeAsync(request, requestOptions));
381
+ }
382
+ __executeAsync(request, requestOptions) {
383
+ return __awaiter(this, void 0, void 0, function* () {
384
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
385
+ const { "Idempotency-Key": idempotencyKey, body: _body } = request;
386
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
387
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Idempotency-Key": idempotencyKey !== undefined ? idempotencyKey : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
388
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
389
+ 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"),
390
+ method: "POST",
391
+ headers: _headers,
392
+ contentType: "application/json",
393
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
394
+ requestType: "json",
395
+ body: _body,
396
+ 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,
397
+ 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,
398
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
399
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
400
+ logging: this._options.logging,
401
+ });
402
+ if (_response.ok) {
403
+ return {
404
+ data: _response.body,
405
+ rawResponse: _response.rawResponse,
406
+ };
407
+ }
408
+ if (_response.error.reason === "status-code") {
409
+ switch (_response.error.statusCode) {
410
+ case 400:
411
+ throw new AthenaIntelligence.BadRequestError(_response.error.body, _response.rawResponse);
412
+ case 401:
413
+ throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
414
+ case 404:
415
+ throw new AthenaIntelligence.NotFoundError(_response.error.body, _response.rawResponse);
416
+ case 409:
417
+ throw new AthenaIntelligence.ConflictError(_response.error.body, _response.rawResponse);
418
+ case 422:
419
+ throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
420
+ case 500:
421
+ throw new AthenaIntelligence.InternalServerError(_response.error.body, _response.rawResponse);
422
+ default:
423
+ throw new errors.AthenaIntelligenceError({
424
+ statusCode: _response.error.statusCode,
425
+ body: _response.error.body,
426
+ rawResponse: _response.rawResponse,
427
+ });
428
+ }
429
+ }
430
+ switch (_response.error.reason) {
431
+ case "non-json":
432
+ throw new errors.AthenaIntelligenceError({
433
+ statusCode: _response.error.statusCode,
434
+ body: _response.error.rawBody,
435
+ rawResponse: _response.rawResponse,
436
+ });
437
+ case "body-is-null":
438
+ throw new errors.AthenaIntelligenceError({
439
+ statusCode: _response.error.statusCode,
440
+ rawResponse: _response.rawResponse,
441
+ });
442
+ case "timeout":
443
+ throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/aop/execute-async.");
444
+ case "unknown":
445
+ throw new errors.AthenaIntelligenceError({
446
+ message: _response.error.errorMessage,
447
+ rawResponse: _response.rawResponse,
448
+ });
449
+ }
450
+ });
451
+ }
452
+ /**
453
+ * 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`.
454
+ *
455
+ * @param {AthenaIntelligence.AopBatchExecuteRequestIn} request
456
+ * @param {AopClient.RequestOptions} requestOptions - Request-specific configuration.
457
+ *
458
+ * @throws {@link AthenaIntelligence.BadRequestError}
459
+ * @throws {@link AthenaIntelligence.UnauthorizedError}
460
+ * @throws {@link AthenaIntelligence.NotFoundError}
461
+ * @throws {@link AthenaIntelligence.UnprocessableEntityError}
462
+ * @throws {@link AthenaIntelligence.InternalServerError}
463
+ *
464
+ * @example
465
+ * await client.aop.executeBatch({
271
466
  * asset_id: "asset_9249292-d118-42d3-95b4-00eccfe0754f",
272
467
  * run_budget: {
273
468
  * max_cost_usd: 30,
274
469
  * max_model_calls: 80
275
470
  * },
276
- * user_inputs: {
277
- * "company": "Acme Corp",
278
- * "quarter": "Q1 2024"
279
- * }
471
+ * runs: [{
472
+ * client_ref: "row-1",
473
+ * user_inputs: {
474
+ * "company": "Acme Corp"
475
+ * }
476
+ * }, {
477
+ * client_ref: "row-2",
478
+ * user_inputs: {
479
+ * "company": "Globex"
480
+ * }
481
+ * }]
280
482
  * })
281
483
  */
282
- executeAsync(request, requestOptions) {
283
- return core.HttpResponsePromise.fromPromise(this.__executeAsync(request, requestOptions));
484
+ executeBatch(request, requestOptions) {
485
+ return core.HttpResponsePromise.fromPromise(this.__executeBatch(request, requestOptions));
284
486
  }
285
- __executeAsync(request, requestOptions) {
487
+ __executeBatch(request, requestOptions) {
286
488
  return __awaiter(this, void 0, void 0, function* () {
287
489
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
288
490
  const _authRequest = yield this._options.authProvider.getAuthRequest();
289
491
  const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
290
492
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
291
- 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"),
493
+ 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"),
292
494
  method: "POST",
293
495
  headers: _headers,
294
496
  contentType: "application/json",
@@ -340,7 +542,7 @@ class AopClient {
340
542
  rawResponse: _response.rawResponse,
341
543
  });
342
544
  case "timeout":
343
- throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/aop/execute-async.");
545
+ throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/aop/execute-batch.");
344
546
  case "unknown":
345
547
  throw new errors.AthenaIntelligenceError({
346
548
  message: _response.error.errorMessage,
@@ -0,0 +1,34 @@
1
+ import type * as AthenaIntelligence from "../../../../index.js";
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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ import type * as AthenaIntelligence from "../../../../index.js";
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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,6 @@
1
+ export type { AopBatchExecuteRequestIn } from "./AopBatchExecuteRequestIn.js";
1
2
  export type { AopConfigUpdateRequestIn } from "./AopConfigUpdateRequestIn.js";
2
3
  export type { AopCreateRequestIn } from "./AopCreateRequestIn.js";
4
+ export type { ExecuteAsyncAopRequest } from "./ExecuteAsyncAopRequest.js";
5
+ export type { GetBatchStatusAopRequest } from "./GetBatchStatusAopRequest.js";
3
6
  export type { GetConfigAopRequest } from "./GetConfigAopRequest.js";
@@ -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
  *
@@ -135,6 +135,87 @@ class ThreadsClient {
135
135
  }
136
136
  });
137
137
  }
138
+ /**
139
+ * 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.
140
+ *
141
+ * @param {AthenaIntelligence.ThreadStatusBatchRequestIn} request
142
+ * @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
143
+ *
144
+ * @throws {@link AthenaIntelligence.UnauthorizedError}
145
+ * @throws {@link AthenaIntelligence.UnprocessableEntityError}
146
+ * @throws {@link AthenaIntelligence.InternalServerError}
147
+ *
148
+ * @example
149
+ * await client.threads.getStatusBatch({
150
+ * thread_ids: ["thread_12345-6789-abcd-efgh", "thread_22345-6789-abcd-efgh"]
151
+ * })
152
+ */
153
+ getStatusBatch(request, requestOptions) {
154
+ return core.HttpResponsePromise.fromPromise(this.__getStatusBatch(request, requestOptions));
155
+ }
156
+ __getStatusBatch(request, requestOptions) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
159
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
160
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
161
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
162
+ 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"),
163
+ method: "POST",
164
+ headers: _headers,
165
+ contentType: "application/json",
166
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
167
+ requestType: "json",
168
+ body: request,
169
+ 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,
170
+ 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,
171
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
172
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
173
+ logging: this._options.logging,
174
+ });
175
+ if (_response.ok) {
176
+ return {
177
+ data: _response.body,
178
+ rawResponse: _response.rawResponse,
179
+ };
180
+ }
181
+ if (_response.error.reason === "status-code") {
182
+ switch (_response.error.statusCode) {
183
+ case 401:
184
+ throw new AthenaIntelligence.UnauthorizedError(_response.error.body, _response.rawResponse);
185
+ case 422:
186
+ throw new AthenaIntelligence.UnprocessableEntityError(_response.error.body, _response.rawResponse);
187
+ case 500:
188
+ throw new AthenaIntelligence.InternalServerError(_response.error.body, _response.rawResponse);
189
+ default:
190
+ throw new errors.AthenaIntelligenceError({
191
+ statusCode: _response.error.statusCode,
192
+ body: _response.error.body,
193
+ rawResponse: _response.rawResponse,
194
+ });
195
+ }
196
+ }
197
+ switch (_response.error.reason) {
198
+ case "non-json":
199
+ throw new errors.AthenaIntelligenceError({
200
+ statusCode: _response.error.statusCode,
201
+ body: _response.error.rawBody,
202
+ rawResponse: _response.rawResponse,
203
+ });
204
+ case "body-is-null":
205
+ throw new errors.AthenaIntelligenceError({
206
+ statusCode: _response.error.statusCode,
207
+ rawResponse: _response.rawResponse,
208
+ });
209
+ case "timeout":
210
+ throw new errors.AthenaIntelligenceTimeoutError("Timeout exceeded when calling POST /api/v0/threads/status-batch.");
211
+ case "unknown":
212
+ throw new errors.AthenaIntelligenceError({
213
+ message: _response.error.errorMessage,
214
+ rawResponse: _response.rawResponse,
215
+ });
216
+ }
217
+ });
218
+ }
138
219
  /**
139
220
  * 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.
140
221
  *
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,3 @@
1
1
  export type { GetStatusThreadsRequest } from "./GetStatusThreadsRequest.js";
2
2
  export type { StopThreadsRequest } from "./StopThreadsRequest.js";
3
+ export type { ThreadStatusBatchRequestIn } from "./ThreadStatusBatchRequestIn.js";
@@ -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 */