asyx 0.7.1 → 0.7.2
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/README.md +38 -27
- package/package.json +1 -1
- package/src/commands/reject-messages.js +9 -2
- package/src/commands/tunnel.js +8 -7
- package/src/main.js +3 -3
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Agent writes code → dev server starts → asyx tunnel → share HTTPS link
|
|
|
21
21
|
| Account + enroll | **You** (once per machine) | `asyx setup` after [registering](https://www.asyx.ai/register) |
|
|
22
22
|
| Build / edit code | **Agent** | Implements the feature locally |
|
|
23
23
|
| Start dev server | **Agent or you** | `npm run dev`, `vite`, `flask run`, etc. |
|
|
24
|
-
| Open public URL | **Agent or you** (terminal) | `asyx tunnel --http --port <port>` |
|
|
24
|
+
| Open public URL | **Agent or you** (terminal) | `asyx tunnel --http --port <port> --to <your hostname>` |
|
|
25
25
|
| Share the link | **You** | PR comment, Slack, email, client review |
|
|
26
26
|
|
|
27
27
|
Enrollment is human-gated (browser verification) so prompts alone cannot open tunnels from an unbound machine. After `asyx setup`, your agent only needs the port and one tunnel command.
|
|
@@ -30,19 +30,19 @@ Enrollment is human-gated (browser verification) so prompts alone cannot open tu
|
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm install -g asyx # 1. install (Node 18.17+)
|
|
33
|
-
asyx setup # 2. enroll once — approve in the browser
|
|
33
|
+
asyx setup # 2. enroll once — approve in the browser; it prints your hostname
|
|
34
34
|
npm run dev # 3. start your app (note the port, often 3000 or 5173)
|
|
35
|
-
asyx tunnel --http --port 3000 # 4. second terminal
|
|
35
|
+
asyx tunnel --http --port 3000 --to yourname.tunnel.asyx.ai # 4. second terminal
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Share `https://yourname.tunnel.asyx.ai`. Press `Ctrl+C` in the tunnel terminal when the demo ends.
|
|
38
|
+
Share `https://yourname.tunnel.asyx.ai`. Press `Ctrl+C` in the tunnel terminal when the demo ends. (`--to` names the address the tunnel serves; leave it out and the tunnel serves this device's default address, the one `asyx setup` printed. The console shows each address's ready-made commands.)
|
|
39
39
|
|
|
40
40
|
Works with React, Next.js, Vite, Flask, FastAPI, Express, static sites, local LLM UIs—anything speaking HTTP on localhost.
|
|
41
41
|
|
|
42
42
|
Prefer no global install?
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
npx asyx@latest tunnel --http --port 3000
|
|
45
|
+
npx asyx@latest tunnel --http --port 3000 --to yourname.tunnel.asyx.ai
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
### Copy-paste for your agent
|
|
@@ -59,22 +59,24 @@ Prerequisites (human completes once per machine):
|
|
|
59
59
|
show the approval link to the human; the human approves with the code shown.
|
|
60
60
|
|
|
61
61
|
When a local HTTP server is running on PORT:
|
|
62
|
-
1. Run: asyx tunnel --http --port PORT
|
|
63
|
-
2. Return
|
|
62
|
+
1. Run: asyx tunnel --http --port PORT --to HOSTNAME
|
|
63
|
+
2. Return https://HOSTNAME as "public_demo_url"
|
|
64
64
|
3. Do NOT read, print, or commit ~/.asyx/ or any private.pem files
|
|
65
65
|
4. Stop tunnel with Ctrl+C when the user says the demo is over
|
|
66
66
|
|
|
67
67
|
If asyx setup was never run, tell the human to run it before tunneling.
|
|
68
|
+
If the tunnel exits with code 75, the address already has a tunnel of
|
|
69
|
+
that kind: report it to the human; do not add --replace unless told to.
|
|
68
70
|
```
|
|
69
71
|
|
|
70
|
-
Replace `PORT` with the actual port (e.g. `3000`, `5173`, `8080`).
|
|
72
|
+
Replace `PORT` with the actual port (e.g. `3000`, `5173`, `8080`) and `HOSTNAME` with your address (e.g. `orders-api.tunnel.asyx.ai`: printed by `asyx setup` and shown in the console).
|
|
71
73
|
|
|
72
74
|
### Example Cursor prompt
|
|
73
75
|
|
|
74
76
|
```text
|
|
75
77
|
Implement the settings page, run the dev server on port 3000, then run
|
|
76
|
-
asyx tunnel --http --port 3000
|
|
77
|
-
I already ran asyx setup on this machine.
|
|
78
|
+
asyx tunnel --http --port 3000 --to orders-api.tunnel.asyx.ai
|
|
79
|
+
and give me the public demo URL. I already ran asyx setup on this machine.
|
|
78
80
|
```
|
|
79
81
|
|
|
80
82
|
**Can the agent run the tunnel itself?** Yes—if your IDE grants terminal access and `asyx` is installed. Many teams run the tunnel command themselves for visibility.
|
|
@@ -108,9 +110,9 @@ asyx setup
|
|
|
108
110
|
- Running `asyx setup` again on the same machine keeps the same device and hostname (it renews the certificate).
|
|
109
111
|
- Run `asyx setup` on each host you want to trust—certificates are single-device.
|
|
110
112
|
|
|
111
|
-
###
|
|
113
|
+
### Addresses, devices and names
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
Hostnames and ports belong to your **account**, not to one computer. Any device you have set up can serve any address of your account: name it with `--to <hostname>`. Without `--to`, a device serves its **default address**, the hostname it got at setup (an app serves only its own address). Your first device uses your account's name; setting up a further device adds an address for it:
|
|
114
116
|
|
|
115
117
|
```bash
|
|
116
118
|
asyx name check orders-api # is orders-api.tunnel.asyx.ai available? (no setup needed)
|
|
@@ -119,7 +121,7 @@ asyx setup --random # or a generated name such as quiet-otte
|
|
|
119
121
|
asyx setup # or choose on the approval page (it proposes <machine>-<account>)
|
|
120
122
|
```
|
|
121
123
|
|
|
122
|
-
Names use 3–30 characters: lowercase letters, digits and hyphens, starting and ending with a letter or digit. Some names are reserved. How many devices an account can have depends on its plan.
|
|
124
|
+
Names use 3–30 characters: lowercase letters, digits and hyphens, starting and ending with a letter or digit. Some names are reserved. How many devices and addresses an account can have depends on its plan.
|
|
123
125
|
|
|
124
126
|
### For agents and scripts: `--json` and exit codes
|
|
125
127
|
|
|
@@ -144,11 +146,11 @@ On failure the last line is `{"event":"error","error":"<code>",…}` (with `sugg
|
|
|
144
146
|
## HTTP tunnels (most common)
|
|
145
147
|
|
|
146
148
|
```bash
|
|
147
|
-
asyx tunnel --http --port 3000
|
|
149
|
+
asyx tunnel --http --port 3000 --to orders-api.tunnel.asyx.ai
|
|
148
150
|
```
|
|
149
151
|
|
|
150
152
|
- Forwards to your app on localhost (loopback only; works whether it listens on IPv4 `127.0.0.1` or IPv6 `::1`).
|
|
151
|
-
- Prints
|
|
153
|
+
- Prints the address's stable `https://<hostname>.tunnel.asyx.ai` URL (the same on every start, from any of your devices).
|
|
152
154
|
- If your app stops answering, the tunnel stays up: the terminal says so, visitors see a "not reachable" page, and the terminal tells you when the app is answering again.
|
|
153
155
|
- TLS and token refresh handled automatically; your app keeps its port.
|
|
154
156
|
- If the connection drops (network loss, laptop wake, Asyx server maintenance), the CLI reconnects on its own and the same URL comes back.
|
|
@@ -158,7 +160,7 @@ asyx tunnel --http --port 3000
|
|
|
158
160
|
For client-only or team-only previews—not open to the whole internet:
|
|
159
161
|
|
|
160
162
|
```bash
|
|
161
|
-
asyx tunnel --http --port 3000 --secgroup reviewers
|
|
163
|
+
asyx tunnel --http --port 3000 --to orders-api.tunnel.asyx.ai --secgroup reviewers
|
|
162
164
|
```
|
|
163
165
|
|
|
164
166
|
Guests enroll via QuickPass; the relay enforces membership. See https://www.asyx.ai/docs/quickpass
|
|
@@ -172,22 +174,25 @@ All tunnels are loopback-only. The CLI forwards to your existing listener—it n
|
|
|
172
174
|
**TCP** — databases, SSH, games:
|
|
173
175
|
|
|
174
176
|
```bash
|
|
175
|
-
asyx tunnel --tcp --port
|
|
177
|
+
asyx tunnel --tcp --port 5432 --to orders-api.tunnel.asyx.ai
|
|
178
|
+
asyx tunnel --tcp --port 5432 --to orders-api.tunnel.asyx.ai --external-port 10003 # a specific public port
|
|
176
179
|
```
|
|
177
180
|
|
|
178
181
|
**UDP** — games, realtime apps:
|
|
179
182
|
|
|
180
183
|
```bash
|
|
181
|
-
asyx tunnel --udp --port
|
|
184
|
+
asyx tunnel --udp --port 27015 --to orders-api.tunnel.asyx.ai [--external-port <publicPort>]
|
|
182
185
|
```
|
|
183
186
|
|
|
184
187
|
**Minecraft** — shortcut with SRV record (players use hostname only):
|
|
185
188
|
|
|
186
189
|
```bash
|
|
187
|
-
asyx tunnel --minecraft [--port 25565] [--name <alias>]
|
|
190
|
+
asyx tunnel --minecraft --to orders-api.tunnel.asyx.ai [--port 25565] [--name <alias>]
|
|
188
191
|
```
|
|
189
192
|
|
|
190
|
-
|
|
193
|
+
**Public ports.** Your account has 10 TCP and 10 UDP public ports (its block). An address gets one of each kind the first time it opens a TCP or UDP tunnel and keeps it: every restart, from any of your devices, uses the same public port. `--external-port <p>` picks a specific port of your block for the address; a port that already belongs to another of your addresses is refused with its name. Ports are not released automatically.
|
|
194
|
+
|
|
195
|
+
After a tunnel opens, the CLI prints the public hostname (and port for TCP/UDP) plus the local target (`tcp://127.0.0.1:<port>` or `udp://127.0.0.1:<port>`).
|
|
191
196
|
|
|
192
197
|
If the connection of a TCP or UDP tunnel drops (network loss, Asyx server maintenance, or Asyx moving your tunnel to another server), the CLI reconnects on its own and keeps the same hostname and public port. Visitor connections that were open at the moment of the drop end; new ones work as soon as the tunnel is back, usually within seconds. If the service closes the tunnel's lease while the CLI is still running (for example after the computer slept through it), the tunnel reopens on the same hostname and port by itself and says so. The CLI ends if another tunnel took the address over with `--replace`, if reopening is refused, or if it cannot reconnect for 15 minutes.
|
|
193
198
|
|
|
@@ -233,15 +238,19 @@ asyx help # commands; asyx tunnel --help for tunnel options
|
|
|
233
238
|
asyx --version
|
|
234
239
|
asyx setup [--hostname <name> | --random] [--json]
|
|
235
240
|
asyx name check <name> [--json]
|
|
236
|
-
asyx tunnel --http --port <n> [--secgroup <slug>]
|
|
237
|
-
asyx tunnel --tcp --port <n> [--name <alias>] [--external-port <p>]
|
|
238
|
-
asyx tunnel --udp --port <n> [--external-port <p>]
|
|
239
|
-
asyx tunnel --minecraft [--port <n>] [--name <alias>]
|
|
240
|
-
# any tunnel: --
|
|
241
|
+
asyx tunnel --http --port <n> --to <hostname> [--secgroup <slug>]
|
|
242
|
+
asyx tunnel --tcp --port <n> --to <hostname> [--name <alias>] [--external-port <p>]
|
|
243
|
+
asyx tunnel --udp --port <n> --to <hostname> [--external-port <p>]
|
|
244
|
+
asyx tunnel --minecraft --to <hostname> [--port <n>] [--name <alias>]
|
|
245
|
+
# any tunnel: --replace --wait --json (without --to: this device's default address)
|
|
241
246
|
```
|
|
242
247
|
|
|
243
248
|
---
|
|
244
249
|
|
|
250
|
+
## What's new in 0.7.2
|
|
251
|
+
|
|
252
|
+
**Refusals always come with words** — if the cloud refuses a tunnel with a reason this version does not know yet, the CLI now shows the explanation the cloud sends instead of only a code. A device whose setup is incomplete is told to run `asyx setup` again (or contact support), and the tunnel stops with exit code 1.
|
|
253
|
+
|
|
245
254
|
## What's new in 0.7.1
|
|
246
255
|
|
|
247
256
|
**Stopping a tunnel frees its address at once** — on Ctrl-C (or when a service manager stops it) the tunnel tells the cloud it is stopping, so its address and port are free for the next start right away instead of after the lease runs out. This never delays a stop by more than two seconds.
|
|
@@ -340,7 +349,7 @@ Changes since 0.6.1, in short: `--to`, one tunnel of each kind per address (`--r
|
|
|
340
349
|
## Logging
|
|
341
350
|
|
|
342
351
|
```bash
|
|
343
|
-
ASYX_LOG_LEVEL=debug asyx tunnel --http --port 3000
|
|
352
|
+
ASYX_LOG_LEVEL=debug asyx tunnel --http --port 3000 --to orders-api.tunnel.asyx.ai
|
|
344
353
|
```
|
|
345
354
|
|
|
346
355
|
Levels: `error` | `warn` | `info` | `debug` (default `info`).
|
|
@@ -360,7 +369,9 @@ Levels: `error` | `warn` | `info` | `debug` (default `info`).
|
|
|
360
369
|
| Tunnel URL 502 / unreachable | Dev server not running on the same port |
|
|
361
370
|
| Link stops while the computer sleeps | Expected—the tunnel serves only while the CLI runs and the machine is awake; when it wakes, the tunnel reconnects (and reopens its lease if needed) on the same address |
|
|
362
371
|
| TCP/UDP tunnel ended after an outage | It retries for 15 minutes, then exits; run the same command again (raise `ASYX_TUNNEL_RECONNECT_MAX_MS` for longer outages) |
|
|
363
|
-
| External port rejected | `--external-port` must be inside your
|
|
372
|
+
| External port rejected | `--external-port` must be inside your account's 10-port block and not belong to another of your addresses (the message names it) |
|
|
373
|
+
| "… is not an address of this account" | Check the `--to` hostname; it must be one of your account's addresses (see the console) |
|
|
374
|
+
| "This device is not set up for your account yet" | Run `asyx setup` again on that computer; if it persists, contact support@asyx.ai |
|
|
364
375
|
| Windows: secure connection fails at startup | Re-run `asyx setup` to regenerate the device key |
|
|
365
376
|
|
|
366
377
|
---
|
package/package.json
CHANGED
|
@@ -101,9 +101,16 @@ export function printOpenReject({ code, reason, data }) {
|
|
|
101
101
|
process.exit(1);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
+
// Story 2.12 c3: should never happen; the coordinator sends the words (shown as sent), with ours as fallback.
|
|
105
|
+
case 'account_not_migrated': {
|
|
106
|
+
process.stderr.write(`${d.message || 'This device is not set up for your account yet. Run asyx setup again on this computer; if that does not help, contact support@asyx.ai.'}\n`);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
104
110
|
default:
|
|
105
|
-
// Not fatal: print and keep running (e.g. a refused renewal).
|
|
106
|
-
|
|
111
|
+
// Not fatal: print and keep running (e.g. a refused renewal). Story 2.12: a message the coordinator
|
|
112
|
+
// sends with a reason this CLI does not know is shown rather than a bare code.
|
|
113
|
+
process.stdout.write(`❌ Connection rejected${reason ? ` (${reason})` : ''}${typeof d.message === 'string' && d.message ? `: ${d.message}` : ''}\n`);
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
|
package/src/commands/tunnel.js
CHANGED
|
@@ -34,22 +34,23 @@ export default async function tunnel(args = []) {
|
|
|
34
34
|
if (parsed.help || args.length === 0) {
|
|
35
35
|
logger.info("cli.help", {});
|
|
36
36
|
process.stdout.write(`Usage:
|
|
37
|
-
asyx tunnel --http --port <n> [--secgroup <slug>]
|
|
37
|
+
asyx tunnel --http --port <n> --to <hostname> [--secgroup <slug>]
|
|
38
38
|
HTTP tunnel: a public HTTPS URL for a web app on localhost:<n>.
|
|
39
39
|
--secgroup <slug> QuickPass security group; only its members can open the URL
|
|
40
40
|
|
|
41
|
-
asyx tunnel --tcp --port <n> [--name <alias>] [--external-port <p>]
|
|
41
|
+
asyx tunnel --tcp --port <n> --to <hostname> [--name <alias>] [--external-port <p>]
|
|
42
42
|
TCP tunnel: a public TCP port for a service on localhost:<n> (databases, SSH, games).
|
|
43
43
|
|
|
44
|
-
asyx tunnel --udp --port <n> [--external-port <p>]
|
|
44
|
+
asyx tunnel --udp --port <n> --to <hostname> [--external-port <p>]
|
|
45
45
|
UDP tunnel: a public UDP port for a service on localhost:<n> (games, realtime apps).
|
|
46
46
|
|
|
47
|
-
asyx tunnel --minecraft [--port <n>] [--name <alias>]
|
|
47
|
+
asyx tunnel --minecraft --to <hostname> [--port <n>] [--name <alias>]
|
|
48
48
|
Minecraft server (default port 25565); players connect with the hostname only.
|
|
49
49
|
|
|
50
|
-
--to <hostname> the address this tunnel serves, e.g. --to orders-api.tunnel.asyx.ai
|
|
51
|
-
|
|
52
|
-
--external-port <p>
|
|
50
|
+
--to <hostname> the address this tunnel serves, e.g. --to orders-api.tunnel.asyx.ai: any
|
|
51
|
+
address of your account; without it, this device's default address
|
|
52
|
+
--external-port <p> a specific public port of your account's 10-port block (it then belongs
|
|
53
|
+
to that address); without it, the address keeps its own port
|
|
53
54
|
--replace take over this address's running tunnel of the same kind (it is told and stops)
|
|
54
55
|
--wait if the address already runs this kind, keep trying every 30 s instead of exiting
|
|
55
56
|
--json print refusals as JSON
|
package/src/main.js
CHANGED
|
@@ -39,9 +39,9 @@ Usage: asyx <command>
|
|
|
39
39
|
asyx setup
|
|
40
40
|
asyx setup --hostname orders-api (or --random; add --json for agents)
|
|
41
41
|
asyx name check orders-api
|
|
42
|
-
asyx tunnel --http --port 3000
|
|
43
|
-
asyx tunnel --tcp --port 5432
|
|
44
|
-
asyx tunnel --udp --port 27015
|
|
42
|
+
asyx tunnel --http --port 3000 --to orders-api.tunnel.asyx.ai
|
|
43
|
+
asyx tunnel --tcp --port 5432 --to orders-api.tunnel.asyx.ai
|
|
44
|
+
asyx tunnel --udp --port 27015 --to orders-api.tunnel.asyx.ai
|
|
45
45
|
|
|
46
46
|
Options for each tunnel type: asyx tunnel --help
|
|
47
47
|
Documentation: https://www.asyx.ai/docs
|