@lumavox/react 0.26.0 → 0.29.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"];
@@ -128,6 +134,8 @@ export interface AgentControls extends Snapshot {
128
134
  reconnect(): void;
129
135
  /** A new conversation with the same agent. */
130
136
  newSession(): void;
137
+ /** The conversation is over: its report is written now (`Conversation.end`), then it closes. */
138
+ end(): void;
131
139
  close(): void;
132
140
  }
133
141
  export declare function useAgent(target: AgentTarget | null, options?: UseAgentOptions): AgentControls;
package/dist/use-agent.js CHANGED
@@ -267,6 +267,7 @@ export function useAgent(target, options = {}) {
267
267
  return connected().then((c) => (c ? c.send(text, turn) : notOpen));
268
268
  },
269
269
  startAudio: (start) => current.current?.startAudio(start) ?? null,
270
+ note: (text, noteOptions) => current.current?.note(text, noteOptions) ?? false,
270
271
  sendAudio: (pcm) => current.current?.sendAudio(pcm) ?? false,
271
272
  endAudio: ((end) => current.current
272
273
  ? current.current.endAudio(end)
@@ -365,7 +366,7 @@ export function useAgent(target, options = {}) {
365
366
  if (stop.transcribeOnly)
366
367
  return c.endAudio({ transcribeOnly: true });
367
368
  hush();
368
- return c.endAudio();
369
+ return c.endAudio(stop.context ? { context: stop.context } : {});
369
370
  },
370
371
  async listen(listenOptions = {}) {
371
372
  const audio = latest.current.audio;
@@ -418,6 +419,10 @@ export function useAgent(target, options = {}) {
418
419
  current.current?.mute();
419
420
  },
420
421
  reconnect: () => current.current?.reconnect(),
422
+ end() {
423
+ hush();
424
+ current.current?.end();
425
+ },
421
426
  close() {
422
427
  hush();
423
428
  current.current?.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumavox/react",
3
- "version": "0.26.0",
3
+ "version": "0.29.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.26.0"
32
+ "@lumavox/client": "0.29.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=18"