screen-relay 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/Makefile +165 -0
- package/README.md +113 -2
- package/THIRD-PARTY-NOTICES.md +75 -0
- package/dist/cli/client.d.ts +28 -0
- package/dist/cli/commands.d.ts +52 -0
- package/dist/cli/config.d.ts +32 -0
- package/dist/cli/format.d.ts +15 -0
- package/dist/cli/help.d.ts +5 -0
- package/dist/cli/host/common.d.ts +23 -0
- package/dist/cli/host/doctor.d.ts +2 -0
- package/dist/cli/host/packages.d.ts +13 -0
- package/dist/cli/host/session_commands.d.ts +8 -0
- package/dist/cli/host/setup.d.ts +22 -0
- package/dist/cli/host/state.d.ts +23 -0
- package/dist/cli/host/supervisor.d.ts +91 -0
- package/dist/cli/host/watcher.d.ts +4 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/mode.d.ts +14 -0
- package/dist/cli/output.d.ts +24 -0
- package/dist/cli/parser.d.ts +6 -0
- package/dist/cli/relay.mjs +12247 -0
- package/dist/cli/skills.d.ts +21 -0
- package/dist/cli/theme.d.ts +14 -0
- package/dist/protocol/errors.d.ts +155 -0
- package/dist/protocol/index.d.ts +119 -0
- package/dist/protocol/index.js +418 -0
- package/dist/sdk/index.d.ts +77 -0
- package/dist/sdk/index.js +724 -0
- package/dist/viewer/index.html +96 -0
- package/dist/viewer/viewer.js +1052 -0
- package/package.json +50 -4
- package/packages.tsv +38 -0
- package/skills/core/SKILL.md +169 -0
- package/skills/core/references/cli.md +119 -0
- package/skills/core/references/config.md +48 -0
- package/skills/core/references/macos.md +50 -0
- package/skills/core/references/sdk.md +69 -0
- package/skills/core/references/troubleshooting.md +33 -0
- package/skills/core/references/wayland.md +47 -0
- package/skills/screen-relay/SKILL.md +24 -0
- package/skills/vercel-sandbox/SKILL.md +68 -0
- package/src/engine/backends/linux/keycodes.hpp +35 -0
- package/src/engine/backends/linux/wayland/capture.cpp +298 -0
- package/src/engine/backends/linux/wayland/input.cpp +559 -0
- package/src/engine/backends/linux/wayland/keymap.cpp +118 -0
- package/src/engine/backends/linux/wayland/keymap.hpp +54 -0
- package/src/engine/backends/linux/wayland/protocols/virtual-keyboard-unstable-v1.xml +112 -0
- package/src/engine/backends/linux/wayland/protocols/wlr-screencopy-unstable-v1.xml +234 -0
- package/src/engine/backends/linux/wayland/protocols/wlr-virtual-pointer-unstable-v1.xml +152 -0
- package/src/engine/backends/linux/wayland/wayland.cpp +166 -0
- package/src/engine/backends/linux/wayland/wayland.hpp +60 -0
- package/src/engine/backends/linux/x11/capture.cpp +206 -0
- package/src/engine/backends/linux/x11/input.cpp +266 -0
- package/src/engine/backends/macos/capture.mm +367 -0
- package/src/engine/backends/macos/display.hpp +20 -0
- package/src/engine/backends/macos/display.mm +84 -0
- package/src/engine/backends/macos/input.mm +287 -0
- package/src/engine/backends/macos/keys.hpp +34 -0
- package/src/engine/backends/windows/capture.cpp +393 -0
- package/src/engine/backends/windows/input.cpp +274 -0
- package/src/engine/backends/windows/output.cpp +65 -0
- package/src/engine/backends/windows/output.hpp +26 -0
- package/src/engine/core/capture-bucket.hpp +40 -0
- package/src/engine/core/capture-source.hpp +59 -0
- package/src/engine/core/capture.cpp +565 -0
- package/src/engine/core/capture.hpp +58 -0
- package/src/engine/core/color.cpp +176 -0
- package/src/engine/core/color.hpp +16 -0
- package/src/engine/core/cpu-budget.hpp +196 -0
- package/src/engine/core/flow.hpp +317 -0
- package/src/engine/core/input.cpp +98 -0
- package/src/engine/core/input.hpp +115 -0
- package/src/engine/core/wait.cpp +125 -0
- package/src/engine/core/wait.hpp +41 -0
- package/src/engine/server/backend.cpp +65 -0
- package/src/engine/server/backend.hpp +18 -0
- package/src/engine/server/config.cpp +257 -0
- package/src/engine/server/config.hpp +24 -0
- package/src/engine/server/main.cpp +82 -0
- package/src/engine/server/metrics.cpp +47 -0
- package/src/engine/server/metrics.hpp +10 -0
- package/src/engine/server/screenshot.cpp +108 -0
- package/src/engine/server/screenshot.hpp +31 -0
- package/src/engine/server/server.cpp +531 -0
- package/src/engine/server/server.hpp +88 -0
- package/src/engine/server/wire.cpp +65 -0
- package/src/engine/server/wire.hpp +27 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Failure } from './output.js';
|
|
2
|
+
/** Lists visible skills with their names and descriptions. */
|
|
3
|
+
export declare function list(): {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}[];
|
|
7
|
+
/** Returns a skill's Markdown, optionally appending all reference and template files. */
|
|
8
|
+
export declare function get(name: string, options?: {
|
|
9
|
+
full?: boolean;
|
|
10
|
+
}): {
|
|
11
|
+
name: string;
|
|
12
|
+
content: string;
|
|
13
|
+
};
|
|
14
|
+
/** Returns the skills directory, or a named skill's directory. */
|
|
15
|
+
export declare function path(name?: string): string;
|
|
16
|
+
/** Explains an unknown action; a skill name points at its get command instead. */
|
|
17
|
+
export declare function unknownAction(action: string): Failure;
|
|
18
|
+
/** Runs skills list, get and path, printing text or the noun-shaped JSON document. */
|
|
19
|
+
export declare function cmdSkills(args: Record<string, unknown> & {
|
|
20
|
+
json: boolean;
|
|
21
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OutputOptions } from './mode.js';
|
|
2
|
+
export declare function theme(args?: OutputOptions, stream?: NodeJS.WriteStream): {
|
|
3
|
+
plain: boolean;
|
|
4
|
+
success: string;
|
|
5
|
+
warning: string;
|
|
6
|
+
error: string;
|
|
7
|
+
primary: (value: string) => string;
|
|
8
|
+
strong: (value: string) => string;
|
|
9
|
+
dim: (value: string) => string;
|
|
10
|
+
italic: (value: string) => string;
|
|
11
|
+
muted: (value: string) => string;
|
|
12
|
+
command: (value: string) => string;
|
|
13
|
+
accent: (value: string) => string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
export type ErrorClass = 'usage' | 'missing_input' | 'not_found' | 'conflict' | 'network' | 'platform' | 'permission' | 'config' | 'bug' | 'canceled';
|
|
2
|
+
export interface NextCommand {
|
|
3
|
+
command: string;
|
|
4
|
+
argv: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface ErrorOptions {
|
|
7
|
+
hint?: string;
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
next?: NextCommand[];
|
|
10
|
+
status?: 'error' | 'action_required';
|
|
11
|
+
label?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const ERROR_REASONS: {
|
|
14
|
+
readonly invalid_input: {
|
|
15
|
+
readonly class: 'usage';
|
|
16
|
+
readonly code: 'INVALID_ARGUMENT';
|
|
17
|
+
readonly exitCode: 2;
|
|
18
|
+
};
|
|
19
|
+
readonly invalid_option: {
|
|
20
|
+
readonly class: 'usage';
|
|
21
|
+
readonly code: 'INVALID_ARGUMENT';
|
|
22
|
+
readonly exitCode: 2;
|
|
23
|
+
};
|
|
24
|
+
readonly unknown_command: {
|
|
25
|
+
readonly class: 'usage';
|
|
26
|
+
readonly code: 'INVALID_ARGUMENT';
|
|
27
|
+
readonly exitCode: 2;
|
|
28
|
+
};
|
|
29
|
+
readonly missing_input: {
|
|
30
|
+
readonly class: 'missing_input';
|
|
31
|
+
readonly code: 'INVALID_ARGUMENT';
|
|
32
|
+
readonly exitCode: 2;
|
|
33
|
+
};
|
|
34
|
+
readonly missing_command: {
|
|
35
|
+
readonly class: 'missing_input';
|
|
36
|
+
readonly code: 'INVALID_ARGUMENT';
|
|
37
|
+
readonly exitCode: 2;
|
|
38
|
+
};
|
|
39
|
+
readonly not_found: {
|
|
40
|
+
readonly class: 'not_found';
|
|
41
|
+
readonly code: 'NOT_FOUND';
|
|
42
|
+
readonly exitCode: 1;
|
|
43
|
+
};
|
|
44
|
+
readonly not_running: {
|
|
45
|
+
readonly class: 'not_found';
|
|
46
|
+
readonly code: 'NOT_FOUND';
|
|
47
|
+
readonly exitCode: 1;
|
|
48
|
+
};
|
|
49
|
+
readonly already_running: {
|
|
50
|
+
readonly class: 'conflict';
|
|
51
|
+
readonly code: 'BUSY';
|
|
52
|
+
readonly exitCode: 1;
|
|
53
|
+
};
|
|
54
|
+
readonly port_in_use: {
|
|
55
|
+
readonly class: 'conflict';
|
|
56
|
+
readonly code: 'BUSY';
|
|
57
|
+
readonly exitCode: 1;
|
|
58
|
+
};
|
|
59
|
+
readonly busy: {
|
|
60
|
+
readonly class: 'conflict';
|
|
61
|
+
readonly code: 'BUSY';
|
|
62
|
+
readonly exitCode: 1;
|
|
63
|
+
};
|
|
64
|
+
readonly unreachable: {
|
|
65
|
+
readonly class: 'network';
|
|
66
|
+
readonly code: 'NETWORK_ERROR';
|
|
67
|
+
readonly exitCode: 1;
|
|
68
|
+
};
|
|
69
|
+
readonly timeout: {
|
|
70
|
+
readonly class: 'network';
|
|
71
|
+
readonly code: 'TIMEOUT';
|
|
72
|
+
readonly exitCode: 1;
|
|
73
|
+
};
|
|
74
|
+
readonly disconnected: {
|
|
75
|
+
readonly class: 'network';
|
|
76
|
+
readonly code: 'DISCONNECTED';
|
|
77
|
+
readonly exitCode: 1;
|
|
78
|
+
};
|
|
79
|
+
readonly unauthorized: {
|
|
80
|
+
readonly class: 'permission';
|
|
81
|
+
readonly code: 'UNAUTHORIZED';
|
|
82
|
+
readonly exitCode: 1;
|
|
83
|
+
};
|
|
84
|
+
readonly forbidden: {
|
|
85
|
+
readonly class: 'permission';
|
|
86
|
+
readonly code: 'UNAUTHORIZED';
|
|
87
|
+
readonly exitCode: 1;
|
|
88
|
+
};
|
|
89
|
+
readonly unsupported_input: {
|
|
90
|
+
readonly class: 'platform';
|
|
91
|
+
readonly code: 'UNSUPPORTED';
|
|
92
|
+
readonly exitCode: 1;
|
|
93
|
+
};
|
|
94
|
+
readonly unsupported_platform: {
|
|
95
|
+
readonly class: 'platform';
|
|
96
|
+
readonly code: 'UNSUPPORTED';
|
|
97
|
+
readonly exitCode: 1;
|
|
98
|
+
};
|
|
99
|
+
readonly missing_dependency: {
|
|
100
|
+
readonly class: 'platform';
|
|
101
|
+
readonly code: 'UNSUPPORTED';
|
|
102
|
+
readonly exitCode: 1;
|
|
103
|
+
};
|
|
104
|
+
readonly component_failed: {
|
|
105
|
+
readonly class: 'platform';
|
|
106
|
+
readonly code: 'HTTP_ERROR';
|
|
107
|
+
readonly exitCode: 1;
|
|
108
|
+
};
|
|
109
|
+
readonly spawn_failed: {
|
|
110
|
+
readonly class: 'platform';
|
|
111
|
+
readonly code: 'IO_ERROR';
|
|
112
|
+
readonly exitCode: 1;
|
|
113
|
+
};
|
|
114
|
+
readonly io_error: {
|
|
115
|
+
readonly class: 'platform';
|
|
116
|
+
readonly code: 'IO_ERROR';
|
|
117
|
+
readonly exitCode: 1;
|
|
118
|
+
};
|
|
119
|
+
readonly protocol_error: {
|
|
120
|
+
readonly class: 'platform';
|
|
121
|
+
readonly code: 'PROTOCOL_ERROR';
|
|
122
|
+
readonly exitCode: 1;
|
|
123
|
+
};
|
|
124
|
+
readonly invalid_config: {
|
|
125
|
+
readonly class: 'config';
|
|
126
|
+
readonly code: 'CONFIG_ERROR';
|
|
127
|
+
readonly exitCode: 1;
|
|
128
|
+
};
|
|
129
|
+
readonly internal: {
|
|
130
|
+
readonly class: 'bug';
|
|
131
|
+
readonly code: 'INTERNAL';
|
|
132
|
+
readonly exitCode: 1;
|
|
133
|
+
};
|
|
134
|
+
readonly canceled: {
|
|
135
|
+
readonly class: 'canceled';
|
|
136
|
+
readonly code: 'CANCELED';
|
|
137
|
+
readonly exitCode: 130;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
export type ErrorReason = keyof typeof ERROR_REASONS;
|
|
141
|
+
export declare class RelayError extends Error {
|
|
142
|
+
readonly code: string;
|
|
143
|
+
readonly reason: ErrorReason;
|
|
144
|
+
readonly class: ErrorClass;
|
|
145
|
+
readonly exitCode: number;
|
|
146
|
+
readonly hint?: string;
|
|
147
|
+
readonly data?: Record<string, unknown>;
|
|
148
|
+
readonly next?: NextCommand[];
|
|
149
|
+
readonly status: 'error' | 'action_required';
|
|
150
|
+
readonly label?: string;
|
|
151
|
+
constructor(reason: string, message: string, options?: string | ErrorOptions);
|
|
152
|
+
}
|
|
153
|
+
/** Maps a Node network failure to the shared timeout or unreachable reason with a human cause. */
|
|
154
|
+
export declare function networkError(error: unknown): RelayError;
|
|
155
|
+
export declare function responseError(status: number, detail: unknown): RelayError;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export { RelayError, ERROR_REASONS, networkError, responseError } from './errors.js';
|
|
2
|
+
export type { ErrorClass, ErrorReason, ErrorOptions, NextCommand } from './errors.js';
|
|
3
|
+
export declare const MAGIC = 1314081841;
|
|
4
|
+
export declare const VERSION = 1;
|
|
5
|
+
export declare const HEADER_SIZE = 20;
|
|
6
|
+
export declare const INPUT_SIZE = 16;
|
|
7
|
+
export declare const MAX_INPUT_BATCH = 256;
|
|
8
|
+
export declare const MAX_INPUT_PENDING = 32;
|
|
9
|
+
export declare const MAX_WIDTH = 65535;
|
|
10
|
+
export declare const MAX_HEIGHT = 65535;
|
|
11
|
+
export declare const MAX_BYTES_IN_FLIGHT = 8388608;
|
|
12
|
+
export declare const SUBPROTOCOL = "nsl1";
|
|
13
|
+
export declare const MESSAGE_TYPES: {
|
|
14
|
+
readonly frame: 1;
|
|
15
|
+
readonly ack: 2;
|
|
16
|
+
readonly input: 3;
|
|
17
|
+
readonly controlReady: 4;
|
|
18
|
+
readonly inputResponse: 5;
|
|
19
|
+
readonly cursor: 6;
|
|
20
|
+
};
|
|
21
|
+
export declare const INPUT_TYPES: {
|
|
22
|
+
readonly keyDown: 1;
|
|
23
|
+
readonly keyUp: 2;
|
|
24
|
+
readonly pointerMove: 3;
|
|
25
|
+
readonly buttonDown: 4;
|
|
26
|
+
readonly buttonUp: 5;
|
|
27
|
+
readonly wheel: 6;
|
|
28
|
+
readonly releaseAll: 7;
|
|
29
|
+
readonly text: 8;
|
|
30
|
+
};
|
|
31
|
+
export type InputEvent = ({
|
|
32
|
+
type: 'keyDown' | 'keyUp';
|
|
33
|
+
key: number;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'pointerMove';
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'buttonDown' | 'buttonUp';
|
|
40
|
+
button: 1 | 2 | 3;
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'wheel';
|
|
45
|
+
axis: 'vertical' | 'horizontal';
|
|
46
|
+
delta: number;
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'releaseAll';
|
|
51
|
+
} | {
|
|
52
|
+
type: 'text';
|
|
53
|
+
codepoint: number;
|
|
54
|
+
}) & {
|
|
55
|
+
buttons?: number;
|
|
56
|
+
modifiers?: number;
|
|
57
|
+
};
|
|
58
|
+
export declare function integer(value: number, min: number, max: number, name: string): number;
|
|
59
|
+
export declare function coordinate(value: number, name: string): number;
|
|
60
|
+
export declare function encodeInputRecord(event: InputEvent): Uint8Array;
|
|
61
|
+
export declare function encodeInputBatch(events: InputEvent[]): Uint8Array;
|
|
62
|
+
export declare function batches(groups: InputEvent[][], limit?: number): InputEvent[][];
|
|
63
|
+
export declare function header(type: number, generation: number, sequence: number, size: number): Uint8Array;
|
|
64
|
+
export declare function encodeInput(event: InputEvent, generation: number, sequence: number): Uint8Array;
|
|
65
|
+
/** Builds an ACK carrying how long the frame waited inside the viewer, in microseconds, saturating at 2^32 - 1. Without a wait it is the 20-byte ACK that engines before the wait field require. */
|
|
66
|
+
export declare function encodeAck(generation: number, sequence: number, viewerWaitMs?: number): Uint8Array;
|
|
67
|
+
export interface Header {
|
|
68
|
+
type: number;
|
|
69
|
+
flags: number;
|
|
70
|
+
generation: number;
|
|
71
|
+
sequence: number;
|
|
72
|
+
payloadLength: number;
|
|
73
|
+
}
|
|
74
|
+
export declare function parseHeader(bytes: Uint8Array | ArrayBuffer): Header;
|
|
75
|
+
export type Message = {
|
|
76
|
+
type: 'frame';
|
|
77
|
+
generation: number;
|
|
78
|
+
sequence: number;
|
|
79
|
+
keyframe: boolean;
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
timestamp: number;
|
|
83
|
+
data: Uint8Array;
|
|
84
|
+
} | {
|
|
85
|
+
type: 'cursor';
|
|
86
|
+
generation: number;
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
hotX: number;
|
|
90
|
+
hotY: number;
|
|
91
|
+
pixels: Uint8ClampedArray;
|
|
92
|
+
} | {
|
|
93
|
+
type: 'controlReady';
|
|
94
|
+
generation: number;
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
} | {
|
|
98
|
+
type: 'inputResponse';
|
|
99
|
+
generation: number;
|
|
100
|
+
sequence: number;
|
|
101
|
+
status: number;
|
|
102
|
+
};
|
|
103
|
+
/** Validates and decodes one server message; throws a protocol_error RelayError for anything malformed or client-bound. */
|
|
104
|
+
export declare function parseMessage(bytes: Uint8Array | ArrayBuffer): Message;
|
|
105
|
+
/** Returns the `avc1.PPCCLL` codec string from the SPS in an H.264 Annex B keyframe. */
|
|
106
|
+
export declare function h264Codec(bytes: Uint8Array): string;
|
|
107
|
+
/** Returns the WebSocket URL and subprotocols for `/stream` or `/control` on an engine origin. */
|
|
108
|
+
export declare function socketTarget(origin: URL, path: '/stream' | '/control', token?: string): {
|
|
109
|
+
url: URL;
|
|
110
|
+
protocols: string[];
|
|
111
|
+
};
|
|
112
|
+
export declare const HID_KEYS: Record<string, number>;
|
|
113
|
+
export declare const MODIFIERS: Readonly<Record<string, number>>;
|
|
114
|
+
export declare const NAMED_KEYS: Readonly<Record<string, number>>;
|
|
115
|
+
export declare function comboEvents(spec: string): InputEvent[];
|
|
116
|
+
export declare function textEvents(text: string): InputEvent[];
|
|
117
|
+
export declare function isLoopback(hostname: string): boolean;
|
|
118
|
+
export declare function validToken(token: unknown): token is string;
|
|
119
|
+
export declare function baseUrl(url: string, token?: string): URL;
|