@theoremjs/web 0.3.4-next.675.g8fb1e99 → 0.3.4-next.679.gcdf1a3a

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
@@ -258,7 +258,7 @@ const transport = withPageToolDispatch(
258
258
  | `provider` | Host options, including the credential vault. A function can return these options per request, for example for tenant-specific credentials. |
259
259
  | `session` | Returns the session id of the caller, for example `${userId}:${conversationId}`. Return `undefined` to refuse the request with a 401. Default: a random id in an HttpOnly, SameSite=Lax cookie that lasts 30 days. |
260
260
  | `host` | App data for the tool handlers (`ctx.host`), such as the signed-in user. |
261
- | `prepare` | Your app's own turn, from the one the handler builds (`TurnWiring.prepare` from `@theoremjs/agents`). Set what your app sets per turn, such as `system`, `credentials`, `onStage` and `onAgentCall`; read your app data as `turn.host`. The handler keeps its profile, its tool execution and its abort. Your `onStage` runs before the handler's steering, and your `credentials` are read before the session's. |
261
+ | `prepare` | Your app's own turn, from the one the handler builds (`TurnWiring.prepare` from `@theoremjs/agents`). Set what your app sets per turn, such as `system`, `credentials`, `onStage` and `onAgentCall`; read your app data as `turn.host`. The handler keeps its profile, its tool execution and its abort. Your `onStage` runs before the handler's steering, and your `credentials` are read before the session's. A call held at a gate runs on, once answered, with the `host`, `onStage` and `credentials` you give for that call's turn. |
262
262
  | `onStage` | The server's own stage handler, on every call the handler runs, a host profile's included: after your app's (`prepare`), before steering. For a rule the server adds to whatever the app says, such as a question before each tool that writes. |
263
263
  | `pageToolBroker` | Delivers results to active page dispatches. Default: bounded process memory. |
264
264
  | `conversationStore` | Where the conversation is kept. Required, except for a stateless profile, which must not have one. See [Keep the conversation](#keep-the-conversation). |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/web",
3
- "version": "0.3.4-next.675.g8fb1e99",
3
+ "version": "0.3.4-next.679.gcdf1a3a",
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.675.g8fb1e99"
28
+ "@theoremjs/agents": "^0.3.4-next.679.gcdf1a3a"
29
29
  }
30
30
  }
@@ -70,7 +70,7 @@ export type TheoremHandlerOptions = {
70
70
  * value the application's other call sites use too. The handler keeps its profile, its tool
71
71
  * execution and its abort. The application's `onStage` runs before the handler's steering, and
72
72
  * its `credentials` are read before the session's. A call held at a gate runs on, once
73
- * answered, with the `onStage` and `credentials` it gives for that call's turn.
73
+ * answered, with the `host`, `onStage` and `credentials` it gives for that call's turn.
74
74
  */
75
75
  prepare?: TurnWiring['prepare'];
76
76
  /**
package/server/handler.js CHANGED
@@ -362,8 +362,8 @@ async function* settleAnswered(ctx, request, session, answered) {
362
362
  }
363
363
  async function* invokeAnswered(ctx, request, sessionId, { callId, pending, answer }) {
364
364
  const host = await ctx.options.host?.(request);
365
- // why: The held call goes on with what the application set for its turn: its stage handler and credentials.
366
- const { credentials, onStage } = await preparedTurn(ctx.options.prepare, { profile: ctx.profile.id, input: pending.turnInput ?? {}, host, signal: request.signal }, {
365
+ // why: The held call goes on with what the application set for its turn: its context, stage handler and credentials.
366
+ const prepared = await preparedTurn(ctx.options.prepare, { profile: ctx.profile.id, input: pending.turnInput ?? {}, host, signal: request.signal }, {
367
367
  credentials: sessionCredentials(ctx, sessionId),
368
368
  ...(ctx.options.onStage ? { onStage: ctx.options.onStage } : {}),
369
369
  });
@@ -381,14 +381,14 @@ async function* invokeAnswered(ctx, request, sessionId, { callId, pending, answe
381
381
  ? { page: answer.page ?? { unanswered: true } }
382
382
  : {}),
383
383
  sessionPermissions: answer.sessionPermissions,
384
- credentials,
385
- ...(onStage ? { onStage } : {}),
384
+ credentials: prepared.credentials,
385
+ ...(prepared.onStage ? { onStage: prepared.onStage } : {}),
386
386
  turnInput: pending.turnInput,
387
387
  snapshot: pending.snapshot,
388
388
  promoted: pending.promoted,
389
389
  model: pending.model,
390
390
  signal: request.signal,
391
- host,
391
+ host: prepared.host,
392
392
  });
393
393
  }
394
394
  /** A settled call's answer, streamed again. */