@danypops/papyrus 0.44.2 → 0.44.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/client.ts +12 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/papyrus",
3
- "version": "0.44.2",
3
+ "version": "0.44.3",
4
4
  "description": "Daemon-backed graph artifacts, evidence-bearing tasks, rules, skills, and native TUI workflows for Pi",
5
5
  "type": "module",
6
6
  "keywords": ["pi-package"],
@@ -35,7 +35,7 @@
35
35
  "files": ["src", "README.md"],
36
36
  "dependencies": {
37
37
  "@danypops/vehicle-core": "^0.10.0",
38
- "@danypops/vehicle-client": "^0.5.0",
38
+ "@danypops/vehicle-client": "^0.6.0",
39
39
  "@danypops/vehicle-server": "^0.13.0"
40
40
  }
41
41
  }
package/src/client.ts CHANGED
@@ -1,13 +1,19 @@
1
1
  import { spawn as spawnProcess } from "node:child_process";
2
2
  import { fileURLToPath } from "node:url";
3
- import { connectWithVersionCheck, spawnDetachedDaemon } from "@danypops/vehicle-client/daemon-client";
4
- import { readPackageVersion } from "@danypops/vehicle-client/version";
3
+ import { connectWithVersionCheck, type ExpectedVersion, spawnDetachedDaemon } from "@danypops/vehicle-client/daemon-client";
4
+ import { createLiveVersionExpectation } from "@danypops/vehicle-client/version";
5
5
  import { DAEMON_CLIENT_TIMEOUT_MS, DAEMON_DIR_ENV, DAEMON_PROBE_TIMEOUT_MS } from "./constants.ts";
6
6
  import { type DaemonHandle, daemonStateDir, readDaemonHandle } from "./daemon-state.ts";
7
7
  import type { OperationName, SchemaState } from "./service.ts";
8
8
 
9
- /** Compared against the running daemon's /health-reported version by connectWithVersionCheck below -- a long-lived daemon holds whatever code was loaded at its own start. */
10
- const PAPYRUS_VERSION = readPackageVersion(new URL("../package.json", import.meta.url), "Papyrus");
9
+ /**
10
+ * Compared against the running daemon's /health-reported version by connectWithVersionCheck
11
+ * below. Re-read fresh on every call, not cached -- a module-level `const` here was the exact
12
+ * bug that caused repeated, never-self-healing daemon kill/respawn churn on any process that
13
+ * outlived an `npm update` (a respawned daemon runs the same source and reports the same real
14
+ * version, so a stale cached expectation never converges).
15
+ */
16
+ const papyrusExpectedVersion = createLiveVersionExpectation(new URL("../package.json", import.meta.url), "Papyrus");
11
17
 
12
18
  export type FetchAdapter = (request: Request) => Promise<Response>;
13
19
 
@@ -89,7 +95,7 @@ export interface ConnectPapyrusClientOptions {
89
95
  */
90
96
  env?: Record<string, string | undefined>;
91
97
  /** Overrides the version connectWithVersionCheck compares against. Defaults to PAPYRUS_VERSION; test-only -- lets a test force a mismatch against a real daemon without a second build. */
92
- expectedVersion?: string;
98
+ expectedVersion?: ExpectedVersion;
93
99
  }
94
100
 
95
101
  /**
@@ -126,7 +132,7 @@ export async function connectPapyrusClient(
126
132
  fallbackMessage: "Papyrus daemon failed to start automatically; run `papyrus service install` or `papyrus serve` manually.",
127
133
  },
128
134
  {
129
- expectedVersion: options.expectedVersion ?? PAPYRUS_VERSION,
135
+ expectedVersion: options.expectedVersion ?? papyrusExpectedVersion,
130
136
  readVersion: async (client) => (await client.health()).version,
131
137
  killStaleProcess: killStalePapyrusDaemon,
132
138
  },