@agents24/node 0.5.33 → 0.5.34
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 +39 -3
- 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 +39 -3
- package/dist/bff.js.map +1 -1
- package/dist/{client-IX8nsoyr.d.cts → client-CY0o68YO.d.cts} +25 -0
- package/dist/{client-IX8nsoyr.d.ts → client-CY0o68YO.d.ts} +25 -0
- package/dist/index.cjs +36 -7
- 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 +36 -7
- package/dist/index.js.map +1 -1
- package/dist/types/agents.d.ts +1 -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-types.d.ts +3 -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/manifest.d.ts +1 -1
- package/dist/types/generated/manifest.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 +6 -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
|
};
|
|
@@ -294,6 +302,7 @@ async function submitConversationStream(input) {
|
|
|
294
302
|
...resolution.customerTenant === void 0 ? {} : { customer_tenant: resolution.customerTenant },
|
|
295
303
|
...resolution.trustedContext === void 0 ? {} : { trusted_context: resolution.trustedContext },
|
|
296
304
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
305
|
+
...value.requestedOutputs === void 0 ? {} : { requested_outputs: value.requestedOutputs },
|
|
297
306
|
tool_inputs: value.toolInputs,
|
|
298
307
|
metadata: objectValue(body.metadata)
|
|
299
308
|
}, {
|
|
@@ -592,6 +601,10 @@ function sseResponse(execute, headers, failurePayload, onFailure, requestSignal,
|
|
|
592
601
|
});
|
|
593
602
|
return new Response(stream, { headers: sseHeaders(headers) });
|
|
594
603
|
}
|
|
604
|
+
function runtimeEventEnabled(request, event) {
|
|
605
|
+
const feature = event.event === "assistant.completed" ? "assistant-completion-v1" : event.event.startsWith("workflow.output.") ? "workflow-outputs-v1" : null;
|
|
606
|
+
return feature === null || Boolean(new URL(request.url).searchParams.get("stream_features")?.split(",").includes(feature));
|
|
607
|
+
}
|
|
595
608
|
|
|
596
609
|
// src/bff-resolver.ts
|
|
597
610
|
var AgentBffResolverError = class extends Error {
|
|
@@ -681,6 +694,21 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
681
694
|
{ ...threadIdentity, integrationId }
|
|
682
695
|
), resolution.responseHeaders);
|
|
683
696
|
let response;
|
|
697
|
+
if (request.method === "GET" && /^\/runs\/[^/]+\/outputs(?:\/[^/]+)?$/.test(path)) {
|
|
698
|
+
const parts = path.split("/");
|
|
699
|
+
const scope = {
|
|
700
|
+
...threadIdentity,
|
|
701
|
+
integrationId,
|
|
702
|
+
runtimeTarget,
|
|
703
|
+
...resolution.chatScope === void 0 ? {} : { chatScope: resolution.chatScope }
|
|
704
|
+
};
|
|
705
|
+
const result = parts[4] ? await embed.getAgentRunOutput(agentId, decodeURIComponent(parts[2]), decodeURIComponent(parts[4]), scope) : await embed.listAgentRunOutputs(agentId, decodeURIComponent(parts[2]), {
|
|
706
|
+
...scope,
|
|
707
|
+
after: Number(url.searchParams.get("after") || 0),
|
|
708
|
+
limit: Number(url.searchParams.get("limit") || 50)
|
|
709
|
+
});
|
|
710
|
+
return mergeHeaders(json(result), resolution.responseHeaders);
|
|
711
|
+
}
|
|
684
712
|
if (request.method === "GET" && path === "/bootstrap") {
|
|
685
713
|
const raw = await embed.getRuntimeBootstrap(agentId, agentVersionId, runtimeTarget);
|
|
686
714
|
response = json(bootstrapDocument(raw, agentVersionId));
|
|
@@ -720,6 +748,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
720
748
|
...resolution.trustedContext === void 0 ? {} : { trustedContext: resolution.trustedContext },
|
|
721
749
|
...stringValue(body.requestedModelId) ? { requestedModelId: stringValue(body.requestedModelId) } : {},
|
|
722
750
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledgeNamespaces: resolution.knowledgeNamespaces },
|
|
751
|
+
...body.requestedOutputs === void 0 ? {} : { requestedOutputs: requestedOutputNames(body.requestedOutputs) },
|
|
723
752
|
toolInputs: objectValue(body.toolInputs),
|
|
724
753
|
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) }
|
|
725
754
|
}, { idempotencyKey }) : await embed.startAgentRun(agentId, {
|
|
@@ -736,6 +765,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
736
765
|
attachment_ids: attachmentIds,
|
|
737
766
|
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
738
767
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
768
|
+
...body.requestedOutputs === void 0 ? {} : { requested_outputs: requestedOutputNames(body.requestedOutputs) },
|
|
739
769
|
tool_inputs: objectValue(body.toolInputs),
|
|
740
770
|
...body.metadata === void 0 ? {} : { metadata: objectValue(body.metadata) },
|
|
741
771
|
client: objectValue(body.client)
|
|
@@ -754,7 +784,7 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
754
784
|
client: objectValue(body.client),
|
|
755
785
|
cursor: 0
|
|
756
786
|
}, (event) => {
|
|
757
|
-
if (
|
|
787
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
758
788
|
}, { signal, onControl: control, leaseSeconds: 60, streamFeatures: url.searchParams.get("stream_features") || "", onPreview: (frame) => write(frame) });
|
|
759
789
|
}, {
|
|
760
790
|
"X-Run-ID": admittedRunId,
|
|
@@ -777,12 +807,13 @@ function createAgents24BffHandlerWithResolver(options, resolveCustomerIdentity)
|
|
|
777
807
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
778
808
|
...cursor === void 0 ? {} : { cursor: Number(cursor) }
|
|
779
809
|
}, (event) => {
|
|
780
|
-
if (
|
|
810
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
781
811
|
}, {
|
|
782
812
|
idempotencyKey,
|
|
783
813
|
signal,
|
|
784
814
|
onControl: control,
|
|
785
815
|
leaseSeconds: 60,
|
|
816
|
+
streamFeatures: url.searchParams.get("stream_features") || "",
|
|
786
817
|
...url.searchParams.get("thread_id") ? { threadId: url.searchParams.get("thread_id") } : {}
|
|
787
818
|
});
|
|
788
819
|
}, void 0, void 0, streamFailure(request, "run.attach"), request.signal);
|
|
@@ -1162,6 +1193,10 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1162
1193
|
});
|
|
1163
1194
|
return (await requestedAgent(detail.runtime_selection?.agent_id)).agentId;
|
|
1164
1195
|
};
|
|
1196
|
+
if (request.method === "GET" && /^\/runs\/[^/]+\/outputs(?:\/[^/]+)?$/.test(path)) {
|
|
1197
|
+
const runId = routeId(path, /^\/runs\/([^/]+)\/outputs/, "runId");
|
|
1198
|
+
return dispatchToAgent(await resolveRunAgent(runId));
|
|
1199
|
+
}
|
|
1165
1200
|
if (request.method === "POST" && path === "/chat/stream") {
|
|
1166
1201
|
const body = await requestJson(request);
|
|
1167
1202
|
const threadId = stringValue(body.threadId);
|
|
@@ -1196,6 +1231,7 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1196
1231
|
client_submission_id: stringValue(body.clientSubmissionId),
|
|
1197
1232
|
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
1198
1233
|
attachment_ids: attachmentIds,
|
|
1234
|
+
...body.requestedOutputs === void 0 ? {} : { requested_outputs: requestedOutputNames(body.requestedOutputs) },
|
|
1199
1235
|
...stringValue(body.requestedModelId) ? { requested_model_id: stringValue(body.requestedModelId) } : {},
|
|
1200
1236
|
...resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: resolution.knowledgeNamespaces },
|
|
1201
1237
|
tool_inputs: objectValue(body.toolInputs),
|
|
@@ -1214,7 +1250,7 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1214
1250
|
client: objectValue(body.client),
|
|
1215
1251
|
cursor: 0
|
|
1216
1252
|
}, (event) => {
|
|
1217
|
-
if (
|
|
1253
|
+
if (runtimeEventEnabled(request, event)) return write(event);
|
|
1218
1254
|
}, { signal, onControl: control, leaseSeconds: 60, streamFeatures: url.searchParams.get("stream_features") || "", onPreview: (frame) => write(frame) });
|
|
1219
1255
|
}, {
|
|
1220
1256
|
"X-Run-ID": admittedRunId,
|