@morlay/dsh-desktop-host 0.0.1-alpha.4 → 0.0.1-alpha.5

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.
@@ -10,9 +10,9 @@
10
10
 
11
11
  - insert:
12
12
  - id: portless-webserver
13
- name: '../lib/webserver.js'
13
+ name: "../lib/webserver.js"
14
14
  config:
15
- host: '127.0.0.1'
15
+ host: "127.0.0.1"
16
16
  port: 0
17
17
 
18
18
  - id: web-runtime
package/lib/index.js CHANGED
@@ -5867,9 +5867,9 @@ function streamHandler(ctx) {
5867
5867
  response.end("gateway unavailable");
5868
5868
  return;
5869
5869
  }
5870
- let body;
5870
+ let parsed;
5871
5871
  try {
5872
- body = await readJsonBody(request);
5872
+ parsed = await readJsonBody(request);
5873
5873
  } catch (error) {
5874
5874
  reportStreamFailure("stream body is not JSON", error);
5875
5875
  response.writeHead(400);
@@ -5877,17 +5877,18 @@ function streamHandler(ctx) {
5877
5877
  return;
5878
5878
  }
5879
5879
  const endpointFromQuery = new URL(request.url ?? "/", "http://127.0.0.1").searchParams.get("endpoint");
5880
- if (!isRecord(body) && endpointFromQuery === null) {
5880
+ if (!isRecord(parsed) && endpointFromQuery === null) {
5881
5881
  reportStreamFailure("empty stream request", String(request.url));
5882
5882
  response.writeHead(400);
5883
5883
  response.end("invalid stream request");
5884
5884
  return;
5885
5885
  }
5886
- if (!isRecord(body)) body = {
5886
+ const body = isRecord(parsed) ? parsed : {
5887
5887
  endpoint: endpointFromQuery,
5888
5888
  payload: { args: {} }
5889
5889
  };
5890
- if (typeof body.endpoint !== "string") {
5890
+ const endpoint = body.endpoint;
5891
+ if (typeof endpoint !== "string") {
5891
5892
  reportStreamFailure("invalid stream request", JSON.stringify(body).slice(0, 200));
5892
5893
  response.writeHead(400);
5893
5894
  response.end("invalid stream request");
@@ -5900,9 +5901,9 @@ function streamHandler(ctx) {
5900
5901
  request.once("aborted", cancel);
5901
5902
  response.once("close", cancel);
5902
5903
  try {
5903
- console.error(`[dsh-desktop] stream opening ${body.endpoint}`);
5904
- const values = await gateway.wireStream.open(body.endpoint, body.payload, abort.signal);
5905
- console.error(`[dsh-desktop] stream opened ${body.endpoint}`);
5904
+ console.error(`[dsh-desktop] stream opening ${endpoint}`);
5905
+ const values = await gateway.wireStream.open(endpoint, body.payload, abort.signal);
5906
+ console.error(`[dsh-desktop] stream opened ${endpoint}`);
5906
5907
  response.writeHead(200, {
5907
5908
  "content-type": "application/x-ndjson",
5908
5909
  "cache-control": "no-store"
@@ -5910,7 +5911,7 @@ function streamHandler(ctx) {
5910
5911
  for await (const value of values) response.write(`${JSON.stringify(value)}\n`);
5911
5912
  response.end();
5912
5913
  } catch (error) {
5913
- reportStreamFailure(`stream ${body.endpoint} failed`, error);
5914
+ reportStreamFailure(`stream ${endpoint} failed`, error);
5914
5915
  if (response.headersSent) {
5915
5916
  response.destroy(error instanceof Error ? error : new Error(String(error)));
5916
5917
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morlay/dsh-desktop-host",
3
- "version": "0.0.1-alpha.4",
3
+ "version": "0.0.1-alpha.5",
4
4
  "description": "Desktop host process for dsh-desktopify: boots the desktop profile and serves it through an in-process, portless webServer over byte pipes — upstream apps/desktop-host with the web carrier taken over and the Office skill mount removed.",
5
5
  "keywords": [
6
6
  "desktop",