@belonguniverseai/react-sdk 0.6.28 → 0.6.29

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 (101) hide show
  1. package/README.md +14 -4
  2. package/dist/api/artifact-actions.d.ts +0 -1
  3. package/dist/api/auth-errors.d.ts +21 -0
  4. package/dist/api/client.d.ts +800 -64
  5. package/dist/api/goals.d.ts +19 -2
  6. package/dist/api/task-schedule-sharing.d.ts +18 -3
  7. package/dist/api/task-schedules.d.ts +74 -10
  8. package/dist/app/VoiceOverlay.d.ts +4 -3
  9. package/dist/app/dock-story-data.d.ts +15 -0
  10. package/dist/browser/control-channel.d.ts +9 -0
  11. package/dist/browser/dom-bridge.d.ts +2 -0
  12. package/dist/component/BelongWidget.d.ts +13 -3
  13. package/dist/component/{abnfDiagram-N423BO3Z-BGC_KU0K.js → abnfDiagram-N423BO3Z-BvL7baZ-.js} +4 -4
  14. package/dist/component/{arc-BpIEtZvJ.js → arc-DVUroP2Z.js} +2 -2
  15. package/dist/component/{architectureDiagram-T3A2C74G-DYlEVfnh.js → architectureDiagram-T3A2C74G-CYt93mxs.js} +3 -3
  16. package/dist/component/{blockDiagram-VBNYF7ZC-BWDnhAW1.js → blockDiagram-VBNYF7ZC-yST7U8Pb.js} +4 -4
  17. package/dist/component/{c4Diagram-5PPSVZJV-VKL0Shn2.js → c4Diagram-5PPSVZJV-BHz6Efx3.js} +3 -3
  18. package/dist/component/{channel-gGd0pNDR.js → channel-CKTqNdN4.js} +2 -2
  19. package/dist/component/{chunk-2GRJ4B5K-CEt4y1jX.js → chunk-2GRJ4B5K-Bw2zHHAm.js} +2 -2
  20. package/dist/component/{chunk-2Q5K7J3B-Dj2wrNzr.js → chunk-2Q5K7J3B-DpBuF73m.js} +2 -2
  21. package/dist/component/{chunk-5RXB4S5H-oJQEn1bH.js → chunk-5RXB4S5H-dxBtwi1p.js} +5 -5
  22. package/dist/component/{chunk-5VM5RSS4-DddP8MPP.js → chunk-5VM5RSS4-BOTqM1Rc.js} +2 -2
  23. package/dist/component/{chunk-6Q2QTUOP-CppUJwrF.js → chunk-6Q2QTUOP-DjMXJhRD.js} +2 -2
  24. package/dist/component/{chunk-GF5L2VYU--hyUlO9v.js → chunk-GF5L2VYU-CGpnSfXM.js} +6 -6
  25. package/dist/component/{chunk-JWPE2WC7-CN0Ieqel.js → chunk-JWPE2WC7-L5aYKPho.js} +2 -2
  26. package/dist/component/{chunk-KBJHAD2P-BWhCQoHz.js → chunk-KBJHAD2P-DH2RFBaF.js} +2 -2
  27. package/dist/component/{chunk-RYQCIY6F-BgNewpQe.js → chunk-RYQCIY6F-QPgRO0s7.js} +2 -2
  28. package/dist/component/{chunk-XXDRQBXY-mNH171OF.js → chunk-XXDRQBXY-C1ezaFpA.js} +2 -2
  29. package/dist/component/{classDiagram-JCYQIIEL-UjZbWotD.js → classDiagram-JCYQIIEL-Dx7Qx836.js} +3 -3
  30. package/dist/component/{classDiagram-v2-OCEON4UE-UjZbWotD.js → classDiagram-v2-OCEON4UE-Dx7Qx836.js} +3 -3
  31. package/dist/component/{cose-bilkent-JH36ORCC-lsVWGlMj.js → cose-bilkent-JH36ORCC-Bem1eaLJ.js} +2 -2
  32. package/dist/component/{cynefinDiagram-MW4NZA55-B5Ss0zoy.js → cynefinDiagram-MW4NZA55-DF15EWOu.js} +3 -3
  33. package/dist/component/{dagre-VZM6K2ZE-DisWRVfU.js → dagre-VZM6K2ZE-BVzwev7l.js} +3 -3
  34. package/dist/component/{diagram-7IWD3JNH-B2QrdsOh.js → diagram-7IWD3JNH-DzQhKX_v.js} +4 -4
  35. package/dist/component/{diagram-B4RE2ZJO-Bs8l4THz.js → diagram-B4RE2ZJO-DnHINfhE.js} +3 -3
  36. package/dist/component/{diagram-LBJQPF4R-JTadtYMW.js → diagram-LBJQPF4R-CPqE_GwY.js} +3 -3
  37. package/dist/component/{diagram-Q27KOJAE-BQC33flc.js → diagram-Q27KOJAE-BjpvfqhL.js} +4 -4
  38. package/dist/component/{diagram-UB23O5K3-ujC22dQx.js → diagram-UB23O5K3-BcYqFjqI.js} +3 -3
  39. package/dist/component/{ebnfDiagram-BXEA7PRR-0WnF2wzt.js → ebnfDiagram-BXEA7PRR-DoqGcWGx.js} +4 -4
  40. package/dist/component/{erDiagram-JOGREHBK-CqgMsd5R.js → erDiagram-JOGREHBK-DGrj5tIK.js} +5 -5
  41. package/dist/component/{flowDiagram-UKHOOZJN-BOM0P8Mk.js → flowDiagram-UKHOOZJN-B8OuOrVY.js} +7 -7
  42. package/dist/component/{ganttDiagram-PKOTCBZU-WeRFC1th.js → ganttDiagram-PKOTCBZU-BaxSqTVY.js} +3 -3
  43. package/dist/component/{gitGraphDiagram-DS77QQ5N-CS8L-BA8.js → gitGraphDiagram-DS77QQ5N-W1Sqa3Hc.js} +4 -4
  44. package/dist/component/{highlighted-body-OFNGDK62-CGejnMyq.js → highlighted-body-OFNGDK62-Cf1UqcGe.js} +2 -2
  45. package/dist/component/index.d.ts +1 -0
  46. package/dist/component/index.js +2 -2
  47. package/dist/component/{infoDiagram-6WML65LV-CQQhytkd.js → infoDiagram-6WML65LV-BS0JlYPr.js} +2 -2
  48. package/dist/component/{ishikawaDiagram-WSZJBQD7-CjDo3-zt.js → ishikawaDiagram-WSZJBQD7-Df_NzOQV.js} +2 -2
  49. package/dist/component/{journeyDiagram-NVQOT4AX-BCCoblta.js → journeyDiagram-NVQOT4AX-JWKvZ6rc.js} +5 -5
  50. package/dist/component/{kanban-definition-27J2QSJJ-DgTIrgvB.js → kanban-definition-27J2QSJJ-DMvICKAB.js} +3 -3
  51. package/dist/component/{linear-BOaza_dp.js → linear-D02U2fTS.js} +2 -2
  52. package/dist/component/{mermaid-GHXKKRXX-BAq5-Vj8.js → mermaid-GHXKKRXX-B7CJJdoE.js} +37650 -36676
  53. package/dist/component/{mindmap-definition-FAOFIHXS-D1oolR3A.js → mindmap-definition-FAOFIHXS-AzTh8oju.js} +4 -4
  54. package/dist/component/{pegDiagram-VL7TDLO6-C9UxqvBP.js → pegDiagram-VL7TDLO6-DSCzZs_w.js} +4 -4
  55. package/dist/component/{pieDiagram-7S7Q4E2Y-I5IXzOZM.js → pieDiagram-7S7Q4E2Y-CEByr6BB.js} +4 -4
  56. package/dist/component/{quadrantDiagram-CIZ2JOQS-DPDFBhEd.js → quadrantDiagram-CIZ2JOQS-BrWOf-GT.js} +3 -3
  57. package/dist/component/{railroadDiagram-AXF67PYL-DIAkhVTf.js → railroadDiagram-AXF67PYL-DRtsV2gM.js} +4 -4
  58. package/dist/component/{requirementDiagram-LRYGKXZP-DBEmV-Qy.js → requirementDiagram-LRYGKXZP-_WwAo7AE.js} +4 -4
  59. package/dist/component/{sankeyDiagram-W5VNT64P-BEeDyDj7.js → sankeyDiagram-W5VNT64P-DBxP3yyK.js} +2 -2
  60. package/dist/component/{sequenceDiagram-SI44F4Z6-WYcXWUHF.js → sequenceDiagram-SI44F4Z6-B3SNXrpC.js} +4 -4
  61. package/dist/component/{sizeCapture-X5ZJPWSS-BqDBRpiS.js → sizeCapture-X5ZJPWSS-D5G8pyPC.js} +2 -2
  62. package/dist/component/{stateDiagram-OKZ733FA-CfYfR0OH.js → stateDiagram-OKZ733FA-C4UZwsoc.js} +3 -3
  63. package/dist/component/{stateDiagram-v2-UEYNNEHI-BSa2VwcQ.js → stateDiagram-v2-UEYNNEHI-DIYB5q15.js} +3 -3
  64. package/dist/component/{swimlanes-SLNWSIFB-C-7mrC4X.js → swimlanes-SLNWSIFB-Cc9yJXTh.js} +4 -4
  65. package/dist/component/{swimlanesDiagram-ULZ7WXOC-DXcMd7U4.js → swimlanesDiagram-ULZ7WXOC-DsGPiJ-s.js} +3 -3
  66. package/dist/component/{timeline-definition-Z64GVDOM-Dp65E80E.js → timeline-definition-Z64GVDOM-Dr4-iAeD.js} +3 -3
  67. package/dist/component/{vennDiagram-T6HMQDX7-CRpZ12TH.js → vennDiagram-T6HMQDX7-ZiaZ9jYw.js} +2 -2
  68. package/dist/component/{wardleyDiagram-T6FBY63Y-BupsM8K3.js → wardleyDiagram-T6FBY63Y-KdF37MT-.js} +3 -3
  69. package/dist/component/{xychartDiagram-ELKLHX3M-CUnr8Qbu.js → xychartDiagram-ELKLHX3M-NH_bOKPL.js} +3 -3
  70. package/dist/components/embed/ComposerContext.d.ts +11 -7
  71. package/dist/components/embed/EmbedComposer.d.ts +3 -1
  72. package/dist/components/embed/GoalRefusalCard.d.ts +5 -1
  73. package/dist/components/scheduled/ConfirmRunPausedScheduleDialog.d.ts +18 -0
  74. package/dist/components/scheduled/EmailCopiesFields.d.ts +19 -0
  75. package/dist/components/scheduled/ScheduledDetailSurface.d.ts +2 -1
  76. package/dist/components/scheduled/use-run-now-with-confirmation.d.ts +17 -0
  77. package/dist/embed/artifact-action-bridge.d.ts +11 -3
  78. package/dist/embed/artifact-remint-budget.d.ts +5 -0
  79. package/dist/embed/copy.d.ts +13 -18
  80. package/dist/embed/goal-edit-command.d.ts +6 -5
  81. package/dist/embed/plan-decision-text.d.ts +1 -0
  82. package/dist/embed/voice-config.d.ts +22 -31
  83. package/dist/embed/voice-prefs.d.ts +18 -34
  84. package/dist/i18n/messages/en.d.ts +28 -2
  85. package/dist/i18n/messages/surfaces/feedback.d.ts +12 -0
  86. package/dist/i18n/messages/surfaces/plan.d.ts +4 -0
  87. package/dist/i18n/messages/surfaces/scheduled.d.ts +53 -1
  88. package/dist/i18n/messages/surfaces/usage.d.ts +1 -1
  89. package/dist/lib/tab-control-store.d.ts +14 -0
  90. package/dist/lib/tab-leadership.d.ts +9 -24
  91. package/dist/lib/use-tab-leadership.d.ts +5 -7
  92. package/dist/routes/chat/history-merge.d.ts +53 -0
  93. package/dist/routes/chat/history-paging.d.ts +25 -6
  94. package/dist/routes/chat/use-catch-up-on-return.d.ts +70 -0
  95. package/dist/routes/chat/use-return-to-page.d.ts +7 -0
  96. package/dist/stream/belong-chat-transport.d.ts +8 -6
  97. package/dist/stream/dispatch-once.d.ts +1 -1
  98. package/dist/stream/queued-message-outbox.d.ts +1 -0
  99. package/dist/stream/session-control-context.d.ts +7 -0
  100. package/dist/types/public.d.ts +12 -5
  101. package/package.json +1 -1
