paseo-plugin-account-switcher 0.9.0 → 0.10.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/OVERVIEW.md CHANGED
@@ -16,7 +16,7 @@ Limits cover every window the provider reports, such as 5-hour and weekly use, w
16
16
 
17
17
  ## Setup
18
18
 
19
- - Paseo 0.11 to 0.14 on a macOS or Linux daemon, with Node.js 22.12 or newer.
19
+ - Paseo 0.11 or newer on a macOS or Linux daemon, with Node.js 22.12 or newer.
20
20
  - The official Paseo CLI and at least one of Claude Code or Codex on the daemon. A provider without its CLI shows as unavailable; after you install it, reload the plugin and select **Enable** in that provider's section.
21
21
  - A Claude or ChatGPT subscription for each account. API keys are not supported. Adding an account runs the official CLI sign-in from Paseo.
22
22
 
@@ -26,7 +26,7 @@ Limits cover every window the provider reports, such as 5-hour and weekly use, w
26
26
  - Claude limits come from a request to `api.anthropic.com` with the account's access token. When that token has expired, for example on an idle account, the plugin runs `claude -p /usage --no-session-persistence` under the account so the official CLI renews it, at most every 10 minutes. The command sends no model message and saves no session. Codex limits and the plan's model list come from the official `codex app-server`, which asks OpenAI and may refresh the account's token. Limit checks send no model messages.
27
27
  - To list accounts in Paseo's Usage view, the plugin reports the limits it has already collected under the source name Account Switcher, without new provider requests. For an agent on a managed account, it adds that account's profile directory to the agent's session environment so Paseo's usage popover reads the right account.
28
28
  - The only message the plugin sends to an agent is **Continue.**, after a switch made from the limit row, or by automatic switching after a failed turn.
29
- - Limits refresh every 5 minutes, and every minute while Accounts or the switcher is open. Missing values show as no data, and a failed refresh can keep the last values, marked stale.
29
+ - Limits refresh every 5 minutes, and every minute while Accounts or the switcher is open. Missing values show as no data, and a failed refresh can keep the last values, marked stale. With **Check usage** off in the host's settings (Paseo 0.15 and newer), the plugin makes no limit requests and offers no switch when a limit runs out; Accounts says so.
30
30
  - Removing a managed account deletes its profile and stored sign-in, including a Claude account's Keychain item on macOS. Shared session history stays.
31
31
 
32
32
  ## Limitations
@@ -37,3 +37,9 @@ Limits cover every window the provider reports, such as 5-hour and weekly use, w
37
37
  - Plans differ in the models they offer: after a switch to a plan without the agent's model, its next message fails. For Codex, the switcher compares the agent's model with the models the account's plan offers and warns before **Apply**. Claude does not report its models, so there is no such check for Claude.
38
38
  - Codex's **In browser** sign-in must finish on the daemon's computer. From another device, use **Device code**.
39
39
  - Providers can change their limit formats. Values the plugin cannot read show as no data.
