@agents24/node 0.5.26 → 0.5.28
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 +7 -1
- package/compatibility.json +7 -7
- package/dist/artifacts.cjs +2 -1
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.d.cts +23 -2
- package/dist/artifacts.d.ts +23 -2
- package/dist/artifacts.js +2 -1
- package/dist/artifacts.js.map +1 -1
- package/dist/bff.cjs +60 -11
- package/dist/bff.cjs.map +1 -1
- package/dist/bff.d.cts +2 -1
- package/dist/bff.d.ts +2 -1
- package/dist/bff.js +60 -11
- package/dist/bff.js.map +1 -1
- package/dist/{client-yYT9UnqF.d.cts → client-yHQmkcMz.d.cts} +269 -12
- package/dist/{client-yYT9UnqF.d.ts → client-yHQmkcMz.d.ts} +269 -12
- package/dist/index.cjs +174 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +173 -15
- package/dist/index.js.map +1 -1
- package/dist/relay.cjs +514 -0
- package/dist/relay.cjs.map +1 -0
- package/dist/relay.d.cts +98 -0
- package/dist/relay.d.ts +98 -0
- package/dist/relay.js +511 -0
- package/dist/relay.js.map +1 -0
- package/dist/server.cjs +80 -10
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +3 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +80 -10
- package/dist/server.js.map +1 -1
- package/dist/types/agents.d.ts +1 -0
- package/dist/types/agents.d.ts.map +1 -1
- package/dist/types/artifacts.d.ts +22 -1
- package/dist/types/artifacts.d.ts.map +1 -1
- package/dist/types/bff-request.d.ts +5 -3
- package/dist/types/bff-request.d.ts.map +1 -1
- package/dist/types/bff.d.ts.map +1 -1
- package/dist/types/client.d.ts +4 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/embed-run-wait.d.ts +9 -0
- package/dist/types/embed-run-wait.d.ts.map +1 -0
- package/dist/types/embed-types.d.ts +15 -2
- package/dist/types/embed-types.d.ts.map +1 -1
- package/dist/types/embed.d.ts +5 -1
- package/dist/types/embed.d.ts.map +1 -1
- package/dist/types/generated/delegation-types.d.ts +3 -2
- package/dist/types/generated/delegation-types.d.ts.map +1 -1
- package/dist/types/generated/ingestion-types.d.ts +33 -1
- package/dist/types/generated/ingestion-types.d.ts.map +1 -1
- package/dist/types/generated/ingestionJobs.d.ts +2 -2
- package/dist/types/generated/ingestionJobs.d.ts.map +1 -1
- package/dist/types/generated/knowledgeStores.d.ts +2 -1
- package/dist/types/generated/knowledgeStores.d.ts.map +1 -1
- package/dist/types/generated/manifest.d.ts +1 -1
- package/dist/types/generated/manifest.d.ts.map +1 -1
- package/dist/types/generated/model-capabilities.d.ts +4 -0
- package/dist/types/generated/model-capabilities.d.ts.map +1 -1
- package/dist/types/generated/relayClients.d.ts +13 -0
- package/dist/types/generated/relayClients.d.ts.map +1 -0
- package/dist/types/generated/resourceInstallations.d.ts +1 -2
- package/dist/types/generated/resourceInstallations.d.ts.map +1 -1
- package/dist/types/generated/run-usage.d.ts +12 -0
- package/dist/types/generated/run-usage.d.ts.map +1 -0
- package/dist/types/http.d.ts +1 -0
- package/dist/types/http.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/models.d.ts +92 -0
- package/dist/types/models.d.ts.map +1 -0
- package/dist/types/relay-http.d.ts +14 -0
- package/dist/types/relay-http.d.ts.map +1 -0
- package/dist/types/relay.d.ts +89 -0
- package/dist/types/relay.d.ts.map +1 -0
- package/dist/types/server.d.ts +3 -0
- package/dist/types/server.d.ts.map +1 -1
- package/dist/types/types.d.ts +95 -6
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +9 -3
package/dist/bff.d.cts
CHANGED
package/dist/bff.d.ts
CHANGED
package/dist/bff.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { ATTACHMENT_RUNTIME_LIMITS } from '@agents24/client';
|
|
1
2
|
import { randomUUID } from 'crypto';
|
|
2
3
|
|
|
4
|
+
// src/bff-request.ts
|
|
5
|
+
|
|
3
6
|
// src/bff-values.ts
|
|
4
7
|
function normalized(value, field) {
|
|
5
8
|
const result = String(value || "").trim();
|
|
@@ -41,8 +44,9 @@ function bootstrapDocument(raw, agentVersionId) {
|
|
|
41
44
|
// src/bff-request.ts
|
|
42
45
|
var JSON_LIMIT_BYTES = 1048576;
|
|
43
46
|
var MAX_INPUT_LENGTH = 2e5;
|
|
44
|
-
var MAX_ATTACHMENTS =
|
|
45
|
-
var MAX_ATTACHMENT_BYTES =
|
|
47
|
+
var MAX_ATTACHMENTS = ATTACHMENT_RUNTIME_LIMITS.max_attachments_per_turn;
|
|
48
|
+
var MAX_ATTACHMENT_BYTES = ATTACHMENT_RUNTIME_LIMITS.max_file_bytes;
|
|
49
|
+
var MAX_TOTAL_ATTACHMENT_BYTES = ATTACHMENT_RUNTIME_LIMITS.max_total_bytes;
|
|
46
50
|
var HITL_ACTIONS = /* @__PURE__ */ new Set(["approve", "reject", "connect", "skip", "respond"]);
|
|
47
51
|
var CUSTOMER_IDENTITY_CACHE_TTL_MS = 6e4;
|
|
48
52
|
var CUSTOMER_IDENTITY_CACHE_MAX_ENTRIES = 1024;
|
|
@@ -122,6 +126,43 @@ async function requestJson(request) {
|
|
|
122
126
|
}
|
|
123
127
|
return value;
|
|
124
128
|
}
|
|
129
|
+
async function requestMultipart(request) {
|
|
130
|
+
const limit = MAX_TOTAL_ATTACHMENT_BYTES + JSON_LIMIT_BYTES;
|
|
131
|
+
const tooLarge = () => new BffInputError(413, "REQUEST_TOO_LARGE", "The attachment batch is too large.");
|
|
132
|
+
if (Number(request.headers.get("content-length") || 0) > limit) throw tooLarge();
|
|
133
|
+
const reader = request.body?.getReader();
|
|
134
|
+
let received = 0;
|
|
135
|
+
const body = new ReadableStream({
|
|
136
|
+
async pull(controller) {
|
|
137
|
+
if (!reader) {
|
|
138
|
+
controller.close();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const chunk = await reader.read();
|
|
142
|
+
if (chunk.done) {
|
|
143
|
+
controller.close();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
received += chunk.value.byteLength;
|
|
147
|
+
if (received > limit) {
|
|
148
|
+
await reader.cancel();
|
|
149
|
+
controller.error(tooLarge());
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
controller.enqueue(chunk.value);
|
|
153
|
+
},
|
|
154
|
+
async cancel(reason) {
|
|
155
|
+
await reader?.cancel(reason);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
try {
|
|
159
|
+
const init = { method: "POST", headers: request.headers, body, duplex: "half" };
|
|
160
|
+
return await new Request(request.url, init).formData();
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (error instanceof BffInputError) throw error;
|
|
163
|
+
throw new BffInputError(400, "INVALID_MULTIPART", "A valid attachment form is required.");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
125
166
|
var BffInputError = class extends Error {
|
|
126
167
|
constructor(status, code, message) {
|
|
127
168
|
super(message);
|
|
@@ -157,7 +198,7 @@ function messageBody(body) {
|
|
|
157
198
|
attachmentIds,
|
|
158
199
|
...requestedModelId ? { requestedModelId } : {},
|
|
159
200
|
toolInputs: objectValue(body.toolInputs),
|
|
160
|
-
metadata: objectValue(body.metadata)
|
|
201
|
+
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) }
|
|
161
202
|
};
|
|
162
203
|
}
|
|
163
204
|
function messageRevision(value) {
|
|
@@ -602,6 +643,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
602
643
|
...resolution.chatScope === void 0 ? {} : { chatScope: resolution.chatScope },
|
|
603
644
|
runtimeTarget,
|
|
604
645
|
clientSubmissionId: stringValue(body.clientSubmissionId),
|
|
646
|
+
...body.relayClientId === null ? { relayClientId: null } : stringValue(body.relayClientId) ? { relayClientId: stringValue(body.relayClientId) } : {},
|
|
605
647
|
agentVersionId: agentVersionId ?? null,
|
|
606
648
|
mode: "queue",
|
|
607
649
|
input,
|
|
@@ -609,7 +651,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
609
651
|
...stringValue(body.requestedModelId) ? { requestedModelId: stringValue(body.requestedModelId) } : {},
|
|
610
652
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledgeNamespaces: resolution.knowledgeNamespaces },
|
|
611
653
|
toolInputs: objectValue(body.toolInputs),
|
|
612
|
-
metadata: objectValue(body.metadata)
|
|
654
|
+
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) }
|
|
613
655
|
}, { idempotencyKey }) : await embed.startAgentRun(agentId, {
|
|
614
656
|
...identity,
|
|
615
657
|
integration_id: integrationId,
|
|
@@ -618,11 +660,12 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
618
660
|
runtime_target: runtimeTarget,
|
|
619
661
|
...input ? { input } : {},
|
|
620
662
|
client_submission_id: stringValue(body.clientSubmissionId),
|
|
663
|
+
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
621
664
|
attachment_ids: attachmentIds,
|
|
622
665
|
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
623
666
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
624
667
|
tool_inputs: objectValue(body.toolInputs),
|
|
625
|
-
metadata: objectValue(body.metadata),
|
|
668
|
+
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) },
|
|
626
669
|
client: objectValue(body.client)
|
|
627
670
|
}, { idempotencyKey });
|
|
628
671
|
const admittedRunId = admission.run_id;
|
|
@@ -635,7 +678,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
635
678
|
integration_id: integrationId,
|
|
636
679
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
637
680
|
runtime_target: runtimeTarget,
|
|
638
|
-
metadata: objectValue(body.metadata),
|
|
681
|
+
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) },
|
|
639
682
|
client: objectValue(body.client),
|
|
640
683
|
cursor: 0
|
|
641
684
|
}, (event) => {
|
|
@@ -781,6 +824,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
781
824
|
input,
|
|
782
825
|
attachmentIds,
|
|
783
826
|
...mode ? { mode } : {},
|
|
827
|
+
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) },
|
|
784
828
|
...stringValue(body.requestedModelId) ? { requestedModelId: stringValue(body.requestedModelId) } : {}
|
|
785
829
|
}
|
|
786
830
|
));
|
|
@@ -841,7 +885,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
841
885
|
const threadId = routeId(path, /^\/threads\/([^/]+)$/, "threadId");
|
|
842
886
|
response = json(await embed.deleteAgentThread(agentId, threadId, { ...threadIdentity, integrationId }, { idempotencyKey }));
|
|
843
887
|
} else if (request.method === "POST" && path === "/attachments/upload") {
|
|
844
|
-
const form = await request
|
|
888
|
+
const form = await requestMultipart(request);
|
|
845
889
|
const files = form.getAll("files").filter((entry) => entry instanceof File);
|
|
846
890
|
if (files.length === 0) throw new BffInputError(400, "ATTACHMENT_REQUIRED", "At least one attachment is required.");
|
|
847
891
|
if (files.length > MAX_ATTACHMENTS) {
|
|
@@ -850,6 +894,9 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
850
894
|
if (files.some((file) => file.size > MAX_ATTACHMENT_BYTES)) {
|
|
851
895
|
throw new BffInputError(413, "ATTACHMENT_TOO_LARGE", "An attachment exceeds the allowed size.");
|
|
852
896
|
}
|
|
897
|
+
if (files.reduce((total, file) => total + file.size, 0) > MAX_TOTAL_ATTACHMENT_BYTES) {
|
|
898
|
+
throw new BffInputError(413, "ATTACHMENT_BATCH_TOO_LARGE", "The attachment batch exceeds the allowed size.");
|
|
899
|
+
}
|
|
853
900
|
response = json(await embed.uploadAgentAttachments(agentId, {
|
|
854
901
|
...threadIdentity,
|
|
855
902
|
files,
|
|
@@ -1097,6 +1144,7 @@ function createResolvedAgents24BffHandler(options) {
|
|
|
1097
1144
|
...resolution.chatScope === void 0 ? {} : { chatScope: resolution.chatScope },
|
|
1098
1145
|
runtimeTarget,
|
|
1099
1146
|
clientSubmissionId: stringValue(body.clientSubmissionId),
|
|
1147
|
+
...body.relayClientId === null ? { relayClientId: null } : stringValue(body.relayClientId) ? { relayClientId: stringValue(body.relayClientId) } : {},
|
|
1100
1148
|
agentVersionId: selected.agentVersionId ?? null,
|
|
1101
1149
|
mode: "queue",
|
|
1102
1150
|
input: input ?? "",
|
|
@@ -1104,7 +1152,7 @@ function createResolvedAgents24BffHandler(options) {
|
|
|
1104
1152
|
...stringValue(body.requestedModelId) ? { requestedModelId: stringValue(body.requestedModelId) } : {},
|
|
1105
1153
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledgeNamespaces: resolution.knowledgeNamespaces },
|
|
1106
1154
|
toolInputs: objectValue(body.toolInputs),
|
|
1107
|
-
metadata: objectValue(body.metadata)
|
|
1155
|
+
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) }
|
|
1108
1156
|
}, { idempotencyKey: stringValue(request.headers.get("idempotency-key")) }) : await options.client.embed.startAgentRun(selected.agentId, {
|
|
1109
1157
|
...identity,
|
|
1110
1158
|
...selected.agentVersionId ? { agent_version_id: selected.agentVersionId } : {},
|
|
@@ -1113,11 +1161,12 @@ function createResolvedAgents24BffHandler(options) {
|
|
|
1113
1161
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
1114
1162
|
...input ? { input } : {},
|
|
1115
1163
|
client_submission_id: stringValue(body.clientSubmissionId),
|
|
1164
|
+
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
1116
1165
|
attachment_ids: attachmentIds,
|
|
1117
1166
|
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
1118
1167
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
1119
1168
|
tool_inputs: objectValue(body.toolInputs),
|
|
1120
|
-
metadata: objectValue(body.metadata),
|
|
1169
|
+
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) },
|
|
1121
1170
|
client: objectValue(body.client)
|
|
1122
1171
|
}, { idempotencyKey: stringValue(request.headers.get("idempotency-key")) });
|
|
1123
1172
|
const admittedRunId = admission.run_id;
|
|
@@ -1128,7 +1177,7 @@ function createResolvedAgents24BffHandler(options) {
|
|
|
1128
1177
|
runtime_target: runtimeTarget,
|
|
1129
1178
|
integration_id: integrationId,
|
|
1130
1179
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
1131
|
-
metadata: objectValue(body.metadata),
|
|
1180
|
+
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) },
|
|
1132
1181
|
client: objectValue(body.client),
|
|
1133
1182
|
cursor: 0
|
|
1134
1183
|
}, (event) => {
|
|
@@ -1276,7 +1325,7 @@ function createResolvedAgents24BffHandler(options) {
|
|
|
1276
1325
|
}, { idempotencyKey: stringValue(request.headers.get("idempotency-key")) })), resolution.responseHeaders);
|
|
1277
1326
|
}
|
|
1278
1327
|
if (request.method === "POST" && path === "/attachments/upload") {
|
|
1279
|
-
const form = await request.clone()
|
|
1328
|
+
const form = await requestMultipart(request.clone());
|
|
1280
1329
|
const selected = await requestedAgent(form.get("requested_agent_id"));
|
|
1281
1330
|
const policy = await options.client.embed.getResourcePolicy(selected.agentId, {
|
|
1282
1331
|
external_user_id: externalUserId,
|