@agents24/node 0.5.33 → 0.5.35
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 +8 -8
- package/dist/bff.cjs +103 -4
- 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 +103 -4
- package/dist/bff.js.map +1 -1
- package/dist/{client-IX8nsoyr.d.cts → client-BQN80Nb5.d.cts} +111 -3
- package/dist/{client-IX8nsoyr.d.ts → client-BQN80Nb5.d.ts} +111 -3
- package/dist/index.cjs +132 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +132 -11
- package/dist/index.js.map +1 -1
- package/dist/types/agents.d.ts +5 -0
- package/dist/types/agents.d.ts.map +1 -1
- package/dist/types/bff-conversation-submission.d.ts.map +1 -1
- package/dist/types/bff-multi-agent.d.ts.map +1 -1
- package/dist/types/bff-request.d.ts +2 -0
- package/dist/types/bff-request.d.ts.map +1 -1
- package/dist/types/bff-single-agent.d.ts.map +1 -1
- package/dist/types/bff-sse.d.ts +3 -0
- package/dist/types/bff-sse.d.ts.map +1 -1
- package/dist/types/embed-run-wait.d.ts +4 -1
- package/dist/types/embed-run-wait.d.ts.map +1 -1
- package/dist/types/embed-types.d.ts +7 -0
- package/dist/types/embed-types.d.ts.map +1 -1
- package/dist/types/embed.d.ts +5 -0
- package/dist/types/embed.d.ts.map +1 -1
- package/dist/types/generated/dictation.d.ts +99 -0
- package/dist/types/generated/dictation.d.ts.map +1 -0
- package/dist/types/generated/embed.d.ts +4 -1
- package/dist/types/generated/embed.d.ts.map +1 -1
- package/dist/types/generated/ingestion-types.d.ts +2 -0
- package/dist/types/generated/ingestion-types.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 +2 -2
- package/dist/types/generated/model-capabilities.d.ts.map +1 -1
- package/dist/types/generated/run-usage.d.ts +2 -0
- package/dist/types/generated/run-usage.d.ts.map +1 -1
- package/dist/types/runs.d.ts +11 -0
- package/dist/types/runs.d.ts.map +1 -1
- package/dist/types/types.d.ts +24 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
package/compatibility.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"contractHash": "
|
|
2
|
+
"contractHash": "0855723f1fcc295edf523aca825e9b9c43b120c10e8ba261979da9eb2cc3768e",
|
|
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": "9d624998b7ba0eb7055eaf4720ee4756ae579be0733ed3485d577086f9bf847c",
|
|
19
19
|
"runtime": "run-stream.v3"
|
|
20
20
|
},
|
|
21
21
|
"@agents24/node": {
|
|
22
|
-
"contract": "
|
|
22
|
+
"contract": "0855723f1fcc295edf523aca825e9b9c43b120c10e8ba261979da9eb2cc3768e",
|
|
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": "9d624998b7ba0eb7055eaf4720ee4756ae579be0733ed3485d577086f9bf847c",
|
|
31
31
|
"protocolOwner": "@agents24/client"
|
|
32
32
|
},
|
|
33
33
|
"agents24": {
|
|
34
|
-
"contract": "
|
|
34
|
+
"contract": "0855723f1fcc295edf523aca825e9b9c43b120c10e8ba261979da9eb2cc3768e",
|
|
35
35
|
"python": ">=3.10"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"schemaVersion": "agents24.compatibility.v1",
|
|
49
49
|
"targetOperationCounts": {
|
|
50
|
-
"client":
|
|
51
|
-
"node":
|
|
52
|
-
"python":
|
|
50
|
+
"client": 41,
|
|
51
|
+
"node": 211,
|
|
52
|
+
"python": 205
|
|
53
53
|
}
|
|
54
54
|
}
|
package/dist/bff.cjs
CHANGED
|
@@ -189,6 +189,13 @@ function routeId(path, pattern, field) {
|
|
|
189
189
|
throw new BffInputError(400, "INVALID_PATH", `${field} is invalid.`);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
+
function requestedOutputNames(value) {
|
|
193
|
+
if (value === void 0) return void 0;
|
|
194
|
+
if (!Array.isArray(value) || !value.every((name) => typeof name === "string")) {
|
|
195
|
+
throw new BffInputError(400, "INVALID_REQUESTED_OUTPUTS", "requestedOutputs must be a string array.");
|
|
196
|
+
}
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
192
199
|
function messageBody(body) {
|
|
193
200
|
const mode = body.mode === "steer" ? "steer" : body.mode === "queue" ? "queue" : null;
|
|
194
201
|
if (!mode) throw new BffInputError(400, "INVALID_MODE", "Message mode must be queue or steer.");
|
|
@@ -205,6 +212,7 @@ function messageBody(body) {
|
|
|
205
212
|
input,
|
|
206
213
|
attachmentIds,
|
|
207
214
|
...requestedModelId ? { requestedModelId } : {},
|
|
215
|
+
...body.requestedOutputs === void 0 ? {} : { requestedOutputs: requestedOutputNames(body.requestedOutputs) },
|
|
208
216
|
toolInputs: objectValue(body.toolInputs),
|
|
209
217
|
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) }
|
|
210
218
|
};
|
|
@@ -290,12 +298,14 @@ async function submitConversationStream(input) {
|
|
|
290
298
|
input: value.input,
|
|
291
299
|
attachment_ids: value.attachmentIds,
|
|
292
300
|
client_submission_id: value.clientSubmissionId,
|
|
301
|
+
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
293
302
|
...input.requestedAgentId ? { requested_agent_id: input.requestedAgentId } : {},
|
|
294
303
|
...value.requestedModelId ? { requested_model_id: value.requestedModelId } : {},
|
|
295
304
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
296
305
|
...resolution.customerTenant === void 0 ? {} : { customer_tenant: resolution.customerTenant },
|
|
297
306
|
...resolution.trustedContext === void 0 ? {} : { trusted_context: resolution.trustedContext },
|
|
298
307
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
308
|
+
...value.requestedOutputs === void 0 ? {} : { requested_outputs: value.requestedOutputs },
|
|
299
309
|
tool_inputs: value.toolInputs,
|
|
300
310
|
metadata: objectValue(body.metadata)
|
|
301
311
|
}, {
|
|
@@ -594,6 +604,10 @@ function sseResponse(execute, headers, failurePayload, onFailure, requestSignal,
|
|
|
594
604
|
});
|
|
595
605
|
return new Response(stream, { headers: sseHeaders(headers) });
|
|
596
606
|
}
|
|
607
|
+
function runtimeEventEnabled(request, event) {
|
|
608
|
+
const feature = event.event === "assistant.completed" ? "assistant-completion-v1" : event.event.startsWith("workflow.output.") ? "workflow-outputs-v1" : null;
|
|
609
|
+
return feature === null || Boolean(new URL(request.url).searchParams.get("stream_features")?.split(",").includes(feature));
|
|
610
|
+
}
|
|
597
611
|
|
|
598
612
|
// src/bff-resolver.ts
|
|
599
613
|
var AgentBffResolverError = class extends Error {
|
|
@@ -683,9 +697,58 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
683
697
|
{ ...threadIdentity, integrationId }
|
|
684
698
|
), resolution.responseHeaders);
|
|
685
699
|
let response;
|
|
700
|
+
if (request.method === "GET" && /^\/runs\/[^/]+\/outputs(?:\/[^/]+)?$/.test(path)) {
|
|
701
|
+
const parts = path.split("/");
|
|
702
|
+
const scope = {
|
|
703
|
+
...threadIdentity,
|
|
704
|
+
integrationId,
|
|
705
|
+
runtimeTarget,
|
|
706
|
+
...resolution.chatScope === void 0 ? {} : { chatScope: resolution.chatScope }
|
|
707
|
+
};
|
|
708
|
+
const result = parts[4] ? await embed.getAgentRunOutput(agentId, decodeURIComponent(parts[2]), decodeURIComponent(parts[4]), scope) : await embed.listAgentRunOutputs(agentId, decodeURIComponent(parts[2]), {
|
|
709
|
+
...scope,
|
|
710
|
+
after: Number(url.searchParams.get("after") || 0),
|
|
711
|
+
limit: Number(url.searchParams.get("limit") || 50)
|
|
712
|
+
});
|
|
713
|
+
return mergeHeaders(json(result), resolution.responseHeaders);
|
|
714
|
+
}
|
|
686
715
|
if (request.method === "GET" && path === "/bootstrap") {
|
|
687
716
|
const raw = await embed.getRuntimeBootstrap(agentId, agentVersionId, runtimeTarget);
|
|
688
717
|
response = json(bootstrapDocument(raw, agentVersionId));
|
|
718
|
+
} else if (request.method === "POST" && path === "/dictation-sessions") {
|
|
719
|
+
if (!idempotencyKey) throw new BffInputError(400, "IDEMPOTENCY_REQUIRED", "A dictation operation ID is required.");
|
|
720
|
+
response = json(await embed.createDictationSession(agentId, {
|
|
721
|
+
external_user_id: customerPrincipalRef,
|
|
722
|
+
integration_id: integrationId,
|
|
723
|
+
...principal.externalSessionId ? { external_session_id: principal.externalSessionId } : {},
|
|
724
|
+
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
725
|
+
...agentVersionId ? { agent_version_id: agentVersionId } : {},
|
|
726
|
+
runtime_target: runtimeTarget,
|
|
727
|
+
origin: new URL(request.url).origin
|
|
728
|
+
}, { idempotencyKey, signal: request.signal }));
|
|
729
|
+
} else if (path.startsWith("/dictation-sessions/")) {
|
|
730
|
+
const match = /^\/dictation-sessions\/([^/]+)(\/cancel)?$/.exec(path);
|
|
731
|
+
if (!match) throw new BffInputError(404, "NOT_FOUND", "Dictation session is unavailable.");
|
|
732
|
+
const sessionId = decodeURIComponent(match[1]);
|
|
733
|
+
const scope = {
|
|
734
|
+
external_user_id: customerPrincipalRef,
|
|
735
|
+
integration_id: integrationId,
|
|
736
|
+
...principal.externalSessionId ? { external_session_id: principal.externalSessionId } : {},
|
|
737
|
+
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
738
|
+
...agentVersionId ? { agent_version_id: agentVersionId } : {},
|
|
739
|
+
runtime_target: runtimeTarget
|
|
740
|
+
};
|
|
741
|
+
if (request.method === "POST" && match[2]) response = json(await embed.cancelDictationSession(agentId, sessionId, scope, { signal: request.signal }));
|
|
742
|
+
else if (request.method === "GET" && !match[2]) response = json(await embed.getDictationSession(agentId, sessionId, {
|
|
743
|
+
externalUserId: customerPrincipalRef,
|
|
744
|
+
integrationId,
|
|
745
|
+
externalSessionId: principal.externalSessionId,
|
|
746
|
+
chatScope: resolution.chatScope,
|
|
747
|
+
runtimeTarget,
|
|
748
|
+
agentVersionId,
|
|
749
|
+
signal: request.signal
|
|
750
|
+
}));
|
|
751
|
+
else throw new BffInputError(405, "METHOD_NOT_ALLOWED", "The operation is unavailable.");
|
|
689
752
|
} else if (request.method === "GET" && path === "/resource-policy") {
|
|
690
753
|
response = json(await embed.getResourcePolicy(agentId, {
|
|
691
754
|
external_user_id: customerPrincipalRef,
|
|
@@ -722,6 +785,8 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
722
785
|
...resolution.trustedContext === void 0 ? {} : { trustedContext: resolution.trustedContext },
|
|
723
786
|
...stringValue(body.requestedModelId) ? { requestedModelId: stringValue(body.requestedModelId) } : {},
|
|
724
787
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledgeNamespaces: resolution.knowledgeNamespaces },
|
|
788
|
+
...stringValue(body.dictationSessionId) ? { dictationSessionId: stringValue(body.dictationSessionId) } : {},
|
|
789
|
+
...body.requestedOutputs === void 0 ? {} : { requestedOutputs: requestedOutputNames(body.requestedOutputs) },
|
|
725
790
|
toolInputs: objectValue(body.toolInputs),
|
|
726
791
|
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) }
|
|
727
792
|
}, { idempotencyKey }) : await embed.startAgentRun(agentId, {
|
|
@@ -738,6 +803,8 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
738
803
|
attachment_ids: attachmentIds,
|
|
739
804
|
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
740
805
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
806
|
+
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
807
|
+
...body.requestedOutputs === void 0 ? {} : { requested_outputs: requestedOutputNames(body.requestedOutputs) },
|
|
741
808
|
tool_inputs: objectValue(body.toolInputs),
|
|
742
809
|
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) },
|
|
743
810
|
client: objectValue(body.client)
|
|
@@ -756,7 +823,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
756
823
|
client: objectValue(body.client),
|
|
757
824
|
cursor: 0
|
|
758
825
|
}, (event) => {
|
|
759
|
-
if (
|
|
826
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
760
827
|
}, { signal, onControl: control, leaseSeconds: 60, streamFeatures: url.searchParams.get("stream_features") || "", onPreview: (frame) => write(frame) });
|
|
761
828
|
}, {
|
|
762
829
|
"X-Run-ID": admittedRunId,
|
|
@@ -779,12 +846,13 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
779
846
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
780
847
|
...cursor === void 0 ? {} : { cursor: Number(cursor) }
|
|
781
848
|
}, (event) => {
|
|
782
|
-
if (
|
|
849
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
783
850
|
}, {
|
|
784
851
|
idempotencyKey,
|
|
785
852
|
signal,
|
|
786
853
|
onControl: control,
|
|
787
854
|
leaseSeconds: 60,
|
|
855
|
+
streamFeatures: url.searchParams.get("stream_features") || "",
|
|
788
856
|
...url.searchParams.get("thread_id") ? { threadId: url.searchParams.get("thread_id") } : {}
|
|
789
857
|
});
|
|
790
858
|
}, void 0, void 0, streamFailure(request, "run.attach"), request.signal);
|
|
@@ -871,7 +939,15 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
871
939
|
response = json(await embed.submitAgentThreadMessage(
|
|
872
940
|
agentId,
|
|
873
941
|
threadId,
|
|
874
|
-
{
|
|
942
|
+
{
|
|
943
|
+
...threadIdentity,
|
|
944
|
+
integrationId,
|
|
945
|
+
...messageBody(body),
|
|
946
|
+
...resolution.trustedContext === void 0 ? {} : { trustedContext: resolution.trustedContext },
|
|
947
|
+
...resolution.customerTenant === void 0 ? {} : { customerTenant: resolution.customerTenant },
|
|
948
|
+
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledgeNamespaces: resolution.knowledgeNamespaces },
|
|
949
|
+
agentVersionId: agentVersionId ?? null
|
|
950
|
+
},
|
|
875
951
|
{ idempotencyKey }
|
|
876
952
|
));
|
|
877
953
|
} else if (/^\/threads\/[^/]+\/messages\/[^/]+$/.test(path) && request.method === "PATCH") {
|
|
@@ -974,6 +1050,17 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
974
1050
|
response = json(await embed.uploadAgentAttachments(agentId, {
|
|
975
1051
|
...threadIdentity,
|
|
976
1052
|
files,
|
|
1053
|
+
...form.has("transcript_presentations") ? { transcriptPresentations: (() => {
|
|
1054
|
+
const value = stringValue(form.get("transcript_presentations"));
|
|
1055
|
+
let parsed;
|
|
1056
|
+
try {
|
|
1057
|
+
parsed = JSON.parse(value || "null");
|
|
1058
|
+
} catch {
|
|
1059
|
+
throw new BffInputError(400, "INVALID_REQUEST", "Invalid transcript presentation.");
|
|
1060
|
+
}
|
|
1061
|
+
if (!Array.isArray(parsed) || parsed.length !== files.length || parsed.some((item) => item !== "attachment" && item !== "dictation")) throw new BffInputError(400, "INVALID_REQUEST", "Invalid transcript presentation.");
|
|
1062
|
+
return parsed;
|
|
1063
|
+
})() } : {},
|
|
977
1064
|
...stringValue(form.get("thread_id")) ? { threadId: stringValue(form.get("thread_id")) } : {},
|
|
978
1065
|
integrationId,
|
|
979
1066
|
...resolution.chatScope === void 0 ? {} : { chatScope: resolution.chatScope },
|
|
@@ -1164,6 +1251,16 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1164
1251
|
});
|
|
1165
1252
|
return (await requestedAgent(detail.runtime_selection?.agent_id)).agentId;
|
|
1166
1253
|
};
|
|
1254
|
+
if (request.method === "GET" && /^\/runs\/[^/]+\/outputs(?:\/[^/]+)?$/.test(path)) {
|
|
1255
|
+
const runId = routeId(path, /^\/runs\/([^/]+)\/outputs/, "runId");
|
|
1256
|
+
return dispatchToAgent(await resolveRunAgent(runId));
|
|
1257
|
+
}
|
|
1258
|
+
if (path === "/dictation-sessions" || /^\/dictation-sessions\/[^/]+(?:\/cancel)?$/.test(path)) {
|
|
1259
|
+
const message = request.method === "POST" ? await requestJson(request) : void 0;
|
|
1260
|
+
const selected = await requestedAgent(message?.requestedAgentId || url.searchParams.get("requestedAgentId"));
|
|
1261
|
+
assertWritableAgent(selected.agentId, historical);
|
|
1262
|
+
return dispatchToAgent(selected.agentId, message);
|
|
1263
|
+
}
|
|
1167
1264
|
if (request.method === "POST" && path === "/chat/stream") {
|
|
1168
1265
|
const body = await requestJson(request);
|
|
1169
1266
|
const threadId = stringValue(body.threadId);
|
|
@@ -1198,6 +1295,8 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1198
1295
|
client_submission_id: stringValue(body.clientSubmissionId),
|
|
1199
1296
|
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
1200
1297
|
attachment_ids: attachmentIds,
|
|
1298
|
+
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
1299
|
+
...body.requestedOutputs === void 0 ? {} : { requested_outputs: requestedOutputNames(body.requestedOutputs) },
|
|
1201
1300
|
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
1202
1301
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
1203
1302
|
tool_inputs: objectValue(body.toolInputs),
|
|
@@ -1216,7 +1315,7 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1216
1315
|
client: objectValue(body.client),
|
|
1217
1316
|
cursor: 0
|
|
1218
1317
|
}, (event) => {
|
|
1219
|
-
if (
|
|
1318
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
1220
1319
|
}, { signal, onControl: control, leaseSeconds: 60, streamFeatures: url.searchParams.get("stream_features") || "", onPreview: (frame) => write(frame) });
|
|
1221
1320
|
}, {
|
|
1222
1321
|
"X-Run-ID": admittedRunId,
|