From 5068cc32193bf12caf55e970ba69ce1919bf7cdb Mon Sep 17 00:00:00 2001 From: "A. S." Date: Mon, 26 Oct 2026 07:56:45 +0000 Subject: [PATCH] devin: the CLI sign-in saves metadata.cli as a string, so OpenCode 1 keeps the account (#396) Devin CLI's sign-in saved metadata.cli as the boolean true. OpenCode 1's auth schema (src/auth Api: metadata Record, v1.19.4) drops an auth.json entry with a non-string metadata value. The account then disappeared and requests went past the plugin's fetch to the placeholder URL, which returned 404. The flag is now the string "true". live() only checks that it is truthy, so entries saved with the boolean (magpie's mover writes one) keep working in magpie. An OpenCode 1 entry already saved with the boolean stays dropped until the account signs in again. Reviewed at 151c72f: - TMPDIR= HOME=$(mktemp -d) bun test in packages/devin: 101 pass, 0 fail. bun scripts/check.mjs devin passes. - Probe: a sandbox XDG_DATA_HOME with a credentials.toml and a stubbed GetUserStatus fetch, then the "Devin CLI's sign-in" method's callback. On main, metadata is {email, plan, cli: true}, and cli is the one non-string value. With the PR, cli is "true" and every value is a string. live() returns the CLI's key in both cases. - Checked that whoOfStatus gives plan, orgId and teamId as strings too. Not tried: a real OpenCode 1 run (the schema was read from the v1.19.4 source). --- packages/devin/cli-key.test.mjs | 2 +- packages/devin/index.mjs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/devin/cli-key.test.mjs b/packages/devin/cli-key.test.mjs index df505f8..37268a5 100644 --- a/packages/devin/cli-key.test.mjs +++ b/packages/devin/cli-key.test.mjs @@ -18,7 +18,7 @@ afterAll(() => { }) test("the CLI's account follows credentials.toml; a browser sign-in stays", async () => { - const cli = { type: "api", key: "saved", metadata: { cli: true, server: "https://s.example" } } + const cli = { type: "api", key: "saved", metadata: { cli: "true", server: "https://s.example" } } expect(await _internal.live(cli)).toEqual({ key: "saved", server: "https://s.example" }) mkdirSync(join(data, "devin")) writeFileSync(join(data, "devin", "credentials.toml"), 'windsurf_api_key = "rotated"\napi_server_url = "https://t.example/"\n') diff --git a/packages/devin/index.mjs b/packages/devin/index.mjs index 3d245a1..3b54fb3 100644 --- a/packages/devin/index.mjs +++ b/packages/devin/index.mjs @@ -985,7 +985,10 @@ async function cliSignIn() { const c = readCredentials(await readFile(path, "utf8")) if (!c.windsurf_api_key) return { type: "failed", error: `Devin isn't signed in: ${path} has no key` } const r = await success(c.windsurf_api_key, (c.api_server_url || SERVER).replace(/\/+$/, "")) - r.metadata.cli = true + // a string: OpenCode 1 keeps an auth's metadata as strings and drops + // an auth.json entry with any other value, so its requests go past + // this fetch to BASE (a 404). live() takes it as truthy. + r.metadata.cli = "true" return r } catch (e) { return { type: "failed", error: e?.code === "ENOENT" ? "Devin isn't signed in: run `devin auth login`" : e.message }