@unoverse-platform/studio 0.1.23 → 0.1.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unoverse-platform/studio",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "description": "Unoverse Studio: the local authoring app. Reads your own rx/ folder, no backend.",
6
6
  "scripts": {
@@ -41,16 +41,18 @@ const chatIdFor = (app: string) => `demo-${app.toLowerCase()}-${SESSION_NONCE}`;
41
41
  // it opens the Gravity data plane (WS component stream + REST execute) against the
42
42
  // configured server/workflow/node; in MOCK mode it seeds a fake conversation.
43
43
  // These are editable in the toolbar (LIVE mode) and persisted across refreshes.
44
- // Dev workbench serves /api + /ws/gravity + /stream on the merged uWS at :4205
45
- // (the retired gateway was :4100). Prod uses the page origin.
46
- const CONN_DEFAULTS = { server: "localhost:4205", workflowId: "wf-r4jzo7", triggerNode: "inputtrigger1", token: "" };
44
+ // The dev universe serves /mcp + /api + /ws/gravity + /stream on the merged uWS at
45
+ // :4105 — since the workbench retired, uWS binds the public port DIRECTLY in dev, same
46
+ // as prod (the retired workbench was :4205, the retired gateway :4100). Prod uses the
47
+ // page origin.
48
+ const CONN_DEFAULTS = { server: "localhost:4105", workflowId: "wf-r4jzo7", triggerNode: "inputtrigger1", token: "" };
47
49
  const CONN_KEY = "unoverse.workbench.conn";
48
50
 
49
51
  function loadConn(): typeof CONN_DEFAULTS {
50
52
  try {
51
53
  const saved = JSON.parse(localStorage.getItem(CONN_KEY) ?? "{}");
52
- // Migration: drop the retired gateway port so the new default applies.
53
- if (saved.server === "localhost:4100") delete saved.server;
54
+ // Migration: drop retired ports (gateway :4100, workbench :4205) so the new default applies.
55
+ if (saved.server === "localhost:4100" || saved.server === "localhost:4205") delete saved.server;
54
56
  return { ...CONN_DEFAULTS, ...saved };
55
57
  } catch {
56
58
  return { ...CONN_DEFAULTS };
@@ -12,6 +12,12 @@ type HostConfig = Omit<AppConfig, "getAccessToken"> & { token?: string };
12
12
  let root: Root | null = null;
13
13
  let current: HostConfig | null = null;
14
14
 
15
+ // Stable identity, module-level: the connection hook keys its lifecycle on the
16
+ // `getAccessToken` reference (connection.tsx effect deps), and the host re-posts
17
+ // config on every iframe load — an inline closure here would recycle the live
18
+ // /stream session on each repost.
19
+ const readToken = () => current?.token ?? null;
20
+
15
21
  function render() {
16
22
  if (!current) return;
17
23
  const el = document.getElementById("root")!;
@@ -23,15 +29,21 @@ function render() {
23
29
  templateId={current.templateId}
24
30
  userId={current.userId}
25
31
  conversationId={current.conversationId}
26
- getAccessToken={() => current?.token ?? null}
32
+ // Only claim auth when the host actually sent a token. A fabricated accessor on a
33
+ // tokenless boot made the SDK skip its guest-id substitution (connection.tsx), so
34
+ // the session registered a non-guest id and the public-entry gate refused it.
35
+ // No token ⇒ no accessor ⇒ the SDK mints/persists `guest-<uuid>` per the contract
36
+ // (UNOVERSE_MCP_TEMPLATE_PROTOCOL §5, AUTH_TOKEN_FLOW Run Authorization).
37
+ getAccessToken={current.token ? readToken : undefined}
27
38
  />,
28
39
  );
29
40
  }
30
41
 
31
42
  function apply(cfg: HostConfig) {
32
- const first = !current;
33
43
  current = { ...current, ...cfg };
34
- if (first) render(); // mount once; token refresh just updates `current` (getAccessToken reads it)
44
+ // Re-render on every apply so a token appearing/disappearing takes effect; a same-token
45
+ // refresh changes nothing (readToken is stable, values equal), so no connection churn.
46
+ render();
35
47
  }
36
48
 
37
49
  declare global {