Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(skills): size the import request budget for a full 100-skill collection
AdityaUmale00f7fd3a4e4a
diff --git a/server/skill-fetch.test.ts b/server/skill-fetch.test.tsindex 083f8df0ce..816ae5e3de 100644--- a/server/skill-fetch.test.ts+++ b/server/skill-fetch.test.ts@@ -369,6 +369,14 @@ describe("skill import budget", () => {expect(peak).toBeLessThanOrEqual(4);});+ it("imports a full collection after walking a full folder of other files first", async () => {+ const entries: Record<string, FakeRepoEntry> = {};+ for (let i = 0; i < 100; i++) entries[`docs/page-${i}/README.md`] = "# Page";+ for (let i = 0; i < MAX_SKILLS_PER_IMPORT; i++) entries[`packs/skill-${i}/SKILL.md`] = SKILL(`skill-${i}`);+ const skills = ok(await fetchSkillFromSource("a/b", fakeGitHub({ "a/b": entries }).fetch));+ expect(skills).toHaveLength(MAX_SKILLS_PER_IMPORT);+ });+it("stops a larger collection at the per-import cap", async () => {const entries: Record<string, FakeRepoEntry> = {};for (let i = 0; i < MAX_SKILLS_PER_IMPORT + 5; i++) entries[`skills/skill-${i}/SKILL.md`] = SKILL(`skill-${i}`);@@ -385,7 +393,7 @@ describe("skill import budget", () => {}) as typeof fetch;const result = await fetchSkillFromSource("a/b", fetcher);expect(result).toEqual({ error: expect.stringContaining("request limit") });- expect(fetcher).toHaveBeenCalledTimes(256);+ expect(fetcher).toHaveBeenCalledTimes(320);});it("stops reading an oversized file before buffering the whole download", async () => {diff --git a/server/skill-fetch.ts b/server/skill-fetch.tsindex 930082fb8d..d43069645f 100644--- a/server/skill-fetch.ts+++ b/server/skill-fetch.ts@@ -11,7 +11,8 @@ const RAW_HOST = "raw.githubusercontent.com";const USER_AGENT = "OpenMausBot-skills";const LISTING_MAX_BYTES = 1_048_576;// GitHub allows 60 API requests an hour without sign-in; downloads from the raw host are not counted against it.-const IMPORT_LIMITS = { apiRequests: 256, downloads: 1_000, bytes: 64 * 1_048_576, ms: 120_000 };+// A full collection takes a listing and a tree per skill, with room left to walk one full folder of other files first.+const IMPORT_LIMITS = { apiRequests: 320, downloads: 1_000, bytes: 64 * 1_048_576, ms: 120_000 };const PARALLEL_DOWNLOADS = 4;class ImportLimitError extends Error {}class GitHubApiError extends Error {}