@m64/nats-agent-dashboard 0.1.2 → 0.1.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/bin/dashboard.js +21 -2
  2. package/package.json +1 -1
package/bin/dashboard.js CHANGED
@@ -43,9 +43,25 @@ let natsArg = null
43
43
  let ownerArg = null
44
44
  let openBrowser = true
45
45
 
46
+ /** Parse a port value; returns null if missing or invalid. */
47
+ function parsePort(raw) {
48
+ if (raw == null || raw === '') return null
49
+ const n = Number(raw)
50
+ if (!Number.isFinite(n) || n < 0 || n > 65535) return null
51
+ return n
52
+ }
53
+
46
54
  for (let i = 0; i < args.length; i++) {
47
55
  const a = args[i]
48
- if (a === '--port' || a === '-p') portArg = Number(args[++i])
56
+ if (a === '--port' || a === '-p') {
57
+ const raw = args[++i]
58
+ const parsed = parsePort(raw)
59
+ if (parsed == null) {
60
+ console.error(`invalid port: "${raw}" (must be 0-65535)`)
61
+ process.exit(1)
62
+ }
63
+ portArg = parsed
64
+ }
49
65
  else if (a === '--nats-url' || a === '-u') natsArg = args[++i]
50
66
  else if (a === '--owner') ownerArg = args[++i]
51
67
  else if (a === '--no-open') openBrowser = false
@@ -85,7 +101,10 @@ const server = createServer((req, res) => {
85
101
  res.end(html)
86
102
  })
87
103
 
88
- const startPort = portArg ?? Number(process.env.PORT) ?? 5173
104
+ // `??` only fires on null/undefined, NOT on NaN. Without parsePort(), a
105
+ // missing PORT env var would give `Number(undefined) === NaN`, which then
106
+ // skips the `?? 5173` fallback and lands `NaN` in server.listen().
107
+ const startPort = portArg ?? parsePort(process.env.PORT) ?? 5173
89
108
 
90
109
  tryPort(startPort)
91
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m64/nats-agent-dashboard",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "Static Vue 3 dashboard for the NATS AI agent network — discover, prompt and manage agents across pi-channel, pi-exec, claude-channel and OpenClaw runtimes from a single screen, with no backend. Ships as a single HTML file or via npx.",
6
6
  "license": "Apache-2.0",