@moejay/wrightty 0.1.1 → 0.2.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/dist/cli.js +8 -2
- package/dist/terminal.d.ts +2 -0
- package/dist/terminal.js +22 -0
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,8 @@ const command = args[0];
|
|
|
8
8
|
function usage() {
|
|
9
9
|
console.log(`wrightty-js — Playwright for terminals (Node.js)
|
|
10
10
|
|
|
11
|
+
Note: This is a client CLI. To start a server: cargo install wrightty
|
|
12
|
+
|
|
11
13
|
Usage:
|
|
12
14
|
wrightty-js run <command> [--timeout <s>] Run a command and print output
|
|
13
15
|
wrightty-js read Read the terminal screen
|
|
@@ -22,6 +24,7 @@ Usage:
|
|
|
22
24
|
Options:
|
|
23
25
|
--url <url> Server URL (default: auto-discover)
|
|
24
26
|
--session <id> Session ID (default: first available)
|
|
27
|
+
--password <pass> Password for server authentication
|
|
25
28
|
--help Show this help`);
|
|
26
29
|
}
|
|
27
30
|
function getOpt(name) {
|
|
@@ -34,7 +37,8 @@ function hasFlag(name) {
|
|
|
34
37
|
async function getTerminal() {
|
|
35
38
|
const url = getOpt("--url");
|
|
36
39
|
const sessionId = getOpt("--session");
|
|
37
|
-
|
|
40
|
+
const password = getOpt("--password");
|
|
41
|
+
return terminal_1.Terminal.connect({ url, sessionId, password });
|
|
38
42
|
}
|
|
39
43
|
async function main() {
|
|
40
44
|
if (!command || hasFlag("--help") || hasFlag("-h")) {
|
|
@@ -50,7 +54,9 @@ async function main() {
|
|
|
50
54
|
}
|
|
51
55
|
else {
|
|
52
56
|
for (const s of servers) {
|
|
53
|
-
|
|
57
|
+
const name = s.name ? ` [${s.name}]` : "";
|
|
58
|
+
const auth = s.authentication ? ` (auth: ${s.authentication})` : "";
|
|
59
|
+
console.log(` ${s.url} ${s.implementation} v${s.version}${name}${auth}`);
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
break;
|
package/dist/terminal.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export declare class Terminal {
|
|
|
35
35
|
resize(cols: number, rows: number): Promise<void>;
|
|
36
36
|
/** Get server info and capabilities. */
|
|
37
37
|
getInfo(): Promise<Record<string, any>>;
|
|
38
|
+
/** Authenticate with the server using a password. */
|
|
39
|
+
authenticate(password: string): Promise<void>;
|
|
38
40
|
/** Start recording raw PTY I/O (asciicast v2 format). */
|
|
39
41
|
startSessionRecording(includeInput?: boolean): Promise<string>;
|
|
40
42
|
/** Stop a session recording and return asciicast data. */
|
package/dist/terminal.js
CHANGED
|
@@ -29,6 +29,8 @@ class Terminal {
|
|
|
29
29
|
version: info.version ?? "unknown",
|
|
30
30
|
implementation: info.implementation ?? "unknown",
|
|
31
31
|
capabilities: info.capabilities ?? {},
|
|
32
|
+
name: info.name,
|
|
33
|
+
authentication: info.authentication,
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
finally {
|
|
@@ -56,6 +58,14 @@ class Terminal {
|
|
|
56
58
|
url = servers[0].url;
|
|
57
59
|
}
|
|
58
60
|
const client = await client_1.WrighttyClient.connect(url, options.timeout ?? 5000);
|
|
61
|
+
const info = await client.request("Wrightty.getInfo");
|
|
62
|
+
if (info.authentication === "password") {
|
|
63
|
+
if (!options.password) {
|
|
64
|
+
client.close();
|
|
65
|
+
throw new Error("Server requires password authentication but no password was provided");
|
|
66
|
+
}
|
|
67
|
+
await client.request("Wrightty.authenticate", { password: options.password });
|
|
68
|
+
}
|
|
59
69
|
let sessionId = options.sessionId;
|
|
60
70
|
if (!sessionId) {
|
|
61
71
|
const result = await client.request("Session.list");
|
|
@@ -68,6 +78,14 @@ class Terminal {
|
|
|
68
78
|
static async spawn(options = {}) {
|
|
69
79
|
const url = options.serverUrl ?? "ws://127.0.0.1:9420";
|
|
70
80
|
const client = await client_1.WrighttyClient.connect(url);
|
|
81
|
+
const info = await client.request("Wrightty.getInfo");
|
|
82
|
+
if (info.authentication === "password") {
|
|
83
|
+
if (!options.password) {
|
|
84
|
+
client.close();
|
|
85
|
+
throw new Error("Server requires password authentication but no password was provided");
|
|
86
|
+
}
|
|
87
|
+
await client.request("Wrightty.authenticate", { password: options.password });
|
|
88
|
+
}
|
|
71
89
|
const result = await client.request("Session.create", {
|
|
72
90
|
cols: options.cols ?? 120,
|
|
73
91
|
rows: options.rows ?? 40,
|
|
@@ -174,6 +192,10 @@ class Terminal {
|
|
|
174
192
|
async getInfo() {
|
|
175
193
|
return this.client.request("Wrightty.getInfo");
|
|
176
194
|
}
|
|
195
|
+
/** Authenticate with the server using a password. */
|
|
196
|
+
async authenticate(password) {
|
|
197
|
+
await this.client.request("Wrightty.authenticate", { password });
|
|
198
|
+
}
|
|
177
199
|
// --- Recording ---
|
|
178
200
|
/** Start recording raw PTY I/O (asciicast v2 format). */
|
|
179
201
|
async startSessionRecording(includeInput = false) {
|
package/dist/types.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface ServerInfo {
|
|
|
3
3
|
version: string;
|
|
4
4
|
implementation: string;
|
|
5
5
|
capabilities: Capabilities;
|
|
6
|
+
name?: string;
|
|
7
|
+
authentication: "none" | "password";
|
|
6
8
|
}
|
|
7
9
|
export interface Capabilities {
|
|
8
10
|
screenshot: ScreenshotFormat[];
|
|
@@ -72,6 +74,8 @@ export interface DiscoveredServer {
|
|
|
72
74
|
version: string;
|
|
73
75
|
implementation: string;
|
|
74
76
|
capabilities: Capabilities;
|
|
77
|
+
name?: string;
|
|
78
|
+
authentication?: string;
|
|
75
79
|
}
|
|
76
80
|
export interface ConnectOptions {
|
|
77
81
|
/** Server URL (default: auto-discover) */
|
|
@@ -80,6 +84,8 @@ export interface ConnectOptions {
|
|
|
80
84
|
sessionId?: string;
|
|
81
85
|
/** Connection timeout in ms (default: 5000) */
|
|
82
86
|
timeout?: number;
|
|
87
|
+
/** Password for server authentication */
|
|
88
|
+
password?: string;
|
|
83
89
|
}
|
|
84
90
|
export interface SpawnOptions {
|
|
85
91
|
shell?: string;
|
|
@@ -87,4 +93,6 @@ export interface SpawnOptions {
|
|
|
87
93
|
rows?: number;
|
|
88
94
|
cwd?: string;
|
|
89
95
|
serverUrl?: string;
|
|
96
|
+
/** Password for server authentication */
|
|
97
|
+
password?: string;
|
|
90
98
|
}
|