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<String, String>, 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=<scratch> 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).
This commit is contained in:
A. S.
2026-10-26 15:56:45 +08:00
committed by GitHub
parent 07e643018e
commit 5068cc3219
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -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')
+4 -1
View File
@@ -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 }