@talk2view/sdk 0.19.0 → 0.20.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 (52) hide show
  1. package/README.md +8 -2
  2. package/dist/assistant-ui/index.d.ts.map +1 -1
  3. package/dist/assistant-ui/index.js +9 -4
  4. package/dist/assistant-ui/index.js.map +1 -1
  5. package/dist/auth.d.ts +8 -0
  6. package/dist/auth.d.ts.map +1 -1
  7. package/dist/auth.js +27 -11
  8. package/dist/auth.js.map +1 -1
  9. package/dist/chat/index.d.ts +1 -0
  10. package/dist/chat/index.d.ts.map +1 -1
  11. package/dist/chat/index.js +1 -0
  12. package/dist/chat/index.js.map +1 -1
  13. package/dist/chat/launcher.d.ts.map +1 -1
  14. package/dist/chat/launcher.js +11 -2
  15. package/dist/chat/launcher.js.map +1 -1
  16. package/dist/chat/provider.d.ts +15 -0
  17. package/dist/chat/provider.d.ts.map +1 -1
  18. package/dist/chat/provider.js +36 -3
  19. package/dist/chat/provider.js.map +1 -1
  20. package/dist/chat/voice-button.d.ts +34 -0
  21. package/dist/chat/voice-button.d.ts.map +1 -0
  22. package/dist/chat/voice-button.js +175 -0
  23. package/dist/chat/voice-button.js.map +1 -0
  24. package/dist/chat-css.js +1 -1
  25. package/dist/chat.css +1 -1
  26. package/dist/chat.isolated.css +169 -3
  27. package/dist/chat.raw.css +169 -3
  28. package/dist/event-emitter.d.ts +1 -0
  29. package/dist/event-emitter.d.ts.map +1 -1
  30. package/dist/event-emitter.js +3 -0
  31. package/dist/event-emitter.js.map +1 -1
  32. package/dist/index.d.ts +21 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +34 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/types.d.ts +60 -0
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/voice-error.d.ts +8 -0
  39. package/dist/voice-error.d.ts.map +1 -0
  40. package/dist/voice-error.js +10 -0
  41. package/dist/voice-error.js.map +1 -0
  42. package/dist/voice-facade.d.ts +57 -0
  43. package/dist/voice-facade.d.ts.map +1 -0
  44. package/dist/voice-facade.js +139 -0
  45. package/dist/voice-facade.js.map +1 -0
  46. package/dist/voice.d.ts +157 -0
  47. package/dist/voice.d.ts.map +1 -0
  48. package/dist/voice.js +630 -0
  49. package/dist/voice.js.map +1 -0
  50. package/docs/chat.md +4 -4
  51. package/docs/voice.md +88 -0
  52. package/package.json +3 -1
package/docs/chat.md CHANGED
@@ -109,7 +109,7 @@ take directly.
109
109
  | `systemPrompt` | none | Your own instructions, sent with every message. Changing it does not restart the conversation. |
110
110
  | `welcome` | `{}` | `heading` and `suggestions` on the empty chat. Clicking a suggestion sends it. |
111
111
  | `allowAnonymous` | `true` | Logged-out visitors chat as guests. `false` shows sign-in first — **and see the note below**. |
112
- | `features` | all on | `{ dictation, attachments, settings, account, threadList, skills }`. |
112
+ | `features` | all on | `{ dictation, attachments, settings, account, threadList, skills, voice }`. `voice` is the realtime voice button beside the launcher, shown only for partners with voice enabled — see [voice.md](voice.md). |
113
113
  | `fontFamily` | inherit | Your own font stack. Default: whatever the page uses. |
114
114
  | `resetPasswordUrl` | none | Where "Forgot it?" goes. Without it the link is not shown. |
115
115
  | `footer` | none | A short line under the composer — your terms, a disclaimer. |
@@ -403,9 +403,9 @@ Stated plainly, because it is large.
403
403
 
404
404
  | | gzip |
405
405
  |---|---|
406
- | `@talk2view/sdk` (the core client) | 9.4 KB |
407
- | `@talk2view/sdk/ui` (the previous chat panel) | 39.9 KB |
408
- | **`@talk2view/sdk/chat`** | **361.8 KB** |
406
+ | `@talk2view/sdk` (the core client) | 11.1 KB |
407
+ | `@talk2view/sdk/ui` (the previous chat panel) | 40.3 KB |
408
+ | **`@talk2view/sdk/chat`** | **372.4 KB** |
409
409
  | A whole page containing the chat and React | ~437 KB |
410
410
 
411
411
  The first three exclude React and React DOM, which your app already has. The
