@belonguniverseai/react-sdk 0.3.6 → 0.4.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/api/client.d.ts +238 -0
- package/dist/api/queries.d.ts +16 -0
- package/dist/api/query-keys.d.ts +1 -0
- package/dist/api/report-client-error.d.ts +1 -1
- package/dist/api/task-schedules.d.ts +3 -3
- package/dist/component/BelongWidget.d.ts +5 -3
- package/dist/component/{arc-6nY2VvBR.js → arc-Du1-HUt0.js} +2 -2
- package/dist/component/{architectureDiagram-3BPJPVTR-8NzFzSu-.js → architectureDiagram-3BPJPVTR-NTFoFNN-.js} +3 -3
- package/dist/component/{blockDiagram-GPEHLZMM-DUEwMafH.js → blockDiagram-GPEHLZMM-9LBL4EUV.js} +4 -4
- package/dist/component/{c4Diagram-AAUBKEIU-CDD_6To7.js → c4Diagram-AAUBKEIU-C1enIoRg.js} +3 -3
- package/dist/component/{channel-B4iaYdVF.js → channel-CNnOkAN_.js} +2 -2
- package/dist/component/{chunk-2J33WTMH-DyOrhFxY.js → chunk-2J33WTMH-X2Iy3mMD.js} +2 -2
- package/dist/component/{chunk-4BX2VUAB-Bc66-Fjy.js → chunk-4BX2VUAB-BLlcE09Q.js} +2 -2
- package/dist/component/{chunk-55IACEB6-CIN0g3JH.js → chunk-55IACEB6-23v_td5T.js} +2 -2
- package/dist/component/{chunk-727SXJPM-BGs-m5or.js → chunk-727SXJPM-BC2kAa1t.js} +6 -6
- package/dist/component/{chunk-AQP2D5EJ-CPlwnVcL.js → chunk-AQP2D5EJ-CsRFVdwF.js} +4 -4
- package/dist/component/{chunk-FMBD7UC4-09viRWEH.js → chunk-FMBD7UC4-CWrggihb.js} +2 -2
- package/dist/component/{chunk-ND2GUHAM-BJo4K53f.js → chunk-ND2GUHAM-Bj78QMsn.js} +2 -2
- package/dist/component/{chunk-QZHKN3VN-DufugBok.js → chunk-QZHKN3VN-CS_FAlLS.js} +2 -2
- package/dist/component/{classDiagram-4FO5ZUOK-DfAygW-7.js → classDiagram-4FO5ZUOK-ci84KOU1.js} +3 -3
- package/dist/component/{classDiagram-v2-Q7XG4LA2-DfAygW-7.js → classDiagram-v2-Q7XG4LA2-ci84KOU1.js} +3 -3
- package/dist/component/{cose-bilkent-S5V4N54A-CUKOuMcm.js → cose-bilkent-S5V4N54A-QLIj0pt2.js} +2 -2
- package/dist/component/{dagre-BM42HDAG-BPRObW6r.js → dagre-BM42HDAG-D32wP-VH.js} +2 -2
- package/dist/component/{diagram-2AECGRRQ-Cxsg-pXz.js → diagram-2AECGRRQ-Dn47q_hT.js} +3 -3
- package/dist/component/{diagram-5GNKFQAL-U6L8NDef.js → diagram-5GNKFQAL-Df7a_ICg.js} +4 -4
- package/dist/component/{diagram-KO2AKTUF-BxN_e8Dk.js → diagram-KO2AKTUF-CNcoKufc.js} +3 -3
- package/dist/component/{diagram-LMA3HP47-Dbkb79LU.js → diagram-LMA3HP47-Dq8j6XNs.js} +3 -3
- package/dist/component/{diagram-OG6HWLK6-SASqlYMy.js → diagram-OG6HWLK6-CZ1WglbZ.js} +4 -4
- package/dist/component/{erDiagram-TEJ5UH35-CDTBM9wY.js → erDiagram-TEJ5UH35-CDlHARAu.js} +5 -5
- package/dist/component/{flowDiagram-I6XJVG4X-DugkNxCw.js → flowDiagram-I6XJVG4X-Cw1mKy8X.js} +7 -7
- package/dist/component/{ganttDiagram-6RSMTGT7-D3FuGu21.js → ganttDiagram-6RSMTGT7-B3FUForj.js} +3 -3
- package/dist/component/{gitGraphDiagram-PVQCEYII-DMKggb_e.js → gitGraphDiagram-PVQCEYII-BgHuuQ27.js} +4 -4
- package/dist/component/{highlighted-body-OFNGDK62-Bnl71RgK.js → highlighted-body-OFNGDK62-BTv_Fxf3.js} +2 -2
- package/dist/component/index.js +2 -2
- package/dist/component/{infoDiagram-5YYISTIA-BaUo1fFU.js → infoDiagram-5YYISTIA-DE9i_OcK.js} +2 -2
- package/dist/component/{ishikawaDiagram-YF4QCWOH-DofOP6uV.js → ishikawaDiagram-YF4QCWOH-BDe88Hz2.js} +2 -2
- package/dist/component/{journeyDiagram-JHISSGLW-D-xl9LqQ.js → journeyDiagram-JHISSGLW-D3t45UC1.js} +5 -5
- package/dist/component/{kanban-definition-UN3LZRKU-Lfcidbpn.js → kanban-definition-UN3LZRKU-DfFJIuhU.js} +3 -3
- package/dist/component/{linear-CtCl_nrs.js → linear-AXxuun7R.js} +2 -2
- package/dist/component/{mermaid-GHXKKRXX-CnzRBGo3.js → mermaid-GHXKKRXX-D7NVqIBP.js} +31181 -29271
- package/dist/component/{mindmap-definition-RKZ34NQL-RZVaz4dV.js → mindmap-definition-RKZ34NQL-cTac4kYU.js} +4 -4
- package/dist/component/{pieDiagram-4H26LBE5-CEwcfNwI.js → pieDiagram-4H26LBE5-B1SubLQb.js} +4 -4
- package/dist/component/{quadrantDiagram-W4KKPZXB-BJBEiTgK.js → quadrantDiagram-W4KKPZXB-CzyBW8Cr.js} +3 -3
- package/dist/component/{requirementDiagram-4Y6WPE33-CVHog8O-.js → requirementDiagram-4Y6WPE33-DgS33NcX.js} +4 -4
- package/dist/component/{sankeyDiagram-5OEKKPKP-Cn1N0qrl.js → sankeyDiagram-5OEKKPKP-Cp4o_akq.js} +2 -2
- package/dist/component/{sequenceDiagram-3UESZ5HK-CRaBqdL0.js → sequenceDiagram-3UESZ5HK-2gf91-2b.js} +4 -4
- package/dist/component/{stateDiagram-AJRCARHV-9q4hv0ii.js → stateDiagram-AJRCARHV-BByZezJw.js} +3 -3
- package/dist/component/{stateDiagram-v2-BHNVJYJU-By7O-5eN.js → stateDiagram-v2-BHNVJYJU-B-IObShO.js} +3 -3
- package/dist/component/{timeline-definition-PNZ67QCA-BWfxZI7f.js → timeline-definition-PNZ67QCA-D_2NG1sj.js} +3 -3
- package/dist/component/{vennDiagram-CIIHVFJN-B_PQ6bU6.js → vennDiagram-CIIHVFJN-BjrQUaEs.js} +2 -2
- package/dist/component/{wardleyDiagram-YWT4CUSO-P7tCzeA0.js → wardleyDiagram-YWT4CUSO-DYcvfAeQ.js} +3 -3
- package/dist/component/{xychartDiagram-2RQKCTM6-B4Z_Zrko.js → xychartDiagram-2RQKCTM6-CtLaJFtQ.js} +3 -3
- package/dist/components/embed/AgentChatIcon.d.ts +16 -0
- package/dist/components/embed/AgentPhaseIcon.d.ts +17 -0
- package/dist/components/embed/EmbedAvatar.d.ts +21 -2
- package/dist/components/embed/EmbedHeader.d.ts +25 -2
- package/dist/components/embed/EmbedRail.d.ts +20 -1
- package/dist/components/embed/EmbedSessions.d.ts +33 -8
- package/dist/components/embed/MobileNavBar.d.ts +4 -1
- package/dist/components/embed/SessionStatsPanel.d.ts +12 -0
- package/dist/components/embed/rail-flags.d.ts +23 -0
- package/dist/embed/adoption-notice.d.ts +32 -0
- package/dist/embed/auth0-cache.d.ts +32 -0
- package/dist/embed/auth0-refresh.d.ts +8 -5
- package/dist/embed/copy.d.ts +2 -0
- package/dist/embed/dock-state.d.ts +16 -0
- package/dist/embed/global.d.ts +6 -0
- package/dist/embed/host-layout-vars.d.ts +24 -0
- package/dist/embed/host-push-controller.d.ts +67 -0
- package/dist/embed/host-surface.d.ts +57 -0
- package/dist/embed/presets.d.ts +10 -0
- package/dist/embed/theme.d.ts +13 -0
- package/dist/embed/voice/agent-spawn.d.ts +38 -0
- package/dist/embed/voice/audio-utils.d.ts +6 -0
- package/dist/embed/voice/call-active-marker.d.ts +67 -0
- package/dist/embed/voice/line-dispatch.d.ts +34 -4
- package/dist/embed/voice/line-run-reader.d.ts +29 -1
- package/dist/embed/voice/line-slots.d.ts +99 -0
- package/dist/embed/voice/reconnect-offer.d.ts +29 -0
- package/dist/embed/voice/session-create.d.ts +26 -0
- package/dist/embed/voice/voice-http.d.ts +12 -0
- package/dist/embed/voice-bus.d.ts +2 -0
- package/dist/embed/voice-call-lines.d.ts +241 -14
- package/dist/embed/voice-call.d.ts +34 -6
- package/dist/i18n/messages/en.d.ts +33 -0
- package/dist/i18n/messages/surfaces/header.d.ts +18 -0
- package/dist/i18n/messages/surfaces/sessions.d.ts +6 -0
- package/dist/i18n/messages/surfaces/stats.d.ts +55 -0
- package/dist/i18n/messages/surfaces/stream.d.ts +3 -0
- package/dist/stream/belong-chat-transport.d.ts +45 -8
- package/dist/stream/belong-data-parts.d.ts +8 -0
- package/dist/stream/chat-export-store.d.ts +35 -0
- package/dist/stream/route-dispatch.d.ts +17 -0
- package/dist/stream/session-stats-csv.d.ts +52 -0
- package/dist/stream/stream-state-store.d.ts +36 -6
- package/dist/types/public.d.ts +3 -1
- package/package.json +1 -1
|
@@ -198,36 +198,36 @@ export declare const wireStreamPartSchema: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
198
198
|
}, "strip", z.ZodTypeAny, {
|
|
199
199
|
toolName: string;
|
|
200
200
|
state: "completed" | "failed" | "started";
|
|
201
|
-
input?: Record<string, unknown> | undefined;
|
|
202
|
-
output?: Record<string, unknown> | null | undefined;
|
|
203
201
|
error?: {
|
|
204
202
|
message: string;
|
|
205
203
|
code: string;
|
|
206
204
|
severity?: "error" | "stop" | undefined;
|
|
207
205
|
} | undefined;
|
|
206
|
+
input?: Record<string, unknown> | undefined;
|
|
207
|
+
output?: Record<string, unknown> | null | undefined;
|
|
208
208
|
}, {
|
|
209
209
|
toolName: string;
|
|
210
210
|
state: "completed" | "failed" | "started";
|
|
211
|
-
input?: Record<string, unknown> | undefined;
|
|
212
|
-
output?: Record<string, unknown> | null | undefined;
|
|
213
211
|
error?: {
|
|
214
212
|
message: string;
|
|
215
213
|
code: string;
|
|
216
214
|
severity?: "error" | "stop" | undefined;
|
|
217
215
|
} | undefined;
|
|
216
|
+
input?: Record<string, unknown> | undefined;
|
|
217
|
+
output?: Record<string, unknown> | null | undefined;
|
|
218
218
|
}>;
|
|
219
219
|
}, "strip", z.ZodTypeAny, {
|
|
220
220
|
id: string;
|
|
221
221
|
data: {
|
|
222
222
|
toolName: string;
|
|
223
223
|
state: "completed" | "failed" | "started";
|
|
224
|
-
input?: Record<string, unknown> | undefined;
|
|
225
|
-
output?: Record<string, unknown> | null | undefined;
|
|
226
224
|
error?: {
|
|
227
225
|
message: string;
|
|
228
226
|
code: string;
|
|
229
227
|
severity?: "error" | "stop" | undefined;
|
|
230
228
|
} | undefined;
|
|
229
|
+
input?: Record<string, unknown> | undefined;
|
|
230
|
+
output?: Record<string, unknown> | null | undefined;
|
|
231
231
|
};
|
|
232
232
|
type: "data-tool-call";
|
|
233
233
|
}, {
|
|
@@ -235,13 +235,13 @@ export declare const wireStreamPartSchema: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
235
235
|
data: {
|
|
236
236
|
toolName: string;
|
|
237
237
|
state: "completed" | "failed" | "started";
|
|
238
|
-
input?: Record<string, unknown> | undefined;
|
|
239
|
-
output?: Record<string, unknown> | null | undefined;
|
|
240
238
|
error?: {
|
|
241
239
|
message: string;
|
|
242
240
|
code: string;
|
|
243
241
|
severity?: "error" | "stop" | undefined;
|
|
244
242
|
} | undefined;
|
|
243
|
+
input?: Record<string, unknown> | undefined;
|
|
244
|
+
output?: Record<string, unknown> | null | undefined;
|
|
245
245
|
};
|
|
246
246
|
type: "data-tool-call";
|
|
247
247
|
}>, z.ZodObject<{
|
|
@@ -410,18 +410,22 @@ export declare const wireStreamPartSchema: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
410
410
|
data: z.ZodObject<{
|
|
411
411
|
status: z.ZodEnum<["continuing", "completed", "cancelled", "failed", "throttled"]>;
|
|
412
412
|
message: z.ZodOptional<z.ZodString>;
|
|
413
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
413
414
|
}, "strip", z.ZodTypeAny, {
|
|
414
415
|
status: "completed" | "failed" | "cancelled" | "continuing" | "throttled";
|
|
415
416
|
message?: string | undefined;
|
|
417
|
+
retryable?: boolean | undefined;
|
|
416
418
|
}, {
|
|
417
419
|
status: "completed" | "failed" | "cancelled" | "continuing" | "throttled";
|
|
418
420
|
message?: string | undefined;
|
|
421
|
+
retryable?: boolean | undefined;
|
|
419
422
|
}>;
|
|
420
423
|
}, "strip", z.ZodTypeAny, {
|
|
421
424
|
id: string;
|
|
422
425
|
data: {
|
|
423
426
|
status: "completed" | "failed" | "cancelled" | "continuing" | "throttled";
|
|
424
427
|
message?: string | undefined;
|
|
428
|
+
retryable?: boolean | undefined;
|
|
425
429
|
};
|
|
426
430
|
type: "data-status";
|
|
427
431
|
}, {
|
|
@@ -429,6 +433,7 @@ export declare const wireStreamPartSchema: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
429
433
|
data: {
|
|
430
434
|
status: "completed" | "failed" | "cancelled" | "continuing" | "throttled";
|
|
431
435
|
message?: string | undefined;
|
|
436
|
+
retryable?: boolean | undefined;
|
|
432
437
|
};
|
|
433
438
|
type: "data-status";
|
|
434
439
|
}>, z.ZodObject<{
|
|
@@ -667,6 +672,25 @@ export declare const RECONNECT_MAX_CONSECUTIVE_FAILURES = 10;
|
|
|
667
672
|
* instead — the same discipline browser/control-channel.ts already applies.
|
|
668
673
|
*/
|
|
669
674
|
export declare const STALL_TIMEOUT_MS = 30000;
|
|
675
|
+
/**
|
|
676
|
+
* How long a retryable terminal (`data-status {status:"failed",
|
|
677
|
+
* retryable:true}` — a turn-deadline abort whose task WILL be reactivated on
|
|
678
|
+
* the same run/stream) may sit with no subsequent delivered event before the
|
|
679
|
+
* transport stops waiting and promotes it to a real failure. Reactivation is
|
|
680
|
+
* normally near-instant (the post-drain outbox recheck fires as the aborted
|
|
681
|
+
* drain settles) but the resumed turn can take a while to emit its first
|
|
682
|
+
* event (sandbox boot, transcript hydrate); the fleet-wide outbox sweep is
|
|
683
|
+
* the slowest legitimate path (≤60s period + ~30s first event). Without this
|
|
684
|
+
* bound a run that never resumes would hold the connection open forever —
|
|
685
|
+
* the server's 15s keepalives feed the stall watchdog, so no drop ever
|
|
686
|
+
* occurs and the composer stays wedged. Kept ≤ the persisted-cursor
|
|
687
|
+
* freshness window (stream-state-store RESUME_MAX_AGE_MS, 120s) so a reload
|
|
688
|
+
* anywhere inside an armed grace can still resume the run cursor.
|
|
689
|
+
*/
|
|
690
|
+
export declare const RESUME_GRACE_MS = 120000;
|
|
691
|
+
/** Test-only: forget every claimed live-stream entry (module state persists
|
|
692
|
+
* across tests in the same file otherwise). */
|
|
693
|
+
export declare const __resetLiveStreamRegistryForTest: () => void;
|
|
670
694
|
export type BelongChatTransportOptions = {
|
|
671
695
|
/** Belong cloud base URL, e.g. `http://localhost:8787`. */
|
|
672
696
|
readonly apiBaseUrl: string;
|
|
@@ -680,6 +704,11 @@ export type BelongChatTransportOptions = {
|
|
|
680
704
|
* production uses `STALL_TIMEOUT_MS`.
|
|
681
705
|
*/
|
|
682
706
|
readonly stallTimeoutMs?: number;
|
|
707
|
+
/**
|
|
708
|
+
* Retryable-terminal grace override (§25). Tests shrink it to tens of ms;
|
|
709
|
+
* production uses `RESUME_GRACE_MS`.
|
|
710
|
+
*/
|
|
711
|
+
readonly resumeGraceMs?: number;
|
|
683
712
|
/**
|
|
684
713
|
* Workspace isolation: the host workspace this transport's session belongs
|
|
685
714
|
* to. Defaults to the CURRENT scope at construction — captured once, so a
|
|
@@ -688,6 +717,14 @@ export type BelongChatTransportOptions = {
|
|
|
688
717
|
* Tests may pin it explicitly.
|
|
689
718
|
*/
|
|
690
719
|
readonly workspaceExternalId?: string | null;
|
|
720
|
+
/**
|
|
721
|
+
* Foreground-mount generation (R2 — order-aware selection). Defaults to the
|
|
722
|
+
* CURRENT generation at construction — captured once, so a transport whose
|
|
723
|
+
* `select_if_empty` persist resolves AFTER a newer ChatRoute remount (a
|
|
724
|
+
* fresher chat already superseded it) never steals the selection pointer
|
|
725
|
+
* from that newer transport. Tests may pin it explicitly.
|
|
726
|
+
*/
|
|
727
|
+
readonly foregroundGeneration?: number;
|
|
691
728
|
};
|
|
692
729
|
export type StreamContext = {
|
|
693
730
|
/** Stable id we emit on every `text-delta`. Null when no text run is open. */
|
|
@@ -147,6 +147,14 @@ export type ArtifactData = {
|
|
|
147
147
|
export type StatusData = {
|
|
148
148
|
readonly status: RunStatusKind;
|
|
149
149
|
readonly message?: string | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Resume promise on a "failed" status: the backend verified the session
|
|
152
|
+
* still has pending work, so outbox recovery will reactivate the task and
|
|
153
|
+
* keep streaming into the SAME run/stream. The transport keeps its cursor
|
|
154
|
+
* open on it (no finalize) and the renderer shows a quiet "picking it back
|
|
155
|
+
* up" pill instead of a scary failure badge.
|
|
156
|
+
*/
|
|
157
|
+
readonly retryable?: boolean | undefined;
|
|
150
158
|
};
|
|
151
159
|
/**
|
|
152
160
|
* F3 — per-turn token usage + compaction context. Emitted once per turn at
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat-export state — module-level, so a pending export SURVIVES switching
|
|
3
|
+
* chats/views: the dock header (BelongDock) reads per-session state via
|
|
4
|
+
* `useSyncExternalStore`, while the poller lives here, independent of any
|
|
5
|
+
* mounted route. When the backend job turns `ready`, the file downloads
|
|
6
|
+
* AUTOMATICALLY — even if the user is viewing another chat at that moment —
|
|
7
|
+
* and the session's button reverts.
|
|
8
|
+
*
|
|
9
|
+
* Flow (see belong-cloud session-export.routes.ts):
|
|
10
|
+
* startChatExport → POST /v1/sessions/:id/exports → 202 { exportId }
|
|
11
|
+
* poller (~2s) → GET …/exports/:exportId → queued|running|ready|failed
|
|
12
|
+
* ready → GET …/exports/:exportId/file → browser download
|
|
13
|
+
*
|
|
14
|
+
* Persistence (best-effort `localStorage`, Zod-parsed on read §4):
|
|
15
|
+
* • pending exports — a page reload resumes polling and still auto-downloads
|
|
16
|
+
* • per-session "last export" timestamps — the hover affordance. UI-ONLY by
|
|
17
|
+
* design: the backend intentionally does not persist this.
|
|
18
|
+
*/
|
|
19
|
+
export type ChatExportSessionState = {
|
|
20
|
+
readonly status: "idle" | "generating";
|
|
21
|
+
/** Epoch ms of this session's last successful export download (UI-only). */
|
|
22
|
+
readonly lastExportAtMs: number | null;
|
|
23
|
+
};
|
|
24
|
+
export type StartChatExportResult = "started" | "already_generating" | "failed";
|
|
25
|
+
/**
|
|
26
|
+
* Request a fresh export for the session and start (or join) the poller.
|
|
27
|
+
* Idempotent per session while one is in flight — the header button is also
|
|
28
|
+
* disabled while generating, but the store is the authority (§28).
|
|
29
|
+
*/
|
|
30
|
+
export declare const startChatExport: (apiBaseUrl: string, sessionId: string) => Promise<StartChatExportResult>;
|
|
31
|
+
/** Per-session snapshot for the header button (identity-stable across reads). */
|
|
32
|
+
export declare const peekChatExportState: (sessionId: string) => ChatExportSessionState;
|
|
33
|
+
export declare const subscribeChatExport: (listener: () => void) => (() => void);
|
|
34
|
+
/** Test-only: drop all state, listeners, storage, and the poll timer. */
|
|
35
|
+
export declare const resetChatExportStoreForTests: () => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE seam that turns a `data-navigation` part into a host route-handler
|
|
3
|
+
* call — shared by the foreground renderer (`ai-sdk-part-renderers.tsx`'s
|
|
4
|
+
* `NavigationRenderer`) and a BACKGROUND line's run reader
|
|
5
|
+
* (`voice/line-run-reader.ts`), so a navigation the model dispatches on a
|
|
6
|
+
* background agent actually reaches the host instead of being silently
|
|
7
|
+
* dropped (a background line has no renderer to pick it up).
|
|
8
|
+
*
|
|
9
|
+
* Every failure mode (no handler registered, the handler throwing, the
|
|
10
|
+
* handler resolving `{ ok: false }`) collapses to one of three outcomes —
|
|
11
|
+
* never a throw — so both call sites can treat this as a plain result.
|
|
12
|
+
*/
|
|
13
|
+
export type RouteDispatchOutcome = "ok" | "failed" | "no_handler";
|
|
14
|
+
export declare const dispatchRouteNavigation: (data: {
|
|
15
|
+
readonly routeName: string;
|
|
16
|
+
readonly params: Readonly<Record<string, string>>;
|
|
17
|
+
}) => Promise<RouteDispatchOutcome>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-stats CSV builders (plan 2026-07-24). Pure string builders (no DOM)
|
|
3
|
+
* so they are unit-tested; `downloadCsv` is the only impure part.
|
|
4
|
+
*
|
|
5
|
+
* Types mirror the belong-cloud `SessionStatsDetail` / `SessionStatsSummaryRow`
|
|
6
|
+
* DTOs. Kept as an explicit local mirror (not inferred from AppType) so the CSV
|
|
7
|
+
* column contract is readable in one place.
|
|
8
|
+
*
|
|
9
|
+
* RFC-4180: CRLF line breaks, header first, a field is quoted when it contains
|
|
10
|
+
* `"`, `,`, CR or LF; interior quotes are doubled. CSV-injection guard: a text
|
|
11
|
+
* field starting with = + - @ is prefixed with a single quote before quoting.
|
|
12
|
+
*/
|
|
13
|
+
export type SessionStatsTurn = {
|
|
14
|
+
readonly turn: number;
|
|
15
|
+
readonly at: string;
|
|
16
|
+
readonly inputTokens: number;
|
|
17
|
+
readonly outputTokens: number;
|
|
18
|
+
readonly totalTokens: number;
|
|
19
|
+
};
|
|
20
|
+
export type SessionStatsDetail = {
|
|
21
|
+
readonly totalInputTokens: number;
|
|
22
|
+
readonly totalOutputTokens: number;
|
|
23
|
+
readonly totalTokens: number;
|
|
24
|
+
readonly turns: number;
|
|
25
|
+
readonly runningMs: number;
|
|
26
|
+
readonly toolCalls: number;
|
|
27
|
+
readonly runtimes: readonly string[];
|
|
28
|
+
readonly turnRows: readonly SessionStatsTurn[];
|
|
29
|
+
};
|
|
30
|
+
export type SessionStatsSummaryRow = {
|
|
31
|
+
readonly sessionId: string;
|
|
32
|
+
readonly title: string | null;
|
|
33
|
+
readonly createdAt: string;
|
|
34
|
+
readonly updatedAt: string;
|
|
35
|
+
readonly totalInputTokens: number;
|
|
36
|
+
readonly totalOutputTokens: number;
|
|
37
|
+
readonly totalTokens: number;
|
|
38
|
+
readonly turns: number;
|
|
39
|
+
readonly runningMs: number;
|
|
40
|
+
readonly toolCalls: number;
|
|
41
|
+
readonly runtimes: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
/** Human duration: `m:ss` under an hour, `h:mm:ss` at/over an hour. */
|
|
44
|
+
export declare const formatDurationMs: (ms: number) => string;
|
|
45
|
+
export declare const toPerTurnCsv: (detail: SessionStatsDetail) => string;
|
|
46
|
+
export declare const toSummaryCsv: (rows: readonly SessionStatsSummaryRow[]) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Trigger a browser download of `csv` as `filename`. Appends a transient anchor
|
|
49
|
+
* to document.body (NOT the shadow root) so the click reaches the top document —
|
|
50
|
+
* required for the download to fire from inside the dock's closed Shadow DOM.
|
|
51
|
+
*/
|
|
52
|
+
export declare const downloadCsv: (filename: string, csv: string) => void;
|
|
@@ -30,6 +30,23 @@ declare const streamStateSchema: z.ZodObject<{
|
|
|
30
30
|
lastEventId: string | null;
|
|
31
31
|
}>;
|
|
32
32
|
export type PersistedStreamState = z.infer<typeof streamStateSchema>;
|
|
33
|
+
/** Bump the foreground-mount generation. Call exactly once per ChatRoute
|
|
34
|
+
* remount (BelongDock's `chatMount.key` writers), synchronously alongside
|
|
35
|
+
* the pointer change that triggers the remount. */
|
|
36
|
+
export declare const nextForegroundGeneration: () => number;
|
|
37
|
+
/** Read the current foreground-mount generation without bumping it. A
|
|
38
|
+
* transport captures this at construction to stamp its later persists. */
|
|
39
|
+
export declare const peekForegroundGeneration: () => number;
|
|
40
|
+
/** Peek the most recent generation-loss orphan (see above), or null. A single
|
|
41
|
+
* most-recent slot, not a queue: this is a belt-and-braces safety net for the
|
|
42
|
+
* self-referential bind, not the primary recovery mechanism, and the race it
|
|
43
|
+
* guards against produces at most one loser per window in practice. */
|
|
44
|
+
export declare const peekGenerationLostSession: () => string | null;
|
|
45
|
+
/** Consume the orphan once a reconciler has adopted it onto a line. A no-op
|
|
46
|
+
* when `sessionId` does not match the currently-tracked loser (already
|
|
47
|
+
* consumed, or superseded by a newer loss) — a stale reconciler can never
|
|
48
|
+
* clear a loss it did not actually adopt. */
|
|
49
|
+
export declare const consumeGenerationLostSession: (sessionId: string) => void;
|
|
33
50
|
/**
|
|
34
51
|
* The tab's active stream state.
|
|
35
52
|
*
|
|
@@ -45,7 +62,20 @@ export type PersistedStreamState = z.infer<typeof streamStateSchema>;
|
|
|
45
62
|
* is demoted off the live run cursor.
|
|
46
63
|
*/
|
|
47
64
|
export declare const readStreamState: (workspaceId?: string | null) => PersistedStreamState | null;
|
|
48
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Forget a DELETED session from the shared seed — narrowly, only when the
|
|
67
|
+
* seed still names it. `clearStreamState` (New chat) deliberately leaves the
|
|
68
|
+
* shared seed alone so an unrelated tab's most-recent conversation survives;
|
|
69
|
+
* that assumption breaks when the session in the seed was just deleted, since
|
|
70
|
+
* any brand-new tab (e.g. a spawned browser-automation preview tab — see
|
|
71
|
+
* `readStreamState`'s adoption path) would otherwise adopt a session that
|
|
72
|
+
* 404s/409s on every request. Session delete is the only caller: an ordinary
|
|
73
|
+
* "New chat" must not reach this, which is why it is a separate function
|
|
74
|
+
* rather than a flag on `clearStreamState`.
|
|
75
|
+
*/
|
|
76
|
+
export declare const forgetDeletedSessionSeed: (sessionId: string, workspaceId?: string | null) => void;
|
|
77
|
+
export type StreamStateWriteMode = "select" | "select_if_empty" | "preserve_selection";
|
|
78
|
+
export declare const writeStreamState: (state: Omit<PersistedStreamState, "updatedAt">, workspaceId?: string | null, mode?: StreamStateWriteMode, generation?: number) => void;
|
|
49
79
|
/**
|
|
50
80
|
* Clear THIS TAB's pointer (New chat). Removes only the per-tab sessionStorage
|
|
51
81
|
* record and marks the tab "seeded" so a reload stays blank instead of
|
|
@@ -63,11 +93,11 @@ export declare const clearStreamState: (workspaceId?: string | null) => void;
|
|
|
63
93
|
*/
|
|
64
94
|
export declare const readResumableStreamState: (workspaceId?: string | null) => PersistedStreamState | null;
|
|
65
95
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
96
|
+
* Select one Session (sessions menu switch / new). A Session with a live cursor
|
|
97
|
+
* parked by this tab restores that cursor so the next ChatRoute mount resumes
|
|
98
|
+
* its working run. Historical/terminal Sessions restore from history with no
|
|
99
|
+
* run cursor. Passing null clears only the selected pointer; parked live runs
|
|
100
|
+
* remain available when the user comes back to them.
|
|
71
101
|
*/
|
|
72
102
|
export declare const setActiveSessionId: (sessionId: string | null) => void;
|
|
73
103
|
/**
|
package/dist/types/public.d.ts
CHANGED
|
@@ -259,8 +259,10 @@ export type BelongGlobal = {
|
|
|
259
259
|
readonly __forceAgentLines?: (lines: readonly {
|
|
260
260
|
line: number;
|
|
261
261
|
label: string;
|
|
262
|
-
status: "working" | "ready" | "failed" | "needs_approval";
|
|
262
|
+
status: "idle" | "working" | "ready" | "failed" | "needs_approval";
|
|
263
263
|
sessionId?: string;
|
|
264
|
+
currentStepLabel?: string;
|
|
265
|
+
currentPhase?: "coding" | "files" | "actions";
|
|
264
266
|
}[]) => void;
|
|
265
267
|
};
|
|
266
268
|
declare global {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@belonguniverseai/react-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "0.4.1",
|
|
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",
|