@belonguniverseai/react-sdk 0.6.0 → 0.6.2

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 (79) hide show
  1. package/dist/api/client.d.ts +58 -32
  2. package/dist/api/task-schedules.d.ts +138 -255
  3. package/dist/component/{arc-DpA4gw3l.js → arc-TLcl3N8_.js} +2 -2
  4. package/dist/component/{architectureDiagram-3BPJPVTR-C8WjH-Q1.js → architectureDiagram-3BPJPVTR-DYcaPx2M.js} +3 -3
  5. package/dist/component/{blockDiagram-GPEHLZMM-O9IURu7q.js → blockDiagram-GPEHLZMM-BdjruLO5.js} +4 -4
  6. package/dist/component/{c4Diagram-AAUBKEIU-B4cFy6te.js → c4Diagram-AAUBKEIU-Bd2ebSgB.js} +3 -3
  7. package/dist/component/{channel-7qPdE580.js → channel-CYFijF_t.js} +2 -2
  8. package/dist/component/{chunk-2J33WTMH-CUyqMMUN.js → chunk-2J33WTMH-B06Y_xVy.js} +2 -2
  9. package/dist/component/{chunk-4BX2VUAB-4MjzMD47.js → chunk-4BX2VUAB-DVpS0I_p.js} +2 -2
  10. package/dist/component/{chunk-55IACEB6-BOiOLlJY.js → chunk-55IACEB6-DmZctFkK.js} +2 -2
  11. package/dist/component/{chunk-727SXJPM-D7rQvYjL.js → chunk-727SXJPM-A5r5oL1_.js} +6 -6
  12. package/dist/component/{chunk-AQP2D5EJ-B4yIZLgM.js → chunk-AQP2D5EJ-D4G4syYu.js} +4 -4
  13. package/dist/component/{chunk-FMBD7UC4-CHC657o0.js → chunk-FMBD7UC4-CbRxWx_A.js} +2 -2
  14. package/dist/component/{chunk-ND2GUHAM-BAq6BoPv.js → chunk-ND2GUHAM-OX1-DIU1.js} +2 -2
  15. package/dist/component/{chunk-QZHKN3VN-DSE2KpkL.js → chunk-QZHKN3VN-DLQ8oUCc.js} +2 -2
  16. package/dist/component/{classDiagram-4FO5ZUOK-Dp6GpqVA.js → classDiagram-4FO5ZUOK-4S9mdFC1.js} +3 -3
  17. package/dist/component/{classDiagram-v2-Q7XG4LA2-Dp6GpqVA.js → classDiagram-v2-Q7XG4LA2-4S9mdFC1.js} +3 -3
  18. package/dist/component/{cose-bilkent-S5V4N54A-D7qy0jl5.js → cose-bilkent-S5V4N54A-BIrVaakt.js} +2 -2
  19. package/dist/component/{dagre-BM42HDAG-Bp1xKCuc.js → dagre-BM42HDAG-BoPUzTvD.js} +2 -2
  20. package/dist/component/{diagram-2AECGRRQ-BgnTJHhy.js → diagram-2AECGRRQ-PIXCGxIt.js} +3 -3
  21. package/dist/component/{diagram-5GNKFQAL-D2Sf6fvv.js → diagram-5GNKFQAL-CbJxbGBh.js} +4 -4
  22. package/dist/component/{diagram-KO2AKTUF-B6q2Givz.js → diagram-KO2AKTUF-Da1E68Eo.js} +3 -3
  23. package/dist/component/{diagram-LMA3HP47-Dd-PZ9QO.js → diagram-LMA3HP47-dRbk5sBa.js} +3 -3
  24. package/dist/component/{diagram-OG6HWLK6-v65-inn8.js → diagram-OG6HWLK6-CcKT8mhn.js} +4 -4
  25. package/dist/component/{erDiagram-TEJ5UH35-s5ngcfah.js → erDiagram-TEJ5UH35-3ATYT9J-.js} +5 -5
  26. package/dist/component/{flowDiagram-I6XJVG4X-C-3l7ZN2.js → flowDiagram-I6XJVG4X-D9PLm9Od.js} +7 -7
  27. package/dist/component/{ganttDiagram-6RSMTGT7-AFajly3C.js → ganttDiagram-6RSMTGT7-F_XUzD1p.js} +3 -3
  28. package/dist/component/{gitGraphDiagram-PVQCEYII-DLcn7CA-.js → gitGraphDiagram-PVQCEYII-13gVhAGc.js} +4 -4
  29. package/dist/component/{highlighted-body-OFNGDK62-C7pDeGQU.js → highlighted-body-OFNGDK62-DCxRI4UV.js} +2 -2
  30. package/dist/component/index.js +2 -2
  31. package/dist/component/{infoDiagram-5YYISTIA-BuR4-KVY.js → infoDiagram-5YYISTIA-DymxA7AN.js} +2 -2
  32. package/dist/component/{ishikawaDiagram-YF4QCWOH-DlsfzgFK.js → ishikawaDiagram-YF4QCWOH-C3sTn76C.js} +2 -2
  33. package/dist/component/{journeyDiagram-JHISSGLW-D0rpdvR5.js → journeyDiagram-JHISSGLW-Cq0hOAfJ.js} +5 -5
  34. package/dist/component/{kanban-definition-UN3LZRKU-Cz0Dixqc.js → kanban-definition-UN3LZRKU-5tBWjkp7.js} +3 -3
  35. package/dist/component/{linear-BVVr39mA.js → linear-BT4blD8s.js} +2 -2
  36. package/dist/component/{mermaid-GHXKKRXX-BEhqkLaB.js → mermaid-GHXKKRXX-DXPXjnb7.js} +38570 -40748
  37. package/dist/component/{mindmap-definition-RKZ34NQL-wo3l0Jy7.js → mindmap-definition-RKZ34NQL-DO-OuAQQ.js} +4 -4
  38. package/dist/component/{pieDiagram-4H26LBE5-TtxT_WMN.js → pieDiagram-4H26LBE5-BkEktPwZ.js} +4 -4
  39. package/dist/component/{quadrantDiagram-W4KKPZXB-DK6ShvdY.js → quadrantDiagram-W4KKPZXB-CaJWg9ep.js} +3 -3
  40. package/dist/component/{requirementDiagram-4Y6WPE33-Z0IavHMQ.js → requirementDiagram-4Y6WPE33-CmZrtZqe.js} +4 -4
  41. package/dist/component/{sankeyDiagram-5OEKKPKP-C408nFHk.js → sankeyDiagram-5OEKKPKP-Cp95M1aj.js} +2 -2
  42. package/dist/component/{sequenceDiagram-3UESZ5HK-CMFVhmkn.js → sequenceDiagram-3UESZ5HK-C0x0WvhR.js} +4 -4
  43. package/dist/component/{stateDiagram-AJRCARHV-C6Z5V-Yt.js → stateDiagram-AJRCARHV-H10vaGL3.js} +3 -3
  44. package/dist/component/{stateDiagram-v2-BHNVJYJU-CztCn1yf.js → stateDiagram-v2-BHNVJYJU-rj7ljkc-.js} +3 -3
  45. package/dist/component/{timeline-definition-PNZ67QCA-D_9a8hKa.js → timeline-definition-PNZ67QCA-Cil1QaqZ.js} +3 -3
  46. package/dist/component/{vennDiagram-CIIHVFJN-HuWQgr4e.js → vennDiagram-CIIHVFJN-Dk8PKmfb.js} +2 -2
  47. package/dist/component/{wardleyDiagram-YWT4CUSO-CeUvdi76.js → wardleyDiagram-YWT4CUSO-Xq5Hnmio.js} +3 -3
  48. package/dist/component/{xychartDiagram-2RQKCTM6-DNmBGn_r.js → xychartDiagram-2RQKCTM6-dinwR4Zm.js} +3 -3
  49. package/dist/components/embed/BetaBadge.d.ts +12 -0
  50. package/dist/components/embed/DisclaimerGate.d.ts +16 -0
  51. package/dist/components/embed/EmbedHeader.d.ts +11 -4
  52. package/dist/components/embed/LegalShortDisclaimer.d.ts +11 -0
  53. package/dist/components/embed/LocalePills.d.ts +18 -0
  54. package/dist/components/embed/WelcomeIntro.d.ts +3 -1
  55. package/dist/components/embed/rail-flags.d.ts +10 -0
  56. package/dist/embed/brand-marks.d.ts +5 -5
  57. package/dist/embed/copy.d.ts +13 -0
  58. package/dist/embed/legal-disclaimer.d.ts +23 -0
  59. package/dist/embed/presets.d.ts +5 -1
  60. package/dist/embed/task-schedule-store.d.ts +3 -13
  61. package/dist/embed/voice/call-active-marker.d.ts +67 -30
  62. package/dist/embed/voice/line-dispatch.d.ts +22 -20
  63. package/dist/embed/voice/realtime-call.d.ts +12 -0
  64. package/dist/embed/voice/reconnect-offer.d.ts +14 -5
  65. package/dist/embed/voice/voice-token.d.ts +2 -12
  66. package/dist/embed/voice-call-lines.d.ts +4 -25
  67. package/dist/embed/voice-call.d.ts +112 -73
  68. package/dist/i18n/messages/en.d.ts +12 -6
  69. package/dist/i18n/messages/surfaces/embedMisc.d.ts +0 -3
  70. package/dist/i18n/messages/surfaces/stream.d.ts +28 -0
  71. package/dist/stream/belong-chat-transport.d.ts +101 -587
  72. package/dist/stream/message-metadata.d.ts +6 -36
  73. package/dist/stream/run-line-progress.d.ts +6 -5
  74. package/dist/stream/stream-state-store.d.ts +1 -25
  75. package/dist/stream/tool-action-label.d.ts +16 -0
  76. package/package.json +1 -1
  77. package/dist/components/embed/PoweredByBelong.d.ts +0 -7
  78. package/dist/embed/voice/agent-queue.d.ts +0 -106
  79. package/dist/embed/voice/call-roster-store.d.ts +0 -110
