@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
@@ -0,0 +1,33 @@
1
+ import { type EmbeddingInput, type EmbeddingProfile, type EmbeddingProfileDefinition, type KeyVault, type ProviderHostOptions, type TraceSink, z } from '@theoremjs/agents';
2
+ import type { ClientTurnOptions } from '@theoremjs/agents/host';
3
+ export type TheoremEmbeddingHandlerOptions = {
4
+ profile: EmbeddingProfile | EmbeddingProfileDefinition;
5
+ vault?: KeyVault;
6
+ fetch?: typeof globalThis.fetch;
7
+ provider?: ProviderHostOptions | ((ctx: {
8
+ request: Request;
9
+ model?: string;
10
+ }) => ProviderHostOptions | Promise<ProviderHostOptions>);
11
+ sink?: TraceSink;
12
+ metadata?: (request: Request) => Record<string, unknown> | undefined;
13
+ clientEvents?: ClientTurnOptions;
14
+ onError?: (err: unknown, ctx: {
15
+ request: Request;
16
+ }) => void;
17
+ };
18
+ /** The body an embedding request posts: the input, and optionally the model and the task. */
19
+ export declare const embedBodySchema: z.ZodObject<{
20
+ input: z.ZodUnknown;
21
+ model: z.ZodOptional<z.ZodString>;
22
+ task: z.ZodOptional<z.ZodEnum<{
23
+ document: "document";
24
+ query: "query";
25
+ }>>;
26
+ }, z.core.$strip>;
27
+ /** The body as the embedding request `runEmbedding` takes, less its profile. */
28
+ export declare function embedRequest(body: z.infer<typeof embedBodySchema>): {
29
+ task?: "document" | "query" | undefined;
30
+ model?: string | undefined;
31
+ input: EmbeddingInput | readonly EmbeddingInput[];
32
+ };
33
+ export declare function createTheoremEmbeddingHandler(options: TheoremEmbeddingHandlerOptions): (request: Request) => Promise<Response>;
@@ -0,0 +1,45 @@
1
+ import { defineProfile, registerProfile, runEmbedding, z, } from '@theoremjs/agents';
2
+ import { embeddingInterface } from "../client/embedding-transport.js";
3
+ import { readBody } from "./handler.js";
4
+ import { singleActionHandler } from "./single-action.js";
5
+ /** The body an embedding request posts: the input, and optionally the model and the task. */
6
+ export const embedBodySchema = z.object({
7
+ input: z.unknown(),
8
+ model: z.string().min(1).optional(),
9
+ task: z.enum(['query', 'document']).optional(),
10
+ });
11
+ /** The body as the embedding request `runEmbedding` takes, less its profile. */
12
+ export function embedRequest(body) {
13
+ return {
14
+ input: body.input,
15
+ ...(body.model === undefined ? {} : { model: body.model }),
16
+ ...(body.task === undefined ? {} : { task: body.task }),
17
+ };
18
+ }
19
+ export function createTheoremEmbeddingHandler(options) {
20
+ const profile = defineProfile(options.profile);
21
+ if (profile.type !== 'embedding') {
22
+ throw new Error(`createTheoremEmbeddingHandler serves type 'embedding'; got type '${profile.type}'.`);
23
+ }
24
+ registerProfile(profile);
25
+ return singleActionHandler({
26
+ action: 'embed',
27
+ iface: embeddingInterface(profile),
28
+ labels: profile.labels,
29
+ clientEvents: options.clientEvents,
30
+ onError: options.onError,
31
+ }, async (request) => {
32
+ const body = await readBody(request, embedBodySchema);
33
+ const provider = typeof options.provider === 'function'
34
+ ? await options.provider({ request, model: body.model })
35
+ : options.provider;
36
+ return runEmbedding({
37
+ profile: profile.id,
38
+ ...embedRequest(body),
39
+ signal: request.signal,
40
+ metadata: options.metadata?.(request),
41
+ }, provider
42
+ ? { ...provider, ...(options.sink ? { sink: options.sink } : {}) }
43
+ : { vault: options.vault, fetch: options.fetch, sink: options.sink });
44
+ });
45
+ }
@@ -1,3 +1,4 @@
1
+ import { type PageToolBroker } from './page-dispatch.ts';
1
2
  /**
2
3
  * One Web-standard handler that serves a Theorem chat UI for a single profile.
3
4
  *
@@ -9,27 +10,35 @@
9
10
  * waits on gates walks away from them first (`abandon`)
10
11
  * - `POST <base>/invoke` → NDJSON events for the user's answer to a paused tool call
11
12
  * - `POST <base>/steer` → inject messages into a running turn
13
+ * - `POST <base>/conversation` → the transcript and the paused reply, to draw
14
+ * - `POST <base>/rewind` → `{ conversation, view }` the conversation cut after one block, and its new ref
12
15
  *
13
16
  * `createTheoremHostHandler` serves a host profile the same way, with no model:
14
17
  *
15
18
  * - `GET <base>` → `{ interface }` the tools the page may call, with their schemas
16
19
  * - `POST <base>/call` → NDJSON events for one call of one of those tools
17
20
  * - `POST <base>/invoke` → NDJSON events for the user's answer to a paused call
21
+ * - `POST <base>/page-result` → grant-correlated browser result receipt
18
22
  *
19
- * Trust boundary: the browser owns the conversation text; the server owns every
20
- * decision that grants authority. Tool permissions, which paused calls may run
21
- * (and with what input), and which provider interactions may be continued are
22
- * kept in a server-side session — request bodies can't grant any of them.
23
+ * Trust boundary: the host owns the conversation and every decision that grants
24
+ * authority. Two stores keep them. The `conversationStore` owns the transcript,
25
+ * the history the model reads and the paused reply; the browser sends only what
26
+ * the person did now, with the opaque ref the store issued. The session store
27
+ * owns which paused calls may run (and with what input) and the tool
28
+ * permissions — request bodies can't grant any of them. A profile whose `providerContinuation.history` is
29
+ * `'stateless'` keeps no conversation, and takes no store.
23
30
  * Tool credentials are held on the server too: a key the user types at a gate
24
31
  * is sent once and saved, and no credential is ever sent back to the browser.
25
32
  *
26
33
  * @module
27
34
  */