@@ -0,0 +1,70 @@
1
+ import { BelongUIMessage } from '../../stream/belong-data-parts.ts';
2
+ import { HistoryPageResult, LoadedHistoryPage } from './history-cache.ts';
3
+ import { useReturnToPage } from './use-return-to-page.ts';
4
+ /** The chat as the catch-up reads it: `@ai-sdk/react`'s `Chat`, live. Its
5
+ * `messages` array is replaced on every change, so identity says "changed". */
6
+ export type CatchUpChat = {
7
+ readonly status: "submitted" | "streaming" | "ready" | "error";
8
+ readonly messages: readonly BelongUIMessage[];
9
+ };
10
+ /** The server's answer about the session's active run. `failed` (network,
11
+ * non-2xx, a drifted body) is not `none`: only a confirmed `none` is
12
+ * remembered. */
13
+ export type ActiveRunLookup = {
14
+ readonly kind: "none";
15
+ } | {
16
+ readonly kind: "run";
17
+ readonly runId: string;
18
+ } | {
19
+ readonly kind: "failed";
20
+ };
21
+ /** The transport as the catch-up reads it. */
22
+ export type CatchUpTransport = {
23
+ readonly sessionId: string | null;
24
+ /** A stream, its handshake or its retry loop owns this session. */
25
+ readonly hasLiveStream: boolean;
26
+ };
27
+ /** What else may own the transcript right now; any of them blocks a step. */
28
+ export type CatchUpBlockers = {
29
+ /** The workspace does not resolve. */
30
+ readonly workspaceMissing: boolean;
31
+ /** The mount's first history read is out. */
32
+ readonly historyLoading: boolean;
33
+ /** A resume handshake is under way. */
34
+ readonly restoringLiveRun: boolean;
35
+ /** A queued-reply reconciliation is pending. It starts without a render,
36
+ * so it is asked for when needed rather than passed as a value. */
37
+ readonly queuedReconciliationPending: () => boolean;
38
+ };
39
+ export declare const useCatchUpOnReturn: (input: {
40
+ readonly chat: CatchUpChat;
41
+ readonly transport: CatchUpTransport;
42
+ /** Checked when a step starts and again after every await, against the
43
+ * latest render's values, never those of the render that started it. */
44
+ readonly blockers: CatchUpBlockers;
45
+ /** Read the newest page from the server now. */
46
+ readonly readNewestPage: (sessionId: string) => Promise<HistoryPageResult>;
47
+ /** The read landed after the transcript changed: the page it cached may
48
+ * predate the change (a clear), so no chat may be painted from it. */
49
+ readonly onReadOutdated: (sessionId: string) => void;
50
+ /** Show `caughtUp`, the conversation `page` brought the screen up to. */
51
+ readonly onCaughtUp: (caughtUp: BelongUIMessage[], page: LoadedHistoryPage) => void;
52
+ /** Ask the server for the session's active run. */
53
+ readonly findActiveRun: (sessionId: string) => Promise<ActiveRunLookup>;
54
+ /** Follow `runId`, the reply to the turn `page` ends on, from its first event. */
55
+ readonly onFollowRun: (sessionId: string, runId: string, page: LoadedHistoryPage) => void;
56
+ /** The session this tab has selected now (the stream-state pointer). */
57
+ readonly selectedSessionId: () => string | null;
58
+ /** Bumped when the transcript's work loses its owner (leaving the chat, a
59
+ * clear, a stop): a step started under an older value drops itself. A
60
+ * clear's POST runs before it empties the screen, so the transcript alone
61
+ * cannot tell a lookup that the clear is under way. */
62
+ readonly ownerGeneration: () => number;
63
+ /** A newly controlling tab catches up even when the page stayed visible. */
64
+ readonly controlRole?: "leader" | "follower";
65
+ /** Explicit retries of a control request, including a failed catch-up. */
66
+ readonly controlRequestId?: number;
67
+ readonly prepareControl?: (sessionId: string) => Promise<void>;
68
+ readonly onControlReady?: (ready: boolean) => void;
69
+ readonly returnOptions?: Parameters<typeof useReturnToPage>[1];
70
+ }) => void;
@@ -0,0 +1,7 @@
1
+ /** Two return signals closer together than this are one return. */
2
+ export declare const RETURN_MIN_GAP_MS = 2000;
3
+ export declare const useReturnToPage: (onReturn: () => void, options?: {
4
+ readonly minGapMs?: number;
5
+ /** Clock seam (§25). */
6
+ readonly nowMs?: () => number;
7
+ }) => void;
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ChatTransport, UIMessageChunk } from 'ai';
3
3
  import { FirstResponseObservation, FirstResponseSample } from '../infrastructure/telemetry/first-response-timing.ts';
