@aerol-ai/aerolvm-sdk 0.1.4 → 0.1.6
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/dist/internal/client.d.ts +15 -0
- package/dist/internal/client.js +35 -5
- package/package.json +3 -3
|
@@ -32,6 +32,19 @@ export declare class APIClient {
|
|
|
32
32
|
uploadFile(id: string, targetPath: string, data: BinaryLike): Promise<void>;
|
|
33
33
|
downloadFile(id: string, targetPath: string): Promise<Uint8Array>;
|
|
34
34
|
exposePort(id: string, port: number): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Publish a raw TCP port through caddy-l4. The returned URL is in
|
|
37
|
+
* `tcp://<host>:<port>` form and works directly with `psql`, `redis-cli`,
|
|
38
|
+
* `mysql`, `mongosh`, and any other native-protocol client.
|
|
39
|
+
*/
|
|
40
|
+
exposeTCPPort(id: string, port: number): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Publish a TCP port behind the shared TLS-SNI multiplexer. Returns
|
|
43
|
+
* `tls://<id>-<port>.<domain>:<l4-port>`. Requires the daemon to have a
|
|
44
|
+
* domain configured AND `SB_L4_TLS_LISTEN` set.
|
|
45
|
+
*/
|
|
46
|
+
exposeTLSPort(id: string, port: number): Promise<string>;
|
|
47
|
+
private exposePortWithProtocol;
|
|
35
48
|
unexposePort(id: string, port: number): Promise<void>;
|
|
36
49
|
reconcile(): Promise<void>;
|
|
37
50
|
health(): Promise<HealthStatus>;
|
|
@@ -82,6 +95,8 @@ export declare class SandboxResource implements Sandbox {
|
|
|
82
95
|
uploadFile(targetPath: string, data: BinaryLike): Promise<void>;
|
|
83
96
|
downloadFile(targetPath: string): Promise<Uint8Array>;
|
|
84
97
|
exposePort(port: number): Promise<string>;
|
|
98
|
+
exposeTCPPort(port: number): Promise<string>;
|
|
99
|
+
exposeTLSPort(port: number): Promise<string>;
|
|
85
100
|
unexposePort(port: number): Promise<void>;
|
|
86
101
|
start(): Promise<this>;
|
|
87
102
|
stop(): Promise<this>;
|
package/dist/internal/client.js
CHANGED
|
@@ -93,7 +93,27 @@ export class APIClient {
|
|
|
93
93
|
return new Uint8Array(await response.arrayBuffer());
|
|
94
94
|
}
|
|
95
95
|
async exposePort(id, port) {
|
|
96
|
-
|
|
96
|
+
return this.exposePortWithProtocol(id, port);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Publish a raw TCP port through caddy-l4. The returned URL is in
|
|
100
|
+
* `tcp://<host>:<port>` form and works directly with `psql`, `redis-cli`,
|
|
101
|
+
* `mysql`, `mongosh`, and any other native-protocol client.
|
|
102
|
+
*/
|
|
103
|
+
async exposeTCPPort(id, port) {
|
|
104
|
+
return this.exposePortWithProtocol(id, port, "tcp");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Publish a TCP port behind the shared TLS-SNI multiplexer. Returns
|
|
108
|
+
* `tls://<id>-<port>.<domain>:<l4-port>`. Requires the daemon to have a
|
|
109
|
+
* domain configured AND `SB_L4_TLS_LISTEN` set.
|
|
110
|
+
*/
|
|
111
|
+
async exposeTLSPort(id, port) {
|
|
112
|
+
return this.exposePortWithProtocol(id, port, "tls");
|
|
113
|
+
}
|
|
114
|
+
async exposePortWithProtocol(id, port, protocol) {
|
|
115
|
+
const body = protocol ? { protocol } : undefined;
|
|
116
|
+
const response = await this.doJSON("POST", `/v1/sandboxes/${id}/ports/${port}`, body);
|
|
97
117
|
return response.public_url;
|
|
98
118
|
}
|
|
99
119
|
async unexposePort(id, port) {
|
|
@@ -202,6 +222,12 @@ export class SandboxResource {
|
|
|
202
222
|
async exposePort(port) {
|
|
203
223
|
return this.client.exposePort(this.id, port);
|
|
204
224
|
}
|
|
225
|
+
async exposeTCPPort(port) {
|
|
226
|
+
return this.client.exposeTCPPort(this.id, port);
|
|
227
|
+
}
|
|
228
|
+
async exposeTLSPort(port) {
|
|
229
|
+
return this.client.exposeTLSPort(this.id, port);
|
|
230
|
+
}
|
|
205
231
|
async unexposePort(port) {
|
|
206
232
|
await this.client.unexposePort(this.id, port);
|
|
207
233
|
}
|
|
@@ -471,6 +497,12 @@ function describeWSClose(event) {
|
|
|
471
497
|
parts.push(`wasClean=${e.wasClean}`);
|
|
472
498
|
return parts.join(" ");
|
|
473
499
|
}
|
|
500
|
+
function toWebSocketBinaryFrame(data) {
|
|
501
|
+
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
502
|
+
const frame = new Uint8Array(bytes.byteLength);
|
|
503
|
+
frame.set(bytes);
|
|
504
|
+
return frame;
|
|
505
|
+
}
|
|
474
506
|
function openExecStream(baseURL, patToken, sandboxID, options) {
|
|
475
507
|
const wsURL = baseURL.replace(/^http/, "ws") + `/v1/sandboxes/${encodeURIComponent(sandboxID)}/toolbox/process/exec/stream`;
|
|
476
508
|
const WS = globalThis.WebSocket;
|
|
@@ -561,8 +593,7 @@ function openExecStream(baseURL, patToken, sandboxID, options) {
|
|
|
561
593
|
failWith(detail !== "" ? `websocket error: ${detail}` : "websocket error");
|
|
562
594
|
});
|
|
563
595
|
const sendBinary = (data) => {
|
|
564
|
-
|
|
565
|
-
ws.send(bytes);
|
|
596
|
+
ws.send(toWebSocketBinaryFrame(data));
|
|
566
597
|
};
|
|
567
598
|
return {
|
|
568
599
|
write: sendBinary,
|
|
@@ -661,8 +692,7 @@ function openSessionAttach(baseURL, patToken, sandboxID, sessionID, options) {
|
|
|
661
692
|
failWith(detail !== "" ? `websocket error: ${detail}` : "websocket error");
|
|
662
693
|
});
|
|
663
694
|
const sendBinary = (data) => {
|
|
664
|
-
|
|
665
|
-
ws.send(bytes);
|
|
695
|
+
ws.send(toWebSocketBinaryFrame(data));
|
|
666
696
|
};
|
|
667
697
|
return {
|
|
668
698
|
write: sendBinary,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aerol-ai/aerolvm-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"test": "tsc -p tsconfig.test.json --outDir dist-test && node --test dist-test/*.test.js"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "^
|
|
24
|
-
"typescript": "^
|
|
23
|
+
"@types/node": "^25.6.2",
|
|
24
|
+
"typescript": "^6.0.3",
|
|
25
25
|
"tsx": "^4.21.0"
|
|
26
26
|
}
|
|
27
27
|
}
|