@theoremjs/react 0.3.4-next.363.g11be542 → 0.3.4-next.375.ga2d1878

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 (201) hide show
  1. package/README.md +23 -336
  2. package/client/host-call.d.ts +2 -2
  3. package/client/host-call.js +1 -2
  4. package/client/index.d.ts +1 -28
  5. package/client/index.js +1 -22
  6. package/client/live/apply-live-turn-tool-event.js +1 -1
  7. package/client/live/run-live-tool-call.d.ts +1 -3
  8. package/client/live/run-live-tool-call.js +1 -1
  9. package/client/transcript-groups.js +1 -1
  10. package/client/voice-recorder.js +1 -1
  11. package/components/live/use-live-runner-controls.d.ts +1 -2
  12. package/components/live/use-live-runner-model.d.ts +7 -8
  13. package/components/live/use-live-runner-model.js +1 -2
  14. package/components/live/use-live-runner-ui.d.ts +2 -4
  15. package/components/live/use-live-runner-ui.js +1 -1
  16. package/components/live/use-live-session-client.d.ts +2 -5
  17. package/components/live/use-live-session-client.js +1 -1
  18. package/hooks/use-described.d.ts +1 -1
  19. package/hooks/use-described.js +1 -1
  20. package/hooks/use-embedding-index.d.ts +1 -1
  21. package/hooks/use-embedding-index.js +1 -1
  22. package/hooks/use-one-call.d.ts +2 -2
  23. package/hooks/use-one-call.js +1 -2
  24. package/hooks/use-page-tool-warnings.d.ts +2 -5
  25. package/hooks/use-page-tool-warnings.js +3 -14
  26. package/hooks/use-theorem-chat.d.ts +35 -81
  27. package/hooks/use-theorem-chat.js +30 -522
  28. package/hooks/use-theorem-decision.d.ts +1 -2
  29. package/hooks/use-theorem-embedding.d.ts +1 -2
  30. package/hooks/use-theorem-host.d.ts +2 -4
  31. package/hooks/use-theorem-host.js +1 -4
  32. package/hooks/use-theorem-interface.d.ts +1 -2
  33. package/hooks/use-trace-records.d.ts +1 -1
  34. package/index.d.ts +2 -3
  35. package/index.js +2 -3
  36. package/live.d.ts +1 -2
  37. package/package.json +3 -2
  38. package/server/mod.d.ts +1 -26
  39. package/server/mod.js +1 -24
  40. package/ui/ChatComposerBar.d.ts +1 -1
  41. package/ui/ChatComposerBar.js +1 -3
  42. package/ui/ChatTranscript.d.ts +1 -1
  43. package/ui/ChatTranscript.js +1 -1
  44. package/ui/ConsoleFrame.d.ts +1 -1
  45. package/ui/DecisionAnswers.d.ts +1 -1
  46. package/ui/EmbeddingDocuments.d.ts +2 -2
  47. package/ui/EmbeddingDocuments.js +1 -2
  48. package/ui/EmbeddingQuery.d.ts +1 -1
  49. package/ui/EmbeddingQuery.js +1 -2
  50. package/ui/EmbeddingResults.d.ts +1 -1
  51. package/ui/EmbeddingResults.js +1 -1
  52. package/ui/EmbeddingSpace.d.ts +1 -2
  53. package/ui/LiveRunner.d.ts +1 -2
  54. package/ui/SchemaFields.d.ts +1 -1
  55. package/ui/SchemaFields.js +1 -2
  56. package/ui/ShapedData.js +1 -1
  57. package/ui/StateFields.js +1 -1
  58. package/ui/TheoremChat.d.ts +2 -2
  59. package/ui/TheoremChat.js +1 -1
  60. package/ui/TheoremDecision.d.ts +1 -1
  61. package/ui/TheoremDecision.js +1 -1
  62. package/ui/TheoremEmbedding.d.ts +1 -1
  63. package/ui/TheoremEmbedding.js +1 -2
  64. package/ui/TheoremHost.d.ts +2 -3
  65. package/ui/TheoremHost.js +1 -3
  66. package/ui/ToolGateCard.d.ts +1 -1
  67. package/ui/ToolGateCard.js +1 -2
  68. package/ui/ToolResult.d.ts +1 -1
  69. package/ui/ToolResult.js +1 -2
  70. package/ui/ToolResultCharts.d.ts +1 -1
  71. package/ui/ToolResultCharts.js +1 -2
  72. package/ui/TraceInspector.d.ts +1 -1
  73. package/ui/TraceInspectorPanel.d.ts +1 -1
  74. package/ui/approval-heading.js +1 -1
  75. package/ui/embedding-space-gl.d.ts +2 -2
  76. package/ui/embedding-space-gl.js +1 -1
  77. package/ui/index.d.ts +1 -1
  78. package/ui/labels.d.ts +1 -2
  79. package/client/audio-level.d.ts +0 -5
  80. package/client/audio-level.js +0 -24
  81. package/client/composer-drawer.d.ts +0 -19
  82. package/client/composer-drawer.js +0 -15
  83. package/client/composer-hints.d.ts +0 -25
  84. package/client/composer-hints.js +0 -20
  85. package/client/composer-primary.d.ts +0 -16
  86. package/client/composer-primary.js +0 -25
  87. package/client/decision-transport.d.ts +0 -70
  88. package/client/decision-transport.js +0 -175
  89. package/client/decode-composer-draft.d.ts +0 -11
  90. package/client/decode-composer-draft.js +0 -12
  91. package/client/embedding-input.d.ts +0 -84
  92. package/client/embedding-input.js +0 -194
  93. package/client/embedding-space.d.ts +0 -82
  94. package/client/embedding-space.js +0 -389
  95. package/client/embedding-transport.d.ts +0 -40
  96. package/client/embedding-transport.js +0 -71
  97. package/client/encode-composer-draft.d.ts +0 -9
  98. package/client/encode-composer-draft.js +0 -34
  99. package/client/encode-files.d.ts +0 -18
  100. package/client/encode-files.js +0 -54
  101. package/client/failure.d.ts +0 -29
  102. package/client/failure.js +0 -34
  103. package/client/generation-selection.d.ts +0 -15
  104. package/client/generation-selection.js +0 -24
  105. package/client/host-transport.d.ts +0 -70
  106. package/client/host-transport.js +0 -75
  107. package/client/live/live-mic-forward.d.ts +0 -30
  108. package/client/live/live-mic-forward.js +0 -46
  109. package/client/live/live-page-tool.d.ts +0 -34
  110. package/client/live/live-page-tool.js +0 -11
  111. package/client/live/live-state.d.ts +0 -13
  112. package/client/live/live-state.js +0 -22
  113. package/client/live/live-tool.d.ts +0 -11
  114. package/client/live/live-tool.js +0 -1
  115. package/client/live-client.d.ts +0 -189
  116. package/client/live-client.js +0 -829
  117. package/client/live-errors.d.ts +0 -2
  118. package/client/live-errors.js +0 -9
  119. package/client/live-messages.d.ts +0 -148
  120. package/client/live-messages.js +0 -100
  121. package/client/mic-capture.d.ts +0 -4
  122. package/client/mic-capture.js +0 -6
  123. package/client/oauth-popup.d.ts +0 -26
  124. package/client/oauth-popup.js +0 -30
  125. package/client/page-dispatch.d.ts +0 -15
  126. package/client/page-dispatch.js +0 -63
  127. package/client/pcm-downsample.d.ts +0 -4
  128. package/client/pcm-downsample.js +0 -45
  129. package/client/run-commit.d.ts +0 -34
  130. package/client/run-commit.js +0 -49
  131. package/client/run-session.d.ts +0 -79
  132. package/client/run-session.js +0 -207
  133. package/client/schema-fields.d.ts +0 -63
  134. package/client/schema-fields.js +0 -199
  135. package/client/shaped-data.d.ts +0 -118
  136. package/client/shaped-data.js +0 -343
  137. package/client/source-citations.d.ts +0 -13
  138. package/client/source-citations.js +0 -56
  139. package/client/space-geometry.d.ts +0 -39
  140. package/client/space-geometry.js +0 -183
  141. package/client/tool-result.d.ts +0 -78
  142. package/client/tool-result.js +0 -293
  143. package/client/tool-resume.d.ts +0 -50
  144. package/client/tool-resume.js +0 -14
  145. package/client/trace-feed.d.ts +0 -13
  146. package/client/trace-feed.js +0 -18
  147. package/client/transcript-schema.d.ts +0 -10
  148. package/client/transcript-schema.js +0 -120
  149. package/client/transport.d.ts +0 -264
  150. package/client/transport.js +0 -330
  151. package/client/turn-client.d.ts +0 -44
  152. package/client/turn-client.js +0 -88
  153. package/client/wire-line.d.ts +0 -56
  154. package/client/wire-line.js +0 -90
  155. package/client/worklets/mic-capture.js +0 -16
  156. package/hooks/use-theorem-chat-actions.d.ts +0 -79
  157. package/hooks/use-theorem-chat-actions.js +0 -287
  158. package/hooks/use-theorem-chat-state.d.ts +0 -66
  159. package/hooks/use-theorem-chat-state.js +0 -122
  160. package/server/checkpoint-ownership.d.ts +0 -6
  161. package/server/checkpoint-ownership.js +0 -42
  162. package/server/conversation-store.d.ts +0 -92
  163. package/server/conversation-store.js +0 -131
  164. package/server/conversation.d.ts +0 -193
  165. package/server/conversation.js +0 -552
  166. package/server/credential-store.d.ts +0 -24
  167. package/server/credential-store.js +0 -14
  168. package/server/decision-handler.d.ts +0 -42
  169. package/server/decision-handler.js +0 -46
  170. package/server/embedding-handler.d.ts +0 -33
  171. package/server/embedding-handler.js +0 -45
  172. package/server/handler.d.ts +0 -158
  173. package/server/handler.js +0 -775
  174. package/server/json-response.d.ts +0 -2
  175. package/server/json-response.js +0 -7
  176. package/server/mcp-handler.d.ts +0 -46
  177. package/server/mcp-handler.js +0 -312
  178. package/server/page-dispatch.d.ts +0 -22
  179. package/server/page-dispatch.js +0 -127
  180. package/server/request-body.d.ts +0 -2
  181. package/server/request-body.js +0 -42
  182. package/server/request-check.d.ts +0 -21
  183. package/server/request-check.js +0 -49
  184. package/server/session-authority.d.ts +0 -8
  185. package/server/session-authority.js +0 -78
  186. package/server/session-boundary.d.ts +0 -26
  187. package/server/session-boundary.js +0 -64
  188. package/server/session-identity.d.ts +0 -16
  189. package/server/session-identity.js +0 -41
  190. package/server/session-limits.d.ts +0 -12
  191. package/server/session-limits.js +0 -59
  192. package/server/session-store.d.ts +0 -123
  193. package/server/session-store.js +0 -264
  194. package/server/single-action.d.ts +0 -21
  195. package/server/single-action.js +0 -30
  196. package/server/steer-inbox.d.ts +0 -35
  197. package/server/steer-inbox.js +0 -52
  198. package/server/tool-operations.d.ts +0 -6
  199. package/server/tool-operations.js +0 -132
  200. package/server/turn-input.d.ts +0 -10
  201. package/server/turn-input.js +0 -29
