Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(1password): item choices reach My Cloud before the token; say when a token can't be taken off again; Settings scale + pt-BR strings (#4954)
Bugfixer 26b1759f464ea
diff --git a/electron/cloud-send.mjs b/electron/cloud-send.mjsindex 700560245a..f92a13ba17 100644--- a/electron/cloud-send.mjs+++ b/electron/cloud-send.mjs@@ -899,6 +899,15 @@ export function createCloudSend({ local, cloud, handoff, store, onChange = () =>if (!record(onePassword) || typeof onePassword.token !== "string") throw new CloudSendError("local", "1Password is not connected on this computer.");const parts = row.parts ?? ["token", "vaults"];const connecting = row.state === "only-here" || parts.includes("token");+ // My Cloud's item choices become this computer's, so one handed back to its vault here is handed back there too.+ // They go ahead of the token, so no item is readable there under its vault's wider choice even for a moment.+ const items = Object.fromEntries(Object.entries(onePassword.itemGrants ?? {}).filter(([item]) => ITEM_KEY.test(item))+ .map(([item, bots]) => [item, botsOnCloud(bots, ctx.cloudBots)]));+ const itemsKept = await ctx.session.call("PUT", "/api/logins/1password/items", { items });+ // A Cloud too old for item choices has none to undo, but an item narrowed here must not open to every bot there.+ if (!itemsKept.ok && !(itemsKept.status === 405 && !Object.keys(items).length)) {+ throw refusedError("refused", itemsKept, "My Cloud could not keep its 1Password logins to the same bots. Update My Cloud and send again.");+ }if (connecting) {const connected = await ctx.session.call("POST", "/api/logins/1password", { token: onePassword.token });if (!connected.ok) throw onePasswordRefusal(connected);@@ -909,17 +918,14 @@ export function createCloudSend({ local, cloud, handoff, store, onChange = () =>const granted = await ctx.session.call("PATCH", `/api/logins/1password/vaults/${encodeURIComponent(vault)}`, { bots: botsOnCloud(bots, ctx.cloudBots) });if (!granted.ok && granted.status !== 404) throw refusedError("refused", granted, "My Cloud connected 1Password but could not keep its vaults to the same bots.");}- // My Cloud's item choices become this computer's, so one handed back to its vault here is handed back there too.- const items = Object.fromEntries(Object.entries(onePassword.itemGrants ?? {}).filter(([item]) => ITEM_KEY.test(item))- .map(([item, bots]) => [item, botsOnCloud(bots, ctx.cloudBots)]));- const granted = await ctx.session.call("PUT", "/api/logins/1password/items", { items });- // A Cloud too old for item choices has none to undo, but an item narrowed here must not open to every bot there.- if (!granted.ok && !(granted.status === 405 && !Object.keys(items).length)) {- throw refusedError("refused", granted, "My Cloud connected 1Password but could not keep its logins to the same bots. Update My Cloud and send again.");- }} catch (error) {// Fail closed: a token this send connected is taken off again rather than left open wider than here.- if (connecting) await ctx.session.call("DELETE", "/api/logins/1password").catch(() => {});+ if (connecting) {+ const removed = await ctx.session.call("DELETE", "/api/logins/1password").catch(() => null);+ if (!removed?.ok) {+ throw new CloudSendError("refused", "My Cloud connected 1Password but could not keep its vaults to the same bots, nor disconnect it again. Disconnect 1Password in My Cloud's settings, then send again.", { cause: error });+ }+ }throw error;}done(ctx, row.key);diff --git a/electron/cloud-send.node-test.mjs b/electron/cloud-send.node-test.mjsindex 7d37e7f00a..86f088c7a1 100644--- a/electron/cloud-send.node-test.mjs+++ b/electron/cloud-send.node-test.mjs@@ -92,7 +92,8 @@ function fakeSides({ cloudItems = [], localItems = [], refuse = {} } = {}) {calls.push(`${method} ${route}`);bodies[`${method} ${route}`] = body;if (route === "/api/cloud-send" || route === "/api/cloud-send?move=1") return reply(200, summary(cloudItems));- if (refuse[route]) return reply(refuse[route].status, { error: refuse[route].error });+ const refused = refuse[`${method} ${route}`] ?? refuse[route];+ if (refused) return reply(refused.status, { error: refused.error });return reply(200, {});},upload: async (route) => { calls.push(`UPLOAD ${route}`); return reply(201, { path: "/data/attachments/abc.png" }); },@@ -411,7 +412,7 @@ test("1Password items with bots of their own keep them on My Cloud; a Cloud tooold.deps.handoff = async () => ({ onePassword: { token: "ops_fake", grants: {}, itemGrants: { "v1:i1": [] } } });const refused = await createCloudSend(old.deps).send();assert.deepEqual(refused.result.failed.map((entry) => entry.key), ["1password"], "never left open to every bot there");- assert.ok(old.calls.includes("DELETE /api/logins/1password"), "the token this send connected is taken off again");+ assert.ok(!old.calls.includes("POST /api/logins/1password"), "a refused item choice never connects the token");const plain = fakeSides({ localItems: [onePassword], refuse: items });plain.deps.handoff = async () => ({ onePassword: { token: "ops_fake", grants: {} } });assert.equal((await createCloudSend(plain.deps).send()).result.failed.length, 0, "a Cloud too old for item choices takes a vault-only 1Password");@@ -420,6 +421,13 @@ test("1Password items with bots of their own keep them on My Cloud; a Cloud toovaults.deps.handoff = async () => ({ onePassword: { token: "ops_fake", grants: { v1: [] } } });assert.equal((await createCloudSend(vaults.deps).send()).result.failed.length, 1);assert.ok(vaults.calls.includes("DELETE /api/logins/1password"), "a vault choice that did not take closes the token too");+ // Item choices are in place there before the token is.+ assert.ok(sides.calls.indexOf("PUT /api/logins/1password/items") < sides.calls.indexOf("POST /api/logins/1password"));+ const stuck = fakeSides({ localItems: [onePassword], refuse: { "/api/logins/1password/vaults/v1": { status: 500, error: "boom" }, "DELETE /api/logins/1password": { status: 500, error: "down" } } });+ stuck.deps.handoff = async () => ({ onePassword: { token: "ops_fake", grants: { v1: [] } } });+ const left = (await createCloudSend(stuck.deps).send()).result.failed;+ assert.equal(left.length, 1);+ assert.match(JSON.stringify(left[0]), /Disconnect 1Password/, "a token that could not be taken off again is said out loud");});test("chats by row: the cursor moves only past what My Cloud took; one removed there is never sent again; one being answered waits", async () => {diff --git a/src/components/VaultSettings.tsx b/src/components/VaultSettings.tsxindex 4d2b7d1843..7c8b268198 100644--- a/src/components/VaultSettings.tsx+++ b/src/components/VaultSettings.tsx@@ -321,7 +321,7 @@ function OnePasswordItemAccess({ item, value: initial, bots, onCancel, onSaved }return (<div className="ms-6 flex flex-col gap-2 rounded-lg bg-inset/60 p-3" data-onepassword-item={item.item}><LoginBotPicker value={value} onChange={setValue} bots={bots} disabled={busy} />- <p className="text-[12px] leading-snug text-ink-tertiary">{t("settings.logins.onePassword.itemNote")}</p>+ <p className="text-[12px] text-ink-tertiary">{t("settings.logins.onePassword.itemNote")}</p>{error && <p role="alert" className="text-[12px] text-danger">{error}</p>}<div className="flex flex-wrap justify-end gap-2">{item.ownBots && (diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex c0b918a2a6..a8d16e3332 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -3669,6 +3669,10 @@"settings.logins.onePassword.vaults": "Cofres do 1Password","settings.logins.onePassword.vaultUse": "Logins: {count} · {who}","settings.logins.onePassword.changeVault": "Alterar quem pode usar {vault}",+ "settings.logins.onePassword.changeItem": "Alterar quem pode usar {name}",+ "settings.logins.onePassword.vaultChoice": "{who} (escolha do cofre)",+ "settings.logins.onePassword.itemNote": "Esta escolha vale só para este item do 1Password, antes da escolha do cofre. Ela continua quando a escolha do cofre muda.",+ "settings.logins.onePassword.useVaultChoice": "Usar a escolha do cofre","settings.logins.onePassword.error": "Não foi possível acessar o 1Password. Confira a conexão com a internet e o token e tente novamente.","settings.logins.onePassword.note": "O token é criptografado no computador onde o app {app} roda e nunca mais é exibido. Os logins do 1Password aparecem na lista acima e são preenchidos da mesma forma. Edite-os no 1Password. Um cofre fica disponível para todos os bots, a menos que você escolha quais podem usá-lo.","settings.logins.cloudOwn": "Estes são os logins do próprio Cloud. Os logins do seu computador vêm automaticamente quando o app {app} instalado nele move os bots para cá.",diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.jsonindex aefdc23670..c29dad6134 100644--- a/src/locales/source-hashes.json+++ b/src/locales/source-hashes.json@@ -36470,7 +36470,11 @@"settings.domain.httpsFirst": "41486ac1d5f39e25ccf3835d520137ecac15a0f49a9dcb5b73f7523fe6df330f","settings.backTo": "ea37ec29c3865c359d3efb005bd252c35457976140bb718824f39d157ea32567","devices.route.httpsAccount": "518ed79b3110cf735bc507bd796cf5c9cd701c3b2dc72bd764e599d411e3baf5",- "backup.importAction": "ea94509e38cf6d6427db3a1b5a3b5816cba1e8f89b08f9739f6077ade188163c"+ "backup.importAction": "ea94509e38cf6d6427db3a1b5a3b5816cba1e8f89b08f9739f6077ade188163c",+ "settings.logins.onePassword.changeItem": "95e5d6046e9d25e73ce6f33a97f95108c2c3027ebb01c08a94739467135ff468",+ "settings.logins.onePassword.vaultChoice": "79ecc022e82d6ad96c1f0f82806170d3a0e69d331ac91851a0dd8d6c806c503b",+ "settings.logins.onePassword.itemNote": "eee14017812e91c3b664d8e16e51132ae281c22c00810c0da99fd732bb3ae486",+ "settings.logins.onePassword.useVaultChoice": "a14647f6e4b5a8dbbb97d8fbd70814f8d93c2debf7c85fade4e8988fb4bf31ee"},"zh": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",