@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.js
CHANGED
|
@@ -53,10 +53,10 @@ import {
|
|
|
53
53
|
vectorSearch,
|
|
54
54
|
waitForLiteLLMReady,
|
|
55
55
|
withRetry
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-IZOD2X2F.js";
|
|
57
57
|
import {
|
|
58
58
|
findLiteLLMModel
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-YCE44CMU.js";
|
|
60
60
|
|
|
61
61
|
// src/index.ts
|
|
62
62
|
import "dotenv/config";
|
|
@@ -504,7 +504,8 @@ var RBACResolver = async (db, entityName, resourceId, rights_mode) => {
|
|
|
504
504
|
return {
|
|
505
505
|
type: "public",
|
|
506
506
|
users: [],
|
|
507
|
-
roles: []
|
|
507
|
+
roles: [],
|
|
508
|
+
teams: []
|
|
508
509
|
};
|
|
509
510
|
}
|
|
510
511
|
const rbacRecords = await db.from("rbac").where({
|
|
@@ -513,13 +514,16 @@ var RBACResolver = async (db, entityName, resourceId, rights_mode) => {
|
|
|
513
514
|
}).select("*");
|
|
514
515
|
const users = rbacRecords.filter((r) => r.access_type === "User")?.map((r) => ({ id: r.user_id, rights: r.rights }));
|
|
515
516
|
const roles = rbacRecords.filter((r) => r.access_type === "Role")?.map((r) => ({ id: r.role_id, rights: r.rights }));
|
|
517
|
+
const teams = rbacRecords.filter((r) => r.access_type === "Team")?.map((r) => ({ id: r.team_id, rights: r.rights }));
|
|
516
518
|
let type = rights_mode || "private";
|
|
517
519
|
if (type === "users" && users.length === 0) type = "private";
|
|
518
520
|
if (type === "roles" && roles.length === 0) type = "private";
|
|
521
|
+
if (type === "teams" && teams.length === 0) type = "private";
|
|
519
522
|
return {
|
|
520
523
|
type,
|
|
521
524
|
users,
|
|
522
|
-
roles
|
|
525
|
+
roles,
|
|
526
|
+
teams
|
|
523
527
|
};
|
|
524
528
|
};
|
|
525
529
|
|
|
@@ -1233,7 +1237,8 @@ var handleRBACUpdate = async (db, entityName, resourceId, rbacData, existingRbac
|
|
|
1233
1237
|
}
|
|
1234
1238
|
const {
|
|
1235
1239
|
users = [],
|
|
1236
|
-
roles = []
|
|
1240
|
+
roles = [],
|
|
1241
|
+
teams = []
|
|
1237
1242
|
/* projects = [] */
|
|
1238
1243
|
} = rbacData;
|
|
1239
1244
|
if (!existingRbacRecords) {
|
|
@@ -1244,20 +1249,28 @@ var handleRBACUpdate = async (db, entityName, resourceId, rbacData, existingRbac
|
|
|
1244
1249
|
}
|
|
1245
1250
|
const newUserRecords = new Set(users.map((u) => `${u.id}:${u.rights}`));
|
|
1246
1251
|
const newRoleRecords = new Set(roles.map((r) => `${r.id}:${r.rights}`));
|
|
1252
|
+
const newTeamRecords = new Set(teams.map((t) => `${t.id}:${t.rights}`));
|
|
1247
1253
|
const existingUserRecords = new Set(
|
|
1248
1254
|
existingRbacRecords.filter((r) => r.access_type === "User").map((r) => `${r.user_id}:${r.rights}`)
|
|
1249
1255
|
);
|
|
1250
1256
|
const existingRoleRecords = new Set(
|
|
1251
1257
|
existingRbacRecords.filter((r) => r.access_type === "Role").map((r) => `${r.role_id}:${r.rights}`)
|
|
1252
1258
|
);
|
|
1259
|
+
const existingTeamRecords = new Set(
|
|
1260
|
+
existingRbacRecords.filter((r) => r.access_type === "Team").map((r) => `${r.team_id}:${r.rights}`)
|
|
1261
|
+
);
|
|
1253
1262
|
const usersToCreate = users.filter((u) => !existingUserRecords.has(`${u.id}:${u.rights}`));
|
|
1254
1263
|
const rolesToCreate = roles.filter((r) => !existingRoleRecords.has(`${r.id}:${r.rights}`));
|
|
1264
|
+
const teamsToCreate = teams.filter((t) => !existingTeamRecords.has(`${t.id}:${t.rights}`));
|
|
1255
1265
|
const usersToRemove = existingRbacRecords.filter(
|
|
1256
1266
|
(r) => r.access_type === "User" && !newUserRecords.has(`${r.user_id}:${r.rights}`)
|
|
1257
1267
|
);
|
|
1258
1268
|
const rolesToRemove = existingRbacRecords.filter(
|
|
1259
1269
|
(r) => r.access_type === "Role" && !newRoleRecords.has(`${r.role_id}:${r.rights}`)
|
|
1260
1270
|
);
|
|
1271
|
+
const teamsToRemove = existingRbacRecords.filter(
|
|
1272
|
+
(r) => r.access_type === "Team" && !newTeamRecords.has(`${r.team_id}:${r.rights}`)
|
|
1273
|
+
);
|
|
1261
1274
|
if (usersToRemove.length > 0) {
|
|
1262
1275
|
await db.from("rbac").whereIn(
|
|
1263
1276
|
"id",
|
|
@@ -1270,6 +1283,12 @@ var handleRBACUpdate = async (db, entityName, resourceId, rbacData, existingRbac
|
|
|
1270
1283
|
rolesToRemove.map((r) => r.id)
|
|
1271
1284
|
).del();
|
|
1272
1285
|
}
|
|
1286
|
+
if (teamsToRemove.length > 0) {
|
|
1287
|
+
await db.from("rbac").whereIn(
|
|
1288
|
+
"id",
|
|
1289
|
+
teamsToRemove.map((r) => r.id)
|
|
1290
|
+
).del();
|
|
1291
|
+
}
|
|
1273
1292
|
const recordsToInsert = [];
|
|
1274
1293
|
usersToCreate.forEach((user) => {
|
|
1275
1294
|
recordsToInsert.push({
|
|
@@ -1293,6 +1312,17 @@ var handleRBACUpdate = async (db, entityName, resourceId, rbacData, existingRbac
|
|
|
1293
1312
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1294
1313
|
});
|
|
1295
1314
|
});
|
|
1315
|
+
teamsToCreate.forEach((team) => {
|
|
1316
|
+
recordsToInsert.push({
|
|
1317
|
+
entity: entityName,
|
|
1318
|
+
access_type: "Team",
|
|
1319
|
+
target_resource_id: resourceId,
|
|
1320
|
+
team_id: team.id,
|
|
1321
|
+
rights: team.rights,
|
|
1322
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1323
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
1324
|
+
});
|
|
1325
|
+
});
|
|
1296
1326
|
if (recordsToInsert.length > 0) {
|
|
1297
1327
|
await db.from("rbac").insert(recordsToInsert);
|
|
1298
1328
|
}
|
|
@@ -1491,6 +1521,19 @@ function createMutations(table, providers, contexts, rerankers, tools, config) {
|
|
|
1491
1521
|
}
|
|
1492
1522
|
throw new Error("Insufficient role permissions to edit this record");
|
|
1493
1523
|
}
|
|
1524
|
+
if (record.rights_mode === "teams" && user.team) {
|
|
1525
|
+
const rbacRecord = await db.from("rbac").where({
|
|
1526
|
+
entity: table.name.singular,
|
|
1527
|
+
target_resource_id: id,
|
|
1528
|
+
access_type: "Team",
|
|
1529
|
+
team_id: user.team,
|
|
1530
|
+
rights: "write"
|
|
1531
|
+
}).first();
|
|
1532
|
+
if (rbacRecord) {
|
|
1533
|
+
return true;
|
|
1534
|
+
}
|
|
1535
|
+
throw new Error("Insufficient team permissions to edit this record");
|
|
1536
|
+
}
|
|
1494
1537
|
throw new Error("Insufficient permissions to edit this record");
|
|
1495
1538
|
} catch (error) {
|
|
1496
1539
|
console.error("Write access validation error:", error);
|
|
@@ -3177,7 +3220,7 @@ var processUiMessagesFlow = async ({
|
|
|
3177
3220
|
modelId: agent.model,
|
|
3178
3221
|
user,
|
|
3179
3222
|
providers,
|
|
3180
|
-
agent
|
|
3223
|
+
agent
|
|
3181
3224
|
});
|
|
3182
3225
|
const providerapikey = resolved.apiKey;
|
|
3183
3226
|
const resolvedLanguageModel = resolved.languageModel;
|
|
@@ -4209,6 +4252,8 @@ type LiteLLMModel {
|
|
|
4209
4252
|
supports_function_calling: Boolean
|
|
4210
4253
|
supports_pdf_input: Boolean
|
|
4211
4254
|
supports_audio_input: Boolean
|
|
4255
|
+
input_cost_per_million_tokens: Float
|
|
4256
|
+
output_cost_per_million_tokens: Float
|
|
4212
4257
|
}
|
|
4213
4258
|
`;
|
|
4214
4259
|
resolvers.Query["agentRateLimitUsage"] = async (_, args, context) => {
|
|
@@ -4264,7 +4309,7 @@ type LiteLLMModel {
|
|
|
4264
4309
|
};
|
|
4265
4310
|
};
|
|
4266
4311
|
resolvers.Query["litellmCatalog"] = async () => {
|
|
4267
|
-
const { fetchLiteLLMCatalog } = await import("./catalog-
|
|
4312
|
+
const { fetchLiteLLMCatalog } = await import("./catalog-TBSPSN2N.js");
|
|
4268
4313
|
return fetchLiteLLMCatalog();
|
|
4269
4314
|
};
|
|
4270
4315
|
resolvers.Query["workflowSchedule"] = async (_, args, context, info) => {
|
|
@@ -5781,7 +5826,7 @@ var ExuluProvider = class {
|
|
|
5781
5826
|
modelId: agent.model,
|
|
5782
5827
|
user,
|
|
5783
5828
|
providers,
|
|
5784
|
-
agent
|
|
5829
|
+
agent
|
|
5785
5830
|
});
|
|
5786
5831
|
const providerapikey = resolved.apiKey;
|
|
5787
5832
|
console.log(
|
|
@@ -7476,7 +7521,7 @@ var registerOpenAIGatewayRoutes = async (app, providers, tools, contexts, config
|
|
|
7476
7521
|
});
|
|
7477
7522
|
return;
|
|
7478
7523
|
}
|
|
7479
|
-
let project =
|
|
7524
|
+
let project = void 0;
|
|
7480
7525
|
if (projectName) {
|
|
7481
7526
|
let projectQuery = db("projects").select("*");
|
|
7482
7527
|
projectQuery = applyAccessControl(projectsSchema3(), projectQuery, user);
|
|
@@ -7499,8 +7544,8 @@ var registerOpenAIGatewayRoutes = async (app, providers, tools, contexts, config
|
|
|
7499
7544
|
modelId: agent.model,
|
|
7500
7545
|
user,
|
|
7501
7546
|
providers,
|
|
7502
|
-
agent
|
|
7503
|
-
project
|
|
7547
|
+
agent,
|
|
7548
|
+
project
|
|
7504
7549
|
});
|
|
7505
7550
|
} catch (err) {
|
|
7506
7551
|
if (err instanceof ResolveModelError) {
|
|
@@ -7672,6 +7717,7 @@ var {
|
|
|
7672
7717
|
rbacSchema,
|
|
7673
7718
|
promptLibrarySchema,
|
|
7674
7719
|
contextPresetsSchema,
|
|
7720
|
+
teamsSchema,
|
|
7675
7721
|
embedderSettingsSchema,
|
|
7676
7722
|
promptFavoritesSchema,
|
|
7677
7723
|
statisticsSchema,
|
|
@@ -7721,6 +7767,7 @@ var createExpressRoutes = async (app, providers, tools, contexts, config, evals,
|
|
|
7721
7767
|
jobResultsSchema(),
|
|
7722
7768
|
promptLibrarySchema(),
|
|
7723
7769
|
contextPresetsSchema(),
|
|
7770
|
+
teamsSchema(),
|
|
7724
7771
|
embedderSettingsSchema(),
|
|
7725
7772
|
promptFavoritesSchema(),
|
|
7726
7773
|
evalRunsSchema(),
|
|
@@ -8107,7 +8154,7 @@ Mood: friendly and intelligent.
|
|
|
8107
8154
|
modelId,
|
|
8108
8155
|
user,
|
|
8109
8156
|
providers,
|
|
8110
|
-
agent
|
|
8157
|
+
agent
|
|
8111
8158
|
});
|
|
8112
8159
|
} catch (err) {
|
|
8113
8160
|
if (err instanceof ResolveModelError) {
|
|
@@ -8368,7 +8415,7 @@ ${customInstructions}` : agent.instructions;
|
|
|
8368
8415
|
modelId: agent.model,
|
|
8369
8416
|
user,
|
|
8370
8417
|
providers,
|
|
8371
|
-
agent
|
|
8418
|
+
agent
|
|
8372
8419
|
});
|
|
8373
8420
|
} catch (err) {
|
|
8374
8421
|
if (err instanceof ResolveModelError) {
|
|
@@ -9180,7 +9227,9 @@ ${style.markdown}` : params.prompt;
|
|
|
9180
9227
|
project_id: project?.id,
|
|
9181
9228
|
user_name: user.email,
|
|
9182
9229
|
role_name: user.role?.name,
|
|
9183
|
-
project_name: project?.name
|
|
9230
|
+
project_name: project?.name,
|
|
9231
|
+
team_id: user.team?.id,
|
|
9232
|
+
team_name: user.team?.name
|
|
9184
9233
|
});
|
|
9185
9234
|
if (tags?.length) {
|
|
9186
9235
|
upstreamHeaders["x-litellm-tags"] = tags.join(",");
|
|
@@ -10217,7 +10266,7 @@ var ExuluMCP = class {
|
|
|
10217
10266
|
modelId: agent.model,
|
|
10218
10267
|
user,
|
|
10219
10268
|
providers: allProviders,
|
|
10220
|
-
agent
|
|
10269
|
+
agent
|
|
10221
10270
|
});
|
|
10222
10271
|
const providerapikey = resolved.apiKey;
|
|
10223
10272
|
if (!isLiteLLMEnabled()) {
|
|
@@ -11449,6 +11498,7 @@ var ExuluEval = class {
|
|
|
11449
11498
|
|
|
11450
11499
|
// src/templates/evals/index.ts
|
|
11451
11500
|
import { z as z4 } from "zod";
|
|
11501
|
+
import { generateText as generateText5, Output as Output2 } from "ai";
|
|
11452
11502
|
var llmAsJudgeEval = () => {
|
|
11453
11503
|
if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
|
|
11454
11504
|
return new ExuluEval({
|
|
@@ -11489,27 +11539,27 @@ var llmAsJudgeEval = () => {
|
|
|
11489
11539
|
const resolved = await resolveModel({
|
|
11490
11540
|
modelId: agent.model,
|
|
11491
11541
|
providers: exuluApp.get().providers,
|
|
11492
|
-
agent
|
|
11542
|
+
agent,
|
|
11493
11543
|
rbacBypass: true
|
|
11494
11544
|
});
|
|
11495
|
-
const providerapikey = resolved.apiKey;
|
|
11496
11545
|
console.log("[EXULU] prompt", prompt);
|
|
11497
|
-
const
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11546
|
+
const { output } = await generateText5({
|
|
11547
|
+
temperature: 0,
|
|
11548
|
+
model: resolved.languageModel,
|
|
11549
|
+
system: "",
|
|
11501
11550
|
prompt,
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11551
|
+
maxRetries: 2,
|
|
11552
|
+
output: Output2.object({
|
|
11553
|
+
schema: z4.object({
|
|
11554
|
+
score: z4.number().min(0).max(100).describe("The score between 0 and 100.")
|
|
11555
|
+
})
|
|
11556
|
+
})
|
|
11507
11557
|
});
|
|
11508
|
-
console.log("[EXULU]
|
|
11509
|
-
const score =
|
|
11558
|
+
console.log("[EXULU] output", output);
|
|
11559
|
+
const score = output.score;
|
|
11510
11560
|
if (isNaN(score)) {
|
|
11511
11561
|
throw new Error(
|
|
11512
|
-
`Generated score from llm as a judge eval is not a number: ${
|
|
11562
|
+
`Generated score from llm as a judge eval is not a number: ${output.score}`
|
|
11513
11563
|
);
|
|
11514
11564
|
}
|
|
11515
11565
|
return score;
|
|
@@ -14634,6 +14684,7 @@ var {
|
|
|
14634
14684
|
agentMessagesSchema: agentMessagesSchema2,
|
|
14635
14685
|
modelsSchema: modelsSchema2,
|
|
14636
14686
|
rolesSchema: rolesSchema2,
|
|
14687
|
+
teamsSchema: teamsSchema2,
|
|
14637
14688
|
usersSchema: usersSchema2,
|
|
14638
14689
|
skillsSchema: skillsSchema2,
|
|
14639
14690
|
statisticsSchema: statisticsSchema2,
|
|
@@ -14676,6 +14727,7 @@ var up = async function(knex) {
|
|
|
14676
14727
|
agentMessagesSchema2(),
|
|
14677
14728
|
modelsSchema2(),
|
|
14678
14729
|
rolesSchema2(),
|
|
14730
|
+
teamsSchema2(),
|
|
14679
14731
|
testCasesSchema2(),
|
|
14680
14732
|
evalSetsSchema2(),
|
|
14681
14733
|
evalRunsSchema2(),
|
|
@@ -15691,7 +15743,7 @@ var MarkdownChunker = class {
|
|
|
15691
15743
|
// ee/python/documents/processing/doc_processor.ts
|
|
15692
15744
|
import * as fs4 from "fs";
|
|
15693
15745
|
import * as path from "path";
|
|
15694
|
-
import { generateText as
|
|
15746
|
+
import { generateText as generateText6, Output as Output3 } from "ai";
|
|
15695
15747
|
import { z as z12 } from "zod";
|
|
15696
15748
|
import pLimit from "p-limit";
|
|
15697
15749
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
@@ -16041,9 +16093,9 @@ If the page contains a flow-chart, schematic, technical drawing or control board
|
|
|
16041
16093
|
|
|
16042
16094
|
### 7. Only populate \`corrected_text\` when \`needs_correction\` is true. If the OCR output is accurate, return \`needs_correction: false\` and \`corrected_content: null\`.
|
|
16043
16095
|
`;
|
|
16044
|
-
const result = await
|
|
16096
|
+
const result = await generateText6({
|
|
16045
16097
|
model,
|
|
16046
|
-
output:
|
|
16098
|
+
output: Output3.object({
|
|
16047
16099
|
schema: z12.object({
|
|
16048
16100
|
needs_correction: z12.boolean(),
|
|
16049
16101
|
corrected_text: z12.string().nullable(),
|
package/ee/rbac-resolver.ts
CHANGED
|
@@ -9,6 +9,7 @@ export const RBACResolver = async (
|
|
|
9
9
|
type: string;
|
|
10
10
|
users: any[];
|
|
11
11
|
roles: any[];
|
|
12
|
+
teams: any[];
|
|
12
13
|
}> => {
|
|
13
14
|
|
|
14
15
|
// If RBAC is not available
|
|
@@ -18,7 +19,8 @@ export const RBACResolver = async (
|
|
|
18
19
|
return {
|
|
19
20
|
type: "public",
|
|
20
21
|
users: [],
|
|
21
|
-
roles: []
|
|
22
|
+
roles: [],
|
|
23
|
+
teams: []
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
// Get RBAC records for this resource
|
|
@@ -38,14 +40,20 @@ export const RBACResolver = async (
|
|
|
38
40
|
.filter((r) => r.access_type === "Role")
|
|
39
41
|
?.map((r) => ({ id: r.role_id, rights: r.rights }));
|
|
40
42
|
|
|
43
|
+
const teams = rbacRecords
|
|
44
|
+
.filter((r) => r.access_type === "Team")
|
|
45
|
+
?.map((r) => ({ id: r.team_id, rights: r.rights }));
|
|
46
|
+
|
|
41
47
|
// Determine the type based on rights_mode or presence of records
|
|
42
48
|
let type = rights_mode || "private";
|
|
43
49
|
if (type === "users" && users.length === 0) type = "private";
|
|
44
50
|
if (type === "roles" && roles.length === 0) type = "private";
|
|
51
|
+
if (type === "teams" && teams.length === 0) type = "private";
|
|
45
52
|
|
|
46
53
|
return {
|
|
47
54
|
type,
|
|
48
55
|
users,
|
|
49
56
|
roles,
|
|
57
|
+
teams,
|
|
50
58
|
};
|
|
51
59
|
};
|
package/ee/rbac-update.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const handleRBACUpdate = async (
|
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const { users = [], roles = [] /* projects = [] */ } = rbacData;
|
|
18
|
+
const { users = [], roles = [], teams = [] /* projects = [] */ } = rbacData;
|
|
19
19
|
|
|
20
20
|
// Get existing RBAC records if not provided
|
|
21
21
|
if (!existingRbacRecords) {
|
|
@@ -31,6 +31,7 @@ export const handleRBACUpdate = async (
|
|
|
31
31
|
// Create sets for comparison
|
|
32
32
|
const newUserRecords = new Set(users.map((u: any) => `${u.id}:${u.rights}`));
|
|
33
33
|
const newRoleRecords = new Set(roles.map((r: any) => `${r.id}:${r.rights}`));
|
|
34
|
+
const newTeamRecords = new Set(teams.map((t: any) => `${t.id}:${t.rights}`));
|
|
34
35
|
// const newProjectRecords = new Set(projects.map((p: any) => `${p.id}:${p.rights}`));
|
|
35
36
|
const existingUserRecords = new Set(
|
|
36
37
|
existingRbacRecords
|
|
@@ -42,10 +43,16 @@ export const handleRBACUpdate = async (
|
|
|
42
43
|
.filter((r) => r.access_type === "Role")
|
|
43
44
|
.map((r) => `${r.role_id}:${r.rights}`),
|
|
44
45
|
);
|
|
46
|
+
const existingTeamRecords = new Set(
|
|
47
|
+
existingRbacRecords
|
|
48
|
+
.filter((r) => r.access_type === "Team")
|
|
49
|
+
.map((r) => `${r.team_id}:${r.rights}`),
|
|
50
|
+
);
|
|
45
51
|
|
|
46
52
|
// Records to create
|
|
47
53
|
const usersToCreate = users.filter((u: any) => !existingUserRecords.has(`${u.id}:${u.rights}`));
|
|
48
54
|
const rolesToCreate = roles.filter((r: any) => !existingRoleRecords.has(`${r.id}:${r.rights}`));
|
|
55
|
+
const teamsToCreate = teams.filter((t: any) => !existingTeamRecords.has(`${t.id}:${t.rights}`));
|
|
49
56
|
// const projectsToCreate = projects.filter((p: any) => !existingProjectRecords.has(`${p.id}:${p.rights}`));
|
|
50
57
|
|
|
51
58
|
// Records to remove
|
|
@@ -55,6 +62,9 @@ export const handleRBACUpdate = async (
|
|
|
55
62
|
const rolesToRemove = existingRbacRecords.filter(
|
|
56
63
|
(r) => r.access_type === "Role" && !newRoleRecords.has(`${r.role_id}:${r.rights}`),
|
|
57
64
|
);
|
|
65
|
+
const teamsToRemove = existingRbacRecords.filter(
|
|
66
|
+
(r) => r.access_type === "Team" && !newTeamRecords.has(`${r.team_id}:${r.rights}`),
|
|
67
|
+
);
|
|
58
68
|
// const projectsToRemove = existingRbacRecords
|
|
59
69
|
// .filter(r => r.access_type === 'Project' && !newProjectRecords.has(`${r.project_id}:${r.rights}`));
|
|
60
70
|
|
|
@@ -77,6 +87,15 @@ export const handleRBACUpdate = async (
|
|
|
77
87
|
)
|
|
78
88
|
.del();
|
|
79
89
|
}
|
|
90
|
+
if (teamsToRemove.length > 0) {
|
|
91
|
+
await db
|
|
92
|
+
.from("rbac")
|
|
93
|
+
.whereIn(
|
|
94
|
+
"id",
|
|
95
|
+
teamsToRemove.map((r) => r.id),
|
|
96
|
+
)
|
|
97
|
+
.del();
|
|
98
|
+
}
|
|
80
99
|
|
|
81
100
|
// Create new records
|
|
82
101
|
const recordsToInsert: any[] = [];
|
|
@@ -105,6 +124,18 @@ export const handleRBACUpdate = async (
|
|
|
105
124
|
});
|
|
106
125
|
});
|
|
107
126
|
|
|
127
|
+
teamsToCreate.forEach((team: any) => {
|
|
128
|
+
recordsToInsert.push({
|
|
129
|
+
entity: entityName,
|
|
130
|
+
access_type: "Team",
|
|
131
|
+
target_resource_id: resourceId,
|
|
132
|
+
team_id: team.id,
|
|
133
|
+
rights: team.rights,
|
|
134
|
+
createdAt: new Date(),
|
|
135
|
+
updatedAt: new Date(),
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
108
139
|
if (recordsToInsert.length > 0) {
|
|
109
140
|
await db.from("rbac").insert(recordsToInsert);
|
|
110
141
|
}
|
package/ee/schemas.ts
CHANGED
|
@@ -76,6 +76,27 @@ export const rolesSchema: ExuluTableDefinition = {
|
|
|
76
76
|
],
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
export const teamsSchema: ExuluTableDefinition = {
|
|
80
|
+
type: "teams",
|
|
81
|
+
name: {
|
|
82
|
+
plural: "teams",
|
|
83
|
+
singular: "team",
|
|
84
|
+
},
|
|
85
|
+
fields: [
|
|
86
|
+
{
|
|
87
|
+
name: "name",
|
|
88
|
+
type: "text",
|
|
89
|
+
index: true,
|
|
90
|
+
unique: true,
|
|
91
|
+
required: true,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "description",
|
|
95
|
+
type: "text",
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
|
|
79
100
|
export const statisticsSchema: ExuluTableDefinition = {
|
|
80
101
|
type: "tracking",
|
|
81
102
|
name: {
|
|
@@ -301,6 +322,10 @@ export const rbacSchema: ExuluTableDefinition = {
|
|
|
301
322
|
name: "role_id",
|
|
302
323
|
type: "uuid",
|
|
303
324
|
},
|
|
325
|
+
{
|
|
326
|
+
name: "team_id",
|
|
327
|
+
type: "uuid",
|
|
328
|
+
},
|
|
304
329
|
{
|
|
305
330
|
name: "user_id",
|
|
306
331
|
type: "number",
|
package/ee/workers.ts
CHANGED
|
@@ -1390,7 +1390,7 @@ export const processUiMessagesFlow = async ({
|
|
|
1390
1390
|
modelId: agent.model,
|
|
1391
1391
|
user,
|
|
1392
1392
|
providers,
|
|
1393
|
-
agent:
|
|
1393
|
+
agent: agent
|
|
1394
1394
|
});
|
|
1395
1395
|
const providerapikey = resolved.apiKey;
|
|
1396
1396
|
const resolvedLanguageModel = resolved.languageModel;
|