@@ -1,45 +1,15 @@
1
1
  import { z } from 'zod';
2
2
  export declare const belongMessageMetadataSchema: z.ZodObject<{
3
- /** Producing task of an assistant turn — the reload-stable feedback key. */
4
3
  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
4
  feedback: z.ZodOptional<z.ZodNullable<z.ZodObject<{
9
- sentiment: z.ZodEnum<["up", "down"]>;
5
+ sentiment: z.ZodEnum<{
6
+ up: "up";
7
+ down: "down";
8
+ }>;
10
9
  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). */
10
+ }, z.core.$strip>>>;
19
11
  createdAt: z.ZodOptional<z.ZodString>;
20
- /** Skill picked for this user message — renders the bubble's skill chip. */
21
12
  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
13
  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
- }>;
14
+ }, z.core.$strip>;
45
15
  export type BelongMessageMetadata = z.infer<typeof belongMessageMetadataSchema>;
@@ -6,11 +6,12 @@ import { RunStatusKind } from './belong-data-parts.ts';
6
6
  * turn that only writes text calls no tools, so `tool_started` never fires and
7
7
  * the chip would otherwise sit at "idle" through the whole answer.
8
8
  *
9
- * There is deliberately NO `text` variant. An accumulator feeding
10
- * `AgentLine.lastText` was specified and dropped: nothing in the dock renders
11
- * `lastText`, and because this seam no-ops while the session is on screen the
12
- * accumulator could only ever have collected the post-switch TAIL of an
13
- * answer. Re-add it when something renders it.
9
+ * There is deliberately NO `text` variant. An accumulator feeding a per-line
10
+ * "last result text" field was specified and dropped: nothing in the dock
11
+ * renders such a field (the registry no longer even carries one), and because
12
+ * this seam no-ops while the session is on screen the accumulator could only
13
+ * ever have collected the post-switch TAIL of an answer. Re-add both when
14
+ * something renders it.
14
15
  *
