@belonguniverseai/react-sdk 0.1.3 → 0.1.4-beta

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.
Files changed (75) hide show
  1. package/dist/api/client.d.ts +57 -9
  2. package/dist/api/query-keys.d.ts +9 -0
  3. package/dist/api/workspace-files.d.ts +1 -1
  4. package/dist/component/{arc-Dftg9hbM.js → arc-BxS7Httb.js} +2 -2
  5. package/dist/component/{architectureDiagram-3BPJPVTR-LDQnfAgM.js → architectureDiagram-3BPJPVTR-C9p6wCFY.js} +3 -3
  6. package/dist/component/{blockDiagram-GPEHLZMM-7C0jnncw.js → blockDiagram-GPEHLZMM-B_4sjrFH.js} +4 -4
  7. package/dist/component/{c4Diagram-AAUBKEIU-BGEe9CdO.js → c4Diagram-AAUBKEIU-BAZBnWkR.js} +3 -3
  8. package/dist/component/{channel-CsGW22vj.js → channel-D_9jCQmy.js} +2 -2
  9. package/dist/component/{chunk-2J33WTMH-Dg3NXbVg.js → chunk-2J33WTMH-BAqJCIVt.js} +2 -2
  10. package/dist/component/{chunk-4BX2VUAB-BDtEKe-l.js → chunk-4BX2VUAB-CTC8q-Ea.js} +2 -2
  11. package/dist/component/{chunk-55IACEB6-Da2BRT6c.js → chunk-55IACEB6-CcASKowe.js} +2 -2
  12. package/dist/component/{chunk-727SXJPM-DhH-ppYY.js → chunk-727SXJPM-DUSkaQ6e.js} +6 -6
  13. package/dist/component/{chunk-AQP2D5EJ-D8PxFJHV.js → chunk-AQP2D5EJ-B_-4XjtP.js} +4 -4
  14. package/dist/component/{chunk-FMBD7UC4--IsNL9At.js → chunk-FMBD7UC4-D4VtGmb1.js} +2 -2
  15. package/dist/component/{chunk-ND2GUHAM-DbdImadK.js → chunk-ND2GUHAM-_nr7rOab.js} +2 -2
  16. package/dist/component/{chunk-QZHKN3VN-6IxJ3-HB.js → chunk-QZHKN3VN-BCKH-gFC.js} +2 -2
  17. package/dist/component/{classDiagram-4FO5ZUOK-BhkVSVk_.js → classDiagram-4FO5ZUOK-Dnq69pDR.js} +3 -3
  18. package/dist/component/{classDiagram-v2-Q7XG4LA2-BhkVSVk_.js → classDiagram-v2-Q7XG4LA2-Dnq69pDR.js} +3 -3
  19. package/dist/component/{cose-bilkent-S5V4N54A-_2z1EHfc.js → cose-bilkent-S5V4N54A-Ci3256Cw.js} +2 -2
  20. package/dist/component/{dagre-BM42HDAG-DlKG5hsO.js → dagre-BM42HDAG-D1H7ndes.js} +2 -2
  21. package/dist/component/{diagram-2AECGRRQ-CFAaADeR.js → diagram-2AECGRRQ-DA0oXo6P.js} +3 -3
  22. package/dist/component/{diagram-5GNKFQAL-ZJ957Qm9.js → diagram-5GNKFQAL-DwMOYjf9.js} +4 -4
  23. package/dist/component/{diagram-KO2AKTUF-CROmuIwX.js → diagram-KO2AKTUF-BAVad1Vy.js} +3 -3
  24. package/dist/component/{diagram-LMA3HP47-4YR2hh1P.js → diagram-LMA3HP47-BWNN256P.js} +3 -3
  25. package/dist/component/{diagram-OG6HWLK6-CfsgJnIX.js → diagram-OG6HWLK6-CTsISqXy.js} +4 -4
  26. package/dist/component/{erDiagram-TEJ5UH35-BajpSizj.js → erDiagram-TEJ5UH35-BLKTD8lF.js} +5 -5
  27. package/dist/component/{flowDiagram-I6XJVG4X-DYfoJvQB.js → flowDiagram-I6XJVG4X-DNmugITh.js} +7 -7
  28. package/dist/component/{ganttDiagram-6RSMTGT7-DxWg1-cU.js → ganttDiagram-6RSMTGT7-C834AkNu.js} +3 -3
  29. package/dist/component/{gitGraphDiagram-PVQCEYII-DPfijUuS.js → gitGraphDiagram-PVQCEYII-KpnFC5UI.js} +4 -4
  30. package/dist/component/{highlighted-body-OFNGDK62-BFpReqjo.js → highlighted-body-OFNGDK62-CNK-tfA_.js} +2 -2
  31. package/dist/component/index.js +2 -2
  32. package/dist/component/{infoDiagram-5YYISTIA-Cs3ZkSNq.js → infoDiagram-5YYISTIA-D7-Yqlci.js} +2 -2
  33. package/dist/component/{ishikawaDiagram-YF4QCWOH-wgyW2oOS.js → ishikawaDiagram-YF4QCWOH-Dkl6wTqA.js} +2 -2
  34. package/dist/component/{journeyDiagram-JHISSGLW-qvEHDcP8.js → journeyDiagram-JHISSGLW-CcN28ByV.js} +5 -5
  35. package/dist/component/{kanban-definition-UN3LZRKU-CS8E5I3H.js → kanban-definition-UN3LZRKU-hS_UMH7H.js} +3 -3
  36. package/dist/component/{linear-DSEm-mVJ.js → linear-BdhJkh0B.js} +2 -2
  37. package/dist/component/{mermaid-GHXKKRXX-mE-t6fEG.js → mermaid-GHXKKRXX-CUwFO8-B.js} +26675 -26113
  38. package/dist/component/{mindmap-definition-RKZ34NQL-4eLujZip.js → mindmap-definition-RKZ34NQL-DB-r9g1c.js} +4 -4
  39. package/dist/component/{pieDiagram-4H26LBE5-Bv3aeU7h.js → pieDiagram-4H26LBE5-CMqPVjRg.js} +4 -4
  40. package/dist/component/{quadrantDiagram-W4KKPZXB-BlpxPqAT.js → quadrantDiagram-W4KKPZXB-DWWi29dP.js} +3 -3
  41. package/dist/component/{requirementDiagram-4Y6WPE33-DGG1FxFS.js → requirementDiagram-4Y6WPE33-D1nFFrnS.js} +4 -4
  42. package/dist/component/{sankeyDiagram-5OEKKPKP-CQ-jfvW-.js → sankeyDiagram-5OEKKPKP-BnfzKSOs.js} +2 -2
  43. package/dist/component/{sequenceDiagram-3UESZ5HK-Ck-VbsGz.js → sequenceDiagram-3UESZ5HK-D3r-W-Vw.js} +4 -4
  44. package/dist/component/{stateDiagram-AJRCARHV-KlZdFGFQ.js → stateDiagram-AJRCARHV-Ba3bMrr0.js} +3 -3
  45. package/dist/component/{stateDiagram-v2-BHNVJYJU-Djoz6HMn.js → stateDiagram-v2-BHNVJYJU-YCAvqrHf.js} +3 -3
  46. package/dist/component/{timeline-definition-PNZ67QCA-C3x7MWUx.js → timeline-definition-PNZ67QCA-DlxU8RFH.js} +3 -3
  47. package/dist/component/{vennDiagram-CIIHVFJN-B4SXjWyu.js → vennDiagram-CIIHVFJN-teVIHl4-.js} +2 -2
  48. package/dist/component/{wardleyDiagram-YWT4CUSO-B_0Q8QFc.js → wardleyDiagram-YWT4CUSO-B31MFPtu.js} +3 -3
  49. package/dist/component/{xychartDiagram-2RQKCTM6-yIfLkIZO.js → xychartDiagram-2RQKCTM6-csegzRq-.js} +3 -3
  50. package/dist/components/embed/AgentGrantCard.d.ts +6 -4
  51. package/dist/components/embed/ComposerMenu.d.ts +9 -1
  52. package/dist/components/embed/EmbedRail.d.ts +17 -1
  53. package/dist/components/embed/SlashCommandMenu.d.ts +10 -6
  54. package/dist/components/feedback/feedback-metadata.d.ts +4 -30
  55. package/dist/embed/approval-bus.d.ts +14 -0
  56. package/dist/embed/approval-decision.d.ts +10 -0
  57. package/dist/embed/closed-surface-voice-bus.d.ts +25 -0
  58. package/dist/embed/copy.d.ts +3 -0
  59. package/dist/embed/global.d.ts +4 -3
  60. package/dist/embed/plan-decision.d.ts +3 -1
  61. package/dist/embed/use-workspace-file-download.d.ts +2 -0
  62. package/dist/embed/voice-decision.d.ts +27 -0
  63. package/dist/embed/voice-phrase-match.d.ts +5 -0
  64. package/dist/embed/voice-prefs.d.ts +4 -0
  65. package/dist/embed/voice-send-intent.d.ts +12 -0
  66. package/dist/embed/workspace-scope.d.ts +44 -0
  67. package/dist/i18n/messages/en.d.ts +3 -0
  68. package/dist/i18n/messages/surfaces/embedMisc.d.ts +4 -0
  69. package/dist/stream/ai-sdk-part-renderers.d.ts +8 -1
  70. package/dist/stream/belong-chat-transport.d.ts +54 -1
  71. package/dist/stream/belong-data-parts.d.ts +6 -4
  72. package/dist/stream/message-metadata.d.ts +45 -0
  73. package/dist/stream/stream-state-store.d.ts +4 -4
  74. package/dist/types/public.d.ts +11 -0
  75. package/package.json +1 -1
