dsh-phone-bridge 0.2.7 → 0.2.8

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/index.js +33 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -244,6 +244,32 @@ const REQUIRED_CONTROLLER_METHODS = [
244
244
  "selectModel",
245
245
  ];
246
246
 
247
+ // The DSH version this build was last exercised against. Bumped by hand when the
248
+ // plugin is re-tested on a newer DSH. It is not a compatibility claim, only the
249
+ // value /health compares the running version to, so that a mismatch shows up as a
250
+ // sentence rather than as a mystery.
251
+ const TESTED_WITH_DSH = "0.2.0-rc.2";
252
+
253
+ // Best effort. The plugin runs inside the DSH process, and Electron patches fs so
254
+ // an app.asar reads like a directory, which is what makes this possible at all.
255
+ // Returns null when it cannot be read; /health says so rather than guessing.
256
+ function readDshVersion() {
257
+ const candidates = [];
258
+ if (process.resourcesPath) {
259
+ candidates.push(join(process.resourcesPath, "app.asar", "package.json"));
260
+ candidates.push(join(process.resourcesPath, "app", "package.json"));
261
+ }
262
+ for (const candidate of candidates) {
263
+ try {
264
+ const parsed = JSON.parse(readFileSync(candidate, "utf8"));
265
+ if (parsed?.version) return { name: parsed.name ?? null, version: parsed.version };
266
+ } catch {
267
+ // try the next candidate
268
+ }
269
+ }
270
+ return null;
271
+ }
272
+
247
273
  // A session lives at sessions/<slug-of-cwd>/<sessionId>/, where the slug is a
248
274
  // lossy encoding of the working directory. Locate it by scanning instead of
249
275
  // trying to re-derive that encoding.
@@ -1058,11 +1084,18 @@ export function apply(ctx, config = {}) {
1058
1084
  const missing = sessionController
1059
1085
  ? REQUIRED_CONTROLLER_METHODS.filter((name) => typeof sessionController[name] !== "function")
1060
1086
  : REQUIRED_CONTROLLER_METHODS.slice();
1087
+ const dsh = readDshVersion();
1061
1088
  sendJson(res, 200, {
1062
1089
  ok: missing.length === 0,
1063
1090
  controllerAvailable: Boolean(sessionController),
1064
1091
  required: REQUIRED_CONTROLLER_METHODS,
1065
1092
  missing,
1093
+ // The method list above is the real compatibility signal. The version is
1094
+ // context: a newer DSH can keep every method and still change what one of
1095
+ // them means, and that is the one failure nothing here can detect.
1096
+ testedWith: TESTED_WITH_DSH,
1097
+ dshVersion: dsh?.version ?? null,
1098
+ versionMatchesTested: dsh?.version ? dsh.version === TESTED_WITH_DSH : null,
1066
1099
  });
1067
1100
  } catch (error) {
1068
1101
  sendJson(res, 500, { ok: false, error: String(error?.message ?? error) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-phone-bridge",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Drive an existing DSH desktop session from a chat app, plus a sidebar delete button and trash panel",
5
5
  "type": "module",
6
6
  "main": "index.js",