4
+ import { AUTH_EXPIRED_ERROR_PREFIX } from '../api/auth-errors.ts';
4
5
  import { BelongUIMessage, WireStreamPart } from './belong-data-parts.ts';
5
6
  declare const cancelRunResponseSchema: z.ZodObject<{
6
7
  recalledMessages: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -364,9 +365,9 @@ export declare const wireStreamPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
364
365
  at: z.ZodString;
365
366
  }, z.core.$strip>>>;
366
367
  runway: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
368
+ long: "long";
367
369
  quick: "quick";
368
370
  normal: "normal";
369
- long: "long";
370
371
  }>>>;
371
372
  }, z.core.$strip>;
372
373
  }, z.core.$strip>, z.ZodObject<{
@@ -377,15 +378,17 @@ export declare const wireStreamPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
377
378
  why: z.ZodString;
378
379
  criteria: z.ZodOptional<z.ZodArray<z.ZodString>>;
379
380
  runway: z.ZodOptional<z.ZodEnum<{
381
+ long: "long";
380
382
  quick: "quick";
381
383
  normal: "normal";
382
- long: "long";
383
384
  }>>;
384
385
  }, z.core.$strip>;
385
386
  }, z.core.$strip>], "type">;
386
- /** A request was 401'd twice (once with a freshly re-read token): the host
387
- * session is expired — the dock must surface re-auth, not retry forever. */
388
- export declare const AUTH_EXPIRED_ERROR_PREFIX = "auth_expired:";
387
+ /** A request was 401'd twice (once with a freshly re-read token), or no usable
388
+ * token could be had at all (`BelongAuthUnavailableError`): the host session is
389
+ * expired — the dock must surface re-auth, not retry forever. Defined by the
390
+ * request layer, which raises it too; re-exported here for chat.tsx. */
391
+ export { AUTH_EXPIRED_ERROR_PREFIX };
389
392
  /** The SSE reconnect loop exhausted its attempt budget without the backend
390
393
  * delivering a single event — the service is unreachable. */
