Two Devin organizations under one email both answered GetUserStatus with
the same email, so the plugin saved both sign-ins as the same
metadata.email and magpie's host (settle, which matches on it) put the
second over the first. The account is now named "email · <organization>"
when Devin names an organization (devinInfo.accountDisplayName) that isn't
the email, with orgId and teamId in its metadata. The usage hook brings an
older sign-in's name and ids up to date through client.auth.set, which the
host scopes to that account. `devin auth status`'s Team ID must match
before the CLI is taken to answer for a key. An account with no
organization in its status is left as it was and nothing is written.
Existing users: on the next usage poll, a sign-in whose status names an
organization is renamed "email · <org>" once; its slot, key and plan stay.
metadata.orgId and teamId aren't read by magpie's host today; the slot
split comes from the distinct name. The magpie side (a CLI account's label
overwritten by `devin auth status`) is yetone/magpie#3198.
Run at the reviewed head 7d589ab45323ee46a03af0f4b496c2dc94e67ba4
(base af360a5), on macOS, bun 1.4.2:
- HOME=$(mktemp -d) bun test: 2051 pass, 0 fail; bun scripts/check.mjs ok.
- Red without the change: the two new tests (identity, usage) fail against
main's index.mjs.
- Ad-hoc test (not committed): a status with no organization writes
nothing through auth.set and keeps the name; an organization named as
the email adds no suffix.
- With #297's change on the same tree: 2052 pass, check ok.
Not tried here: real Devin accounts (the author reports two live Devin Max
organizations under one email on Windows 11).
28 lines
1.4 KiB
JavaScript
28 lines
1.4 KiB
JavaScript
// An account taken from the CLI's sign-in uses the key credentials.toml
|
|
// has now, as magpie's built-in re-reads it: a `devin auth login` since
|
|
// changes it. Others keep the key they were saved with.
|
|
import { afterAll, expect, test } from "bun:test"
|
|
import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs"
|
|
import { tmpdir } from "node:os"
|
|
import { join } from "node:path"
|
|
import { _internal } from "./index.mjs"
|
|
|
|
const was = process.env.XDG_DATA_HOME
|
|
const wasAppData = process.env.APPDATA
|
|
const data = mkdtempSync(join(tmpdir(), "devin-data-"))
|
|
process.env.XDG_DATA_HOME = data
|
|
process.env.APPDATA = data
|
|
afterAll(() => {
|
|
was === undefined ? delete process.env.XDG_DATA_HOME : (process.env.XDG_DATA_HOME = was)
|
|
wasAppData === undefined ? delete process.env.APPDATA : (process.env.APPDATA = wasAppData)
|
|
})
|
|
|
|
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" } }
|
|
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')
|
|
expect(await _internal.live(cli)).toEqual({ key: "rotated", server: "https://t.example" })
|
|
expect(await _internal.live({ type: "api", key: "own", metadata: {} })).toMatchObject({ key: "own" })
|
|
})
|