@yinaoxiong/paseo-protocol 0.18.1-personal.1 → 0.18.2-personal.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.
- package/build-info.json +9 -9
- package/dist/agent-profile.d.ts +2 -2
- package/dist/agent-profile.js +2 -2
- package/dist/agent-types.d.ts +12 -0
- package/dist/binary-frames/diff.d.ts +2 -0
- package/dist/binary-frames/diff.js +6 -0
- package/dist/binary-frames/file-transfer-wire.d.ts +47 -0
- package/dist/binary-frames/file-transfer-wire.js +124 -0
- package/dist/binary-frames/file-transfer.d.ts +1 -38
- package/dist/binary-frames/file-transfer.js +1 -98
- package/dist/binary-frames/terminal-wire.d.ts +30 -0
- package/dist/binary-frames/terminal-wire.js +93 -0
- package/dist/binary-frames/terminal.d.ts +1 -23
- package/dist/binary-frames/terminal.js +1 -70
- package/dist/browser-automation/rpc-schemas.d.ts +4 -4
- package/dist/browser-automation/rpc-schemas.js +2 -4
- package/dist/connection-offer-wire.d.ts +27 -0
- package/dist/connection-offer-wire.js +77 -0
- package/dist/connection-offer.d.ts +1 -10
- package/dist/connection-offer.js +1 -35
- package/dist/generated/validation/message-defaults.d.ts +6 -0
- package/dist/generated/validation/message-defaults.js +107 -0
- package/dist/generated/validation/ws-outbound-schema-metadata.d.ts +572 -414
- package/dist/generated/validation/ws-outbound-schema-metadata.js +5 -0
- package/dist/generated/validation/ws-outbound.aot.d.ts +10 -0
- package/dist/generated/validation/ws-outbound.aot.js +114580 -113412
- package/dist/host-target.d.ts +1 -1
- package/dist/host-target.js +1 -1
- package/dist/messages.d.ts +1518 -640
- package/dist/messages.js +97 -28
- package/dist/paseo-config-schema.d.ts +5 -5
- package/dist/paseo-config-schema.js +0 -1
- package/dist/paseo-tool-presentation/agent-message.d.ts +9 -6
- package/dist/paseo-tool-presentation/agent-message.js +18 -14
- package/dist/paseo-tool-presentation/catalog.d.ts +9 -1
- package/dist/paseo-tool-presentation/catalog.js +8 -1
- package/dist/paseo-tool-presentation/index.d.ts +1 -1
- package/dist/paseo-tool-presentation/index.js +1 -1
- package/dist/plugin-config.d.ts +2 -2
- package/dist/plugin-config.js +2 -4
- package/dist/provider-config.d.ts +2 -0
- package/dist/provider-config.js +1 -0
- package/dist/schedule/normalize-options.d.ts +4 -0
- package/dist/schedule/normalize-options.js +23 -0
- package/dist/schedule/rpc-schemas.d.ts +114 -112
- package/dist/schedule/rpc-schemas.js +12 -9
- package/dist/schedule/types.d.ts +145 -7
- package/dist/schedule/types.js +16 -2
- package/dist/timeline-turn.d.ts +0 -1
- package/dist/timeline-turn.js +12 -1
- package/dist/tool-call-display.d.ts +1 -1
- package/dist/tool-call-display.js +6 -8
- package/dist/tunnels.d.ts +227 -0
- package/dist/tunnels.js +109 -0
- package/dist/validation/message-defaults.d.ts +37 -0
- package/dist/validation/message-defaults.js +145 -0
- package/dist/validation/unknown-variants.d.ts +23 -0
- package/dist/validation/unknown-variants.js +107 -0
- package/dist/validation/wire-schema-audit.d.ts +4 -0
- package/dist/validation/wire-schema-audit.js +91 -0
- package/dist/validation/ws-outbound-envelope.d.ts +3681 -153
- package/dist/validation/ws-outbound-envelope.js +18 -1
- package/dist/validation/ws-outbound.d.ts +6 -10
- package/dist/validation/ws-outbound.js +8 -0
- package/package.json +1 -1
package/build-info.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"upstreamVersion": "0.18.
|
|
4
|
-
"revision":
|
|
5
|
-
"version": "0.18.
|
|
6
|
-
"appVersion": "0.18.
|
|
7
|
-
"androidVersionCode":
|
|
8
|
-
"iosBuildNumber": "
|
|
9
|
-
"sourceSha": "
|
|
10
|
-
"lockSha256": "
|
|
3
|
+
"upstreamVersion": "0.18.2",
|
|
4
|
+
"revision": 2,
|
|
5
|
+
"version": "0.18.2-personal.2",
|
|
6
|
+
"appVersion": "0.18.2",
|
|
7
|
+
"androidVersionCode": 18002002,
|
|
8
|
+
"iosBuildNumber": "18002002",
|
|
9
|
+
"sourceSha": "96a72e49e867e89043fe70bbac4afe6921d1f477",
|
|
10
|
+
"lockSha256": "8bcf4983ccfa57cfa444ec7ecbad301c8fef0fcc2c495df5176758cf1e2f2faa",
|
|
11
11
|
"nodeVersion": "v24.21.0",
|
|
12
12
|
"npmVersion": "11.19.0",
|
|
13
13
|
"platform": "linux",
|
|
14
14
|
"arch": "x64",
|
|
15
15
|
"signature": "unsigned",
|
|
16
16
|
"packageName": "@yinaoxiong/paseo-protocol",
|
|
17
|
-
"desktopVersion": "0.18.
|
|
17
|
+
"desktopVersion": "0.18.2+personal.2"
|
|
18
18
|
}
|
package/dist/agent-profile.d.ts
CHANGED
|
@@ -24,9 +24,9 @@ export declare const AgentProfileSchema: z.ZodObject<{
|
|
|
24
24
|
export type AgentProfile = z.infer<typeof AgentProfileSchema>;
|
|
25
25
|
export declare const AgentSkillSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
26
26
|
mode: z.ZodLiteral<"all">;
|
|
27
|
-
}, z.core.$
|
|
27
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
28
28
|
mode: z.ZodLiteral<"custom">;
|
|
29
29
|
skills: z.ZodArray<z.ZodString>;
|
|
30
|
-
}, z.core.$
|
|
30
|
+
}, z.core.$strip>], "mode">;
|
|
31
31
|
export type AgentSkillSelection = z.infer<typeof AgentSkillSelectionSchema>;
|
|
32
32
|
//# sourceMappingURL=agent-profile.d.ts.map
|
package/dist/agent-profile.js
CHANGED
|
@@ -30,7 +30,7 @@ export const AgentProfileSchema = z
|
|
|
30
30
|
})
|
|
31
31
|
.passthrough();
|
|
32
32
|
export const AgentSkillSelectionSchema = z.discriminatedUnion("mode", [
|
|
33
|
-
z.object({ mode: z.literal("all") })
|
|
34
|
-
z.object({ mode: z.literal("custom"), skills: z.array(z.string()) })
|
|
33
|
+
z.object({ mode: z.literal("all") }),
|
|
34
|
+
z.object({ mode: z.literal("custom"), skills: z.array(z.string()) }),
|
|
35
35
|
]);
|
|
36
36
|
//# sourceMappingURL=agent-profile.js.map
|
package/dist/agent-types.d.ts
CHANGED
|
@@ -81,6 +81,8 @@ export interface AgentModelDefinition {
|
|
|
81
81
|
contextWindowMaxTokens?: number;
|
|
82
82
|
thinkingOptions?: AgentSelectOption[];
|
|
83
83
|
defaultThinkingOptionId?: string;
|
|
84
|
+
/** A previous-release model. Pickers fold it behind the current models; search still finds it. */
|
|
85
|
+
legacy?: boolean;
|
|
84
86
|
}
|
|
85
87
|
export interface AgentSelectOption {
|
|
86
88
|
id: string;
|
|
@@ -109,6 +111,8 @@ export interface ProviderSnapshotEntry {
|
|
|
109
111
|
defaultModeId?: string | null;
|
|
110
112
|
/** The provider can run a session behind an `agent.open.before` wrap. Absent means it cannot. */
|
|
111
113
|
launchWrap?: boolean;
|
|
114
|
+
/** User-picked model IDs, in display order. Pickers show these first and fold the rest. */
|
|
115
|
+
shownModels?: string[];
|
|
112
116
|
}
|
|
113
117
|
export interface AgentFeatureToggle {
|
|
114
118
|
type: "toggle";
|
|
@@ -341,11 +345,19 @@ export interface AgentTaskItem {
|
|
|
341
345
|
status?: "pending" | "in_progress" | "completed";
|
|
342
346
|
activeForm?: string;
|
|
343
347
|
}
|
|
348
|
+
export interface UploadedImage {
|
|
349
|
+
id: string;
|
|
350
|
+
fileName: string;
|
|
351
|
+
mimeType: string;
|
|
352
|
+
size: number;
|
|
353
|
+
path: string;
|
|
354
|
+
}
|
|
344
355
|
export type AgentTimelineItem = {
|
|
345
356
|
type: "user_message";
|
|
346
357
|
text: string;
|
|
347
358
|
messageId?: string;
|
|
348
359
|
clientMessageId?: string;
|
|
360
|
+
images?: UploadedImage[];
|
|
349
361
|
} | {
|
|
350
362
|
type: "assistant_message";
|
|
351
363
|
text: string;
|
|
@@ -4,6 +4,7 @@ export declare const DiffOpcode: {
|
|
|
4
4
|
readonly Bodies: 65;
|
|
5
5
|
readonly End: 66;
|
|
6
6
|
};
|
|
7
|
+
export declare const DIFF_SUPERSEDED_MESSAGE = "Diff revision superseded by newer changes";
|
|
7
8
|
export declare const DIFF_HIGHLIGHT_STYLES: readonly [null, "keyword", "comment", "string", "number", "literal", "function", "definition", "class", "type", "tag", "attribute", "property", "variable", "operator", "punctuation", "regexp", "escape", "meta", "heading", "link", "diffAddition", "diffDeletion"];
|
|
8
9
|
declare const CHANGES: readonly ["added", "modified", "deleted", "renamed"];
|
|
9
10
|
declare const CONTENTS: readonly ["text", "binary"];
|
|
@@ -66,6 +67,7 @@ export interface DiffEnd {
|
|
|
66
67
|
} | null;
|
|
67
68
|
}
|
|
68
69
|
export type DiffFrame = DiffBegin | DiffBodies | DiffEnd;
|
|
70
|
+
export declare function isSupersededDiffError(error: DiffEnd["error"]): boolean;
|
|
69
71
|
export declare class InvalidDiffFrameError extends Error {
|
|
70
72
|
}
|
|
71
73
|
export declare function encodeDiffFrame(frame: DiffFrame): Uint8Array;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// Opcodes 0x40–0x4f are reserved for diff revisions. Plugins own 0x20–0x2f.
|
|
2
2
|
export const DiffOpcode = { Begin: 0x40, Bodies: 0x41, End: 0x42 };
|
|
3
|
+
// An UNKNOWN End with this message discards the pending revision. Older
|
|
4
|
+
// readers support the frame and can recover from the following full revision.
|
|
5
|
+
export const DIFF_SUPERSEDED_MESSAGE = "Diff revision superseded by newer changes";
|
|
3
6
|
export const DIFF_HIGHLIGHT_STYLES = [
|
|
4
7
|
null,
|
|
5
8
|
"keyword",
|
|
@@ -36,6 +39,9 @@ const ERRORS = [
|
|
|
36
39
|
"TOO_MANY_SUBSCRIPTIONS",
|
|
37
40
|
"UNKNOWN",
|
|
38
41
|
];
|
|
42
|
+
export function isSupersededDiffError(error) {
|
|
43
|
+
return error?.code === "UNKNOWN" && error.message === DIFF_SUPERSEDED_MESSAGE;
|
|
44
|
+
}
|
|
39
45
|
export class InvalidDiffFrameError extends Error {
|
|
40
46
|
}
|
|
41
47
|
const textEncoder = new TextEncoder();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const FileTransferOpcode: {
|
|
2
|
+
readonly FileBegin: 16;
|
|
3
|
+
readonly FileChunk: 17;
|
|
4
|
+
readonly FileEnd: 18;
|
|
5
|
+
};
|
|
6
|
+
export type FileTransferOpcode = (typeof FileTransferOpcode)[keyof typeof FileTransferOpcode];
|
|
7
|
+
export interface FileBeginMetadata {
|
|
8
|
+
mime: string;
|
|
9
|
+
size: number;
|
|
10
|
+
encoding: "utf-8" | "binary";
|
|
11
|
+
modifiedAt: string;
|
|
12
|
+
revision?: string;
|
|
13
|
+
fileName?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FileBegin {
|
|
16
|
+
opcode: typeof FileTransferOpcode.FileBegin;
|
|
17
|
+
requestId: string;
|
|
18
|
+
metadata: FileBeginMetadata;
|
|
19
|
+
payload: Uint8Array;
|
|
20
|
+
}
|
|
21
|
+
export interface FileChunk {
|
|
22
|
+
opcode: typeof FileTransferOpcode.FileChunk;
|
|
23
|
+
requestId: string;
|
|
24
|
+
payload: Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
export interface FileEnd {
|
|
27
|
+
opcode: typeof FileTransferOpcode.FileEnd;
|
|
28
|
+
requestId: string;
|
|
29
|
+
payload: Uint8Array;
|
|
30
|
+
}
|
|
31
|
+
export type FileTransferFrame = FileBegin | FileChunk | FileEnd;
|
|
32
|
+
type FileTransferFrameInput = {
|
|
33
|
+
opcode: typeof FileTransferOpcode.FileBegin;
|
|
34
|
+
requestId: string;
|
|
35
|
+
metadata: FileBeginMetadata;
|
|
36
|
+
} | {
|
|
37
|
+
opcode: typeof FileTransferOpcode.FileChunk;
|
|
38
|
+
requestId: string;
|
|
39
|
+
payload?: Uint8Array | ArrayBuffer | string;
|
|
40
|
+
} | {
|
|
41
|
+
opcode: typeof FileTransferOpcode.FileEnd;
|
|
42
|
+
requestId: string;
|
|
43
|
+
};
|
|
44
|
+
export declare function encodeFileTransferFrame(input: FileTransferFrameInput): Uint8Array;
|
|
45
|
+
export declare function decodeFileTransferFrame(bytes: Uint8Array): FileTransferFrame | null;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=file-transfer-wire.d.ts.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { asUint8Array } from "./terminal-wire.js";
|
|
2
|
+
export const FileTransferOpcode = {
|
|
3
|
+
FileBegin: 0x10,
|
|
4
|
+
FileChunk: 0x11,
|
|
5
|
+
FileEnd: 0x12,
|
|
6
|
+
};
|
|
7
|
+
function parseFileBeginMetadata(input) {
|
|
8
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const record = input;
|
|
12
|
+
if (typeof record.mime !== "string" || record.mime.length === 0)
|
|
13
|
+
return null;
|
|
14
|
+
if (typeof record.size !== "number" || !Number.isInteger(record.size) || record.size < 0) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (record.encoding !== "utf-8" && record.encoding !== "binary")
|
|
18
|
+
return null;
|
|
19
|
+
if (typeof record.modifiedAt !== "string")
|
|
20
|
+
return null;
|
|
21
|
+
if (record.revision !== undefined && typeof record.revision !== "string")
|
|
22
|
+
return null;
|
|
23
|
+
if (record.fileName !== undefined && typeof record.fileName !== "string")
|
|
24
|
+
return null;
|
|
25
|
+
return {
|
|
26
|
+
mime: record.mime,
|
|
27
|
+
size: record.size,
|
|
28
|
+
encoding: record.encoding,
|
|
29
|
+
modifiedAt: record.modifiedAt,
|
|
30
|
+
...(record.revision !== undefined ? { revision: record.revision } : {}),
|
|
31
|
+
...(record.fileName !== undefined ? { fileName: record.fileName } : {}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function encodeFileTransferFrame(input) {
|
|
35
|
+
const requestId = encodeRequestId(input.requestId);
|
|
36
|
+
if (input.opcode === FileTransferOpcode.FileBegin) {
|
|
37
|
+
const metadata = encodeJsonPayload(input.metadata);
|
|
38
|
+
if (metadata.byteLength > 0xffff) {
|
|
39
|
+
throw new RangeError("FileBegin metadata is too long");
|
|
40
|
+
}
|
|
41
|
+
const bytes = new Uint8Array(4 + requestId.byteLength + metadata.byteLength);
|
|
42
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
43
|
+
bytes[0] = input.opcode;
|
|
44
|
+
bytes[1] = requestId.byteLength;
|
|
45
|
+
bytes.set(requestId, 2);
|
|
46
|
+
view.setUint16(2 + requestId.byteLength, metadata.byteLength);
|
|
47
|
+
bytes.set(metadata, 4 + requestId.byteLength);
|
|
48
|
+
return bytes;
|
|
49
|
+
}
|
|
50
|
+
const payload = input.opcode === FileTransferOpcode.FileChunk
|
|
51
|
+
? (asUint8Array(input.payload ?? new Uint8Array()) ?? new Uint8Array())
|
|
52
|
+
: new Uint8Array();
|
|
53
|
+
const bytes = new Uint8Array(2 + requestId.byteLength + payload.byteLength);
|
|
54
|
+
bytes[0] = input.opcode;
|
|
55
|
+
bytes[1] = requestId.byteLength;
|
|
56
|
+
bytes.set(requestId, 2);
|
|
57
|
+
bytes.set(payload, 2 + requestId.byteLength);
|
|
58
|
+
return bytes;
|
|
59
|
+
}
|
|
60
|
+
export function decodeFileTransferFrame(bytes) {
|
|
61
|
+
if (bytes.byteLength < 2) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const opcode = bytes[0];
|
|
65
|
+
if (!isFileTransferOpcode(opcode)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const requestIdLength = bytes[1];
|
|
69
|
+
if (requestIdLength === 0 || requestIdLength > bytes.byteLength - 2) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const requestId = decodeRequestId(bytes.subarray(2, 2 + requestIdLength));
|
|
73
|
+
const body = bytes.subarray(2 + requestIdLength);
|
|
74
|
+
if (opcode === FileTransferOpcode.FileBegin) {
|
|
75
|
+
if (body.byteLength < 2) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const view = new DataView(body.buffer, body.byteOffset, body.byteLength);
|
|
79
|
+
const metadataLength = view.getUint16(0);
|
|
80
|
+
if (metadataLength !== body.byteLength - 2) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const metadataBytes = body.subarray(2);
|
|
84
|
+
const metadata = parseFileBeginMetadata(decodeJsonPayload(metadataBytes));
|
|
85
|
+
return metadata ? { opcode, requestId, metadata, payload: new Uint8Array() } : null;
|
|
86
|
+
}
|
|
87
|
+
if (opcode === FileTransferOpcode.FileChunk) {
|
|
88
|
+
return { opcode, requestId, payload: body };
|
|
89
|
+
}
|
|
90
|
+
if (body.byteLength !== 0) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return { opcode, requestId, payload: new Uint8Array() };
|
|
94
|
+
}
|
|
95
|
+
function isFileTransferOpcode(value) {
|
|
96
|
+
return (value === FileTransferOpcode.FileBegin ||
|
|
97
|
+
value === FileTransferOpcode.FileChunk ||
|
|
98
|
+
value === FileTransferOpcode.FileEnd);
|
|
99
|
+
}
|
|
100
|
+
function encodeJsonPayload(value) {
|
|
101
|
+
return new TextEncoder().encode(JSON.stringify(value));
|
|
102
|
+
}
|
|
103
|
+
function encodeRequestId(requestId) {
|
|
104
|
+
const bytes = new TextEncoder().encode(requestId);
|
|
105
|
+
if (bytes.byteLength === 0) {
|
|
106
|
+
throw new RangeError("File transfer requestId is required");
|
|
107
|
+
}
|
|
108
|
+
if (bytes.byteLength > 0xff) {
|
|
109
|
+
throw new RangeError("File transfer requestId is too long");
|
|
110
|
+
}
|
|
111
|
+
return bytes;
|
|
112
|
+
}
|
|
113
|
+
function decodeRequestId(bytes) {
|
|
114
|
+
return new TextDecoder().decode(bytes);
|
|
115
|
+
}
|
|
116
|
+
function decodeJsonPayload(bytes) {
|
|
117
|
+
try {
|
|
118
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=file-transfer-wire.js.map
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export
|
|
3
|
-
readonly FileBegin: 16;
|
|
4
|
-
readonly FileChunk: 17;
|
|
5
|
-
readonly FileEnd: 18;
|
|
6
|
-
};
|
|
7
|
-
export type FileTransferOpcode = (typeof FileTransferOpcode)[keyof typeof FileTransferOpcode];
|
|
2
|
+
export { FileTransferOpcode, decodeFileTransferFrame, encodeFileTransferFrame, type FileBegin, type FileBeginMetadata, type FileChunk, type FileEnd, type FileTransferFrame, } from "./file-transfer-wire.js";
|
|
8
3
|
export declare const FileBeginMetadataSchema: z.ZodObject<{
|
|
9
4
|
mime: z.ZodString;
|
|
10
5
|
size: z.ZodNumber;
|
|
@@ -16,36 +11,4 @@ export declare const FileBeginMetadataSchema: z.ZodObject<{
|
|
|
16
11
|
revision: z.ZodOptional<z.ZodString>;
|
|
17
12
|
fileName: z.ZodOptional<z.ZodString>;
|
|
18
13
|
}, 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
14
|
//# sourceMappingURL=file-transfer.d.ts.map
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export const FileTransferOpcode = {
|
|
4
|
-
FileBegin: 0x10,
|
|
5
|
-
FileChunk: 0x11,
|
|
6
|
-
FileEnd: 0x12,
|
|
7
|
-
};
|
|
2
|
+
export { FileTransferOpcode, decodeFileTransferFrame, encodeFileTransferFrame, } from "./file-transfer-wire.js";
|
|
8
3
|
export const FileBeginMetadataSchema = z.object({
|
|
9
4
|
mime: z.string().min(1),
|
|
10
5
|
size: z.number().int().nonnegative(),
|
|
@@ -13,96 +8,4 @@ export const FileBeginMetadataSchema = z.object({
|
|
|
13
8
|
revision: z.string().optional(),
|
|
14
9
|
fileName: z.string().optional(),
|
|
15
10
|
});
|
|
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
11
|
//# sourceMappingURL=file-transfer.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const TerminalStreamOpcode: {
|
|
2
|
+
readonly Output: 1;
|
|
3
|
+
readonly Input: 2;
|
|
4
|
+
readonly Resize: 3;
|
|
5
|
+
readonly Snapshot: 4;
|
|
6
|
+
readonly Restore: 5;
|
|
7
|
+
readonly ReplayBegin: 6;
|
|
8
|
+
readonly ReplayData: 7;
|
|
9
|
+
readonly ReplayEnd: 8;
|
|
10
|
+
};
|
|
11
|
+
export type TerminalStreamOpcode = (typeof TerminalStreamOpcode)[keyof typeof TerminalStreamOpcode];
|
|
12
|
+
export interface TerminalStreamFrame {
|
|
13
|
+
opcode: TerminalStreamOpcode;
|
|
14
|
+
slot: number;
|
|
15
|
+
payload: Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
export interface TerminalReplayMetadata {
|
|
18
|
+
rows: number;
|
|
19
|
+
cols: number;
|
|
20
|
+
retainedHistoryLines: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function parseTerminalReplayMetadata(input: unknown): TerminalReplayMetadata | null;
|
|
23
|
+
export declare function asUint8Array(data: unknown): Uint8Array | null;
|
|
24
|
+
export declare function encodeTerminalStreamFrame(input: {
|
|
25
|
+
opcode: TerminalStreamOpcode;
|
|
26
|
+
slot: number;
|
|
27
|
+
payload?: Uint8Array | ArrayBuffer | string;
|
|
28
|
+
}): Uint8Array;
|
|
29
|
+
export declare function decodeTerminalStreamFrame(bytes: Uint8Array): TerminalStreamFrame | null;
|
|
30
|
+
//# sourceMappingURL=terminal-wire.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export const TerminalStreamOpcode = {
|
|
2
|
+
Output: 0x01,
|
|
3
|
+
Input: 0x02,
|
|
4
|
+
Resize: 0x03,
|
|
5
|
+
Snapshot: 0x04,
|
|
6
|
+
Restore: 0x05,
|
|
7
|
+
ReplayBegin: 0x06,
|
|
8
|
+
ReplayData: 0x07,
|
|
9
|
+
ReplayEnd: 0x08,
|
|
10
|
+
};
|
|
11
|
+
export function parseTerminalReplayMetadata(input) {
|
|
12
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const record = input;
|
|
16
|
+
if (typeof record.rows !== "number" ||
|
|
17
|
+
!Number.isInteger(record.rows) ||
|
|
18
|
+
record.rows <= 0 ||
|
|
19
|
+
typeof record.cols !== "number" ||
|
|
20
|
+
!Number.isInteger(record.cols) ||
|
|
21
|
+
record.cols <= 0 ||
|
|
22
|
+
typeof record.retainedHistoryLines !== "number" ||
|
|
23
|
+
!Number.isInteger(record.retainedHistoryLines) ||
|
|
24
|
+
record.retainedHistoryLines < 0) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
rows: record.rows,
|
|
29
|
+
cols: record.cols,
|
|
30
|
+
retainedHistoryLines: record.retainedHistoryLines,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function asUint8Array(data) {
|
|
34
|
+
if (typeof data === "string") {
|
|
35
|
+
if (typeof TextEncoder !== "undefined") {
|
|
36
|
+
return new TextEncoder().encode(data);
|
|
37
|
+
}
|
|
38
|
+
if (typeof Buffer !== "undefined") {
|
|
39
|
+
return new Uint8Array(Buffer.from(data, "utf8"));
|
|
40
|
+
}
|
|
41
|
+
const out = new Uint8Array(data.length);
|
|
42
|
+
for (let index = 0; index < data.length; index += 1) {
|
|
43
|
+
out[index] = data.charCodeAt(index) & 0xff;
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
if (data instanceof Uint8Array) {
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
if (typeof ArrayBuffer !== "undefined" && data instanceof ArrayBuffer) {
|
|
51
|
+
return new Uint8Array(data);
|
|
52
|
+
}
|
|
53
|
+
if (ArrayBuffer.isView(data)) {
|
|
54
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
55
|
+
}
|
|
56
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(data)) {
|
|
57
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function isTerminalStreamOpcode(value) {
|
|
62
|
+
return (value === TerminalStreamOpcode.Output ||
|
|
63
|
+
value === TerminalStreamOpcode.Input ||
|
|
64
|
+
value === TerminalStreamOpcode.Resize ||
|
|
65
|
+
value === TerminalStreamOpcode.Snapshot ||
|
|
66
|
+
value === TerminalStreamOpcode.ReplayBegin ||
|
|
67
|
+
value === TerminalStreamOpcode.ReplayData ||
|
|
68
|
+
value === TerminalStreamOpcode.ReplayEnd ||
|
|
69
|
+
value === TerminalStreamOpcode.Restore);
|
|
70
|
+
}
|
|
71
|
+
export function encodeTerminalStreamFrame(input) {
|
|
72
|
+
const payload = asUint8Array(input.payload ?? new Uint8Array(0)) ?? new Uint8Array(0);
|
|
73
|
+
const bytes = new Uint8Array(2 + payload.byteLength);
|
|
74
|
+
bytes[0] = input.opcode;
|
|
75
|
+
bytes[1] = input.slot & 0xff;
|
|
76
|
+
bytes.set(payload, 2);
|
|
77
|
+
return bytes;
|
|
78
|
+
}
|
|
79
|
+
export function decodeTerminalStreamFrame(bytes) {
|
|
80
|
+
if (bytes.byteLength < 2) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const opcode = bytes[0];
|
|
84
|
+
if (!isTerminalStreamOpcode(opcode)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
opcode,
|
|
89
|
+
slot: bytes[1],
|
|
90
|
+
payload: bytes.subarray(2),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=terminal-wire.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { TerminalStateSchema } from "../messages.js";
|
|
3
|
+
export { TerminalStreamOpcode, asUint8Array, decodeTerminalStreamFrame, encodeTerminalStreamFrame, parseTerminalReplayMetadata, type TerminalReplayMetadata, type TerminalStreamFrame, } from "./terminal-wire.js";
|
|
3
4
|
export declare const TerminalReplayMetadataSchema: z.ZodObject<{
|
|
4
5
|
rows: z.ZodNumber;
|
|
5
6
|
cols: z.ZodNumber;
|
|
@@ -13,29 +14,6 @@ export declare const TerminalStreamResizeSchema: z.ZodObject<{
|
|
|
13
14
|
claim: "claim";
|
|
14
15
|
}>>;
|
|
15
16
|
}, z.core.$strip>;
|
|
16
|
-
export declare const TerminalStreamOpcode: {
|
|
17
|
-
readonly Output: 1;
|
|
18
|
-
readonly Input: 2;
|
|
19
|
-
readonly Resize: 3;
|
|
20
|
-
readonly Snapshot: 4;
|
|
21
|
-
readonly Restore: 5;
|
|
22
|
-
readonly ReplayBegin: 6;
|
|
23
|
-
readonly ReplayData: 7;
|
|
24
|
-
readonly ReplayEnd: 8;
|
|
25
|
-
};
|
|
26
|
-
export type TerminalStreamOpcode = (typeof TerminalStreamOpcode)[keyof typeof TerminalStreamOpcode];
|
|
27
|
-
export interface TerminalStreamFrame {
|
|
28
|
-
opcode: TerminalStreamOpcode;
|
|
29
|
-
slot: number;
|
|
30
|
-
payload: Uint8Array;
|
|
31
|
-
}
|
|
32
|
-
export declare function asUint8Array(data: unknown): Uint8Array | null;
|
|
33
|
-
export declare function encodeTerminalStreamFrame(input: {
|
|
34
|
-
opcode: TerminalStreamOpcode;
|
|
35
|
-
slot: number;
|
|
36
|
-
payload?: Uint8Array | ArrayBuffer | string;
|
|
37
|
-
}): Uint8Array;
|
|
38
|
-
export declare function decodeTerminalStreamFrame(bytes: Uint8Array): TerminalStreamFrame | null;
|
|
39
17
|
export declare function encodeTerminalSnapshotPayload(state: z.infer<typeof TerminalStateSchema>): Uint8Array;
|
|
40
18
|
export declare function decodeTerminalSnapshotPayload(bytes: Uint8Array): z.infer<typeof TerminalStateSchema> | null;
|
|
41
19
|
export declare function encodeTerminalResizePayload(input: z.infer<typeof TerminalStreamResizeSchema>): Uint8Array;
|