391
394
  export declare const BACKEND_UNAVAILABLE_ERROR_PREFIX = "backend_unavailable:";
@@ -604,4 +607,3 @@ export declare class BelongChatTransport implements ChatTransport<BelongUIMessag
604
607
  reconnectToStream: ChatTransport<BelongUIMessage>["reconnectToStream"];
605
608
  }
606
609
  export declare const wireToUiChunks: (part: WireStreamPart, ctx: StreamContext) => readonly UIMessageChunk[];
607
- export {};
@@ -4,7 +4,7 @@ export declare const claimDispatch: (key: string) => boolean;
4
4
  * Run `effect` once for `key` on this page — or, without a key, once for the
5
5
  * component's lifetime (React 19 StrictMode double-invokes included).
6
6
  */
7
- export declare const useDispatchOnce: (key: string | undefined, effect: () => void, deps: readonly unknown[]) => void;
7
+ export declare const useDispatchOnce: (key: string | undefined, effect: () => void, deps: readonly unknown[], canDispatch?: () => boolean) => void;
8
8
  /** Where a dispatch card's one-shot call stands. */
9
9
  export type DispatchStatus = "dispatching" | "running" | "ok" | "no_handler" | "failed" | "done";
10
10
  /** What a dispatch card shows, remembered by the same key as its guard. */
