Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Templates: accept a catalog of up to 1000 templates

aivsomkar96795bf64aff
diff --git a/server/team-library.test.ts b/server/team-library.test.ts
index ec2dca6d77..dfea85e42b 100644
--- a/server/team-library.test.ts
+++ b/server/team-library.test.ts
@@ -65,6 +65,15 @@ describe("team library", () => {
expect(() => parseTeamCatalog(unsafe)).toThrow("safe catalog path");
});
+ it("accepts a catalog of hundreds of published templates", () => {
+ const entry = catalog.teams[0]!;
+ const teams = Array.from({ length: 500 }, (_, index) => {
+ const slug = `bot-${index}`;
+ return { ...entry, slug, manifest: `teams/${slug}/team.mausteam.json`, readme: `teams/${slug}/README.md`, skills: [] };
+ });
+ expect(parseTeamCatalog({ ...catalog, teams }).teams).toHaveLength(500);
+ });
+
it("loads only the manifest selected by the trusted catalog", async () => {
const fetcher = vi.fn(async (url: string | URL | Request) => {
const target = String(url);
diff --git a/server/team-library.ts b/server/team-library.ts
index 5f900f403b..703af9fdb0 100644
--- a/server/team-library.ts
+++ b/server/team-library.ts
@@ -8,7 +8,8 @@ export const TEAM_LIBRARY_REPOSITORY = "https://github.com/milind-soni/openmausb
export const TEAM_LIBRARY_RAW_ROOT = "https://raw.githubusercontent.com/milind-soni/openmausbot-teams/main";
export const TEAM_LIBRARY_CATALOG_URL = `${TEAM_LIBRARY_RAW_ROOT}/catalog.json`;
-const MAX_CATALOG_BYTES = 256_000;
+// Templates published from MausBot are merged into the catalog automatically, so it grows by several a day.
+const MAX_CATALOG_BYTES = 2_000_000, MAX_CATALOG_TEAMS = 1000;
const MAX_MANIFEST_BYTES = 1_000_000;
export interface TeamCatalogEntry {
@@ -72,7 +73,7 @@ export function parseTeamCatalog(value: unknown): TeamCatalog {
if (!isRecord(value) || value.format !== "openmaus.catalog" || value.version !== 1) {
throw new Error("The team library catalog is not supported");
}
- if (!Array.isArray(value.teams) || value.teams.length > 100) {
+ if (!Array.isArray(value.teams) || value.teams.length > MAX_CATALOG_TEAMS) {
throw new Error("The team library catalog is invalid");
}
const slugs = new Set<string>();