@@ -1,6 +1,34 @@
1
1
  import { z } from 'zod';
2
2
  import { ChatTransport, UIMessageChunk } from 'ai';
3
3
  import { BelongUIMessage, WireStreamPart } from './belong-data-parts.ts';
4
+ declare const cancelRunResponseSchema: z.ZodObject<{
5
+ recalledMessages: z.ZodDefault<z.ZodArray<z.ZodObject<{
6
+ messageId: z.ZodString;
7
+ clientMessageId: z.ZodNullable<z.ZodString>;
8
+ text: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ clientMessageId: string | null;
11
+ text: string;
12
+ messageId: string;
13
+ }, {
14
+ clientMessageId: string | null;
15
+ text: string;
16
+ messageId: string;
17
+ }>, "many">>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ recalledMessages: {
20
+ clientMessageId: string | null;
21
+ text: string;
22
+ messageId: string;
23
+ }[];
24
+ }, {
25
+ recalledMessages?: {
26
+ clientMessageId: string | null;
27
+ text: string;
28
+ messageId: string;
29
+ }[] | undefined;
30
+ }>;
31
+ export type RecalledQueuedMessage = z.infer<typeof cancelRunResponseSchema>["recalledMessages"][number];
4
32
  /**
5
33
  * The wire/stored part union. Exported so the history loader (chat.tsx) can
6
34
  * validate persisted assistant parts against the SAME shapes the live stream
@@ -652,6 +680,14 @@ export type BelongChatTransportOptions = {
652
680
  * production uses `STALL_TIMEOUT_MS`.
653
681
  */
