@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.
@@ -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
- parts: [{ type: "text", text }],
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
@@ -21,7 +21,7 @@ import {
21
21
  import {
22
22
  useSessionStream,
23
23
  useSidecarAuth
24
- } from "./chunk-MEDE37J5.js";
24
+ } from "./chunk-QORIZARI.js";
25
25
  import {
26
26
  usePtySession
27
27
  } from "./chunk-77WVVJA4.js";
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  import {
22
22
  useSessionStream,
23
23
  useSidecarAuth
24
- } from "./chunk-MEDE37J5.js";
24
+ } from "./chunk-QORIZARI.js";
25
25
  import {
26
26
  activeSessionsAtom,
27
27
  addMessage,
package/dist/sdk-hooks.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useSessionStream,
3
3
  useSidecarAuth
4
- } from "./chunk-MEDE37J5.js";
4
+ } from "./chunk-QORIZARI.js";
5
5
  import "./chunk-U67V476Y.js";
6
6
 
7
7
  // src/sdk-hooks.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox-ui",
3
- "version": "0.85.0",
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",