@sippet-ai/sdk-js 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,2 @@
1
+ COPYRIGHT (c) 2026 SIPPET TECHNOLOGIES VCC
2
+ ALL RIGHTS RESERVED
package/README.md ADDED
@@ -0,0 +1,196 @@
1
+ # Sippet AI JS SDK
2
+
3
+ Typed JavaScript/TypeScript client for Sippet AI.
4
+
5
+ It includes three layers:
6
+
7
+ - RPC actions for calls, queues, contacts, operators, and AI agents.
8
+ - Realtime events via WebSocket channels.
9
+ - SIP conference helpers built on `sip.js` for WebRTC audio.
10
+
11
+ This SDK is used by the Sippet call center UI and the operator widget.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @sippet-ai/sdk-js
17
+ ```
18
+
19
+ ## Entry points
20
+
21
+ - `@sippet-ai/sdk-js` for RPC actions + realtime helpers.
22
+ - `@sippet-ai/sdk-js/realtime` for realtime helpers only.
23
+ - `@sippet-ai/sdk-js/sip` for SIP/WebRTC helpers only.
24
+
25
+ ### `createClient` (recommended)
26
+
27
+ ```ts
28
+ import { createClient } from "@sippet-ai/sdk-js";
29
+
30
+ const client = createClient({
31
+ apiKey: "YOUR_PUBLISHABLE_KEY",
32
+ });
33
+
34
+ const result = await client.listCalls({
35
+ fields: ["id", "callUuid", "status"],
36
+ });
37
+ ```
38
+
39
+ `createClient` only injects the API key into RPC calls; realtime helpers like `initSocket` are passed through unchanged.
40
+
41
+ ## RPC usage
42
+
43
+ All RPC functions return a discriminated union:
44
+
45
+ - `{ success: true, data }`
46
+ - `{ success: false, errors }`
47
+
48
+ ### Common config options
49
+
50
+ Most actions accept the same config shape:
51
+
52
+ - `fields`: field selection for typed responses.
53
+ - `filter`: filter expression for list/read actions.
54
+ - `sort`: sort string supported by the API.
55
+ - `page`: pagination config (`{ limit, offset, count }` or keyset params).
56
+ - `headers`: add custom headers (auth, etc.).
57
+ - `fetchOptions`: pass `RequestInit` options (signal, cache, credentials, ...).
58
+ - `customFetch`: supply your own `fetch` implementation.
59
+
60
+ ### Start an outbound call
61
+
62
+ ```ts
63
+ import { createClient } from "@sippet-ai/sdk-js";
64
+
65
+ const client = createClient({ apiKey: "YOUR_PUBLISHABLE_KEY" });
66
+
67
+ const result = await client.startOutboundCall({
68
+ input: {
69
+ contactId: "CONTACT_ID",
70
+ aiAgentId: "AGENT_ID",
71
+ },
72
+ });
73
+
74
+ if (!result.success) {
75
+ throw new Error(result.errors.map((e) => e.message).join(", "));
76
+ }
77
+
78
+ const call = result.data;
79
+ ```
80
+
81
+ ### List calls with filters
82
+
83
+ ```ts
84
+ import { createClient } from "@sippet-ai/sdk-js";
85
+
86
+ const client = createClient({ apiKey: "YOUR_PUBLISHABLE_KEY" });
87
+
88
+ const result = await client.listCalls({
89
+ fields: ["id", "callUuid", "fromNumber", "toNumber", "status", "startedAt"],
90
+ filter: {
91
+ status: { in: ["initiated", "ringing", "answered"] },
92
+ },
93
+ });
94
+ ```
95
+
96
+ ### Pagination
97
+
98
+ Many `list*` actions accept `page` to enable pagination.
99
+
100
+ ```ts
101
+ import { createClient } from "@sippet-ai/sdk-js";
102
+
103
+ const client = createClient({ apiKey: "YOUR_PUBLISHABLE_KEY" });
104
+
105
+ const result = await client.listCalls({
106
+ fields: ["id", "callUuid", "status"],
107
+ page: { limit: 50, offset: 0, count: true },
108
+ });
109
+ ```
110
+
111
+ ## Realtime events
112
+
113
+ Realtime helpers are built on Phoenix channels. The SDK exposes a helper
114
+ for the `events` channel used by Sippet AI.
115
+
116
+ ```ts
117
+ import { initSocket, joinEventsChannel } from "@sippet-ai/sdk-js";
118
+
119
+ initSocket({
120
+ baseUrl: "https://api.sippet.ai",
121
+ publishableKey: "YOUR_PUBLISHABLE_KEY",
122
+ });
123
+
124
+ const channel = joinEventsChannel();
125
+
126
+ channel.on("incoming_call", (payload) => {
127
+ console.log("incoming_call", payload);
128
+ });
129
+
130
+ channel.on("call_answered", (payload) => {
131
+ console.log("call_answered", payload);
132
+ });
133
+
134
+ channel.on("call_ended", (payload) => {
135
+ console.log("call_ended", payload);
136
+ });
137
+ ```
138
+
139
+ Known `events` channel names:
140
+
141
+ - `incoming_call`
142
+ - `call_answered`
143
+ - `call_ended`
144
+ - `operator_status_change`
145
+ - `call_queue_entry_updated`
146
+ - `call_queue_entry_deleted`
147
+ - `call_participant_joined`
148
+ - `call_participant_left`
149
+ - `call_transcript_delta`
150
+ - `call_transcript_completed`
151
+
152
+ ## SIP / WebRTC helpers
153
+
154
+ Use the SIP helpers when you need to join a SIP conference or eavesdrop
155
+ session directly in the browser.
156
+
157
+ ```ts
158
+ import {
159
+ joinConference,
160
+ leaveConference,
161
+ setInputDevice,
162
+ setOutputDevice,
163
+ } from "@sippet-ai/sdk-js/sip";
164
+
165
+ await joinConference({
166
+ server: "wss://sip.sippet.ai:7443",
167
+ domain: "sip.sippet.ai",
168
+ username: "SIP_USERNAME",
169
+ password: "SIP_PASSWORD",
170
+ roomId: "ROOM_ID",
171
+ codecPreference: "pcma",
172
+ });
173
+
174
+ await setInputDevice("mic-device-id");
175
+ await setOutputDevice("speaker-device-id");
176
+
177
+ await leaveConference();
178
+ ```
179
+
180
+ ## RPC API surface (high-level)
181
+
182
+ This SDK is generated from the Sippet AI API. Key categories:
183
+
184
+ - Identity: `whoAmI`.
185
+ - Calls: `listCalls`, `createCall`, `endCall`, `startOutboundCall`, `resumeAiCall`, `bargeCall`, `callCodec`.
186
+ - AI agents: `listAiAgents`.
187
+ - Call participants and transcripts: `listCallParticipants`, `listCallTranscripts`.
188
+ - Queue and routing: `listQueues`, `listCallQueueEntries`, `getCallQueueEntry`, `acceptCallQueueEntry`.
189
+ - Contacts: `listContacts`, `createContact`, `updateContact`, `deleteContact`.
190
+ - Operators: `listOperatorStatuses`, `setOperatorStatus`, `listOperatorStatusEvents`.
191
+ - Telephony access: `issueOperatorSipAccess`, `issueSipAccess`, `revokeSipAccess`.
192
+ - Phone numbers and gateways: `listPhoneNumbers`, `listGateways`.
193
+
194
+ ## Related packages
195
+
196
+ - `@sippet-ai/operator-widget`: a full VoIP UI built on this SDK (web component + React wrapper).