@origonai/web-sdk 0.1.1 → 0.1.3

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
@@ -41,7 +41,7 @@ client.setCallbacks({
41
41
 
42
42
  const { sessionId } = await client.startSession({ channel: 'chat' })
43
43
 
44
- await client.sendMessage(sessionId, { text: 'Hello!' }) // audience defaults to all
44
+ await client.sendMessage(sessionId, { text: 'Hello!' }) // participant server defaults audience to all
45
45
 
46
46
  client.notifyTyping(sessionId) // call on each keystroke; SDK debounces
47
47
 
@@ -68,8 +68,8 @@ await client.endSession(sessionId)
68
68
  - `getSession(sessionId)` — GET `/session/{id}` (transcript + control)
69
69
 
70
70
  ### Chat
71
- - `sendMessage(sessionId, payload)` — post a message with optional `metadata: {audience}`; ordinary sends default to `all`. The SDK fires `onMessageAdded` immediately with `status: 'sending'`, then `onMessageUpdated` with `'delivered'` or `'failed'` after the server acks
72
- - `notifyTyping(sessionId, metadata?)` — call on each keystroke; ordinary typing defaults to `all`, and the SDK debounces (3s window) and emits typing on/off automatically
71
+ - `sendMessage(sessionId, payload)` — post a message with optional `metadata: {audience}`; ordinary participant sends omit it and the server resolves the audience to `all`. The SDK fires `onMessageAdded` immediately with `status: 'sending'`, then `onMessageUpdated` with `'delivered'` or `'failed'` after the server acks
72
+ - `notifyTyping(sessionId, metadata?)` — call on each keystroke; ordinary participant typing omits metadata, and the SDK debounces (3s window) and emits typing on/off automatically
73
73
  - `stopTyping(sessionId)` — flush typing-off immediately
74
74
 
75
75
  ### Attachments
@@ -130,10 +130,13 @@ consumer can host multiple sessions.
130
130
  The outbound `payload.role` is a local-only hint for the provisional
131
131
  `onMessageAdded` row; it's stripped before POST.
132
132
 
133
- Every message has required `metadata: { audience: 'internal' | 'all' }`.
134
- Missing or unknown wire metadata is a protocol failure, not a compatibility
135
- default. Typing callbacks carry the same required audience plus participant
136
- identity; watchdogs are isolated by `participantId`.
133
+ Message metadata is optional at both levels:
134
+ `metadata?: { audience?: 'internal' | 'all' }`. Missing/null containers remain
135
+ absent, while an explicitly present empty object remains `{}`; unknown
136
+ non-empty audiences are protocol failures. A
137
+ monitor client must always send an explicit known audience even though the
138
+ shared SDK type is optional. Typing callbacks retain required audience plus
139
+ participant identity; watchdogs are isolated by `participantId`.
137
140
 
138
141
  ## Errors
139
142
 
@@ -172,6 +175,7 @@ client.initialize({
172
175
 
173
176
  const { sessionId } = await client.startSession({ channel: 'voice' })
174
177
  await client.setMute(sessionId, 'uplink') // 'uplink' | 'downlink' | 'both' | 'none'
178
+ await client.sendDtmf(sessionId, '5') // one of 0-9, *, #, A-D
175
179
 
176
180
  const off = client.subscribeAudioStats(sessionId, ({ outboundLevel, inboundLevel }) => {
177
181
  // VU meters at ~5 Hz
@@ -189,6 +193,11 @@ Voice requires:
189
193
 
190
194
  The browser opens a single WebTransport to `<media-server>/web`, sends a B2BUA `Connect` over the control sub-stream, and pumps 20 ms Opus frames as `ObjectDatagram`s with `group_id = floor(Date.now()/1000) - serverEpochUnix`. Reconnect is Tier-3 only (`Resume` verb) with `[100, 250, 500, 1000]` ms backoff.
191
195
 
196
+ `sendDtmf` resolves when Media acknowledges publication to the active CX flow.
197
+ It rejects while the voice transport is reconnecting and is never queued or
198
+ replayed after `Resume`. The SDK does not play a local tone or expose a peer
199
+ DTMF callback.
200
+
192
201
  ## Joining a provisioned session
193
202
 
194
203
  `startSession` originates a session by calling `POST /session/start` itself.
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ export declare interface AudioWorkletStats {
39
39
 
40
40
  export declare type Channel = 'chat' | 'voice';
41
41
 
42
- /** Audience carried explicitly on every live-monitoring message/typing frame. */
42
+ /** Closed audience vocabulary; the field holding it may be absent. */
43
43
  export declare type ChatAudience = 'internal' | 'all';
44
44
 
45
45
  export declare class ClientError extends Error {
@@ -150,6 +150,9 @@ export declare type DisconnectReason = {
150
150
  detail: string;
151
151
  };
152
152
 
153
+ /** Complete programmatic DTMF alphabet; lowercase is intentionally invalid. */
154
+ export declare type DtmfDigit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '*' | '#' | 'A' | 'B' | 'C' | 'D';
155
+
153
156
  export declare function getSessionManager(): SessionManager;
154
157
 
155
158
  /**
@@ -189,7 +192,7 @@ export declare interface Message {
189
192
  errorText?: string;
190
193
  status: MessageStatus;
191
194
  state: MessageState;
192
- metadata: MessageMetadata;
195
+ metadata?: MessageMetadata;
193
196
  /**
194
197
  * Lifecycle action for a `role:'system'` message — `'queued' | 'joined' |
195
198
  * 'ended'` (kept an open `string`: the server may add more; a distinct
@@ -244,7 +247,7 @@ export declare interface MessageCard {
244
247
  }
245
248
 
246
249
  export declare interface MessageMetadata {
247
- audience: ChatAudience;
250
+ audience?: ChatAudience;
248
251
  }
249
252
 
250
253
  export declare type MessageRole = 'ai' | 'external' | 'user' | 'system';
@@ -358,7 +361,7 @@ export declare interface SendMessagePayload {
358
361
  text?: string;
359
362
  html?: string;
360
363
  attachments?: Attachment[];
361
- /** Defaults to `{ audience: 'all' }` for ordinary visitor compatibility. */
364
+ /** Optional for participant callers; monitor callers must supply an audience. */
362
365
  metadata?: MessageMetadata;
363
366
  /**
364
367
  * Local-only hint for the provisional `onMessageAdded` role. Defaults to
@@ -457,6 +460,8 @@ export declare class SessionManager {
457
460
  notifyTyping(sessionId: string, metadata?: TypingMetadata): void;
458
461
  stopTyping(sessionId: string): void;
459
462
  setMute(sessionId: string, scope: MuteScope): Promise<void>;
463
+ /** Send one DTMF symbol to the active CX flow for a voice session. */
464
+ sendDtmf(sessionId: string, digit: DtmfDigit): Promise<void>;
460
465
  /** Enable microphone coaching on a receive-only voice join. */
461
466
  enableCapture(sessionId: string): Promise<void>;
462
467
  /** Return a coaching voice join to Listen and release its microphone. */