@victor-software-house/pi-acp 0.14.0 → 0.15.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.
@@ -2115,7 +2115,7 @@ var SshBackend = class {
2115
2115
  //#endregion
2116
2116
  //#region package.json
2117
2117
  var name = "@victor-software-house/pi-acp";
2118
- var version = "0.14.0";
2118
+ var version = "0.15.0";
2119
2119
  //#endregion
2120
2120
  //#region src/acp/agent.ts
2121
2121
  /** Builtin ACP slash commands handled directly by the adapter. */
@@ -2413,7 +2413,8 @@ var PiAcpAgent = class {
2413
2413
  list: {},
2414
2414
  close: {},
2415
2415
  resume: {},
2416
- fork: {}
2416
+ fork: {},
2417
+ delete: {}
2417
2418
  }
2418
2419
  }
2419
2420
  };
@@ -2786,6 +2787,40 @@ var PiAcpAgent = class {
2786
2787
  else if (local !== void 0) this.sessions.detach(params.sessionId);
2787
2788
  return {};
2788
2789
  }
2790
+ /**
2791
+ * Deletes a session's on-disk file + releases any live state.
2792
+ *
2793
+ * Pi's SessionManager exposes no `delete()` method (verified against
2794
+ * session-manager.d.ts) — sessions are append-only JSONL files. We
2795
+ * unlink the file directly via `fs.rmSync`. `resolveSessionFile`
2796
+ * sources paths from `PiSessionManager.listAll`, so the unlinked path
2797
+ * is always inside `~/.pi/agent/sessions/...`.
2798
+ *
2799
+ * Refuses to delete sessions owned by ANOTHER connection in the daemon
2800
+ * registry — security boundary: clients may only delete sessions they
2801
+ * own or sessions that are not currently live. Always releases the
2802
+ * daemon registry entry first so the live piSession is disposed
2803
+ * cleanly before the file disappears.
2804
+ *
2805
+ * Gated by `sessionCapabilities.delete = {}` (advertised in initialize).
2806
+ */
2807
+ async unstable_deleteSession(params) {
2808
+ const sessionFile = await this.resolveSessionFile(params.sessionId);
2809
+ if (sessionFile === null) throw RequestError.invalidParams(`Unknown sessionId: ${params.sessionId}`);
2810
+ const live = this.daemonContext?.sessionRegistry.get(params.sessionId);
2811
+ if (live !== void 0 && live.ownerConnectionId !== this.connectionId) throw RequestError.invalidParams(`Session ${params.sessionId} is owned by another connection — cannot delete`);
2812
+ if (live !== void 0) {
2813
+ if (this.releaseFromDaemon(params.sessionId).disposed) this.sessions.close(params.sessionId);
2814
+ } else if (this.sessions.maybeGet(params.sessionId) !== void 0) this.sessions.close(params.sessionId);
2815
+ try {
2816
+ rmSync(sessionFile, { force: true });
2817
+ } catch (e) {
2818
+ const msg = e instanceof Error ? e.message : String(e);
2819
+ throw RequestError.internalError({}, `Failed to delete session file: ${msg}`);
2820
+ }
2821
+ this.sessionPaths.delete(params.sessionId);
2822
+ return { _meta: { piAcp: { deletedFile: sessionFile } } };
2823
+ }
2789
2824
  async resumeSession(params) {
2790
2825
  if (!isAbsolute(params.cwd)) throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
2791
2826
  const existing = this.sessions.maybeGet(params.sessionId);
@@ -3528,4 +3563,4 @@ async function runDaemon() {
3528
3563
  //#endregion
3529
3564
  export { runDaemon };
3530
3565
 
3531
- //# sourceMappingURL=daemon-CjPR14E_.mjs.map
3566
+ //# sourceMappingURL=daemon-C-rb-cf5.mjs.map