@rstreamlabs/webtty 1.6.4 → 1.7.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/README.md +215 -1
- package/dist/index.d.mts +168 -1
- package/dist/index.d.ts +168 -1
- package/dist/index.js +1679 -399
- package/dist/index.mjs +1649 -379
- package/examples/filesystem-sidecar/.env.local.example +1 -0
- package/examples/filesystem-sidecar/README.md +11 -0
- package/examples/filesystem-sidecar/package.json +20 -0
- package/examples/filesystem-sidecar/src/main.ts +42 -0
- package/examples/filesystem-sidecar/tsconfig.json +14 -0
- package/examples/remote-command/.env.local.example +1 -0
- package/examples/remote-command/README.md +11 -0
- package/examples/remote-command/package.json +20 -0
- package/examples/remote-command/src/main.ts +37 -0
- package/examples/remote-command/tsconfig.json +14 -0
- package/package.json +10 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
RSTREAM_WEBTTY_URL='https://host.example.t.rstream.io?rstream.token=XXX'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# `rstream-webtty-filesystem-sidecar-example`
|
|
2
|
+
|
|
3
|
+
Example of using `@rstreamlabs/webtty` to read and write files through the optional WebDAV filesystem sidecar.
|
|
4
|
+
|
|
5
|
+
The sample only needs the WebTTY URL. If you build an inventory-driven integration, pass the advertised `fs_path` from `rstream webtty list -o json` as the SDK `fsPath` option.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
cp .env.local.example .env.local
|
|
9
|
+
npm install
|
|
10
|
+
npm start
|
|
11
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rstream-webtty-filesystem-sidecar-example",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Example of using the WebTTY filesystem sidecar through rstream.",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@rstreamlabs/webtty": "file:../..",
|
|
9
|
+
"dotenv": "^17.2.2"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "tsx src/main.ts",
|
|
13
|
+
"type-check": "tsc --noEmit"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^25",
|
|
17
|
+
"tsx": "^4.21.0",
|
|
18
|
+
"typescript": "5.9.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// See LICENSE file in the project root for license information.
|
|
2
|
+
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
import { WebTTYFileSystem } from "@rstreamlabs/webtty";
|
|
5
|
+
|
|
6
|
+
dotenv.config({ path: ".env.local" });
|
|
7
|
+
|
|
8
|
+
function env(name: string): string {
|
|
9
|
+
const value = process.env[name];
|
|
10
|
+
if (value) return value;
|
|
11
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function readText(stream: ReadableStream<Uint8Array>): Promise<string> {
|
|
15
|
+
const reader = stream.getReader();
|
|
16
|
+
const chunks = await readChunks(reader);
|
|
17
|
+
reader.releaseLock();
|
|
18
|
+
return new TextDecoder().decode(Buffer.concat(chunks));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function readChunks(
|
|
22
|
+
reader: ReadableStreamDefaultReader<Uint8Array>,
|
|
23
|
+
chunks: readonly Uint8Array[] = [],
|
|
24
|
+
): Promise<readonly Uint8Array[]> {
|
|
25
|
+
const result = await reader.read();
|
|
26
|
+
return result.done ? chunks : readChunks(reader, [...chunks, result.value]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function main(): Promise<void> {
|
|
30
|
+
const fs = new WebTTYFileSystem({
|
|
31
|
+
url: env("RSTREAM_WEBTTY_URL"),
|
|
32
|
+
});
|
|
33
|
+
await fs.writeFile("/codex-note.txt", "written through rstream WebTTY\n");
|
|
34
|
+
console.log(await fs.readdir("/"));
|
|
35
|
+
console.log(await fs.readText("/codex-note.txt"));
|
|
36
|
+
console.log(await readText(await fs.readStream("/codex-note.txt")));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main().catch((error) => {
|
|
40
|
+
console.error(error);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"esModuleInterop": true,
|
|
4
|
+
"forceConsistentCasingInFileNames": true,
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"target": "ES2022",
|
|
11
|
+
"types": ["node"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts"]
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
RSTREAM_WEBTTY_URL='wss://host.example.t.rstream.io?rstream.token=XXX'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# `rstream-webtty-remote-command-example`
|
|
2
|
+
|
|
3
|
+
Example of using `@rstreamlabs/webtty` to run collected and streaming commands through a WebTTY server.
|
|
4
|
+
|
|
5
|
+
The sample only needs the WebTTY URL. If you build an inventory-driven integration, pass the advertised `exec_path` from `rstream webtty list -o json` as the SDK `execPath` option.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
cp .env.local.example .env.local
|
|
9
|
+
npm install
|
|
10
|
+
npm start
|
|
11
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rstream-webtty-remote-command-example",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Example of running WebTTY commands through rstream.",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@rstreamlabs/webtty": "file:../..",
|
|
9
|
+
"dotenv": "^17.2.2"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "tsx src/main.ts",
|
|
13
|
+
"type-check": "tsc --noEmit"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^25",
|
|
17
|
+
"tsx": "^4.21.0",
|
|
18
|
+
"typescript": "5.9.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// See LICENSE file in the project root for license information.
|
|
2
|
+
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
import { WebTTYRemoteExecutor } from "@rstreamlabs/webtty";
|
|
5
|
+
|
|
6
|
+
dotenv.config({ path: ".env.local" });
|
|
7
|
+
|
|
8
|
+
function env(name: string): string {
|
|
9
|
+
const value = process.env[name];
|
|
10
|
+
if (value) return value;
|
|
11
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function main(): Promise<void> {
|
|
15
|
+
const executor = new WebTTYRemoteExecutor({
|
|
16
|
+
url: env("RSTREAM_WEBTTY_URL"),
|
|
17
|
+
});
|
|
18
|
+
const result = await executor.runCommand("sh", ["-lc", "uname -a && pwd"], {
|
|
19
|
+
timeoutMs: 30_000,
|
|
20
|
+
});
|
|
21
|
+
console.log({ exitCode: result.exitCode, stdout: result.stdout });
|
|
22
|
+
const command = await executor.openCommand("sh", [
|
|
23
|
+
"-lc",
|
|
24
|
+
"for i in 1 2 3; do echo tick:$i; sleep 1; done",
|
|
25
|
+
]);
|
|
26
|
+
for await (const entry of command.logs()) {
|
|
27
|
+
process[entry.stream === "stdout" ? "stdout" : "stderr"].write(entry.data);
|
|
28
|
+
}
|
|
29
|
+
const status = await command.wait();
|
|
30
|
+
if (!status.success)
|
|
31
|
+
throw new Error(`Remote command exited with ${status.exitCode}.`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main().catch((error) => {
|
|
35
|
+
console.error(error);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"esModuleInterop": true,
|
|
4
|
+
"forceConsistentCasingInFileNames": true,
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"target": "ES2022",
|
|
11
|
+
"types": ["node"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts"]
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstreamlabs/webtty",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Client-side implementation of the rstream WebTTY protocol.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/rstreamlabs/rstream-js",
|
|
8
|
+
"directory": "packages/webtty"
|
|
9
|
+
},
|
|
5
10
|
"license": "Apache-2.0",
|
|
6
11
|
"main": "./dist/index.js",
|
|
7
12
|
"module": "./dist/index.mjs",
|
|
8
13
|
"types": "./dist/index.d.ts",
|
|
9
14
|
"files": [
|
|
10
15
|
"dist",
|
|
16
|
+
"examples",
|
|
11
17
|
"README.md"
|
|
12
18
|
],
|
|
13
19
|
"scripts": {
|
|
@@ -18,6 +24,7 @@
|
|
|
18
24
|
"lint": "eslint \"./**/*.ts*\"",
|
|
19
25
|
"pretest": "npm run generate-proto-files && npm run build",
|
|
20
26
|
"test": "node --test ./test/**/*.test.cjs",
|
|
27
|
+
"test:runtime": "node ./test/runtime-e2e.mjs",
|
|
21
28
|
"type-check": "tsc --noEmit"
|
|
22
29
|
},
|
|
23
30
|
"devDependencies": {
|
|
@@ -25,13 +32,13 @@
|
|
|
25
32
|
"@types/node": "^25",
|
|
26
33
|
"eslint-config": "*",
|
|
27
34
|
"eslint": "9.39.4",
|
|
28
|
-
"protobufjs-cli": "^2.0
|
|
35
|
+
"protobufjs-cli": "^2.4.0",
|
|
29
36
|
"tsup": "^8.5.1",
|
|
30
37
|
"typescript-config": "*",
|
|
31
38
|
"typescript": "5.9.3"
|
|
32
39
|
},
|
|
33
40
|
"dependencies": {
|
|
34
|
-
"protobufjs": "^8.0
|
|
41
|
+
"protobufjs": "^8.4.0"
|
|
35
42
|
},
|
|
36
43
|
"publishConfig": {
|
|
37
44
|
"access": "public"
|