@exulu/backend 5.10.0 → 5.10.1
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.
|
@@ -659,7 +659,7 @@ var ExuluTool = class _ExuluTool {
|
|
|
659
659
|
if (!agent) {
|
|
660
660
|
throw new Error("Agent not found.");
|
|
661
661
|
}
|
|
662
|
-
const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-
|
|
662
|
+
const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-LL7R3VTK.js");
|
|
663
663
|
const tools = await convertExuluToolsToAiSdkTools2(
|
|
664
664
|
[this],
|
|
665
665
|
[],
|
|
@@ -845,6 +845,34 @@ var createSessionItemsRetrievalTool = async ({
|
|
|
845
845
|
return sessionItemsRetrievalTool;
|
|
846
846
|
};
|
|
847
847
|
|
|
848
|
+
// src/exulu/approval-revalidation.ts
|
|
849
|
+
function answeredApprovalToolCallIds(messages) {
|
|
850
|
+
const toolCallByApproval = /* @__PURE__ */ new Map();
|
|
851
|
+
for (const message of messages ?? []) {
|
|
852
|
+
if (message.role !== "assistant" || typeof message.content === "string") continue;
|
|
853
|
+
for (const part of message.content) {
|
|
854
|
+
if (part?.type === "tool-approval-request" && typeof part.approvalId === "string" && typeof part.toolCallId === "string") {
|
|
855
|
+
toolCallByApproval.set(part.approvalId, part.toolCallId);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
const answered = /* @__PURE__ */ new Set();
|
|
860
|
+
for (const message of messages ?? []) {
|
|
861
|
+
if (message.role !== "tool" || typeof message.content === "string") continue;
|
|
862
|
+
for (const part of message.content) {
|
|
863
|
+
if (part?.type !== "tool-approval-response" || typeof part.approvalId !== "string") continue;
|
|
864
|
+
const toolCallId = toolCallByApproval.get(part.approvalId);
|
|
865
|
+
if (toolCallId) answered.add(toolCallId);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
return answered;
|
|
869
|
+
}
|
|
870
|
+
function needsApprovalForCall(args) {
|
|
871
|
+
if (!args.requiresApproval) return false;
|
|
872
|
+
if (answeredApprovalToolCallIds(args.messages).has(args.toolCallId)) return true;
|
|
873
|
+
return !args.approvedForSession;
|
|
874
|
+
}
|
|
875
|
+
|
|
848
876
|
// ee/agentic-retrieval/pipeline/index.ts
|
|
849
877
|
import { z as z8 } from "zod";
|
|
850
878
|
|
|
@@ -15238,11 +15266,12 @@ var convertExuluToolsToAiSdkTools = async (currentTools, currentSkills, approved
|
|
|
15238
15266
|
)?.default;
|
|
15239
15267
|
const toolDescription = cur.description;
|
|
15240
15268
|
const description = userDefinedConfigDescription || defaultConfigDescription || toolDescription;
|
|
15269
|
+
const approvedForSession = approvedTools?.includes("tool-" + cur.name) ?? false;
|
|
15241
15270
|
console.log(
|
|
15242
15271
|
"[EXULU] Tool",
|
|
15243
15272
|
cur.name,
|
|
15244
15273
|
"needs approval",
|
|
15245
|
-
|
|
15274
|
+
cur.needsApprovalFn ? "per call" : isMemoryToolId(cur.id) ? true : approvedForSession ? "only answered calls" : !!cur.needsApproval
|
|
15246
15275
|
);
|
|
15247
15276
|
return {
|
|
15248
15277
|
...prev,
|
|
@@ -15251,8 +15280,16 @@ var convertExuluToolsToAiSdkTools = async (currentTools, currentSkills, approved
|
|
|
15251
15280
|
description,
|
|
15252
15281
|
// The approvedTools array uses the tool.name lookup as the frontend
|
|
15253
15282
|
// Vercel AI SDK uses the sanitized tool name as the key, so this matches.
|
|
15254
|
-
|
|
15255
|
-
//
|
|
15283
|
+
// Never a plain `false` for a tool the user allowed for this chat: the
|
|
15284
|
+
// SDK re-validates an ANSWERED approval by calling needsApproval again
|
|
15285
|
+
// and reads `false` as "deny" — see approval-revalidation.ts.
|
|
15286
|
+
needsApproval: cur.needsApprovalFn ? (input, opts) => cur.needsApprovalFn(input, opts) : isMemoryToolId(cur.id) ? true : (_input, opts) => needsApprovalForCall({
|
|
15287
|
+
toolCallId: opts.toolCallId,
|
|
15288
|
+
messages: opts.messages,
|
|
15289
|
+
approvedForSession,
|
|
15290
|
+
requiresApproval: !!cur.needsApproval
|
|
15291
|
+
// todo make configurable
|
|
15292
|
+
}),
|
|
15256
15293
|
// Auth-wrapped tools: the model sees scrub text instead of the
|
|
15257
15294
|
// credentialRequest/oauth payload; the UI stream keeps the raw
|
|
15258
15295
|
// output (spec 2026-07-22 §1.2).
|
package/dist/index.cjs
CHANGED
|
@@ -9826,6 +9826,40 @@ var init_session_items_retrieval_tool = __esm({
|
|
|
9826
9826
|
}
|
|
9827
9827
|
});
|
|
9828
9828
|
|
|
9829
|
+
// src/exulu/approval-revalidation.ts
|
|
9830
|
+
function answeredApprovalToolCallIds(messages) {
|
|
9831
|
+
const toolCallByApproval = /* @__PURE__ */ new Map();
|
|
9832
|
+
for (const message of messages ?? []) {
|
|
9833
|
+
if (message.role !== "assistant" || typeof message.content === "string") continue;
|
|
9834
|
+
for (const part of message.content) {
|
|
9835
|
+
if (part?.type === "tool-approval-request" && typeof part.approvalId === "string" && typeof part.toolCallId === "string") {
|
|
9836
|
+
toolCallByApproval.set(part.approvalId, part.toolCallId);
|
|
9837
|
+
}
|
|
9838
|
+
}
|
|
9839
|
+
}
|
|
9840
|
+
const answered = /* @__PURE__ */ new Set();
|
|
9841
|
+
for (const message of messages ?? []) {
|
|
9842
|
+
if (message.role !== "tool" || typeof message.content === "string") continue;
|
|
9843
|
+
for (const part of message.content) {
|
|
9844
|
+
if (part?.type !== "tool-approval-response" || typeof part.approvalId !== "string") continue;
|
|
9845
|
+
const toolCallId = toolCallByApproval.get(part.approvalId);
|
|
9846
|
+
if (toolCallId) answered.add(toolCallId);
|
|
9847
|
+
}
|
|
9848
|
+
}
|
|
9849
|
+
return answered;
|
|
9850
|
+
}
|
|
9851
|
+
function needsApprovalForCall(args) {
|
|
9852
|
+
if (!args.requiresApproval) return false;
|
|
9853
|
+
if (answeredApprovalToolCallIds(args.messages).has(args.toolCallId)) return true;
|
|
9854
|
+
return !args.approvedForSession;
|
|
9855
|
+
}
|
|
9856
|
+
var init_approval_revalidation = __esm({
|
|
9857
|
+
"src/exulu/approval-revalidation.ts"() {
|
|
9858
|
+
"use strict";
|
|
9859
|
+
init_cjs_shims();
|
|
9860
|
+
}
|
|
9861
|
+
});
|
|
9862
|
+
|
|
9829
9863
|
// ee/agentic-retrieval/pipeline/global-ids.ts
|
|
9830
9864
|
function parsePreselectedItems(globalIds) {
|
|
9831
9865
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -15610,6 +15644,7 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
15610
15644
|
init_client();
|
|
15611
15645
|
import_crypto_js4 = __toESM(require("crypto-js"), 1);
|
|
15612
15646
|
init_session_items_retrieval_tool();
|
|
15647
|
+
init_approval_revalidation();
|
|
15613
15648
|
init_pipeline();
|
|
15614
15649
|
init_project_scope();
|
|
15615
15650
|
init_sanitize_tool_name();
|
|
@@ -15956,11 +15991,12 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
15956
15991
|
)?.default;
|
|
15957
15992
|
const toolDescription = cur.description;
|
|
15958
15993
|
const description = userDefinedConfigDescription || defaultConfigDescription || toolDescription;
|
|
15994
|
+
const approvedForSession = approvedTools?.includes("tool-" + cur.name) ?? false;
|
|
15959
15995
|
console.log(
|
|
15960
15996
|
"[EXULU] Tool",
|
|
15961
15997
|
cur.name,
|
|
15962
15998
|
"needs approval",
|
|
15963
|
-
|
|
15999
|
+
cur.needsApprovalFn ? "per call" : isMemoryToolId(cur.id) ? true : approvedForSession ? "only answered calls" : !!cur.needsApproval
|
|
15964
16000
|
);
|
|
15965
16001
|
return {
|
|
15966
16002
|
...prev,
|
|
@@ -15969,8 +16005,16 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
15969
16005
|
description,
|
|
15970
16006
|
// The approvedTools array uses the tool.name lookup as the frontend
|
|
15971
16007
|
// Vercel AI SDK uses the sanitized tool name as the key, so this matches.
|
|
15972
|
-
|
|
15973
|
-
//
|
|
16008
|
+
// Never a plain `false` for a tool the user allowed for this chat: the
|
|
16009
|
+
// SDK re-validates an ANSWERED approval by calling needsApproval again
|
|
16010
|
+
// and reads `false` as "deny" — see approval-revalidation.ts.
|
|
16011
|
+
needsApproval: cur.needsApprovalFn ? (input, opts) => cur.needsApprovalFn(input, opts) : isMemoryToolId(cur.id) ? true : (_input, opts) => needsApprovalForCall({
|
|
16012
|
+
toolCallId: opts.toolCallId,
|
|
16013
|
+
messages: opts.messages,
|
|
16014
|
+
approvedForSession,
|
|
16015
|
+
requiresApproval: !!cur.needsApproval
|
|
16016
|
+
// todo make configurable
|
|
16017
|
+
}),
|
|
15974
16018
|
// Auth-wrapped tools: the model sees scrub text instead of the
|
|
15975
16019
|
// credentialRequest/oauth payload; the UI stream keeps the raw
|
|
15976
16020
|
// output (spec 2026-07-22 §1.2).
|
package/dist/index.js
CHANGED