* Support file uploads to agents * Harden prompt file upload handling * Fix duplicate upload retry handling * Update relay reconnect tests for queued messages * Make upload timeout track idle progress * Clean failed upload directories
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
decodeBinaryFrame,
|
|
encodeFileTransferFrame,
|
|
encodeTerminalStreamFrame,
|
|
FileTransferOpcode,
|
|
TerminalStreamOpcode,
|
|
} from "./index.js";
|
|
|
|
describe("binary frame demux", () => {
|
|
it("routes terminal frames by opcode", () => {
|
|
expect(
|
|
decodeBinaryFrame(
|
|
encodeTerminalStreamFrame({
|
|
opcode: TerminalStreamOpcode.Input,
|
|
slot: 7,
|
|
payload: "ls",
|
|
}),
|
|
),
|
|
).toEqual({
|
|
kind: "terminal",
|
|
frame: {
|
|
opcode: TerminalStreamOpcode.Input,
|
|
slot: 7,
|
|
payload: new TextEncoder().encode("ls"),
|
|
},
|
|
});
|
|
});
|
|
|
|
it("routes file-transfer frames by opcode", () => {
|
|
expect(
|
|
decodeBinaryFrame(
|
|
encodeFileTransferFrame({
|
|
opcode: FileTransferOpcode.FileChunk,
|
|
requestId: "req-upload",
|
|
payload: new TextEncoder().encode("hello"),
|
|
}),
|
|
),
|
|
).toEqual({
|
|
kind: "file_transfer",
|
|
frame: {
|
|
opcode: FileTransferOpcode.FileChunk,
|
|
requestId: "req-upload",
|
|
payload: new TextEncoder().encode("hello"),
|
|
},
|
|
});
|
|
});
|
|
|
|
it("rejects unknown binary opcodes", () => {
|
|
expect(decodeBinaryFrame(new Uint8Array([0xff, 0]))).toBeNull();
|
|
});
|
|
});
|