@theoremjs/react 0.3.0 → 0.3.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.
Files changed (258) hide show
  1. package/README.md +728 -202
  2. package/client/composer-hints.js +1 -1
  3. package/client/decision-images.d.ts +76 -0
  4. package/client/decision-images.js +139 -0
  5. package/client/decision-transport.d.ts +26 -4
  6. package/client/decision-transport.js +79 -6
  7. package/client/embedding-input.d.ts +84 -0
  8. package/client/embedding-input.js +194 -0
  9. package/client/embedding-space.d.ts +82 -0
  10. package/client/embedding-space.js +389 -0
  11. package/client/embedding-transport.d.ts +40 -0
  12. package/client/embedding-transport.js +71 -0
  13. package/client/failure.d.ts +7 -10
  14. package/client/failure.js +9 -9
  15. package/client/host-call.d.ts +1 -1
  16. package/client/host-call.js +7 -2
  17. package/client/host-transport.d.ts +2 -0
  18. package/client/host-transport.js +3 -2
  19. package/client/index.d.ts +19 -11
  20. package/client/index.js +14 -10
  21. package/client/ink-waveform.d.ts +1 -1
  22. package/client/ink-waveform.js +1 -2
  23. package/client/live/apply-live-turn-tool-event.js +1 -1
  24. package/client/live/live-captions.d.ts +30 -0
  25. package/client/live/live-captions.js +105 -1
  26. package/client/live/live-mic-forward.d.ts +1 -0
  27. package/client/live/live-mic-forward.js +11 -2
  28. package/client/live/live-page-tool.d.ts +34 -0
  29. package/client/live/live-page-tool.js +11 -0
  30. package/client/live/live-state.d.ts +4 -2
  31. package/client/live/live-state.js +2 -0
  32. package/client/live/live-video.js +1 -1
  33. package/client/live/run-live-tool-call.d.ts +7 -2
  34. package/client/live/run-live-tool-call.js +48 -10
  35. package/client/live/use-live-caption-log.d.ts +17 -0
  36. package/client/live/use-live-caption-log.js +51 -0
  37. package/client/live-client.d.ts +52 -4
  38. package/client/live-client.js +250 -59
  39. package/client/live-messages.d.ts +51 -13
  40. package/client/live-messages.js +42 -9
  41. package/client/page-dispatch.d.ts +15 -0
  42. package/client/page-dispatch.js +63 -0
  43. package/client/run-commit.d.ts +16 -43
  44. package/client/run-commit.js +26 -101
  45. package/client/run-session.d.ts +40 -41
  46. package/client/run-session.js +104 -112
  47. package/client/schema-fields.js +27 -6
  48. package/client/shaped-data.js +37 -8
  49. package/client/source-citations.js +1 -1
  50. package/client/space-geometry.d.ts +39 -0
  51. package/client/space-geometry.js +183 -0
  52. package/client/state-fields.js +1 -1
  53. package/client/tool-result.js +30 -12
  54. package/client/tool-resume.d.ts +18 -1
  55. package/client/tool-resume.js +4 -1
  56. package/client/trace-feed.d.ts +1 -1
  57. package/client/trace-story.d.ts +2 -2
  58. package/client/trace-story.js +43 -19
  59. package/client/trace-view.d.ts +2 -2
  60. package/client/trace-view.js +56 -16
  61. package/client/transcript-groups.d.ts +28 -2
  62. package/client/transcript-groups.js +63 -13
  63. package/client/transcript-schema.d.ts +10 -0
  64. package/client/transcript-schema.js +120 -0
  65. package/client/transport.d.ts +114 -26
  66. package/client/transport.js +106 -32
  67. package/client/turn-client.d.ts +17 -8
  68. package/client/turn-client.js +26 -31
  69. package/client/voice-recorder.d.ts +1 -1
  70. package/client/voice-recorder.js +2 -5
  71. package/client/wire-line.js +5 -5
  72. package/client/worklets/mic-capture.js +9 -9
  73. package/components/InkWaveform.d.ts +12 -1
  74. package/components/InkWaveform.js +65 -42
  75. package/components/live/use-live-runner-controls.d.ts +3 -4
  76. package/components/live/use-live-runner-controls.js +6 -10
  77. package/components/live/use-live-runner-model.d.ts +10 -6
  78. package/components/live/use-live-runner-model.js +29 -14
  79. package/components/live/use-live-runner-ui.d.ts +10 -8
  80. package/components/live/use-live-runner-ui.js +19 -11
  81. package/components/live/use-live-session-client.d.ts +4 -4
  82. package/components/live/use-live-session-client.js +11 -8
  83. package/components/use-composer-voice.d.ts +4 -4
  84. package/components/use-composer-voice.js +8 -8
  85. package/components/use-editor-selection.js +4 -1
  86. package/components/use-voice-playback.d.ts +2 -1
  87. package/components/use-voice-playback.js +4 -4
  88. package/hooks/use-described.d.ts +5 -1
  89. package/hooks/use-described.js +11 -9
  90. package/hooks/use-embedding-index.d.ts +27 -0
  91. package/hooks/use-embedding-index.js +43 -0
  92. package/hooks/use-one-call.d.ts +31 -0
  93. package/hooks/use-one-call.js +76 -0
  94. package/hooks/use-page-tool-warnings.d.ts +6 -0
  95. package/hooks/use-page-tool-warnings.js +25 -0
  96. package/hooks/use-second-ticker.d.ts +2 -0
  97. package/hooks/use-second-ticker.js +13 -0
  98. package/hooks/use-theorem-chat-actions.d.ts +25 -21
  99. package/hooks/use-theorem-chat-actions.js +67 -45
  100. package/hooks/use-theorem-chat-state.d.ts +6 -6
  101. package/hooks/use-theorem-chat-state.js +13 -9
  102. package/hooks/use-theorem-chat.d.ts +48 -14
  103. package/hooks/use-theorem-chat.js +329 -141
  104. package/hooks/use-theorem-decision.d.ts +5 -10
  105. package/hooks/use-theorem-decision.js +4 -67
  106. package/hooks/use-theorem-embedding.d.ts +18 -0
  107. package/hooks/use-theorem-embedding.js +12 -0
  108. package/hooks/use-theorem-host.d.ts +5 -4
  109. package/hooks/use-theorem-host.js +26 -8
  110. package/hooks/use-theorem-interface.d.ts +6 -3
  111. package/hooks/use-theorem-interface.js +12 -22
  112. package/index.d.ts +6 -3
  113. package/index.js +5 -2
  114. package/live.d.ts +1 -0
  115. package/live.js +1 -1
  116. package/package.json +6 -5
  117. package/server/checkpoint-ownership.d.ts +6 -0
  118. package/server/checkpoint-ownership.js +42 -0
  119. package/server/conversation-store.d.ts +92 -0
  120. package/server/conversation-store.js +131 -0
  121. package/server/conversation.d.ts +193 -0
  122. package/server/conversation.js +552 -0
  123. package/server/decision-handler.d.ts +12 -4
  124. package/server/decision-handler.js +29 -38
  125. package/server/embedding-handler.d.ts +33 -0
  126. package/server/embedding-handler.js +45 -0
  127. package/server/handler.d.ts +58 -20
  128. package/server/handler.js +441 -238
  129. package/server/mod.d.ts +15 -6
  130. package/server/mod.js +13 -5
  131. package/server/page-dispatch.d.ts +22 -0
  132. package/server/page-dispatch.js +127 -0
  133. package/server/request-body.d.ts +2 -0
  134. package/server/request-body.js +42 -0
  135. package/server/request-check.d.ts +6 -1
  136. package/server/request-check.js +27 -12
  137. package/server/session-authority.d.ts +8 -0
  138. package/server/session-authority.js +78 -0
  139. package/server/session-boundary.d.ts +26 -0
  140. package/server/session-boundary.js +64 -0
  141. package/server/session-identity.d.ts +16 -0
  142. package/server/session-identity.js +41 -0
  143. package/server/session-limits.d.ts +12 -0
  144. package/server/session-limits.js +59 -0
  145. package/server/session-store.d.ts +69 -20
  146. package/server/session-store.js +220 -5
  147. package/server/single-action.d.ts +21 -0
  148. package/server/single-action.js +30 -0
  149. package/server/steer-inbox.js +1 -1
  150. package/server/tool-operations.d.ts +6 -0
  151. package/server/tool-operations.js +132 -0
  152. package/server/turn-input.d.ts +10 -0
  153. package/server/turn-input.js +29 -0
  154. package/styles/ink-controls.css +78 -78
  155. package/ui/CardWall.d.ts +10 -0
  156. package/ui/CardWall.js +61 -0
  157. package/ui/ChatComposerBar.d.ts +28 -5
  158. package/ui/ChatComposerBar.js +85 -30
  159. package/ui/ChatTranscript.d.ts +14 -1
  160. package/ui/ChatTranscript.js +110 -57
  161. package/ui/ConsoleFrame.d.ts +61 -4
  162. package/ui/ConsoleFrame.js +109 -9
  163. package/ui/DecisionAnswers.d.ts +40 -2
  164. package/ui/DecisionAnswers.js +166 -35
  165. package/ui/DecisionImages.d.ts +16 -0
  166. package/ui/DecisionImages.js +46 -0
  167. package/ui/EmbeddingDocuments.d.ts +78 -0
  168. package/ui/EmbeddingDocuments.js +278 -0
  169. package/ui/EmbeddingQuery.d.ts +27 -0
  170. package/ui/EmbeddingQuery.js +95 -0
  171. package/ui/EmbeddingResults.d.ts +41 -0
  172. package/ui/EmbeddingResults.js +165 -0
  173. package/ui/EmbeddingSpace.d.ts +26 -0
  174. package/ui/EmbeddingSpace.js +106 -0
  175. package/ui/LiveCaptionsPanel.d.ts +22 -0
  176. package/ui/LiveCaptionsPanel.js +27 -0
  177. package/ui/LiveRunner.d.ts +6 -4
  178. package/ui/LiveRunner.js +42 -55
  179. package/ui/PaneState.d.ts +33 -0
  180. package/ui/PaneState.js +50 -0
  181. package/ui/SchemaFields.d.ts +1 -1
  182. package/ui/SchemaFields.js +54 -26
  183. package/ui/ShapedData.js +73 -28
  184. package/ui/SidePanel.d.ts +74 -5
  185. package/ui/SidePanel.js +82 -9
  186. package/ui/StateFields.d.ts +10 -2
  187. package/ui/StateFields.js +56 -13
  188. package/ui/TheoremChat.d.ts +65 -14
  189. package/ui/TheoremChat.js +66 -78
  190. package/ui/TheoremDecision.d.ts +12 -20
  191. package/ui/TheoremDecision.js +78 -35
  192. package/ui/TheoremEmbedding.d.ts +27 -0
  193. package/ui/TheoremEmbedding.js +122 -0
  194. package/ui/TheoremHost.d.ts +22 -5
  195. package/ui/TheoremHost.js +127 -37
  196. package/ui/ToolGateCard.d.ts +5 -1
  197. package/ui/ToolGateCard.js +30 -23
  198. package/ui/ToolResult.js +12 -10
  199. package/ui/ToolResultCharts.js +29 -12
  200. package/ui/TraceCharts.d.ts +2 -2
  201. package/ui/TraceCharts.js +48 -17
  202. package/ui/TraceGuardrails.d.ts +3 -2
  203. package/ui/TraceGuardrails.js +24 -6
  204. package/ui/TraceInspector.d.ts +11 -1
  205. package/ui/TraceInspector.js +45 -28
  206. package/ui/TraceInspectorPanel.d.ts +31 -9
  207. package/ui/TraceInspectorPanel.js +77 -39
  208. package/ui/TraceOverview.d.ts +7 -3
  209. package/ui/TraceOverview.js +44 -14
  210. package/ui/TraceSpanDetail.js +24 -22
  211. package/ui/TraceStory.js +9 -8
  212. package/ui/TraceValues.js +19 -9
  213. package/ui/TraceWaterfall.js +12 -9
  214. package/ui/VoiceNote.js +4 -4
  215. package/ui/approval-heading.d.ts +4 -0
  216. package/ui/approval-heading.js +9 -0
  217. package/ui/arrive.d.ts +18 -0
  218. package/ui/arrive.js +46 -0
  219. package/ui/built/theme.css +86 -68
  220. package/ui/built/theme.css.d.ts +9 -0
  221. package/ui/built/theorem.d.ts +3 -3
  222. package/ui/built/theorem.js +34 -5
  223. package/ui/built/theorem.variants.d.ts +8 -2
  224. package/ui/code-language.d.ts +12 -0
  225. package/ui/code-language.js +50 -0
  226. package/ui/disclosure-motion.js +53 -9
  227. package/ui/embedding-space-gl.d.ts +37 -0
  228. package/ui/embedding-space-gl.js +663 -0
  229. package/ui/embedding-space-view.d.ts +8 -0
  230. package/ui/embedding-space-view.js +8 -0
  231. package/ui/glide.d.ts +7 -0
  232. package/ui/glide.js +44 -0
  233. package/ui/icons.js +2 -1
  234. package/ui/index.d.ts +20 -9
  235. package/ui/index.js +20 -10
  236. package/ui/labels-provider.js +5 -2
  237. package/ui/labels.d.ts +374 -85
  238. package/ui/labels.js +1028 -188
  239. package/ui/markdown-plugins.d.ts +9 -0
  240. package/ui/markdown-plugins.js +13 -0
  241. package/ui/mcp-icon.d.ts +6 -0
  242. package/ui/mcp-icon.js +8 -0
  243. package/ui/row-keys.d.ts +19 -0
  244. package/ui/row-keys.js +33 -0
  245. package/ui/theme.d.ts +1 -1
  246. package/ui/theme.js +2 -2
  247. package/ui/theorem-theme.js +32 -10
  248. package/ui/trace-palette.d.ts +2 -16
  249. package/ui/trace-palette.js +2 -16
  250. package/ui/trace-patterns.d.ts +11 -3
  251. package/ui/trace-patterns.js +16 -3
  252. package/ui/transcript-copy-text.js +1 -0
  253. package/ui/wall-columns.d.ts +8 -0
  254. package/ui/wall-columns.js +19 -0
  255. package/client/walk-away.d.ts +0 -34
  256. package/client/walk-away.js +0 -48
  257. package/server/walk-away.d.ts +0 -22
  258. package/server/walk-away.js +0 -41
