@agents24/node 0.5.9 → 0.5.11
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/compatibility.json +7 -7
- package/dist/bff.cjs +81 -57
- package/dist/bff.cjs.map +1 -1
- package/dist/bff.d.cts +1 -1
- package/dist/bff.d.ts +1 -1
- package/dist/bff.js +81 -57
- package/dist/bff.js.map +1 -1
- package/dist/{client-DA9J56wi.d.cts → client-DTdpRgGB.d.cts} +111 -1
- package/dist/{client-DA9J56wi.d.ts → client-DTdpRgGB.d.ts} +111 -1
- package/dist/index.cjs +65 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +65 -18
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +11 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +6 -1
- package/dist/server.d.ts +6 -1
- package/dist/server.js +11 -2
- package/dist/server.js.map +1 -1
- package/dist/types/bff-values.d.ts +6 -0
- package/dist/types/bff-values.d.ts.map +1 -0
- package/dist/types/bff.d.ts.map +1 -1
- package/dist/types/client.d.ts +2 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/delegations.d.ts +80 -0
- package/dist/types/delegations.d.ts.map +1 -0
- package/dist/types/generated/delegations.d.ts +18 -0
- package/dist/types/generated/delegations.d.ts.map +1 -0
- package/dist/types/generated/manifest.d.ts +1 -1
- package/dist/types/generated/manifest.d.ts.map +1 -1
- package/dist/types/generated/resourceInstallations.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/server.d.ts +5 -0
- package/dist/types/server.d.ts.map +1 -1
- package/dist/types/types.d.ts +15 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +4 -4
package/compatibility.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"contractHash": "
|
|
2
|
+
"contractHash": "dd147d991227abbd4733d63e7203e32b1e918df689d540681dec0d0678311af1",
|
|
3
3
|
"contractVersion": "0.3.0",
|
|
4
4
|
"corpus": "conformance/v1/corpus.json",
|
|
5
5
|
"generatedBy": "@agents24/sdk-contract",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"reactDom": ">=19 <20"
|
|
16
16
|
},
|
|
17
17
|
"@agents24/client": {
|
|
18
|
-
"contract": "
|
|
18
|
+
"contract": "f936f83dc38a06dcf3690e0c0474a5558704cb1c866b0a688d62a4514a5a81cf",
|
|
19
19
|
"runtime": "run-stream.v3"
|
|
20
20
|
},
|
|
21
21
|
"@agents24/node": {
|
|
22
|
-
"contract": "
|
|
22
|
+
"contract": "dd147d991227abbd4733d63e7203e32b1e918df689d540681dec0d0678311af1",
|
|
23
23
|
"node": "^22.0.0 || ^24.0.0"
|
|
24
24
|
},
|
|
25
25
|
"@agents24/react": {
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"react": ">=19 <20"
|
|
28
28
|
},
|
|
29
29
|
"@talmudpedia/runtime-sdk": {
|
|
30
|
-
"contract": "
|
|
30
|
+
"contract": "f936f83dc38a06dcf3690e0c0474a5558704cb1c866b0a688d62a4514a5a81cf",
|
|
31
31
|
"protocolOwner": "@agents24/client"
|
|
32
32
|
},
|
|
33
33
|
"agents24": {
|
|
34
|
-
"contract": "
|
|
34
|
+
"contract": "dd147d991227abbd4733d63e7203e32b1e918df689d540681dec0d0678311af1",
|
|
35
35
|
"python": ">=3.10"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"schemaVersion": "agents24.compatibility.v1",
|
|
49
49
|
"targetOperationCounts": {
|
|
50
50
|
"client": 22,
|
|
51
|
-
"node":
|
|
52
|
-
"python":
|
|
51
|
+
"node": 112,
|
|
52
|
+
"python": 105
|
|
53
53
|
}
|
|
54
54
|
}
|
package/dist/bff.cjs
CHANGED
|
@@ -189,7 +189,7 @@ function errorResponse(error) {
|
|
|
189
189
|
|
|
190
190
|
// src/bff-diagnostics.ts
|
|
191
191
|
function emitDiagnostic(callback, diagnostic) {
|
|
192
|
-
void Promise.resolve(callback(diagnostic)).catch(() => void 0);
|
|
192
|
+
void Promise.resolve().then(() => callback(diagnostic)).catch(() => void 0);
|
|
193
193
|
}
|
|
194
194
|
function reportFailureResponse(callback, request, operation, response) {
|
|
195
195
|
if (!callback || response.status < 400) return response;
|
|
@@ -215,6 +215,44 @@ function reportFailureResponse(callback, request, operation, response) {
|
|
|
215
215
|
return response;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
// src/bff-values.ts
|
|
219
|
+
function normalized(value, field) {
|
|
220
|
+
const result = String(value || "").trim();
|
|
221
|
+
if (!result || /[\r\n\0]/.test(result)) throw new Error(`${field} is required.`);
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
function stringValue(value) {
|
|
225
|
+
const result = typeof value === "string" ? value.trim() : "";
|
|
226
|
+
return result || void 0;
|
|
227
|
+
}
|
|
228
|
+
function stringList(value) {
|
|
229
|
+
return Array.isArray(value) ? value.map(stringValue).filter((item) => Boolean(item)) : [];
|
|
230
|
+
}
|
|
231
|
+
function objectValue(value) {
|
|
232
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
233
|
+
}
|
|
234
|
+
function bootstrapDocument(raw, agentVersionId) {
|
|
235
|
+
const features = objectValue(raw.features);
|
|
236
|
+
const selectable = objectValue(features.models).selectable === true;
|
|
237
|
+
const resolvedVersionId = stringValue(raw.agent_version_id) || agentVersionId || "";
|
|
238
|
+
const versionNumber = Number(raw.agent_version_number || 0);
|
|
239
|
+
return {
|
|
240
|
+
version: String(raw.version || "agents24.embed.bootstrap.v1"),
|
|
241
|
+
deployment: {
|
|
242
|
+
id: "server-embed",
|
|
243
|
+
name: normalized(String(raw.agent_name || ""), "agent_name"),
|
|
244
|
+
version_policy: agentVersionId ? { mode: "pinned", version_id: agentVersionId } : { mode: "latest_published" },
|
|
245
|
+
resolved_agent_version_id: resolvedVersionId,
|
|
246
|
+
resolved_agent_version_number: Number.isFinite(versionNumber) ? versionNumber : 0,
|
|
247
|
+
policy_epoch: 0
|
|
248
|
+
},
|
|
249
|
+
authentication: { modes: ["server_embed"], access_token_lifetime_seconds: 0, jwks_path: "" },
|
|
250
|
+
capabilities: ["attachments.read", "attachments.write", "feedback.write", ...selectable ? ["models.select"] : []],
|
|
251
|
+
features,
|
|
252
|
+
native_profiles: []
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
218
256
|
// src/bff.ts
|
|
219
257
|
var JSON_LIMIT_BYTES = 1048576;
|
|
220
258
|
var MAX_INPUT_LENGTH = 2e5;
|
|
@@ -261,11 +299,6 @@ function createCustomerIdentityResolver(embed, integrationId, integrationName) {
|
|
|
261
299
|
return value;
|
|
262
300
|
};
|
|
263
301
|
}
|
|
264
|
-
function normalized(value, field) {
|
|
265
|
-
const result = String(value || "").trim();
|
|
266
|
-
if (!result || /[\r\n\0]/.test(result)) throw new Error(`${field} is required.`);
|
|
267
|
-
return result;
|
|
268
|
-
}
|
|
269
302
|
function normalizeBasePath(value) {
|
|
270
303
|
const path = String(value || "/api/agents24").trim().replace(/\/+$/, "");
|
|
271
304
|
if (!path.startsWith("/") || /[\r\n\0?#]/.test(path)) throw new Error("basePath must be an absolute path.");
|
|
@@ -313,16 +346,6 @@ var BffInputError = class extends Error {
|
|
|
313
346
|
status;
|
|
314
347
|
code;
|
|
315
348
|
};
|
|
316
|
-
function stringValue(value) {
|
|
317
|
-
const result = typeof value === "string" ? value.trim() : "";
|
|
318
|
-
return result || void 0;
|
|
319
|
-
}
|
|
320
|
-
function stringList(value) {
|
|
321
|
-
return Array.isArray(value) ? value.map(stringValue).filter((item) => Boolean(item)) : [];
|
|
322
|
-
}
|
|
323
|
-
function objectValue(value) {
|
|
324
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
325
|
-
}
|
|
326
349
|
function routeId(path, pattern, field) {
|
|
327
350
|
const match = pattern.exec(path);
|
|
328
351
|
if (!match?.[1]) throw new BffInputError(404, "NOT_FOUND", "The requested BFF route does not exist.");
|
|
@@ -366,27 +389,6 @@ function sseResponse(execute, headers, failurePayload, onFailure) {
|
|
|
366
389
|
}).finally(() => writer.close().catch(() => void 0));
|
|
367
390
|
return new Response(stream.readable, { headers: sseHeaders(headers) });
|
|
368
391
|
}
|
|
369
|
-
function bootstrapDocument(raw, agentVersionId) {
|
|
370
|
-
const features = objectValue(raw.features);
|
|
371
|
-
const selectable = objectValue(features.models).selectable === true;
|
|
372
|
-
const resolvedVersionId = stringValue(raw.agent_version_id) || agentVersionId || "";
|
|
373
|
-
const versionNumber = Number(raw.agent_version_number || 0);
|
|
374
|
-
return {
|
|
375
|
-
version: String(raw.version || "agents24.embed.bootstrap.v1"),
|
|
376
|
-
deployment: {
|
|
377
|
-
id: "server-embed",
|
|
378
|
-
name: normalized(String(raw.agent_name || ""), "agent_name"),
|
|
379
|
-
version_policy: agentVersionId ? { mode: "pinned", version_id: agentVersionId } : { mode: "latest_published" },
|
|
380
|
-
resolved_agent_version_id: resolvedVersionId,
|
|
381
|
-
resolved_agent_version_number: Number.isFinite(versionNumber) ? versionNumber : 0,
|
|
382
|
-
policy_epoch: 0
|
|
383
|
-
},
|
|
384
|
-
authentication: { modes: ["server_embed"], access_token_lifetime_seconds: 0, jwks_path: "" },
|
|
385
|
-
capabilities: ["attachments.read", "attachments.write", "feedback.write", ...selectable ? ["models.select"] : []],
|
|
386
|
-
features,
|
|
387
|
-
native_profiles: []
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
392
|
function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity) {
|
|
391
393
|
const agentId = normalized(options.agentId, "agentId");
|
|
392
394
|
const agentVersionId = stringValue(options.agentVersionId);
|
|
@@ -452,21 +454,32 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
452
454
|
if (attachmentIds.length > MAX_ATTACHMENTS) {
|
|
453
455
|
throw new BffInputError(400, "TOO_MANY_ATTACHMENTS", `At most ${MAX_ATTACHMENTS} attachments are allowed.`);
|
|
454
456
|
}
|
|
457
|
+
const admission = await embed.startAgentRun(agentId, {
|
|
458
|
+
...identity,
|
|
459
|
+
integration_id: integrationId,
|
|
460
|
+
...agentVersionId ? { agent_version_id: agentVersionId } : {},
|
|
461
|
+
runtime_target: runtimeTarget,
|
|
462
|
+
...input ? { input } : {},
|
|
463
|
+
attachment_ids: attachmentIds,
|
|
464
|
+
...stringValue(body.threadId) ? { thread_id: stringValue(body.threadId) } : {},
|
|
465
|
+
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
466
|
+
tool_inputs: objectValue(body.toolInputs),
|
|
467
|
+
metadata: objectValue(body.metadata),
|
|
468
|
+
client: objectValue(body.client)
|
|
469
|
+
}, { idempotencyKey });
|
|
455
470
|
response = sseResponse(async (write) => {
|
|
456
|
-
await embed.
|
|
471
|
+
await embed.attachAgentRun(agentId, admission.run_id, {
|
|
457
472
|
...identity,
|
|
458
473
|
integration_id: integrationId,
|
|
459
|
-
...agentVersionId ? { agent_version_id: agentVersionId } : {},
|
|
460
474
|
runtime_target: runtimeTarget,
|
|
461
|
-
...input ? { input } : {},
|
|
462
|
-
attachment_ids: attachmentIds,
|
|
463
|
-
...stringValue(body.threadId) ? { thread_id: stringValue(body.threadId) } : {},
|
|
464
|
-
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
465
|
-
tool_inputs: objectValue(body.toolInputs),
|
|
466
475
|
metadata: objectValue(body.metadata),
|
|
467
|
-
client: objectValue(body.client)
|
|
468
|
-
|
|
469
|
-
|
|
476
|
+
client: objectValue(body.client),
|
|
477
|
+
cursor: 0
|
|
478
|
+
}, (event) => write(event), { signal: request.signal });
|
|
479
|
+
}, {
|
|
480
|
+
"X-Run-ID": admission.run_id,
|
|
481
|
+
...admission.thread_id ? { "X-Thread-ID": admission.thread_id } : {}
|
|
482
|
+
}, void 0, streamFailure(request, "chat.stream"));
|
|
470
483
|
} else if (request.method === "POST" && /^\/runs\/[^/]+\/attach$/.test(path)) {
|
|
471
484
|
const runId = routeId(path, /^\/runs\/([^/]+)\/attach$/, "runId");
|
|
472
485
|
const body = await requestJson(request);
|
|
@@ -789,21 +802,32 @@ function createResolvedAgents24BffHandler(options) {
|
|
|
789
802
|
if (!input && attachmentIds.length === 0) throw new BffInputError(400, "INPUT_REQUIRED", "A message or attachment is required.");
|
|
790
803
|
if (input && input.length > MAX_INPUT_LENGTH) throw new BffInputError(413, "INPUT_TOO_LARGE", "The message is too large.");
|
|
791
804
|
if (attachmentIds.length > MAX_ATTACHMENTS) throw new BffInputError(400, "TOO_MANY_ATTACHMENTS", `At most ${MAX_ATTACHMENTS} attachments are allowed.`);
|
|
805
|
+
const admission = await options.client.embed.startAgentRun(selected.agentId, {
|
|
806
|
+
...identity,
|
|
807
|
+
...selected.agentVersionId ? { agent_version_id: selected.agentVersionId } : {},
|
|
808
|
+
runtime_target: runtimeTarget,
|
|
809
|
+
integration_id: integrationId,
|
|
810
|
+
...input ? { input } : {},
|
|
811
|
+
attachment_ids: attachmentIds,
|
|
812
|
+
...stringValue(body.threadId) ? { thread_id: stringValue(body.threadId) } : {},
|
|
813
|
+
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
814
|
+
tool_inputs: objectValue(body.toolInputs),
|
|
815
|
+
metadata: objectValue(body.metadata),
|
|
816
|
+
client: objectValue(body.client)
|
|
817
|
+
}, { idempotencyKey: stringValue(request.headers.get("idempotency-key")) });
|
|
792
818
|
return mergeHeaders(sseResponse(async (write) => {
|
|
793
|
-
await options.client.embed.
|
|
819
|
+
await options.client.embed.attachAgentRun(selected.agentId, admission.run_id, {
|
|
794
820
|
...identity,
|
|
795
|
-
...selected.agentVersionId ? { agent_version_id: selected.agentVersionId } : {},
|
|
796
821
|
runtime_target: runtimeTarget,
|
|
797
822
|
integration_id: integrationId,
|
|
798
|
-
...input ? { input } : {},
|
|
799
|
-
attachment_ids: attachmentIds,
|
|
800
|
-
...stringValue(body.threadId) ? { thread_id: stringValue(body.threadId) } : {},
|
|
801
|
-
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
802
|
-
tool_inputs: objectValue(body.toolInputs),
|
|
803
823
|
metadata: objectValue(body.metadata),
|
|
804
|
-
client: objectValue(body.client)
|
|
805
|
-
|
|
806
|
-
|
|
824
|
+
client: objectValue(body.client),
|
|
825
|
+
cursor: 0
|
|
826
|
+
}, (event) => write(event), { signal: request.signal });
|
|
827
|
+
}, {
|
|
828
|
+
"X-Run-ID": admission.run_id,
|
|
829
|
+
...admission.thread_id ? { "X-Thread-ID": admission.thread_id } : {}
|
|
830
|
+
}, void 0, (error) => reportFailureResponse(options.onDiagnostic, request, "chat.stream", errorResponse(error))), resolution.responseHeaders);
|
|
807
831
|
}
|
|
808
832
|
if (request.method === "GET" && path === "/threads") {
|
|
809
833
|
const skip = Number(url.searchParams.get("skip") || 0);
|