@ouispec/agent-worker 0.30.0 → 0.32.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 (63) hide show
  1. package/README.md +59 -12
  2. package/dist/authz/tool-policy.d.ts +2 -1
  3. package/dist/authz/tool-policy.d.ts.map +1 -1
  4. package/dist/authz/tool-policy.js.map +1 -1
  5. package/dist/handoff/handoff-tool.d.ts +51 -0
  6. package/dist/handoff/handoff-tool.d.ts.map +1 -0
  7. package/dist/handoff/handoff-tool.js +146 -0
  8. package/dist/handoff/handoff-tool.js.map +1 -0
  9. package/dist/index.d.ts +8 -3
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +6 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/live-call/handler.d.ts +11 -4
  14. package/dist/live-call/handler.d.ts.map +1 -1
  15. package/dist/live-call/handler.js +34 -7
  16. package/dist/live-call/handler.js.map +1 -1
  17. package/dist/live-call/protocol.d.ts +52 -6
  18. package/dist/live-call/protocol.d.ts.map +1 -1
  19. package/dist/live-call/protocol.js +55 -7
  20. package/dist/live-call/protocol.js.map +1 -1
  21. package/dist/orchestrator.d.ts.map +1 -1
  22. package/dist/orchestrator.js +40 -20
  23. package/dist/orchestrator.js.map +1 -1
  24. package/dist/prompt/capture.d.ts +11 -2
  25. package/dist/prompt/capture.d.ts.map +1 -1
  26. package/dist/prompt/capture.js +22 -4
  27. package/dist/prompt/capture.js.map +1 -1
  28. package/dist/prompt/clock.d.ts +4 -4
  29. package/dist/prompt/clock.js +4 -4
  30. package/dist/prompt/handoff.d.ts +140 -0
  31. package/dist/prompt/handoff.d.ts.map +1 -0
  32. package/dist/prompt/handoff.js +218 -0
  33. package/dist/prompt/handoff.js.map +1 -0
  34. package/dist/prompt/spoken-input.d.ts +2 -2
  35. package/dist/prompt/spoken-input.js +2 -2
  36. package/dist/prompt/spoken-reply.d.ts +2 -2
  37. package/dist/prompt/spoken-reply.js +2 -2
  38. package/dist/prompt/vision.d.ts +3 -3
  39. package/dist/prompt/vision.js +3 -3
  40. package/dist/runtime/config.d.ts.map +1 -1
  41. package/dist/runtime/config.js +3 -0
  42. package/dist/runtime/config.js.map +1 -1
  43. package/dist/runtime/turn-runner.d.ts.map +1 -1
  44. package/dist/runtime/turn-runner.js +14 -0
  45. package/dist/runtime/turn-runner.js.map +1 -1
  46. package/dist/runtime/types.d.ts +25 -5
  47. package/dist/runtime/types.d.ts.map +1 -1
  48. package/dist/step-messages.d.ts +46 -9
  49. package/dist/step-messages.d.ts.map +1 -1
  50. package/dist/step-messages.js +43 -23
  51. package/dist/step-messages.js.map +1 -1
  52. package/dist/testing/scripted.d.ts +6 -4
  53. package/dist/testing/scripted.d.ts.map +1 -1
  54. package/dist/testing/scripted.js +7 -5
  55. package/dist/testing/scripted.js.map +1 -1
  56. package/dist/tools/types.d.ts +5 -4
  57. package/dist/tools/types.d.ts.map +1 -1
  58. package/dist/tools/types.js.map +1 -1
  59. package/dist/types.d.ts +34 -4
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/ui/snapshot.d.ts +1 -1
  62. package/dist/ui/snapshot.js +1 -1
  63. package/package.json +2 -2