15
16
  * `terminal` carries the run's OWN id, and it is not decoration: the durable
16
17
  * slot runId this seam clears is shared with the voice dispatch, and a line can
@@ -1,34 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  declare const streamStateSchema: z.ZodObject<{
3
3
  sessionId: z.ZodString;
4
- /**
5
- * Active run id, or null once the run reached a terminal state. The session
6
- * pointer outlives the run: it survives on terminal so a reload can still
7
- * restore this conversation's history — only the run cursor is dropped so we
8
- * never reconnect to a finished run.
9
- */
10
4
  runId: z.ZodNullable<z.ZodString>;
11
- /** `<seq>-0` SSE cursor, or null when no event has been seen yet. */
12
5
  lastEventId: z.ZodNullable<z.ZodString>;
13
- /**
14
- * Epoch ms of the last cursor write. Resume is only attempted for
15
- * recently-touched runs (see {@link readResumableStreamState}). State
16
- * written by an older SDK build has no `updatedAt`, fails this schema, and
17
- * is treated as absent — which is exactly the "start fresh" behavior we
18
- * want for stale leftovers from a previous visit.
19
- */
20
6
  updatedAt: z.ZodNumber;
21
- }, "strip", z.ZodTypeAny, {
22
- updatedAt: number;
23
- sessionId: string;
24
- runId: string | null;
25
- lastEventId: string | null;
26
- }, {
27
- updatedAt: number;
28
- sessionId: string;
29
- runId: string | null;
30
- lastEventId: string | null;
31
- }>;
7
+ }, z.core.$strip>;
32
8
  export type PersistedStreamState = z.infer<typeof streamStateSchema>;
