@exulu/backend 1.62.0 → 1.63.0
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/dist/{catalog-BWE6SLE2.js → catalog-TBSPSN2N.js} +1 -1
- package/dist/{chunk-LYNLQWXC.js → chunk-IZOD2X2F.js} +102 -15
- package/dist/{chunk-ILAHW4UT.js → chunk-YCE44CMU.js} +14 -2
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-2HF7PPYW.js → convert-exulu-tools-to-ai-sdk-tools-THDKPKF3.js} +1 -1
- package/dist/index.cjs +198 -47
- package/dist/index.d.cts +17 -10
- package/dist/index.d.ts +17 -10
- package/dist/index.js +84 -32
- package/ee/rbac-resolver.ts +9 -1
- package/ee/rbac-update.ts +32 -1
- package/ee/schemas.ts +25 -0
- package/ee/workers.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -267,6 +267,12 @@ var init_auth = __esm({
|
|
|
267
267
|
user.role = role;
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
+
if (user?.team) {
|
|
271
|
+
const team = await db2.from("teams").select("*").where("id", user?.team).first();
|
|
272
|
+
if (team) {
|
|
273
|
+
user.team = team;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
270
276
|
if (!user) {
|
|
271
277
|
return {
|
|
272
278
|
error: true,
|
|
@@ -376,7 +382,7 @@ var init_statistics = __esm({
|
|
|
376
382
|
});
|
|
377
383
|
|
|
378
384
|
// src/exulu/litellm/supervisor.ts
|
|
379
|
-
var import_node_child_process, import_node_fs, import_node_path, MAX_CRASHES, INITIAL_BACKOFF_MS, MAX_BACKOFF_MS, READY_TIMEOUT_MS, READY_POLL_INTERVAL_MS, SHUTDOWN_GRACE_MS, internal, isLiteLLMEnabled, resolveConfig, log, pollHealth, spawnLiteLLM, supervise, _packageRoot, setLiteLLMPackageRoot, startLiteLLMSupervisor, waitForLiteLLMReady, stopLiteLLM, shutdownHandlersRegistered, registerShutdownHandlers;
|
|
385
|
+
var import_node_child_process, import_node_fs, import_node_path, MAX_CRASHES, INITIAL_BACKOFF_MS, MAX_BACKOFF_MS, READY_TIMEOUT_MS, WAIT_TIMEOUT_MS, READY_POLL_INTERVAL_MS, SHUTDOWN_GRACE_MS, internal, isLiteLLMEnabled, resolveConfig, log, pollHealth, spawnLiteLLM, supervise, _packageRoot, setLiteLLMPackageRoot, startLiteLLMSupervisor, waitForLiteLLMReady, stopLiteLLM, shutdownHandlersRegistered, registerShutdownHandlers, getSupervisorState;
|
|
380
386
|
var init_supervisor = __esm({
|
|
381
387
|
"src/exulu/litellm/supervisor.ts"() {
|
|
382
388
|
"use strict";
|
|
@@ -387,7 +393,8 @@ var init_supervisor = __esm({
|
|
|
387
393
|
MAX_CRASHES = 5;
|
|
388
394
|
INITIAL_BACKOFF_MS = 1e3;
|
|
389
395
|
MAX_BACKOFF_MS = 3e4;
|
|
390
|
-
READY_TIMEOUT_MS =
|
|
396
|
+
READY_TIMEOUT_MS = 9e4;
|
|
397
|
+
WAIT_TIMEOUT_MS = 6e4;
|
|
391
398
|
READY_POLL_INTERVAL_MS = 200;
|
|
392
399
|
SHUTDOWN_GRACE_MS = 5e3;
|
|
393
400
|
internal = {
|
|
@@ -560,10 +567,18 @@ var init_supervisor = __esm({
|
|
|
560
567
|
waitForLiteLLMReady = async () => {
|
|
561
568
|
if (!isLiteLLMEnabled()) return;
|
|
562
569
|
if (!internal.readyPromise) {
|
|
563
|
-
|
|
564
|
-
return;
|
|
570
|
+
return startLiteLLMSupervisor();
|
|
565
571
|
}
|
|
566
|
-
|
|
572
|
+
const deadline = Date.now() + WAIT_TIMEOUT_MS;
|
|
573
|
+
while (Date.now() < deadline) {
|
|
574
|
+
const s = getSupervisorState();
|
|
575
|
+
if (s === "ready") return;
|
|
576
|
+
if (s === "given_up") {
|
|
577
|
+
throw new Error("LiteLLM supervisor has given up.");
|
|
578
|
+
}
|
|
579
|
+
await new Promise((r) => setTimeout(r, READY_POLL_INTERVAL_MS));
|
|
580
|
+
}
|
|
581
|
+
throw new Error("Timed out waiting for LiteLLM to become ready.");
|
|
567
582
|
};
|
|
568
583
|
stopLiteLLM = (signal = "SIGTERM") => {
|
|
569
584
|
internal.shutdownRequested = true;
|
|
@@ -590,6 +605,7 @@ var init_supervisor = __esm({
|
|
|
590
605
|
process.on("SIGTERM", () => stopLiteLLM("SIGTERM"));
|
|
591
606
|
process.on("exit", () => stopLiteLLM("SIGTERM"));
|
|
592
607
|
};
|
|
608
|
+
getSupervisorState = () => internal.state;
|
|
593
609
|
}
|
|
594
610
|
});
|
|
595
611
|
|
|
@@ -627,6 +643,7 @@ var init_check_record_access = __esm({
|
|
|
627
643
|
const isPublic = record.rights_mode === "public";
|
|
628
644
|
const byUsers = record.rights_mode === "users";
|
|
629
645
|
const byRoles = record.rights_mode === "roles";
|
|
646
|
+
const byTeams = record.rights_mode === "teams";
|
|
630
647
|
const createdBy = typeof record.created_by === "string" ? record.created_by : record.created_by?.toString();
|
|
631
648
|
const isCreator = user ? createdBy === user.id.toString() : false;
|
|
632
649
|
const isAdmin = user ? user.super_admin : false;
|
|
@@ -672,6 +689,23 @@ var init_check_record_access = __esm({
|
|
|
672
689
|
return true;
|
|
673
690
|
}
|
|
674
691
|
}
|
|
692
|
+
if (byTeams) {
|
|
693
|
+
if (!user) {
|
|
694
|
+
setRecordAccessCache(false);
|
|
695
|
+
return false;
|
|
696
|
+
}
|
|
697
|
+
hasAccess = record.RBAC?.teams?.find((x) => x.id === user.team?.id)?.rights || "none";
|
|
698
|
+
if (!hasAccess || hasAccess === "none" || hasAccess !== request2) {
|
|
699
|
+
console.error(
|
|
700
|
+
`[EXULU] Your current team ${user.team?.name} does not have access to this record, current access type is: ${hasAccess}.`
|
|
701
|
+
);
|
|
702
|
+
setRecordAccessCache(false);
|
|
703
|
+
return false;
|
|
704
|
+
} else {
|
|
705
|
+
setRecordAccessCache(true);
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
675
709
|
setRecordAccessCache(false);
|
|
676
710
|
return false;
|
|
677
711
|
};
|
|
@@ -774,6 +808,12 @@ function buildTags(input) {
|
|
|
774
808
|
if (input.agent_name) {
|
|
775
809
|
candidates.push("agent_name_" + input.agent_name);
|
|
776
810
|
}
|
|
811
|
+
if (input.team_id) {
|
|
812
|
+
candidates.push("team_id_" + input.team_id);
|
|
813
|
+
}
|
|
814
|
+
if (input.team_name) {
|
|
815
|
+
candidates.push("team_name_" + input.team_name);
|
|
816
|
+
}
|
|
777
817
|
console.log("[EXULU] Candidates", candidates);
|
|
778
818
|
const out = [];
|
|
779
819
|
for (const candidate of candidates) {
|
|
@@ -871,10 +911,11 @@ async function resolveModel(input) {
|
|
|
871
911
|
);
|
|
872
912
|
}
|
|
873
913
|
const litellm = getLiteLLMProvider({
|
|
874
|
-
user
|
|
875
|
-
role: user?.role
|
|
876
|
-
project
|
|
877
|
-
agent
|
|
914
|
+
user,
|
|
915
|
+
role: user?.role,
|
|
916
|
+
project,
|
|
917
|
+
agent,
|
|
918
|
+
team: user?.team
|
|
878
919
|
});
|
|
879
920
|
const languageModel2 = litellm(modelId);
|
|
880
921
|
const syntheticModel = {
|
|
@@ -986,17 +1027,24 @@ var init_resolve_model = __esm({
|
|
|
986
1027
|
user,
|
|
987
1028
|
role,
|
|
988
1029
|
project,
|
|
989
|
-
agent
|
|
1030
|
+
agent,
|
|
1031
|
+
team
|
|
990
1032
|
}) => {
|
|
991
1033
|
if (_litellmProvider) return _litellmProvider;
|
|
992
1034
|
const host = process.env.LITELLM_HOST ?? "127.0.0.1";
|
|
993
1035
|
const port = process.env.LITELLM_PORT ?? "4000";
|
|
994
1036
|
const masterKey = process.env.LITELLM_MASTER_KEY;
|
|
995
1037
|
const tags = buildTags({
|
|
996
|
-
user,
|
|
997
|
-
role,
|
|
998
|
-
project,
|
|
999
|
-
agent
|
|
1038
|
+
user_id: user?.id,
|
|
1039
|
+
role_id: role?.id,
|
|
1040
|
+
project_id: project?.id,
|
|
1041
|
+
agent_id: agent?.id,
|
|
1042
|
+
user_name: !user ? void 0 : user.type === "api" ? user.firstname ?? user.email : user.email,
|
|
1043
|
+
role_name: role?.name,
|
|
1044
|
+
project_name: project?.name,
|
|
1045
|
+
agent_name: agent?.name,
|
|
1046
|
+
team_id: team?.id,
|
|
1047
|
+
team_name: team?.name
|
|
1000
1048
|
});
|
|
1001
1049
|
if (!masterKey) {
|
|
1002
1050
|
throw new ResolveModelError(
|
|
@@ -3318,7 +3366,7 @@ var init_tool = __esm({
|
|
|
3318
3366
|
modelId: agent.model,
|
|
3319
3367
|
user,
|
|
3320
3368
|
providers,
|
|
3321
|
-
agent
|
|
3369
|
+
agent,
|
|
3322
3370
|
rbacBypass: true
|
|
3323
3371
|
});
|
|
3324
3372
|
providerapikey = resolved.apiKey;
|
|
@@ -3688,6 +3736,16 @@ var init_access_control = __esm({
|
|
|
3688
3736
|
});
|
|
3689
3737
|
});
|
|
3690
3738
|
}
|
|
3739
|
+
if (user?.team) {
|
|
3740
|
+
const userTeamId = user.team.id;
|
|
3741
|
+
this.orWhere(function() {
|
|
3742
|
+
this.where(`${prefix}rights_mode`, "teams").whereExists(function() {
|
|
3743
|
+
this.select("*").from("rbac").whereRaw(
|
|
3744
|
+
"rbac.target_resource_id = " + (prefix ? prefix.slice(0, -1) : tableNamePlural) + ".id"
|
|
3745
|
+
).where("rbac.entity", table.name.singular).where("rbac.access_type", "Team").where("rbac.team_id", userTeamId);
|
|
3746
|
+
});
|
|
3747
|
+
});
|
|
3748
|
+
}
|
|
3691
3749
|
});
|
|
3692
3750
|
} catch (error) {
|
|
3693
3751
|
console.error("Access control error:", error);
|
|
@@ -3830,7 +3888,7 @@ var init_vector_methods = __esm({
|
|
|
3830
3888
|
});
|
|
3831
3889
|
|
|
3832
3890
|
// ee/schemas.ts
|
|
3833
|
-
var feedbackSchema, rolesSchema, statisticsSchema, testCasesSchema, evalSetsSchema, jobResultsSchema, evalRunsSchema, rbacSchema, workflowTemplatesSchema;
|
|
3891
|
+
var feedbackSchema, rolesSchema, teamsSchema, statisticsSchema, testCasesSchema, evalSetsSchema, jobResultsSchema, evalRunsSchema, rbacSchema, workflowTemplatesSchema;
|
|
3834
3892
|
var init_schemas = __esm({
|
|
3835
3893
|
"ee/schemas.ts"() {
|
|
3836
3894
|
"use strict";
|
|
@@ -3914,6 +3972,26 @@ var init_schemas = __esm({
|
|
|
3914
3972
|
}
|
|
3915
3973
|
]
|
|
3916
3974
|
};
|
|
3975
|
+
teamsSchema = {
|
|
3976
|
+
type: "teams",
|
|
3977
|
+
name: {
|
|
3978
|
+
plural: "teams",
|
|
3979
|
+
singular: "team"
|
|
3980
|
+
},
|
|
3981
|
+
fields: [
|
|
3982
|
+
{
|
|
3983
|
+
name: "name",
|
|
3984
|
+
type: "text",
|
|
3985
|
+
index: true,
|
|
3986
|
+
unique: true,
|
|
3987
|
+
required: true
|
|
3988
|
+
},
|
|
3989
|
+
{
|
|
3990
|
+
name: "description",
|
|
3991
|
+
type: "text"
|
|
3992
|
+
}
|
|
3993
|
+
]
|
|
3994
|
+
};
|
|
3917
3995
|
statisticsSchema = {
|
|
3918
3996
|
type: "tracking",
|
|
3919
3997
|
name: {
|
|
@@ -4134,6 +4212,10 @@ var init_schemas = __esm({
|
|
|
4134
4212
|
name: "role_id",
|
|
4135
4213
|
type: "uuid"
|
|
4136
4214
|
},
|
|
4215
|
+
{
|
|
4216
|
+
name: "team_id",
|
|
4217
|
+
type: "uuid"
|
|
4218
|
+
},
|
|
4137
4219
|
{
|
|
4138
4220
|
name: "user_id",
|
|
4139
4221
|
type: "number"
|
|
@@ -4601,6 +4683,10 @@ var init_core_schema = __esm({
|
|
|
4601
4683
|
{
|
|
4602
4684
|
name: "role",
|
|
4603
4685
|
type: "uuid"
|
|
4686
|
+
},
|
|
4687
|
+
{
|
|
4688
|
+
name: "team",
|
|
4689
|
+
type: "uuid"
|
|
4604
4690
|
}
|
|
4605
4691
|
]
|
|
4606
4692
|
};
|
|
@@ -4879,6 +4965,7 @@ var init_core_schema = __esm({
|
|
|
4879
4965
|
}
|
|
4880
4966
|
if (license["rbac"]) {
|
|
4881
4967
|
schemas.rolesSchema = () => addCoreFields(rolesSchema);
|
|
4968
|
+
schemas.teamsSchema = () => addCoreFields(teamsSchema);
|
|
4882
4969
|
schemas.rbacSchema = () => addCoreFields(rbacSchema);
|
|
4883
4970
|
}
|
|
4884
4971
|
if (license["evals"]) {
|
|
@@ -7769,6 +7856,8 @@ var init_catalog = __esm({
|
|
|
7769
7856
|
region: m.model_info?.region ?? null,
|
|
7770
7857
|
max_tokens: m.model_info?.max_tokens ?? null,
|
|
7771
7858
|
max_input_tokens: m.model_info?.max_input_tokens ?? null,
|
|
7859
|
+
input_cost_per_million_tokens: m.model_info?.input_cost_per_token * 1e6,
|
|
7860
|
+
output_cost_per_million_tokens: m.model_info?.output_cost_per_token * 1e6,
|
|
7772
7861
|
active: m.model_info?.active ?? true,
|
|
7773
7862
|
max_output_tokens: m.model_info?.max_output_tokens ?? null,
|
|
7774
7863
|
supports_vision: !!m.model_info?.supports_vision,
|
|
@@ -7780,8 +7869,18 @@ var init_catalog = __esm({
|
|
|
7780
7869
|
supports_edit: !!m.model_info?.supports_edit,
|
|
7781
7870
|
max_n: typeof m.model_info?.max_n === "number" ? m.model_info.max_n : null
|
|
7782
7871
|
}));
|
|
7783
|
-
|
|
7784
|
-
|
|
7872
|
+
const map = /* @__PURE__ */ new Map();
|
|
7873
|
+
for (const item of items) {
|
|
7874
|
+
const key2 = `${item.model_name}-${item.upstream_model}`;
|
|
7875
|
+
if (map.has(key2)) {
|
|
7876
|
+
map.get(key2).tags.push(...item.tags);
|
|
7877
|
+
} else {
|
|
7878
|
+
map.set(key2, item);
|
|
7879
|
+
}
|
|
7880
|
+
}
|
|
7881
|
+
const uniqueItems = Array.from(map.values());
|
|
7882
|
+
_cache = { expiresAt: Date.now() + CACHE_TTL_MS2, items: uniqueItems };
|
|
7883
|
+
return uniqueItems.filter((m) => m.type !== "speech_to_text" && m.type !== "text_to_speech");
|
|
7785
7884
|
} catch (err) {
|
|
7786
7885
|
console.error("[EXULU] litellmCatalog: failed to fetch /model/info:", err);
|
|
7787
7886
|
return [];
|
|
@@ -8303,7 +8402,8 @@ var RBACResolver = async (db2, entityName, resourceId, rights_mode) => {
|
|
|
8303
8402
|
return {
|
|
8304
8403
|
type: "public",
|
|
8305
8404
|
users: [],
|
|
8306
|
-
roles: []
|
|
8405
|
+
roles: [],
|
|
8406
|
+
teams: []
|
|
8307
8407
|
};
|
|
8308
8408
|
}
|
|
8309
8409
|
const rbacRecords = await db2.from("rbac").where({
|
|
@@ -8312,13 +8412,16 @@ var RBACResolver = async (db2, entityName, resourceId, rights_mode) => {
|
|
|
8312
8412
|
}).select("*");
|
|
8313
8413
|
const users = rbacRecords.filter((r) => r.access_type === "User")?.map((r) => ({ id: r.user_id, rights: r.rights }));
|
|
8314
8414
|
const roles = rbacRecords.filter((r) => r.access_type === "Role")?.map((r) => ({ id: r.role_id, rights: r.rights }));
|
|
8415
|
+
const teams = rbacRecords.filter((r) => r.access_type === "Team")?.map((r) => ({ id: r.team_id, rights: r.rights }));
|
|
8315
8416
|
let type = rights_mode || "private";
|
|
8316
8417
|
if (type === "users" && users.length === 0) type = "private";
|
|
8317
8418
|
if (type === "roles" && roles.length === 0) type = "private";
|
|
8419
|
+
if (type === "teams" && teams.length === 0) type = "private";
|
|
8318
8420
|
return {
|
|
8319
8421
|
type,
|
|
8320
8422
|
users,
|
|
8321
|
-
roles
|
|
8423
|
+
roles,
|
|
8424
|
+
teams
|
|
8322
8425
|
};
|
|
8323
8426
|
};
|
|
8324
8427
|
|
|
@@ -9075,7 +9178,8 @@ var handleRBACUpdate = async (db2, entityName, resourceId, rbacData, existingRba
|
|
|
9075
9178
|
}
|
|
9076
9179
|
const {
|
|
9077
9180
|
users = [],
|
|
9078
|
-
roles = []
|
|
9181
|
+
roles = [],
|
|
9182
|
+
teams = []
|
|
9079
9183
|
/* projects = [] */
|
|
9080
9184
|
} = rbacData;
|
|
9081
9185
|
if (!existingRbacRecords) {
|
|
@@ -9086,20 +9190,28 @@ var handleRBACUpdate = async (db2, entityName, resourceId, rbacData, existingRba
|
|
|
9086
9190
|
}
|
|
9087
9191
|
const newUserRecords = new Set(users.map((u) => `${u.id}:${u.rights}`));
|
|
9088
9192
|
const newRoleRecords = new Set(roles.map((r) => `${r.id}:${r.rights}`));
|
|
9193
|
+
const newTeamRecords = new Set(teams.map((t) => `${t.id}:${t.rights}`));
|
|
9089
9194
|
const existingUserRecords = new Set(
|
|
9090
9195
|
existingRbacRecords.filter((r) => r.access_type === "User").map((r) => `${r.user_id}:${r.rights}`)
|
|
9091
9196
|
);
|
|
9092
9197
|
const existingRoleRecords = new Set(
|
|
9093
9198
|
existingRbacRecords.filter((r) => r.access_type === "Role").map((r) => `${r.role_id}:${r.rights}`)
|
|
9094
9199
|
);
|
|
9200
|
+
const existingTeamRecords = new Set(
|
|
9201
|
+
existingRbacRecords.filter((r) => r.access_type === "Team").map((r) => `${r.team_id}:${r.rights}`)
|
|
9202
|
+
);
|
|
9095
9203
|
const usersToCreate = users.filter((u) => !existingUserRecords.has(`${u.id}:${u.rights}`));
|
|
9096
9204
|
const rolesToCreate = roles.filter((r) => !existingRoleRecords.has(`${r.id}:${r.rights}`));
|
|
9205
|
+
const teamsToCreate = teams.filter((t) => !existingTeamRecords.has(`${t.id}:${t.rights}`));
|
|
9097
9206
|
const usersToRemove = existingRbacRecords.filter(
|
|
9098
9207
|
(r) => r.access_type === "User" && !newUserRecords.has(`${r.user_id}:${r.rights}`)
|
|
9099
9208
|
);
|
|
9100
9209
|
const rolesToRemove = existingRbacRecords.filter(
|
|
9101
9210
|
(r) => r.access_type === "Role" && !newRoleRecords.has(`${r.role_id}:${r.rights}`)
|
|
9102
9211
|
);
|
|
9212
|
+
const teamsToRemove = existingRbacRecords.filter(
|
|
9213
|
+
(r) => r.access_type === "Team" && !newTeamRecords.has(`${r.team_id}:${r.rights}`)
|
|
9214
|
+
);
|
|
9103
9215
|
if (usersToRemove.length > 0) {
|
|
9104
9216
|
await db2.from("rbac").whereIn(
|
|
9105
9217
|
"id",
|
|
@@ -9112,6 +9224,12 @@ var handleRBACUpdate = async (db2, entityName, resourceId, rbacData, existingRba
|
|
|
9112
9224
|
rolesToRemove.map((r) => r.id)
|
|
9113
9225
|
).del();
|
|
9114
9226
|
}
|
|
9227
|
+
if (teamsToRemove.length > 0) {
|
|
9228
|
+
await db2.from("rbac").whereIn(
|
|
9229
|
+
"id",
|
|
9230
|
+
teamsToRemove.map((r) => r.id)
|
|
9231
|
+
).del();
|
|
9232
|
+
}
|
|
9115
9233
|
const recordsToInsert = [];
|
|
9116
9234
|
usersToCreate.forEach((user) => {
|
|
9117
9235
|
recordsToInsert.push({
|
|
@@ -9135,6 +9253,17 @@ var handleRBACUpdate = async (db2, entityName, resourceId, rbacData, existingRba
|
|
|
9135
9253
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9136
9254
|
});
|
|
9137
9255
|
});
|
|
9256
|
+
teamsToCreate.forEach((team) => {
|
|
9257
|
+
recordsToInsert.push({
|
|
9258
|
+
entity: entityName,
|
|
9259
|
+
access_type: "Team",
|
|
9260
|
+
target_resource_id: resourceId,
|
|
9261
|
+
team_id: team.id,
|
|
9262
|
+
rights: team.rights,
|
|
9263
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
9264
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
9265
|
+
});
|
|
9266
|
+
});
|
|
9138
9267
|
if (recordsToInsert.length > 0) {
|
|
9139
9268
|
await db2.from("rbac").insert(recordsToInsert);
|
|
9140
9269
|
}
|
|
@@ -9333,6 +9462,19 @@ function createMutations(table, providers, contexts, rerankers, tools, config) {
|
|
|
9333
9462
|
}
|
|
9334
9463
|
throw new Error("Insufficient role permissions to edit this record");
|
|
9335
9464
|
}
|
|
9465
|
+
if (record.rights_mode === "teams" && user.team) {
|
|
9466
|
+
const rbacRecord = await db2.from("rbac").where({
|
|
9467
|
+
entity: table.name.singular,
|
|
9468
|
+
target_resource_id: id,
|
|
9469
|
+
access_type: "Team",
|
|
9470
|
+
team_id: user.team,
|
|
9471
|
+
rights: "write"
|
|
9472
|
+
}).first();
|
|
9473
|
+
if (rbacRecord) {
|
|
9474
|
+
return true;
|
|
9475
|
+
}
|
|
9476
|
+
throw new Error("Insufficient team permissions to edit this record");
|
|
9477
|
+
}
|
|
9336
9478
|
throw new Error("Insufficient permissions to edit this record");
|
|
9337
9479
|
} catch (error) {
|
|
9338
9480
|
console.error("Write access validation error:", error);
|
|
@@ -11036,7 +11178,7 @@ var processUiMessagesFlow = async ({
|
|
|
11036
11178
|
modelId: agent.model,
|
|
11037
11179
|
user,
|
|
11038
11180
|
providers,
|
|
11039
|
-
agent
|
|
11181
|
+
agent
|
|
11040
11182
|
});
|
|
11041
11183
|
const providerapikey = resolved.apiKey;
|
|
11042
11184
|
const resolvedLanguageModel = resolved.languageModel;
|
|
@@ -12077,6 +12219,8 @@ type LiteLLMModel {
|
|
|
12077
12219
|
supports_function_calling: Boolean
|
|
12078
12220
|
supports_pdf_input: Boolean
|
|
12079
12221
|
supports_audio_input: Boolean
|
|
12222
|
+
input_cost_per_million_tokens: Float
|
|
12223
|
+
output_cost_per_million_tokens: Float
|
|
12080
12224
|
}
|
|
12081
12225
|
`;
|
|
12082
12226
|
resolvers.Query["agentRateLimitUsage"] = async (_, args, context) => {
|
|
@@ -13668,7 +13812,7 @@ var ExuluProvider = class {
|
|
|
13668
13812
|
modelId: agent.model,
|
|
13669
13813
|
user,
|
|
13670
13814
|
providers,
|
|
13671
|
-
agent
|
|
13815
|
+
agent
|
|
13672
13816
|
});
|
|
13673
13817
|
const providerapikey = resolved.apiKey;
|
|
13674
13818
|
console.log(
|
|
@@ -15376,7 +15520,7 @@ var registerOpenAIGatewayRoutes = async (app, providers, tools, contexts, config
|
|
|
15376
15520
|
});
|
|
15377
15521
|
return;
|
|
15378
15522
|
}
|
|
15379
|
-
let project =
|
|
15523
|
+
let project = void 0;
|
|
15380
15524
|
if (projectName) {
|
|
15381
15525
|
let projectQuery = db2("projects").select("*");
|
|
15382
15526
|
projectQuery = applyAccessControl(projectsSchema4(), projectQuery, user);
|
|
@@ -15399,8 +15543,8 @@ var registerOpenAIGatewayRoutes = async (app, providers, tools, contexts, config
|
|
|
15399
15543
|
modelId: agent.model,
|
|
15400
15544
|
user,
|
|
15401
15545
|
providers,
|
|
15402
|
-
agent
|
|
15403
|
-
project
|
|
15546
|
+
agent,
|
|
15547
|
+
project
|
|
15404
15548
|
});
|
|
15405
15549
|
} catch (err) {
|
|
15406
15550
|
if (err instanceof ResolveModelError) {
|
|
@@ -15577,6 +15721,7 @@ var {
|
|
|
15577
15721
|
rbacSchema: rbacSchema2,
|
|
15578
15722
|
promptLibrarySchema: promptLibrarySchema2,
|
|
15579
15723
|
contextPresetsSchema: contextPresetsSchema2,
|
|
15724
|
+
teamsSchema: teamsSchema2,
|
|
15580
15725
|
embedderSettingsSchema: embedderSettingsSchema2,
|
|
15581
15726
|
promptFavoritesSchema: promptFavoritesSchema2,
|
|
15582
15727
|
statisticsSchema: statisticsSchema2,
|
|
@@ -15626,6 +15771,7 @@ var createExpressRoutes = async (app, providers, tools, contexts, config, evals,
|
|
|
15626
15771
|
jobResultsSchema2(),
|
|
15627
15772
|
promptLibrarySchema2(),
|
|
15628
15773
|
contextPresetsSchema2(),
|
|
15774
|
+
teamsSchema2(),
|
|
15629
15775
|
embedderSettingsSchema2(),
|
|
15630
15776
|
promptFavoritesSchema2(),
|
|
15631
15777
|
evalRunsSchema2(),
|
|
@@ -16012,7 +16158,7 @@ Mood: friendly and intelligent.
|
|
|
16012
16158
|
modelId,
|
|
16013
16159
|
user,
|
|
16014
16160
|
providers,
|
|
16015
|
-
agent
|
|
16161
|
+
agent
|
|
16016
16162
|
});
|
|
16017
16163
|
} catch (err) {
|
|
16018
16164
|
if (err instanceof ResolveModelError) {
|
|
@@ -16273,7 +16419,7 @@ ${customInstructions}` : agent.instructions;
|
|
|
16273
16419
|
modelId: agent.model,
|
|
16274
16420
|
user,
|
|
16275
16421
|
providers,
|
|
16276
|
-
agent
|
|
16422
|
+
agent
|
|
16277
16423
|
});
|
|
16278
16424
|
} catch (err) {
|
|
16279
16425
|
if (err instanceof ResolveModelError) {
|
|
@@ -17085,7 +17231,9 @@ ${style.markdown}` : params.prompt;
|
|
|
17085
17231
|
project_id: project?.id,
|
|
17086
17232
|
user_name: user.email,
|
|
17087
17233
|
role_name: user.role?.name,
|
|
17088
|
-
project_name: project?.name
|
|
17234
|
+
project_name: project?.name,
|
|
17235
|
+
team_id: user.team?.id,
|
|
17236
|
+
team_name: user.team?.name
|
|
17089
17237
|
});
|
|
17090
17238
|
if (tags?.length) {
|
|
17091
17239
|
upstreamHeaders["x-litellm-tags"] = tags.join(",");
|
|
@@ -18130,7 +18278,7 @@ var ExuluMCP = class {
|
|
|
18130
18278
|
modelId: agent.model,
|
|
18131
18279
|
user,
|
|
18132
18280
|
providers: allProviders,
|
|
18133
|
-
agent
|
|
18281
|
+
agent
|
|
18134
18282
|
});
|
|
18135
18283
|
const providerapikey = resolved.apiKey;
|
|
18136
18284
|
if (!isLiteLLMEnabled()) {
|
|
@@ -19376,6 +19524,7 @@ var ExuluEval = class {
|
|
|
19376
19524
|
init_resolve_model();
|
|
19377
19525
|
init_singleton();
|
|
19378
19526
|
var import_zod14 = require("zod");
|
|
19527
|
+
var import_ai14 = require("ai");
|
|
19379
19528
|
var llmAsJudgeEval = () => {
|
|
19380
19529
|
if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
|
|
19381
19530
|
return new ExuluEval({
|
|
@@ -19416,27 +19565,27 @@ var llmAsJudgeEval = () => {
|
|
|
19416
19565
|
const resolved = await resolveModel({
|
|
19417
19566
|
modelId: agent.model,
|
|
19418
19567
|
providers: exuluApp.get().providers,
|
|
19419
|
-
agent
|
|
19568
|
+
agent,
|
|
19420
19569
|
rbacBypass: true
|
|
19421
19570
|
});
|
|
19422
|
-
const providerapikey = resolved.apiKey;
|
|
19423
19571
|
console.log("[EXULU] prompt", prompt);
|
|
19424
|
-
const
|
|
19425
|
-
|
|
19426
|
-
|
|
19427
|
-
|
|
19572
|
+
const { output } = await (0, import_ai14.generateText)({
|
|
19573
|
+
temperature: 0,
|
|
19574
|
+
model: resolved.languageModel,
|
|
19575
|
+
system: "",
|
|
19428
19576
|
prompt,
|
|
19429
|
-
|
|
19430
|
-
|
|
19431
|
-
|
|
19432
|
-
|
|
19433
|
-
|
|
19577
|
+
maxRetries: 2,
|
|
19578
|
+
output: import_ai14.Output.object({
|
|
19579
|
+
schema: import_zod14.z.object({
|
|
19580
|
+
score: import_zod14.z.number().min(0).max(100).describe("The score between 0 and 100.")
|
|
19581
|
+
})
|
|
19582
|
+
})
|
|
19434
19583
|
});
|
|
19435
|
-
console.log("[EXULU]
|
|
19436
|
-
const score =
|
|
19584
|
+
console.log("[EXULU] output", output);
|
|
19585
|
+
const score = output.score;
|
|
19437
19586
|
if (isNaN(score)) {
|
|
19438
19587
|
throw new Error(
|
|
19439
|
-
`Generated score from llm as a judge eval is not a number: ${
|
|
19588
|
+
`Generated score from llm as a judge eval is not a number: ${output.score}`
|
|
19440
19589
|
);
|
|
19441
19590
|
}
|
|
19442
19591
|
return score;
|
|
@@ -22843,6 +22992,7 @@ var {
|
|
|
22843
22992
|
agentMessagesSchema: agentMessagesSchema3,
|
|
22844
22993
|
modelsSchema: modelsSchema3,
|
|
22845
22994
|
rolesSchema: rolesSchema3,
|
|
22995
|
+
teamsSchema: teamsSchema3,
|
|
22846
22996
|
usersSchema: usersSchema3,
|
|
22847
22997
|
skillsSchema: skillsSchema3,
|
|
22848
22998
|
statisticsSchema: statisticsSchema3,
|
|
@@ -22885,6 +23035,7 @@ var up = async function(knex) {
|
|
|
22885
23035
|
agentMessagesSchema3(),
|
|
22886
23036
|
modelsSchema3(),
|
|
22887
23037
|
rolesSchema3(),
|
|
23038
|
+
teamsSchema3(),
|
|
22888
23039
|
testCasesSchema3(),
|
|
22889
23040
|
evalSetsSchema3(),
|
|
22890
23041
|
evalRunsSchema3(),
|
|
@@ -23912,7 +24063,7 @@ var MarkdownChunker = class {
|
|
|
23912
24063
|
init_cjs_shims();
|
|
23913
24064
|
var fs5 = __toESM(require("fs"), 1);
|
|
23914
24065
|
var path2 = __toESM(require("path"), 1);
|
|
23915
|
-
var
|
|
24066
|
+
var import_ai15 = require("ai");
|
|
23916
24067
|
var import_zod22 = require("zod");
|
|
23917
24068
|
var import_p_limit = __toESM(require("p-limit"), 1);
|
|
23918
24069
|
var import_crypto = require("crypto");
|
|
@@ -24265,9 +24416,9 @@ If the page contains a flow-chart, schematic, technical drawing or control board
|
|
|
24265
24416
|
|
|
24266
24417
|
### 7. Only populate \`corrected_text\` when \`needs_correction\` is true. If the OCR output is accurate, return \`needs_correction: false\` and \`corrected_content: null\`.
|
|
24267
24418
|
`;
|
|
24268
|
-
const result = await (0,
|
|
24419
|
+
const result = await (0, import_ai15.generateText)({
|
|
24269
24420
|
model,
|
|
24270
|
-
output:
|
|
24421
|
+
output: import_ai15.Output.object({
|
|
24271
24422
|
schema: import_zod22.z.object({
|
|
24272
24423
|
needs_correction: import_zod22.z.boolean(),
|
|
24273
24424
|
corrected_text: import_zod22.z.string().nullable(),
|
package/dist/index.d.cts
CHANGED
|
@@ -24,15 +24,22 @@ type User = {
|
|
|
24
24
|
favourite_agents?: string[];
|
|
25
25
|
scope_mode?: ApiKeyScopeMode;
|
|
26
26
|
agent_ids?: string[];
|
|
27
|
-
role:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
role: UserRole;
|
|
28
|
+
team?: ExuluTeam;
|
|
29
|
+
};
|
|
30
|
+
type UserRole = {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
agents: "read" | "write";
|
|
34
|
+
evals: "read" | "write";
|
|
35
|
+
workflows: "read" | "write";
|
|
36
|
+
variables: "read" | "write";
|
|
37
|
+
users: "read" | "write";
|
|
38
|
+
};
|
|
39
|
+
type ExuluTeam = {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
description?: string;
|
|
36
43
|
};
|
|
37
44
|
|
|
38
45
|
declare function redisClient(): Promise<{
|
|
@@ -789,7 +796,7 @@ declare class ExuluProvider {
|
|
|
789
796
|
get providerName(): string;
|
|
790
797
|
get modelName(): string;
|
|
791
798
|
tool: (instance: string, providers: ExuluProvider[], contexts: ExuluContext[], rerankers: ExuluReranker[]) => Promise<ExuluTool | null>;
|
|
792
|
-
generateSync: ({ prompt, req, user, session, inputMessages, approvedTools, currentTools, currentSkills, allExuluTools, statistics, toolConfigs, providerapikey, languageModel, contexts, rerankers, exuluConfig, agent, instructions, maxStepCount, onTokenUsage
|
|
799
|
+
generateSync: ({ prompt, req, user, session, inputMessages, approvedTools, currentTools, currentSkills, allExuluTools, statistics, toolConfigs, providerapikey, languageModel, contexts, rerankers, exuluConfig, agent, instructions, maxStepCount, onTokenUsage }: {
|
|
793
800
|
prompt?: string;
|
|
794
801
|
user?: User;
|
|
795
802
|
maxStepCount?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -24,15 +24,22 @@ type User = {
|
|
|
24
24
|
favourite_agents?: string[];
|
|
25
25
|
scope_mode?: ApiKeyScopeMode;
|
|
26
26
|
agent_ids?: string[];
|
|
27
|
-
role:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
role: UserRole;
|
|
28
|
+
team?: ExuluTeam;
|
|
29
|
+
};
|
|
30
|
+
type UserRole = {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
agents: "read" | "write";
|
|
34
|
+
evals: "read" | "write";
|
|
35
|
+
workflows: "read" | "write";
|
|
36
|
+
variables: "read" | "write";
|
|
37
|
+
users: "read" | "write";
|
|
38
|
+
};
|
|
39
|
+
type ExuluTeam = {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
description?: string;
|
|
36
43
|
};
|
|
37
44
|
|
|
38
45
|
declare function redisClient(): Promise<{
|
|
@@ -789,7 +796,7 @@ declare class ExuluProvider {
|
|
|
789
796
|
get providerName(): string;
|
|
790
797
|
get modelName(): string;
|
|
791
798
|
tool: (instance: string, providers: ExuluProvider[], contexts: ExuluContext[], rerankers: ExuluReranker[]) => Promise<ExuluTool | null>;
|
|
792
|
-
generateSync: ({ prompt, req, user, session, inputMessages, approvedTools, currentTools, currentSkills, allExuluTools, statistics, toolConfigs, providerapikey, languageModel, contexts, rerankers, exuluConfig, agent, instructions, maxStepCount, onTokenUsage
|
|
799
|
+
generateSync: ({ prompt, req, user, session, inputMessages, approvedTools, currentTools, currentSkills, allExuluTools, statistics, toolConfigs, providerapikey, languageModel, contexts, rerankers, exuluConfig, agent, instructions, maxStepCount, onTokenUsage }: {
|
|
793
800
|
prompt?: string;
|
|
794
801
|
user?: User;
|
|
795
802
|
maxStepCount?: number;
|