654
682
  readonly stallTimeoutMs?: number;
683
+ /**
684
+ * Workspace isolation: the host workspace this transport's session belongs
685
+ * to. Defaults to the CURRENT scope at construction — captured once, so a
686
+ * workspace-A transport still streaming after the host switched to B keeps
687
+ * persisting its cursor under A's key and stamping A on its requests.
688
+ * Tests may pin it explicitly.
689
+ */
690
+ readonly workspaceExternalId?: string | null;
655
691
  };
656
692
  export type StreamContext = {
657
693
  /** Stable id we emit on every `text-delta`. Null when no text run is open. */
@@ -682,15 +718,32 @@ export type StreamContext = {
682
718
  export declare class BelongChatTransport implements ChatTransport<BelongUIMessage> {
683
719
  #private;
684
720
  constructor(options: BelongChatTransportOptions);
721
+ /**
722
+ * The server session this transport is pinned to (adopted at construction
723
+ * or created on first send), or null before any exists. The queued-send
724
+ * path reads THIS — never the live workspace-keyed pointer — so a steering
725
+ * message posts to the conversation on screen even inside the scope
726
+ * store's poll window after a host workspace switch.
727
+ */
728
+ get sessionId(): string | null;
729
+ /** The construction-captured workspace (see #workspaceExternalId). */
730
+ get workspaceExternalId(): string | null;
685
731
  /** Drop the cached session so the next `sendMessages` creates a new one. */
686
732
  reset(): void;
687
733
  /**
688
734
  * Best-effort server-side cancel of an in-flight run. `useChat`'s `stop()`
689
735
  * only aborts the local stream (stops listening); this tells belong-cloud to
690
736
  * actually halt the agent (POST /v1/runs/:runId/cancel → run-cancel pub/sub).
737
+ *
738
+ * BEL-144 — the backend also recalls the session's queued-but-unclaimed
739
+ * messages so they never execute; their text is returned here for the caller
740
+ * to restore into the composer. Any failure (network, non-2xx, old backend
741
+ * without the field) collapses to an empty list — the cancel stays
742
+ * best-effort.
691
743
  */
692
- cancelRun: (runId: string) => Promise<void>;
744
+ cancelRun: (runId: string) => Promise<readonly RecalledQueuedMessage[]>;
693
745
  sendMessages: ChatTransport<BelongUIMessage>["sendMessages"];
694
746
  reconnectToStream: ChatTransport<BelongUIMessage>["reconnectToStream"];
695
747
  }
696
748
  export declare const wireToUiChunks: (part: WireStreamPart, ctx: StreamContext) => readonly UIMessageChunk[];
749
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { UIMessage } from 'ai';
2
+ import { BelongMessageMetadata } from './message-metadata.ts';
2
3
  /**
3
4
  * F2 — per-step execution status. Optional: absent means `pending`
4
5
  * (back-compat with plans proposed before F2 and the initial propose). The
@@ -183,11 +184,12 @@ export type BelongDataParts = {
183
184
  };
184
185
  /**
185
186
  * The concrete `UIMessage` shape the chat surface and transport speak.
186
- * Metadata is typed `unknown` and read defensively at use sites (e.g. the
187
- * user-bubble skill chip reads `metadata.skill` via a narrowing guard) — keep
188
- * it `unknown` so new metadata fields need no type-plumbing changes.
187
+ * Metadata was `unknown` until the `fromHistory` gate needed to propagate
188
+ * reliably now it's the `belongMessageMetadataSchema`-inferred type, parsed
189
+ * once at the wire perimeter (§4) so use sites read typed fields instead of
190
+ * re-narrowing.
189
191
  */
190
- export type BelongUIMessage = UIMessage<unknown, BelongDataParts>;
192
+ export type BelongUIMessage = UIMessage<BelongMessageMetadata, BelongDataParts>;
191
193
  /**
192
194
  * Wire shape emitted by belong-cloud's SSE adapter. This stays as a
193
195
  * separate union because the server side has not migrated to AI-SDK
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ export declare const belongMessageMetadataSchema: z.ZodObject<{
3
+ /** Producing task of an assistant turn — the reload-stable feedback key. */
4
+ taskId: z.ZodOptional<z.ZodString>;
5
+ /** The user's current 👍/👎 on that turn; `.nullish()` because the live
6
+ * `start` chunk stamps no vote yet while history returns `null` for
7
+ * "no vote" (requiring it would hide the thumbs on a fresh turn). */
8
+ feedback: z.ZodOptional<z.ZodNullable<z.ZodObject<{
9
+ sentiment: z.ZodEnum<["up", "down"]>;
10
+ reason: z.ZodNullable<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ reason: string | null;
13
+ sentiment: "up" | "down";
14
+ }, {
15
+ reason: string | null;
16
+ sentiment: "up" | "down";
17
+ }>>>;
18
+ /** Server row creation time (ISO) — per-bubble clock, history only (§41). */
19
+ createdAt: z.ZodOptional<z.ZodString>;
20
+ /** Skill picked for this user message — renders the bubble's skill chip. */
21
+ skill: z.ZodOptional<z.ZodString>;
22
+ /** Set by `loadSessionHistory` on every restored message. Gates the
23
+ * dispatch renderers' auto-fire: absent (live/replayed turn) → fire once;
24
+ * true (restored history) → render settled, never re-dispatch. */
25
+ fromHistory: z.ZodOptional<z.ZodBoolean>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ createdAt?: string | undefined;
28
+ taskId?: string | undefined;
29
+ skill?: string | undefined;
30
+ feedback?: {
31
+ reason: string | null;
32
+ sentiment: "up" | "down";
33
+ } | null | undefined;
34
+ fromHistory?: boolean | undefined;
35
+ }, {
36
+ createdAt?: string | undefined;
37
+ taskId?: string | undefined;
38
+ skill?: string | undefined;
39
+ feedback?: {
40
+ reason: string | null;
41
+ sentiment: "up" | "down";
42
+ } | null | undefined;
43
+ fromHistory?: boolean | undefined;
44
+ }>;
45
+ export type BelongMessageMetadata = z.infer<typeof belongMessageMetadataSchema>;
@@ -30,9 +30,9 @@ declare const streamStateSchema: z.ZodObject<{
30
30
  lastEventId: string | null;
31
31
  }>;
32
32
  export type PersistedStreamState = z.infer<typeof streamStateSchema>;
33
- export declare const readStreamState: () => PersistedStreamState | null;
34
- export declare const writeStreamState: (state: Omit<PersistedStreamState, "updatedAt">) => void;
35
- export declare const clearStreamState: () => void;
33
+ export declare const readStreamState: (workspaceId?: string | null) => PersistedStreamState | null;
34
+ export declare const writeStreamState: (state: Omit<PersistedStreamState, "updatedAt">, workspaceId?: string | null) => void;
35
+ export declare const clearStreamState: (workspaceId?: string | null) => void;
36
36
  /**
37
37
  * Like {@link readStreamState}, but only returns state fresh enough that its
38
38
  * run is worth reconnecting to. Returns null for stale state WITHOUT clearing
@@ -40,7 +40,7 @@ export declare const clearStreamState: () => void;
40
40
  * and history restore on reload — only the *run* is too old to resume. A new
41
41
  * message overwrites the cursor via {@link writeStreamState}.
42
42
  */
43
- export declare const readResumableStreamState: () => PersistedStreamState | null;
43
+ export declare const readResumableStreamState: (workspaceId?: string | null) => PersistedStreamState | null;
44
44
  /**
45
45
  * Persist the chosen session as the active stream session (sessions menu
46
46
  * switch / new). Passing a session id points the next ChatRoute mount at that
@@ -177,6 +177,17 @@ export type BelongGlobal = {
177
177
  readonly setToken: (jwt: string) => void;
178
178
  /** Switch the dock UI language at runtime (persisted; relabels live). */
179
179
  readonly setLocale: (locale: BelongLocale) => void;
180
+ /**
181
+ * Switch the dock's workspace at runtime (workspace isolation). Re-scopes
182
+ * the whole dock synchronously — session list, Files tab, chat, and the
183
+ * agent's Simetrik CLI credential all follow the given workspace id (the
184
+ * same value `agentGrant.scopeExternalId` / the `scopeUrlParam` URL param
185
+ * carry). Wins over URL tracking until cleared with `null` (which falls
186
+ * back to the URL/static resolution). Invalid ids are ignored with a
187
+ * console warning. Hosts can use this standalone (no `scopeUrlParam`) or
188
+ * alongside URL tracking for instant switches.
189
+ */
190
+ readonly setWorkspace: (id: string | null) => void;
180
191
  readonly setTheme: (theme: PartialBelongTheme) => void;
181
192
  readonly applyPreset: (name: PresetName) => void;
182
193
  readonly open: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@belonguniverseai/react-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4-beta",
4
4
  "description": "Belong — embeddable React AI assistant dock. Mount <BelongWidget> in your app tree with getToken dependency-injection auth.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",