dsh-phone-bridge 0.2.3 → 0.2.4

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 (3) hide show
  1. package/README.md +1 -0
  2. package/index.js +53 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -37,6 +37,7 @@ trash panel at the bottom of the sidebar where each entry can be restored or pur
37
37
  | `POST /stop` | cancel the session's running turn |
38
38
  | `GET /models` | the deployment model catalog |
39
39
  | `POST /model` | switch the model a session uses |
40
+ | `GET /health` | whether this DSH build still has every `sessionController` method the plugin calls, and which are missing if not |
40
41
 
41
42
  Deleting **moves** a session to `~/.dsh/deleted-sessions/` instead of unlinking it,
42
43
  so a delete stays recoverable and purging is a separate, explicit step.
package/index.js CHANGED
@@ -227,6 +227,22 @@ const WORKSPACE_FILE = join(DSH_HOME, "storages", "workspace.json");
227
227
  // TRASH_ROOT is assigned in apply() from Config, because it is the one path a
228
228
  // deployment may reasonably want to move somewhere else.
229
229
 
230
+ // Every sessionController method this plugin calls. DSH is pre-1.0 and this set
231
+ // is an internal surface, so it is checked at load and reported by /health
232
+ // rather than discovered one failing route at a time.
233
+ const REQUIRED_CONTROLLER_METHODS = [
234
+ "cancel",
235
+ "create",
236
+ "follow",
237
+ "inspect",
238
+ "list",
239
+ "modelCatalog",
240
+ "prompt",
241
+ "rename",
242
+ "search",
243
+ "selectModel",
244
+ ];
245
+
230
246
  // A session lives at sessions/<slug-of-cwd>/<sessionId>/, where the slug is a
231
247
  // lossy encoding of the working directory. Locate it by scanning instead of
232
248
  // trying to re-derive that encoding.
@@ -879,6 +895,32 @@ export function apply(ctx, config = {}) {
879
895
  },
880
896
  }));
881
897
 
898
+ // What this build of DSH is expected to hand us. The plugin drives sessions
899
+ // through sessionController, which is an internal surface that can change
900
+ // between releases; when it does, the symptom would otherwise be a bare 500 on
901
+ // whichever route happens to touch the missing method, with nothing said about
902
+ // why. Reporting it up front turns that into one clear line.
903
+ disposers.push(ctx.webServer.register({
904
+ kind: "exact",
905
+ path: `${ROUTE_PATH}/health`,
906
+ handler: async (_req, res) => {
907
+ try {
908
+ const sessionController = ctx.get("sessionController");
909
+ const missing = sessionController
910
+ ? REQUIRED_CONTROLLER_METHODS.filter((name) => typeof sessionController[name] !== "function")
911
+ : REQUIRED_CONTROLLER_METHODS.slice();
912
+ sendJson(res, 200, {
913
+ ok: missing.length === 0,
914
+ controllerAvailable: Boolean(sessionController),
915
+ required: REQUIRED_CONTROLLER_METHODS,
916
+ missing,
917
+ });
918
+ } catch (error) {
919
+ sendJson(res, 500, { ok: false, error: String(error?.message ?? error) });
920
+ }
921
+ },
922
+ }));
923
+
882
924
  disposers.push(ctx.webServer.register({
883
925
  kind: "exact",
884
926
  path: ROUTE_PATH,
@@ -886,6 +928,17 @@ export function apply(ctx, config = {}) {
886
928
  }));
887
929
 
888
930
  ctx.logger?.info?.(`phone-bridge listening on ${ROUTE_PATH}`);
931
+ {
932
+ const controller = ctx.get("sessionController");
933
+ const missing = controller
934
+ ? REQUIRED_CONTROLLER_METHODS.filter((name) => typeof controller[name] !== "function")
935
+ : REQUIRED_CONTROLLER_METHODS.slice();
936
+ if (missing.length > 0) {
937
+ ctx.logger?.warn?.(
938
+ `phone-bridge: this DSH build is missing ${missing.join(", ")} on sessionController - the routes that use them will fail. GET ${ROUTE_PATH}/health reports the same list.`,
939
+ );
940
+ }
941
+ }
889
942
 
890
943
  return async () => {
891
944
  for (const dispose of disposers) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-phone-bridge",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
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",