@lumavox/react 0.23.0 → 0.28.0

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
@@ -56,7 +56,7 @@ redial.
56
56
  | `error` | `{ kind, message }`: the session, an `error` frame, the close, the microphone |
57
57
  | `speaking` `recording` | the adapter is playing; the recorder is open |
58
58
  | `interrupted` | the device has the audio — a call, Siri, another app |
59
- | `send` `startAudio` `sendAudio` `endAudio` `cancel` `mute` `reconnect` `close` | the conversation's |
59
+ | `send` `note` `startAudio` `sendAudio` `endAudio` `cancel` `mute` `reconnect` `close` | the conversation's |
60
60
  | `startRecording({ rate, transcribeOnly, speech, thoughts })` `stopRecording({ transcribeOnly, discard })` | through the `audio` adapter; a held turn's own voice and thinking, as `send`'s |
61
61
  | `listen(options)` `stopListening()` `listening` `hearing` | hands-free: each utterance a turn, talking over the agent stopping it (`@lumavox/client`'s `listen`); `listen({ halfDuplex: true })` where echo cannot be cancelled — nothing heard while the agent speaks |
62
62
  | `newSession()` | a new conversation with the same agent |
@@ -27,7 +27,7 @@
27
27
  * Push-to-talk waits while it listens, and it ends with the
28
28
  * conversation.
29
29
  */
30
- import { type AgentAudio, type Client, type CloseInfo, type ConnectOptions, type Conversation, type ConversationHandlers, type ErrorFrame, type ListenOptions, type PlatformError, type SessionDetail, type Snapshot, type StartAudioOptions, type TranscriptOutcome, type TurnOptions, type TurnOutcome } from "@lumavox/client";
30
+ import { type AgentAudio, type Client, type CloseInfo, type ConnectOptions, type Conversation, type ConversationHandlers, type ErrorFrame, type ListenOptions, type PlatformError, type SendOptions, type SessionDetail, type Snapshot, type StartAudioOptions, type TranscriptOutcome, type TurnOptions, type TurnOutcome } from "@lumavox/client";
31
31
  /** Whom to talk to; `null` for nobody yet — nothing is opened. */
32
32
  export type AgentTarget =
33
33
  /** An agent: the person's last conversation with it, by default — `resume: false` for a new one. */
@@ -86,6 +86,8 @@ export interface RecordingOptions extends TurnOptions {
86
86
  export interface StopRecordingOptions {
87
87
  /** No turn: this recording's words, answered by `stopRecording`. */
88
88
  transcribeOnly?: boolean;
89
+ /** The turn's: what the app says about the moment (`SendOptions.context`). */
90
+ context?: SendOptions["context"];
89
91
  /** Throw it away: the recording is cancelled, and so is a turn running. */
90
92
  discard?: boolean;
91
93
  }
@@ -105,7 +107,11 @@ export interface AgentControls extends Snapshot {
105
107
  hearing: boolean;
106
108
  /** The conversation itself, once it is made. */
107
109
  conversation: Conversation | null;
108
- send(text: string, options?: TurnOptions): Promise<TurnOutcome>;
110
+ send(text: string, options?: SendOptions): Promise<TurnOutcome>;
111
+ /** A note to the agent that is not a message (`Conversation.note`); false when refused or not open. */
112
+ note(text: string, options?: {
113
+ reply?: boolean;
114
+ }): boolean;
109
115
  startAudio(options: StartAudioOptions): string | null;
110
116
  sendAudio(pcm: ArrayBuffer | Int16Array): boolean;
111
117
  endAudio: Conversation["endAudio"];
package/dist/use-agent.js CHANGED
@@ -34,6 +34,7 @@ import { asPlatformError } from "./read.js";
34
34
  /** Every handler passed straight through; `onAudio` is wired apart. */
35
35
  const PASSED = [
36
36
  "onReady",
37
+ "onAgent",
37
38
  "onTurnStart",
38
39
  "onHeard",
39
40
  "onHeardPartial",
@@ -46,6 +47,7 @@ const PASSED = [
46
47
  "onToolStart",
47
48
  "onToolEnd",
48
49
  "onToolConfirm",
50
+ "onToolDone",
49
51
  "onUsage",
50
52
  "onMuted",
51
53
  "onAudioStart",
@@ -265,6 +267,7 @@ export function useAgent(target, options = {}) {
265
267
  return connected().then((c) => (c ? c.send(text, turn) : notOpen));
266
268
  },
267
269
  startAudio: (start) => current.current?.startAudio(start) ?? null,
270
+ note: (text, noteOptions) => current.current?.note(text, noteOptions) ?? false,
268
271
  sendAudio: (pcm) => current.current?.sendAudio(pcm) ?? false,
269
272
  endAudio: ((end) => current.current
270
273
  ? current.current.endAudio(end)
@@ -363,7 +366,7 @@ export function useAgent(target, options = {}) {
363
366
  if (stop.transcribeOnly)
364
367
  return c.endAudio({ transcribeOnly: true });
365
368
  hush();
366
- return c.endAudio();
369
+ return c.endAudio(stop.context ? { context: stop.context } : {});
367
370
  },
368
371
  async listen(listenOptions = {}) {
369
372
  const audio = latest.current.audio;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumavox/react",
3
- "version": "0.23.0",
3
+ "version": "0.28.0",
4
4
  "description": "React and React Native hooks for Lumavox agents: a conversation that keeps itself connected, sessions, memory and relations, over @lumavox/client.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "typecheck": "tsc --noEmit && tsc --noEmit -p test"
30
30
  },
31
31
  "dependencies": {
32
- "@lumavox/client": "0.23.0"
32
+ "@lumavox/client": "0.28.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=18"