@m64/nats-agent-dashboard 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 m64
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing permissions
201
+ and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # nats-agent-dashboard
2
+
3
+ A static Vue 3 web UI that connects directly to a NATS server over WebSocket and provides a unified dashboard for the entire NATS AI agent network. Discover, inspect, prompt and manage agents across all four runtimes from a single screen — **with no backend server**. NATS is the only data channel.
4
+
5
+ Supported runtimes (auto-detected from `$SRV.PING` + metadata):
6
+
7
+ - **`pi-channel`** — interactive PI agents (`agents.pi.[{org}.]{owner}.{session}`)
8
+ - **`pi-exec`** — headless PI bridge with intake + per-session services (`agents.pi-exec.{owner}[.{sessionId}]`)
9
+ - **`claude-channel`** — Claude Code MCP bridge (`agents.ccc.{owner}.{session}`)
10
+ - **`nats-channel` / OpenClaw** — OpenClaw plugin agents (`agents.oc.[{org}.]{name}`)
11
+
12
+ The visual design language and architectural patterns are copied from the **REMEMBRA** web UI to keep this dashboard consistent with the rest of the product family.
13
+
14
+ ## Features
15
+
16
+ - **Live agent grid** — periodic `$SRV.PING` discovery, grouped by runtime, color-coded badges, status dots, automatic removal when agents disappear from the bus.
17
+ - **Streaming prompt panel** — pick any agent, type a prompt, watch the response render token-by-token as live markdown (with code-block syntax highlighting and copy buttons).
18
+ - **Pi-exec session control plane** — create new headless sessions with cwd / model / thinking-level / lifetime, stop them, and see live `list`-enriched details (remaining lifetime, queue depth, active request) on every session card.
19
+ - **Fan-out** — run the same prompt across N working directories in parallel, with grouped streaming result cards.
20
+ - **Connection settings** — change the NATS WebSocket URL on the fly with auto-reconnect.
21
+
22
+ ## Tech stack
23
+
24
+ - [Vue 3](https://vuejs.org/) (Composition API, `<script setup>`)
25
+ - [Vite](https://vitejs.dev/) — dev server + bundler
26
+ - [`@nats-io/nats-core`](https://www.npmjs.com/package/@nats-io/nats-core) v3 + `wsconnect()` — the only transport
27
+ - [`@nats-io/services`](https://www.npmjs.com/package/@nats-io/services) v3 — `Svcm` discovery client
28
+ - [marked](https://www.npmjs.com/package/marked) + [DOMPurify](https://www.npmjs.com/package/dompurify) + [highlight.js](https://www.npmjs.com/package/highlight.js) — markdown rendering for streaming responses
29
+
30
+ No router, no Pinia, no backend, no REST, no SSE. State is plain `reactive()` modules — same pattern REMEMBRA uses.
31
+
32
+ ## Distribution
33
+
34
+ The dashboard ships in three forms. All three are built from the same source and show the same UI:
35
+
36
+ ### 1. Single HTML file — the demo-killer
37
+
38
+ `npm run build` produces exactly one file: `dist/index.html` (~450 KB, ~140 KB gzipped). Everything — Vue, the stores, the markdown renderer, the NATS client, the CSS — is inlined. You can:
39
+
40
+ - double-click it from any file manager (loads via `file://`)
41
+ - email it / drop it on a USB stick
42
+ - host it on any static web server (GitHub Pages, S3, Netlify, nginx, a goddamn FTP drop)
43
+
44
+ Out of the box it connects to **`wss://demo.nats.io:8443`** — Synadia's public demo server — so double-clicking the HTML file Just Works with zero local setup. Change the URL via the Settings cog (persists to localStorage), or pre-seed it via the query string:
45
+
46
+ ```
47
+ file:///tmp/index.html?nats=ws://localhost:8080
48
+ https://my-host/dashboard.html?nats=wss://nats.example.com:443
49
+ ```
50
+
51
+ No install, no Node, no npm, no setup. **For a demo, this is the one to share.**
52
+
53
+ ### 2. `npx` launcher
54
+
55
+ ```bash
56
+ npx @m64/nats-agent-dashboard
57
+ ```
58
+
59
+ Downloads the package (~150 KB, no runtime deps besides Node built-ins), spawns a tiny HTTP server on `http://localhost:5173` that serves the same single HTML file, and opens your default browser. Good for daily use where you want a consistent URL and a real `http://` origin. Connects to `wss://demo.nats.io:8443` by default, same as the single HTML file.
60
+
61
+ Flags:
62
+
63
+ ```bash
64
+ npx @m64/nats-agent-dashboard --nats-url ws://localhost:8080 # override the NATS URL
65
+ npx @m64/nats-agent-dashboard --port 8000 # pick a port
66
+ npx @m64/nats-agent-dashboard --no-open # don't open browser
67
+ npx @m64/nats-agent-dashboard --help
68
+ ```
69
+
70
+ ### 3. Local dev
71
+
72
+ For contributing to the dashboard itself, with hot reload and source maps:
73
+
74
+ ```bash
75
+ git clone …
76
+ npm install
77
+ npm run dev # Vite dev server at http://localhost:5173
78
+ ```
79
+
80
+ ## Running a NATS server with WebSocket
81
+
82
+ All three distributions need a NATS server with WebSocket enabled. Minimal config:
83
+
84
+ ```hocon
85
+ # nats.conf
86
+ port: 4222
87
+
88
+ websocket {
89
+ port: 8080
90
+ no_tls: true
91
+ }
92
+ ```
93
+
94
+ ```bash
95
+ nats-server -c nats.conf
96
+ ```
97
+
98
+ For production / remote access, add TLS:
99
+
100
+ ```hocon
101
+ websocket {
102
+ port: 443
103
+ tls {
104
+ cert_file: "/etc/letsencrypt/live/nats.example.com/fullchain.pem"
105
+ key_file: "/etc/letsencrypt/live/nats.example.com/privkey.pem"
106
+ }
107
+ }
108
+ ```
109
+
110
+ Then connect the dashboard to `wss://nats.example.com:443`.
111
+
112
+ ## Spinning up some agents
113
+
114
+ In separate terminals, start one or more of:
115
+
116
+ ```bash
117
+ # PI exec headless bridge (intake + per-session sub-services)
118
+ cd ../nats-pi-bridge && npm run dev
119
+
120
+ # PI interactive in any project that loads the nats-pi-channel extension
121
+ cd ~/some-project && pi
122
+
123
+ # Claude Code NATS bridge
124
+ cd ../nats-claude-channel && bun server.ts
125
+
126
+ # OpenClaw with the NATS channel plugin enabled — depends on your setup
127
+ ```
128
+
129
+ Within ~5 s the agents pop into the dashboard grid, grouped by runtime. Click any card to prompt it. Click a pi-exec control card to create a new session or fan out across multiple directories.
130
+
131
+ ## Architecture
132
+
133
+ ```
134
+ Browser
135
+ Vue 3 app (static)
136
+ ┌─────────────────────────────────────┐
137
+ │ @nats-io/nats-core wsconnect() │ ←── single WebSocket connection
138
+ │ │
139
+ │ Discovery $SRV.INFO via Svcm │
140
+ │ Inspect {subject}.inspect │
141
+ │ Prompt agents.<type>.… │
142
+ │ Control agents.pi-exec.{owner} │
143
+ └─────────────────────────────────────┘
144
+
145
+ │ ws:// or wss://
146
+
147
+ NATS Server (websocket port)
148
+ ```
149
+
150
+ State is split into plain `reactive()` modules in `src/stores/`:
151
+
152
+ | Store | Responsibility |
153
+ |---|---|
154
+ | `natsConnection.js` | `wsconnect()` lifecycle, status async iterator, persisted config |
155
+ | `agentDiscovery.js` | Periodic `Svcm.client(nc).info()`, categorisation into runtime buckets, reactive `Map<id, AgentRecord>` with grace-window removal |
156
+ | `piexecState.js` | Periodic `sessionMode: "list"` enrichment of pi-exec session records (lifetime, queue, active request) |
157
+ | `promptState.js` | Per-agent streaming chat sessions, in-memory only |
158
+ | `fanoutState.js` | Fan-out form + parallel run state |
159
+ | `appState.js` | Selected agent + UI flags |
160
+
161
+ The `useNatsRequest.js` composable wraps the streaming reply pattern: create an inbox, subscribe, publish with `reply: inbox`, accumulate chunks, treat empty payload as end-of-stream sentinel. This pattern is verified verbatim against all four sibling channel servers — see `DESIGN.md` for the protocol details and source references.
162
+
163
+ The visual design tokens, base CSS, markdown styles and `useMarkdown` composable are copied verbatim from `/home/m64/space/ai/remembra/web/src/` so the dashboard looks like it belongs in the same product family.
164
+
165
+ ## Build from source
166
+
167
+ ```bash
168
+ npm install
169
+ npm run build # produces dist/index.html (single self-contained file)
170
+ npm run preview # serves dist/ for local smoke-testing
171
+ npm start # runs the npx launcher against dist/
172
+ ```
173
+
174
+ The build uses [`vite-plugin-singlefile`](https://github.com/richardtallent/vite-plugin-singlefile) with `base: './'` to inline everything into a single HTML file that's loadable from `file://`, any static host, or the bundled npx launcher. There is no server-side runtime and no backend.
175
+
176
+ Every third-party package bundled into `dist/index.html` has its copyright notice and full license text aggregated into `dist/THIRD-PARTY-LICENSES.txt` at build time (via [`rollup-plugin-license`](https://github.com/mjeanroy/rollup-plugin-license)), so redistributing the single HTML file preserves the notice-retention clauses in MIT / BSD / Apache / MPL.
177
+
178
+ ## What's not in v1
179
+
180
+ - Authentication UI (relies on the NATS server's own auth: token / nkey / creds)
181
+ - Persistent prompt history (each page reload starts fresh)
182
+ - Session export viewer (the pi-bridge doesn't auto-export yet — revisit when it does)
183
+ - Multi-user awareness, theming, mobile layout, A2A protocol UI
184
+
185
+
186
+ ## License
187
+
188
+ Same license as the rest of the family.
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * nats-agent-dashboard launcher
4
+ *
5
+ * Serves the single-file build (dist/index.html) on a local port and
6
+ * opens it in the user's default browser. Zero dependencies — uses only
7
+ * Node's built-in `http` module.
8
+ *
9
+ * Usage:
10
+ * npx @m64/nats-agent-dashboard [options]
11
+ *
12
+ * Options:
13
+ * --port, -p <n> Port to listen on (default 5173, auto-increments if taken)
14
+ * --nats-url, -u <url> Default NATS WebSocket URL (pre-seeds the dashboard)
15
+ * --no-open Don't open the browser automatically
16
+ * --help, -h Show this help
17
+ */
18
+ import { createServer } from 'node:http'
19
+ import { readFileSync } from 'node:fs'
20
+ import { dirname, join } from 'node:path'
21
+ import { fileURLToPath } from 'node:url'
22
+ import { spawn } from 'node:child_process'
23
+
24
+ const __dirname = dirname(fileURLToPath(import.meta.url))
25
+ const indexPath = join(__dirname, '..', 'dist', 'index.html')
26
+
27
+ // ── Load the single-file build ────────────────────────────────────────────
28
+ let html
29
+ try {
30
+ html = readFileSync(indexPath)
31
+ } catch (err) {
32
+ console.error(
33
+ `\n nats-agent-dashboard: could not read ${indexPath}\n` +
34
+ ` (did the package include the dist/ folder? run \`npm run build\` if you're developing locally)\n`,
35
+ )
36
+ process.exit(1)
37
+ }
38
+
39
+ // ── Parse CLI flags ───────────────────────────────────────────────────────
40
+ const args = process.argv.slice(2)
41
+ let portArg = null
42
+ let natsArg = null
43
+ let ownerArg = null
44
+ let openBrowser = true
45
+
46
+ for (let i = 0; i < args.length; i++) {
47
+ const a = args[i]
48
+ if (a === '--port' || a === '-p') portArg = Number(args[++i])
49
+ else if (a === '--nats-url' || a === '-u') natsArg = args[++i]
50
+ else if (a === '--owner') ownerArg = args[++i]
51
+ else if (a === '--no-open') openBrowser = false
52
+ else if (a === '--help' || a === '-h') { printHelp(); process.exit(0) }
53
+ else {
54
+ console.error(`unknown option: ${a}`)
55
+ printHelp()
56
+ process.exit(1)
57
+ }
58
+ }
59
+
60
+ function printHelp() {
61
+ console.log(`
62
+ nats-agent-dashboard — static dashboard for the NATS AI agent network
63
+
64
+ usage:
65
+ npx @m64/nats-agent-dashboard [options]
66
+
67
+ options:
68
+ -p, --port <n> Port to listen on (default: 5173)
69
+ -u, --nats-url <url> Default NATS WebSocket URL to seed the dashboard with
70
+ --owner <name> Override the auto-detected owner name
71
+ --no-open Don't open the browser automatically
72
+ -h, --help Show this help
73
+
74
+ examples:
75
+ npx @m64/nats-agent-dashboard
76
+ npx @m64/nats-agent-dashboard -u ws://localhost:8080
77
+ npx @m64/nats-agent-dashboard -u wss://nats.example.com:443 -p 8000
78
+ `)
79
+ }
80
+
81
+ // ── Serve the single HTML file ────────────────────────────────────────────
82
+ const server = createServer((req, res) => {
83
+ res.setHeader('Content-Type', 'text/html; charset=utf-8')
84
+ res.setHeader('Cache-Control', 'no-store')
85
+ res.end(html)
86
+ })
87
+
88
+ const startPort = portArg ?? Number(process.env.PORT) ?? 5173
89
+
90
+ tryPort(startPort)
91
+
92
+ function tryPort(port, attemptsLeft = 10) {
93
+ const onError = (err) => {
94
+ if (err.code === 'EADDRINUSE' && attemptsLeft > 0) {
95
+ tryPort(port + 1, attemptsLeft - 1)
96
+ } else {
97
+ console.error(`failed to bind port ${port}: ${err.message}`)
98
+ process.exit(1)
99
+ }
100
+ }
101
+ server.once('error', onError)
102
+ server.listen(port, '127.0.0.1', () => {
103
+ server.removeListener('error', onError)
104
+ const { port: actualPort } = server.address()
105
+ printBanner(actualPort)
106
+ })
107
+ }
108
+
109
+ function printBanner(port) {
110
+ const query = new URLSearchParams()
111
+ if (natsArg) query.set('nats', natsArg)
112
+ if (ownerArg) query.set('owner', ownerArg)
113
+ const qs = query.toString()
114
+ const url = `http://localhost:${port}/${qs ? `?${qs}` : ''}`
115
+
116
+ console.log('')
117
+ console.log(' \x1b[35m● nats-agent-dashboard\x1b[0m')
118
+ console.log(` \x1b[90mhttp://localhost:${port}\x1b[0m`)
119
+ if (natsArg) console.log(` \x1b[90m→ seeding NATS URL: ${natsArg}\x1b[0m`)
120
+ if (ownerArg) console.log(` \x1b[90m→ owner override: ${ownerArg}\x1b[0m`)
121
+ console.log('')
122
+ console.log(' press Ctrl+C to stop')
123
+ console.log('')
124
+
125
+ if (openBrowser) tryOpenBrowser(url)
126
+ }
127
+
128
+ function tryOpenBrowser(url) {
129
+ const platform = process.platform
130
+ try {
131
+ if (platform === 'darwin') {
132
+ spawn('open', [url], { stdio: 'ignore', detached: true }).unref()
133
+ } else if (platform === 'win32') {
134
+ spawn('cmd.exe', ['/c', 'start', '', url], { stdio: 'ignore', detached: true }).unref()
135
+ } else {
136
+ spawn('xdg-open', [url], { stdio: 'ignore', detached: true }).unref()
137
+ }
138
+ } catch {
139
+ // Silent — the URL is already printed above, user can copy it
140
+ }
141
+ }
142
+
143
+ process.on('SIGINT', () => {
144
+ server.close(() => process.exit(0))
145
+ })
146
+ process.on('SIGTERM', () => {
147
+ server.close(() => process.exit(0))
148
+ })