@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/dist/bff.d.cts
CHANGED
package/dist/bff.d.ts
CHANGED
package/dist/bff.js
CHANGED
|
@@ -187,6 +187,13 @@ function routeId(path, pattern, field) {
|
|
|
187
187
|
throw new BffInputError(400, "INVALID_PATH", `${field} is invalid.`);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
+
function requestedOutputNames(value) {
|
|
191
|
+
if (value === void 0) return void 0;
|
|
192
|
+
if (!Array.isArray(value) || !value.every((name) => typeof name === "string")) {
|
|
193
|
+
throw new BffInputError(400, "INVALID_REQUESTED_OUTPUTS", "requestedOutputs must be a string array.");
|
|
194
|
+
}
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
190
197
|
function messageBody(body) {
|
|
191
198
|
const mode = body.mode === "steer" ? "steer" : body.mode === "queue" ? "queue" : null;
|
|
192
199
|
if (!mode) throw new BffInputError(400, "INVALID_MODE", "Message mode must be queue or steer.");
|
|
@@ -203,6 +210,7 @@ function messageBody(body) {
|
|
|
203
210
|
input,
|
|
204
211
|
attachmentIds,
|
|
205
212
|
...requestedModelId ? { requestedModelId } : {},
|
|
213
|
+
...body.requestedOutputs === void 0 ? {} : { requestedOutputs: requestedOutputNames(body.requestedOutputs) },
|
|
206
214
|
toolInputs: objectValue(body.toolInputs),
|
|
207
215
|
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) }
|
|
208
216
|
};
|
|
@@ -288,12 +296,14 @@ async function submitConversationStream(input) {
|
|
|
288
296
|
input: value.input,
|
|
289
297
|
attachment_ids: value.attachmentIds,
|
|
290
298
|
client_submission_id: value.clientSubmissionId,
|
|
299
|
+
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
291
300
|
...input.requestedAgentId ? { requested_agent_id: input.requestedAgentId } : {},
|
|
292
301
|
...value.requestedModelId ? { requested_model_id: value.requestedModelId } : {},
|
|
293
302
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
294
303
|
...resolution.customerTenant === void 0 ? {} : { customer_tenant: resolution.customerTenant },
|
|
295
304
|
...resolution.trustedContext === void 0 ? {} : { trusted_context: resolution.trustedContext },
|
|
296
305
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
306
|
+
...value.requestedOutputs === void 0 ? {} : { requested_outputs: value.requestedOutputs },
|
|
297
307
|
tool_inputs: value.toolInputs,
|
|
298
308
|
metadata: objectValue(body.metadata)
|
|
299
309
|
}, {
|
|
@@ -592,6 +602,10 @@ function sseResponse(execute, headers, failurePayload, onFailure, requestSignal,
|
|
|
592
602
|
});
|
|
593
603
|
return new Response(stream, { headers: sseHeaders(headers) });
|
|
594
604
|
}
|
|
605
|
+
function runtimeEventEnabled(request, event) {
|
|
606
|
+
const feature = event.event === "assistant.completed" ? "assistant-completion-v1" : event.event.startsWith("workflow.output.") ? "workflow-outputs-v1" : null;
|
|
607
|
+
return feature === null || Boolean(new URL(request.url).searchParams.get("stream_features")?.split(",").includes(feature));
|
|
608
|
+
}
|
|
595
609
|
|
|
596
610
|
// src/bff-resolver.ts
|
|
597
611
|
var AgentBffResolverError = class extends Error {
|
|
@@ -681,9 +695,58 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
681
695
|
{ ...threadIdentity, integrationId }
|
|
682
696
|
), resolution.responseHeaders);
|
|
683
697
|
let response;
|
|
698
|
+
if (request.method === "GET" && /^\/runs\/[^/]+\/outputs(?:\/[^/]+)?$/.test(path)) {
|
|
699
|
+
const parts = path.split("/");
|
|
700
|
+
const scope = {
|
|
701
|
+
...threadIdentity,
|
|
702
|
+
integrationId,
|
|
703
|
+
runtimeTarget,
|
|
704
|
+
...resolution.chatScope === void 0 ? {} : { chatScope: resolution.chatScope }
|
|
705
|
+
};
|
|
706
|
+
const result = parts[4] ? await embed.getAgentRunOutput(agentId, decodeURIComponent(parts[2]), decodeURIComponent(parts[4]), scope) : await embed.listAgentRunOutputs(agentId, decodeURIComponent(parts[2]), {
|
|
707
|
+
...scope,
|
|
708
|
+
after: Number(url.searchParams.get("after") || 0),
|
|
709
|
+
limit: Number(url.searchParams.get("limit") || 50)
|
|
710
|
+
});
|
|
711
|
+
return mergeHeaders(json(result), resolution.responseHeaders);
|
|
712
|
+
}
|
|
684
713
|
if (request.method === "GET" && path === "/bootstrap") {
|
|
685
714
|
const raw = await embed.getRuntimeBootstrap(agentId, agentVersionId, runtimeTarget);
|
|
686
715
|
response = json(bootstrapDocument(raw, agentVersionId));
|
|
716
|
+
} else if (request.method === "POST" && path === "/dictation-sessions") {
|
|
717
|
+
if (!idempotencyKey) throw new BffInputError(400, "IDEMPOTENCY_REQUIRED", "A dictation operation ID is required.");
|
|
718
|
+
response = json(await embed.createDictationSession(agentId, {
|
|
719
|
+
external_user_id: customerPrincipalRef,
|
|
720
|
+
integration_id: integrationId,
|
|
721
|
+
...principal.externalSessionId ? { external_session_id: principal.externalSessionId } : {},
|
|
722
|
+
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
723
|
+
...agentVersionId ? { agent_version_id: agentVersionId } : {},
|
|
724
|
+
runtime_target: runtimeTarget,
|
|
725
|
+
origin: new URL(request.url).origin
|
|
726
|
+
}, { idempotencyKey, signal: request.signal }));
|
|
727
|
+
} else if (path.startsWith("/dictation-sessions/")) {
|
|
728
|
+
const match = /^\/dictation-sessions\/([^/]+)(\/cancel)?$/.exec(path);
|
|
729
|
+
if (!match) throw new BffInputError(404, "NOT_FOUND", "Dictation session is unavailable.");
|
|
730
|
+
const sessionId = decodeURIComponent(match[1]);
|
|
731
|
+
const scope = {
|
|
732
|
+
external_user_id: customerPrincipalRef,
|
|
733
|
+
integration_id: integrationId,
|
|
734
|
+
...principal.externalSessionId ? { external_session_id: principal.externalSessionId } : {},
|
|
735
|
+
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
736
|
+
...agentVersionId ? { agent_version_id: agentVersionId } : {},
|
|
737
|
+
runtime_target: runtimeTarget
|
|
738
|
+
};
|
|
739
|
+
if (request.method === "POST" && match[2]) response = json(await embed.cancelDictationSession(agentId, sessionId, scope, { signal: request.signal }));
|
|
740
|
+
else if (request.method === "GET" && !match[2]) response = json(await embed.getDictationSession(agentId, sessionId, {
|
|
741
|
+
externalUserId: customerPrincipalRef,
|
|
742
|
+
integrationId,
|
|
743
|
+
externalSessionId: principal.externalSessionId,
|
|
744
|
+
chatScope: resolution.chatScope,
|
|
745
|
+
runtimeTarget,
|
|
746
|
+
agentVersionId,
|
|
747
|
+
signal: request.signal
|
|
748
|
+
}));
|
|
749
|
+
else throw new BffInputError(405, "METHOD_NOT_ALLOWED", "The operation is unavailable.");
|
|
687
750
|
} else if (request.method === "GET" && path === "/resource-policy") {
|
|
688
751
|
response = json(await embed.getResourcePolicy(agentId, {
|
|
689
752
|
external_user_id: customerPrincipalRef,
|
|
@@ -720,6 +783,8 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
720
783
|
...resolution.trustedContext === void 0 ? {} : { trustedContext: resolution.trustedContext },
|
|
721
784
|
...stringValue(body.requestedModelId) ? { requestedModelId: stringValue(body.requestedModelId) } : {},
|
|
722
785
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledgeNamespaces: resolution.knowledgeNamespaces },
|
|
786
|
+
...stringValue(body.dictationSessionId) ? { dictationSessionId: stringValue(body.dictationSessionId) } : {},
|
|
787
|
+
...body.requestedOutputs === void 0 ? {} : { requestedOutputs: requestedOutputNames(body.requestedOutputs) },
|
|
723
788
|
toolInputs: objectValue(body.toolInputs),
|
|
724
789
|
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) }
|
|
725
790
|
}, { idempotencyKey }) : await embed.startAgentRun(agentId, {
|
|
@@ -736,6 +801,8 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
736
801
|
attachment_ids: attachmentIds,
|
|
737
802
|
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
738
803
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
804
|
+
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
805
|
+
...body.requestedOutputs === void 0 ? {} : { requested_outputs: requestedOutputNames(body.requestedOutputs) },
|
|
739
806
|
tool_inputs: objectValue(body.toolInputs),
|
|
740
807
|
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) },
|
|
741
808
|
client: objectValue(body.client)
|
|
@@ -754,7 +821,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
754
821
|
client: objectValue(body.client),
|
|
755
822
|
cursor: 0
|
|
756
823
|
}, (event) => {
|
|
757
|
-
if (
|
|
824
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
758
825
|
}, { signal, onControl: control, leaseSeconds: 60, streamFeatures: url.searchParams.get("stream_features") || "", onPreview: (frame) => write(frame) });
|
|
759
826
|
}, {
|
|
760
827
|
"X-Run-ID": admittedRunId,
|
|
@@ -777,12 +844,13 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
777
844
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
778
845
|
...cursor === void 0 ? {} : { cursor: Number(cursor) }
|
|
779
846
|
}, (event) => {
|
|
780
|
-
if (
|
|
847
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
781
848
|
}, {
|
|
782
849
|
idempotencyKey,
|
|
783
850
|
signal,
|
|
784
851
|
onControl: control,
|
|
785
852
|
leaseSeconds: 60,
|
|
853
|
+
streamFeatures: url.searchParams.get("stream_features") || "",
|
|
786
854
|
...url.searchParams.get("thread_id") ? { threadId: url.searchParams.get("thread_id") } : {}
|
|
787
855
|
});
|
|
788
856
|
}, void 0, void 0, streamFailure(request, "run.attach"), request.signal);
|
|
@@ -869,7 +937,15 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
869
937
|
response = json(await embed.submitAgentThreadMessage(
|
|
870
938
|
agentId,
|
|
871
939
|
threadId,
|
|
872
|
-
{
|
|
940
|
+
{
|
|
941
|
+
...threadIdentity,
|
|
942
|
+
integrationId,
|
|
943
|
+
...messageBody(body),
|
|
944
|
+
...resolution.trustedContext === void 0 ? {} : { trustedContext: resolution.trustedContext },
|
|
945
|
+
...resolution.customerTenant === void 0 ? {} : { customerTenant: resolution.customerTenant },
|
|
946
|
+
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledgeNamespaces: resolution.knowledgeNamespaces },
|
|
947
|
+
agentVersionId: agentVersionId ?? null
|
|
948
|
+
},
|
|
873
949
|
{ idempotencyKey }
|
|
874
950
|
));
|
|
875
951
|
} else if (/^\/threads\/[^/]+\/messages\/[^/]+$/.test(path) && request.method === "PATCH") {
|
|
@@ -972,6 +1048,17 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
972
1048
|
response = json(await embed.uploadAgentAttachments(agentId, {
|
|
973
1049
|
...threadIdentity,
|
|
974
1050
|
files,
|
|
1051
|
+
...form.has("transcript_presentations") ? { transcriptPresentations: (() => {
|
|
1052
|
+
const value = stringValue(form.get("transcript_presentations"));
|
|
1053
|
+
let parsed;
|
|
1054
|
+
try {
|
|
1055
|
+
parsed = JSON.parse(value || "null");
|
|
1056
|
+
} catch {
|
|
1057
|
+
throw new BffInputError(400, "INVALID_REQUEST", "Invalid transcript presentation.");
|
|
1058
|
+
}
|
|
1059
|
+
if (!Array.isArray(parsed) || parsed.length !== files.length || parsed.some((item) => item !== "attachment" && item !== "dictation")) throw new BffInputError(400, "INVALID_REQUEST", "Invalid transcript presentation.");
|
|
1060
|
+
return parsed;
|
|
1061
|
+
})() } : {},
|
|
975
1062
|
...stringValue(form.get("thread_id")) ? { threadId: stringValue(form.get("thread_id")) } : {},
|
|
976
1063
|
integrationId,
|
|
977
1064
|
...resolution.chatScope === void 0 ? {} : { chatScope: resolution.chatScope },
|
|
@@ -1162,6 +1249,16 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1162
1249
|
});
|
|
1163
1250
|
return (await requestedAgent(detail.runtime_selection?.agent_id)).agentId;
|
|
1164
1251
|
};
|
|
1252
|
+
if (request.method === "GET" && /^\/runs\/[^/]+\/outputs(?:\/[^/]+)?$/.test(path)) {
|
|
1253
|
+
const runId = routeId(path, /^\/runs\/([^/]+)\/outputs/, "runId");
|
|
1254
|
+
return dispatchToAgent(await resolveRunAgent(runId));
|
|
1255
|
+
}
|
|
1256
|
+
if (path === "/dictation-sessions" || /^\/dictation-sessions\/[^/]+(?:\/cancel)?$/.test(path)) {
|
|
1257
|
+
const message = request.method === "POST" ? await requestJson(request) : void 0;
|
|
1258
|
+
const selected = await requestedAgent(message?.requestedAgentId || url.searchParams.get("requestedAgentId"));
|
|
1259
|
+
assertWritableAgent(selected.agentId, historical);
|
|
1260
|
+
return dispatchToAgent(selected.agentId, message);
|
|
1261
|
+
}
|
|
1165
1262
|
if (request.method === "POST" && path === "/chat/stream") {
|
|
1166
1263
|
const body = await requestJson(request);
|
|
1167
1264
|
const threadId = stringValue(body.threadId);
|
|
@@ -1196,6 +1293,8 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1196
1293
|
client_submission_id: stringValue(body.clientSubmissionId),
|
|
1197
1294
|
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
1198
1295
|
attachment_ids: attachmentIds,
|
|
1296
|
+
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
1297
|
+
...body.requestedOutputs === void 0 ? {} : { requested_outputs: requestedOutputNames(body.requestedOutputs) },
|
|
1199
1298
|
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
1200
1299
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
1201
1300
|
tool_inputs: objectValue(body.toolInputs),
|
|
@@ -1214,7 +1313,7 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1214
1313
|
client: objectValue(body.client),
|
|
1215
1314
|
cursor: 0
|
|
1216
1315
|
}, (event) => {
|
|
1217
|
-
if (
|
|
1316
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
1218
1317
|
}, { signal, onControl: control, leaseSeconds: 60, streamFeatures: url.searchParams.get("stream_features") || "", onPreview: (frame) => write(frame) });
|
|
1219
1318
|
}, {
|
|
1220
1319
|
"X-Run-ID": admittedRunId,
|