@@ -1,7 +1,6 @@
1
1
  import type { LiveProfileInterface } from '@theoremjs/agents/interface';
2
+ import type { LiveCallOptions, LiveConnection } from '@theoremjs/web/client';
2
3
  import { type LiveCaptionState, type LiveCaptionTurn } from '../../client/live/live-captions.ts';
3
- import type { LiveCallOptions } from '../../client/live/live-page-tool.ts';
4
- import type { LiveConnection } from '../../client/live-client.ts';
5
4
  /**
6
5
  * Owns LiveRunner state, session client, and stage callbacks.
7
6
  * `connection` resolves what the call opens: a host with a fixed profile returns
@@ -10,11 +9,11 @@ import type { LiveConnection } from '../../client/live-client.ts';
10
9
  */
11
10
  export declare function useLiveRunnerModel(iface: LiveProfileInterface, connection: () => LiveConnection | Promise<LiveConnection>, options?: LiveCallOptions): {
12
11
  handle: string;
13
- traces: import("../../index.ts").TraceFeed;
12
+ traces: import("@theoremjs/web/client").TraceFeed;
14
13
  callStarted: boolean;
15
14
  pastCalls: LiveCaptionTurn[][];
16
15
  captions: LiveCaptionState;
17
- failure: import("../../index.ts").ClientFailure | null;
16
+ failure: import("@theoremjs/web/client").ClientFailure | null;
18
17
  sessionEnded: string | null;
19
18
  levelsRef: import("react").RefObject<{
20
19
  input: number;
@@ -23,9 +22,9 @@ export declare function useLiveRunnerModel(iface: LiveProfileInterface, connecti
23
22
  isMuted: boolean;
24
23
  isVideoOn: boolean;
25
24
  sessionActive: boolean;
26
- liveState: import("../../index.ts").LiveState;
25
+ liveState: import("@theoremjs/web/client").LiveState;
27
26
  activeTool: string | null;
28
- status: import("../../index.ts").LiveSessionStatus;
27
+ status: import("@theoremjs/web/client").LiveSessionStatus;
29
28
  textAvailable: boolean;
30
29
  textDraft: string;
31
30
  toolActive: boolean;
@@ -34,7 +33,7 @@ export declare function useLiveRunnerModel(iface: LiveProfileInterface, connecti
34
33
  videoPreview: HTMLVideoElement | null;
35
34
  voiceAvailable: boolean;
36
35
  canRestart: boolean;
37
- gatePrompt: import("../../index.ts").LiveToolGatePrompt | null;
36
+ gatePrompt: import("@theoremjs/web/client").LiveToolGatePrompt | null;
38
37
  setTextDraft: import("react").Dispatch<import("react").SetStateAction<string>>;
39
38
  handleEnd: () => void;
40
39
  startCall: (options: {
@@ -45,5 +44,5 @@ export declare function useLiveRunnerModel(iface: LiveProfileInterface, connecti
45
44
  handleToggleMic: () => void;
46
45
  handleFlipCamera: () => Promise<void>;
47
46
  handleToggleVideo: () => Promise<void>;
48
- resolveGateDecision: (resolution: import("../../index.ts").ToolGateResolution) => void;
47
+ resolveGateDecision: (resolution: import("@theoremjs/web/client").ToolGateResolution) => void;
49
48
  };
@@ -1,8 +1,7 @@
1
1
  import { liveIngressEnabledFromSpec } from '@theoremjs/agents';
2
+ import { createTraceFeed, liveState } from '@theoremjs/web/client';
2
3
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
4
  import { stashLiveCaptionCall, } from "../../client/live/live-captions.js";
4
- import { liveState } from "../../client/live/live-state.js";
5
- import { createTraceFeed } from "../../client/trace-feed.js";
6
5
  import { usePageToolWarnings } from "../../hooks/use-page-tool-warnings.js";
7
6
  import { useLiveRunnerControls } from "./use-live-runner-controls.js";
8
7
  import { useLiveRunnerGate, useLiveRunnerUiState } from "./use-live-runner-ui.js";
@@ -1,12 +1,10 @@
1
1
  import { type LabelOverrides, type SessionEventOf } from '@theoremjs/agents';
2
+ import type { LiveConnectPhase, LiveGateAnswer, LiveSessionStatus, LiveToolGatePrompt, ToolGateResolution } from '@theoremjs/web/client';
3
+ import { type ClientFailure } from '@theoremjs/web/client';
2
4
  import { type Dispatch, type SetStateAction } from 'react';
3
- import { type ClientFailure } from '../../client/failure.ts';
4
5
  import { applyLiveTurnToolEvent } from '../../client/live/apply-live-turn-tool-event.ts';
5
6
  import { type LiveCaptionState } from '../../client/live/live-captions.ts';
6
- import type { LiveConnectPhase, LiveSessionStatus } from '../../client/live/live-state.ts';
7
- import type { LiveGateAnswer, LiveToolGatePrompt } from '../../client/live/live-tool.ts';
8
7
  import type { LiveFacingMode, LiveVideoCapture } from '../../client/live/live-video.ts';
9
- import type { ToolGateResolution } from '../../client/tool-resume.ts';
10
8
  /** UI + media state bag for the live runner. `labels` is the interface's: the profile's wording. */
11
9
  export declare function useLiveRunnerUiState(labels: LabelOverrides): {
12
10
  status: LiveSessionStatus;
@@ -1,6 +1,6 @@
1
1
  import { TheoremError } from '@theoremjs/agents';
2
+ import { clientFailure } from '@theoremjs/web/client';
2
3
  import { useCallback, useEffect, useRef, useState, } from 'react';
3
- import { clientFailure } from "../../client/failure.js";
4
4
  import { applyLiveTurnToolEvent } from "../../client/live/apply-live-turn-tool-event.js";
5
5
  import { applyLiveTurnEvent, clearLiveCaptionInterim, emptyLiveCaptionState, } from "../../client/live/live-captions.js";
6
6
  /** UI + media state bag for the live runner. `labels` is the interface's: the profile's wording. */
@@ -1,12 +1,9 @@
1
1
  import { type SessionEventOf, type TurnEvent } from '@theoremjs/agents';
2
+ import type { LiveCallOptions, LiveConnectPhase, LiveGateAnswer, LiveSessionStatus, LiveToolGatePrompt, TraceFeed } from '@theoremjs/web/client';
3
+ import { type LiveConnection, LiveSessionClient } from '@theoremjs/web/client';
2
4
  import { type Dispatch, type MutableRefObject, type SetStateAction } from 'react';
3
5
  import { type LiveCaptionState } from '../../client/live/live-captions.ts';
4
- import type { LiveCallOptions } from '../../client/live/live-page-tool.ts';
5
- import type { LiveConnectPhase, LiveSessionStatus } from '../../client/live/live-state.ts';
6
- import type { LiveGateAnswer, LiveToolGatePrompt } from '../../client/live/live-tool.ts';
7
6
  import type { LiveFacingMode, LiveVideoCapture } from '../../client/live/live-video.ts';
8
- import { type LiveConnection, LiveSessionClient } from '../../client/live-client.ts';
9
- import type { TraceFeed } from '../../client/trace-feed.ts';
10
7
  export type LiveClientBindings = LiveCallOptions & {
11
8
  voiceAvailable: boolean;
12
9
  /** Where the session's trace records go, when the relay delivers them. */
@@ -1,8 +1,8 @@
1
1
  import { TheoremError } from '@theoremjs/agents';
2
+ import { LiveSessionClient } from '@theoremjs/web/client';
2
3
  import { useCallback, useRef, } from 'react';
3
4
  import { applyLiveTranscript } from "../../client/live/live-captions.js";
4
5
  import { runLiveToolCall } from "../../client/live/run-live-tool-call.js";
5
- import { LiveSessionClient } from "../../client/live-client.js";
6
6
  function onLiveStatusChange(next, bindings) {
7
7
  bindings.setStatus(next);
8
8
  if (next === 'listening' || next === 'ready') {
@@ -1,4 +1,4 @@
1
- import { type ClientFailure } from '../client/failure.ts';
1
+ import { type ClientFailure } from '@theoremjs/web/client';
2
2
  /**
3
3
  * What a transport describes, read once per transport; a failure when it can't be read. A new
4
4
  * transport keeps the last description up until it describes itself, so swapping one in (a
@@ -1,5 +1,5 @@
1
+ import { clientFailure } from '@theoremjs/web/client';
1
2
  import { useEffect, useState } from 'react';
2
- import { clientFailure } from "../client/failure.js";
3
3
  /**
4
4
  * What a transport describes, read once per transport; a failure when it can't be read. A new
5
5
  * transport keeps the last description up until it describes itself, so swapping one in (a
@@ -1,5 +1,5 @@
1
1
  import type { EmbeddingInput, EmbeddingUsage } from '@theoremjs/agents';
2
- import type { EmbeddingInterface, EmbeddingTransport } from '../client/embedding-transport.ts';
2
+ import type { EmbeddingInterface, EmbeddingTransport } from '@theoremjs/web/client';
3
3
  import { type OneCallState } from './use-one-call.ts';
4
4
  /** Documents embedded for search: each one's vector, in the order given. */
5
5
  export type EmbeddingIndex = {
@@ -1,5 +1,5 @@
1
+ import { addUsage, embeddingBatches } from '@theoremjs/web/client';
1
2
  import { useState } from 'react';
2
- import { addUsage, embeddingBatches } from "../client/embedding-input.js";
3
3
  import { useOneCall } from "./use-one-call.js";
4
4
  async function indexWith(transport, signal, inputs, rules, onProgress) {
5
5
  const batches = embeddingBatches(inputs, rules);
@@ -1,6 +1,6 @@
1
1
  import type { TraceRecord } from '@theoremjs/agents';
2
- import { type ClientFailure } from '../client/failure.ts';
3
- import type { TraceFeed } from '../client/trace-feed.ts';
2
+ import type { TraceFeed } from '@theoremjs/web/client';
3
+ import { type ClientFailure } from '@theoremjs/web/client';
4
4
  /** A profile that answers in one call: a decision or an embedding. */
5
5
  export type OneCallTransport = {
6
6
  traces?: TraceFeed;
@@ -1,6 +1,5 @@
1
+ import { clientFailure, failedTraces } from '@theoremjs/web/client';
1
2
  import { useCallback, useEffect, useRef, useState } from 'react';
2
- import { failedTraces } from "../client/decision-transport.js";
3
- import { clientFailure } from "../client/failure.js";
4
3
  const IDLE = {
5
4
  status: 'idle',
6
5
  result: null,
@@ -1,6 +1,3 @@
1
- import { type PageTools } from '../client/live/live-page-tool.ts';
2
- /**
3
- * Says in the console, once, where the page's tools and the profile's disagree. A wrong name is
4
- * the builder's to fix, so it is never said to the visitor.
5
- */
1
+ import { type PageTools } from '@theoremjs/web/client';
2
+ /** Says in the console, once for each set of names, where the page's tools and the profile's disagree. */
6
3
  export declare function usePageToolWarnings(declared: readonly string[] | undefined, pageTools: PageTools | undefined): void;
@@ -1,9 +1,6 @@
1
+ import { warnPageToolMismatch } from '@theoremjs/web/client';
1
2
  import { useEffect } from 'react';
2
- import { pageToolMismatch } from "../client/live/live-page-tool.js";
3
- /**
4
- * Says in the console, once, where the page's tools and the profile's disagree. A wrong name is
5
- * the builder's to fix, so it is never said to the visitor.
6
- */
3
+ /** Says in the console, once for each set of names, where the page's tools and the profile's disagree. */
7
4
  export function usePageToolWarnings(declared, pageTools) {
8
5
  const handled = Object.keys(pageTools ?? {})
9
6
  .sort()
@@ -12,14 +9,6 @@ export function usePageToolWarnings(declared, pageTools) {
12
9
  useEffect(() => {
13
10
  if (named === undefined)
14
11
  return;
15
- const { unanswered, unused } = pageToolMismatch(named ? named.split('\n') : [], handled ? handled.split('\n') : []);
16
- for (const name of unanswered) {
17
- // labels-exempt: builder diagnostic
18
- console.warn(`Theorem: page tool '${name}' has no handler in pageTools; the agent gets no answer.`);
19
- }
20
- for (const name of unused) {
21
- // labels-exempt: builder diagnostic
22
- console.warn(`Theorem: pageTools has '${name}', which the profile does not declare answeredBy: 'page'.`);
23
- }
12
+ warnPageToolMismatch(named ? named.split('\n') : [], handled ? handled.split('\n') : []);
24
13
  }, [named, handled]);
25
14
  }
@@ -1,97 +1,51 @@
1
- import { type ComposerPendingMessage, type ComposerProfileInterface, type ComposerRunPhase, type InterfaceTurnSession, type TranscriptBlock } from '@theoremjs/agents/interface';
2
- import type { PageTools } from '../client/live/live-page-tool.ts';
3
- import type { ConversationView, TheoremTransport, TurnEventSink } from '../client/transport.ts';
4
- import { type MessageDelivery } from './use-theorem-chat-state.ts';
5
- export type UseTheoremChatOptions = {
6
- transport: TheoremTransport;
7
- /** Composer interface for the host profile — see `useTheoremInterface`. `null` while loading. */
8
- iface: ComposerProfileInterface | null;
9
- /**
10
- * The ref of a conversation to resume, as `onConversationChange` reported it. Read once, when
11
- * the chat mounts: the chat draws the conversation as the host keeps it. A stateless profile
12
- * keeps no conversation, so it has no ref.
13
- */
14
- conversation?: string;
15
- /**
16
- * The conversation under `conversation` as the host showed it with the ref, as
17
- * `startConversation` returns it. Read once, when the chat mounts: the chat draws it at once,
18
- * and does not read it from the host again.
19
- */
20
- conversationView?: ConversationView;
21
- /** The text the composer starts with. Read once, when the chat mounts. */
22
- initialText?: string;
23
- /**
24
- * Each new ref the host issues for the conversation: once the message posts, and again as the
25
- * reply's runs are saved. Keep the latest to resume the chat later.
26
- */
27
- onConversationChange?: (ref: string) => void;
28
- /**
29
- * The value chosen for each of the profile's `inputs.slots`. Sent with every turn. A slot you
30
- * name here is fixed to that value; one you leave out is chosen in the composer, starting at
31
- * its first allowed value.
32
- */
33
- slots?: Record<string, string>;
34
- /** Told each time the visitor chooses a slot in the composer, with every slot's value. */
35
- onSlotsChange?: (slots: Record<string, string>) => void;
36
- /** What the page wants the agent to know: any JSON. The latest value goes with every turn. */
37
- context?: unknown;
38
- /** The page's tools, by name: each answers a tool the profile declares with `answeredBy: 'page'`. */
39
- pageTools?: PageTools;
40
- /**
41
- * Every event of every turn, as it arrives and before the transcript takes it: the ones the
42
- * transcript shows, and the ones it does not (a stage, a session, a guardrail decision).
43
- */
44
- onTurnEvent?: TurnEventSink;
45
- };
46
- /** What `sendText` hands back: the blocks the turn added, its user message, and the reply. */
47
- export type SentTurn = {
48
- blocks: TranscriptBlock[];
49
- };
1
+ import { type ChatOptions, type SentTurn } from '@theoremjs/web/client';
2
+ export type { SentTurn };
3
+ export type UseTheoremChatOptions = ChatOptions;
50
4
  /**
51
5
  * Headless chat model: transcript, streaming, composer drafts, pending
52
6
  * queue / steer / stash, tool gates. Render it with `@theoremjs/react/ui` or
53
- * your own components.
7
+ * your own components. A React binding of `createChatController` from
8
+ * `@theoremjs/web/client`, which works with no framework.
54
9
  */
55
- export declare function useTheoremChat({ transport, iface, conversation: initialConversation, conversationView, initialText, onConversationChange, slots, onSlotsChange, context, pageTools, onTurnEvent, }: UseTheoremChatOptions): {
56
- iface: ComposerProfileInterface | null;
57
- blocks: TranscriptBlock[];
58
- chatStarted: boolean;
59
- draftText: string;
60
- failure: import("../index.ts").ClientFailure | null;
61
- /** The answer on its way to a gate, shown on it until the answer settles or fails. */
62
- answering: import("../index.ts").AnsweringGate | null;
63
- issues: import("@theoremjs/agents").AttachmentValidationIssue[];
64
- pendingFiles: File[];
65
- pendingMessages: ComposerPendingMessage[];
66
- pendingVoice: File[];
67
- phase: ComposerRunPhase;
68
- session: InterfaceTurnSession;
69
- /** The latest message's delivery; `null` before the first and once its turn failed. */
70
- delivery: MessageDelivery | null;
71
- streamBlocks: TranscriptBlock[];
72
- streaming: boolean;
73
- setDraftText: import("react").Dispatch<import("react").SetStateAction<string>>;
74
- setPendingFiles: import("react").Dispatch<import("react").SetStateAction<File[]>>;
75
- setPendingVoice: import("react").Dispatch<import("react").SetStateAction<File[]>>;
76
- setPendingMessages: import("react").Dispatch<import("react").SetStateAction<ComposerPendingMessage[]>>;
77
- setIssues: import("react").Dispatch<import("react").SetStateAction<import("@theoremjs/agents").AttachmentValidationIssue[]>>;
10
+ export declare function useTheoremChat(options: UseTheoremChatOptions): {
11
+ slotChoices: {
12
+ onChange: (name: string, value: string) => void;
13
+ declared: Record<string, string[]>;
14
+ values: Record<string, string>;
15
+ } | undefined;
16
+ setDraftText: (value: import("@theoremjs/web/client").ChatUpdate<string>) => void;
17
+ setPendingFiles: (value: import("@theoremjs/web/client").ChatUpdate<File[]>) => void;
18
+ setPendingVoice: (value: import("@theoremjs/web/client").ChatUpdate<File[]>) => void;
19
+ setPendingMessages: (value: import("@theoremjs/web/client").ChatUpdate<import("../../../src/interface/pending").ComposerPendingMessage[]>) => void;
20
+ setIssues: (value: import("@theoremjs/web/client").ChatUpdate<import("../../../mod").AttachmentValidationIssue[]>) => void;
78
21
  handleAuthenticated: (_index: number, secret?: string) => Promise<void>;
79
22
  handleBranch: (index: number) => Promise<void>;
80
23
  handleSubmit: () => Promise<void>;
81
24
  handleStop: () => void;
82
- handleMenuAction: (action: import("@theoremjs/agents/interface").ComposerMenuAction) => void;
25
+ handleMenuAction: (action: import("../../../src/interface/composer-actions").ComposerMenuAction) => void;
83
26
  handlePendingQueue: (id: string) => void;
84
27
  handlePendingRestore: (id: string) => Promise<void>;
85
- handleSendNow: (draftSource?: ComposerPendingMessage) => Promise<void>;
86
- handleToolDecision: (_index: number, action: import("../index.ts").ToolDecisionAction) => Promise<void>;
28
+ handleSendNow: (source?: import("../../../src/interface/pending").ComposerPendingMessage) => Promise<void>;
29
+ handleToolDecision: (_index: number, action: "allow" | "deny") => Promise<void>;
87
30
  handleGenerationChange: (next: {
88
31
  modelId: string;
89
32
  effort?: string;
90
33
  }) => void;
91
- slotChoices: {
92
- declared: Record<string, string[]>;
93
- values: Record<string, string>;
94
- onChange: (name: string, value: string) => void;
95
- } | undefined;
96
34
  sendText: (text: string, files?: readonly File[]) => Promise<SentTurn | null>;
35
+ iface: import("../../../src/interface/types").ComposerProfileInterface | null;
36
+ blocks: import("../../../src/interface/types").TranscriptBlock[];
37
+ streamBlocks: import("../../../src/interface/types").TranscriptBlock[];
38
+ chatStarted: boolean;
39
+ draftText: string;
40
+ pendingFiles: File[];
41
+ pendingVoice: File[];
42
+ pendingMessages: import("../../../src/interface/pending").ComposerPendingMessage[];
43
+ issues: import("../../../mod").AttachmentValidationIssue[];
44
+ failure: import("@theoremjs/web/client").ClientFailure | null;
45
+ answering: import("@theoremjs/web/client").AnsweringGate | null;
46
+ phase: import("../../../src/interface/composer-actions").ComposerRunPhase;
47
+ session: import("../../../src/interface/session").InterfaceTurnSession;
48
+ delivery: import("@theoremjs/web/client").MessageDelivery | null;
49
+ streaming: boolean;
50
+ slots: import("@theoremjs/web/client").ChatSlots | undefined;
97
51
  };