Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Devin: find the terminal sign-in in the data folder as well as the config folder (#6062)

Milind Soni8a11af818e97
diff --git a/server/drivers/acp/devin.test.ts b/server/drivers/acp/devin.test.ts
index 8d4c951827..cbcd7277be 100644
--- a/server/drivers/acp/devin.test.ts
+++ b/server/drivers/acp/devin.test.ts
@@ -9,7 +9,7 @@ import type { ProviderInstance } from "../../contracts.ts";
import { recordEvents, type EventRecorder } from "../../testing/events.ts";
import { removeTempDir } from "../../testing/cleanup.ts";
import { BUILT_IN_DRIVERS } from "../builtIn.ts";
-import { classifyDevinError, DevinAgentDriver, devinConfigDir, devinPermissionRequest, devinSignedIn, resolveDevinModels } from "./devin.ts";
+import { classifyDevinError, DevinAgentDriver, devinCredentialsFiles, devinPermissionRequest, devinSignedIn, resolveDevinModels } from "./devin.ts";
const FAKE_CLI = join(dirname(fileURLToPath(import.meta.url)), "../../testing/fake-acp-cli.ts");
const MODELS = "swe-1-6-fast,claude-sonnet-5-5";
@@ -24,25 +24,85 @@ describe("Devin sign-in", () => {
await removeTempDir(scratch);
});
- it("looks for Devin's config in %APPDATA% on Windows and ~/.config elsewhere", () => {
+ it("looks for the sign-in in %APPDATA% on Windows, and in the XDG data and config folders elsewhere", () => {
const home = join(scratch, "home");
- expect(devinConfigDir({ HOME: home }, "linux")).toBe(join(home, ".config", "devin"));
- expect(devinConfigDir({ HOME: home }, "darwin")).toBe(join(home, ".config", "devin"));
- expect(devinConfigDir({ HOME: home, XDG_CONFIG_HOME: join(scratch, "cfg") }, "linux")).toBe(join(scratch, "cfg", "devin"));
- expect(devinConfigDir({ USERPROFILE: home, APPDATA: join(scratch, "roaming") }, "win32")).toBe(join(scratch, "roaming", "devin"));
+ const data = join(home, ".local", "share", "devin", "credentials.toml");
+ const config = join(home, ".config", "devin", "credentials.toml");
+ expect(devinCredentialsFiles({ HOME: home }, "linux")).toEqual([data, config]);
+ expect(devinCredentialsFiles({ HOME: home }, "darwin")).toEqual([data, config]);
+ expect(devinCredentialsFiles({ HOME: home, XDG_DATA_HOME: join(scratch, "data") }, "linux"))
+ .toEqual([join(scratch, "data", "devin", "credentials.toml"), config]);
+ expect(devinCredentialsFiles({ HOME: home, XDG_CONFIG_HOME: join(scratch, "cfg") }, "darwin"))
+ .toEqual([data, join(scratch, "cfg", "devin", "credentials.toml")]);
+ expect(devinCredentialsFiles({ HOME: home, XDG_DATA_HOME: " ", XDG_CONFIG_HOME: "" }, "linux")).toEqual([data, config]);
+ expect(devinCredentialsFiles({ USERPROFILE: home, APPDATA: join(scratch, "roaming") }, "win32"))
+ .toEqual([join(scratch, "roaming", "devin", "credentials.toml")]);
+ expect(devinCredentialsFiles({ USERPROFILE: home }, "win32")).toEqual([join(home, "AppData", "Roaming", "devin", "credentials.toml")]);
});
- it("is signed in by the credentials `devin auth login` stored, or by WINDSURF_API_KEY", () => {
+ it("is signed in by WINDSURF_API_KEY", () => {
const home = join(scratch, "home");
expect(devinSignedIn({ HOME: home }, "linux")).toBe(false);
expect(devinSignedIn({ HOME: home, WINDSURF_API_KEY: " " }, "linux")).toBe(false);
expect(devinSignedIn({ HOME: home, WINDSURF_API_KEY: "fixture-key" }, "linux")).toBe(true);
- const dir = devinConfigDir({ HOME: home }, "linux");
- mkdirSync(dir, { recursive: true });
- writeFileSync(join(dir, "config.json"), "{}");
+ });
+
+ const signIn = (dir: string) => {
+ mkdirSync(join(dir, "devin"), { recursive: true });
+ writeFileSync(join(dir, "devin", "credentials.toml"), "token = \"fixture\"\n");
+ };
+
+ it.each(["linux", "darwin"] as const)("is signed in on %s by credentials in the data folder alone", (platform) => {
+ const home = join(scratch, "home");
+ expect(devinSignedIn({ HOME: home }, platform)).toBe(false);
+ signIn(join(home, ".local", "share"));
+ expect(existsSync(join(home, ".config"))).toBe(false);
+ expect(devinSignedIn({ HOME: home }, platform)).toBe(true);
+ });
+
+ it.each(["linux", "darwin"] as const)("is signed in on %s by credentials in the config folder alone", (platform) => {
+ const home = join(scratch, "home");
+ expect(devinSignedIn({ HOME: home }, platform)).toBe(false);
+ signIn(join(home, ".config"));
+ expect(existsSync(join(home, ".local"))).toBe(false);
+ expect(devinSignedIn({ HOME: home }, platform)).toBe(true);
+ });
+
+ it("follows XDG_DATA_HOME to the credentials", () => {
+ const home = join(scratch, "home");
+ const env = { HOME: home, XDG_DATA_HOME: join(scratch, "data") };
+ signIn(join(home, ".local", "share"));
+ expect(devinSignedIn(env, "linux")).toBe(false);
+ signIn(join(scratch, "data"));
+ expect(devinSignedIn(env, "linux")).toBe(true);
+ });
+
+ it("follows XDG_CONFIG_HOME to the credentials", () => {
+ const home = join(scratch, "home");
+ const env = { HOME: home, XDG_CONFIG_HOME: join(scratch, "cfg") };
+ signIn(join(home, ".config"));
+ expect(devinSignedIn(env, "linux")).toBe(false);
+ signIn(join(scratch, "cfg"));
+ expect(devinSignedIn(env, "linux")).toBe(true);
+ });
+
+ it("does not read Devin's config folder, present before any sign-in, as one", () => {
+ const home = join(scratch, "home");
+ const config = join(home, ".config", "devin");
+ mkdirSync(config, { recursive: true });
+ writeFileSync(join(config, "config.json"), "{}");
expect(devinSignedIn({ HOME: home }, "linux")).toBe(false);
- writeFileSync(join(dir, "credentials.toml"), "token = \"fixture\"\n");
- expect(devinSignedIn({ HOME: home }, "linux")).toBe(true);
+ expect(devinSignedIn({ HOME: home }, "darwin")).toBe(false);
+ });
+
+ it("finds a Windows sign-in under %APPDATA% only", () => {
+ const home = join(scratch, "home");
+ const roaming = join(scratch, "roaming");
+ signIn(join(home, ".local", "share"));
+ signIn(join(home, ".config"));
+ expect(devinSignedIn({ USERPROFILE: home, APPDATA: roaming }, "win32")).toBe(false);
+ signIn(roaming);
+ expect(devinSignedIn({ USERPROFILE: home, APPDATA: roaming }, "win32")).toBe(true);
});
it("reads Devin's signed-out prompt refusal as a missing login, and nothing else", () => {
diff --git a/server/drivers/acp/devin.ts b/server/drivers/acp/devin.ts
index a9fa797e18..464311b8ed 100644
--- a/server/drivers/acp/devin.ts
+++ b/server/drivers/acp/devin.ts
@@ -25,15 +25,21 @@ const API_KEY_ENV = "WINDSURF_API_KEY";
const LOGIN_NOTE = `Devin is not signed in. Run ${SIGN_IN} in a terminal, or set ${API_KEY_ENV}, then check again.`;
export const DEVIN_MODE = { ask: "accept-edits", full: "bypass" } as const;
-/** Devin keeps its user config in `%APPDATA%\devin` on Windows and `~/.config/devin` elsewhere. */
-export function devinConfigDir(env: Record<string, string | undefined>, platform: NodeJS.Platform = process.platform): string {
- if (platform === "win32") return join(env.APPDATA?.trim() || join(userHome(env), "AppData", "Roaming"), "devin");
- return join(env.XDG_CONFIG_HOME?.trim() || join(userHome(env), ".config"), "devin");
+/** Where `devin auth login` may have stored the sign-in. On Windows, `%APPDATA%\devin`. Elsewhere two folders are
+ * accepted: the XDG data folder Devin's documentation names (docs.devin.ai/cli/enterprise/devin-auth), `$XDG_DATA_HOME/devin`
+ * or `~/.local/share/devin`; and the XDG config folder, `$XDG_CONFIG_HOME/devin` or `~/.config/devin`, which this driver
+ * read when it was checked against devin 3000.12.57 and 3000.12.59. */
+export function devinCredentialsFiles(env: Record<string, string | undefined>, platform: NodeJS.Platform = process.platform): string[] {
+ const home = userHome(env);
+ const dirs = platform === "win32"
+ ? [env.APPDATA?.trim() || join(home, "AppData", "Roaming")]
+ : [env.XDG_DATA_HOME?.trim() || join(home, ".local", "share"), env.XDG_CONFIG_HOME?.trim() || join(home, ".config")];
+ return dirs.map((dir) => join(dir, "devin", "credentials.toml"));
}
/** Signed in by WINDSURF_API_KEY, or by the `credentials.toml` that `devin auth login` writes. */
export function devinSignedIn(env: Record<string, string | undefined>, platform: NodeJS.Platform = process.platform): boolean {
- return Boolean(env[API_KEY_ENV]?.trim()) || existsSync(join(devinConfigDir(env, platform), "credentials.toml"));
+ return Boolean(env[API_KEY_ENV]?.trim()) || devinCredentialsFiles(env, platform).some((file) => existsSync(file));
}
/** No exit grace: devin 3000.12.57 exits on EOF but orphans the MCP servers it started from its own config, which then