@theoremjs/web 0.3.4-next.711.g78e504a → 0.3.4-next.717.gd16ffc6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -131,8 +131,13 @@ const boundary = await createTheoremSessionBoundary({
131
131
  });
132
132
  const open = parseLiveOpenMessage(firstFrame);
133
133
  const session = await runSession(
134
- { profile, ...await boundary.prepareLiveOpen(open, hostContext) },
135
- { vault: hostKeyVault, execution: boundary.toolExecution, pageExecution: boundary.pageExecution },
134
+ {
135
+ profile,
136
+ ...await boundary.prepareLiveOpen(open, hostContext),
137
+ execution: boundary.toolExecution,
138
+ pageExecution: boundary.pageExecution,
139
+ },
140
+ { vault: hostKeyVault },
136
141
  );
137
142
  for await (const event of session.events()) {
138
143
  if ((event.type === 'done' || event.type === 'provider_checkpoint') && event.providerState) {
@@ -447,9 +452,9 @@ These claims do not provide exactly-once effects at the destination. Use the ope
447
452
  Concurrent pending attempts can reach preparation before one claims the body.
448
453
  Permission checks and pre-body hooks must be read-only or independently idempotent. The kernel cannot prove hook purity.
449
454
  A live session does not restore a dispatched call after an unexpected failure. It retains an uncertain call on that connection.
450
- To retain execution claims across connections, supply a durable coordinator through `RunSessionOptions.execution`.
455
+ To retain execution claims across connections, supply a durable coordinator as `execution` on `SessionRequest`.
451
456
  Browser dispatch uses a host-owned `PageToolExecution` service beside the execution coordinator.
452
- `createTheoremHandler` supplies both services. Live relays pass the session boundary's `pageExecution` and `toolExecution` to `runSession`.
457
+ `createTheoremHandler` supplies both services. Live relays put the session boundary's `pageExecution` and `toolExecution` on `SessionRequest`.
453
458
 
454
459
  A tool with a `background` setting runs inline until you pass the `background` option to `createTheoremHandler`. The option takes `{ request, sessionId }` and returns a `ToolBackgroundService`, which receives each detached call and its late events. The session keeps the call as `background` until it settles, and a late settlement does not invalidate a checkpoint. Keep the service's values valid after the request ends. A live relay passes its service to `runSession`.
455
460
  Forward live page results to `answerPageResult`. Preserve checkpoint ownership through `beforeEvent` when using the Studio bridge.
@@ -19,6 +19,10 @@ export type LiveCallOptions = {
19
19
  slots?: Record<string, string>;
20
20
  /** Which prompt lines the call gets, for a host that lets its page choose (`pageStatesTurn`). */
21
21
  stated?: StatedTurn;
22
+ /** The model picked for the call, read as the call starts, when the profile allows it. */
23
+ model?: string;
24
+ /** That model's effort, read as the call starts, when the binding allows it. */
25
+ effort?: string;
22
26
  /**
23
27
  * What the page tells the agent: any JSON. It goes with the call's opening, and
24
28
  * again whenever it changes, as background the agent reads without replying.
@@ -26,6 +26,10 @@ export interface LiveClientOptions {
26
26
  slots?: Record<string, string>;
27
27
  /** Which prompt lines the call gets, for a host that lets its page choose (`pageStatesTurn`). */
28
28
  stated?: StatedTurn;
29
+ /** The model picked for the call, when the profile allows it. */
30
+ model?: string;
31
+ /** That model's effort, when the binding allows it. */
32
+ effort?: string;
29
33
  /** What the page tells the agent as the call opens; `setContext` replaces it during the call. */
30
34
  context?: unknown;
31
35
  relayUrl?: string;
@@ -228,12 +228,14 @@ export class LiveSessionClient {
228
228
  }
229
229
  /** The first message: the call's values, and the handle and time away when it takes a dropped call up again. */
230
230
  openMessage() {
231
- const { slots, stated, openMessage: host } = this.options;
231
+ const { slots, stated, model, effort, openMessage: host } = this.options;
232
232
  return {
233
233
  type: 'open',
234
234
  ...(this.history.length ? { history: structuredClone(this.history) } : {}),
235
235
  ...(slots ? { slots } : {}),
236
236
  ...(stated ? { stated } : {}),
237
+ ...(model ? { model } : {}),
238
+ ...(effort ? { effort } : {}),
237
239
  ...(this.context === undefined ? {} : { context: this.context }),
238
240
  ...(this.providerState
239
241
  ? {
@@ -22,6 +22,10 @@ export type LiveOpenMessage = {
22
22
  context?: unknown;
23
23
  /** Which prompt lines the call gets, for a host that lets its page choose (`pageStatesTurn`). */
24
24
  stated?: StatedTurn;
25
+ /** The model picked for the call, when the profile allows it. */
26
+ model?: string;
27
+ /** That model's effort, when the binding allows it. */
28
+ effort?: string;
25
29
  /** A call that dropped, taken up again: the provider's handle, and how long the caller was away. */
26
30
  resume?: {
27
31
  providerState: ProviderCheckpoint;
@@ -15,6 +15,8 @@ const liveOpenMessage = z.object({
15
15
  slots: z.record(z.string(), z.string()).optional(),
16
16
  context: z.unknown().optional(),
17
17
  stated: statedTurnSchema.optional(),
18
+ model: z.string().optional(),
19
+ effort: z.string().optional(),
18
20
  resume: z
19
21
  .object({ providerState: providerCheckpointSchema, awayMs: z.number().nonnegative() })
20
22
  .optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/web",
3
- "version": "0.3.4-next.711.g78e504a",
3
+ "version": "0.3.4-next.717.gd16ffc6",
4
4
  "description": "Theorem on the web platform, with no UI framework: Web-standard server handlers that serve a profile, and the browser client that talks to them.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,6 +25,6 @@
25
25
  },
26
26
  "peerDependencies": {
27
27
  "zod": "^4.6.5",
28
- "@theoremjs/agents": "^0.3.4-next.711.g78e504a"
28
+ "@theoremjs/agents": "^0.3.4-next.717.gd16ffc6"
29
29
  }
30
30
  }
@@ -14,9 +14,9 @@
14
14
  *
15
15
  * @module
16
16
  */
17
- import { type GateReference, type LabelOverrides, type Profile, type ProviderCheckpoint, TheoremError, type ToolId, type TurnEvent, type TurnHistoryMessage, type TurnInput } from '@theoremjs/agents';
17
+ import { type GateReference, type LabelOverrides, type Profile, type ProviderCheckpoint, TheoremError, type TurnEvent, type TurnHistoryMessage, type TurnInput } from '@theoremjs/agents';
18
18
  import { type ClientTurnOptions } from '@theoremjs/agents/host';
19
- import { type ComposerProfileInterface, streamThoughtsEnabled, type TranscriptBlock, type UserTurnDraft, type UserTurnHistoryMedia } from '@theoremjs/agents/interface';
19
+ import { type ComposerProfileInterface, type ReplyCarried, streamThoughtsEnabled, type TranscriptBlock, type UserTurnDraft, type UserTurnHistoryMedia } from '@theoremjs/agents/interface';
20
20
  import type { ConversationLine, ConversationView, StatedTurn, TheoremTurnInput } from '../client/transport.ts';
21
21
  import { type StoredConversation, type TheoremConversationStore } from './conversation-store.ts';
22
22
  /** One walked-away call: its id, and the run that settles it (`invokeTool` with the abandoned resume). */
@@ -120,8 +120,8 @@ export type ReplyTurn = {
120
120
  model?: string;
121
121
  effort?: string;
122
122
  stated?: StatedTurn;
123
- /** The tools the reply had when it paused, for a reply that goes on. */
124
- promoted?: ToolId[];
123
+ /** The tools and steps the reply had when it paused, for a reply that goes on. */
124
+ carried?: ReplyCarried;
125
125
  };
126
126
  /** What a reply's model run takes from the host. */
127
127
  export type ReplyRunner = {
@@ -135,7 +135,7 @@ export type ReplyRunner = {
135
135
  model?: string;
136
136
  effort?: string;
137
137
  stated?: StatedTurn;
138
- promoted?: ToolId[];
138
+ carried?: ReplyCarried;
139
139
  signal: AbortSignal;
140
140
  };
141
141
  /** A line of a reply's stream: an event, or the ref of what the store wrote. */
@@ -17,7 +17,7 @@
17
17
  import { attachmentsRefused, labelText, TheoremError, toErrorEvent, } from '@theoremjs/agents';
18
18
  import { sanitizeTurnRequestWithEvents, withPublicLabels } from '@theoremjs/agents/guardrails';
19
19
  import { forClient } from '@theoremjs/agents/host';
20
- import { appendAssistantEventsToHistory, appendUserDraftToHistory, applyTurnEventsToSession, emptyInterfaceTurnSession, foldTurnEvents, gatedToolsFromEvents, historyFromTranscriptBlocks, prepareUserTurn, replyToolIdsFromEvents, settlesToolCall, streamThoughtsEnabled, } from '@theoremjs/agents/interface';
20
+ import { appendAssistantEventsToHistory, appendUserDraftToHistory, applyTurnEventsToSession, emptyInterfaceTurnSession, foldTurnEvents, gatedToolsFromEvents, historyFromTranscriptBlocks, prepareUserTurn, replyCarriedFromEvents, settlesToolCall, streamThoughtsEnabled, } from '@theoremjs/agents/interface';
21
21
  import { base64ToBytes } from '@theoremjs/agents/kernel';
22
22
  import { stampWorked, stoppedReply } from "../client/run-commit.js";
23
23
  import { emptyConversation, unknownConversation, } from "./conversation-store.js";
@@ -236,7 +236,7 @@ async function* runReply(host, opened, reply, runner, input, withMessage) {
236
236
  model: runner.model,
237
237
  effort: runner.effort,
238
238
  ...(runner.stated ? { stated: runner.stated } : {}),
239
- ...(runner.promoted ? { promoted: runner.promoted } : {}),
239
+ ...(runner.carried ? { carried: runner.carried } : {}),
240
240
  });
241
241
  for await (const event of events) {
242
242
  reply.events.push(event);
@@ -493,7 +493,7 @@ export async function* answerReply(args) {
493
493
  model: runner.model ?? paused.model,
494
494
  effort: runner.effort ?? paused.effort,
495
495
  ...(paused.stated ? { stated: paused.stated } : {}),
496
- promoted: replyToolIdsFromEvents(reply.events),
496
+ carried: replyCarriedFromEvents(reply.events),
497
497
  }, {
498
498
  history: replyHistory(reply),
499
499
  ...(waiting.inputTokens === undefined ? {} : { inputTokens: waiting.inputTokens }),
package/server/handler.js CHANGED
@@ -426,7 +426,7 @@ async function* chatTurn(ctx, request, session, turn, key, stop) {
426
426
  host,
427
427
  ...(turn.model ? { model: turn.model } : {}),
428
428
  ...(turn.effort ? { effort: turn.effort } : {}),
429
- ...(turn.promoted ? { promoted: turn.promoted } : {}),
429
+ ...turn.carried,
430
430
  ...turn.stated,
431
431
  }, {
432
432
  credentials: sessionCredentials(ctx, session.id),
@@ -7,4 +7,4 @@ export declare function kernelTurnInput(input: TheoremTurnInput, server?: unknow
7
7
  * What a live call's first message asks of the session, as `runSession` takes
8
8
  * it: the page's context is the client's, and `server` is the host's own.
9
9
  */
10
- export declare function liveSessionOpen(open: LiveOpenMessage, server?: unknown): Pick<SessionRequest, 'slots' | 'context' | 'providerState' | 'awayMs' | 'history' | 'path' | 'conditions'>;
10
+ export declare function liveSessionOpen(open: LiveOpenMessage, server?: unknown): Pick<SessionRequest, 'slots' | 'context' | 'providerState' | 'awayMs' | 'history' | 'path' | 'conditions' | 'model' | 'effort'>;
@@ -23,6 +23,8 @@ export function liveSessionOpen(open, server) {
23
23
  ...(open.slots ? { slots: open.slots } : {}),
24
24
  ...(context ? { context } : {}),
25
25
  ...open.stated,
26
+ ...(open.model ? { model: open.model } : {}),
27
+ ...(open.effort ? { effort: open.effort } : {}),
26
28
  ...(open.resume
27
29
  ? { providerState: open.resume.providerState, awayMs: open.resume.awayMs }
28
30
  : {}),