@hyperdrive.bot/paseo-client 0.2.6 → 0.2.7
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/dist/daemon-client.js +29 -2
- package/package.json +2 -2
package/dist/daemon-client.js
CHANGED
|
@@ -3,7 +3,7 @@ import { AgentCreateFailedStatusPayloadSchema, AgentCreatedStatusPayloadSchema,
|
|
|
3
3
|
import { validateWSOutboundMessage } from "@hyperdrive.bot/paseo-protocol/validation/ws-outbound";
|
|
4
4
|
import { isRelayClientWebSocketUrl } from "@hyperdrive.bot/paseo-protocol/daemon-endpoints";
|
|
5
5
|
import { terminalSubscriptionKey } from "@hyperdrive.bot/paseo-protocol/terminal-subscription-key";
|
|
6
|
-
import { asUint8Array, decodeFileTransferFrame,
|
|
6
|
+
import { asUint8Array, decodeFileTransferFrame, decodeTerminalStreamFrame, FileTransferOpcode, TerminalStreamOpcode, } from "@hyperdrive.bot/paseo-protocol/binary-frames/index";
|
|
7
7
|
import { UPLOAD_CHUNK_SIZE_BYTES } from "@hyperdrive.bot/paseo-protocol/binary-frames/chunk-size";
|
|
8
8
|
import { createRelayE2eeTransportFactory, createWebSocketTransportFactory, decodeMessageData, defaultWebSocketFactory, describeTransportClose, describeTransportError, } from "./daemon-client-transport.js";
|
|
9
9
|
import { DaemonClientRuntimeMetrics } from "./daemon-client-runtime-metrics.js";
|
|
@@ -159,6 +159,19 @@ function decodeBase64ToBytes(base64) {
|
|
|
159
159
|
}
|
|
160
160
|
return bytes;
|
|
161
161
|
}
|
|
162
|
+
// Uint8Array -> base64, portable across the browser (web app) and Node (tests/CLI) via the
|
|
163
|
+
// same `globalThis.btoa` the decoder above assumes. Built in 32 KiB windows so a full upload
|
|
164
|
+
// chunk (up to UPLOAD_CHUNK_SIZE_BYTES = 256 KiB) never hits the `String.fromCharCode(...spread)`
|
|
165
|
+
// argument-count limit. Used by uploadFile to stream chunks as text on transports that drop
|
|
166
|
+
// binary WebSocket frames (see FilesUploadChunkSchema).
|
|
167
|
+
function encodeBytesToBase64(bytes) {
|
|
168
|
+
let binary = "";
|
|
169
|
+
const windowSize = 0x8000;
|
|
170
|
+
for (let offset = 0; offset < bytes.length; offset += windowSize) {
|
|
171
|
+
binary += String.fromCharCode.apply(null, bytes.subarray(offset, offset + windowSize));
|
|
172
|
+
}
|
|
173
|
+
return globalThis.btoa(binary);
|
|
174
|
+
}
|
|
162
175
|
function legacyExplorerFileToBytes(file) {
|
|
163
176
|
let bytes;
|
|
164
177
|
if (file.encoding === "base64" && file.content) {
|
|
@@ -3948,7 +3961,21 @@ export class DaemonClient {
|
|
|
3948
3961
|
return;
|
|
3949
3962
|
}
|
|
3950
3963
|
try {
|
|
3951
|
-
|
|
3964
|
+
// Stream the chunk as a base64 JSON message rather than a binary FileChunk frame.
|
|
3965
|
+
// Binary WebSocket frames are dropped by some proxy transports (notably the
|
|
3966
|
+
// hyperdrive proxy path), which would stall this windowed sender forever with zero
|
|
3967
|
+
// acks. The daemon decodes `data` and feeds it through the IDENTICAL FileChunk
|
|
3968
|
+
// write+ack pipeline (FilesUploadChunkSchema), so the window/ack flow control below
|
|
3969
|
+
// is unchanged and this works over any text-capable transport.
|
|
3970
|
+
this.sendSessionMessage({
|
|
3971
|
+
type: "files.upload.chunk",
|
|
3972
|
+
payload: {
|
|
3973
|
+
requestId,
|
|
3974
|
+
uploadId,
|
|
3975
|
+
chunkIndex: index,
|
|
3976
|
+
data: encodeBytesToBase64(payload),
|
|
3977
|
+
},
|
|
3978
|
+
});
|
|
3952
3979
|
}
|
|
3953
3980
|
catch (error) {
|
|
3954
3981
|
settleReject(new UploadFailedError(uploadId, error instanceof Error ? error.message : String(error)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperdrive.bot/paseo-client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Paseo client SDK package",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "vitest run"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@hyperdrive.bot/paseo-protocol": "0.2.
|
|
38
|
+
"@hyperdrive.bot/paseo-protocol": "0.2.7",
|
|
39
39
|
"@hyperdrive.bot/paseo-relay": "0.2.5",
|
|
40
40
|
"zod": "^4.4.3"
|
|
41
41
|
},
|