package/docs/voice.md ADDED
@@ -0,0 +1,88 @@
1
+ # Voice
2
+
3
+ The realtime voice agent: the end-user talks, the agent answers out loud, and
4
+ it can use your client tools while it does. It runs the **same** tools,
5
+ permission checks and approval card as the chat. A tool you registered for chat
6
+ is already a voice tool, so there is no new code to write for voice.
7
+
8
+ Voice is off until Talk2View turns it on for your partner account. While it is
9
+ off, `/v1/config` returns `voice_agent_enabled: false` and nothing below shows.
10
+
11
+ ## In the launcher
12
+
13
+ `<Talk2ViewChatLauncher>` shows a microphone beside its mark when your partner
14
+ account has voice enabled. Press it to talk, and press it again to hang up. A
15
+ press while the call is still connecting cancels the call. To hide the button
16
+ even when voice is enabled:
17
+
18
+ ```tsx
19
+ <Talk2ViewChatLauncher partnerKey="pk_live_…" features={{ voice: false }} />
20
+ ```
21
+
22
+ Above the button, a small note shows what the call is doing: connecting,
23
+ listening, working, or why it ended. Errors are written for the end-user, not
24
+ the developer. For example, when every voice slot is taken, the note reads
25
+ "Voice is busy right now. Try again shortly." When a tool needs approval, its
26
+ card appears in the same place.
27
+
28
+ ## Standalone
29
+
30
+ ```tsx
31
+ import { VoiceButton } from '@talk2view/sdk/chat';
32
+ import '@talk2view/sdk/chat.css';
33
+
34
+ <VoiceButton client={t2v} />;
35
+ ```
36
+
37
+ | Prop | Default | |
38
+ |---|---|---|
39
+ | `client` | the chat's | Required outside `<Talk2ViewChat>` / the launcher. |
40
+ | `label` | `"Talk to Talk2View"` | The button's accessible name. |
41
+ | `earcon` | `true` | A short, locally generated sound when the microphone goes live. |
42
+ | `className` | none | Put `dark` here for the dark palette. |
43
+
44
+ A standalone `<VoiceButton>` does not check `voice_agent_enabled` itself.
45
+ Render it only when `(await t2v.getConfig()).voice_agent_enabled` is true.
46
+
47
+ ## Without a UI: `t2v.voice`
48
+
49
+ ```ts
50
+ await t2v.voice.start(); // resolves once the microphone is live
51
+ t2v.voice.on('transcript', ({ role, text, final }) => { /* … */ });
52
+ t2v.voice.on('toolCall', ({ toolName, arguments: args }) => { /* … */ });
53
+ t2v.voice.on('approvalChange', (pending) => pending?.decide({ action: 'once' }));
54
+ t2v.voice.on('error', ({ type, message }) => { /* … */ });
55
+ t2v.voice.on('ended', (reason) => { /* 'stopped', 'idle', 'session_cap', … */ });
56
+ await t2v.voice.stop(); // hangs up and releases the microphone
57
+ ```
58
+
59
+ `on()` returns an unsubscribe function. Other events are `stateChange`
60
+ (`idle | connecting | listening | ended | error`) and `agentState`
61
+ (`working | idle`).
62
+
63
+ If `start()` fails, it rejects with an error whose `.type` gives the reason:
64
+ `voice_disabled`, `account_required`, `auth_expired`, `no_api_key`,
65
+ `insufficient_credit`, `credit_check_unavailable`, `service_unavailable`,
66
+ `voice_at_capacity`, `voice_ticket_invalid`, `voice_offer_invalid`,
67
+ `upstream_error`, `transport_error` or `voice_error`. The same types arrive on
68
+ the `error` event, which also reports what ends a call without `start()`
69
+ rejecting: `mic_unavailable` (the microphone was refused or is missing; the
70
+ call ends with `'error'`), `auth_expired` (the sign-in expired; the call ends with
71
+ `'auth_expired'`) and `insufficient_credit` (credit ran out; the call ends with
72
+ `'budget_exhausted'`). A deliberate `t2v.auth.logout()` hangs up a call as
73
+ `'stopped'`, with no error.
74
+
75
+ ## Browser requirements
76
+
77
+ - **HTTPS.** Browsers only give microphone access on a secure page (localhost
78
+ counts as secure).
79
+ - **Microphone permission.** The browser asks on the first press. If the
80
+ end-user refuses, the call ends with a `mic_unavailable` error.
81
+ - **WebRTC.** The call is a WebRTC connection to Talk2View's voice service. A
82
+ network that blocks WebRTC fails with `transport_error`.
83
+ - **Content-Security-Policy.** Your bundler puts the Pipecat client libraries
84
+ in a separate chunk that loads from your own origin on the first press. The
85
+ call then connects to the voice service URL returned by the engine, so
86
+ `connect-src` must allow that host as well as your engine.
87
+
88
+ A chat-only integration never loads the Pipecat libraries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talk2view/sdk",
3
- "version": "0.19.0",
3
+ "version": "0.20.1",
4
4
  "description": "Talk2View SDK — Add AI-powered natural language control to any application",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -82,6 +82,8 @@
82
82
  "@assistant-ui/react": "^0.15.20",
83
83
  "@assistant-ui/react-markdown": "^0.14.15",
84
84
  "@base-ui/react": "^1.8.0",
85
+ "@pipecat-ai/client-js": "1.13.1",
86
+ "@pipecat-ai/small-webrtc-transport": "1.10.8",
85
87
  "class-variance-authority": "^0.7.1",
86
88
  "clsx": "^2.1.1",
87
89
  "dompurify": "^3.4.13",