@getmateo/protocol 0.0.0-stage → 0.17.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/LICENSE +211 -0
- package/README.md +11 -2
- package/dist/addresses.d.ts +6 -0
- package/dist/addresses.js +2 -0
- package/dist/agent-attention-notification.d.ts +57 -0
- package/dist/agent-attention-notification.js +177 -0
- package/dist/agent-deep-link.d.ts +8 -0
- package/dist/agent-deep-link.js +49 -0
- package/dist/agent-labels.d.ts +14 -0
- package/dist/agent-labels.js +38 -0
- package/dist/agent-lifecycle.d.ts +3 -0
- package/dist/agent-lifecycle.js +8 -0
- package/dist/agent-message.d.ts +20 -0
- package/dist/agent-message.js +12 -0
- package/dist/agent-profile.d.ts +31 -0
- package/dist/agent-profile.js +32 -0
- package/dist/agent-runtime-config.d.ts +4 -0
- package/dist/agent-runtime-config.js +5 -0
- package/dist/agent-shells.d.ts +25 -0
- package/dist/agent-shells.js +17 -0
- package/dist/agent-state-bucket.d.ts +15 -0
- package/dist/agent-state-bucket.js +41 -0
- package/dist/agent-title-limits.d.ts +2 -0
- package/dist/agent-title-limits.js +2 -0
- package/dist/agent-types.d.ts +484 -0
- package/dist/agent-types.js +33 -0
- package/dist/binary-frames/demux.d.ts +15 -0
- package/dist/binary-frames/demux.js +28 -0
- package/dist/binary-frames/file-transfer.d.ts +51 -0
- package/dist/binary-frames/file-transfer.js +108 -0
- package/dist/binary-frames/host-route.d.ts +13 -0
- package/dist/binary-frames/host-route.js +39 -0
- package/dist/binary-frames/index.d.ts +5 -0
- package/dist/binary-frames/index.js +5 -0
- package/dist/binary-frames/terminal.d.ts +35 -0
- package/dist/binary-frames/terminal.js +100 -0
- package/dist/branch-slug.d.ts +14 -0
- package/dist/branch-slug.js +49 -0
- package/dist/browser-automation/capabilities.d.ts +7 -0
- package/dist/browser-automation/capabilities.js +31 -0
- package/dist/browser-automation/rpc-schemas.d.ts +1113 -0
- package/dist/browser-automation/rpc-schemas.js +463 -0
- package/dist/build-metadata.d.ts +17 -0
- package/dist/build-metadata.js +61 -0
- package/dist/chat/rpc-schemas.d.ts +158 -0
- package/dist/chat/rpc-schemas.js +104 -0
- package/dist/chat/types.d.ts +30 -0
- package/dist/chat/types.js +23 -0
- package/dist/check-traits.d.ts +11 -0
- package/dist/check-traits.js +10 -0
- package/dist/chunked-transport.d.ts +42 -0
- package/dist/chunked-transport.js +277 -0
- package/dist/client-capabilities.d.ts +24 -0
- package/dist/client-capabilities.js +52 -0
- package/dist/connection-offer.d.ts +36 -0
- package/dist/connection-offer.js +53 -0
- package/dist/daemon-auth.d.ts +548 -0
- package/dist/daemon-auth.js +152 -0
- package/dist/daemon-endpoints.d.ts +54 -0
- package/dist/daemon-endpoints.js +243 -0
- package/dist/error-utils.d.ts +11 -0
- package/dist/error-utils.js +27 -0
- package/dist/fleet.d.ts +381 -0
- package/dist/fleet.js +134 -0
- package/dist/forge-manifest.d.ts +66 -0
- package/dist/forge-manifest.js +92 -0
- package/dist/generated/validation/ws-outbound-schema-metadata.d.ts +14023 -0
- package/dist/generated/validation/ws-outbound-schema-metadata.js +258 -0
- package/dist/generated/validation/ws-outbound.aot.d.ts +512 -0
- package/dist/generated/validation/ws-outbound.aot.js +105425 -0
- package/dist/git-remote.d.ts +33 -0
- package/dist/git-remote.js +94 -0
- package/dist/gitea-status.d.ts +10 -0
- package/dist/gitea-status.js +23 -0
- package/dist/gitlab-pipeline.d.ts +10 -0
- package/dist/gitlab-pipeline.js +17 -0
- package/dist/global-terminal.d.ts +3 -0
- package/dist/global-terminal.js +8 -0
- package/dist/host-connection-schema.d.ts +11 -0
- package/dist/host-connection-schema.js +9 -0
- package/dist/host-target.d.ts +20 -0
- package/dist/host-target.js +137 -0
- package/dist/hosts.d.ts +133 -0
- package/dist/hosts.js +82 -0
- package/dist/literal-union.d.ts +2 -0
- package/dist/literal-union.js +2 -0
- package/dist/loop/rpc-schemas.d.ts +636 -0
- package/dist/loop/rpc-schemas.js +164 -0
- package/dist/mateo-config-schema.d.ts +138 -0
- package/dist/mateo-config-schema.js +98 -0
- package/dist/mateo-tool-call-detail.d.ts +2 -0
- package/dist/mateo-tool-call-detail.js +3 -0
- package/dist/mateo-tool-presentation/agent-message.d.ts +10 -0
- package/dist/mateo-tool-presentation/agent-message.js +23 -0
- package/dist/mateo-tool-presentation/catalog.d.ts +320 -0
- package/dist/mateo-tool-presentation/catalog.js +318 -0
- package/dist/mateo-tool-presentation/detail-sections.d.ts +15 -0
- package/dist/mateo-tool-presentation/detail-sections.js +161 -0
- package/dist/mateo-tool-presentation/index.d.ts +22 -0
- package/dist/mateo-tool-presentation/index.js +62 -0
- package/dist/mateo-tool-presentation/summary-text.d.ts +7 -0
- package/dist/mateo-tool-presentation/summary-text.js +22 -0
- package/dist/messages.d.ts +69382 -0
- package/dist/messages.js +6717 -0
- package/dist/path-utils.d.ts +2 -0
- package/dist/path-utils.js +16 -0
- package/dist/plugin-config.d.ts +18 -0
- package/dist/plugin-config.js +13 -0
- package/dist/plugin-overview.d.ts +12 -0
- package/dist/plugin-overview.js +50 -0
- package/dist/plugin-registry.d.ts +153 -0
- package/dist/plugin-registry.js +83 -0
- package/dist/plugin-requirements.d.ts +11 -0
- package/dist/plugin-requirements.js +26 -0
- package/dist/plugin-source-reference.d.ts +11 -0
- package/dist/plugin-source-reference.js +68 -0
- package/dist/provider-config.d.ts +141 -0
- package/dist/provider-config.js +113 -0
- package/dist/provider-icon-names.d.ts +5 -0
- package/dist/provider-icon-names.js +54 -0
- package/dist/provider-manifest.d.ts +30 -0
- package/dist/provider-manifest.js +247 -0
- package/dist/provider-snapshot-codec.d.ts +18 -0
- package/dist/provider-snapshot-codec.js +71 -0
- package/dist/schedule/cadence.d.ts +6 -0
- package/dist/schedule/cadence.js +28 -0
- package/dist/schedule/cron-expression.d.ts +14 -0
- package/dist/schedule/cron-expression.js +107 -0
- package/dist/schedule/rpc-schemas.d.ts +570 -0
- package/dist/schedule/rpc-schemas.js +158 -0
- package/dist/schedule/types.d.ts +201 -0
- package/dist/schedule/types.js +68 -0
- package/dist/search/text-match.d.ts +78 -0
- package/dist/search/text-match.js +330 -0
- package/dist/service-defaults.d.ts +3 -0
- package/dist/service-defaults.js +5 -0
- package/dist/ssh-transport.d.ts +11 -0
- package/dist/ssh-transport.js +72 -0
- package/dist/terminal-activity.d.ts +21 -0
- package/dist/terminal-activity.js +25 -0
- package/dist/terminal-input-mode.d.ts +30 -0
- package/dist/terminal-input-mode.js +180 -0
- package/dist/terminal-key-input.d.ts +13 -0
- package/dist/terminal-key-input.js +210 -0
- package/dist/terminal-profile.d.ts +10 -0
- package/dist/terminal-profile.js +11 -0
- package/dist/terminal-profiles.d.ts +41 -0
- package/dist/terminal-profiles.js +276 -0
- package/dist/terminal-snapshot.d.ts +4 -0
- package/dist/terminal-snapshot.js +220 -0
- package/dist/terminal-stream-protocol.d.ts +2 -0
- package/dist/terminal-stream-protocol.js +2 -0
- package/dist/terminal-subscription-key.d.ts +2 -0
- package/dist/terminal-subscription-key.js +9 -0
- package/dist/timeline-identity.d.ts +3 -0
- package/dist/timeline-identity.js +8 -0
- package/dist/tool-call-display.d.ts +13 -0
- package/dist/tool-call-display.js +144 -0
- package/dist/tool-name-normalization.d.ts +9 -0
- package/dist/tool-name-normalization.js +82 -0
- package/dist/user-agent.d.ts +26 -0
- package/dist/user-agent.js +101 -0
- package/dist/validation/ws-outbound-envelope.d.ts +13261 -0
- package/dist/validation/ws-outbound-envelope.js +17 -0
- package/dist/validation/ws-outbound.d.ts +12 -0
- package/dist/validation/ws-outbound.js +38 -0
- package/dist/websocket-message-limit.d.ts +5 -0
- package/dist/websocket-message-limit.js +5 -0
- package/dist/workspace-labels.d.ts +9 -0
- package/dist/workspace-labels.js +19 -0
- package/package.json +43 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HOST_ROUTE_OPCODE, decodeHostRouteFrame } from "./host-route.js";
|
|
2
|
+
import { decodeFileTransferFrame, FileTransferOpcode, } from "./file-transfer.js";
|
|
3
|
+
import { decodeTerminalStreamFrame, TerminalStreamOpcode, } from "./terminal.js";
|
|
4
|
+
export function decodeBinaryFrame(bytes) {
|
|
5
|
+
switch (bytes[0]) {
|
|
6
|
+
case HOST_ROUTE_OPCODE: {
|
|
7
|
+
const frame = decodeHostRouteFrame(bytes);
|
|
8
|
+
return frame ? { kind: "host_route", frame } : null;
|
|
9
|
+
}
|
|
10
|
+
case TerminalStreamOpcode.Output:
|
|
11
|
+
case TerminalStreamOpcode.Input:
|
|
12
|
+
case TerminalStreamOpcode.Resize:
|
|
13
|
+
case TerminalStreamOpcode.Snapshot:
|
|
14
|
+
case TerminalStreamOpcode.Restore: {
|
|
15
|
+
const frame = decodeTerminalStreamFrame(bytes);
|
|
16
|
+
return frame ? { kind: "terminal", frame } : null;
|
|
17
|
+
}
|
|
18
|
+
case FileTransferOpcode.FileBegin:
|
|
19
|
+
case FileTransferOpcode.FileChunk:
|
|
20
|
+
case FileTransferOpcode.FileEnd: {
|
|
21
|
+
const frame = decodeFileTransferFrame(bytes);
|
|
22
|
+
return frame ? { kind: "file_transfer", frame } : null;
|
|
23
|
+
}
|
|
24
|
+
default:
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=demux.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const FileTransferOpcode: {
|
|
3
|
+
readonly FileBegin: 16;
|
|
4
|
+
readonly FileChunk: 17;
|
|
5
|
+
readonly FileEnd: 18;
|
|
6
|
+
};
|
|
7
|
+
export type FileTransferOpcode = (typeof FileTransferOpcode)[keyof typeof FileTransferOpcode];
|
|
8
|
+
export declare const FileBeginMetadataSchema: z.ZodObject<{
|
|
9
|
+
mime: z.ZodString;
|
|
10
|
+
size: z.ZodNumber;
|
|
11
|
+
encoding: z.ZodEnum<{
|
|
12
|
+
binary: "binary";
|
|
13
|
+
"utf-8": "utf-8";
|
|
14
|
+
}>;
|
|
15
|
+
modifiedAt: z.ZodString;
|
|
16
|
+
revision: z.ZodOptional<z.ZodString>;
|
|
17
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export interface FileBegin {
|
|
20
|
+
opcode: typeof FileTransferOpcode.FileBegin;
|
|
21
|
+
requestId: string;
|
|
22
|
+
metadata: z.infer<typeof FileBeginMetadataSchema>;
|
|
23
|
+
payload: Uint8Array;
|
|
24
|
+
}
|
|
25
|
+
export interface FileChunk {
|
|
26
|
+
opcode: typeof FileTransferOpcode.FileChunk;
|
|
27
|
+
requestId: string;
|
|
28
|
+
payload: Uint8Array;
|
|
29
|
+
}
|
|
30
|
+
export interface FileEnd {
|
|
31
|
+
opcode: typeof FileTransferOpcode.FileEnd;
|
|
32
|
+
requestId: string;
|
|
33
|
+
payload: Uint8Array;
|
|
34
|
+
}
|
|
35
|
+
export type FileTransferFrame = FileBegin | FileChunk | FileEnd;
|
|
36
|
+
type FileTransferFrameInput = {
|
|
37
|
+
opcode: typeof FileTransferOpcode.FileBegin;
|
|
38
|
+
requestId: string;
|
|
39
|
+
metadata: z.infer<typeof FileBeginMetadataSchema>;
|
|
40
|
+
} | {
|
|
41
|
+
opcode: typeof FileTransferOpcode.FileChunk;
|
|
42
|
+
requestId: string;
|
|
43
|
+
payload?: Uint8Array | ArrayBuffer | string;
|
|
44
|
+
} | {
|
|
45
|
+
opcode: typeof FileTransferOpcode.FileEnd;
|
|
46
|
+
requestId: string;
|
|
47
|
+
};
|
|
48
|
+
export declare function encodeFileTransferFrame(input: FileTransferFrameInput): Uint8Array;
|
|
49
|
+
export declare function decodeFileTransferFrame(bytes: Uint8Array): FileTransferFrame | null;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=file-transfer.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { asUint8Array } from "./terminal.js";
|
|
3
|
+
export const FileTransferOpcode = {
|
|
4
|
+
FileBegin: 0x10,
|
|
5
|
+
FileChunk: 0x11,
|
|
6
|
+
FileEnd: 0x12,
|
|
7
|
+
};
|
|
8
|
+
export const FileBeginMetadataSchema = z.object({
|
|
9
|
+
mime: z.string().min(1),
|
|
10
|
+
size: z.number().int().nonnegative(),
|
|
11
|
+
encoding: z.enum(["utf-8", "binary"]),
|
|
12
|
+
modifiedAt: z.string(),
|
|
13
|
+
revision: z.string().optional(),
|
|
14
|
+
fileName: z.string().optional(),
|
|
15
|
+
});
|
|
16
|
+
export function encodeFileTransferFrame(input) {
|
|
17
|
+
const requestId = encodeRequestId(input.requestId);
|
|
18
|
+
if (input.opcode === FileTransferOpcode.FileBegin) {
|
|
19
|
+
const metadata = encodeJsonPayload(input.metadata);
|
|
20
|
+
if (metadata.byteLength > 0xffff) {
|
|
21
|
+
throw new RangeError("FileBegin metadata is too long");
|
|
22
|
+
}
|
|
23
|
+
const bytes = new Uint8Array(4 + requestId.byteLength + metadata.byteLength);
|
|
24
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
25
|
+
bytes[0] = input.opcode;
|
|
26
|
+
bytes[1] = requestId.byteLength;
|
|
27
|
+
bytes.set(requestId, 2);
|
|
28
|
+
view.setUint16(2 + requestId.byteLength, metadata.byteLength);
|
|
29
|
+
bytes.set(metadata, 4 + requestId.byteLength);
|
|
30
|
+
return bytes;
|
|
31
|
+
}
|
|
32
|
+
const payload = input.opcode === FileTransferOpcode.FileChunk
|
|
33
|
+
? (asUint8Array(input.payload ?? new Uint8Array()) ?? new Uint8Array())
|
|
34
|
+
: new Uint8Array();
|
|
35
|
+
const bytes = new Uint8Array(2 + requestId.byteLength + payload.byteLength);
|
|
36
|
+
bytes[0] = input.opcode;
|
|
37
|
+
bytes[1] = requestId.byteLength;
|
|
38
|
+
bytes.set(requestId, 2);
|
|
39
|
+
bytes.set(payload, 2 + requestId.byteLength);
|
|
40
|
+
return bytes;
|
|
41
|
+
}
|
|
42
|
+
export function decodeFileTransferFrame(bytes) {
|
|
43
|
+
if (bytes.byteLength < 2) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const opcode = bytes[0];
|
|
47
|
+
if (!isFileTransferOpcode(opcode)) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const requestIdLength = bytes[1];
|
|
51
|
+
if (requestIdLength === 0 || requestIdLength > bytes.byteLength - 2) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const requestId = decodeRequestId(bytes.subarray(2, 2 + requestIdLength));
|
|
55
|
+
const body = bytes.subarray(2 + requestIdLength);
|
|
56
|
+
if (opcode === FileTransferOpcode.FileBegin) {
|
|
57
|
+
if (body.byteLength < 2) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const view = new DataView(body.buffer, body.byteOffset, body.byteLength);
|
|
61
|
+
const metadataLength = view.getUint16(0);
|
|
62
|
+
if (metadataLength !== body.byteLength - 2) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const metadataBytes = body.subarray(2);
|
|
66
|
+
const result = FileBeginMetadataSchema.safeParse(decodeJsonPayload(metadataBytes));
|
|
67
|
+
return result.success
|
|
68
|
+
? { opcode, requestId, metadata: result.data, payload: new Uint8Array() }
|
|
69
|
+
: null;
|
|
70
|
+
}
|
|
71
|
+
if (opcode === FileTransferOpcode.FileChunk) {
|
|
72
|
+
return { opcode, requestId, payload: body };
|
|
73
|
+
}
|
|
74
|
+
if (body.byteLength !== 0) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return { opcode, requestId, payload: new Uint8Array() };
|
|
78
|
+
}
|
|
79
|
+
function isFileTransferOpcode(value) {
|
|
80
|
+
return (value === FileTransferOpcode.FileBegin ||
|
|
81
|
+
value === FileTransferOpcode.FileChunk ||
|
|
82
|
+
value === FileTransferOpcode.FileEnd);
|
|
83
|
+
}
|
|
84
|
+
function encodeJsonPayload(value) {
|
|
85
|
+
return new TextEncoder().encode(JSON.stringify(value));
|
|
86
|
+
}
|
|
87
|
+
function encodeRequestId(requestId) {
|
|
88
|
+
const bytes = new TextEncoder().encode(requestId);
|
|
89
|
+
if (bytes.byteLength === 0) {
|
|
90
|
+
throw new RangeError("File transfer requestId is required");
|
|
91
|
+
}
|
|
92
|
+
if (bytes.byteLength > 0xff) {
|
|
93
|
+
throw new RangeError("File transfer requestId is too long");
|
|
94
|
+
}
|
|
95
|
+
return bytes;
|
|
96
|
+
}
|
|
97
|
+
function decodeRequestId(bytes) {
|
|
98
|
+
return new TextDecoder().decode(bytes);
|
|
99
|
+
}
|
|
100
|
+
function decodeJsonPayload(bytes) {
|
|
101
|
+
try {
|
|
102
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=file-transfer.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Routing adds a bounded header; the enclosed terminal/file frame is never re-encoded. */
|
|
2
|
+
export declare const HOST_ROUTE_OPCODE = 48;
|
|
3
|
+
export declare const MAX_HOST_ROUTE_ID_BYTES = 256;
|
|
4
|
+
export declare const MAX_HOST_ROUTE_HEADER_BYTES: number;
|
|
5
|
+
export declare const MAX_HOST_CHANNEL_FRAME_BYTES: number;
|
|
6
|
+
export declare const MAX_ROUTED_PAYLOAD_BYTES: number;
|
|
7
|
+
export interface HostRouteFrame {
|
|
8
|
+
routeId: string;
|
|
9
|
+
payload: Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
export declare function encodeHostRouteFrame(routeId: string, payload: Uint8Array): Uint8Array;
|
|
12
|
+
export declare function decodeHostRouteFrame(bytes: Uint8Array): HostRouteFrame | null;
|
|
13
|
+
//# sourceMappingURL=host-route.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MAX_WEBSOCKET_MESSAGE_BYTES } from "../websocket-message-limit.js";
|
|
2
|
+
/** Routing adds a bounded header; the enclosed terminal/file frame is never re-encoded. */
|
|
3
|
+
export const HOST_ROUTE_OPCODE = 0x30;
|
|
4
|
+
export const MAX_HOST_ROUTE_ID_BYTES = 256;
|
|
5
|
+
export const MAX_HOST_ROUTE_HEADER_BYTES = 3 + MAX_HOST_ROUTE_ID_BYTES;
|
|
6
|
+
// A logical host channel crosses the 32 MiB route admission boundary. Text can
|
|
7
|
+
// expand sixfold when enclosed in JSON; binary adds the bounded route header.
|
|
8
|
+
export const MAX_HOST_CHANNEL_FRAME_BYTES = Math.floor((32 * 1024 * 1024 - MAX_HOST_ROUTE_HEADER_BYTES) / 6);
|
|
9
|
+
export const MAX_ROUTED_PAYLOAD_BYTES = MAX_WEBSOCKET_MESSAGE_BYTES - MAX_HOST_ROUTE_HEADER_BYTES;
|
|
10
|
+
export function encodeHostRouteFrame(routeId, payload) {
|
|
11
|
+
const id = new TextEncoder().encode(routeId);
|
|
12
|
+
if (!id.length || id.length > MAX_HOST_ROUTE_ID_BYTES)
|
|
13
|
+
throw new Error("Invalid host route ID");
|
|
14
|
+
if (payload.byteLength > MAX_ROUTED_PAYLOAD_BYTES)
|
|
15
|
+
throw new Error("Host frame is too large");
|
|
16
|
+
const frame = new Uint8Array(3 + id.length + payload.byteLength);
|
|
17
|
+
frame[0] = HOST_ROUTE_OPCODE;
|
|
18
|
+
new DataView(frame.buffer).setUint16(1, id.length);
|
|
19
|
+
frame.set(id, 3);
|
|
20
|
+
frame.set(payload, 3 + id.length);
|
|
21
|
+
return frame;
|
|
22
|
+
}
|
|
23
|
+
export function decodeHostRouteFrame(bytes) {
|
|
24
|
+
if (bytes[0] !== HOST_ROUTE_OPCODE || bytes.length < 3)
|
|
25
|
+
return null;
|
|
26
|
+
const length = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint16(1);
|
|
27
|
+
if (!length || length > MAX_HOST_ROUTE_ID_BYTES || bytes.length < 3 + length)
|
|
28
|
+
return null;
|
|
29
|
+
if (bytes.length - 3 - length > MAX_ROUTED_PAYLOAD_BYTES)
|
|
30
|
+
return null;
|
|
31
|
+
try {
|
|
32
|
+
const routeId = new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(3, 3 + length));
|
|
33
|
+
return { routeId, payload: bytes.subarray(3 + length) };
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=host-route.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TerminalStateSchema } from "../messages.js";
|
|
3
|
+
export declare const TerminalStreamResizeSchema: z.ZodObject<{
|
|
4
|
+
rows: z.ZodNumber;
|
|
5
|
+
cols: z.ZodNumber;
|
|
6
|
+
intent: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
update: "update";
|
|
8
|
+
claim: "claim";
|
|
9
|
+
}>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const TerminalStreamOpcode: {
|
|
12
|
+
readonly Output: 1;
|
|
13
|
+
readonly Input: 2;
|
|
14
|
+
readonly Resize: 3;
|
|
15
|
+
readonly Snapshot: 4;
|
|
16
|
+
readonly Restore: 5;
|
|
17
|
+
};
|
|
18
|
+
export type TerminalStreamOpcode = (typeof TerminalStreamOpcode)[keyof typeof TerminalStreamOpcode];
|
|
19
|
+
export interface TerminalStreamFrame {
|
|
20
|
+
opcode: TerminalStreamOpcode;
|
|
21
|
+
slot: number;
|
|
22
|
+
payload: Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
export declare function asUint8Array(data: unknown): Uint8Array | null;
|
|
25
|
+
export declare function encodeTerminalStreamFrame(input: {
|
|
26
|
+
opcode: TerminalStreamOpcode;
|
|
27
|
+
slot: number;
|
|
28
|
+
payload?: Uint8Array | ArrayBuffer | string;
|
|
29
|
+
}): Uint8Array;
|
|
30
|
+
export declare function decodeTerminalStreamFrame(bytes: Uint8Array): TerminalStreamFrame | null;
|
|
31
|
+
export declare function encodeTerminalSnapshotPayload(state: z.infer<typeof TerminalStateSchema>): Uint8Array;
|
|
32
|
+
export declare function decodeTerminalSnapshotPayload(bytes: Uint8Array): z.infer<typeof TerminalStateSchema> | null;
|
|
33
|
+
export declare function encodeTerminalResizePayload(input: z.infer<typeof TerminalStreamResizeSchema>): Uint8Array;
|
|
34
|
+
export declare function decodeTerminalResizePayload(bytes: Uint8Array): z.infer<typeof TerminalStreamResizeSchema> | null;
|
|
35
|
+
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TerminalStateSchema } from "../messages.js";
|
|
3
|
+
export const TerminalStreamResizeSchema = z.object({
|
|
4
|
+
rows: z.number().int().positive(),
|
|
5
|
+
cols: z.number().int().positive(),
|
|
6
|
+
intent: z.enum(["claim", "update"]).optional(),
|
|
7
|
+
});
|
|
8
|
+
export const TerminalStreamOpcode = {
|
|
9
|
+
Output: 0x01,
|
|
10
|
+
Input: 0x02,
|
|
11
|
+
Resize: 0x03,
|
|
12
|
+
Snapshot: 0x04,
|
|
13
|
+
Restore: 0x05,
|
|
14
|
+
};
|
|
15
|
+
export function asUint8Array(data) {
|
|
16
|
+
if (typeof data === "string") {
|
|
17
|
+
if (typeof TextEncoder !== "undefined") {
|
|
18
|
+
return new TextEncoder().encode(data);
|
|
19
|
+
}
|
|
20
|
+
if (typeof Buffer !== "undefined") {
|
|
21
|
+
return new Uint8Array(Buffer.from(data, "utf8"));
|
|
22
|
+
}
|
|
23
|
+
const out = new Uint8Array(data.length);
|
|
24
|
+
for (let index = 0; index < data.length; index += 1) {
|
|
25
|
+
out[index] = data.charCodeAt(index) & 0xff;
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
if (data instanceof Uint8Array) {
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
if (typeof ArrayBuffer !== "undefined" && data instanceof ArrayBuffer) {
|
|
33
|
+
return new Uint8Array(data);
|
|
34
|
+
}
|
|
35
|
+
if (ArrayBuffer.isView(data)) {
|
|
36
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
37
|
+
}
|
|
38
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(data)) {
|
|
39
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function isTerminalStreamOpcode(value) {
|
|
44
|
+
return (value === TerminalStreamOpcode.Output ||
|
|
45
|
+
value === TerminalStreamOpcode.Input ||
|
|
46
|
+
value === TerminalStreamOpcode.Resize ||
|
|
47
|
+
value === TerminalStreamOpcode.Snapshot ||
|
|
48
|
+
value === TerminalStreamOpcode.Restore);
|
|
49
|
+
}
|
|
50
|
+
export function encodeTerminalStreamFrame(input) {
|
|
51
|
+
const payload = asUint8Array(input.payload ?? new Uint8Array(0)) ?? new Uint8Array(0);
|
|
52
|
+
const bytes = new Uint8Array(2 + payload.byteLength);
|
|
53
|
+
bytes[0] = input.opcode;
|
|
54
|
+
bytes[1] = input.slot & 0xff;
|
|
55
|
+
bytes.set(payload, 2);
|
|
56
|
+
return bytes;
|
|
57
|
+
}
|
|
58
|
+
export function decodeTerminalStreamFrame(bytes) {
|
|
59
|
+
if (bytes.byteLength < 2) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const opcode = bytes[0];
|
|
63
|
+
if (!isTerminalStreamOpcode(opcode)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
opcode,
|
|
68
|
+
slot: bytes[1],
|
|
69
|
+
payload: bytes.subarray(2),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function encodeTerminalSnapshotPayload(state) {
|
|
73
|
+
return encodeJsonPayload(state);
|
|
74
|
+
}
|
|
75
|
+
export function decodeTerminalSnapshotPayload(bytes) {
|
|
76
|
+
const parsed = decodeJsonPayload(bytes);
|
|
77
|
+
const result = TerminalStateSchema.safeParse(parsed);
|
|
78
|
+
return result.success ? result.data : null;
|
|
79
|
+
}
|
|
80
|
+
export function encodeTerminalResizePayload(input) {
|
|
81
|
+
return encodeJsonPayload(input);
|
|
82
|
+
}
|
|
83
|
+
export function decodeTerminalResizePayload(bytes) {
|
|
84
|
+
const parsed = decodeJsonPayload(bytes);
|
|
85
|
+
const result = TerminalStreamResizeSchema.safeParse(parsed);
|
|
86
|
+
return result.success ? result.data : null;
|
|
87
|
+
}
|
|
88
|
+
function encodeJsonPayload(value) {
|
|
89
|
+
return new TextEncoder().encode(JSON.stringify(value));
|
|
90
|
+
}
|
|
91
|
+
function decodeJsonPayload(bytes) {
|
|
92
|
+
try {
|
|
93
|
+
const text = new TextDecoder().decode(bytes);
|
|
94
|
+
return JSON.parse(text);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate that a string is a valid git branch name slug.
|
|
3
|
+
* Must be lowercase alphanumeric with hyphens and forward slashes only.
|
|
4
|
+
*/
|
|
5
|
+
export declare function validateBranchSlug(slug: string): {
|
|
6
|
+
valid: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const MAX_SLUG_LENGTH = 50;
|
|
10
|
+
/**
|
|
11
|
+
* Convert a string to kebab-case for branch names.
|
|
12
|
+
*/
|
|
13
|
+
export declare function slugify(input: string): string;
|
|
14
|
+
//# sourceMappingURL=branch-slug.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate that a string is a valid git branch name slug.
|
|
3
|
+
* Must be lowercase alphanumeric with hyphens and forward slashes only.
|
|
4
|
+
*/
|
|
5
|
+
export function validateBranchSlug(slug) {
|
|
6
|
+
if (!slug || slug.length === 0) {
|
|
7
|
+
return { valid: false, error: "Branch name cannot be empty" };
|
|
8
|
+
}
|
|
9
|
+
if (slug.length > 100) {
|
|
10
|
+
return { valid: false, error: "Branch name too long (max 100 characters)" };
|
|
11
|
+
}
|
|
12
|
+
const validPattern = /^[a-z0-9-/]+$/;
|
|
13
|
+
if (!validPattern.test(slug)) {
|
|
14
|
+
return {
|
|
15
|
+
valid: false,
|
|
16
|
+
error: "Branch name must contain only lowercase letters, numbers, hyphens, and forward slashes",
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (slug.startsWith("-") || slug.endsWith("-")) {
|
|
20
|
+
return {
|
|
21
|
+
valid: false,
|
|
22
|
+
error: "Branch name cannot start or end with a hyphen",
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (slug.includes("--")) {
|
|
26
|
+
return { valid: false, error: "Branch name cannot have consecutive hyphens" };
|
|
27
|
+
}
|
|
28
|
+
return { valid: true };
|
|
29
|
+
}
|
|
30
|
+
export const MAX_SLUG_LENGTH = 50;
|
|
31
|
+
/**
|
|
32
|
+
* Convert a string to kebab-case for branch names.
|
|
33
|
+
*/
|
|
34
|
+
export function slugify(input) {
|
|
35
|
+
const slug = input
|
|
36
|
+
.toLowerCase()
|
|
37
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
38
|
+
.replace(/^-+|-+$/g, "");
|
|
39
|
+
if (slug.length <= MAX_SLUG_LENGTH) {
|
|
40
|
+
return slug;
|
|
41
|
+
}
|
|
42
|
+
const truncated = slug.slice(0, MAX_SLUG_LENGTH);
|
|
43
|
+
const lastHyphen = truncated.lastIndexOf("-");
|
|
44
|
+
if (lastHyphen > MAX_SLUG_LENGTH / 2) {
|
|
45
|
+
return truncated.slice(0, lastHyphen);
|
|
46
|
+
}
|
|
47
|
+
return truncated.replace(/-+$/, "");
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=branch-slug.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const BrowserAutomationHostCapabilitySchema: z.ZodObject<{
|
|
3
|
+
supportedCommands: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("type" | "select" | "fill" | "logs" | "list_tabs" | "new_tab" | "snapshot" | "click" | "wait" | "keypress" | "navigate" | "back" | "forward" | "reload" | "screenshot" | "upload" | "hover" | "drag" | "evaluate" | "scroll" | "resize" | "close_tab")[], string[]>>;
|
|
4
|
+
hostKind: z.ZodDefault<z.ZodString>;
|
|
5
|
+
}, z.core.$loose>;
|
|
6
|
+
export type BrowserAutomationHostCapability = z.infer<typeof BrowserAutomationHostCapabilitySchema>;
|
|
7
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BROWSER_AUTOMATION_COMMAND_NAMES, } from "./rpc-schemas.js";
|
|
3
|
+
const KNOWN_BROWSER_AUTOMATION_COMMAND_NAMES = new Set(BROWSER_AUTOMATION_COMMAND_NAMES);
|
|
4
|
+
export const BrowserAutomationHostCapabilitySchema = z
|
|
5
|
+
.object({
|
|
6
|
+
supportedCommands: z.array(z.string().min(1)).transform((commands, context) => {
|
|
7
|
+
const supportedCommands = [];
|
|
8
|
+
const seen = new Set();
|
|
9
|
+
for (const command of commands) {
|
|
10
|
+
if (!isKnownBrowserAutomationCommandName(command) || seen.has(command)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
seen.add(command);
|
|
14
|
+
supportedCommands.push(command);
|
|
15
|
+
}
|
|
16
|
+
if (supportedCommands.length === 0) {
|
|
17
|
+
context.addIssue({
|
|
18
|
+
code: "custom",
|
|
19
|
+
message: "supportedCommands must include at least one known browser automation command",
|
|
20
|
+
});
|
|
21
|
+
return z.NEVER;
|
|
22
|
+
}
|
|
23
|
+
return supportedCommands;
|
|
24
|
+
}),
|
|
25
|
+
hostKind: z.string().min(1).default("browser host"),
|
|
26
|
+
})
|
|
27
|
+
.passthrough();
|
|
28
|
+
function isKnownBrowserAutomationCommandName(value) {
|
|
29
|
+
return KNOWN_BROWSER_AUTOMATION_COMMAND_NAMES.has(value);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=capabilities.js.map
|