@victor-software-house/pi-acp 0.16.0 → 0.17.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.
@@ -8,7 +8,7 @@ import { isAbsolute, join, resolve } from "node:path";
8
8
  import { Hono } from "hono";
9
9
  import { AgentSideConnection, RequestError, ndJsonStream } from "@agentclientprotocol/sdk";
10
10
  import { randomUUID } from "node:crypto";
11
- import { DefaultResourceLoader, SessionManager, createAgentSession, createBashToolDefinition, createReadToolDefinition, getAgentDir } from "@earendil-works/pi-coding-agent";
11
+ import { AuthStorage, DefaultResourceLoader, SessionManager, createAgentSession, createBashToolDefinition, createReadToolDefinition, getAgentDir } from "@earendil-works/pi-coding-agent";
12
12
  import * as z from "zod";
13
13
  import { parse } from "yaml";
14
14
  import { $ } from "bun";
@@ -2195,7 +2195,7 @@ var SshBackend = class {
2195
2195
  //#endregion
2196
2196
  //#region package.json
2197
2197
  var name = "@victor-software-house/pi-acp";
2198
- var version = "0.16.0";
2198
+ var version = "0.17.0";
2199
2199
  //#endregion
2200
2200
  //#region src/acp/agent.ts
2201
2201
  /** Builtin ACP slash commands handled directly by the adapter. */
@@ -2354,6 +2354,41 @@ var PiAcpAgent = class {
2354
2354
  disabled: this.disabledProviders
2355
2355
  }, params);
2356
2356
  }
2357
+ /**
2358
+ * Clears every provider's stored credentials from the shared AuthStorage.
2359
+ *
2360
+ * ACP `LogoutRequest` carries only `_meta` — no per-provider selector —
2361
+ * so this is correctly GLOBAL. Pi has no AuthStorage.clearAll(); we
2362
+ * loop `list()` + `remove()` per provider.
2363
+ *
2364
+ * Sessions stay live. Subsequent prompts may surface auth_required which
2365
+ * is the correct UX. Best-effort fanout: post an agent_message_chunk to
2366
+ * every live PiAcpSession announcing the logout for client visibility.
2367
+ *
2368
+ * Strategy: reuse an active session's AuthStorage instance when one
2369
+ * exists (every live session shares the same on-disk auth.json). When
2370
+ * no session is live, mint an ad-hoc `AuthStorage.create()` to operate
2371
+ * directly on the on-disk store.
2372
+ *
2373
+ * Gated by `agentCapabilities.auth.logout = {}`.
2374
+ */
2375
+ async unstable_logout(_params) {
2376
+ const live = this.sessions.first();
2377
+ const authStorage = live !== void 0 ? live.piSession.modelRegistry.authStorage : AuthStorage.create();
2378
+ const providers = authStorage.list();
2379
+ for (const p of providers) authStorage.remove(p);
2380
+ for (const s of this.sessions.values()) this.conn.sessionUpdate({
2381
+ sessionId: s.sessionId,
2382
+ update: {
2383
+ sessionUpdate: "agent_message_chunk",
2384
+ content: {
2385
+ type: "text",
2386
+ text: "[pi-acp] Logged out from all providers.\n"
2387
+ }
2388
+ }
2389
+ }).catch(() => {});
2390
+ return { _meta: { piAcp: { clearedProviders: providers } } };
2391
+ }
2357
2392
  registerWithDaemon(input) {
2358
2393
  if (this.daemonContext === void 0) return;
2359
2394
  this.daemonContext.sessionRegistry.register({
@@ -2516,6 +2551,7 @@ var PiAcpAgent = class {
2516
2551
  },
2517
2552
  authMethods: buildAuthMethods({ supportsTerminalAuthMeta: this.clientCapabilities.terminalAuth }),
2518
2553
  agentCapabilities: {
2554
+ auth: { logout: {} },
2519
2555
  loadSession: true,
2520
2556
  mcpCapabilities: {
2521
2557
  http: false,
@@ -3681,4 +3717,4 @@ async function runDaemon() {
3681
3717
  //#endregion
3682
3718
  export { runDaemon };
3683
3719
 
3684
- //# sourceMappingURL=daemon-DKl32dgA.mjs.map
3720
+ //# sourceMappingURL=daemon-CTINLJUp.mjs.map