33
9
  /** Bump the foreground-mount generation. Call exactly once per ChatRoute
34
10
  * remount (BelongDock's `chatMount.key` writers), synchronously alongside
@@ -0,0 +1,16 @@
1
+ import { TFunction } from 'i18next';
2
+ export type ToolActionLabel = {
3
+ readonly key: string;
4
+ };
5
+ /**
6
+ * The neutral line for a tool this build has never heard of. Exported because
7
+ * `browserStepMeta` branches on it: an unrecognized `browser_*` suffix keeps
8
+ * the chat's own sentence-cased fallback instead of this.
9
+ */
10
+ export declare const GENERIC_ACTION_KEY = "stream.actionGeneric";
11
+ /**
12
+ * `t(...)` over a `ToolActionLabel` — the ONE way either surface renders one,
13
+ * so the two can't drift into two different names for the same action.
14
+ */
15
+ export declare const translateAction: (t: TFunction, action: ToolActionLabel) => string;
16
+ export declare const toolActionLabel: (toolName: string) => ToolActionLabel | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@belonguniverseai/react-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
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",
@@ -1,7 +0,0 @@
1
- /** Fixed footer height (px) so the terminal overlay can reserve exact space. */
2
- export declare const POWERED_BY_BELONG_HEIGHT_PX = 28;
3
- /**
4
- * Persistent attribution strip pinned to the bottom of the dock panel when a
5
- * tenant brand is active. Always the Belong mark (not the tenant BrandMark).
6
- */
7
- export declare function PoweredByBelong(): import("react").JSX.Element;
@@ -1,106 +0,0 @@
1
- /**
2
- * Per-line FIFO for work an operator asks an agent to do WHILE that agent is
3
- * already busy — the structure behind "queue two things on Agent 2, then
4
- * drop one" (Slice 3 of the voice-operator plan). File-scope-singleton
5
- * idiom, same as `line-slots.ts` / `voice-call-lines.ts` beside it: one
6
- * module-level `Map<number, QueuedRequest[]>`, no class, no React.
7
- *
8
- * WHAT THIS REPLACES: today, sending work to a busy agent POSTs it
9
- * immediately — the message lands in Postgres and the server's own drain
10
- * loop (SAD §5.1 / CLAUDE.md §37) gets to it whenever the agent frees up.
11
- * That queue is invisible (no way to ask "what's waiting for Agent 2?"),
12
- * unorderable (no way to promote the third ask over the second), and
13
- * undroppable (no way to take one back). This module is the queue moved
14
- * into the browser, so a caller can read it back, drop an entry, or reorder
15
- * it before anything is sent. (Wiring `dispatchToLine`'s busy-line path
16
- * through this queue, and adding the voice-facing `manage_queue` tool, are
17
- * later tasks — see NOT WIRED IN YET below.)
18
- *
19
- * WHY CALL-SCOPED AND NOT DURABLE — the trade-off, spelled out:
20
- *
21
- * - A held `QueuedRequest` lives ONLY in this in-memory Map. Today's
22
- * behavior is strictly more durable: a queued follow-up is already
23
- * POSTed and sitting in Postgres the instant the operator says it, so it
24
- * survives a tab crash, a network blip, anything short of the session
25
- * itself being deleted. Moving the queue into the browser gives up that
26
- * durability in exchange for the operator being able to see and steer
27
- * it — that is the entire point, and the trade needs to be made with
28
- * open eyes, not by accident.
29
- * - `drainAllQueues()` is what keeps that loss narrow. It is the hang-up
30
- * flush: called as part of ending a call normally, it empties every
31
- * line's queue and hands back everything that was waiting so it can be
32
- * POSTed to the server exactly as if this module had never sat in front
33
- * of it. A normal end-of-call therefore loses nothing — the queue is
34
- * just a staging area the operator got to look inside before the same
35
- * dispatch that would have happened anyway.
36
- * - The durability genuinely AT RISK is narrower still than it first
37
- * sounds: a live voice call is not something a page reload survives
38
- * regardless of this module — there is no reload-resume contract for
39
- * the call itself (unlike the §41 guarantee for an already-dispatched
40
- * agent turn, which is a Postgres/Redis-backed run, not the call). So
41
- * "a reload loses the queue" is not a NEW failure this module
42
- * introduces; the call was already gone. What is genuinely new is the
43
- * sliver between "something got queued" and "the call ends" during
44
- * which the tab could crash before `drainAllQueues()` ever runs — a
45
- * real but narrow window, and the one honest cost of this design.
46
- *
47
- * NOT WIRED IN YET: this ships as a standalone module with its own tests
48
- * and no production caller. A later task connects `enqueueForLine` /
49
- * `dequeueForLine` to `dispatchToLine`'s busy-line path and `drainAllQueues`
50
- * to the hang-up handler; another adds the voice-facing `manage_queue` tool
51
- * on top of `peekQueue` / `dropQueuedAt` / `moveQueued`.
52
- */
53
- export type QueuedRequest = {
54
- readonly id: string;
55
- readonly request: string;
56
- };
57
- /** Append `request` to the back of `line`'s queue, minting a fresh id
58
- * (`nanoid()`, the same generator `line-dispatch.ts` uses for
59
- * `clientMessageId`). Always succeeds — there is no bound on queue depth. */
60
- export declare const enqueueForLine: (line: number, request: string) => QueuedRequest;
61
- /** Pop and return the FRONT of `line`'s queue, or `null` when it's empty. */
62
- export declare const dequeueForLine: (line: number) => QueuedRequest | null;
63
- /** A read-only snapshot of `line`'s queue, front to back. Never mutates. */
64
- export declare const peekQueue: (line: number) => readonly QueuedRequest[];
65
- /** How many requests are waiting on `line`. */
66
- export declare const queueDepth: (line: number) => number;
67
- /** Remove and return the item at `index` in `line`'s queue, or `null` when
68
- * `index` is out of range — an explicit `< 0 || >= length` bound (§10: never
69
- * truthiness on a length or index), so a bad index is an honest miss rather
70
- * than a silent no-op that could be mistaken for success. */
71
- export declare const dropQueuedAt: (line: number, index: number) => QueuedRequest | null;
72
- /** Move the item at `from` to position `to` in `line`'s queue (both bounds
73
- * explicit, same discipline as `dropQueuedAt`). Returns `false` — leaving
74
- * the queue completely untouched — when either index is out of range;
75
- * `true` on success, including the no-op case `from === to` (a valid index
76
- * moved to itself: nothing changes, but the request was satisfied, not
77
- * refused). `to` is a position in the queue AFTER `from` is removed — the
78
- * standard "move to position N" reading: moving the last item to `to: 0`
79
- * makes it the new front. */
80
- export declare const moveQueued: (line: number, from: number, to: number) => boolean;
81
- /** The hang-up flush: empty EVERY line's queue and return everything that
82
- * was waiting, in line-then-position order (line ascending, FIFO within a
83
- * line) — the order a normal end-of-call should hand work to the server in.
84
- * Exhaustive by construction: every line the map holds is visited and
85
- * cleared, so nothing can be left behind. See the module doc for why this
86
- * is what makes the queue's in-memory-only durability trade-off safe for a
87
- * normal call end. */
88
- export declare const drainAllQueues: () => readonly {
89
- readonly line: number;
90
- readonly request: string;
91
- }[];
92
- /** The call-teardown clear: drop every line's queue without returning
93
- * anything. Unlike `drainAllQueues`, this is for the paths that must not
94
- * re-POST stale work — e.g. resetting state at the START of a fresh call. */
95
- export declare const resetQueues: () => void;
96
- /** Drop `line`'s held queue and report how many items were discarded — the
97
- * ONE-line counterpart to `resetQueues()` (every line). For the paths that
98
- * must not re-POST or re-dispatch one line's stale work without touching any
99
- * other line's: `stop_agent` (voice-call.ts) clearing exactly the queue it
100
- * just told the user was dropped, and `closeAgentLine` (voice-call-lines.ts)
101
- * releasing a line whose held work must not resurrect onto the next
102
- * occupant of the same number. An explicit `=== 0` check rather than
103
- * truthiness (§10), same discipline as `dropQueuedAt`/`moveQueued`: a
104
- * nothing-to-drop line reports `0` honestly instead of writing an empty
105
- * array through `setQueue` for no reason. */
106
- export declare const clearQueueForLine: (line: number) => number;
@@ -1,110 +0,0 @@
1
- /**
2
- * The voice call's agent ROSTER — the browser-side twin of the tenant
3
- * roster minted server-side (`buildCallRoster` in
4
- * apps/belong-cloud/src/features/voice/call-roster.ts) and threaded through
5
- * `POST /v1/voice/call-token`'s `agents` field (`callAgentSpecSchema`,
6
- * voice.schemas.ts). This is what lets the dock's rail, the call screen's
7
- * agent board, and every spoken announcement address an agent by ROLE
8
- * ("cli", "consulting") instead of a bare line number — and do so from the
9
- * moment the dock boots, before any call has ever been started: the rail
10
- * renders dock-wide with no call active, so it needs the LAST-KNOWN roster,
11
- * not only one handed to it live off a fresh mint.
12
- *
13
- * Persisted per workspace, exactly like `line-slots.ts` beside it
14
- * (`belong:voice-call-roster`, suffixed `:ws:<id>` when a workspace is in
15
- * effect via `peekWorkspaceId()`) — a host workspace switch must not hand
16
- * tenant A's roster (its titles, its CLI agent) to a rail rendering for
17
- * tenant B.
18
- *
19
- * localStorage is a perimeter: the persisted roster is zod-validated on read
20
- * and any junk (corrupted JSON, wrong shape, storage disabled) degrades to
21
- * an EMPTY roster — same as "no call minted yet". The schema below is a
22
- * deliberately independent, by-hand copy of the server's
23
- * `callAgentSpecSchema`: the two packages ship separately and share no type
24
- * module, so this is what keeps them honest (mirrors the existing
25
- * `CallAgentSpec`/`callAgentSpecSchema` split already living server-side in
26
- * `call-roster.ts` / `voice.schemas.ts`).
27
- *
28
- * Two fallback rules, and they are NOT the same rule:
29
- *
30
- * - `lineForRole` / `roleForLine` on an EMPTY roster (nothing ever minted,
31
- * or a mint whose body failed to parse) fall back to the POSITIONAL
32
- * default that's been true since roles didn't exist: main=1, cli=2,
33
- * consulting=3. This is what stops a parse failure from bricking role
34
- * addressing mid-call — the switchboard still answers to
35
- * main/cli/consulting by position.
36
- * - On a NON-empty roster that simply doesn't have that role/line (a
37
- * tenant with no CLI), the same lookups return `null` instead — the
38
- * honest signal that THIS workspace has no such agent, which is what
39
- * later produces an `unknown_role` tool response rather than silently
40
- * addressing the wrong agent.
41
- *
42
- * `titleForRole` / `titleForLine` never return `null` — a title is always
43
- * needed for display/announcement, so THEIR fallback is a string, applied
44
- * uniformly regardless of whether the roster is empty or merely missing
45
- * that entry. The two fallbacks are deliberately DIFFERENT shapes, not the
46
- * same rule twice:
47
- *
48
- * - `titleForRole` falls back to a ROLE-derived phrase ("the main agent" /
49
- * "the CLI agent" / "the analyst") — never a switchboard
50
- * number. Every voice tool call carries a role (it is the operator's
51
- * entire addressing vocabulary — see `voice-call.ts`'s
52
- * `resolveRoleLine`), so this fallback is always reachable from a role
53
- * the model already said out loud, and it feeds prose the model
54
- * SPEAKS: an empty roster (nothing minted yet, or a pre-roster backend
55
- * mid rolling deploy — `callTokenResponseSchema`'s `agents` field
56
- * legitimately defaults to `[]`) must not leak a bare "Agent 2" into
57
- * that prose.
58
- * - `titleForLine` falls back to `"the main agent"` for line 1 and
59
- * `` `Agent ${line}` `` otherwise — the "Agent N" convention the
60
- * switchboard used before roles existed. This one serves the UI's
61
- * numbered rail, which genuinely displays a switchboard slot number, so
62
- * a line-derived fallback is correct there and stays as-is.
63
- */
64
- export type CallAgentRole = "main" | "cli" | "consulting";
65
- export type CallAgentSpec = {
66
- readonly role: CallAgentRole;
67
- /** The durable switchboard line underneath (`line-slots.ts`). */
68
- readonly line: number;
69
- /** What the voice calls this agent out loud. */
70
- readonly title: string;
71
- /** One sentence describing what this agent is for. */
72
- readonly purpose: string;
73
- };
74
- /** Persist the roster minted for the current call. A whole-roster replace —
75
- * never a per-entry patch — of whatever this workspace held before. */
76
- export declare const setCallRoster: (roster: readonly CallAgentSpec[]) => void;
77
- /** The current workspace's roster, or an empty array when nothing has been
78
- * minted yet (or storage held junk). */
79
- export declare const peekCallRoster: () => readonly CallAgentSpec[];
80
- /** Persist the tenant's product name minted alongside the roster (U2) — a
81
- * whole-value replace, same discipline as `setCallRoster`. */
82
- export declare const setProductName: (productName: string | null) => void;
83
- /** The current workspace's product name, or `null` when nothing has been
84
- * minted yet, the tenant has none, or storage held junk. Used ONLY to
85
- * localize the SDK's own UI copy (CallScreen's agent board, U2) — never fed
86
- * into any string the model speaks or receives. */
87
- export declare const peekProductName: () => string | null;
88
- /** Resolve a role to its switchboard line. See the module doc: `null` only
89
- * ever means "this NON-empty roster doesn't have that role" — an EMPTY
90
- * roster falls back to the positional default instead. */
91
- export declare const lineForRole: (role: CallAgentRole) => number | null;
92
- /** Resolve a switchboard line to its role — the inverse of `lineForRole`,
93
- * with the same two-rule fallback (EMPTY roster → positional; non-empty and
94
- * missing → `null`). */
95
- export declare const roleForLine: (line: number) => CallAgentRole | null;
96
- /** What the voice calls this role out loud. Always a string — falls back to
97
- * a ROLE-derived title (never a switchboard number, never `null`) when the
98
- * roster has no entry for this role, whether the roster is empty or just
99
- * missing it. */
100
- export declare const titleForRole: (role: CallAgentRole) => string;
101
- /** What the voice calls this line out loud. Always a string — falls back to
102
- * `"the main agent"` (line 1) or `` `Agent ${line}` `` otherwise when the
103
- * roster has no entry for this line, whether the roster is empty or just
104
- * missing it. */
105
- export declare const titleForLine: (line: number) => string;
106
- /** Test-only: drop the persisted roster AND product name for the current
107
- * workspace scope — they are minted together (the same call-token mint), so
108
- * a test resetting one without the other would leak a stale product name
109
- * (or roster) into the next case. */
110
- export declare const __clearCallRosterForTest: () => void;