ai-remote 0.4.0 → 0.4.2

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.
Files changed (166) hide show
  1. package/{src/index.ts → dist/index.d.ts} +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/protocols/index.d.ts +31 -0
  4. package/dist/protocols/index.js +0 -1
  5. package/dist/protocols/rdp/buffer.d.ts +38 -0
  6. package/dist/protocols/rdp/buffer.js +0 -1
  7. package/dist/protocols/rdp/caps.d.ts +49 -0
  8. package/dist/protocols/rdp/caps.js +0 -1
  9. package/dist/protocols/rdp/cert.d.ts +18 -0
  10. package/dist/protocols/rdp/cert.js +0 -1
  11. package/dist/protocols/rdp/client.d.ts +56 -0
  12. package/dist/protocols/rdp/client.js +0 -1
  13. package/dist/protocols/rdp/cliprdr.d.ts +27 -0
  14. package/dist/protocols/rdp/cliprdr.js +0 -1
  15. package/dist/protocols/rdp/credssp.d.ts +34 -0
  16. package/dist/protocols/rdp/credssp.js +0 -1
  17. package/dist/protocols/rdp/crypto.d.ts +63 -0
  18. package/dist/protocols/rdp/crypto.js +0 -1
  19. package/dist/protocols/rdp/display.d.ts +38 -0
  20. package/dist/protocols/rdp/display.js +0 -1
  21. package/dist/protocols/rdp/gcc.d.ts +23 -0
  22. package/dist/protocols/rdp/gcc.js +0 -1
  23. package/dist/protocols/rdp/keymap.d.ts +9 -0
  24. package/dist/protocols/rdp/keymap.js +0 -1
  25. package/dist/protocols/rdp/mcs.d.ts +40 -0
  26. package/dist/protocols/rdp/mcs.js +0 -1
  27. package/dist/protocols/rdp/ntlm.d.ts +61 -0
  28. package/dist/protocols/rdp/ntlm.js +0 -1
  29. package/dist/protocols/rdp/pdu.d.ts +155 -0
  30. package/dist/protocols/rdp/pdu.js +0 -1
  31. package/dist/protocols/rdp/rail.d.ts +119 -0
  32. package/dist/protocols/rdp/rail.js +0 -1
  33. package/dist/protocols/rdp/rle.d.ts +13 -0
  34. package/dist/protocols/rdp/rle.js +0 -1
  35. package/dist/protocols/rdp/sec.d.ts +59 -0
  36. package/dist/protocols/rdp/sec.js +0 -1
  37. package/dist/protocols/rdp/session.d.ts +62 -0
  38. package/dist/protocols/rdp/session.js +0 -1
  39. package/dist/protocols/rdp/tls.d.ts +18 -0
  40. package/dist/protocols/rdp/tls.js +0 -1
  41. package/dist/protocols/rdp/vchannel.d.ts +28 -0
  42. package/dist/protocols/rdp/vchannel.js +0 -1
  43. package/dist/protocols/rdp/x224.d.ts +40 -0
  44. package/dist/protocols/rdp/x224.js +0 -1
  45. package/dist/protocols/ssh/kex.d.ts +97 -0
  46. package/dist/protocols/ssh/kex.js +0 -1
  47. package/dist/protocols/ssh/messages.d.ts +50 -0
  48. package/dist/protocols/ssh/messages.js +0 -1
  49. package/dist/protocols/ssh/session.d.ts +66 -0
  50. package/dist/protocols/ssh/session.js +0 -1
  51. package/dist/protocols/ssh/terminal.d.ts +46 -0
  52. package/dist/protocols/ssh/terminal.js +0 -1
  53. package/dist/protocols/ssh/transport.d.ts +62 -0
  54. package/dist/protocols/ssh/transport.js +0 -1
  55. package/dist/protocols/ssh/wire.d.ts +52 -0
  56. package/dist/protocols/ssh/wire.js +0 -1
  57. package/dist/protocols/types.d.ts +127 -0
  58. package/dist/protocols/types.js +0 -1
  59. package/dist/protocols/vnc/input.d.ts +5 -0
  60. package/dist/protocols/vnc/input.js +0 -1
  61. package/dist/protocols/vnc/session.d.ts +12 -0
  62. package/dist/protocols/vnc/session.js +0 -1
  63. package/dist/shared/connection.d.ts +81 -0
  64. package/dist/shared/connection.js +0 -1
  65. package/dist/shared/device.d.ts +26 -0
  66. package/dist/shared/device.js +0 -1
  67. package/dist/shared/hosts.d.ts +63 -0
  68. package/dist/shared/hosts.js +0 -1
  69. package/dist/shared/icons.d.ts +46 -0
  70. package/dist/shared/icons.js +0 -1
  71. package/dist/shared/protocol.d.ts +28 -0
  72. package/dist/shared/protocol.js +0 -1
  73. package/dist/shared/signals.d.ts +37 -0
  74. package/dist/shared/signals.js +0 -1
  75. package/package.json +10 -11
  76. package/dist/index.js.map +0 -7
  77. package/dist/protocols/index.js.map +0 -7
  78. package/dist/protocols/rdp/buffer.js.map +0 -7
  79. package/dist/protocols/rdp/caps.js.map +0 -7
  80. package/dist/protocols/rdp/cert.js.map +0 -7
  81. package/dist/protocols/rdp/client.js.map +0 -7
  82. package/dist/protocols/rdp/cliprdr.js.map +0 -7
  83. package/dist/protocols/rdp/credssp.js.map +0 -7
  84. package/dist/protocols/rdp/crypto.js.map +0 -7
  85. package/dist/protocols/rdp/display.js.map +0 -7
  86. package/dist/protocols/rdp/gcc.js.map +0 -7
  87. package/dist/protocols/rdp/keymap.js.map +0 -7
  88. package/dist/protocols/rdp/mcs.js.map +0 -7
  89. package/dist/protocols/rdp/ntlm.js.map +0 -7
  90. package/dist/protocols/rdp/pdu.js.map +0 -7
  91. package/dist/protocols/rdp/rail.js.map +0 -7
  92. package/dist/protocols/rdp/rle.js.map +0 -7
  93. package/dist/protocols/rdp/sec.js.map +0 -7
  94. package/dist/protocols/rdp/session.js.map +0 -7
  95. package/dist/protocols/rdp/tls.js.map +0 -7
  96. package/dist/protocols/rdp/vchannel.js.map +0 -7
  97. package/dist/protocols/rdp/x224.js.map +0 -7
  98. package/dist/protocols/ssh/kex.js.map +0 -7
  99. package/dist/protocols/ssh/messages.js.map +0 -7
  100. package/dist/protocols/ssh/session.js.map +0 -7
  101. package/dist/protocols/ssh/terminal.js.map +0 -7
  102. package/dist/protocols/ssh/transport.js.map +0 -7
  103. package/dist/protocols/ssh/wire.js.map +0 -7
  104. package/dist/protocols/types.js.map +0 -7
  105. package/dist/protocols/vnc/input.js.map +0 -7
  106. package/dist/protocols/vnc/session.js.map +0 -7
  107. package/dist/shared/connection.js.map +0 -7
  108. package/dist/shared/device.js.map +0 -7
  109. package/dist/shared/hosts.js.map +0 -7
  110. package/dist/shared/icons.js.map +0 -7
  111. package/dist/shared/protocol.js.map +0 -7
  112. package/dist/shared/signals.js.map +0 -7
  113. package/src/cli/cli.ts +0 -462
  114. package/src/cli/daemon.ts +0 -306
  115. package/src/cli/framebuffer.ts +0 -115
  116. package/src/cli/generated/viewer-bundle.ts +0 -5
  117. package/src/cli/ipc.ts +0 -78
  118. package/src/cli/native/window.swift +0 -151
  119. package/src/cli/paths.ts +0 -28
  120. package/src/cli/png.ts +0 -106
  121. package/src/cli/session.ts +0 -263
  122. package/src/cli/shell.ts +0 -184
  123. package/src/cli/transport.ts +0 -86
  124. package/src/cli/viewer-client/assets.d.ts +0 -4
  125. package/src/cli/viewer-client/main.ts +0 -323
  126. package/src/cli/viewer-page.ts +0 -138
  127. package/src/cli/viewer.ts +0 -296
  128. package/src/cli/window.ts +0 -140
  129. package/src/cli/wsserver.ts +0 -144
  130. package/src/protocols/index.ts +0 -72
  131. package/src/protocols/rdp/buffer.ts +0 -204
  132. package/src/protocols/rdp/caps.ts +0 -304
  133. package/src/protocols/rdp/cert.ts +0 -190
  134. package/src/protocols/rdp/client.ts +0 -1371
  135. package/src/protocols/rdp/cliprdr.ts +0 -344
  136. package/src/protocols/rdp/credssp.ts +0 -319
  137. package/src/protocols/rdp/crypto.ts +0 -416
  138. package/src/protocols/rdp/display.ts +0 -750
  139. package/src/protocols/rdp/gcc.ts +0 -162
  140. package/src/protocols/rdp/keymap.ts +0 -68
  141. package/src/protocols/rdp/mcs.ts +0 -283
  142. package/src/protocols/rdp/ntlm.ts +0 -380
  143. package/src/protocols/rdp/pdu.ts +0 -497
  144. package/src/protocols/rdp/rail.ts +0 -480
  145. package/src/protocols/rdp/rle.ts +0 -343
  146. package/src/protocols/rdp/sec.ts +0 -184
  147. package/src/protocols/rdp/session.ts +0 -393
  148. package/src/protocols/rdp/tls.ts +0 -452
  149. package/src/protocols/rdp/vchannel.ts +0 -89
  150. package/src/protocols/rdp/x224.ts +0 -139
  151. package/src/protocols/ssh/kex.ts +0 -227
  152. package/src/protocols/ssh/messages.ts +0 -54
  153. package/src/protocols/ssh/session.ts +0 -879
  154. package/src/protocols/ssh/terminal.ts +0 -242
  155. package/src/protocols/ssh/transport.ts +0 -745
  156. package/src/protocols/ssh/wire.ts +0 -220
  157. package/src/protocols/types.ts +0 -146
  158. package/src/protocols/vnc/input.ts +0 -13
  159. package/src/protocols/vnc/novnc.d.ts +0 -75
  160. package/src/protocols/vnc/session.ts +0 -367
  161. package/src/shared/connection.ts +0 -206
  162. package/src/shared/device.ts +0 -28
  163. package/src/shared/hosts.ts +0 -240
  164. package/src/shared/icons.ts +0 -49
  165. package/src/shared/protocol.ts +0 -55
  166. package/src/shared/signals.ts +0 -67
