paseo-plugin-account-switcher 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/index.server.ts +12 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +5 -5
- package/server/controller.ts +2 -2
- package/server/integration.ts +25 -2
- package/server/launcher-artifact.ts +1 -1
- package/server/launcher-main.ts +9 -5
- package/server/login.ts +7 -1
package/server/launcher-main.ts
CHANGED
|
@@ -12,14 +12,18 @@ async function finishLogin(exitCode: number): Promise<void> {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async function main(): Promise<void> {
|
|
15
|
-
|
|
16
|
-
const
|
|
15
|
+
// bin/<provider>-launcher, a shell script, runs this bundle (bin/launcher.js) and names the provider first.
|
|
16
|
+
const executable = resolve(process.argv[1]), root = dirname(dirname(executable)), named = process.argv[2];
|
|
17
|
+
const provider = basename(executable) === "launcher.js" && (named === "claude" || named === "codex") ? named : null;
|
|
17
18
|
if (!provider) throw new LauncherError("Unknown account launcher.");
|
|
18
19
|
let registry;
|
|
19
20
|
try { registry = await readRegistry(root); } catch { throw new LauncherError("Account registry is missing or corrupt; launch refused."); }
|
|
20
21
|
const command = registry.commands[provider];
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const launchers = [join(root, "bin", "claude-launcher"), join(root, "bin", "codex-launcher"), join(root, "bin", "launcher.js")];
|
|
23
|
+
if (!command?.[0] || !isAbsolute(command[0]) || command.some(part => isAbsolute(part) && launchers.includes(resolve(part)))) throw new LauncherError("Original provider command is unavailable; launch refused.");
|
|
24
|
+
let args = process.argv.slice(3), env = { ...process.env };
|
|
25
|
+
// Set by the wrapper only to run Paseo's Electron as Node; the provider CLI must not inherit it.
|
|
26
|
+
if (env.ACCOUNT_SWITCHER_ELECTRON) { delete env.ELECTRON_RUN_AS_NODE; delete env.ACCOUNT_SWITCHER_ELECTRON; }
|
|
23
27
|
const login = args[0] === "--account-switcher-login", agentId = env.PASEO_AGENT_ID;
|
|
24
28
|
const binding = agentId ? registry.bindings.find(candidate => candidate.agentId === agentId && candidate.provider === provider) : undefined;
|
|
25
29
|
const accountId = login ? args[1] : binding?.launchAccountId ?? binding?.currentAccountId;
|
|
@@ -70,7 +74,7 @@ async function main(): Promise<void> {
|
|
|
70
74
|
await finishLogin(result.code ?? 1);
|
|
71
75
|
for (const [signal, handler] of forward) process.removeListener(signal, handler);
|
|
72
76
|
if (login && provider === "codex" && result.code !== 0) {
|
|
73
|
-
const quoted = `'${
|
|
77
|
+
const wrapper = join(root, "bin", "codex-launcher"), quoted = `'${wrapper.replace(/'/g, `'\\''`)}'`;
|
|
74
78
|
process.stderr.write(`\nDevice login can require enabling device-code authentication in ChatGPT security settings. For browser login on this host, run:\n${quoted} --account-switcher-login ${account!.id} --browser\n`);
|
|
75
79
|
}
|
|
76
80
|
if (result.signal) { process.kill(process.pid, result.signal); return; }
|
package/server/login.ts
CHANGED
|
@@ -29,6 +29,10 @@ function loginUrl(value: unknown, provider: "claude" | "codex", mode?: "device"
|
|
|
29
29
|
} catch { return null; }
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/** A sign-in refused for a reason written for the user: the dialog shows its message. Any other failure may carry paths
|
|
33
|
+
* or CLI output, so the dialog gets a generic message instead. */
|
|
34
|
+
export class LoginRefusal extends Error { override readonly name = "LoginRefusal"; }
|
|
35
|
+
|
|
32
36
|
export class LoginSessions {
|
|
33
37
|
private readonly entries = new Map<string, Entry>();
|
|
34
38
|
private disposed = false;
|
|
@@ -80,10 +84,12 @@ export class LoginSessions {
|
|
|
80
84
|
clientInfo: { name: "paseo_account_switcher", title: "Paseo Account Switcher", version: "0.1.0" }, capabilities: null,
|
|
81
85
|
} }) + "\n");
|
|
82
86
|
return structuredClone(entry.value);
|
|
83
|
-
} catch {
|
|
87
|
+
} catch (error) {
|
|
84
88
|
clearTimeout(entry.timer);
|
|
85
89
|
if (entry.process) await entry.process.stop();
|
|
86
90
|
this.entries.delete(account.id);
|
|
91
|
+
// A refusal from `beforeLaunch` names the real reason, such as agents still on the account (#55).
|
|
92
|
+
if (error instanceof LoginRefusal) throw error;
|
|
87
93
|
throw new Error("Could not start account sign-in. Check the provider CLI and try again.");
|
|
88
94
|
}
|
|
89
95
|
}
|