paseo-plugin-account-switcher 0.8.0 → 0.8.1

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 CHANGED
@@ -1,4 +1,4 @@
1
- <img src="assets/icon.png" width="88" align="right" alt="">
1
+ ![Account Switcher: switch the account, keep the chat. A Codex agent moves from a used-up account to another with /account, and the chat records the switch.](docs/preview.png)
2
2
 
3
3
  # Account Switcher for Paseo
4
4
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "paseo-plugin-account-switcher",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "paseo-plugin-account-switcher",
9
- "version": "0.8.0",
9
+ "version": "0.8.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@iarna/toml": "^2.2.5"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-plugin-account-switcher",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "dutchakdev",
@@ -1,5 +1,5 @@
1
1
  import { execFile } from "node:child_process";
2
- import { promisify } from "node:util";
2
+ import { promisify, stripVTControlCharacters } from "node:util";
3
3
  import { homedir } from "node:os";
4
4
  import { join, dirname, resolve } from "node:path";
5
5
  import { lstat, readFile, realpath, rm } from "node:fs/promises";
@@ -16,6 +16,13 @@ import { renewExpiredClaudeToken } from "./usage/claude";
16
16
  import { LoginSessions, type LoginDependencies } from "./login";
17
17
 
18
18
  const execFileAsync=promisify(execFile);
19
+ // Paseo sets these for its own Node processes, this plugin's included, and removes them before it starts an outside
20
+ // command. Inherited, ELECTRON_RUN_AS_NODE makes an Electron executable, such as a `paseo` link to the desktop app's
21
+ // executable left by an older install, run as plain Node, which then fails to load "agent" as a script.
22
+ const RUNTIME_ENV=["PASEO_NODE_ENV","PASEO_DESKTOP_MANAGED","PASEO_SUPERVISED","ELECTRON_RUN_AS_NODE","ELECTRON_NO_ATTACH_CONSOLE","ESBUILD_BINARY_PATH"];
23
+ // PASEO_CLI names the desktop app's bundled CLI, for the daemon the app starts and for one started from the app's terminal,
24
+ // which inherits it and can outlive the app. A standalone daemon finds `paseo` on PATH.
25
+ function paseoCli(){const env={...process.env};for(const key of RUNTIME_ENV)delete env[key];return{command:process.env.PASEO_CLI?.trim()||"paseo",env};}
19
26
  // A revoked sign-in fails every renewal; this bounds how often it starts the CLI.
20
27
  const RENEWAL_INTERVAL=600000;
21
28
  // Agent statuses that show a launch got under way, for the receipt check: the Accounts list waits for a session that is
@@ -337,8 +344,18 @@ export class AccountController {
337
344
  const listen=config.daemon?.listen;
338
345
  if(typeof listen!=="string"||!listen)throw new SwitchRefusal("Could not identify the daemon for reload.");
339
346
  const host=listen.replace(/^0\.0\.0\.0:/,"127.0.0.1:");
340
- try{await execFileAsync("paseo",["agent","reload",id,"--json","--host",host],{timeout:120_000,maxBuffer:1024*1024,env:process.env});}
341
- catch{throw new SwitchRefusal("The native agent reload failed. Check the agent status and try again.");}
347
+ const cli=paseoCli();let command=cli.command;
348
+ const reload=(file:string)=>execFileAsync(file,["agent","reload",id,"--json","--host",host],{timeout:120_000,maxBuffer:1024*1024,env:cli.env});
349
+ try{
350
+ // A CLI that could not start reloaded nothing, so `paseo` on PATH can still try. One that ran and failed is not repeated.
351
+ await reload(command).catch(error=>{const code=(error as {code?:unknown}).code;if(command==="paseo"||(code!=="ENOENT"&&code!=="EACCES"))throw error;command="paseo";return reload(command);});
352
+ }
353
+ catch(error){
354
+ // The chat gets the refusal; the cause, which can name local paths, goes only to the plugin log.
355
+ const {code,signal,stderr}=error as {code?:unknown;signal?:unknown;stderr?:unknown};
356
+ console.error(`Native reload of agent ${id} with ${command} failed (${signal?`signal ${signal}`:`code ${code}`}): ${stripVTControlCharacters(String(stderr??"")).replace(/\s+/g," ").trim().slice(0,500)||"no output"}`);
357
+ throw new SwitchRefusal("The native agent reload failed. Check the agent status and try again.");
358
+ }
342
359
  // Paseo 0.11 reloads into an idle session and spawns the CLI on first use; listing
343
360
  // commands starts it so the launcher can confirm the account. Older hosts already started it.
344
361
  const agent=paseo.agents.ref(id) as {commands?:()=>Promise<unknown>};