@@ -1,242 +0,0 @@
1
- // The terminal surface: xterm.js, themed to match the gateway, wired to an
2
- // SSH session's bytes in and keystrokes out.
3
-
4
- import { Terminal } from '@xterm/xterm';
5
- import { FitAddon } from '@xterm/addon-fit';
6
- import xtermStyles from '@xterm/xterm/css/xterm.css';
7
-
8
- const STYLE_ELEMENT_ID = 'xterm-styles';
9
-
10
- /**
11
- * The width almost every command's output is laid out for.
12
- *
13
- * A terminal narrower than this does not merely look cramped, it garbles: `ls
14
- * -l`, `Get-ChildItem`, `ps` and `top` all place columns by character position,
15
- * so the last column wraps one letter per line and the table stops being a
16
- * table. Fitting the font to the panel rather than the panel to the font is
17
- * what keeps that from happening in a docked panel or on a phone.
18
- */
19
- const MIN_COLUMNS = 80;
20
-
21
- /** Comfortable on a wide panel, and the size a roomy one keeps. */
22
- const BASE_FONT_SIZE = 13;
23
-
24
- /**
25
- * The floor. On a small mobile screen this yields 80 columns without wrapping
26
- * or cutting off table outputs.
27
- */
28
- const MIN_FONT_SIZE = 7;
29
-
30
- /** xterm ships its own stylesheet; the bundle carries it instead of a CDN. */
31
- function installStyles() {
32
- if (document.getElementById(STYLE_ELEMENT_ID)) return;
33
- const style = document.createElement('style');
34
- style.id = STYLE_ELEMENT_ID;
35
- style.textContent = xtermStyles;
36
- document.head.appendChild(style);
37
- }
38
-
39
- /** The gateway's palette, so the terminal belongs to the same application. */
40
- const THEME = {
41
- background: '#0b0d12',
42
- foreground: '#dfe4ec',
43
- cursor: '#f38020',
44
- cursorAccent: '#0b0d12',
45
- selectionBackground: 'rgba(243, 128, 32, 0.32)',
46
- black: '#1b1f27',
47
- red: '#ff6b6b',
48
- green: '#4ade80',
49
- yellow: '#fbbf24',
50
- blue: '#60a5fa',
51
- magenta: '#c084fc',
52
- cyan: '#34d3ee',
53
- white: '#cbd3e1',
54
- brightBlack: '#63708a',
55
- brightRed: '#ff8787',
56
- brightGreen: '#86efac',
57
- brightYellow: '#fcd34d',
58
- brightBlue: '#93c5fd',
59
- brightMagenta: '#d8b4fe',
60
- brightCyan: '#67e8f9',
61
- brightWhite: '#f5f7fa',
62
- };
63
-
64
- export class SshTerminal {
65
- constructor(container) {
66
- installStyles();
67
-
68
- this.container = container;
69
- this.terminal = new Terminal({
70
- allowProposedApi: true,
71
- convertEol: false,
72
- cursorBlink: true,
73
- cursorStyle: 'bar',
74
- drawBoldTextInBrightColors: true,
75
- fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',
76
- fontSize: BASE_FONT_SIZE,
77
- lineHeight: 1.25,
78
- letterSpacing: 0,
79
- macOptionIsMeta: true,
80
- minimumContrastRatio: 1.5,
81
- scrollback: 10_000,
82
- theme: THEME,
83
- });
84
-
85
- this.fitAddon = new FitAddon();
86
- this.terminal.loadAddon(this.fitAddon);
87
- this.terminal.open(container);
88
- this.fit();
89
-
90
- // The panel is resizable and the browser window is not the only thing that
91
- // changes its size, so follow the element rather than the window.
92
- this.observer = new ResizeObserver(() => this.fit());
93
- this.observer.observe(container);
94
-
95
- this.dataHandler = null;
96
- this.terminal.onData((data: Uint8Array) => this.dataHandler?.(data));
97
- }
98
-
99
- get columns() {
100
- return this.terminal.cols;
101
- }
102
-
103
- get rows() {
104
- return this.terminal.rows;
105
- }
106
-
107
- onData(handler) {
108
- this.dataHandler = handler;
109
- }
110
-
111
- onResize(handler) {
112
- this.terminal.onResize(({ cols, rows }) => handler(cols, rows));
113
- }
114
-
115
- write(data: Uint8Array) {
116
- this.terminal.write(data);
117
- }
118
-
119
- /** Gateway-side notices, kept visually apart from what the host prints. */
120
- notice(text: string, tone = 'info') {
121
- const color = { info: '\x1b[38;5;245m', good: '\x1b[38;5;114m', bad: '\x1b[38;5;203m' }[tone] || '';
122
- this.terminal.write(`${color}${text}\x1b[0m\r\n`);
123
- }
124
-
125
- clear() {
126
- this.terminal.clear();
127
- }
128
-
129
- focus() {
130
- this.terminal.focus();
131
- }
132
-
133
- /**
134
- * Size the terminal to the panel, choosing the font so MIN_COLUMNS fit.
135
- *
136
- * The columns matter more than the type size here: the commands people run in
137
- * a side panel -- `ls -l`, `top`, anything in PowerShell that prints a table
138
- * -- are laid out for 80 columns, and a narrower grid wraps every row into an
139
- * unreadable stack.
140
- *
141
- * `proposeDimensions()` reports the grid the current font size yields, and a
142
- * monospace cell's width scales with its font size, so `fontSize * cols /
143
- * MIN_COLUMNS` lands close to the size that gives MIN_COLUMNS. It is measured
144
- * rather than assumed because the cell-width-to-font-size ratio belongs to
145
- * whichever font the platform picked. A second pass settles the rounding.
146
- * Changing the font resizes the element, which the ResizeObserver sees, so
147
- * the guard keeps that from recursing.
148
- */
149
- fit() {
150
- if (this.fitting) return;
151
- if (this.container.clientWidth <= 0 || this.container.clientHeight <= 0) return;
152
-
153
- this.fitting = true;
154
- try {
155
- for (let pass = 0; pass < 2; pass++) {
156
- const proposed = this.fitAddon.proposeDimensions();
157
- if (!proposed || !(proposed.cols > 0)) break;
158
-
159
- const current = this.terminal.options.fontSize || BASE_FONT_SIZE;
160
- const wanted = Math.min(
161
- BASE_FONT_SIZE,
162
- Math.max(MIN_FONT_SIZE, Math.floor((current * proposed.cols) / MIN_COLUMNS))
163
- );
164
- if (wanted === current) break;
165
- this.terminal.options.fontSize = wanted;
166
- }
167
-
168
- this.fitAddon.fit();
169
-
170
- // A panel narrow enough to be short of MIN_COLUMNS even at the smallest
171
- // type keeps the columns and scrolls sideways instead, because wrapped
172
- // output is harder to read than output that has to be scrolled to.
173
- const short = this.terminal.cols < MIN_COLUMNS;
174
- this.container.classList.toggle('is-narrow', short);
175
- if (short) this.terminal.resize(MIN_COLUMNS, this.terminal.rows);
176
- } catch {
177
- // A hidden panel has no size to fit to; the next resize will catch it.
178
- } finally {
179
- this.fitting = false;
180
- }
181
- }
182
-
183
- /** The grid the host is being told about, for a status line or a log. */
184
- get geometry() {
185
- return {
186
- columns: this.terminal.cols,
187
- rows: this.terminal.rows,
188
- fontSize: this.terminal.options.fontSize,
189
- };
190
- }
191
-
192
- get selection() {
193
- return this.terminal.getSelection();
194
- }
195
-
196
- /**
197
- * Read one line from the user, for a password or a one-time code the host
198
- * asked for during authentication. The shell is not open yet, so the
199
- * terminal is free to be a prompt.
200
- */
201
- readLine({ prompt = '', echo = false } = {}) {
202
- return new Promise((resolve) => {
203
- const previous = this.dataHandler;
204
- let answer = '';
205
-
206
- this.terminal.write(prompt.replaceAll('\n', '\r\n'));
207
- this.dataHandler = (data: Uint8Array) => {
208
- for (const character of data) {
209
- const code = character.charCodeAt(0);
210
-
211
- if (code === 0x0d || code === 0x0a) { // Enter, or a pasted line break
212
- this.terminal.write('\r\n');
213
- this.dataHandler = previous;
214
- resolve(answer);
215
- return;
216
- }
217
- if (code === 0x7f || code === 0x08) { // Backspace
218
- if (answer.length === 0) continue;
219
- answer = answer.slice(0, -1);
220
- if (echo) this.terminal.write('\b \b');
221
- continue;
222
- }
223
- if (code === 0x03) { // Ctrl-C
224
- this.terminal.write('^C\r\n');
225
- this.dataHandler = previous;
226
- resolve('');
227
- return;
228
- }
229
- if (code < 0x20) continue;
230
-
231
- answer += character;
232
- if (echo) this.terminal.write(character);
233
- }
234
- };
235
- });
236
- }
237
-
238
- destroy() {
239
- this.observer?.disconnect();
240
- this.terminal.dispose();
241
- }
242
- }