@agents24/client 0.1.0 → 0.2.1
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 +38 -6
- package/compatibility.json +10 -10
- package/dist/adapters/browser.d.ts +83 -1
- package/dist/adapters/browser.js +303 -3
- package/dist/adapters/browser.js.map +1 -1
- package/dist/adapters/cloudflare.js +3 -2
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/adapters/node.js +3 -2
- package/dist/adapters/node.js.map +1 -1
- package/dist/adapters/worker.js +3 -2
- package/dist/adapters/worker.js.map +1 -1
- package/dist/bff.d.ts +10 -0
- package/dist/bff.js +282 -0
- package/dist/bff.js.map +1 -0
- package/dist/chunk-FNR3KPB6.js +569 -0
- package/dist/chunk-FNR3KPB6.js.map +1 -0
- package/dist/{chunk-45ITVMX3.js → chunk-GXISGBVW.js} +126 -480
- package/dist/chunk-GXISGBVW.js.map +1 -0
- package/dist/{chunk-VVLMMNXI.js → chunk-IOVCURGW.js} +32 -14
- package/dist/chunk-IOVCURGW.js.map +1 -0
- package/dist/chunk-SPWEZFHZ.js +430 -0
- package/dist/chunk-SPWEZFHZ.js.map +1 -0
- package/dist/context-window.d.ts +16 -1
- package/dist/errors.d.ts +27 -2
- package/dist/generated/protocol.d.ts +50 -9
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -555
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +31 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runtime-types.d.ts +37 -2
- package/dist/types.d.ts +148 -10
- package/package.json +5 -1
- package/dist/chunk-45ITVMX3.js.map +0 -1
- package/dist/chunk-VVLMMNXI.js.map +0 -1
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { Agents24ClientError, normalizeBaseUrl, resolveFetch, resolveDecoderFactory, defaultClock, defaultIds, AuthenticatedHttp, encodePath, createByteMultipartEncoder, resolveEncoder, appendQuery, consumeThreadSummaryStream, responseJson, responseError, consumeRuntimeStream } from './chunk-GXISGBVW.js';
|
|
2
|
+
|
|
3
|
+
// src/client.ts
|
|
4
|
+
function objectResult(value, operation) {
|
|
5
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
6
|
+
throw new Agents24ClientError(`${operation} returned an invalid response.`, {
|
|
7
|
+
kind: "protocol",
|
|
8
|
+
code: "INVALID_JSON_RESPONSE"
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
function deploymentPath(deploymentId, suffix) {
|
|
14
|
+
return `/public/client-runtime/deployments/${encodePath(deploymentId)}${suffix}`;
|
|
15
|
+
}
|
|
16
|
+
function shouldReconnect(error) {
|
|
17
|
+
return error instanceof Agents24ClientError && error.kind === "network" && error.retryable;
|
|
18
|
+
}
|
|
19
|
+
function createAgents24Client(options) {
|
|
20
|
+
if (!options.deploymentId || /[\r\n\0/]/.test(options.deploymentId)) {
|
|
21
|
+
throw new Agents24ClientError("deploymentId is invalid.", {
|
|
22
|
+
kind: "configuration",
|
|
23
|
+
code: "INVALID_DEPLOYMENT_ID"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (options.transport !== void 0 && options.transport !== "auto" && options.transport !== "fetch") {
|
|
27
|
+
throw new Agents24ClientError("The requested transport is unavailable.", {
|
|
28
|
+
kind: "missing_capability",
|
|
29
|
+
code: "MISSING_TRANSPORT"
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const baseUrl = normalizeBaseUrl(options.baseUrl);
|
|
33
|
+
const fetch = resolveFetch(options.fetch);
|
|
34
|
+
const decoder = resolveDecoderFactory(options.decoder);
|
|
35
|
+
const clock = options.clock ?? defaultClock();
|
|
36
|
+
const ids = options.ids ?? defaultIds();
|
|
37
|
+
const maxReconnectAttempts = Math.max(0, Math.min(options.maxReconnectAttempts ?? 3, 10));
|
|
38
|
+
const http = new AuthenticatedHttp({
|
|
39
|
+
baseUrl,
|
|
40
|
+
sessionProvider: options.sessionProvider,
|
|
41
|
+
fetch,
|
|
42
|
+
clock,
|
|
43
|
+
...options.telemetry ? { telemetry: options.telemetry } : {}
|
|
44
|
+
});
|
|
45
|
+
const emit = async (event) => {
|
|
46
|
+
try {
|
|
47
|
+
await options.telemetry?.emit(event);
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const attach = async (runId, cursor, headers, signal, onEvent, onProgress) => {
|
|
52
|
+
const response = await http.request(
|
|
53
|
+
"POST",
|
|
54
|
+
deploymentPath(options.deploymentId, `/runs/${encodePath(runId)}/attach`),
|
|
55
|
+
{
|
|
56
|
+
operation: "runs.attach",
|
|
57
|
+
accept: "text/event-stream",
|
|
58
|
+
body: cursor === void 0 ? {} : { cursor },
|
|
59
|
+
...headers ? { headers } : {},
|
|
60
|
+
...signal ? { signal } : {}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
return consumeRuntimeStream({
|
|
64
|
+
response,
|
|
65
|
+
decoder: decoder(),
|
|
66
|
+
onEvent,
|
|
67
|
+
...signal ? { signal } : {},
|
|
68
|
+
...cursor === void 0 ? {} : { afterCursor: cursor },
|
|
69
|
+
...onProgress ? { onProgress } : {}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const reconnect = async (initial, signal, onEvent, operation, headers) => {
|
|
73
|
+
let state;
|
|
74
|
+
let attempt = 0;
|
|
75
|
+
const onProgress = (next) => {
|
|
76
|
+
if (!state) {
|
|
77
|
+
void emit({
|
|
78
|
+
type: "stream.connected",
|
|
79
|
+
operation,
|
|
80
|
+
...next.runId ? { runId: next.runId } : {},
|
|
81
|
+
...next.cursor === null ? {} : { cursor: next.cursor },
|
|
82
|
+
attempt
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
state = next;
|
|
86
|
+
};
|
|
87
|
+
while (true) {
|
|
88
|
+
try {
|
|
89
|
+
state = state?.runId ? await attach(state.runId, state.cursor ?? void 0, headers, signal, onEvent, onProgress) : await initial(onProgress);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (signal?.aborted || !shouldReconnect(error) || attempt >= maxReconnectAttempts) throw error;
|
|
92
|
+
attempt += 1;
|
|
93
|
+
await emit({
|
|
94
|
+
type: "stream.reconnecting",
|
|
95
|
+
operation,
|
|
96
|
+
...state?.runId ? { runId: state.runId } : {},
|
|
97
|
+
...state?.cursor == null ? {} : { cursor: state.cursor },
|
|
98
|
+
attempt,
|
|
99
|
+
reason: "network"
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!state.detached || signal?.aborted) {
|
|
104
|
+
await emit({
|
|
105
|
+
type: "stream.completed",
|
|
106
|
+
operation,
|
|
107
|
+
...state.runId ? { runId: state.runId } : {},
|
|
108
|
+
...state.cursor === null ? {} : { cursor: state.cursor },
|
|
109
|
+
attempt
|
|
110
|
+
});
|
|
111
|
+
return state;
|
|
112
|
+
}
|
|
113
|
+
await emit({
|
|
114
|
+
type: "stream.detached",
|
|
115
|
+
operation,
|
|
116
|
+
...state.runId ? { runId: state.runId } : {},
|
|
117
|
+
...state.cursor === null ? {} : { cursor: state.cursor },
|
|
118
|
+
attempt,
|
|
119
|
+
reason: state.detachReason ?? "server_detach"
|
|
120
|
+
});
|
|
121
|
+
if (attempt >= maxReconnectAttempts || state.detachReason === "revoked" || state.detachReason === "policy_changed") {
|
|
122
|
+
return state;
|
|
123
|
+
}
|
|
124
|
+
if (state.detachReason === "token_expired" && options.sessionProvider.refresh) {
|
|
125
|
+
await options.sessionProvider.refresh({ reason: "stream_detached", ...signal ? { signal } : {} });
|
|
126
|
+
}
|
|
127
|
+
attempt += 1;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
async bootstrap(input) {
|
|
132
|
+
let response;
|
|
133
|
+
try {
|
|
134
|
+
response = await fetch(
|
|
135
|
+
`${baseUrl}${deploymentPath(options.deploymentId, "/bootstrap")}`,
|
|
136
|
+
{
|
|
137
|
+
method: "GET",
|
|
138
|
+
headers: { Accept: "application/json", "Cache-Control": "no-store", Pragma: "no-cache" },
|
|
139
|
+
redirect: "error",
|
|
140
|
+
cache: "no-store",
|
|
141
|
+
credentials: "omit",
|
|
142
|
+
...input?.signal ? { signal: input.signal } : {}
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
} catch (cause) {
|
|
146
|
+
throw new Agents24ClientError("The Agents24 deployment bootstrap could not be reached.", {
|
|
147
|
+
kind: input?.signal?.aborted ? "aborted" : "network",
|
|
148
|
+
code: input?.signal?.aborted ? "ABORTED" : "NETWORK_ERROR",
|
|
149
|
+
retryable: !input?.signal?.aborted,
|
|
150
|
+
cause
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (response.redirected || response.status >= 300 && response.status < 400) {
|
|
154
|
+
throw new Agents24ClientError("Client-runtime redirects are not allowed.", {
|
|
155
|
+
kind: "network",
|
|
156
|
+
code: "REDIRECT_REJECTED",
|
|
157
|
+
status: response.status
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (!response.ok) throw await responseError(response);
|
|
161
|
+
return objectResult(await responseJson(response), "Bootstrap");
|
|
162
|
+
},
|
|
163
|
+
resourcePolicies: {
|
|
164
|
+
async getEffective(input) {
|
|
165
|
+
const response = await http.request(
|
|
166
|
+
"GET",
|
|
167
|
+
deploymentPath(options.deploymentId, "/resource-policy"),
|
|
168
|
+
{ operation: "resourcePolicies.getEffective", ...input?.signal ? { signal: input.signal } : {} }
|
|
169
|
+
);
|
|
170
|
+
return objectResult(await responseJson(response), "Effective Resource Policy");
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
chat: {
|
|
174
|
+
async stream(input, onEvent) {
|
|
175
|
+
const initial = async (onProgress) => {
|
|
176
|
+
const response = await http.request(
|
|
177
|
+
"POST",
|
|
178
|
+
deploymentPath(options.deploymentId, "/chat/stream"),
|
|
179
|
+
{
|
|
180
|
+
operation: "chat.stream",
|
|
181
|
+
accept: "text/event-stream",
|
|
182
|
+
idempotencyKey: input.idempotencyKey,
|
|
183
|
+
...input.headers ? { headers: input.headers } : {},
|
|
184
|
+
body: {
|
|
185
|
+
input: input.input,
|
|
186
|
+
attachment_ids: [...input.attachmentIds ?? []],
|
|
187
|
+
...input.threadId ? { thread_id: input.threadId } : {},
|
|
188
|
+
...input.requestedModelId ? { requested_model_id: input.requestedModelId } : {},
|
|
189
|
+
tool_inputs: input.toolInputs ?? {},
|
|
190
|
+
metadata: input.metadata ?? {},
|
|
191
|
+
client: input.client ?? { sdk_name: "@agents24/client", sdk_version: "0.2.1" }
|
|
192
|
+
},
|
|
193
|
+
...input.signal ? { signal: input.signal } : {}
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
return consumeRuntimeStream({
|
|
197
|
+
response,
|
|
198
|
+
decoder: decoder(),
|
|
199
|
+
onEvent,
|
|
200
|
+
...input.signal ? { signal: input.signal } : {},
|
|
201
|
+
onProgress
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
return reconnect(initial, input.signal, onEvent, "chat.stream", input.headers);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
runs: {
|
|
208
|
+
async attach(input, onEvent) {
|
|
209
|
+
const initial = (onProgress) => attach(input.runId, input.cursor, input.headers, input.signal, onEvent, onProgress);
|
|
210
|
+
return reconnect(initial, input.signal, onEvent, "runs.attach", input.headers);
|
|
211
|
+
},
|
|
212
|
+
async cancel(input) {
|
|
213
|
+
const result = await http.json(
|
|
214
|
+
"POST",
|
|
215
|
+
deploymentPath(options.deploymentId, `/runs/${encodePath(input.runId)}/cancel`),
|
|
216
|
+
{
|
|
217
|
+
operation: "runs.cancel",
|
|
218
|
+
body: {},
|
|
219
|
+
idempotencyKey: input.idempotencyKey,
|
|
220
|
+
...input.signal ? { signal: input.signal } : {}
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
return objectResult(result, "Run cancellation");
|
|
224
|
+
},
|
|
225
|
+
async setFeedback(input) {
|
|
226
|
+
const result = await http.json(
|
|
227
|
+
"PUT",
|
|
228
|
+
deploymentPath(
|
|
229
|
+
options.deploymentId,
|
|
230
|
+
`/runs/${encodePath(input.runId)}/feedback`
|
|
231
|
+
),
|
|
232
|
+
{
|
|
233
|
+
operation: "runs.setFeedback",
|
|
234
|
+
body: {
|
|
235
|
+
rating: input.rating,
|
|
236
|
+
...input.reason ? { reason: input.reason } : {},
|
|
237
|
+
...input.comment ? { comment: input.comment } : {}
|
|
238
|
+
},
|
|
239
|
+
...input.signal ? { signal: input.signal } : {}
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
return objectResult(result, "Response feedback");
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
threads: {
|
|
246
|
+
async list(input) {
|
|
247
|
+
const path = appendQuery(deploymentPath(options.deploymentId, "/threads"), {
|
|
248
|
+
skip: input?.skip,
|
|
249
|
+
limit: input?.limit
|
|
250
|
+
});
|
|
251
|
+
const result = await http.json("GET", path, {
|
|
252
|
+
operation: "threads.list",
|
|
253
|
+
...input?.signal ? { signal: input.signal } : {}
|
|
254
|
+
});
|
|
255
|
+
return objectResult(result, "Thread listing");
|
|
256
|
+
},
|
|
257
|
+
async get(input) {
|
|
258
|
+
const path = appendQuery(
|
|
259
|
+
deploymentPath(options.deploymentId, `/threads/${encodePath(input.threadId)}`),
|
|
260
|
+
{
|
|
261
|
+
limit: input.limit,
|
|
262
|
+
before_turn_index: input.beforeTurnIndex
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
const result = await http.json("GET", path, {
|
|
266
|
+
operation: "threads.get",
|
|
267
|
+
...input.signal ? { signal: input.signal } : {}
|
|
268
|
+
});
|
|
269
|
+
return objectResult(result, "Thread detail");
|
|
270
|
+
},
|
|
271
|
+
async events(input, onEvent) {
|
|
272
|
+
let cursor = input.cursor;
|
|
273
|
+
let attempts = 0;
|
|
274
|
+
while (!input.signal?.aborted) {
|
|
275
|
+
try {
|
|
276
|
+
const path = appendQuery(deploymentPath(options.deploymentId, "/threads/events"), { cursor });
|
|
277
|
+
const response = await http.request("GET", path, {
|
|
278
|
+
operation: "threads.events",
|
|
279
|
+
accept: "text/event-stream",
|
|
280
|
+
...input.signal ? { signal: input.signal } : {}
|
|
281
|
+
});
|
|
282
|
+
cursor = await consumeThreadSummaryStream({
|
|
283
|
+
response,
|
|
284
|
+
decoder: decoder(),
|
|
285
|
+
onEvent,
|
|
286
|
+
...input.signal ? { signal: input.signal } : {},
|
|
287
|
+
...cursor === void 0 ? {} : { afterCursor: cursor },
|
|
288
|
+
onCursor(next) {
|
|
289
|
+
cursor = next;
|
|
290
|
+
}
|
|
291
|
+
}) ?? void 0;
|
|
292
|
+
return;
|
|
293
|
+
} catch (error) {
|
|
294
|
+
if (input.signal?.aborted || !shouldReconnect(error) || attempts >= maxReconnectAttempts) throw error;
|
|
295
|
+
attempts += 1;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
async delete(input) {
|
|
300
|
+
const result = await http.json(
|
|
301
|
+
"DELETE",
|
|
302
|
+
deploymentPath(options.deploymentId, `/threads/${encodePath(input.threadId)}`),
|
|
303
|
+
{
|
|
304
|
+
operation: "threads.delete",
|
|
305
|
+
idempotencyKey: input.idempotencyKey,
|
|
306
|
+
...input.signal ? { signal: input.signal } : {}
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
return objectResult(result, "Thread deletion");
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
attachments: {
|
|
313
|
+
async uploadBatch(input) {
|
|
314
|
+
const multipart = options.multipart ?? createByteMultipartEncoder(resolveEncoder(options.encoder));
|
|
315
|
+
const encoded = await multipart.encode([
|
|
316
|
+
...input.threadId ? [{ field: "thread_id", value: input.threadId }] : [],
|
|
317
|
+
...input.uploads.map((upload) => ({ field: "files", value: upload }))
|
|
318
|
+
]);
|
|
319
|
+
const result = await http.json(
|
|
320
|
+
"POST",
|
|
321
|
+
deploymentPath(options.deploymentId, "/attachments/upload"),
|
|
322
|
+
{
|
|
323
|
+
operation: "attachments.upload",
|
|
324
|
+
rawBody: encoded.body,
|
|
325
|
+
contentType: encoded.contentType,
|
|
326
|
+
idempotencyKey: input.idempotencyKey,
|
|
327
|
+
...input.signal ? { signal: input.signal } : {}
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
const body = objectResult(result, "Attachment upload");
|
|
331
|
+
if (!Array.isArray(body.items)) throw new Error("Attachment upload returned an invalid batch");
|
|
332
|
+
return body.items.map((item) => objectResult(item, "Attachment upload"));
|
|
333
|
+
},
|
|
334
|
+
async createContentAccess(input) {
|
|
335
|
+
const result = await http.json(
|
|
336
|
+
"POST",
|
|
337
|
+
deploymentPath(
|
|
338
|
+
options.deploymentId,
|
|
339
|
+
`/attachments/${encodePath(input.attachmentId)}/content-access`
|
|
340
|
+
),
|
|
341
|
+
{
|
|
342
|
+
operation: "attachments.create_content_access",
|
|
343
|
+
body: { disposition: input.disposition },
|
|
344
|
+
...input.signal ? { signal: input.signal } : {}
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
return objectResult(result, "Attachment content access");
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
hitl: {
|
|
351
|
+
async resume(input) {
|
|
352
|
+
const result = await http.json(
|
|
353
|
+
"POST",
|
|
354
|
+
deploymentPath(
|
|
355
|
+
options.deploymentId,
|
|
356
|
+
`/runs/${encodePath(input.runId)}/hitl/${encodePath(input.interruptId)}/resume`
|
|
357
|
+
),
|
|
358
|
+
{
|
|
359
|
+
operation: "hitl.resume",
|
|
360
|
+
idempotencyKey: input.idempotencyKey,
|
|
361
|
+
body: {
|
|
362
|
+
schema_version: "agents24.hitl.resume.v2",
|
|
363
|
+
interrupt_id: input.interruptId,
|
|
364
|
+
action: input.action,
|
|
365
|
+
...input.comment ? { comment: input.comment } : {},
|
|
366
|
+
...input.answers ? { answers: input.answers } : {}
|
|
367
|
+
},
|
|
368
|
+
...input.signal ? { signal: input.signal } : {}
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
return objectResult(result, "HITL resume");
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
mcp: {
|
|
375
|
+
async startAuthorization(input) {
|
|
376
|
+
const result = await http.json(
|
|
377
|
+
"POST",
|
|
378
|
+
deploymentPath(
|
|
379
|
+
options.deploymentId,
|
|
380
|
+
`/runs/${encodePath(input.runId)}/mcp/servers/${encodePath(input.serverId)}/auth/start`
|
|
381
|
+
),
|
|
382
|
+
{
|
|
383
|
+
operation: "mcp.startAuthorization",
|
|
384
|
+
idempotencyKey: input.idempotencyKey,
|
|
385
|
+
body: {
|
|
386
|
+
interrupt_id: input.interruptId,
|
|
387
|
+
redirect_uri: input.redirectUri,
|
|
388
|
+
popup_nonce: input.popupNonce,
|
|
389
|
+
code_challenge: input.codeChallenge,
|
|
390
|
+
code_challenge_method: "S256"
|
|
391
|
+
},
|
|
392
|
+
...input.signal ? { signal: input.signal } : {}
|
|
393
|
+
}
|
|
394
|
+
);
|
|
395
|
+
return objectResult(result, "MCP authorization start");
|
|
396
|
+
},
|
|
397
|
+
async redeemCallback(input) {
|
|
398
|
+
const result = await http.json(
|
|
399
|
+
"POST",
|
|
400
|
+
deploymentPath(options.deploymentId, "/mcp/callback/redeem"),
|
|
401
|
+
{
|
|
402
|
+
operation: "mcp.redeemCallback",
|
|
403
|
+
idempotencyKey: input.idempotencyKey,
|
|
404
|
+
body: { code: input.code, code_verifier: input.codeVerifier },
|
|
405
|
+
...input.signal ? { signal: input.signal } : {}
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
return objectResult(result, "MCP callback redemption");
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
sessions: {
|
|
412
|
+
async revoke(input) {
|
|
413
|
+
if (!options.sessionProvider.revoke) {
|
|
414
|
+
throw new Agents24ClientError("The configured session provider cannot revoke sessions.", {
|
|
415
|
+
kind: "missing_capability",
|
|
416
|
+
code: "SESSION_REVOKE_UNAVAILABLE"
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
await options.sessionProvider.revoke({
|
|
420
|
+
idempotencyKey: input?.idempotencyKey ?? ids.createId(),
|
|
421
|
+
...input?.signal ? { signal: input.signal } : {}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
export { createAgents24Client };
|
|
429
|
+
//# sourceMappingURL=chunk-SPWEZFHZ.js.map
|
|
430
|
+
//# sourceMappingURL=chunk-SPWEZFHZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";;;AAwBA,SAAS,YAAA,CAA+B,OAAgB,SAAA,EAAsB;AAC5E,EAAA,IAAI,CAAC,SAAS,OAAO,KAAA,KAAU,YAAY,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC/D,IAAA,MAAM,IAAI,mBAAA,CAAoB,CAAA,EAAG,SAAS,CAAA,8BAAA,CAAA,EAAkC;AAAA,MAC1E,IAAA,EAAM,UAAA;AAAA,MACN,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,cAAA,CAAe,cAAsB,MAAA,EAAwB;AACpE,EAAA,OAAO,CAAA,mCAAA,EAAsC,UAAA,CAAW,YAAY,CAAC,GAAG,MAAM,CAAA,CAAA;AAChF;AAEA,SAAS,gBAAgB,KAAA,EAAyB;AAChD,EAAA,OAAO,KAAA,YAAiB,mBAAA,IAAuB,KAAA,CAAM,IAAA,KAAS,aAAa,KAAA,CAAM,SAAA;AACnF;AAEO,SAAS,qBAAqB,OAAA,EAA6C;AAChF,EAAA,IAAI,CAAC,OAAA,CAAQ,YAAA,IAAgB,YAAY,IAAA,CAAK,OAAA,CAAQ,YAAY,CAAA,EAAG;AACnE,IAAA,MAAM,IAAI,oBAAoB,0BAAA,EAA4B;AAAA,MACxD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ACnC,cAAA,EAAgB,KAAA,EAAO,cAAA,IAAkB,GAAA,CAAI,QAAA,EAAS;AAAA,UACtD,GAAI,OAAO,MAAA,GAAS,EAAE,QAAQ,KAAA,CAAM,MAAA,KAAW;AAAC,SACjD,CAAA;AAAA,MACH;AAAA;AACF,GACF;AACF","file":"chunk-SPWEZFHZ.js","sourcesContent":["import { defaultClock, defaultIds, resolveDecoderFactory, resolveEncoder, resolveFetch } from \"./capabilities.js\";\nimport { Agents24ClientError } from \"./errors.js\";\nimport { AuthenticatedHttp, responseError, responseJson } from \"./http.js\";\nimport { createByteMultipartEncoder } from \"./multipart.js\";\nimport { consumeRuntimeStream, consumeThreadSummaryStream, type RuntimeStreamState } from \"./stream.js\";\nimport { appendQuery, encodePath, normalizeBaseUrl } from \"./url.js\";\nimport type {\n AgentClient,\n Agents24ClientOptions,\n AttachmentResult,\n ClientBootstrap,\n EffectiveResourcePolicy,\n HitlResumeResult,\n McpAuthorizationResult,\n McpCallbackResult,\n ResponseFeedbackResult,\n RuntimeEventHandler,\n StreamResult,\n ThreadDetail,\n ThreadListResult,\n ThreadSummaryEventHandler,\n} from \"./types.js\";\nimport type { AttachmentContentAccess } from \"./runtime-types.js\";\n\nfunction objectResult<T extends object>(value: unknown, operation: string): T {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Agents24ClientError(`${operation} returned an invalid response.`, {\n kind: \"protocol\",\n code: \"INVALID_JSON_RESPONSE\",\n });\n }\n return value as T;\n}\n\nfunction deploymentPath(deploymentId: string, suffix: string): string {\n return `/public/client-runtime/deployments/${encodePath(deploymentId)}${suffix}`;\n}\n\nfunction shouldReconnect(error: unknown): boolean {\n return error instanceof Agents24ClientError && error.kind === \"network\" && error.retryable;\n}\n\nexport function createAgents24Client(options: Agents24ClientOptions): AgentClient {\n if (!options.deploymentId || /[\\r\\n\\0/]/.test(options.deploymentId)) {\n throw new Agents24ClientError(\"deploymentId is invalid.\", {\n kind: \"configuration\",\n code: \"INVALID_DEPLOYMENT_ID\",\n });\n }\n if (options.transport !== undefined && options.transport !== \"auto\" && options.transport !== \"fetch\") {\n throw new Agents24ClientError(\"The requested transport is unavailable.\", {\n kind: \"missing_capability\",\n code: \"MISSING_TRANSPORT\",\n });\n }\n const baseUrl = normalizeBaseUrl(options.baseUrl);\n const fetch = resolveFetch(options.fetch);\n const decoder = resolveDecoderFactory(options.decoder);\n const clock = options.clock ?? defaultClock();\n const ids = options.ids ?? defaultIds();\n const maxReconnectAttempts = Math.max(0, Math.min(options.maxReconnectAttempts ?? 3, 10));\n const http = new AuthenticatedHttp({\n baseUrl,\n sessionProvider: options.sessionProvider,\n fetch,\n clock,\n ...(options.telemetry ? { telemetry: options.telemetry } : {}),\n });\n const emit = async (event: Parameters<NonNullable<typeof options.telemetry>[\"emit\"]>[0]): Promise<void> => {\n try {\n await options.telemetry?.emit(event);\n } catch {\n // Telemetry is isolated from runtime behavior and credentials.\n }\n };\n\n const attach = async (\n runId: string,\n cursor: number | undefined,\n headers: Readonly<Record<string, string>> | undefined,\n signal: Parameters<AgentClient[\"runs\"][\"attach\"]>[0][\"signal\"],\n onEvent: RuntimeEventHandler,\n onProgress?: (state: RuntimeStreamState) => void,\n ): Promise<RuntimeStreamState> => {\n const response = await http.request(\n \"POST\",\n deploymentPath(options.deploymentId, `/runs/${encodePath(runId)}/attach`),\n {\n operation: \"runs.attach\",\n accept: \"text/event-stream\",\n body: cursor === undefined ? {} : { cursor },\n ...(headers ? { headers } : {}),\n ...(signal ? { signal } : {}),\n },\n );\n return consumeRuntimeStream({\n response,\n decoder: decoder(),\n onEvent,\n ...(signal ? { signal } : {}),\n ...(cursor === undefined ? {} : { afterCursor: cursor }),\n ...(onProgress ? { onProgress } : {}),\n });\n };\n\n const reconnect = async (\n initial: (onProgress: (next: RuntimeStreamState) => void) => Promise<RuntimeStreamState>,\n signal: Parameters<AgentClient[\"runs\"][\"attach\"]>[0][\"signal\"],\n onEvent: RuntimeEventHandler,\n operation: \"chat.stream\" | \"runs.attach\",\n headers?: Readonly<Record<string, string>>,\n ): Promise<StreamResult> => {\n let state: RuntimeStreamState | undefined;\n let attempt = 0;\n const onProgress = (next: RuntimeStreamState) => {\n if (!state) {\n void emit({\n type: \"stream.connected\",\n operation,\n ...(next.runId ? { runId: next.runId } : {}),\n ...(next.cursor === null ? {} : { cursor: next.cursor }),\n attempt,\n });\n }\n state = next;\n };\n while (true) {\n try {\n state = state?.runId\n ? await attach(state.runId, state.cursor ?? undefined, headers, signal, onEvent, onProgress)\n : await initial(onProgress);\n } catch (error) {\n if (signal?.aborted || !shouldReconnect(error) || attempt >= maxReconnectAttempts) throw error;\n attempt += 1;\n await emit({\n type: \"stream.reconnecting\",\n operation,\n ...(state?.runId ? { runId: state.runId } : {}),\n ...(state?.cursor == null ? {} : { cursor: state.cursor }),\n attempt,\n reason: \"network\",\n });\n continue;\n }\n if (!state.detached || signal?.aborted) {\n await emit({\n type: \"stream.completed\",\n operation,\n ...(state.runId ? { runId: state.runId } : {}),\n ...(state.cursor === null ? {} : { cursor: state.cursor }),\n attempt,\n });\n return state;\n }\n await emit({\n type: \"stream.detached\",\n operation,\n ...(state.runId ? { runId: state.runId } : {}),\n ...(state.cursor === null ? {} : { cursor: state.cursor }),\n attempt,\n reason: state.detachReason ?? \"server_detach\",\n });\n if (attempt >= maxReconnectAttempts || state.detachReason === \"revoked\" || state.detachReason === \"policy_changed\") {\n return state;\n }\n if (state.detachReason === \"token_expired\" && options.sessionProvider.refresh) {\n await options.sessionProvider.refresh({ reason: \"stream_detached\", ...(signal ? { signal } : {}) });\n }\n attempt += 1;\n }\n };\n\n return {\n async bootstrap(input) {\n let response: Awaited<ReturnType<typeof fetch>>;\n try {\n response = await fetch(\n `${baseUrl}${deploymentPath(options.deploymentId, \"/bootstrap\")}`,\n {\n method: \"GET\",\n headers: { Accept: \"application/json\", \"Cache-Control\": \"no-store\", Pragma: \"no-cache\" },\n redirect: \"error\",\n cache: \"no-store\",\n credentials: \"omit\",\n ...(input?.signal ? { signal: input.signal } : {}),\n },\n );\n } catch (cause) {\n throw new Agents24ClientError(\"The Agents24 deployment bootstrap could not be reached.\", {\n kind: input?.signal?.aborted ? \"aborted\" : \"network\",\n code: input?.signal?.aborted ? \"ABORTED\" : \"NETWORK_ERROR\",\n retryable: !input?.signal?.aborted,\n cause,\n });\n }\n if (response.redirected || (response.status >= 300 && response.status < 400)) {\n throw new Agents24ClientError(\"Client-runtime redirects are not allowed.\", {\n kind: \"network\",\n code: \"REDIRECT_REJECTED\",\n status: response.status,\n });\n }\n if (!response.ok) throw await responseError(response);\n return objectResult<ClientBootstrap>(await responseJson(response), \"Bootstrap\");\n },\n resourcePolicies: {\n async getEffective(input) {\n const response = await http.request(\n \"GET\",\n deploymentPath(options.deploymentId, \"/resource-policy\"),\n { operation: \"resourcePolicies.getEffective\", ...(input?.signal ? { signal: input.signal } : {}) },\n );\n return objectResult<EffectiveResourcePolicy>(await responseJson(response), \"Effective Resource Policy\");\n },\n },\n chat: {\n async stream(input, onEvent) {\n const initial = async (onProgress: (state: RuntimeStreamState) => void) => {\n const response = await http.request(\n \"POST\",\n deploymentPath(options.deploymentId, \"/chat/stream\"),\n {\n operation: \"chat.stream\",\n accept: \"text/event-stream\",\n idempotencyKey: input.idempotencyKey,\n ...(input.headers ? { headers: input.headers } : {}),\n body: {\n input: input.input,\n attachment_ids: [...(input.attachmentIds ?? [])],\n ...(input.threadId ? { thread_id: input.threadId } : {}),\n ...(input.requestedModelId ? { requested_model_id: input.requestedModelId } : {}),\n tool_inputs: input.toolInputs ?? {},\n metadata: input.metadata ?? {},\n client: input.client ?? { sdk_name: \"@agents24/client\", sdk_version: \"0.2.1\" },\n },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return consumeRuntimeStream({\n response,\n decoder: decoder(),\n onEvent,\n ...(input.signal ? { signal: input.signal } : {}),\n onProgress,\n });\n };\n return reconnect(initial, input.signal, onEvent, \"chat.stream\", input.headers);\n },\n },\n runs: {\n async attach(input, onEvent) {\n const initial = (onProgress: (state: RuntimeStreamState) => void) =>\n attach(input.runId, input.cursor, input.headers, input.signal, onEvent, onProgress);\n return reconnect(initial, input.signal, onEvent, \"runs.attach\", input.headers);\n },\n async cancel(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(options.deploymentId, `/runs/${encodePath(input.runId)}/cancel`),\n {\n operation: \"runs.cancel\",\n body: {},\n idempotencyKey: input.idempotencyKey,\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<Record<string, unknown>>(result, \"Run cancellation\");\n },\n async setFeedback(input) {\n const result = await http.json<unknown>(\n \"PUT\",\n deploymentPath(\n options.deploymentId,\n `/runs/${encodePath(input.runId)}/feedback`,\n ),\n {\n operation: \"runs.setFeedback\",\n body: {\n rating: input.rating,\n ...(input.reason ? { reason: input.reason } : {}),\n ...(input.comment ? { comment: input.comment } : {}),\n },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<ResponseFeedbackResult>(result, \"Response feedback\");\n },\n },\n threads: {\n async list(input) {\n const path = appendQuery(deploymentPath(options.deploymentId, \"/threads\"), {\n skip: input?.skip,\n limit: input?.limit,\n });\n const result = await http.json<unknown>(\"GET\", path, {\n operation: \"threads.list\",\n ...(input?.signal ? { signal: input.signal } : {}),\n });\n return objectResult<ThreadListResult>(result, \"Thread listing\");\n },\n async get(input) {\n const path = appendQuery(\n deploymentPath(options.deploymentId, `/threads/${encodePath(input.threadId)}`),\n {\n limit: input.limit,\n before_turn_index: input.beforeTurnIndex,\n },\n );\n const result = await http.json<unknown>(\"GET\", path, {\n operation: \"threads.get\",\n ...(input.signal ? { signal: input.signal } : {}),\n });\n return objectResult<ThreadDetail>(result, \"Thread detail\");\n },\n async events(input, onEvent: ThreadSummaryEventHandler) {\n let cursor = input.cursor;\n let attempts = 0;\n while (!input.signal?.aborted) {\n try {\n const path = appendQuery(deploymentPath(options.deploymentId, \"/threads/events\"), { cursor });\n const response = await http.request(\"GET\", path, {\n operation: \"threads.events\",\n accept: \"text/event-stream\",\n ...(input.signal ? { signal: input.signal } : {}),\n });\n cursor = (await consumeThreadSummaryStream({\n response,\n decoder: decoder(),\n onEvent,\n ...(input.signal ? { signal: input.signal } : {}),\n ...(cursor === undefined ? {} : { afterCursor: cursor }),\n onCursor(next) {\n cursor = next;\n },\n })) ?? undefined;\n return;\n } catch (error) {\n if (input.signal?.aborted || !shouldReconnect(error) || attempts >= maxReconnectAttempts) throw error;\n attempts += 1;\n }\n }\n },\n async delete(input) {\n const result = await http.json<unknown>(\n \"DELETE\",\n deploymentPath(options.deploymentId, `/threads/${encodePath(input.threadId)}`),\n {\n operation: \"threads.delete\",\n idempotencyKey: input.idempotencyKey,\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<Record<string, unknown>>(result, \"Thread deletion\");\n },\n },\n attachments: {\n async uploadBatch(input) {\n const multipart = options.multipart ?? createByteMultipartEncoder(resolveEncoder(options.encoder));\n const encoded = await multipart.encode([\n ...(input.threadId ? [{ field: \"thread_id\", value: input.threadId }] : []),\n ...input.uploads.map((upload) => ({ field: \"files\", value: upload })),\n ]);\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(options.deploymentId, \"/attachments/upload\"),\n {\n operation: \"attachments.upload\",\n rawBody: encoded.body,\n contentType: encoded.contentType,\n idempotencyKey: input.idempotencyKey,\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n const body = objectResult<Record<string, unknown>>(result, \"Attachment upload\");\n if (!Array.isArray(body.items)) throw new Error(\"Attachment upload returned an invalid batch\");\n return body.items.map((item) => objectResult<AttachmentResult>(item, \"Attachment upload\"));\n },\n async createContentAccess(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(\n options.deploymentId,\n `/attachments/${encodePath(input.attachmentId)}/content-access`,\n ),\n {\n operation: \"attachments.create_content_access\",\n body: { disposition: input.disposition },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<AttachmentContentAccess>(result, \"Attachment content access\");\n },\n },\n hitl: {\n async resume(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(\n options.deploymentId,\n `/runs/${encodePath(input.runId)}/hitl/${encodePath(input.interruptId)}/resume`,\n ),\n {\n operation: \"hitl.resume\",\n idempotencyKey: input.idempotencyKey,\n body: {\n schema_version: \"agents24.hitl.resume.v2\",\n interrupt_id: input.interruptId,\n action: input.action,\n ...(input.comment ? { comment: input.comment } : {}),\n ...(input.answers ? { answers: input.answers } : {}),\n },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<HitlResumeResult>(result, \"HITL resume\");\n },\n },\n mcp: {\n async startAuthorization(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(\n options.deploymentId,\n `/runs/${encodePath(input.runId)}/mcp/servers/${encodePath(input.serverId)}/auth/start`,\n ),\n {\n operation: \"mcp.startAuthorization\",\n idempotencyKey: input.idempotencyKey,\n body: {\n interrupt_id: input.interruptId,\n redirect_uri: input.redirectUri,\n popup_nonce: input.popupNonce,\n code_challenge: input.codeChallenge,\n code_challenge_method: \"S256\",\n },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<McpAuthorizationResult>(result, \"MCP authorization start\");\n },\n async redeemCallback(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(options.deploymentId, \"/mcp/callback/redeem\"),\n {\n operation: \"mcp.redeemCallback\",\n idempotencyKey: input.idempotencyKey,\n body: { code: input.code, code_verifier: input.codeVerifier },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<McpCallbackResult>(result, \"MCP callback redemption\");\n },\n },\n sessions: {\n async revoke(input) {\n if (!options.sessionProvider.revoke) {\n throw new Agents24ClientError(\"The configured session provider cannot revoke sessions.\", {\n kind: \"missing_capability\",\n code: \"SESSION_REVOKE_UNAVAILABLE\",\n });\n }\n await options.sessionProvider.revoke({\n idempotencyKey: input?.idempotencyKey ?? ids.createId(),\n ...(input?.signal ? { signal: input.signal } : {}),\n });\n },\n },\n };\n}\n"]}
|
package/dist/context-window.d.ts
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
export type ContextWindowSource = "exact" | "estimated" | "provider_count_api" | "provider_usage" | "provider_cached_estimate" | "runtime_tokenizer" | "hf_tokenizer" | "multimodal_estimate" | "text_estimate" | "tokenizer_estimate" | "heuristic_estimate" | "unknown";
|
|
1
|
+
export type ContextWindowSource = "exact" | "estimated" | "provider_count_api" | "provider_usage" | "provider_cached_estimate" | "runtime_tokenizer" | "hf_tokenizer" | "lab_tokenizer" | "tiktoken" | "multimodal_estimate" | "text_estimate" | "tokenizer_estimate" | "heuristic_estimate" | "unknown";
|
|
2
2
|
export type ContextWindowStage = "preflight" | "sent_prompt" | "final_usage";
|
|
3
3
|
export type ContextWindowConfidence = "exact" | "high" | "medium" | "low" | "unknown";
|
|
4
4
|
export type ContextCompression = {
|
|
5
5
|
active: boolean;
|
|
6
|
+
status?: "started" | "completed" | "failed" | null;
|
|
7
|
+
strategy?: "artifact_references" | "semantic_checkpoint" | null;
|
|
6
8
|
reason?: string | null;
|
|
7
9
|
input_tokens?: number | null;
|
|
8
10
|
max_tokens?: number | null;
|
|
9
11
|
usage_ratio?: number | null;
|
|
12
|
+
admission_input_tokens?: number | null;
|
|
13
|
+
admission_input_tokens_before?: number | null;
|
|
14
|
+
admission_input_tokens_after?: number | null;
|
|
15
|
+
admission_ratio?: number | null;
|
|
16
|
+
admission_confidence?: ContextWindowConfidence | null;
|
|
17
|
+
applied_margin?: number | null;
|
|
10
18
|
full_frame_count?: number | null;
|
|
11
19
|
compact_frame_count?: number | null;
|
|
12
20
|
dropped_frame_count?: number | null;
|
|
13
21
|
artifact_ref_count?: number | null;
|
|
22
|
+
checkpoint_frame_count?: number | null;
|
|
23
|
+
input_tokens_before?: number | null;
|
|
24
|
+
input_tokens_after?: number | null;
|
|
14
25
|
compression_trigger_budget?: number | null;
|
|
15
26
|
compression_target_budget?: number | null;
|
|
16
27
|
compression_target_ratio?: number | null;
|
|
@@ -28,6 +39,10 @@ export type ContextWindow = {
|
|
|
28
39
|
input_tokens?: number | null;
|
|
29
40
|
remaining_tokens?: number | null;
|
|
30
41
|
usage_ratio?: number | null;
|
|
42
|
+
admission_input_tokens?: number | null;
|
|
43
|
+
admission_ratio?: number | null;
|
|
44
|
+
admission_confidence?: ContextWindowConfidence | null;
|
|
45
|
+
applied_margin?: number | null;
|
|
31
46
|
assembly?: Record<string, unknown> | null;
|
|
32
47
|
context_compression?: ContextCompression | null;
|
|
33
48
|
};
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,25 +1,50 @@
|
|
|
1
1
|
export type Agents24ErrorKind = "configuration" | "missing_capability" | "authentication" | "authorization" | "not_found" | "conflict" | "quota" | "rate_limit" | "validation" | "protocol" | "network" | "aborted" | "server";
|
|
2
|
-
export interface
|
|
2
|
+
export interface FailureView {
|
|
3
|
+
schema_version: "agents24.failure.v1";
|
|
4
|
+
failure_id: string;
|
|
3
5
|
code: string;
|
|
6
|
+
category: string;
|
|
4
7
|
message: string;
|
|
5
|
-
request_id: string;
|
|
6
8
|
retryable: boolean;
|
|
9
|
+
request_id: string | null;
|
|
10
|
+
retry_after_ms: number | null;
|
|
11
|
+
details: Readonly<Record<string, unknown>>;
|
|
12
|
+
}
|
|
13
|
+
export interface ResourcePolicyViolation {
|
|
14
|
+
policy_subject_type: "agent" | "client_deployment" | "user";
|
|
15
|
+
rule_type: "allow" | "quota";
|
|
16
|
+
resource_type: "agent" | "model" | "tool" | "toolset" | "knowledge_store";
|
|
17
|
+
resource_name: string;
|
|
18
|
+
aggregation_scope?: "subject" | "consumer";
|
|
19
|
+
quota_unit?: "tokens";
|
|
20
|
+
quota_window?: "monthly";
|
|
21
|
+
limit?: number;
|
|
22
|
+
remaining?: number;
|
|
23
|
+
resets_at?: string;
|
|
7
24
|
}
|
|
8
25
|
export declare class Agents24ClientError extends Error {
|
|
9
26
|
readonly kind: Agents24ErrorKind;
|
|
10
27
|
readonly code: string;
|
|
11
28
|
readonly status: number | undefined;
|
|
29
|
+
readonly failure: FailureView | undefined;
|
|
12
30
|
readonly requestId: string | undefined;
|
|
13
31
|
readonly retryable: boolean;
|
|
32
|
+
readonly violations: readonly ResourcePolicyViolation[];
|
|
14
33
|
readonly cause?: unknown;
|
|
15
34
|
constructor(message: string, options: {
|
|
16
35
|
kind: Agents24ErrorKind;
|
|
17
36
|
code?: string;
|
|
18
37
|
status?: number;
|
|
38
|
+
failure?: FailureView;
|
|
19
39
|
requestId?: string;
|
|
20
40
|
retryable?: boolean;
|
|
41
|
+
violations?: readonly ResourcePolicyViolation[];
|
|
21
42
|
cause?: unknown;
|
|
22
43
|
});
|
|
44
|
+
get failureId(): string | undefined;
|
|
45
|
+
get category(): string | undefined;
|
|
46
|
+
get retryAfterMs(): number | undefined;
|
|
47
|
+
get details(): Readonly<Record<string, unknown>>;
|
|
23
48
|
}
|
|
24
49
|
export declare function missingCapability(name: string): Agents24ClientError;
|
|
25
50
|
export declare function abortedError(cause?: unknown): Agents24ClientError;
|