@danypops/pi-packed 0.5.2 → 0.5.3

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.
@@ -3,9 +3,13 @@
3
3
  *
4
4
  * Pi's extension runtime is Node-compatible and does not guarantee a global
5
5
  * `Bun`. All registry reads, SQLite access, and package mutations therefore
6
- * stay inside the supervised Bun daemon. The seam reconnects for every call so
7
- * a restarted daemon cannot leave a stale port/token client cached in Pi.
6
+ * stay inside the supervised Bun daemon. A restarted daemon binds a new
7
+ * port/token, which would otherwise leave a stale cached client behind for
8
+ * the rest of the Pi session -- daemon-kit's createRetryingClient detects
9
+ * that on the failing call itself and reconnects, so the happy path reuses
10
+ * one connected client instead of reconnecting on every single operation.
8
11
  */
12
+ import { createRetryingClient } from "@danypops/daemon-kit/pi-client";
9
13
  import type { PackageDaemonPort as ClientPackageDaemonPort } from "../../src/client.ts";
10
14
  import type { InstalledPkg, Pkg, PkgInfo, UpdateEntry, UpdateOutcome } from "../../src/ports.ts";
11
15
  import type { MutationApproval, SecuritySettings } from "../../src/security.ts";
@@ -44,28 +48,18 @@ async function connectDefaultDaemon(): Promise<PackageDaemonPort> {
44
48
  }
45
49
 
46
50
  export async function createNatives(connect: PackageDaemonConnector = connectDefaultDaemon): Promise<Natives> {
47
- async function call<T>(operation: (daemon: PackageDaemonPort) => Promise<T>): Promise<T> {
48
- let lastError: unknown;
49
- for (let attempt = 0; attempt < 2; attempt += 1) {
50
- try {
51
- return await operation(await connect());
52
- } catch (error) {
53
- lastError = error;
54
- }
55
- }
56
- throw lastError instanceof Error ? lastError : new Error(String(lastError));
57
- }
51
+ const client = createRetryingClient(connect, { label: "pi-packed" });
58
52
 
59
53
  return {
60
- search: (query, limit) => call((daemon) => daemon.search(query, limit)),
61
- searchOffline: (query, limit) => call((daemon) => daemon.search(query, limit, true)),
62
- info: (name) => call((daemon) => daemon.info(name)),
63
- installed: () => call((daemon) => daemon.installed()),
64
- updates: () => call((daemon) => daemon.updates()),
65
- security: () => call((daemon) => daemon.security()),
66
- setMutationApproval: (value, approved) => call((daemon) => daemon.setMutationApproval(value, approved)),
67
- install: (source, approved) => call((daemon) => daemon.install(source, approved)),
68
- remove: (name, approved) => call((daemon) => daemon.remove(name, approved)),
69
- update: (source, approved) => call((daemon) => daemon.update(source, approved)),
54
+ search: (query, limit) => client.call((daemon) => daemon.search(query, limit)),
55
+ searchOffline: (query, limit) => client.call((daemon) => daemon.search(query, limit, true)),
56
+ info: (name) => client.call((daemon) => daemon.info(name)),
57
+ installed: () => client.call((daemon) => daemon.installed()),
58
+ updates: () => client.call((daemon) => daemon.updates()),
59
+ security: () => client.call((daemon) => daemon.security()),
60
+ setMutationApproval: (value, approved) => client.call((daemon) => daemon.setMutationApproval(value, approved)),
61
+ install: (source, approved) => client.call((daemon) => daemon.install(source, approved)),
62
+ remove: (name, approved) => client.call((daemon) => daemon.remove(name, approved)),
63
+ update: (source, approved) => client.call((daemon) => daemon.update(source, approved)),
70
64
  };
71
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/pi-packed",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Package service for the Pi agent: search/info/install/updates + /packages TUI, backed by a long-running Bun service",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,6 +20,9 @@
20
20
  "extension/src/index.ts"
21
21
  ]
22
22
  },
23
+ "dependencies": {
24
+ "@danypops/daemon-kit": "^0.4.0"
25
+ },
23
26
  "peerDependencies": {
24
27
  "@earendil-works/pi-coding-agent": "*",
25
28
  "@earendil-works/pi-tui": "*",