28
- import { type CreateProviderOptions, type ModelProvider, type Profile, type ProfileDefinition, type ToolGate } from '@theoremjs/agents';
35
+ import { type Profile, type ProfileDefinition, type ProviderHostOptions, type ToolGate, type z } from '@theoremjs/agents';
29
36
  import { type ClientTurnOptions } from '@theoremjs/agents/host';
30
- import type { z } from '@theoremjs/agents';
37
+ import { type TheoremConversationStore } from './conversation-store.ts';
31
38
  import { type TheoremCredentialStore } from './credential-store.ts';
32
- import { type TheoremSessionStore } from './session-store.ts';
39
+ export { theoremSession, theoremSessionId } from './session-identity.ts';
40
+ import { type TheoremSessionLimits } from './session-limits.ts';
41
+ import { type SessionToolOperation, type TheoremSessionStore } from './session-store.ts';
33
42
  import { type SteerInbox } from './steer-inbox.ts';
34
43
  export type TheoremRequestContext = {
35
44
  request: Request;
@@ -40,12 +49,21 @@ export type TheoremHandlerOptions = {
40
49
  /** Profile to serve. Registered with the kernel when the handler is created. */
41
50
  profile: Profile | ProfileDefinition;
42
51
  /**
43
- * Provider credentials passed to `createProvider`, or a factory for hosts that
52
+ * Host options for registered providers, or a factory for hosts that
44
53
  * pick keys per request (BYOK, tenant vaults). Tools are registered by the host.
45
54
  */
46
- provider: CreateProviderOptions | ((ctx: TheoremRequestContext) => ModelProvider | Promise<ModelProvider>);
47
- /** Opaque app context for tool handlers (`ctx.host`) — e.g. the signed-in user. */
55
+ provider: ProviderHostOptions | ((ctx: TheoremRequestContext) => ProviderHostOptions | Promise<ProviderHostOptions>);
56
+ /**
57
+ * Opaque app context for tool handlers (`ctx.host`) — e.g. the signed-in user. A promise is
58
+ * awaited before the run starts, so the tools read what it settles to.
59
+ */
48
60
  host?: (request: Request) => unknown;
61
+ /**
62
+ * What the host wants the agent to know on each turn: any JSON. The profile's
63
+ * `inputs.context.from` must list `server`. The page's own context arrives in the
64
+ * request and is read as untrusted; this one is the host's.
65
+ */
66
+ context?: (request: Request) => unknown;
49
67
  /**
50
68
  * Resolve the caller's session id — e.g. `${userId}:${conversationId}` from your
51
69
  * auth. Return `undefined` to refuse the request (401). Default: an opaque id
@@ -54,12 +72,35 @@ export type TheoremHandlerOptions = {
54
72
  session?: (request: Request) => string | undefined | Promise<string | undefined>;
55
73
  /** Default: in-process memory. Use a shared store when requests can reach different instances. */
56
74
  sessionStore?: TheoremSessionStore;
75
+ /**
76
+ * Where the chat's conversation lives: the transcript, the history the model
77
+ * reads and a reply paused on gates. Required unless the profile's
78
+ * `providerContinuation.history` is `'stateless'`, which keeps none and takes
79
+ * no store. `createMemoryConversationStore` for one instance,
80
+ * `createSealedConversationStore` to keep nothing on the server, or your
81
+ * own database.
82
+ */
83
+ conversationStore?: TheoremConversationStore;
57
84
  /**
58
85
  * How long a gate (permission, confirmation, sign-in) waits for its answer, in
59
86
  * milliseconds. An answer after that is refused with `session.gate_expired`.
60
87
  * Default: 30 minutes.
61
88
  */
62
89
  gateTtlMs?: number;
90
+ /** Retain settled tool results in milliseconds. Default: 24 hours. */
91
+ operationRetentionMs?: number;
92
+ /** Finite per-session bounds. Unresolved authority is never evicted to satisfy them. */
93
+ sessionLimits?: Partial<TheoremSessionLimits>;
94
+ /** Maximum UTF-8 request body bytes before JSON parsing. Default: 16 MiB. */
95
+ maxRequestBytes?: number;
96
+ pageToolBroker?: PageToolBroker;
97
+ /** Check current resource access before disclosing a saved tool result. This callback must be read-only. */
98
+ authorizeToolReplay?: (context: {
99
+ request: Request;
100
+ operation: Extract<SessionToolOperation, {
101
+ status: 'settled';
102
+ }>;
103
+ }) => boolean | Promise<boolean>;
63
104
  /**
64
105
  * Tool credentials by session. Your OAuth callback route saves the token here
65
106
  * under the same session id; every turn reads from here. Default: in-process
@@ -79,18 +120,21 @@ export type TheoremHandlerOptions = {
79
120
  }) => string | Promise<string>;
80
121
  /** Default: in-process memory. Use a shared store when turns and steers can land on different instances. */
81
122
  steerInbox?: SteerInbox;
82
- /** Forwarded to `forClient` when projecting events for the browser. */
123
+ /**
124
+ * Who reads this host's replies, and what an event keeps for them: forwarded to `forClient`
125
+ * for each event and to `clientError` for a failure the handler catches.
126
+ */
83
127
  clientEvents?: ClientTurnOptions;
84
128
  /**
85
129
  * Called with any error the handler catches, for reporting. Users read the
86
- * profile's lexicon wording for the error's kind, never the error itself.
130
+ * profile's labels wording for the error's kind, never the error itself.
87
131
  */
88
132
  onError?: (err: unknown, ctx: {
89
133
  request: Request;
90
134
  }) => void;
91
135
  };
92
136
  /** A host profile runs no model, and takes no turns to steer. */
93
- export type TheoremHostHandlerOptions = Omit<TheoremHandlerOptions, 'profile' | 'provider' | 'steerInbox'> & {
137
+ export type TheoremHostHandlerOptions = Omit<TheoremHandlerOptions, 'profile' | 'provider' | 'steerInbox' | 'conversationStore'> & {
94
138
  /** Host profile to serve. Registered with the kernel when the handler is created. */
95
139
  profile: Extract<Profile, {
96
140
  type: 'host';
@@ -99,13 +143,7 @@ export type TheoremHostHandlerOptions = Omit<TheoremHandlerOptions, 'profile' |
99
143
  }>;
100
144
  };
101
145
  /** A JSON body checked against `schema`; a missing or malformed field is a `request` error (400). */
102
- export declare function readBody<T>(request: Request, schema: z.ZodType<T>): Promise<T>;
103
- /**
104
- * The session id the handler issued in its cookie, for a host route outside the
105
- * handler (an OAuth callback) that saves credentials under it. Hosts that pass
106
- * a `session` resolver use their own id instead.
107
- */
108
- export declare function theoremSessionId(request: Request): string | undefined;
146
+ export declare function readBody<T>(request: Request, schema: z.ZodType<T>, maxBytes?: number): Promise<T>;
109
147
  export declare function createTheoremHandler(options: TheoremHandlerOptions): (request: Request) => Promise<Response>;
110
148
  /**
111
149
  * Serves a host profile to `<TheoremHost />`: the page calls the profile's tools