Prepare prompt file attachments for future UI (#1376)
* 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
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user