40
+
41
+ ## Other plugins by dutchakdev
42
+
43
+ - [Machine Status](https://paseo.sh/plugins/dutchakdev/machine-status): load, memory, disk, the ports and processes your agents started, and Docker on the daemon's Mac, with dev-cache cleanup and confirmed process stops.
44
+ - [Mermaid](https://paseo.sh/plugins/dutchakdev/mermaid): draws Mermaid flowcharts and sequence diagrams from chat messages and `.mmd` files, on desktop and mobile.
45
+ - [secure-input](https://paseo.sh/plugins/dutchakdev/secure-input): agents ask you for secrets through a form, and each value lands in a short-lived file the agent moves without reading it.
package/OVERVIEW.zh-CN.md CHANGED
@@ -18,7 +18,7 @@ Account Switcher 让你在 Paseo 中使用多个 Claude 和 ChatGPT/Codex 订阅
18
18
 
19
19
  ## 设置
20
20
 
21
- - macOS 或 Linux 守护进程上的 Paseo 0.11 至 0.14,以及 Node.js 22.12 或更高版本。
21
+ - macOS 或 Linux 守护进程上的 Paseo 0.11 或更高版本,以及 Node.js 22.12 或更高版本。
22
22
  - 守护进程上需要官方 Paseo CLI,以及 Claude Code 或 Codex 至少其一。缺少 CLI 的提供商会显示为不可用;安装后重新加载插件,并在该提供商的分区中选择 **Enable**。
23
23
  - 每个账号都需要 Claude 或 ChatGPT 订阅。不支持 API 密钥。添加账号时,会在 Paseo 中运行官方 CLI 登录流程。
24
24
 
@@ -28,7 +28,7 @@ Account Switcher 让你在 Paseo 中使用多个 Claude 和 ChatGPT/Codex 订阅
28
28
  - Claude 限制来自使用该账号访问令牌向 `api.anthropic.com` 发出的请求。当该令牌过期时(例如账号闲置),插件会以该账号运行 `claude -p /usage --no-session-persistence`,由官方 CLI 续期令牌,每 10 分钟最多一次。该命令不发送模型消息,也不保存会话。Codex 限制和套餐的模型列表来自官方 `codex app-server`,它会向 OpenAI 查询,并可能刷新账号令牌。限制检查不会发送任何模型消息。
29
29
  - 为在 Paseo 的 Usage 视图中列出账号,插件会以来源名称 Account Switcher 上报它已收集的限制数据,不会产生新的提供商请求。对于使用托管账号的智能体,插件会把该账号的配置文件目录加入智能体的会话环境,使 Paseo 的用量弹窗读取正确的账号。
30
30
  - 插件发给智能体的唯一消息是 **Continue.**,仅在通过限制行完成切换之后,或在失败回合之后自动切换完成时发送。
31
- - 限制每 5 分钟刷新一次;Accounts 或切换器打开时每分钟刷新一次。缺失的值显示为无数据,刷新失败时可能保留上次的值并标记为过期。
31
+ - 限制每 5 分钟刷新一次;Accounts 或切换器打开时每分钟刷新一次。缺失的值显示为无数据,刷新失败时可能保留上次的值并标记为过期。在主机设置中关闭 **Check usage** 时(Paseo 0.15 及更新版本),插件不发起额度请求,额度用尽时也不提供切换;Accounts 页面会说明这一点。
32
32
  - 移除托管账号会删除其配置文件和已保存的登录信息,在 macOS 上包括 Claude 账号的钥匙串项。共享的会话历史会保留。
33
33
 
34
34
  ## 限制
@@ -39,3 +39,9 @@ Account Switcher 让你在 Paseo 中使用多个 Claude 和 ChatGPT/Codex 订阅
39
39
  - 不同套餐提供的模型不同:切换到不提供该智能体模型的套餐后,下一条消息会失败。对于 Codex,切换器会将智能体的模型与该账号套餐提供的模型进行比较,并在 **Apply** 前给出提示。Claude 不报告其模型,因此 Claude 没有此项检查。
40
40
  - Codex 的 **In browser** 登录必须在守护进程所在的电脑上完成。在其他设备上请使用 **Device code**。
41
41
  - 提供商可能更改限制格式。插件无法读取的值显示为无数据。
42
+
43
+ ## dutchakdev 的其他插件
44
+
45
+ - [Machine Status](https://paseo.sh/zh-CN/plugins/dutchakdev/machine-status):显示守护进程所在 Mac 的负载、内存、磁盘、智能体启动的端口和进程以及 Docker,并可清理开发缓存、经确认后停止进程。
46
+ - [Mermaid](https://paseo.sh/zh-CN/plugins/dutchakdev/mermaid):在聊天消息和 `.mmd` 文件中绘制 Mermaid 流程图和时序图,支持桌面端和移动端。
47
+ - [secure-input](https://paseo.sh/zh-CN/plugins/dutchakdev/secure-input):智能体通过表单向你索取密钥;每个值写入一个短期文件,智能体只移动该文件而不读取其内容。
package/README.md CHANGED
@@ -22,7 +22,7 @@ Listed in the [Paseo plugin directory](https://paseo.sh/plugins/dutchakdev/accou
22
22
 
23
23
  ## Requirements
24
24
 
25
- - **Paseo 0.11.x through 0.14.x**, including beta releases after 0.11.0, on a **macOS or Linux** daemon and on the connected client.
25
+ - **Paseo 0.11.0 or newer**, including beta releases after 0.11.0, on a **macOS or Linux** daemon and on the connected client.
26
26
  - **Node.js 22.12.0 or newer**, with npm.
27
27
  - The official **Paseo** CLI and at least one of **Claude Code** or **Codex** available to the daemon. A provider whose CLI is missing is skipped; after installing it, reload the plugin and select **Enable** in its section.
28
28
  - Claude or ChatGPT subscription authentication. API keys and custom authentication/provider overrides are unsupported.
@@ -33,7 +33,7 @@ The interface is in English. Reset dates use the viewing device's local time zon
33
33
 
34
34
  Paseo plugins are trusted, unsandboxed code with the daemon user's access to files, processes, credentials, and network. Account Switcher reads your Claude and Codex sign-ins to identify accounts and check their limits, and checking limits sends no model messages. The only message it sends to an agent is **Continue.**, after you switch from the row a used-up limit adds to the chat, or after an automatic switch that followed a failed turn. The commands below target the local daemon; for another host, see [remote daemons](docs/installation.md#remote-daemons).
35
35
 
36
- On Paseo 0.11.0 or a later release, including 0.12, 0.13 and 0.14, install the reviewed version from the plugin directory:
36
+ On Paseo 0.11.0 or a later release, install the reviewed version from the plugin directory:
37
37
 
38
38
  ```sh
39
39
  paseo plugin add dutchakdev/account-switcher
@@ -196,6 +196,12 @@ This project supports same-provider switching with subscription accounts. Switch
196
196
 
197
197
  Automated tests cover the implementation with synthetic accounts and provider responses. They do not establish real A → B → A switching, compaction, child-session behavior, or rewind for your accounts. Recorded checks and remaining live verification are in [verification](docs/verification.md).
198
198
 
199
+ ## Other plugins by dutchakdev
200
+
201
+ - [Machine Status](https://paseo.sh/plugins/dutchakdev/machine-status) ([source](https://github.com/dutchakdev/paseo-plugin-machine-status)): load, memory, disk, the ports and processes your agents started, and Docker on the daemon's Mac, with dev-cache cleanup and confirmed process stops.
202
+ - [Mermaid](https://paseo.sh/plugins/dutchakdev/mermaid) ([source](https://github.com/dutchakdev/paseo-plugin-mermaid)): draws Mermaid flowcharts and sequence diagrams from chat messages and `.mmd` files, on desktop and mobile.
203
+ - [secure-input](https://paseo.sh/plugins/dutchakdev/secure-input) ([source](https://github.com/dutchakdev/paseo-plugin-secure-input)): agents ask you for secrets through a form, and each value lands in a short-lived file the agent moves without reading it.
204
+
199
205
  ## Documentation and contributions
200
206
 
201
207
  - [Installation, updates, and troubleshooting](docs/installation.md)
@@ -22,8 +22,8 @@ function listed(account: Account, state: AccountState): boolean {
22
22
  return state.providers[account.provider].available || account.source === "managed";
23
23
  }
24
24
 
25
- function AccountCard({ account, state, snapshot, now, theme, layout, host, onChanged, onStarted, onResume }: AccountsProps & SignInActions & {
26
- account: Account; state: AccountState; snapshot: UsageSnapshot | undefined; now: number;
25
+ function AccountCard({ account, state, snapshot, checksOff, now, theme, layout, host, onChanged, onStarted, onResume }: AccountsProps & SignInActions & {
26
+ account: Account; state: AccountState; snapshot: UsageSnapshot | undefined; checksOff: boolean; now: number;
27
27
  }) {
28
28
  const rename = useRpc(renameAccount);
29
29
  const remove = useRpc(removeAccount);
@@ -81,7 +81,7 @@ function AccountCard({ account, state, snapshot, now, theme, layout, host, onCha
81
81
  {"sessionId" in loginSession ? "Finish signing in in your browser. Status and limits will update automatically." : "A sign-in from an older version is still open. Cancel it, then sign in again to use the browser flow."}
82
82
  </Notice> : null}
83
83
  {panel === "menu" ? <View style={{ ...row, paddingTop: 2 }}>
84
- <Button theme={theme} variant="ghost" disabled={busy || Boolean(loginSession)} onPress={() => action.run(() => refresh({ accountId: account.id }))}>Refresh limits</Button>
84
+ <Button theme={theme} variant="ghost" disabled={busy || checksOff || Boolean(loginSession)} onPress={() => action.run(() => refresh({ accountId: account.id }))}>Refresh limits</Button>
85
85
  <Button theme={theme} variant="ghost" disabled={busy} onPress={() => action.run(async () => {
86
86
  const result = await check({ accountId: account.id });
87
87
  setNotice(result.authStatus === "ready" ? "Sign-in confirmed. You can now select this account for agents." : "Sign-in is not confirmed yet. Finish signing in in your browser, then check again.");
@@ -111,7 +111,7 @@ function AccountCard({ account, state, snapshot, now, theme, layout, host, onCha
111
111
  {notice ? <Notice theme={theme}>{notice}</Notice> : null}
112
112
  {action.error ? <Notice theme={theme} tone="danger">{errorMessage(action.error)}</Notice> : null}
113
113
  <QuotaSummary theme={theme} snapshot={snapshot} now={now} compact={layout.compact}
114
- onRefresh={loginSession ? undefined : () => action.run(() => refresh({ accountId: account.id }))} refreshing={busy} />
114
+ onRefresh={loginSession || checksOff ? undefined : () => action.run(() => refresh({ accountId: account.id }))} refreshing={busy} />
115
115
  </View>;
116
116
  }
117
117
 
@@ -177,6 +177,7 @@ export function AccountsSurface(props: AccountsProps) {
177
177
  const onStarted = (account: Account, session: LoginSession) => setSignIn({ account, hostId: host.id, sessionId: session.id, initial: session, autoOpen: true });
178
178
  const onResume = (account: Account, sessionId: string) => setSignIn({ account, hostId: host.id, sessionId, autoOpen: false });
179
179
  const state = accounts.data;
180
+ const checksOff = usage.data?.checksOff === true;
180
181
  const enabled = state?.integration.enabled ?? false;
181
182
  const installed = providers.filter((option) => state?.providers[option.value].available ?? true);
182
183
  const toggleIntegration = () => action.run(() => integration({ enabled: !enabled }));
@@ -190,7 +191,7 @@ export function AccountsSurface(props: AccountsProps) {
190
191
  {enabled ? <InlineAction theme={theme} disabled={action.isPending} onPress={toggleIntegration}>Disable</InlineAction> : null}
191
192
  </View> : <Text style={muted(theme)}>{accounts.isPending ? "Loading…" : "Data unavailable"}</Text>}
192
193
  </View>
193
- <IconButton theme={theme} icon="RefreshCw" label="Refresh all limits" disabled={action.isPending} onPress={() => action.run(() => refresh({}))} />
194
+ <IconButton theme={theme} icon="RefreshCw" label="Refresh all limits" disabled={action.isPending || checksOff} onPress={() => action.run(() => refresh({}))} />
194
195
  <Button theme={theme} variant="primary" disabled={action.isPending || (!adding && !installed.length)} onPress={() => setAdding(adding ? null : installed[0]?.value ?? null)}>{adding ? "Close" : "Add"}</Button>
195
196
  </View>
196
197
  {state && !enabled ? <View style={{ flexDirection: "row", alignItems: "center", gap: 8, flexWrap: "wrap" }}>
@@ -198,6 +199,7 @@ export function AccountsSurface(props: AccountsProps) {
198
199
  <Button theme={theme} disabled={action.isPending} onPress={toggleIntegration}>Enable</Button>
199
200
  </View> : null}
200
201
  {state?.integration.error ? <Notice theme={theme} tone="danger">{state.integration.error}</Notice> : null}
202
+ {checksOff ? <Notice theme={theme} tone="warning">Check usage is off in this host's settings: limits stop updating, and a used-up account gets no switch offer.</Notice> : null}
201
203
  {runtimeError ? <Notice theme={theme} tone="danger">{runtimeError}</Notice> : null}
202
204
  {action.error ? <Notice theme={theme} tone="danger">{errorMessage(action.error)}</Notice> : null}
203
205
  {accounts.error ? <Notice theme={theme} tone="danger">Could not refresh accounts: {errorMessage(accounts.error)}</Notice> : null}
@@ -225,7 +227,7 @@ export function AccountsSurface(props: AccountsProps) {
225
227
  <View style={{ flex: 1, minWidth: 200 }}><Notice theme={theme} tone="warning">Account switching is off for {cliName[provider]}: its agents use the system CLI.</Notice></View>
226
228
  <Button theme={theme} disabled={action.isPending} onPress={enableIntegration}>Enable</Button>
227
229
  </View> : null}
228
- {group.map((account) => <AccountCard key={account.id} {...props} account={account} state={state} snapshot={usage.data?.accounts.find((item) => item.accountId === account.id)} now={now} onStarted={onStarted} onResume={onResume} />)}
230
+ {group.map((account) => <AccountCard key={account.id} {...props} account={account} state={state} snapshot={usage.data?.accounts.find((item) => item.accountId === account.id)} checksOff={checksOff} now={now} onStarted={onStarted} onResume={onResume} />)}
229
231
  {!group.length && status.available ? <View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
230
232
  <Text style={muted(theme)}>No accounts.</Text>
231
233
  <InlineAction theme={theme} onPress={() => setAdding(provider)}>Add</InlineAction>
package/client/screens.ts CHANGED
@@ -10,7 +10,7 @@ function AccountsSidebarRow({ currentScreen, openScreen }: PluginSidebarItemProp
10
10
  return createElement(SidebarRow, { icon: ICON, active: currentScreen?.screenId === SCREEN_ID, onPress: () => openScreen({ screenId: SCREEN_ID }) });
11
11
  }
12
12
 
13
- // The screen API replaced surfaces in Paseo 0.11; both names exist through 0.14. Ask the app what it has, not its version.
13
+ // The screen API replaced surfaces in Paseo 0.11; the old names are deprecated. Ask the app what it has, not its version.
14
14
  // Each registration is decided on its own, so an app that has only half of the new API still gets both pieces.
15
15
  export function registerAccountsScreen(client: PluginClientContext, Component: ComponentType<PluginScreenProps>): () => void {
16
16
  const removeScreen = typeof client.addScreen === "function"
package/index.server.ts CHANGED
@@ -126,8 +126,8 @@ export default function contribute(server:PluginServerContext){
126
126
  return{};
127
127
  });
128
128
  server.handle(rpc.setIntegration,({enabled},{paseo})=>controller.integration(paseo,enabled));
129
- server.handle(rpc.listUsage,async({visible},{paseo})=>{await controller.ensureRuntime(paseo);return{accounts:await controller.usage.list({visible})};});
130
- server.handle(rpc.refreshUsage,async({accountId},{paseo})=>{await controller.ensureRuntime(paseo);return{accounts:await controller.usage.refresh(accountId)};});
129
+ server.handle(rpc.listUsage,async({visible},{paseo})=>{await controller.ensureRuntime(paseo);return{accounts:await controller.usage.list({visible}),checksOff:!await controller.usage.checksEnabled()};});
130
+ server.handle(rpc.refreshUsage,async({accountId},{paseo})=>{await controller.ensureRuntime(paseo);return{accounts:await controller.usage.refresh(accountId),checksOff:!await controller.usage.checksEnabled()};});
131
131
  // Paseo's Usage view lists the managed accounts too; a daemon before 0.11 has no usage sources, and the Accounts screen still shows the same limits.
132
132
  registerPaseoUsage(server,controller);
133
133
  const removeCreate=server.before("agent.create",({request})=>{
@@ -180,6 +180,8 @@ export default function contribute(server:PluginServerContext){
180
180
  const state=await controller.store.read();
181
181
  // Without that provider's launcher the CLI runs on the system login, so a switch could not take effect.
182
182
  if(!state.integration.enabled||!state.integration.providers.includes(provider)||settled(state))return;
183
+ // With the host's usage checks off nothing can read the account again, and an old reading is no proof that it ran out.
184
+ if(!await controller.usage.checksEnabled())return;
183
185
  // An agent started with no app open may have a launch nothing has confirmed yet; its receipt confirms it now.
184
186
  const fromId=await controller.accountOf(paseo,agent.id,provider,state),from=labelOf(state,fromId);
185
187
  if(!fromId||!from)return;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "paseo-plugin-account-switcher",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "paseo-plugin-account-switcher",
9
- "version": "0.9.0",
9
+ "version": "0.10.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.9.0",
3
+ "version": "0.10.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "dutchakdev",
package/paseo-plugin.json CHANGED
@@ -1 +1 @@
1
- {"id":"account-switcher","icon":"assets/icon.png","requirements":{"paseo":"0.11.* || 0.12.* || 0.13.* || 0.14.*"}}
1
+ {"id":"account-switcher","icon":"assets/icon.png","requirements":{"paseo":">=0.11.0"}}
@@ -11,7 +11,7 @@ import { prepareProfile } from "./profiles";
11
11
  import { accountCommand, accountEnvironment, launchLogin, probeAccount, removeAccountCredentials } from "./auth";
12
12
  import { installIntegration, restoreIntegration, writeLaunchers, prepareRuntime, reconcileIntegration } from "./integration";
13
13
  import { SwitchRefusal, SwitchService } from "./switching";
14
- import { createUsageService, readCredentialVersion, type AccountReadOptions, type QuotaAccount } from "./usage";
14
+ import { createUsageService, readCredentialVersion, usageChecksEnabled, type AccountReadOptions, type QuotaAccount } from "./usage";
15
15
  import { renewExpiredClaudeToken } from "./usage/claude";
16
16
  import { LoginSessions, type LoginDependencies } from "./login";
17
17
  import { receiptProcessRuns } from "./process-identity";
@@ -57,7 +57,7 @@ export class AccountController {
57
57
  // A crash during reload must not leave an unconfirmed account marked applied.
58
58
  await this.store.change(state=>{for(const b of state.bindings){if(b.status==="switching"){b.currentAccountId=null;b.launchToken=null;b.status="error";b.error="The account switch was interrupted. Account not confirmed; apply the account again.";}}});
59
59
  });
60
- this.usage=createUsageService({getAccounts:input=>this.quotaAccounts(input),cachePath:join(root,"usage-cache.json")});
60
+ this.usage=createUsageService({getAccounts:input=>this.quotaAccounts(input),cachePath:join(root,"usage-cache.json"),checksEnabled:()=>usageChecksEnabled(join(dirname(root),"config.json"))});
61
61
  void this.ready.then(()=>{if(!this.disposed)this.usage.start();}).catch(()=>{});
62
62
  }
63
63
  async ensureRuntime(paseo:PaseoApi){
@@ -364,25 +364,34 @@ export class AccountController {
364
364
  return{provider:a.provider,busy:a.status==="running"||a.status==="initializing"||!!a.activeTurn||a.pendingPermissions.length>0,archived:!!a.archivedAt};
365
365
  },reload:async(id)=>{
366
366
  await requireIntegration();
367
- const config=JSON.parse(await readFile(join(dirname(this.store.root),"config.json"),"utf8"));
368
- const listen=config.daemon?.listen;
369
- if(typeof listen!=="string"||!listen)throw new SwitchRefusal("Could not identify the daemon for reload.");
370
- const host=listen.replace(/^0\.0\.0\.0:/,"127.0.0.1:");
371
- const cli=paseoCli();let command=cli.command;
372
- const reload=(file:string)=>execFileAsync(file,["agent","reload",id,"--json","--host",host],{timeout:120_000,maxBuffer:1024*1024,env:cli.env});
373
- try{
374
- // A CLI that could not start reloaded nothing, so `paseo` on PATH can still try. One that ran and failed is not repeated.
375
- 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);});
376
- }
377
- catch(error){
378
- // The chat gets the refusal; the cause, which can name local paths, goes only to the plugin log.
379
- const {code,signal,stderr}=error as {code?:unknown;signal?:unknown;stderr?:unknown};
380
- 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"}`);
381
- throw new SwitchRefusal("The native agent reload failed. Check the agent status and try again.");
367
+ const agent=paseo.agents.ref(id) as {reload?:()=>Promise<unknown>;commands?:()=>Promise<unknown>};
368
+ // From Paseo 0.14 the SDK sends the request the CLI would, with no process to start and no daemon address to find.
369
+ if(agent.reload){
370
+ try{await agent.reload();}
371
+ catch(error){
372
+ console.error(`Native reload of agent ${id} failed: ${stripVTControlCharacters(error instanceof Error?error.message:String(error)).replace(/\s+/g," ").trim().slice(0,500)||"no output"}`);
373
+ throw new SwitchRefusal("The native agent reload failed. Check the agent status and try again.");
374
+ }
375
+ }else{
376
+ const config=JSON.parse(await readFile(join(dirname(this.store.root),"config.json"),"utf8"));
377
+ const listen=config.daemon?.listen;
378
+ if(typeof listen!=="string"||!listen)throw new SwitchRefusal("Could not identify the daemon for reload.");
379
+ const host=listen.replace(/^0\.0\.0\.0:/,"127.0.0.1:");
380
+ const cli=paseoCli();let command=cli.command;
381
+ const reload=(file:string)=>execFileAsync(file,["agent","reload",id,"--json","--host",host],{timeout:120_000,maxBuffer:1024*1024,env:cli.env});
382
+ try{
383
+ // A CLI that could not start reloaded nothing, so `paseo` on PATH can still try. One that ran and failed is not repeated.
384
+ 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);});
385
+ }
386
+ catch(error){
387
+ // The chat gets the refusal; the cause, which can name local paths, goes only to the plugin log.
388
+ const {code,signal,stderr}=error as {code?:unknown;signal?:unknown;stderr?:unknown};
389
+ 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"}`);
390
+ throw new SwitchRefusal("The native agent reload failed. Check the agent status and try again.");
391
+ }
382
392
  }
383
393
  // Paseo 0.11 reloads into an idle session and spawns the CLI on first use; listing
384
394
  // commands starts it so the launcher can confirm the account. Older hosts already started it.
385
- const agent=paseo.agents.ref(id) as {commands?:()=>Promise<unknown>};
386
395
  if(agent.commands)await agent.commands().catch(()=>{/* The receipt check reports a failed start. */});
387
396
  }});
388
397
  this.switches.set(paseo,service);return service;