@dev-anywhere/relay 0.0.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.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/chaos.d.ts +22 -0
- package/dist/chaos.d.ts.map +1 -0
- package/dist/chunk-TBYEKF42.js +1487 -0
- package/dist/chunk-TBYEKF42.js.map +1 -0
- package/dist/handlers/client.d.ts +6 -0
- package/dist/handlers/client.d.ts.map +1 -0
- package/dist/handlers/proxy.d.ts +6 -0
- package/dist/handlers/proxy.d.ts.map +1 -0
- package/dist/health.d.ts +4 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/heartbeat.d.ts +3 -0
- package/dist/heartbeat.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +59 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/router.d.ts +22 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +8 -0
- package/dist/server.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 catli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @dev-anywhere/relay
|
|
2
|
+
|
|
3
|
+
Relay server for [`@dev-anywhere/proxy`](https://www.npmjs.com/package/@dev-anywhere/proxy) — bridges local AI CLI proxies to remote web clients via WebSocket.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @dev-anywhere/relay
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This installs the `dev-anywhere-relay` command globally.
|
|
12
|
+
|
|
13
|
+
Requires Node.js >= 20.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Minimal, plaintext WS on port 3100:
|
|
19
|
+
PORT=3100 dev-anywhere-relay
|
|
20
|
+
|
|
21
|
+
# With auth tokens (recommended for any public relay):
|
|
22
|
+
RELAY_PROXY_TOKEN="$(openssl rand -hex 24)" \
|
|
23
|
+
RELAY_CLIENT_TOKEN="$(openssl rand -hex 24)" \
|
|
24
|
+
PORT=3100 dev-anywhere-relay
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Endpoints
|
|
28
|
+
|
|
29
|
+
| Path | Purpose |
|
|
30
|
+
| --------- | --------------------------------------- |
|
|
31
|
+
| `/health` | HTTP GET — health probe |
|
|
32
|
+
| `/status` | HTTP GET — proxy/client counts |
|
|
33
|
+
| `/proxy` | WS — proxy daemon connection |
|
|
34
|
+
| `/client` | WS — web SPA / mobile client connection |
|
|
35
|
+
|
|
36
|
+
## Environment variables
|
|
37
|
+
|
|
38
|
+
| Variable | Default | Notes |
|
|
39
|
+
| -------------------- | ------------------------------- | -------------------------------------------------- |
|
|
40
|
+
| `PORT` | `3100` | HTTP + WSS listen port |
|
|
41
|
+
| `DATA_DIR` | `~/.dev-anywhere/relay-data` | Persistent state. Set to empty string to disable. |
|
|
42
|
+
| `HEARTBEAT_INTERVAL` | `30000` (ms) | WS ping cadence |
|
|
43
|
+
| `RELAY_PROXY_TOKEN` | unset (open `/proxy` endpoint) | When set, `/proxy` rejects connections without it |
|
|
44
|
+
| `RELAY_CLIENT_TOKEN` | unset (open `/client` endpoint) | When set, `/client` rejects connections without it |
|
|
45
|
+
| `LOG_LEVEL` | `info` | pino log level |
|
|
46
|
+
|
|
47
|
+
**Production warning:** always set both `RELAY_PROXY_TOKEN` and `RELAY_CLIENT_TOKEN`. Without a client token, anyone who can reach the relay can connect to `/client`, list proxies, and attempt to bind to a proxy.
|
|
48
|
+
|
|
49
|
+
For the bundled web client, open the app once with `?relayToken=<RELAY_CLIENT_TOKEN>` in the page URL. The token is stored in `sessionStorage` for that browser tab and appended to `/client` WebSocket connections.
|
|
50
|
+
|
|
51
|
+
## TLS
|
|
52
|
+
|
|
53
|
+
This package serves plain HTTP + WS. For production, put it behind nginx / Caddy / Cloudflare with a TLS termination. One-liner turnkey setup (docker compose + nginx + certbot) is available via `install-relay.sh` in the [repo](https://github.com/lichenxicatapple-blip/dev-anywhere).
|
|
54
|
+
|
|
55
|
+
## Using the embedded server programmatically
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { createRelayServer } from "@dev-anywhere/relay/server";
|
|
59
|
+
import pino from "pino";
|
|
60
|
+
|
|
61
|
+
const relay = createRelayServer({
|
|
62
|
+
port: 3100,
|
|
63
|
+
logger: pino(),
|
|
64
|
+
proxyToken: process.env.RELAY_PROXY_TOKEN,
|
|
65
|
+
clientToken: process.env.RELAY_CLIENT_TOKEN,
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT © catli
|
package/dist/chaos.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WebSocket } from "ws";
|
|
2
|
+
import type { Logger } from "@dev-anywhere/shared";
|
|
3
|
+
export type RelayChaosDirection = "client_to_proxy" | "proxy_to_client";
|
|
4
|
+
export interface RelayChaosOptions {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
delayMs: number;
|
|
7
|
+
duplicate: boolean;
|
|
8
|
+
duplicateDelayMs: number;
|
|
9
|
+
reorder: boolean;
|
|
10
|
+
reorderDelayMs: number;
|
|
11
|
+
types: Set<string> | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface RelayChaosMeta {
|
|
14
|
+
direction: RelayChaosDirection;
|
|
15
|
+
type: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RelayChaos {
|
|
18
|
+
send(ws: WebSocket, data: string | Buffer, meta: RelayChaosMeta): void;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseRelayChaosFromEnv(env: NodeJS.ProcessEnv): RelayChaosOptions;
|
|
21
|
+
export declare function createRelayChaos(options: RelayChaosOptions, logger: Logger): RelayChaos;
|
|
22
|
+
//# sourceMappingURL=chaos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chaos.d.ts","sourceRoot":"","sources":["../src/chaos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;CACxE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,iBAAiB,CAehF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAsCvF"}
|