@@ -1,7 +1,9 @@
1
- export type LiveSessionStatus = 'disconnected' | 'connecting' | 'ready' | 'listening' | 'speaking' | 'working' | 'error';
1
+ export type LiveSessionStatus = 'disconnected' | 'connecting'
2
+ /** The call dropped and the client is taking it up again. */
3
+ | 'reconnecting' | 'ready' | 'listening' | 'speaking' | 'working' | 'error';
2
4
  export type LiveConnectPhase = 'socket' | 'microphone';
3
5
  /** What a live call is doing, for its status line; the UI words it. */
4
- export type LiveState = 'calling_tool' | 'connecting' | 'requesting_mic' | 'speaking' | 'connected' | 'muted' | 'listening' | 'error' | 'ended';
6
+ export type LiveState = 'calling_tool' | 'connecting' | 'reconnecting' | 'requesting_mic' | 'speaking' | 'connected' | 'muted' | 'listening' | 'error' | 'ended';
5
7
  export declare function liveState(args: {
6
8
  status: LiveSessionStatus;
7
9
  connectPhase: LiveConnectPhase | null;
@@ -1,4 +1,6 @@
1
1
  export function liveState(args) {
2
+ if (args.status === 'reconnecting')
3
+ return 'reconnecting';
2
4
  if (args.toolName)
3
5
  return 'calling_tool';
4
6
  if (args.connectPhase === 'socket')
@@ -20,7 +20,7 @@ export function startLiveVideoCapture(onFrame, options) {
20
20
  if (!context) {
21
21
  for (const track of stream.getTracks())
22
22
  track.stop();
23
- throw new TheoremError('unsupported', 'no 2d canvas for live video'); // lexicon-exempt: internal diagnostic
23
+ throw new TheoremError('unsupported', 'no 2d canvas for live video'); // labels-exempt: internal diagnostic
24
24
  }
25
25
  let timer = null;
26
26
  let stopped = false;
@@ -1,16 +1,21 @@
1
1
  import type { ExecuteToolOnRelay } from '../live-messages.ts';
2
+ import type { PageTools } from './live-page-tool.ts';
2
3
  import type { LiveGateAnswer, LiveToolGatePrompt } from './live-tool.ts';
3
4
  /**
4
- * Live provider tool-call handler: run the model's call on the relay; at a
5
- * gate, ask the user and send their decision. The session answers the model
5
+ * Live provider tool-call handler: the page answers the call if it is the
6
+ * page's; else run the model's call on the relay; at a gate, ask the user and
7
+ * send their decision. The session answers the model
6
8
  * however the call ends; its tool events tell the user. A call the model
7
9
  * cancels while its gate is open is gone: nothing is sent.
8
10
  */
9
11
  export declare function runLiveToolCall(args: {
10
12
  executeToolOnRelay: ExecuteToolOnRelay;
13
+ /** The host's page tools, if it has any. */
14
+ pageTools?: PageTools;
11
15
  name: string;
12
16
  toolArgs: Record<string, unknown>;
13
17
  callId: string;
18
+ operationId: string;
14
19
  sessionPermissions: string[];
15
20
  setSessionPermissions: (next: string[]) => void;
16
21
  waitForGateDecision: (prompt: LiveToolGatePrompt) => Promise<LiveGateAnswer>;
@@ -1,31 +1,69 @@
1
1
  import { continueGatedToolInvocation } from "../tool-resume.js";
2
2
  /**
3
- * Live provider tool-call handler: run the model's call on the relay; at a
4
- * gate, ask the user and send their decision. The session answers the model
3
+ * Live provider tool-call handler: the page answers the call if it is the
4
+ * page's; else run the model's call on the relay; at a gate, ask the user and
5
+ * send their decision. The session answers the model
5
6
  * however the call ends; its tool events tell the user. A call the model
6
7
  * cancels while its gate is open is gone: nothing is sent.
7
8
  */
8
9
  export async function runLiveToolCall(args) {
9
- const { executeToolOnRelay, name, toolArgs, callId } = args;
10
+ const { executeToolOnRelay, name, toolArgs, callId, operationId } = args;
10
11
  let sessionPermissions = args.sessionPermissions;
11
- let step = await executeToolOnRelay({ callId });
12
- while (step.status === 'gated') {
12
+ // why: A name from the model is looked up among the host's own keys only.
13
+ const pageTool = args.pageTools && Object.hasOwn(args.pageTools, name) ? args.pageTools[name] : undefined;
14
+ let step = await executeToolOnRelay({ callId, operationId });
15
+ const dispatched = new Set();
16
+ while (step.status !== 'settled') {
17
+ if (step.status === 'dispatched') {
18
+ if (dispatched.has(step.grantId))
19
+ return;
20
+ dispatched.add(step.grantId);
21
+ const grantId = step.grantId;
22
+ const input = step.arguments;
23
+ const answer = pageTool
24
+ ? await Promise.resolve()
25
+ .then(() => pageTool(input, { callId, operationId }))
26
+ .catch(() => undefined)
27
+ : undefined;
28
+ step = await executeToolOnRelay({
29
+ callId,
30
+ operationId,
31
+ grantId,
32
+ ...(answer ? { output: answer.output } : { unanswered: true }),
33
+ });
34
+ continue;
35
+ }
13
36
  const { gate } = step;
14
- const resolution = await args.waitForGateDecision({ callId, toolName: name, input: toolArgs, gate });
37
+ if (gate.kind === 'page') {
38
+ await executeToolOnRelay({ callId, operationId, decision: 'deny' });
39
+ return;
40
+ }
41
+ const resolution = await args.waitForGateDecision({
42
+ callId,
43
+ toolName: name,
44
+ input: gate.preparedArguments ?? toolArgs,
45
+ gate,
46
+ });
15
47
  if (resolution === 'withdrawn')
16
48
  return;
17
- const reply = continueGatedToolInvocation({ toolName: name, gate, sessionPermissions, resolution });
49
+ const reply = continueGatedToolInvocation({
50
+ toolName: name,
51
+ gate,
52
+ sessionPermissions,
53
+ resolution,
54
+ });
18
55
  if (reply.decision === 'deny') {
19
- // The session settles the refusal; its tool event tells the user.
20
- await executeToolOnRelay({ callId, decision: 'deny' });
56
+ // why: The session settles the refusal; its tool event tells the user.
57
+ await executeToolOnRelay({ callId, operationId, decision: 'deny' });
21
58
  return;
22
59
  }
23
60
  sessionPermissions = reply.sessionPermissions;
24
61
  args.setSessionPermissions(reply.sessionPermissions);
25
- // Signed in: a typed key goes once, with the approval; after an OAuth callback there is none.
62
+ // why: Signed in: a typed key goes once, with the approval; after an OAuth callback there is none.
26
63
  step = await executeToolOnRelay({
27
64
  callId,
28
65
  decision: 'approve',
66
+ operationId,
29
67
  ...(reply.secret !== undefined ? { secret: reply.secret } : {}),
30
68
  });
31
69
  }
@@ -0,0 +1,17 @@
1
+ import type { TurnEvent } from '@theoremjs/agents';
2
+ import { type LiveCaptionState, type LiveCaptionTurn } from './live-captions.ts';
3
+ /**
4
+ * The captions a live call shows: this call's lines, and earlier calls kept
5
+ * when it is started again. Speech arrives through `applyTranscript`, and the
6
+ * call's turn events (thoughts, tool calls, the reply's end) through
7
+ * `applyTurnEvent`. A typed send is `noteSentText`, which always starts its own line.
8
+ */
9
+ export declare function useLiveCaptionLog(): {
10
+ captions: LiveCaptionState;
11
+ pastCalls: LiveCaptionTurn[][];
12
+ applyTranscript: (text: string, isUser: boolean, interim?: boolean) => void;
13
+ applyTurnEvent: (event: TurnEvent) => void;
14
+ noteSentText: (text: string) => void;
15
+ beginNextCall: () => void;
16
+ clear: () => void;
17
+ };
@@ -0,0 +1,51 @@
1
+ import { useCallback, useRef, useState } from 'react';
2
+ import { applyLiveTranscript, applyLiveTurnEvent, emptyLiveCaptionState, stashLiveCaptionCall, } from "./live-captions.js";
3
+ /**
4
+ * The captions a live call shows: this call's lines, and earlier calls kept
5
+ * when it is started again. Speech arrives through `applyTranscript`, and the
6
+ * call's turn events (thoughts, tool calls, the reply's end) through
7
+ * `applyTurnEvent`. A typed send is `noteSentText`, which always starts its own line.
8
+ */
9
+ export function useLiveCaptionLog() {
10
+ const [captions, setCaptions] = useState(emptyLiveCaptionState);
11
+ const [pastCalls, setPastCalls] = useState([]);
12
+ const captionsRef = useRef(captions);
13
+ captionsRef.current = captions;
14
+ const applyTranscript = useCallback((text, isUser, interim) => {
15
+ const next = applyLiveTranscript(captionsRef.current, text, isUser, interim);
16
+ captionsRef.current = next;
17
+ setCaptions(next);
18
+ }, []);
19
+ const applyTurnEvent = useCallback((event) => {
20
+ const next = applyLiveTurnEvent(captionsRef.current, event);
21
+ captionsRef.current = next;
22
+ setCaptions(next);
23
+ }, []);
24
+ const noteSentText = useCallback((text) => {
25
+ const next = applyLiveTranscript(captionsRef.current, text, true, false, { forceNew: true });
26
+ captionsRef.current = next;
27
+ setCaptions(next);
28
+ }, []);
29
+ const beginNextCall = useCallback(() => {
30
+ const previous = captionsRef.current.turns;
31
+ setPastCalls((calls) => stashLiveCaptionCall(calls, previous));
32
+ const next = emptyLiveCaptionState();
33
+ captionsRef.current = next;
34
+ setCaptions(next);
35
+ }, []);
36
+ const clear = useCallback(() => {
37
+ setPastCalls([]);
38
+ const next = emptyLiveCaptionState();
39
+ captionsRef.current = next;
40
+ setCaptions(next);
41
+ }, []);
42
+ return {
43
+ captions,
44
+ pastCalls,
45
+ applyTranscript,
46
+ applyTurnEvent,
47
+ noteSentText,
48
+ beginNextCall,
49
+ clear,
50
+ };
51
+ }
@@ -19,10 +19,14 @@ export type { LiveConnection, LiveSocket } from './live-messages.ts';
19
19
  import type { LiveSocket } from './live-messages.ts';
20
20
  export interface LiveClientOptions {
21
21
  profile?: string;
22
- /** JSON sent before anything else, as the socket opens. */
22
+ /** The host's own JSON for its relay, sent as the open message's `host`. */
23
23
  openMessage?: Record<string, unknown>;
24
+ /** The value chosen for each of the profile's `inputs.slots`, fixed for the call. */
25
+ slots?: Record<string, string>;
26
+ /** What the page tells the agent as the call opens; `setContext` replaces it during the call. */
27
+ context?: unknown;
24
28
  relayUrl?: string;
25
- /** In-process connections reuse the same microphone, playback and tool client. */
29
+ /** In-process connections reuse the same microphone, playback, and tool client. */
26
30
  createSocket?: () => LiveSocket;
27
31
  /** When false, skip microphone capture; session still receives model audio. */
28
32
  voiceIngress?: boolean;
@@ -38,7 +42,7 @@ export interface LiveClientOptions {
38
42
  onTurnEvent?: (event: ClientTurnEvent) => void;
39
43
  /** A trace record the session wrote, when the relay delivers them. */
40
44
  onTrace?: (record: TraceRecord) => void;
41
- /** A failure, typed by kind; word it with `clientFailure` and the interface's `lexicon`. */
45
+ /** A failure, typed by kind; word it with `clientFailure` and the interface's `labels`. */
42
46
  onError?: (error: Error) => void;
43
47
  /** Provider signalled the upstream session is draining (e.g. goAway). */
44
48
  onSessionClosing?: (timeLeftMs?: number) => void;
@@ -53,6 +57,7 @@ export interface LiveClientOptions {
53
57
  */
54
58
  onToolCall: (name: string, args: Record<string, unknown>, meta: {
55
59
  callId: string;
60
+ operationId: string;
56
61
  }) => Promise<void>;
57
62
  /** The relay opened the call: the id it gave the call, and the profile it runs. */
58
63
  onSessionReady?: (info: {
@@ -93,16 +98,47 @@ export declare class LiveSessionClient {
93
98
  /** Bumped on barge-in / cancel so stale audioChain work is skipped. */
94
99
  private audioEpoch;
95
100
  private pendingExecuteResults;
101
+ /** The page's context package, and the JSON of the one the relay last got. */
102
+ private context;
103
+ private sentContext;
104
+ /** The provider's latest handle for taking this call up again after a drop. */
105
+ private history;
106
+ private providerState;
107
+ /** The session said it ended, or failed: a close after that is the end, not a drop. */
108
+ private sessionOver;
109
+ /** When the call dropped, for the time away a resume reports. */
110
+ private droppedAt;
111
+ /** When the call that could not reconnect dropped: the next call takes it up again. */
112
+ private lostAt;
113
+ private reconnectTries;
114
+ private reconnectTimer;
96
115
  constructor(options: LiveClientOptions);
97
116
  private setStatus;
117
+ /** Still opening: the first connect, or a try at taking a dropped call up again. */
118
+ private get opening();
98
119
  private setConnectPhase;
99
120
  private clearConnectTimeout;
100
121
  private detachWebSocket;
122
+ private clearReconnect;
101
123
  private teardownConnection;
102
124
  /** End the session on `error`: a failed connect or a lost socket. */
103
125
  private failSession;
104
126
  private createSocket;
127
+ /**
128
+ * Start a call. After one that dropped and could not reconnect, it takes that call up again,
129
+ * so the agent neither greets twice nor forgets; after a hang-up it is a new call.
130
+ */
105
131
  connect(): Promise<void>;
132
+ /** A lost call that cannot be taken up again, its handle refused or expired, starts as a new one. */
133
+ private startOver;
134
+ /** The first message: the call's values, and the handle and time away when it takes a dropped call up again. */
135
+ private openMessage;
136
+ /** The socket closed while the call was open: take it up again if the provider gave a handle, else end. */
137
+ private handleDrop;
138
+ private scheduleReconnect;
139
+ /** A try at opening failed: a reconnect waits and tries again, a first connect fails the call. */
140
+ private failOpen;
141
+ private open;
106
142
  private ensureAudioContext;
107
143
  private activateMicrophone;
108
144
  private sendMicFrame;
@@ -115,6 +151,8 @@ export declare class LiveSessionClient {
115
151
  private processServerEnvelope;
116
152
  private enqueueServerMessage;
117
153
  private handleReadyEnvelope;
154
+ /** The call is open, first or again: the page's context catches up with what changed meanwhile. */
155
+ private becomeReady;
118
156
  private handleExecuteToolResultEnvelope;
119
157
  private tryHandleControlEnvelope;
120
158
  private collectInboundTurn;
@@ -134,7 +172,17 @@ export declare class LiveSessionClient {
134
172
  cancelPlayback(): void;
135
173
  toggleMute(): boolean;
136
174
  sendText(text: string): void;
137
- sendContext(text: string): void;
175
+ /**
176
+ * The call's slot values. An open call is taken up again with them when the provider gave a
177
+ * handle; with none, the next call has them.
178
+ */
179
+ setSlots(slots: Record<string, string> | undefined): void;
180
+ /**
181
+ * Replace the page's context package. In a call it reaches the agent as
182
+ * background, with no reply; before one, it goes with the call's opening.
183
+ */
184
+ setContext(context: unknown): void;
185
+ private flushContext;
138
186
  sendVideo(data: string, mimeType?: string): void;
139
187
  disconnect(): void;
140
188
  private cleanupAudio;