@@ -20,6 +20,7 @@ declare const queuedMessageOutboxEntrySchema: z.ZodObject<{
20
20
  fast: "fast";
21
21
  smart: "smart";
22
22
  }>>;
23
+ pageLabel: z.ZodOptional<z.ZodString>;
23
24
  workspaceExternalId: z.ZodOptional<z.ZodString>;
24
25
  }, z.core.$strip>;
25
26
  export type QueuedMessageOutboxEntry = Readonly<z.infer<typeof queuedMessageOutboxEntrySchema>>;
@@ -0,0 +1,7 @@
1
+ export type SessionControl = {
2
+ readonly readOnly: boolean;
3
+ /** Read live ownership again at the moment a side effect starts. */
4
+ readonly canControl: () => boolean;
5
+ };
6
+ export declare const SessionControlContext: import('react').Context<SessionControl>;
7
+ export declare const useSessionControl: () => SessionControl;
@@ -166,9 +166,11 @@ export type BelongInitInput = {
166
166
  };
167
167
  /**
168
168
  * What page the user is on, shown as "Looking at ‹label›" before the first
169
- * message. Omit `label` to use the browser tab title (`document.title`,
169
+ * message and in the composer's page chip, and SENT with every message so
170
+ * the agent can resolve "this page" (the label only, never the page's
171
+ * contents). Omit `label` to use the browser tab title (`document.title`,
170
172
  * tracked live so SPA navigation updates the line); pass
171
- * `fromDocumentTitle: false` to show nothing unless a label is given.
173
+ * `fromDocumentTitle: false` to show and send nothing unless a label is given.
172
174
  * A re-`init` replaces this config wholesale: omitting `pageContext` clears
173
175
  * a previously seeded `label` and restores the tab-title fallback.
174
176
  * `belong.setPageContext` overrides both at runtime and SURVIVES a later
@@ -182,7 +184,12 @@ export type BelongInitInput = {
182
184
  readonly theme?: PartialBelongTheme;
183
185
  /** Optional voice config (push-to-talk + read-aloud). */
