@tangle-network/sandbox-ui 0.85.0 → 0.85.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/dist/{chunk-MEDE37J5.js → chunk-QORIZARI.js} +25 -1
- package/dist/hooks.js +1 -1
- package/dist/index.js +1 -1
- package/dist/sdk-hooks.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
// src/hooks/use-session-stream.ts
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
// src/hooks/wire-encoding.ts
|
|
5
|
+
function utf8ToLatin1(text) {
|
|
6
|
+
return encodeURIComponent(text).replace(
|
|
7
|
+
/%([0-9A-F]{2})/g,
|
|
8
|
+
(_, hex) => String.fromCharCode(Number.parseInt(hex, 16))
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
function encodeTextForWire(text) {
|
|
12
|
+
if (typeof btoa === "function") {
|
|
13
|
+
return btoa(utf8ToLatin1(text));
|
|
14
|
+
}
|
|
15
|
+
const bufferCtor = globalThis.Buffer;
|
|
16
|
+
if (bufferCtor) {
|
|
17
|
+
return bufferCtor.from(text, "utf8").toString("base64");
|
|
18
|
+
}
|
|
19
|
+
throw new Error(
|
|
20
|
+
"encodeTextForWire: no base64 encoder available (btoa and Buffer both undefined)"
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/hooks/use-session-stream.ts
|
|
3
25
|
function mapApiMessage(msg, counterRef) {
|
|
4
26
|
const created = msg.info.timestamp ? new Date(msg.info.timestamp).getTime() : Date.now();
|
|
5
27
|
const message = {
|
|
@@ -235,7 +257,9 @@ function useSessionStream({
|
|
|
235
257
|
await fetchJson(url, token, {
|
|
236
258
|
method: "POST",
|
|
237
259
|
body: JSON.stringify({
|
|
238
|
-
|
|
260
|
+
// The sidecar base64-decodes every text part at the route boundary;
|
|
261
|
+
// a raw-UTF-8 part is rejected 400 (or mis-decoded). See wire-encoding.ts.
|
|
262
|
+
parts: [{ type: "text", text: encodeTextForWire(text) }],
|
|
239
263
|
...options?.agent ? { agent: options.agent } : {},
|
|
240
264
|
...options?.model ? { model: options.model } : {},
|
|
241
265
|
...options?.system ? { system: options.system } : {},
|
package/dist/hooks.js
CHANGED
package/dist/index.js
CHANGED
package/dist/sdk-hooks.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/sandbox-ui",
|
|
3
|
-
"version": "0.85.
|
|
3
|
+
"version": "0.85.1",
|
|
4
4
|
"description": "Unified UI component library for Tangle Sandbox \u2014 primitives, chat, dashboard, terminal, editor, and workspace components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|