@nicmeriano/spool-server 0.0.3 → 0.0.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.
package/dist/index.js CHANGED
@@ -70,6 +70,8 @@ import { createRequire } from "module";
70
70
  // src/orchestrator/routes/events.ts
71
71
  import { Hono } from "hono";
72
72
  import { streamSSE } from "hono/streaming";
73
+ import { execFile } from "child_process";
74
+ import { platform } from "os";
73
75
  var sseClients = /* @__PURE__ */ new Map();
74
76
  var clientIdCounter = 0;
75
77
  function broadcast(message) {
@@ -124,6 +126,11 @@ function createEventsRoutes(ctx) {
124
126
  app.post("/app-url", async (c) => {
125
127
  const body = await c.req.json();
126
128
  console.error(`[spool] Received app URL: ${body.url}`);
129
+ const host = c.req.header("host") || "localhost:3142";
130
+ const shellUrl = `http://${host}`;
131
+ console.error(`[spool] Opening ${shellUrl}`);
132
+ const cmd = platform() === "darwin" ? "open" : platform() === "win32" ? "start" : "xdg-open";
133
+ execFile(cmd, [shellUrl]);
127
134
  let state = ctx.getState();
128
135
  state = { ...state, appUrl: body.url };
129
136
  ctx.setState(state);