Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(1password): keep website logins and secrets ahead of no-website Logins in the item limit
AdityaUmale24603f371292
diff --git a/server/onepassword.test.ts b/server/onepassword.test.tsindex 78494d35d0..9ede0d8478 100644--- a/server/onepassword.test.ts+++ b/server/onepassword.test.ts@@ -82,7 +82,7 @@ describe("1Password logins", () => {{ id: "v2", title: "Finance", items: 1, bots: "all" },{ id: "v1", title: "Shared with OMB", items: 2, bots: "all" },] });- expect(calls).toEqual(["createClient OpenMausBot", "vaults.list", "items.list v2", "items.getAll v2 f1", "items.list v1", "items.getAll v1 i1,i2,i3,i4,i5,i6,i7,i8,i10,i11"]);+ expect(calls).toEqual(["createClient OpenMausBot", "vaults.list", "items.list v2", "items.getAll v2 f1", "items.list v1", "items.getAll v1 i1,i2,i4,i5,i6,i7,i8,i11,i3,i10"]);const rows = source.list();expect(rows.map((row) => [row.site, row.hosts, row.username, row.hasTotp, row.source, row.bots])).toEqual([["example.com", ["accounts.example.com"], "[email protected]", true, "1password", "all"],@@ -274,6 +274,16 @@ describe("1Password secrets", () => {expect(source.list().map((row) => row.site)).not.toContain("");});+ it("never lets Logins without a website push a website login out of the item limit", async () => {+ const noSite = Array.from({ length: 500 }, (_, n) => ({ id: `n${n}`, title: `No site ${n}`, urls: [], username: "x", password: "fake-x-pass" }));+ const { sdk } = fakeOnePasswordSdk({ token: TOKEN, vaults: { v1: { title: "Big", items: [+ ...noSite, { id: "w1", title: "Website", urls: ["https://late.example.com"], username: "late", password: "fake-late-pass" },+ ] } } });+ const source = new OnePasswordLogins({ token: () => TOKEN, grants: () => ({}), connect: (value) => sdkOnePasswordClient(sdk, value, "9.9.9") });+ expect((await source.refresh()).items).toBe(1);+ expect(source.list().map((row) => row.site)).toEqual(["example.com"]);+ });+it("says plainly when a secret left 1Password, and when 1Password can't be read", async () => {let failure: Error | null = null;const { source } = setup({ fail: () => failure });diff --git a/server/onepassword.ts b/server/onepassword.tsindex bd0b1a29fa..3708680d86 100644--- a/server/onepassword.ts+++ b/server/onepassword.ts@@ -237,7 +237,10 @@ export class OnePasswordLogins implements VaultProvider {const counted: Array<Omit<OnePasswordVault, "bots">> = [];for (const vault of vaults) {let items = 0;- const wanted = (await client.items(vault.id)).filter((item) => item.category === "Login" || SECRET_CATEGORIES.has(item.category)).slice(0, MAX_ITEMS);+ const listed = await client.items(vault.id);+ // Website logins and secret items come first, so Logins without a website never push one out of MAX_ITEMS.+ const wanted = [...listed.filter((item) => isLogin(item) || SECRET_CATEGORIES.has(item.category)),+ ...listed.filter((item) => item.category === "Login" && !isLogin(item))].slice(0, MAX_ITEMS);for (let start = 0; start < wanted.length; start += FIELDS_BATCH) {const batch = wanted.slice(start, start + FIELDS_BATCH);// Every value in this answer is dropped here and read again when a bot uses it.