ai-remote 0.4.2 → 0.4.4
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/index.js +1 -6
- package/dist/{protocols/index.d.ts → protocols.d.ts} +2 -0
- package/dist/protocols.js +24 -0
- package/package.json +15 -10
- package/dist/protocols/index.js +0 -34
- package/dist/protocols/rdp/buffer.d.ts +0 -38
- package/dist/protocols/rdp/buffer.js +0 -169
- package/dist/protocols/rdp/caps.d.ts +0 -49
- package/dist/protocols/rdp/caps.js +0 -259
- package/dist/protocols/rdp/cert.d.ts +0 -18
- package/dist/protocols/rdp/cert.js +0 -134
- package/dist/protocols/rdp/client.d.ts +0 -56
- package/dist/protocols/rdp/client.js +0 -1069
- package/dist/protocols/rdp/cliprdr.d.ts +0 -27
- package/dist/protocols/rdp/cliprdr.js +0 -239
- package/dist/protocols/rdp/credssp.d.ts +0 -34
- package/dist/protocols/rdp/credssp.js +0 -253
- package/dist/protocols/rdp/crypto.d.ts +0 -63
- package/dist/protocols/rdp/crypto.js +0 -368
- package/dist/protocols/rdp/display.d.ts +0 -38
- package/dist/protocols/rdp/display.js +0 -588
- package/dist/protocols/rdp/gcc.d.ts +0 -23
- package/dist/protocols/rdp/gcc.js +0 -131
- package/dist/protocols/rdp/keymap.d.ts +0 -9
- package/dist/protocols/rdp/keymap.js +0 -131
- package/dist/protocols/rdp/mcs.d.ts +0 -40
- package/dist/protocols/rdp/mcs.js +0 -222
- package/dist/protocols/rdp/ntlm.d.ts +0 -61
- package/dist/protocols/rdp/ntlm.js +0 -304
- package/dist/protocols/rdp/pdu.d.ts +0 -155
- package/dist/protocols/rdp/pdu.js +0 -443
- package/dist/protocols/rdp/rail.d.ts +0 -119
- package/dist/protocols/rdp/rail.js +0 -382
- package/dist/protocols/rdp/rle.d.ts +0 -13
- package/dist/protocols/rdp/rle.js +0 -275
- package/dist/protocols/rdp/sec.d.ts +0 -59
- package/dist/protocols/rdp/sec.js +0 -155
- package/dist/protocols/rdp/session.d.ts +0 -62
- package/dist/protocols/rdp/session.js +0 -306
- package/dist/protocols/rdp/tls.d.ts +0 -18
- package/dist/protocols/rdp/tls.js +0 -353
- package/dist/protocols/rdp/vchannel.d.ts +0 -28
- package/dist/protocols/rdp/vchannel.js +0 -58
- package/dist/protocols/rdp/x224.d.ts +0 -40
- package/dist/protocols/rdp/x224.js +0 -109
- package/dist/protocols/ssh/kex.d.ts +0 -97
- package/dist/protocols/ssh/kex.js +0 -176
- package/dist/protocols/ssh/messages.d.ts +0 -50
- package/dist/protocols/ssh/messages.js +0 -54
- package/dist/protocols/ssh/session.d.ts +0 -66
- package/dist/protocols/ssh/session.js +0 -608
- package/dist/protocols/ssh/terminal.d.ts +0 -46
- package/dist/protocols/ssh/terminal.js +0 -190
- package/dist/protocols/ssh/transport.d.ts +0 -62
- package/dist/protocols/ssh/transport.js +0 -612
- package/dist/protocols/ssh/wire.d.ts +0 -52
- package/dist/protocols/ssh/wire.js +0 -188
- package/dist/protocols/types.d.ts +0 -127
- package/dist/protocols/types.js +0 -0
- package/dist/protocols/vnc/input.d.ts +0 -5
- package/dist/protocols/vnc/input.js +0 -15
- package/dist/protocols/vnc/session.d.ts +0 -12
- package/dist/protocols/vnc/session.js +0 -258
- package/dist/shared/connection.d.ts +0 -81
- package/dist/shared/connection.js +0 -113
- package/dist/shared/device.d.ts +0 -26
- package/dist/shared/device.js +0 -0
- package/dist/shared/hosts.d.ts +0 -63
- package/dist/shared/hosts.js +0 -132
- package/dist/shared/icons.d.ts +0 -46
- package/dist/shared/icons.js +0 -41
- package/dist/shared/protocol.d.ts +0 -28
- package/dist/shared/protocol.js +0 -39
- package/dist/shared/signals.d.ts +0 -37
- package/dist/shared/signals.js +0 -41
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { Terminal } from "@xterm/xterm";
|
|
2
|
-
import { FitAddon } from "@xterm/addon-fit";
|
|
3
|
-
import xtermStyles from "@xterm/xterm/css/xterm.css";
|
|
4
|
-
const STYLE_ELEMENT_ID = "xterm-styles";
|
|
5
|
-
const MIN_COLUMNS = 80;
|
|
6
|
-
const BASE_FONT_SIZE = 13;
|
|
7
|
-
const MIN_FONT_SIZE = 7;
|
|
8
|
-
function installStyles() {
|
|
9
|
-
if (document.getElementById(STYLE_ELEMENT_ID)) return;
|
|
10
|
-
const style = document.createElement("style");
|
|
11
|
-
style.id = STYLE_ELEMENT_ID;
|
|
12
|
-
style.textContent = xtermStyles;
|
|
13
|
-
document.head.appendChild(style);
|
|
14
|
-
}
|
|
15
|
-
const THEME = {
|
|
16
|
-
background: "#0b0d12",
|
|
17
|
-
foreground: "#dfe4ec",
|
|
18
|
-
cursor: "#f38020",
|
|
19
|
-
cursorAccent: "#0b0d12",
|
|
20
|
-
selectionBackground: "rgba(243, 128, 32, 0.32)",
|
|
21
|
-
black: "#1b1f27",
|
|
22
|
-
red: "#ff6b6b",
|
|
23
|
-
green: "#4ade80",
|
|
24
|
-
yellow: "#fbbf24",
|
|
25
|
-
blue: "#60a5fa",
|
|
26
|
-
magenta: "#c084fc",
|
|
27
|
-
cyan: "#34d3ee",
|
|
28
|
-
white: "#cbd3e1",
|
|
29
|
-
brightBlack: "#63708a",
|
|
30
|
-
brightRed: "#ff8787",
|
|
31
|
-
brightGreen: "#86efac",
|
|
32
|
-
brightYellow: "#fcd34d",
|
|
33
|
-
brightBlue: "#93c5fd",
|
|
34
|
-
brightMagenta: "#d8b4fe",
|
|
35
|
-
brightCyan: "#67e8f9",
|
|
36
|
-
brightWhite: "#f5f7fa"
|
|
37
|
-
};
|
|
38
|
-
class SshTerminal {
|
|
39
|
-
constructor(container) {
|
|
40
|
-
installStyles();
|
|
41
|
-
this.container = container;
|
|
42
|
-
this.terminal = new Terminal({
|
|
43
|
-
allowProposedApi: true,
|
|
44
|
-
convertEol: false,
|
|
45
|
-
cursorBlink: true,
|
|
46
|
-
cursorStyle: "bar",
|
|
47
|
-
drawBoldTextInBrightColors: true,
|
|
48
|
-
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',
|
|
49
|
-
fontSize: BASE_FONT_SIZE,
|
|
50
|
-
lineHeight: 1.25,
|
|
51
|
-
letterSpacing: 0,
|
|
52
|
-
macOptionIsMeta: true,
|
|
53
|
-
minimumContrastRatio: 1.5,
|
|
54
|
-
scrollback: 1e4,
|
|
55
|
-
theme: THEME
|
|
56
|
-
});
|
|
57
|
-
this.fitAddon = new FitAddon();
|
|
58
|
-
this.terminal.loadAddon(this.fitAddon);
|
|
59
|
-
this.terminal.open(container);
|
|
60
|
-
this.fit();
|
|
61
|
-
this.observer = new ResizeObserver(() => this.fit());
|
|
62
|
-
this.observer.observe(container);
|
|
63
|
-
this.dataHandler = null;
|
|
64
|
-
this.terminal.onData((data) => this.dataHandler?.(data));
|
|
65
|
-
}
|
|
66
|
-
get columns() {
|
|
67
|
-
return this.terminal.cols;
|
|
68
|
-
}
|
|
69
|
-
get rows() {
|
|
70
|
-
return this.terminal.rows;
|
|
71
|
-
}
|
|
72
|
-
onData(handler) {
|
|
73
|
-
this.dataHandler = handler;
|
|
74
|
-
}
|
|
75
|
-
onResize(handler) {
|
|
76
|
-
this.terminal.onResize(({ cols, rows }) => handler(cols, rows));
|
|
77
|
-
}
|
|
78
|
-
write(data) {
|
|
79
|
-
this.terminal.write(data);
|
|
80
|
-
}
|
|
81
|
-
/** Gateway-side notices, kept visually apart from what the host prints. */
|
|
82
|
-
notice(text, tone = "info") {
|
|
83
|
-
const color = { info: "\x1B[38;5;245m", good: "\x1B[38;5;114m", bad: "\x1B[38;5;203m" }[tone] || "";
|
|
84
|
-
this.terminal.write(`${color}${text}\x1B[0m\r
|
|
85
|
-
`);
|
|
86
|
-
}
|
|
87
|
-
clear() {
|
|
88
|
-
this.terminal.clear();
|
|
89
|
-
}
|
|
90
|
-
focus() {
|
|
91
|
-
this.terminal.focus();
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Size the terminal to the panel, choosing the font so MIN_COLUMNS fit.
|
|
95
|
-
*
|
|
96
|
-
* The columns matter more than the type size here: the commands people run in
|
|
97
|
-
* a side panel -- `ls -l`, `top`, anything in PowerShell that prints a table
|
|
98
|
-
* -- are laid out for 80 columns, and a narrower grid wraps every row into an
|
|
99
|
-
* unreadable stack.
|
|
100
|
-
*
|
|
101
|
-
* `proposeDimensions()` reports the grid the current font size yields, and a
|
|
102
|
-
* monospace cell's width scales with its font size, so `fontSize * cols /
|
|
103
|
-
* MIN_COLUMNS` lands close to the size that gives MIN_COLUMNS. It is measured
|
|
104
|
-
* rather than assumed because the cell-width-to-font-size ratio belongs to
|
|
105
|
-
* whichever font the platform picked. A second pass settles the rounding.
|
|
106
|
-
* Changing the font resizes the element, which the ResizeObserver sees, so
|
|
107
|
-
* the guard keeps that from recursing.
|
|
108
|
-
*/
|
|
109
|
-
fit() {
|
|
110
|
-
if (this.fitting) return;
|
|
111
|
-
if (this.container.clientWidth <= 0 || this.container.clientHeight <= 0) return;
|
|
112
|
-
this.fitting = true;
|
|
113
|
-
try {
|
|
114
|
-
for (let pass = 0; pass < 2; pass++) {
|
|
115
|
-
const proposed = this.fitAddon.proposeDimensions();
|
|
116
|
-
if (!proposed || !(proposed.cols > 0)) break;
|
|
117
|
-
const current = this.terminal.options.fontSize || BASE_FONT_SIZE;
|
|
118
|
-
const wanted = Math.min(
|
|
119
|
-
BASE_FONT_SIZE,
|
|
120
|
-
Math.max(MIN_FONT_SIZE, Math.floor(current * proposed.cols / MIN_COLUMNS))
|
|
121
|
-
);
|
|
122
|
-
if (wanted === current) break;
|
|
123
|
-
this.terminal.options.fontSize = wanted;
|
|
124
|
-
}
|
|
125
|
-
this.fitAddon.fit();
|
|
126
|
-
const short = this.terminal.cols < MIN_COLUMNS;
|
|
127
|
-
this.container.classList.toggle("is-narrow", short);
|
|
128
|
-
if (short) this.terminal.resize(MIN_COLUMNS, this.terminal.rows);
|
|
129
|
-
} catch {
|
|
130
|
-
} finally {
|
|
131
|
-
this.fitting = false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/** The grid the host is being told about, for a status line or a log. */
|
|
135
|
-
get geometry() {
|
|
136
|
-
return {
|
|
137
|
-
columns: this.terminal.cols,
|
|
138
|
-
rows: this.terminal.rows,
|
|
139
|
-
fontSize: this.terminal.options.fontSize
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
get selection() {
|
|
143
|
-
return this.terminal.getSelection();
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Read one line from the user, for a password or a one-time code the host
|
|
147
|
-
* asked for during authentication. The shell is not open yet, so the
|
|
148
|
-
* terminal is free to be a prompt.
|
|
149
|
-
*/
|
|
150
|
-
readLine({ prompt = "", echo = false } = {}) {
|
|
151
|
-
return new Promise((resolve) => {
|
|
152
|
-
const previous = this.dataHandler;
|
|
153
|
-
let answer = "";
|
|
154
|
-
this.terminal.write(prompt.replaceAll("\n", "\r\n"));
|
|
155
|
-
this.dataHandler = (data) => {
|
|
156
|
-
for (const character of data) {
|
|
157
|
-
const code = character.charCodeAt(0);
|
|
158
|
-
if (code === 13 || code === 10) {
|
|
159
|
-
this.terminal.write("\r\n");
|
|
160
|
-
this.dataHandler = previous;
|
|
161
|
-
resolve(answer);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (code === 127 || code === 8) {
|
|
165
|
-
if (answer.length === 0) continue;
|
|
166
|
-
answer = answer.slice(0, -1);
|
|
167
|
-
if (echo) this.terminal.write("\b \b");
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (code === 3) {
|
|
171
|
-
this.terminal.write("^C\r\n");
|
|
172
|
-
this.dataHandler = previous;
|
|
173
|
-
resolve("");
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (code < 32) continue;
|
|
177
|
-
answer += character;
|
|
178
|
-
if (echo) this.terminal.write(character);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
destroy() {
|
|
184
|
-
this.observer?.disconnect();
|
|
185
|
-
this.terminal.dispose();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
export {
|
|
189
|
-
SshTerminal
|
|
190
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export declare const CLIENT_VERSION = "SSH-2.0-CloudflareGateway_1.0";
|
|
2
|
-
/** Pick the first client preference the host also offered (RFC 4253 7.1). */
|
|
3
|
-
export declare function negotiate(clientNames: any, serverNames: any): any;
|
|
4
|
-
export declare class SshTransport extends EventTarget {
|
|
5
|
-
#private;
|
|
6
|
-
url: string;
|
|
7
|
-
verifyHost: (info: any) => Promise<boolean> | boolean;
|
|
8
|
-
log: (...args: any[]) => void;
|
|
9
|
-
socket: WebSocket | null;
|
|
10
|
-
openTransport: ((url: string) => any) | null;
|
|
11
|
-
closed: boolean;
|
|
12
|
-
buffer: Uint8Array;
|
|
13
|
-
serverVersion: string;
|
|
14
|
-
greeting: string[];
|
|
15
|
-
sendSequence: number;
|
|
16
|
-
receiveSequence: number;
|
|
17
|
-
outgoing: any;
|
|
18
|
-
incoming: any;
|
|
19
|
-
sessionId: Uint8Array | null;
|
|
20
|
-
kex: any;
|
|
21
|
-
kexQueue: Uint8Array[];
|
|
22
|
-
keepaliveTimer: any;
|
|
23
|
-
bytesSent: number;
|
|
24
|
-
bytesReceived: number;
|
|
25
|
-
encryptChain?: Promise<void>;
|
|
26
|
-
newKeysBarrier?: Promise<void> | null;
|
|
27
|
-
releaseNewKeys?: (() => void) | null;
|
|
28
|
-
pendingServerKexInit?: Uint8Array | null;
|
|
29
|
-
established?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* @param {string} url gateway WebSocket URL
|
|
32
|
-
* @param {object} options
|
|
33
|
-
* @param {(info: object) => Promise<boolean>} options.verifyHost decides
|
|
34
|
-
* whether an unknown or changed host key may be used.
|
|
35
|
-
*/
|
|
36
|
-
constructor(url: string, { verifyHost, log, openTransport }?: {
|
|
37
|
-
verifyHost?: (info: any) => Promise<boolean> | boolean;
|
|
38
|
-
log?: (...args: any[]) => void;
|
|
39
|
-
/** Returns a WebSocket-shaped transport for `url`; default is a real one. */
|
|
40
|
-
openTransport?: ((url: string) => any) | null;
|
|
41
|
-
});
|
|
42
|
-
connect(): void;
|
|
43
|
-
disconnect(message?: string): void;
|
|
44
|
-
fail(error: unknown): void;
|
|
45
|
-
/** Application packets wait while a key exchange is in flight (RFC 4253 7.1). */
|
|
46
|
-
send(payload: Uint8Array): boolean;
|
|
47
|
-
}
|
|
48
|
-
/** Padding for a GCM packet: only the encrypted part is block aligned. */
|
|
49
|
-
export declare function gcmPaddingLength(payloadLength: any): number;
|
|
50
|
-
/** A packet before any keys exist: the whole thing is block aligned. */
|
|
51
|
-
export declare function framePlain(payload: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
52
|
-
export declare function buildKexInit(offer: any): Uint8Array<ArrayBufferLike>;
|
|
53
|
-
export declare function parseKexInit(payload: Uint8Array): {
|
|
54
|
-
kex: string[];
|
|
55
|
-
hostKey: string[];
|
|
56
|
-
cipherClientToServer: string[];
|
|
57
|
-
cipherServerToClient: string[];
|
|
58
|
-
macClientToServer: string[];
|
|
59
|
-
macServerToClient: string[];
|
|
60
|
-
compressionClientToServer: string[];
|
|
61
|
-
compressionServerToClient: string[];
|
|
62
|
-
};
|