184
186
  readonly voice?: {
185
- /** Hold-to-talk key as a `KeyboardEvent.code`. Default `"ControlLeft"`. */
187
+ /**
188
+ * Default hold-to-talk key as a `KeyboardEvent.code`: one of
189
+ * `"ControlRight"`, `"ControlLeft"`, `"AltRight"`, `"AltLeft"`, `"F2"`,
190
+ * `"F8"`, `"F9"`; any other code is ignored. Default: none — each user
191
+ * picks a key (or keeps it off) in Settings → Voice, and their choice wins.
192
+ */
186
193
  readonly pushToTalkKey?: string;
187
194
  /** Auto-read assistant replies aloud (ElevenLabs TTS). Default `true`. */
188
195
  readonly autoplayTts?: boolean;
@@ -324,8 +331,8 @@ export type BelongGlobal = {
324
331
  readonly displayName?: string | null;
325
332
  } | null) => void;
326
333
  /**
327
- * Set the page label shown before the first message (wins over
328
- * `init({ pageContext })` and the tab title). `null` drops the override.
334
+ * Set the page label shown in the dock and sent with each message (wins
335
+ * over `init({ pageContext })` and the tab title). `null` drops the override.
329
336
  */
330
337
  readonly setPageContext: (label: string | null) => void;
331
338
  readonly setTheme: (theme: PartialBelongTheme) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@belonguniverseai/react-sdk",
3
- "version": "0.6.28",
3
+ "version": "0.6.29",
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",