package/README.md CHANGED
@@ -48,7 +48,7 @@ const persona: AgentPersonaConfig = {
48
48
 
49
49
  With `format: 'plain'`, the markdown lines are replaced. The model is told to write short, natural sentences; to use no markdown syntax of any kind (no bold or italics, headings, bullet or numbered lists, tables, code, block quotes, rules or link syntax); to say several items in a sentence and compare things in words; to say what matters in tool data in sentences; and that this holds whatever the formatting of the prompt or its examples. The concise preset's "bullet points over paragraphs" becomes one or two short sentences, and the formal preset's "numbered lists and clear headings" becomes a few short paragraphs in a clear order. The few-shot examples and workflows are labelled without bold (`User:`, `Assistant:`, `Trigger:`). No other part of the prompt the SDK writes, and no description of the SDK's own tools, asks for markdown; what your persona's own text says (its identity, instructions, knowledge and examples) is yours to keep plain.
50
50
 
51
- The format is part of the system prompt, so it stays the same on every turn of a runtime, as the prompt cache needs: a channel that needs plain text (SMS, a dealer's web chat) gets a runtime whose persona asks for it, rather than a format that changes turn by turn. A live call's turn is also told, after the conversation, that its reply will be spoken ("What a UI client sends with a turn", `output`); in plain text the two agree, and the system prompt is the same on the call as in the chat. A preset or format the worker does not know, in the object form, fails when the adapter is created, naming it. A `systemPrompt` callback writes its own prompt, so the option does not apply to it. `resolveCommunicationStyle`, `COMMUNICATION_STYLES` and `COMMUNICATION_FORMATS` are exported for a host that reads the setting itself.
51
+ The format is part of the system prompt, so it stays the same on every turn of a runtime, as the prompt cache needs: a channel that needs plain text (SMS, a dealer's web chat) gets a runtime whose persona asks for it, rather than a format that changes turn by turn. A live call's turn is also told, in the turn's context, that its reply will be spoken ("What a UI client sends with a turn", `output`); in plain text the two agree, and the system prompt is the same on the call as in the chat. A preset or format the worker does not know, in the object form, fails when the adapter is created, naming it. A `systemPrompt` callback writes its own prompt, so the option does not apply to it. `resolveCommunicationStyle`, `COMMUNICATION_STYLES` and `COMMUNICATION_FORMATS` are exported for a host that reads the setting itself.
52
52
 
53
53
  A host that fits its stored history loads `@ouispec/agent-worker/history` (`answerWithoutState`): a module with no runtime imports, which also answers a CommonJS resolver.
54
54
 
@@ -62,15 +62,38 @@ Four keys on the turn's `context` are for the worker itself, and your persona or
62
62
  |---|---|---|
63
63
  | `oui` | Its surface snapshot: `ouiRuntime.snapshot()` | Builds the turn's UI tools from it, and from nothing else |
64
64
  | `uiKnowledge` | Its generated knowledge for the page the user is on: `resolveKnowledge(generatedKnowledge, path)` from `@ouispec/bindings` | Renders it after your prompt: each entry under "Platform Knowledge", then each recipe under "Active Workflows" |
65
- | `input` | How the person entered the message, when they did not type it: `{ mode: 'voice', language }` for one they spoke, with the language the recogniser detected. `@ouispec/agent-react` sets it from `sendMessage(text, { input })` | Adds one line after the conversation: the message was spoken and machine-transcribed, so it may contain recognition errors; the language; and to ask rather than guess when a likely mis-hearing makes the request ambiguous. An unknown mode is read as typed, and a language that is not a BCP 47 tag of at most 16 characters is left out (`readMessageInput` in `@ouispec/agent-core`). A typed message, and the turn an approval card's click starts, get nothing |
66
- | `output` | How the reply reaches the person, when it is not shown as text: `{ mode: 'voice' }` when a voice reads it out, with `voiceDirections: { engine, tags, guidance }` when that voice can be directed by inline tags. The live-call handler sets it from the call's request | Adds one line after the conversation: the reply will be heard, not read, so short plain sentences; no markdown, lists, headings, links, code or emoji; numbers, prices, dates and times written as they are said; anything the person should look at shown through the page's actions rather than read out; and a few words before a slow lookup. With `voiceDirections`, the same line offers the engine's tags, written exactly as given, says they are performed rather than read out and that no other tags are used, and ends with the service's `guidance`. An unknown mode is read as a shown reply, which gets nothing, and malformed directions (an empty tag list, a tag or engine with a control character, guidance over 2,000 characters; `VOICE_DIRECTIONS_LIMITS`) are left out while the reply is still spoken (`readReplyOutput` in `@ouispec/agent-core`). It applies on every turn of a call, the turn that continues an approval included |
65
+ | `input` | How the person entered the message, when they did not type it: `{ mode: 'voice', language }` for one they spoke, with the language the recogniser detected. `@ouispec/agent-react` sets it from `sendMessage(text, { input })` | Adds one line to the turn's context ("How a turn is assembled"): the message was spoken and machine-transcribed, so it may contain recognition errors; the language; and to ask rather than guess when a likely mis-hearing makes the request ambiguous. An unknown mode is read as typed, and a language that is not a BCP 47 tag of at most 16 characters is left out (`readMessageInput` in `@ouispec/agent-core`). A typed message, and the turn an approval card's click starts, get nothing |
66
+ | `output` | How the reply reaches the person, when it is not shown as text: `{ mode: 'voice' }` when a voice reads it out, with `voiceDirections: { engine, tags, guidance }` when that voice can be directed by inline tags. The live-call handler sets it from the call's request | Adds one line to the turn's context: the reply will be heard, not read, so short plain sentences; no markdown, lists, headings, links, code or emoji; numbers, prices, dates and times written as they are said; anything the person should look at shown through the page's actions rather than read out; and a few words before a slow lookup. With `voiceDirections`, the same line offers the engine's tags, written exactly as given, says they are performed rather than read out and that no other tags are used, and ends with the service's `guidance`. An unknown mode is read as a shown reply, which gets nothing, and malformed directions (an empty tag list, a tag or engine with a control character, guidance over 2,000 characters; `VOICE_DIRECTIONS_LIMITS`) are left out while the reply is still spoken (`readReplyOutput` in `@ouispec/agent-core`). It applies on every turn of a call, the turn that continues an approval included |
67
67
 
68
- `timeZone` (the user's IANA zone, which `@ouispec/agent-react` sends with every turn) is read by the worker too: the date and time on the user's clock are added to the turn's user message.
68
+ `timeZone` (the user's IANA zone, which `@ouispec/agent-react` sends with every turn) is read by the worker too: the date and time on the user's clock open the turn's context.
69
69
 
70
- What is true only for this turn (the clock, how the message was entered, how the reply is delivered) goes after the conversation, never in the system prompt or on a message. The system prompt, the tools and every message are the cached prefix, and stay byte for byte the same whatever the turn says, so a conversation's chat turns and call turns read the same prefix. Store `input` with the user's message if your chat shows how a message was entered (`AgentStoredMessage.input`); the history the worker reads needs no copy of it.
70
+ What is true only for this turn (the clock, how the message was entered, how the reply is delivered) is the turn's context: it goes with the turn's message, never in the system prompt or in a stored message ("How a turn is assembled"). The system prompt, the tools and every stored message stay byte for byte the same whatever the turn says, so a conversation's chat turns and call turns read the same prefix. Store `input` with the user's message if your chat shows how a message was entered (`AgentStoredMessage.input`); the history the worker reads needs no copy of it.
71
71
 
72
72
  Every other key is the page's context, which a persona prompt shows as the current UI state ("CURRENT UI CONTEXT", as JSON). A persona whose context is not a page renders it itself: `persona.renderContext(ctx)` returns the section to end the system prompt with, or null (or blank) for none, and is given the context without the four keys above. It renders into the system prompt, the start of the cached prefix, so render nothing that changes from turn to turn unless the conversation's context did. A malformed `oui` or `uiKnowledge` fails the turn, naming the bad field. The worker logs `UI surfaces for this turn` with the surface ids and the knowledge's entry and workflow counts.
73
73
 
74
+ ## How a turn is assembled
75
+
76
+ Each step of a turn (each call to the model: the first, and one after every round of tool calls) sends, in this order:
77
+
78
+ 1. **The system prompt**, with a cache breakpoint, then the page's index (`<page_index>`) when the client has a page, with its own. The same on every step, and on every turn on the same page.
79
+ 2. **The conversation** as the host stored it, ending with the turn's own message: the person's words, or the instruction that stands for them (a call's opening, glance, capture update or device update).
80
+ 3. **The turn's context**, straight after the turn's message: what is true for the whole turn and for no other. In this order: the clock (`<now>`), how the message was entered (`<input>`), how the reply is delivered (`<output>`), whether the model can look at the caller (`<vision>`, a glance's observation included), the photo plans and the running capture (`<capture>`), the device the call is on and whether it can move (`<handoff>`), calls whose approval expired, and the host's `stepContext` (what `getHistory` returns beside the messages: an index of work notes, a dealer's notes on what the customer needs). Every step sends it in the same place, in the same words.
81
+ 4. **The turn's rounds so far**: each round's text and tool calls, then their results. A cache breakpoint moves with the end of the conversation: on the turn's context on the first step, then on the newest result, so each step reads all of the step before it from the cache.
82
+ 5. **What is true for this step only**, after that breakpoint, when there is any: the page's state (`<page_state>`: the page as the user's screen sent it, then as the newest answer that carried it left it) and the step's notes (`<step_note>`: the turn policy's `note`, a forced action, the turn's record after a call that failed, a step that has to plan less).
83
+
84
+ So nothing in the user's role follows a tool result except the page's state and the step's notes, each in its own tags, and a UI answer that gave its state up says where it is. The turn's context never does. Sent after a result, it reads as the person's newest message, and the model answers that instead: Claude Haiku 5.5 with thinking off told a caller "your message came through blank", or went back to an earlier question, and dropped what `look` had said, in 14 to 20 of 20 answers to "What am I wearing?" with the host's notes about "their newest message" and an appointment question still open. With the context beside the turn's message it answered from the look in 20 of 20, with and without a page beside the call (`evals/turn-context.live-eval.ts`). A framed `<turn_context>` block after the result, explained in the system prompt, did no better.
85
+
86
+ What is stored is only the person's message and the model's rounds, so the next turn sends the conversation as the host stored it, without this turn's context. It reads from the cache everything up to this turn's message, and writes this turn's calls and results to it once more, after which they are read like the rest.
87
+
88
+ `turnContextPlacement` (on the runtime config and `AgentWorkerConfig`) chooses where the turn's context goes:
89
+
90
+ | Value | Where | |
91
+ |---|---|---|
92
+ | `'with-message'` (default) | Straight after the turn's message, on every step | Safe for every model. The next turn writes this turn's tool calls and results to the cache once more. |
93
+ | `'after-conversation'` | After the conversation's end on every step, before the step's notes: where 0.30 and earlier sent it | The next turn reads all of this one from the cache. After a tool result, the context reads as the person's newest message. Choose it only for a model that `evals/turn-context.live-eval.ts` (`EVAL_MODEL_ID`) shows answering from its tool results with it. |
94
+
95
+ A placement the worker does not know fails when the adapter is created, naming the ones there are (`TURN_CONTEXT_PLACEMENTS`). Context that should reach the model on one step only goes in a turn policy's `note`, never in `stepContext`.
96
+
74
97
  ## Hooks on every turn
75
98
 
76
99
  Every turn reaches the runtime one of four ways: the Lambda adapter, the container's `/turns`, the live-call handler, or your own code calling `runner.run`. Each hook below runs for all of them, and is told which turn it is called for (`AgentTurnInfo`):
@@ -291,7 +314,7 @@ const liveCall = createLiveCallTurnHandler({
291
314
  resolveTurn: async (request, { signal }) => {
292
315
  const conversation = await findConversationByCallRef(request.clientRef);
293
316
  if (!conversation) return null; // answered 404
294
- // What the person said, redacted; for an opening, a glance or a capture, the instruction that stands for it.
317
+ // What the person said, redacted; for an opening, a glance, a capture or a device update, the instruction that stands for it.
295
318
  const said = request.kind === 'message' ? redactCardNumbers(request.text) : liveCallTurnMessage(request);
296
319
  await storeUserMessage(conversation.id, said, request.input);
297
320
  return {
@@ -333,13 +356,13 @@ process.on('SIGTERM', () => liveCall.close()); // waits for running turns
333
356
  | `sessionId` | The call service's session. |
334
357
  | `clientRef` | Your conversation reference, given to the call service when the call was created. |
335
358
  | `turnId` | Unique per turn; the turn runs under it. |
336
- | `kind` | `message`: the person said `text`. `opening`: the call has just connected, `text` is empty, and the agent greets: the model reads `liveCallOpeningMessage(request)` where the person's words would be (`LIVE_CALL_OPENING_MESSAGE` when no disclosure was sent). `glance`: nobody has spoken for a while and the call service's look noticed something; `text` is empty, `client.vision` carries `remarks` on and the `observation`, and the model reads `LIVE_CALL_GLANCE_MESSAGE` ("Vision"). `capture`: something happened in a photo capture; `text` is empty, `client.capture.update` says what, and the model reads `liveCallCaptureMessage(update)` ("Photo captures"). `liveCallTurnMessage(request)` is what the model reads for any kind, and the row to store for it. |
359
+ | `kind` | `message`: the person said `text`. `opening`: the call has just connected, `text` is empty, and the agent greets: the model reads `liveCallOpeningMessage(request)` where the person's words would be (`LIVE_CALL_OPENING_MESSAGE` when no disclosure was sent). `glance`: nobody has spoken for a while and the call service's look noticed something; `text` is empty, `client.vision` carries `remarks` on and the `observation`, and the model reads `LIVE_CALL_GLANCE_MESSAGE` ("Vision"). `capture`: something happened in a photo capture; `text` is empty, `client.capture.update` says what, and the model reads `liveCallCaptureMessage(update)` ("Photo captures"). `device`: something happened to the caller's devices (the call moved, came back, was disconnected or lost); `text` is empty, `client.handoff.update` says what, and the model reads `liveCallDeviceMessage(update)` ("Moving the call to another device"). `liveCallTurnMessage(request)` is what the model reads for any kind, and the row to store for it. |
337
360
  | `text` | What the person said, as transcribed; at most 8,000 characters. |
338
361
  | `input` | `{ mode: 'voice', language? }` for what the person said: set as the turn's `context.input`, so the model is told it was transcribed. `{ mode: 'text' }` for a message they typed during the call: read as typed, with no `context.input`. Dropped on an `opening`. |
339
362
  | `output` | `{ mode: 'voice', voiceDirections? }`: set as the turn's `context.output`, so the model writes for the ear, and may use the voice's tags when `voiceDirections: { engine, tags, guidance }` offers them ("What a UI client sends with a turn"). |
340
363
  | `disclosureLine` | On an `opening`: what the call service has just said to the person before the greeting (that they are talking with an AI assistant), as spoken; at most 1,000 characters. The model is told it was said, and greets following on from it without repeating it. Not read on a `message`. |
341
364
  | `supersedes` | Turns this one replaces. Each still running in this process is stopped at once, and the turn's `getHistory` is given them to wait for, as for any superseding message. |
342
- | `client` | `{ ui, vision, capture }`. `ui`: the person's page, when it sent its UI into the call (Closure's `<LiveCall uiContext>`), as its typed turns carry it: `{ buildId?, currentPath?, oui?, uiKnowledge? }`, at most 64 KiB (`LIVE_CALL_LIMITS.clientUiBytes`). Its `oui`, `uiKnowledge` and `currentPath` go on the turn's context under those names, so the turn's UI tools are the page's and its UI actions reach that page through the room, as on a typed turn; a key your target's `context` sets itself is kept. `buildId` stays on `request.client.ui`, for your `resolveTurn` to check against the build you expect. Fields it does not know are read past. Absent, or `ui: null`, for a call with no page (a phone call): the turn has only your context. `vision`: whether and how the character may look at the caller's camera ("Vision"). `capture`: the session's photo plans, the route the capture tools call, the capture running now and what happened in it ("Photo captures"). |
365
+ | `client` | `{ ui, vision, capture, handoff }`. `ui`: the person's page, when it sent its UI into the call (Closure's `<LiveCall uiContext>`), as its typed turns carry it: `{ buildId?, currentPath?, oui?, uiKnowledge? }`, at most 64 KiB (`LIVE_CALL_LIMITS.clientUiBytes`). Its `oui`, `uiKnowledge` and `currentPath` go on the turn's context under those names, so the turn's UI tools are the page's and its UI actions reach that page through the room, as on a typed turn; a key your target's `context` sets itself is kept. `buildId` stays on `request.client.ui`, for your `resolveTurn` to check against the build you expect. Fields it does not know are read past. Absent, or `ui: null`, for a call with no page (a phone call): the turn has only your context. `vision`: whether and how the character may look at the caller's camera ("Vision"). `capture`: the session's photo plans, the route the capture tools call, the capture running now and what happened in it ("Photo captures"). `handoff`: the route `call_handoff` calls, the device the call is live on, an open offer, and what happened to the caller's devices ("Moving the call to another device"). |
343
366
 
344
367
  `readLiveCallTurnRequest` reads a body as the handler does, and `LIVE_CALL_LIMITS` holds its limits.
345
368
 
@@ -349,7 +372,7 @@ process.on('SIGTERM', () => liveCall.close()); // waits for running turns
349
372
  |---|---|---|
350
373
  | `text` | `{ text }` | The reply; concatenate the pieces. With `speak: 'all'`, as the model writes it: rounds written between tool calls are separated by a blank line, as in the room. With `final-round`, the holding line and the turn's last round. |
351
374
  | `readback` | `{ approvalId, text, expiresAt }` | The turn stopped at a call that needs approval. `text` is the preview's `spokenReadback` when your `approvals.preview` wrote one, else its `readback`, verbatim; `expiresAt` is ISO 8601. Sent once the turn has ended by itself, after all of its text. A turn that was stopped withdrew its approval, and sends none. |
352
- | `done` | `{ stopReason? }` | The turn is over: `complete`, `awaiting_approval`, `present_options`, `time_limit`, `output_limit` or `step_count` when it ended by itself; `user_stop`, `superseded` or `deadline` when it was stopped. A turn whose reply is nothing (a glance with nothing worth a remark, a capture update not worth a word) is `done` alone, with no `text` before it: silence. |
375
+ | `done` | `{ stopReason? }` | The turn is over: `complete`, `awaiting_approval`, `present_options`, `time_limit`, `output_limit` or `step_count` when it ended by itself; `user_stop`, `superseded` or `deadline` when it was stopped. A turn whose reply is nothing (a glance with nothing worth a remark, a capture or device update not worth a word) is `done` alone, with no `text` before it: silence. |
353
376
  | `error` | `{ code, message }` | The turn failed or did not run: `RATE_LIMIT`, `SERVICE_UNAVAILABLE`, `MODEL_TIMEOUT`, `TURN_TIMEOUT`, `TURN_DEADLINE_EXCEEDED`, `TURN_REFUSED` (your turn record refused it), `TURN_DECLINED` (your `beforeTurn` refused it) or `WORKER_ERROR`. `message` is a fixed line for the code; the cause stays in your logs. |
354
377
 
355
378
  The stream is written from the turn's own events as the room receives them (`TurnHost.observe`): the same text, from the same model call. Before the stream opens, a refusal is a status and `{ error: { code, message } }`: `400 INVALID_REQUEST` naming the field, `401 UNAUTHORIZED`, `404 UNKNOWN_CLIENT_REF`, `405`, `409 TURN_RUNNING`, `413 BODY_TOO_LARGE`, `415`, `500 RESOLVE_FAILED` (your `resolveTurn` threw, or returned a target that is not a turn; nothing ran) and `503 UNAVAILABLE`.
@@ -365,7 +388,7 @@ The stream is written from the turn's own events as the room receives them (`Tur
365
388
  `seeing`: the character may see the caller; `remarks`: it may bring up what it sees unprompted (false whenever `seeing` is). `canLook`: it can look now, through `look` (true only with `seeing` and a `look`; the call service sends it only to a brain whose endpoint declares `acceptsVision`). `absent` says why it cannot: `camera_off`, or `turned_off` (the caller or the session turned vision off, with `seeing: false`). `look` is the call service's look route and a token for this session only, sent only over https (or to this machine). It is read as strictly as `client.ui`: a wrong field answers `400` naming it, and no refusal repeats the token. A `frame` from a call service before §2.9 is read past. The handler sets it as the turn payload's `vision` (`TurnVision`; any turn can carry one, `payloadRefusal` checks it), and the worker gives the model:
366
389
 
367
390
  - with `canLook`, the **`look` tool** (`lookTool`, the SDK's `vision` tool class, a `view`): `look({ question, frames? })`, a question of at most 500 characters about the picture and 1–4 of the newest pictures (default 1). It `POST`s `{ question, frames? }` to `look.url` with `Authorization: Bearer <token>`. The answer, `{ looked: true, answer, frames, newestAgeMs }`, reaches the model beside the call's result for that call only: the stored result is `{ looked: true, pictures, newestSecondsAgo }`, so a later turn that needs to see looks again. `{ looked: false, absent }` (`camera_off`, `turned_off`, `no_picture`) is a result that says why there was nothing to see. A `409` (the call is no longer live), `429` (more than 20 looks a minute), any other refusal, a timeout (20 s) or an expired token fails the call with what to do instead, never with the route's own words. A host tool named `look` gives way to it; a tool policy that admits by name should admit the `vision` class;
368
- - one line after the conversation's cache breakpoint, with what else is true only for this turn: "You can look at the caller with `look` when the conversation calls for it: they ask about how they look or what is around them, they show you something, or a glance offers it. Do not look otherwise." (`LOOK_WHEN`), that it describes only what the look said; with `remarks`, that it may also remark unprompted on something significant or compliment what they wear, at most once about their appearance in its greeting and never the same remark twice; without, that it brings up nothing it sees unless asked; and always, that it never infers or names sensitive traits (ethnicity, health or disability, religion, sexual orientation, a guessed age or weight), never identifies anyone from their face and never comments on a body;
391
+ - one line in the turn's context, with what else is true only for this turn: "You can look at the caller with `look` when the conversation calls for it: they ask about how they look or what is around them, they show you something, or a glance offers it. Do not look otherwise." (`LOOK_WHEN`), that it describes only what the look said; with `remarks`, that it may also remark unprompted on something significant or compliment what they wear, at most once about their appearance in its greeting and never the same remark twice; without, that it brings up nothing it sees unless asked; and always, that it never infers or names sensitive traits (ethnicity, health or disability, religion, sexual orientation, a guessed age or weight), never identifies anyone from their face and never comments on a body;
369
392
  - without `canLook`, a line that it cannot see the caller and why, so it never claims to.
370
393
 
371
394
  A **glance** is the call service's look between turns: nobody has spoken for a while, and its own look noticed something worth a remark. `text` is empty, `remarks` is on, and `client.vision.observation` is that one sentence. The model reads `LIVE_CALL_GLANCE_MESSAGE` where the person's words would be and the observation in the turn's vision line, as data (never an instruction), and phrases one short remark, looking first if it needs more; or it says nothing, and the stream is `done` with no `text` event: the call stays silent. Store `liveCallTurnMessage(request)` for it as you store an opening's message: the observation is never in it, and is read on a glance only. A history that kept the glance as its empty `text` is read past (a blank message with no files is never sent to the provider). A glance without `remarks`, or without an observation, answers `400`. An opening carries no picture: a greeting that compliments the caller looks first.
@@ -391,7 +414,7 @@ Set `acceptsCapture: true` on your brain endpoint once you run this version: the
391
414
  - `capture_stop({ reason? })` (a `mutate`): `POST {url}/{captureId}/stop` with `{ reason? }` (at most 200 characters).
392
415
 
393
416
  Each result is `{ captureId, status, outcome?, words }`: the route's `words`, one or two sentences, are what the model says from. A refusal fails with a line chosen by its code, never the route's own words: `CAPTURE_IN_PROGRESS` is "A photo capture is already running; use capture_status.", `RESUME_NOT_ALLOWED` says why by `details.why`, `CAPTURE_AGENT_UNAVAILABLE` gives Closure's `details.words` (its offer included), and `SESSION_NOT_LIVE`, `NO_ROOM_AGENT`, `CAPTURE_PLAN_NOT_FOUND`, `RATE_LIMITED`, `401`/`403`, a timeout (20 s) or an expired token each say what to do instead. No tool returns a picture. A host tool of the same name gives way to them; a tool policy that admits by name should admit the `capture` class;
394
- - one line after the conversation's cache breakpoint: "You can ask the caller for photos with `capture_start` when a plan below fits. Closure’s checker accepts or rejects every photo; you never judge a photo, and you never use `look` for one. While a capture runs you receive capture updates: turn each into one or two short, natural sentences in the caller’s language, and never read out a code. When a capture ends without completing, offer what its update says to offer." (`CAPTURE_WHEN`, the clause Closure's own brain is given), that a plan is offered only when its "offer it when" applies, that it never sees a photo and never claims to (`CAPTURE_NEVER`), the plans, and where the running capture stands. Without a `control` route the tools are not offered, and the line says photos cannot be started from this turn.
417
+ - one line in the turn's context: "You can ask the caller for photos with `capture_start` when a plan below fits. Closure’s checker accepts or rejects every photo; you never judge a photo, and you never use `look` for one. While a capture runs you receive capture updates: turn each into one or two short, natural sentences in the caller’s language, and never read out a code. When a capture ends without completing, offer what its update says to offer." (`CAPTURE_WHEN`, the clause Closure's own brain is given), that a plan is offered only when its "offer it when" applies, that it never sees a photo and never claims to (`CAPTURE_NEVER`), the plans, and where the running capture stands. Without a `control` route the tools are not offered, and the line says photos cannot be started from this turn.
395
418
 
396
419
  A **capture** turn passes on what happened in a capture: consent asked, given or declined, the camera, each step, a hint, a photo accepted or rejected, a step skipped or failed, the end. `text` is empty and `client.capture.update` is the words, for example `Odometer accepted: 48,212 mi.` The model reads `liveCallCaptureMessage(update)` where the person's words would be: the update in a `<capture_update>` tag, as data, and the instruction to say it in one or two short sentences, or to say nothing, and the stream is `done` with no `text` event. Every capture that ends without completing (declined, unanswered, the camera blocked or missing, stopped, out of retries, timed out, the guide or the checker unavailable) ends its words with `Offer: …`, the plan's own offer (a link to finish on the caller's phone, say), and the model is told to say what is missing without pushing and to make that offer. Store `liveCallTurnMessage(request)` for the turn, as for an opening: it is a readable row with what happened, so later turns know which photos were taken. An update can also ride a `message` turn (the caller spoke first): it then reaches the model in the turn's capture line, for that turn only, and the person's message is stored as it is. A capture turn without an update answers `400`.
397
420
 
@@ -399,6 +422,30 @@ The capture's names and values are those of Closure's capture contract (`@closur
399
422
 
400
423
  The token is never logged or emitted, and neither are an update's words: the turn's log lines carry facts only, `capture: { plans, canStart, active?, step?, update? }`. Nothing changes for a host but the opt-in and the stored row: `resolveTurn` sees `request.client.capture` and need not touch it.
401
424
 
425
+ A capture can say why it is `blocked`: `active.blockedReason` is `camera_denied` or `no_rear_camera` (`CAPTURE_BLOCKED_REASONS`). With `no_rear_camera`, the call can move to the caller's phone, and the capture's words say to offer it with `call_handoff` ("Moving the call to another device").
426
+
427
+ **Moving the call to another device.** A caller on a laptop can carry the same call on to their phone (Closure Studio's call hand-off): the character offers it, a QR code appears on the laptop's screen, the phone opens the link on your own site, and the same conversation carries on there while the laptop pauses. Nothing moves on the server: the session, the room, your conversation and a running capture are the same throughout. The character never sees a device, a screen or a code: everything it learns of a move is words, and it never gets the code or the link.
428
+
429
+ Set `acceptsHandoff: true` on your brain endpoint once you run this version: the call service then sends every turn of a session whose call can move `client.handoff`, and sends `device` turns. A worker before it answers a `device` turn `400` (`kind must be one of message, opening, glance, capture`), which is why the call service sends neither without the opt-in. Without it, the caller can still move the call with their own **Continue on phone** control; your brain is simply not told.
430
+
431
+ ```json
432
+ { "control": { "url": "https://…/api/v1/sessions/{id}/handoffs", "token": "lhb1.…", "expiresAt": "2026-11-18T11:16:30.000Z" },
433
+ "device": { "formFactor": "desktop", "switches": 0 },
434
+ "offer": { "handoffId": "3c1d9e2a-…", "purpose": "photos", "expiresAt": "2026-11-18T10:26:30.000Z" },
435
+ "update": null }
436
+ ```
437
+
438
+ `control` is the call service's hand-offs route for the session and an `lhb1` token for it, sent only over https (or to this machine), with no query. `device` is the device the call is live on (`formFactor` one of `CALL_FORM_FACTORS`: `phone`, `tablet`, `desktop`, `unknown`) and how many times the call has switched devices, or null while no device is live. `offer` is the code on the caller's screen now, or null. `update` is what happened since the brain last heard, in Closure's words: the updates pending since then, joined in order, each at most `DEVICE_UPDATE_TEXT_MAX` (600) characters; the whole at most 8,000. It is read as strictly as `client.capture`: a wrong field answers `400` naming it, and no refusal repeats the token. The handler sets it as the turn payload's `handoff` (`TurnHandoff`; `payloadRefusal` checks it), and the worker gives the model:
439
+
440
+ - while there is a `control` route, the **hand-off tool** `call_handoff({ purpose })` (`handoffTool`, the SDK's `handoff` tool class, `kind: 'backend'`, a `mutate`): `POST {url}` with `{ purpose }` and `Authorization: Bearer <token>`. `purpose` is `photos` (a photo capture needs a phone's rear camera), `caller_asked` (the caller asked to continue on their phone) or `other` (`CALL_HANDOFF_PURPOSES`). The result is `{ handoffId, status, words }`: the route's `words` are what the model says from ("A QR code is on their screen. Tell them to scan it with their phone's camera…"). It never carries the code or the link, even if an answer did. A refusal fails with a line chosen by its code, never the route's own words (`HANDOFF_REFUSALS`): `HANDOFF_UNAVAILABLE` is "This call can't move to another device.", `HANDOFF_UNSUPPORTED_CALL` is "This call's app can't move to another device.", `RATE_LIMITED` is "A code was offered several times already; ask them to use the one on their screen.", and `SESSION_NOT_LIVE`, `NO_ACTIVE_DEVICE`, `HANDOFF_TOKEN_WRONG_SESSION`, `401`/`403`, a timeout (15 s) or an expired token each say what to do instead. A host tool of the same name gives way to it; a tool policy that admits by name should admit the `handoff` class;
441
+ - one line in the turn's context: "You can move this call to the caller's phone with `call_handoff`. Offer it when photos need a rear camera this device lacks, or when the caller would be better off on their phone, and call it once they agree. A QR code then appears on their screen. Never read out a code or a link. While the call moves you receive device updates: answer each with one short sentence, or with nothing." (`HANDOFF_WHEN`, the clause Closure's own brain is given), that it never sees the caller's devices, their screen or the code and never claims to (`HANDOFF_NEVER`), the device the call is live on and how often it has moved, and the open offer. Without a `control` route the tool is not offered, and the line says the call cannot be moved from this turn.
442
+
443
+ A **device** turn passes on what happened to the caller's devices (`CALL_DEVICE_UPDATE_KINDS`): a code offered from the caller's own control (`offered`), the call moved to the device that redeemed it (`switched`), brought back (`brought_back`), the other device disconnected by "That wasn't me" (`revoked`), a code that expired unused (`expired`), or the live device lost (`active_lost`). `text` is empty and `client.handoff.update` is the words, for example `The caller moved the call to their phone. Their computer is paused. Carry on where you left off.` The model reads `liveCallDeviceMessage(update)` where the person's words would be: the update in a `<device_update>` tag, as data, and the instruction to answer it in one short sentence, or to say nothing, and the stream is `done` with no `text` event. Capture updates that arrived with it ride the same turn: its message is then `liveCallDeviceMessage(update)` followed by `liveCallCaptureMessage(client.capture.update)`. Store `liveCallTurnMessage(request)` for the turn, as for a capture: it is a readable row with which device the call moved to. An update can also ride a `message` turn (the caller spoke first): it then reaches the model in the turn's hand-off line, for that turn only. A device turn without an update answers `400`.
444
+
445
+ The hand-off's names and values are those of Closure's hand-off contract (`@closurestudio/realtime-contracts`, `live-call-devices`), exported here without depending on it: `CALL_HANDOFF_PURPOSES` / `CallHandoffPurpose`, `CALL_FORM_FACTORS` / `CallFormFactor`, `CALL_HANDOFF_STATUSES` / `CallHandoffStatus`, `CALL_DEVICE_UPDATE_KINDS` / `CallDeviceUpdateKind`, `DEVICE_UPDATE_TEXT_MAX` (600) and `HANDOFF_CODE_TTL_S` (600).
446
+
447
+ The token is never logged or emitted, and neither are an update's words: the turn's log lines carry facts only, `handoff: { canOffer, device, switches?, offer?, update? }`. Nothing changes for a host but the opt-in and the stored row: `resolveTurn` sees `request.client.handoff` and need not touch it.
448
+
402
449
  **Barge-in.** When the person speaks over the reply, the call service closes the connection. The turn is stopped as a superseding message stops it (`stopReason: 'superseded'`): what it had produced is stored with the mark and announced to the room, and the next request names it in `supersedes`. A stop asked for through the realtime server (the person's Stop on a page) is heard too, and that stream ends with `done`.
403
450
 
404
451
  Keep the turn's deadline (`turnDeadlineMs`) and the model to a call's pace: a voice turn waits on its first `text` event, so run it on the container adapter, never behind a queue.
@@ -470,5 +517,5 @@ Header parameters are never model input: `actAs` supplies them, and a call fails
470
517
  - `pnpm test` includes the fixture turn. It runs on both adapters and on two providers, replaying recorded responses through each provider's real `ai` package, against the SDK realtime server on Redis.
471
518
  - `pnpm record:fixture-turn` re-records the Bedrock responses from a live model.
472
519
  - `pnpm eval:live` runs the live operating-rules eval.
473
- - `@ouispec/agent-worker/testing` has what a product's own tests use: `recordingFetch` and `replayingFetch` (recorded model responses through a provider's real package), `scriptedChatCompletions` (a model whose every answer a test states), `conversationOf` (a request's conversation without the step's tail), and the Desk fixture API.
520
+ - `@ouispec/agent-worker/testing` has what a product's own tests use: `recordingFetch` and `replayingFetch` (recorded model responses through a provider's real package), `scriptedChatCompletions` (a model whose every answer a test states), `conversationOf` (a request’s conversation without the turn’s context and the step’s tail), and the Desk fixture API.
474
521
  - Both of those live commands need Bedrock credentials in the environment.
@@ -31,7 +31,8 @@ export interface ToolPolicyContext {
31
31
  toolKind: 'ui' | 'backend';
32
32
  /**
33
33
  * The SDK's class for a tool it owns: `attachment` for the attachment
34
- * tools, `vision` for `look`, `capture` for the capture tools. A policy that
34
+ * tools, `vision` for `look`, `capture` for the capture tools, `handoff`
35
+ * for `call_handoff`. A policy that
35
36
  * admits by name should admit the
36
37
  * class too, so a tool the SDK adds to it later needs no change.
37
38
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tool-policy.d.ts","sourceRoot":"","sources":["../../src/authz/tool-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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AO,CAAC,kBAAkB,CAAC,CAU7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"tool-policy.js","sourceRoot":"","sources":["../../src/authz/tool-policy.ts"],"names":[],"mappings":"AAkEA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAe;IAC3C,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAgB,EAAE,CAAC;CACrD,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAkB,EAClB,GAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC;QAChF,OAAO;YACL,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,2CAA2C,OAAO,EAAE;SAC7D,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"tool-policy.js","sourceRoot":"","sources":["../../src/authz/tool-policy.ts"],"names":[],"mappings":"AAmEA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAe;IAC3C,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAgB,EAAE,CAAC;CACrD,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAkB,EAClB,GAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC;QAChF,OAAO;YACL,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,2CAA2C,OAAO,EAAE;SAC7D,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The hand-off tool: the character moves the call to the caller's phone
3
+ *.
4
+ *
5
+ * The turn's `client.handoff.control` names studio-api's hand-offs route for
6
+ * the session (H1, `POST /sessions/{sessionId}/handoffs`) and an `lhb1` token
7
+ * for it. `call_handoff({ purpose })` calls it as the capture tools call
8
+ * theirs: studio-api mints a single-use code, and the caller's LiveCall shows
9
+ * it as a QR code on their screen. The route answers an `lhb1` caller without
10
+ * the link, and the tool would drop one if it came: the model never gets the
11
+ * code or the link, so it can never read one out.
12
+ *
13
+ * The result is the route's answer's `words` with the hand-off's id and
14
+ * status. A refusal fails with a line chosen by its code, never the route's
15
+ * own message. The token is never logged or emitted.
16
+ */
17
+ import type { RegisteredTool } from '../tools/types.js';
18
+ import { type TurnHandoff } from '../prompt/handoff.js';
19
+ export declare const CALL_HANDOFF_TOOL = "call_handoff";
20
+ /** The SDK's class for the hand-off tool, as a host's tool policy sees it. */
21
+ export declare const HANDOFF_TOOL_CLASS = "handoff";
22
+ /** Limits on a hand-off call. */
23
+ export declare const HANDOFF_TOOL_LIMITS: {
24
+ /** The longest words the tool gives the model. */
25
+ readonly wordsChars: 2000;
26
+ /** The longest `handoffId` read from an answer. */
27
+ readonly handoffIdChars: 128;
28
+ /** How long a call may take: studio-api mints the code and sends it to the caller's screen. */
29
+ readonly timeoutMs: 15000;
30
+ };
31
+ /** The lines the hand-off contract gives a refusal, by code. */
32
+ export declare const HANDOFF_REFUSALS: {
33
+ readonly HANDOFF_UNAVAILABLE: "This call can't move to another device.";
34
+ readonly HANDOFF_UNSUPPORTED_CALL: "This call's app can't move to another device.";
35
+ readonly RATE_LIMITED: "A code was offered several times already; ask them to use the one on their screen.";
36
+ /** The call has ended: nothing to say. */
37
+ readonly SESSION_NOT_LIVE: "The call has already ended. Say nothing about moving it.";
38
+ readonly NO_ACTIVE_DEVICE: "Their device isn't connected to the call right now, so it can't move yet. Wait until they're back, then offer it again.";
39
+ readonly NOT_ALLOWED: "This call can't move to another device right now. Go on without it.";
40
+ readonly FAILED: "Moving the call failed just now. Go on; you may offer it again in a little while.";
41
+ };
42
+ /** The tool's description: when to offer, and that the code and link are never the model's. */
43
+ export declare const CALL_HANDOFF_DESCRIPTION: string;
44
+ /**
45
+ * Builds the turn's hand-off tool, bound to its control route and token: none
46
+ * unless the turn has a route (`canHandoff`).
47
+ */
48
+ export declare function handoffTool(handoff: TurnHandoff | null | undefined, options?: {
49
+ fetch?: typeof fetch;
50
+ }): RegisteredTool[];
51
+ //# sourceMappingURL=handoff-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff-tool.d.ts","sourceRoot":"","sources":["../../src/handoff/handoff-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C,iCAAiC;AACjC,eAAO,MAAM,mBAAmB;IAC9B,kDAAkD;;IAElD,mDAAmD;;IAEnD,+FAA+F;;CAEvF,CAAC;AA4CX,gEAAgE;AAChE,eAAO,MAAM,gBAAgB;;;;IAI3B,0CAA0C;;;;;CAKlC,CAAC;AA2BX,+FAA+F;AAC/F,eAAO,MAAM,wBAAwB,QAKqE,CAAC;AAE3G;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CAAO,GAAG,cAAc,EAAE,CAwD7H"}
@@ -0,0 +1,146 @@
1
+ import { CALL_HANDOFF_PURPOSES, CALL_HANDOFF_STATUSES, canHandoff, } from '../prompt/handoff.js';
2
+ export const CALL_HANDOFF_TOOL = 'call_handoff';
3
+ /** The SDK's class for the hand-off tool, as a host's tool policy sees it. */
4
+ export const HANDOFF_TOOL_CLASS = 'handoff';
5
+ /** Limits on a hand-off call. */
6
+ export const HANDOFF_TOOL_LIMITS = {
7
+ /** The longest words the tool gives the model. */
8
+ wordsChars: 2_000,
9
+ /** The longest `handoffId` read from an answer. */
10
+ handoffIdChars: 128,
11
+ /** How long a call may take: studio-api mints the code and sends it to the caller's screen. */
12
+ timeoutMs: 15_000,
13
+ };
14
+ const HANDOFF_ID = new RegExp(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,${HANDOFF_TOOL_LIMITS.handoffIdChars - 1}}$`);
15
+ const fail = (error) => ({ success: false, error });
16
+ function isPlainObject(value) {
17
+ return !!value && typeof value === 'object' && !Array.isArray(value);
18
+ }
19
+ /** Words the model is given: trimmed and bounded. */
20
+ function wordsOf(value) {
21
+ if (typeof value !== 'string' || !value.trim())
22
+ return null;
23
+ return value.trim().slice(0, HANDOFF_TOOL_LIMITS.wordsChars);
24
+ }
25
+ function readAnswer(body) {
26
+ if (!isPlainObject(body))
27
+ return null;
28
+ const words = wordsOf(body.words);
29
+ if (typeof body.handoffId !== 'string' || !HANDOFF_ID.test(body.handoffId) || !words)
30
+ return null;
31
+ if (!CALL_HANDOFF_STATUSES.includes(body.status))
32
+ return null;
33
+ // Only these three: never `url`, which an API key's answer carries and the model must never have.
34
+ return { handoffId: body.handoffId, status: body.status, words };
35
+ }
36
+ function readRefusal(status, body) {
37
+ const outer = isPlainObject(body) ? body : {};
38
+ const inner = isPlainObject(outer.error) ? outer.error : outer;
39
+ return { status, code: typeof inner.code === 'string' ? inner.code : null };
40
+ }
41
+ /** The lines the hand-off contract gives a refusal, by code. */
42
+ export const HANDOFF_REFUSALS = {
43
+ HANDOFF_UNAVAILABLE: "This call can't move to another device.",
44
+ HANDOFF_UNSUPPORTED_CALL: "This call's app can't move to another device.",
45
+ RATE_LIMITED: 'A code was offered several times already; ask them to use the one on their screen.',
46
+ /** The call has ended: nothing to say. */
47
+ SESSION_NOT_LIVE: 'The call has already ended. Say nothing about moving it.',
48
+ NO_ACTIVE_DEVICE: "Their device isn't connected to the call right now, so it can't move yet. Wait until they're back, then offer it again.",
49
+ NOT_ALLOWED: "This call can't move to another device right now. Go on without it.",
50
+ FAILED: 'Moving the call failed just now. Go on; you may offer it again in a little while.',
51
+ };
52
+ /** What the model is told of a refusal: a line chosen by its code (else its status), never the route's own words. */
53
+ function refusalLine(refusal) {
54
+ switch (refusal.code) {
55
+ case 'HANDOFF_UNAVAILABLE':
56
+ case 'HANDOFF_UNSUPPORTED_CALL':
57
+ case 'RATE_LIMITED':
58
+ case 'SESSION_NOT_LIVE':
59
+ case 'NO_ACTIVE_DEVICE':
60
+ return HANDOFF_REFUSALS[refusal.code];
61
+ case 'HANDOFF_TOKEN_WRONG_SESSION':
62
+ return HANDOFF_REFUSALS.NOT_ALLOWED;
63
+ }
64
+ switch (refusal.status) {
65
+ case 401:
66
+ case 403:
67
+ return HANDOFF_REFUSALS.NOT_ALLOWED;
68
+ case 409:
69
+ return HANDOFF_REFUSALS.HANDOFF_UNAVAILABLE;
70
+ case 429:
71
+ return HANDOFF_REFUSALS.RATE_LIMITED;
72
+ default:
73
+ return HANDOFF_REFUSALS.FAILED;
74
+ }
75
+ }
76
+ /** The tool's description: when to offer, and that the code and link are never the model's. */
77
+ export const CALL_HANDOFF_DESCRIPTION = 'Moves this live call to the caller’s phone: a QR code appears on their screen, they scan it with their phone’s camera, ' +
78
+ 'and the same conversation carries on there while this device pauses. ' +
79
+ 'Offer it when photos need a rear camera this device lacks, or when the caller would be better off on their phone, and call it once they agree. ' +
80
+ 'You never get the code or the link, and you never read one out: tell them to scan the code on their screen. ' +
81
+ 'A code works once, for 10 minutes; call this again only when they ask for a new one or it has expired.';
82
+ /**
83
+ * Builds the turn's hand-off tool, bound to its control route and token: none
84
+ * unless the turn has a route (`canHandoff`).
85
+ */
86
+ export function handoffTool(handoff, options = {}) {
87
+ if (!canHandoff(handoff))
88
+ return [];
89
+ const send = options.fetch ?? fetch;
90
+ const control = handoff.control;
91
+ const offer = {
92
+ name: CALL_HANDOFF_TOOL,
93
+ toolClass: HANDOFF_TOOL_CLASS,
94
+ kind: 'backend',
95
+ effect: 'mutate',
96
+ description: CALL_HANDOFF_DESCRIPTION,
97
+ inputSchema: {
98
+ type: 'object',
99
+ properties: {
100
+ purpose: {
101
+ type: 'string',
102
+ enum: [...CALL_HANDOFF_PURPOSES],
103
+ description: "Why the call moves: 'photos' when a photo capture needs a phone's rear camera; 'caller_asked' when the caller asked to continue on their phone; 'other' otherwise.",
104
+ },
105
+ },
106
+ required: ['purpose'],
107
+ additionalProperties: false,
108
+ },
109
+ execute: async (input, ctx) => {
110
+ const purpose = input.purpose;
111
+ if (typeof purpose !== 'string' || !CALL_HANDOFF_PURPOSES.includes(purpose)) {
112
+ return fail(`"purpose" is one of ${CALL_HANDOFF_PURPOSES.map((p) => `"${p}"`).join(', ')}.`);
113
+ }
114
+ if (Date.parse(control.expiresAt) <= Date.now())
115
+ return fail(HANDOFF_REFUSALS.NOT_ALLOWED);
116
+ const timeout = AbortSignal.timeout(HANDOFF_TOOL_LIMITS.timeoutMs);
117
+ const signal = ctx.abortSignal ? AbortSignal.any([ctx.abortSignal, timeout]) : timeout;
118
+ let res;
119
+ try {
120
+ res = await send(control.url, {
121
+ method: 'POST',
122
+ headers: { authorization: `Bearer ${control.token}`, accept: 'application/json', 'content-type': 'application/json' },
123
+ body: JSON.stringify({ purpose: purpose }),
124
+ signal,
125
+ redirect: 'error',
126
+ });
127
+ }
128
+ catch (err) {
129
+ // The turn's stop is said by the orchestrator; a timeout or a lost connection is said here.
130
+ if (ctx.abortSignal?.aborted)
131
+ throw err;
132
+ return fail(HANDOFF_REFUSALS.FAILED);
133
+ }
134
+ // A body that is not JSON reads as no answer: a failure, or a refusal known only by its status.
135
+ const parsed = await res.json().catch(() => null);
136
+ if (!res.ok)
137
+ return fail(refusalLine(readRefusal(res.status, parsed)));
138
+ const answer = readAnswer(parsed);
139
+ if (!answer)
140
+ return fail(HANDOFF_REFUSALS.FAILED);
141
+ return { success: true, data: { handoffId: answer.handoffId, status: answer.status, words: answer.words } };
142
+ },
143
+ };
144
+ return [offer];
145
+ }
146
+ //# sourceMappingURL=handoff-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff-tool.js","sourceRoot":"","sources":["../../src/handoff/handoff-tool.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,UAAU,GAKX,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEhD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,iCAAiC;AACjC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,kDAAkD;IAClD,UAAU,EAAE,KAAK;IACjB,mDAAmD;IACnD,cAAc,EAAE,GAAG;IACnB,+FAA+F;IAC/F,SAAS,EAAE,MAAM;CACT,CAAC;AAeX,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,iCAAiC,mBAAmB,CAAC,cAAc,GAAG,CAAC,IAAI,CAAC,CAAC;AAE3G,MAAM,IAAI,GAAG,CAAC,KAAa,EAAuB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAEjF,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED,qDAAqD;AACrD,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI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  export type { AgentWorkerConfig, AgentTurnInput, AgentTurnResult, TurnMessage, TurnHistoryMessage, ToolCallRef, SystemPromptContext } from './types.js';
10
10
  export { historyOf } from './history.js';
11
+ export { TURN_CONTEXT_PLACEMENTS } from './step-messages.js';
12
+ export type { TurnContextPlacement } from './step-messages.js';
11
13
  export type { RealtimeEmitAdapter } from './emit/types.js';
12
14
  export { filterEmitAdapter } from './emit/filter.js';
13
15
  export type { TurnEventFilter } from './emit/filter.js';
@@ -83,16 +85,19 @@ export { startContainerAgentWorker, DEFAULT_LIVE_CALL_PATH } from './container/s
83
85
  export type { ContainerAgentConfig, ContainerAgentWorker, ContainerLiveCallRoute } from './container/server.js';
84
86
  export { createLiveCallTurnHandler, liveCallTurnMessage, LIVE_CALL_SPEECH, LIVE_CALL_CHANNEL, LIVE_CALL_APPROVAL_CHANNELS, LIVE_CALL_MAX_BODY_BYTES, } from './live-call/handler.js';
85
87
  export type { LiveCallSpeech, LiveCallApprovalChannel, LiveCallTurnHandler, LiveCallTurnHandlerConfig, LiveCallTurnOptions, LiveCallTurnTarget, LiveCallTurnCallContext, LiveCallTurnMessageSource, } from './live-call/handler.js';
86
- export { readLiveCallTurnRequest, liveCallError, LIVE_CALL_TURN_KINDS, LIVE_CALL_OPENING_MESSAGE, LIVE_CALL_GLANCE_MESSAGE, liveCallCaptureMessage, liveCallOpeningMessage, LIVE_CALL_TYPED_INPUT_MODE, LIVE_CALL_LIMITS, LIVE_CALL_ERROR_MESSAGES, } from './live-call/protocol.js';
88
+ export { readLiveCallTurnRequest, liveCallError, LIVE_CALL_TURN_KINDS, LIVE_CALL_OPENING_MESSAGE, LIVE_CALL_GLANCE_MESSAGE, liveCallCaptureMessage, liveCallDeviceMessage, liveCallOpeningMessage, LIVE_CALL_TYPED_INPUT_MODE, LIVE_CALL_LIMITS, LIVE_CALL_ERROR_MESSAGES, } from './live-call/protocol.js';
87
89
  export type { LiveCallTurnKind, LiveCallTurnRequest, LiveCallStreamEvents, LiveCallStreamEventName, LiveCallRequestReading, LiveCallClient, LiveCallClientUi, } from './live-call/protocol.js';
88
90
  export { DEFAULT_KEEP_ALIVE_MS as LIVE_CALL_KEEP_ALIVE_MS } from './live-call/event-stream.js';
89
91
  export { readTurnVision, visionText, visionFacts, VISION_ABSENCES, VISION_LIMITS, LOOK_WHEN } from './prompt/vision.js';
90
92
  export type { TurnVision, VisionLook, VisionAbsence } from './prompt/vision.js';
91
93
  export { lookTool, LOOK_TOOL, LOOK_LIMITS, LOOK_ABSENCES, VISION_TOOL_CLASS } from './vision/look-tool.js';
92
94
  export type { LookAbsence } from './vision/look-tool.js';
93
- export { readTurnCapture, captureText, captureFacts, canCapture, CAPTURE_LIMITS, CAPTURE_WHEN, CAPTURE_NEVER, CAPTURE_STATUSES, CAPTURE_OUTCOMES, CAPTURE_END_REASONS, CAPTURE_BRAIN_UPDATE_KINDS, CAPTURE_UPDATE_TEXT_MAX, } from './prompt/capture.js';
94
- export type { TurnCapture, CapturePlanOffer, CaptureControl, CaptureActive, CaptureActiveStep, CaptureStatus, CaptureOutcome, CaptureEndReason, CaptureBrainUpdateKind, } from './prompt/capture.js';
95
+ export { readTurnCapture, captureText, captureFacts, canCapture, CAPTURE_LIMITS, CAPTURE_WHEN, CAPTURE_NEVER, CAPTURE_STATUSES, CAPTURE_OUTCOMES, CAPTURE_END_REASONS, CAPTURE_BRAIN_UPDATE_KINDS, CAPTURE_UPDATE_TEXT_MAX, CAPTURE_BLOCKED_REASONS, } from './prompt/capture.js';
96
+ export type { TurnCapture, CapturePlanOffer, CaptureControl, CaptureActive, CaptureActiveStep, CaptureStatus, CaptureOutcome, CaptureEndReason, CaptureBrainUpdateKind, CaptureBlockedReason, } from './prompt/capture.js';
95
97
  export { captureTools, CAPTURE_START_TOOL, CAPTURE_STATUS_TOOL, CAPTURE_STOP_TOOL, CAPTURE_TOOLS, CAPTURE_TOOL_CLASS, CAPTURE_TOOL_LIMITS, } from './capture/capture-tools.js';
98
+ export { readTurnHandoff, handoffText, handoffFacts, canHandoff, HANDOFF_LIMITS, HANDOFF_WHEN, HANDOFF_NEVER, HANDOFF_CODE_TTL_S, CALL_HANDOFF_PURPOSES, CALL_HANDOFF_STATUSES, CALL_FORM_FACTORS, CALL_DEVICE_UPDATE_KINDS, DEVICE_UPDATE_TEXT_MAX, FORM_FACTOR_WORDS, } from './prompt/handoff.js';
99
+ export type { TurnHandoff, HandoffControl, HandoffDevice, HandoffOffer, CallHandoffPurpose, CallHandoffStatus, CallFormFactor, CallDeviceUpdateKind, } from './prompt/handoff.js';
100
+ export { handoffTool, CALL_HANDOFF_TOOL, CALL_HANDOFF_DESCRIPTION, HANDOFF_TOOL_CLASS, HANDOFF_TOOL_LIMITS, HANDOFF_REFUSALS, } from './handoff/handoff-tool.js';
96
101
  export { buildAgentSystemPrompt } from './prompt/index.js';
97
102
  export type { AgentPersonaConfig, AgentKnowledgeEntry, AgentWorkflow, AgentFewShotExample, AgentPersonaOverrides, PromptBuildContext, CommunicationStyle, CommunicationFormat, CommunicationStyleOptions, CommunicationStyleSetting, ResolvedCommunicationStyle, } from './prompt/index.js';
98
103
  export { getBaseRules, getCommunicationRules, resolveCommunicationStyle, COMMUNICATION_STYLES, COMMUNICATION_FORMATS, getToolStrategyRules, getUIControlRules, } from './prompt/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACxJ,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,Y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AAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,eAAe,EACf,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@
7
7
  * retries and timeouts, on Lambda + SQS or in a container.
8
8
  */
9
9
  export { historyOf } from './history.js';
10
+ export { TURN_CONTEXT_PLACEMENTS } from './step-messages.js';
10
11
  export { filterEmitAdapter } from './emit/filter.js';
11
12
  export { createToolRegistry } from './tools/types.js';
12
13
  export { loadToolsFromSchema } from './tools/schema-loader.js';
@@ -66,14 +67,17 @@ export { startContainerAgentWorker, DEFAULT_LIVE_CALL_PATH } from './container/s
66
67
  // Live calls: the call service's turns, answered by the product's own agent as
67
68
  // a server-sent event stream, while the turn streams to its room as any turn does.
68
69
  export { createLiveCallTurnHandler, liveCallTurnMessage, LIVE_CALL_SPEECH, LIVE_CALL_CHANNEL, LIVE_CALL_APPROVAL_CHANNELS, LIVE_CALL_MAX_BODY_BYTES, } from './live-call/handler.js';
69
- export { readLiveCallTurnRequest, liveCallError, LIVE_CALL_TURN_KINDS, LIVE_CALL_OPENING_MESSAGE, LIVE_CALL_GLANCE_MESSAGE, liveCallCaptureMessage, liveCallOpeningMessage, LIVE_CALL_TYPED_INPUT_MODE, LIVE_CALL_LIMITS, LIVE_CALL_ERROR_MESSAGES, } from './live-call/protocol.js';
70
+ export { readLiveCallTurnRequest, liveCallError, LIVE_CALL_TURN_KINDS, LIVE_CALL_OPENING_MESSAGE, LIVE_CALL_GLANCE_MESSAGE, liveCallCaptureMessage, liveCallDeviceMessage, liveCallOpeningMessage, LIVE_CALL_TYPED_INPUT_MODE, LIVE_CALL_LIMITS, LIVE_CALL_ERROR_MESSAGES, } from './live-call/protocol.js';
70
71
  export { DEFAULT_KEEP_ALIVE_MS as LIVE_CALL_KEEP_ALIVE_MS } from './live-call/event-stream.js';
71
72
  // Whether the model may look at the person's camera on a turn: read, and told to the model; and the look itself.
72
73
  export { readTurnVision, visionText, visionFacts, VISION_ABSENCES, VISION_LIMITS, LOOK_WHEN } from './prompt/vision.js';
73
74
  export { lookTool, LOOK_TOOL, LOOK_LIMITS, LOOK_ABSENCES, VISION_TOOL_CLASS } from './vision/look-tool.js';
74
75
  // A client's photo captures on a call: read, told to the model, and the tools that start, read and stop them.
75
- export { readTurnCapture, captureText, captureFacts, canCapture, CAPTURE_LIMITS, CAPTURE_WHEN, CAPTURE_NEVER, CAPTURE_STATUSES, CAPTURE_OUTCOMES, CAPTURE_END_REASONS, CAPTURE_BRAIN_UPDATE_KINDS, CAPTURE_UPDATE_TEXT_MAX, } from './prompt/capture.js';
76
+ export { readTurnCapture, captureText, captureFacts, canCapture, CAPTURE_LIMITS, CAPTURE_WHEN, CAPTURE_NEVER, CAPTURE_STATUSES, CAPTURE_OUTCOMES, CAPTURE_END_REASONS, CAPTURE_BRAIN_UPDATE_KINDS, CAPTURE_UPDATE_TEXT_MAX, CAPTURE_BLOCKED_REASONS, } from './prompt/capture.js';
76
77
  export { captureTools, CAPTURE_START_TOOL, CAPTURE_STATUS_TOOL, CAPTURE_STOP_TOOL, CAPTURE_TOOLS, CAPTURE_TOOL_CLASS, CAPTURE_TOOL_LIMITS, } from './capture/capture-tools.js';
78
+ // The call moving between the caller's devices: read, told to the model, and the tool that offers the move.
79
+ export { readTurnHandoff, handoffText, handoffFacts, canHandoff, HANDOFF_LIMITS, HANDOFF_WHEN, HANDOFF_NEVER, HANDOFF_CODE_TTL_S, CALL_HANDOFF_PURPOSES, CALL_HANDOFF_STATUSES, CALL_FORM_FACTORS, CALL_DEVICE_UPDATE_KINDS, DEVICE_UPDATE_TEXT_MAX, FORM_FACTOR_WORDS, } from './prompt/handoff.js';
80
+ export { handoffTool, CALL_HANDOFF_TOOL, CALL_HANDOFF_DESCRIPTION, HANDOFF_TOOL_CLASS, HANDOFF_TOOL_LIMITS, HANDOFF_REFUSALS, } from './handoff/handoff-tool.js';
77
81
  // Prompt Framework
78
82
  export { buildAgentSystemPrompt } from './prompt/index.js';
79
83
  export { getBaseRules, getCommunicationRules, resolveCommunicationStyle, COMMUNICATION_STYLES, COMMUNICATION_FORMATS, getToolStrategyRules, getUIControlRules, } from './prompt/index.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,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nB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAa7B,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,4GAA4G;AAC5G,OAAO,EACL,eAAe,EACf,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAW7B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,mBAAmB;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAc3D,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
@@ -4,6 +4,7 @@ import { type AgentTurnRunner, type TurnOutcome } from '../runtime/turn-runner.j
4
4
  import { type TurnSlots } from '../runtime/turn-slots.js';
5
5
  import { type LiveCallTurnRequest } from './protocol.js';
6
6
  import { type TurnCapture } from '../prompt/capture.js';
7
+ import { type TurnHandoff } from '../prompt/handoff.js';
7
8
  /** Who and where a live-call turn is, in the product: what the host resolves a call's `clientRef` to. */
8
9
  export interface LiveCallTurnTarget {
9
10
  /** The product's conversation: the call is one more way to reach it. */
@@ -174,16 +175,22 @@ export declare function createLiveCallTurnHandler(config: LiveCallTurnHandlerCon
174
175
  export declare function liveCallRoute(options: LiveCallTurnOptions, host: LiveCallRouteHost): (req: IncomingMessage, res: ServerResponse) => void;
175
176
  /** What of a request its turn's message is made from. */
176
177
  export type LiveCallTurnMessageSource = Pick<LiveCallTurnRequest, 'kind' | 'text' | 'disclosureLine'> & {
177
- /** On a `capture` turn, its `client.capture.update` is the message. */
178
+ /**
179
+ * On a `capture` turn, its `client.capture.update` is the message. On a
180
+ * `device` turn, its `client.handoff.update` is, followed by a
181
+ * `client.capture.update` that arrived with it.
182
+ */
178
183
  client?: {
179
184
  capture?: Pick<TurnCapture, 'update'> | null;
185
+ handoff?: Pick<TurnHandoff, 'update'> | null;
180
186
  } | null;
181
187
  };
182
188
  /**
183
189
  * What the model reads as the person's message, unless the host's target
184
- * gives its own `content`: what they said, or for an `opening`, a `glance` and
185
- * a `capture` the instruction that stands in for it (a capture's carries what
186
- * happened, `liveCallCaptureMessage(update)`). A host that stores the person's
190
+ * gives its own `content`: what they said, or for an `opening`, a `glance`, a
191
+ * `capture` and a `device` turn the instruction that stands in for it (a
192
+ * capture's carries what happened, `liveCallCaptureMessage(update)`; a device
193
+ * turn's, `liveCallDeviceMessage(update)`). A host that stores the person's
187
194
  * messages stores the same, so its history has a readable row for each turn.
188
195
  */
189
196
  export declare function liveCallTurnMessage(request: LiveCallTurnMessageSource): string;