agent-host-protocol-ui 0.1.0 → 0.1.1

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 +11 -3
  2. package/bin/cli.js +60 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -90,14 +90,22 @@ Launch the UI directly in your browser without cloning or installing:
90
90
  npx agent-host-protocol-ui
91
91
  ```
92
92
 
93
- You can optionally pre-configure the host URL and specify a port:
93
+ #### CLI Options & External Network Access
94
94
 
95
95
  ```sh
96
- # Pre-configure your local or remote host connection
97
- npx agent-host-protocol-ui --host "ws://127.0.0.1:63877?tkn=your-token"
96
+ # Serve on all network interfaces (0.0.0.0) so it is accessible externally
97
+ npx agent-host-protocol-ui --host 0.0.0.0
98
+ # or:
99
+ npx agent-host-protocol-ui --bind 0.0.0.0
100
+
101
+ # Pre-configure your local or remote agent host connection
102
+ npx agent-host-protocol-ui --agent-host "ws://127.0.0.1:63877?tkn=your-token"
98
103
 
99
104
  # Specify a custom port
100
105
  npx agent-host-protocol-ui --port 3000
106
+
107
+ # Run headless without opening local browser (e.g. in remote VM or container)
108
+ npx agent-host-protocol-ui --bind 0.0.0.0 --port 8080 --no-open
101
109
  ```
102
110
 
103
111
  ---
package/bin/cli.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import { exec } from "node:child_process";
4
4
  import { existsSync, readFileSync, statSync } from "node:fs";
5
5
  import http from "node:http";
6
+ import os from "node:os";
6
7
  import path from "node:path";
7
8
  import { fileURLToPath } from "node:url";
8
9
 
@@ -24,11 +25,31 @@ const MIME_TYPES = {
24
25
  ".woff2": "font/woff2",
25
26
  };
26
27
 
28
+ function getNetworkIps() {
29
+ const ips = [];
30
+ try {
31
+ const interfaces = os.networkInterfaces();
32
+ for (const name of Object.keys(interfaces)) {
33
+ const netInterface = interfaces[name];
34
+ if (!netInterface) continue;
35
+ for (const iface of netInterface) {
36
+ if (iface.family === "IPv4" && !iface.internal) {
37
+ ips.push(iface.address);
38
+ }
39
+ }
40
+ }
41
+ } catch {
42
+ // ignore network interface errors
43
+ }
44
+ return ips;
45
+ }
46
+
27
47
  // Parse command line arguments
28
48
  const args = process.argv.slice(2);
29
49
  let port = 5173;
50
+ let listenHost = "localhost";
30
51
  let autoOpen = true;
31
- let hostParam = "";
52
+ let agentHostParam = "";
32
53
 
33
54
  for (let i = 0; i < args.length; i++) {
34
55
  const arg = args[i];
@@ -36,8 +57,23 @@ for (let i = 0; i < args.length; i++) {
36
57
  port = Number.parseInt(args[++i], 10) || 5173;
37
58
  } else if (arg === "--no-open") {
38
59
  autoOpen = false;
60
+ } else if (arg === "--bind" || arg === "-b" || arg === "--hostname" || arg === "--listen") {
61
+ listenHost = args[++i] || "0.0.0.0";
39
62
  } else if (arg === "--host" || arg === "-h") {
40
- hostParam = args[++i] || "";
63
+ const next = args[i + 1];
64
+ if (!next || next.startsWith("-")) {
65
+ // Flag present without value: bind to 0.0.0.0 (like Vite --host)
66
+ listenHost = "0.0.0.0";
67
+ } else {
68
+ i++;
69
+ if (next.startsWith("ws://") || next.startsWith("wss://")) {
70
+ agentHostParam = next;
71
+ } else {
72
+ listenHost = next;
73
+ }
74
+ }
75
+ } else if (arg === "--agent-host" || arg === "--ws" || arg === "-a") {
76
+ agentHostParam = args[++i] || "";
41
77
  } else if (arg === "--help") {
42
78
  console.log(`
43
79
  agent-host-protocol-ui - Client-side UI for Agent Host Protocol
@@ -46,10 +82,12 @@ Usage:
46
82
  npx agent-host-protocol-ui [options]
47
83
 
48
84
  Options:
49
- -p, --port <number> Port to listen on (default: 5173)
50
- -h, --host <ws-url> Pre-configure host WebSocket URL
51
- --no-open Do not automatically open the browser
52
- --help Show help
85
+ -b, --bind <address> Hostname/IP to listen on (e.g. 0.0.0.0 or localhost, default: localhost)
86
+ --host [address] Bind to address (default: 0.0.0.0 if flag present without value)
87
+ -p, --port <number> Port to listen on (default: 5173)
88
+ -a, --agent-host <ws-url> Pre-configure agent host WebSocket URL
89
+ --no-open Do not automatically open the browser
90
+ --help Show help
53
91
  `);
54
92
  process.exit(0);
55
93
  }
@@ -107,29 +145,37 @@ server.on("error", (err) => {
107
145
  if (err && typeof err === "object" && "code" in err && err.code === "EADDRINUSE") {
108
146
  console.log(`Port ${port} in use, trying ${port + 1}...`);
109
147
  port++;
110
- server.listen(port);
148
+ server.listen(port, listenHost);
111
149
  } else {
112
150
  console.error("Server error:", err);
113
151
  process.exit(1);
114
152
  }
115
153
  });
116
154
 
117
- server.listen(port, () => {
118
- let targetUrl = `http://localhost:${port}`;
119
- if (hostParam) {
120
- targetUrl += `?host=${encodeURIComponent(hostParam)}`;
121
- }
155
+ server.listen(port, listenHost, () => {
156
+ const isWildcard = listenHost === "0.0.0.0" || listenHost === "::";
157
+ const querySuffix = agentHostParam ? `?host=${encodeURIComponent(agentHostParam)}` : "";
158
+ const localUrl = `http://localhost:${port}${querySuffix}`;
159
+ const networkIps = isWildcard ? getNetworkIps() : [];
160
+
122
161
  console.log(`
123
162
  ┌────────────────────────────────────────────────────────┐
124
163
  │ │
125
164
  │ Agent Host Protocol UI │
126
- │ Running at: ${targetUrl.padEnd(41)}│
127
165
  │ │
166
+ │ > Local: ${localUrl.padEnd(42)}│`);
167
+
168
+ for (const ip of networkIps) {
169
+ const netUrl = `http://${ip}:${port}${querySuffix}`;
170
+ console.log(`│ > Network: ${netUrl.padEnd(42)}│`);
171
+ }
172
+
173
+ console.log(`│ │
128
174
  │ Press Ctrl+C to stop │
129
175
  └────────────────────────────────────────────────────────┘
130
176
  `);
131
177
  if (autoOpen) {
132
- openBrowser(targetUrl);
178
+ openBrowser(localUrl);
133
179
  }
134
180
  });
135
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-host-protocol-ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Client-side web UI for the Agent Host Protocol (AHP) inspired by VS Code Agents view",
5
5
  "author": "Yusuke Tsutsumi <yusuke@tsutsumi.io>",
6
6
  "license": "Apache-2.0",