@babelforce/babelconnect-sdk 0.1.0 → 0.6.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/README.md CHANGED
@@ -22,7 +22,7 @@ messaging) on top of `babelconnect-server`. Two ways to use it:
22
22
  npm install @babelforce/babelconnect-sdk
23
23
  ```
24
24
 
25
- ESM-only, targets ES2022. Runs in modern browsers; Node 18+ for control-only (no-audio) use. Native WebRTC
25
+ ESM-only, targets ES2022. Runs in modern browsers; Node 20+ for control-only (no-audio) use. Native WebRTC
26
26
  audio requires a browser (microphone permission).
27
27
 
28
28
  ## Quickstart — programmatic client (with audio)
@@ -90,8 +90,10 @@ bc.session.set({ number: "+49301234567" }); // correlate / prefill
90
90
  (`setPresence`, `setDisplayAs`, `setAgentNumber`, `setWebrtc`), and history/contacts fetches (`getHistory`,
91
91
  `getSmsThread`, `getPhonebook`).
92
92
 
93
- Full API reference and the embedding guide:
94
- **[babelconnect-sdk-docs](https://babelforce.github.io/babelconnect-sdk-docs/)**.
93
+ Full docs — API reference, guides, and the embedding guide:
94
+ **[babelconnect SDK docs](https://babelforce.github.io/babelconnect-sdk/)**. Good starting points:
95
+ the **[tutorial](https://babelforce.github.io/babelconnect-sdk/docs/tutorial/first-softphone)** and,
96
+ if you hit a snag, **[troubleshooting](https://babelforce.github.io/babelconnect-sdk/docs/guides/troubleshooting)**.
95
97
 
96
98
  ## How it works
97
99
 
package/dist/client.d.ts CHANGED
@@ -8,7 +8,7 @@ export interface ConnectOptions {
8
8
  token: string;
9
9
  /** Per-call WebRTC leg. Defaults to {@link browserMediaFactory}; pass `null` for a control-only client. */
10
10
  mediaFactory?: MediaFactory | null;
11
- /** Auto-answer the agent's own OUTBOUND ringing leg (default `true`). INBOUND waits for {@link answerCall}. */
11
+ /** Auto-answer the agent's own OUTBOUND ringing leg (default `true`). INBOUND waits for {@link BabelconnectClient.answerCall}. */
12
12
  autoAnswer?: boolean;
13
13
  /** Out-of-band server notices (command rejections) + local media failures. */
14
14
  onError?: (err: BcError) => void;
@@ -34,7 +34,18 @@ export declare class BabelconnectClient {
34
34
  private readonly pending;
35
35
  private closed;
36
36
  private constructor();
37
- /** Open the session and start mirroring server state. */
37
+ /**
38
+ * Open the session and start mirroring server state. Returns synchronously and queues intents until the
39
+ * stream is live, so you can subscribe and register immediately.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const bc = BabelconnectClient.connect({ serverUrl, token });
44
+ * bc.subscribe(render); // render(AgentView) on every update
45
+ * bc.register(); // announce reachability + load deployment data
46
+ * bc.placeCall("+15551234567"); // the result arrives as a callUpsert patch
47
+ * ```
48
+ */
38
49
  static connect(opts: ConnectOptions): BabelconnectClient;
39
50
  /** The current view (deep copy). */
40
51
  get view(): AgentView;
@@ -42,6 +53,12 @@ export declare class BabelconnectClient {
42
53
  subscribe(fn: (v: AgentView) => void): () => void;
43
54
  /** The first active call, or undefined. */
44
55
  activeCall(): CallState | undefined;
56
+ /**
57
+ * Announce the agent and load its deployment data (presence options, caller-ID numbers, phonebook, feature
58
+ * config) — call this once after {@link BabelconnectClient.subscribe}. It also marks the agent
59
+ * **WebRTC-reachable** on the backend, so a control-only client that takes calls should follow it with
60
+ * {@link BabelconnectClient.setWebrtc}(false) + {@link BabelconnectClient.setAgentNumber}.
61
+ */
45
62
  register(capabilities?: string[]): void;
46
63
  placeCall(to: string, opts?: {
47
64
  displayAsTo?: string;
@@ -51,10 +68,15 @@ export declare class BabelconnectClient {
51
68
  }): void;
52
69
  /** Manually answer a RINGING call by id (no-op under autoAnswer once already answered). */
53
70
  answerCall(callId: string): Promise<void>;
71
+ /** End (or reject) a call by id. */
54
72
  hangup(callId: string): void;
73
+ /** Mute or unmute the agent's own leg of a call. */
55
74
  mute(callId: string, on: boolean): void;
75
+ /** Put a call on hold or retrieve it. */
56
76
  hold(callId: string, on: boolean): void;
77
+ /** Send DTMF tones into the call (e.g. an IVR menu choice). Valid characters: `0`–`9`, `*`, `#`, `A`–`D`. */
57
78
  sendDigits(callId: string, digits: string): void;
79
+ /** Set the outbound caller ID the consumer sees (choose from `agent.availableNumbers`). */
58
80
  setDisplayAs(number: string): void;
59
81
  /** Switch presence (the selector): "available" or a configured pause reason (see `AgentInfo.presenceOptions`). */
60
82
  setPresence(name: string): void;
@@ -64,24 +86,40 @@ export declare class BabelconnectClient {
64
86
  agentId?: string;
65
87
  applicationId?: string;
66
88
  }): void;
89
+ /** Open a conference around the current call. `hold` parks that call while you add members and consult. */
67
90
  startConference(hold?: boolean): void;
91
+ /** Invite a participant — pass exactly one of `agentId` or `number`. Starts a conference first if none is active. */
68
92
  addConferenceMember(opts: {
69
93
  agentId?: string;
70
94
  number?: string;
71
95
  }): void;
96
+ /** Remove a member from the conference (moderator only). */
72
97
  kickConferenceMember(memberId: string): void;
98
+ /** Hold or unhold an individual conference member (moderator only). */
73
99
  holdConferenceMember(memberId: string, on: boolean): void;
100
+ /** Mute or unmute an individual conference member (moderator only). */
74
101
  muteConferenceMember(memberId: string, on: boolean): void;
102
+ /** End the whole conference for everyone (moderator only). */
75
103
  endConference(): void;
104
+ /** Drop only the agent's own leg; the other members stay connected. */
76
105
  leaveConference(): void;
106
+ /** Add seconds to the after-call-work countdown (default 30). Show only when `wrapUp.canExtend`. */
77
107
  wrapUpExtend(seconds?: number): void;
108
+ /** End after-call work early. Show only when `wrapUp.canCancel`. */
78
109
  wrapUpCancel(): void;
110
+ /** Clear a blocked line (busy / unreachable / declined) so new calls reach the agent again. */
79
111
  resetLineStatus(): void;
112
+ /** Begin recording the current call. Gated on `agent.canRecord`. */
80
113
  startRecording(callId: string): void;
114
+ /** Stop the call's active recording. */
81
115
  stopRecording(callId: string): void;
116
+ /** Toggle the "flagged" mark on the call's active recording. */
82
117
  flagRecording(callId: string): void;
118
+ /** Replace the tags on the call's active recording (choose from `agent.availableTags`). */
83
119
  setRecordingTags(callId: string, tags: string[]): void;
120
+ /** Turn the in-browser WebRTC phone on or off. With it off, set an agent number so calls bridge there. */
84
121
  setWebrtc(on: boolean): void;
122
+ /** Set the agent's external phone number; the backend bridges calls there when WebRTC is off. */
85
123
  setAgentNumber(number: string): void;
86
124
  /** Send an SMS. `from` may be empty (server picks the default); `session` carries CTI/embedding correlation. */
87
125
  sendSms(to: string, text: string, opts?: {
package/dist/client.js CHANGED
@@ -28,7 +28,18 @@ export class BabelconnectClient {
28
28
  });
29
29
  this.rpc = createClient(Agent, transport);
30
30
  }
31
- /** Open the session and start mirroring server state. */
31
+ /**
32
+ * Open the session and start mirroring server state. Returns synchronously and queues intents until the
33
+ * stream is live, so you can subscribe and register immediately.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const bc = BabelconnectClient.connect({ serverUrl, token });
38
+ * bc.subscribe(render); // render(AgentView) on every update
39
+ * bc.register(); // announce reachability + load deployment data
40
+ * bc.placeCall("+15551234567"); // the result arrives as a callUpsert patch
41
+ * ```
42
+ */
32
43
  static connect(opts) {
33
44
  const c = new BabelconnectClient(opts);
34
45
  void c.runSubscribe();
@@ -47,6 +58,12 @@ export class BabelconnectClient {
47
58
  return this.cache.current.activeCalls[0];
48
59
  }
49
60
  // --- intents ---
61
+ /**
62
+ * Announce the agent and load its deployment data (presence options, caller-ID numbers, phonebook, feature
63
+ * config) — call this once after {@link BabelconnectClient.subscribe}. It also marks the agent
64
+ * **WebRTC-reachable** on the backend, so a control-only client that takes calls should follow it with
65
+ * {@link BabelconnectClient.setWebrtc}(false) + {@link BabelconnectClient.setAgentNumber}.
66
+ */
50
67
  register(capabilities = ["webrtc"]) {
51
68
  this.send(new Command({ command: { case: "register", value: new Register({ capabilities }) } }));
52
69
  }
@@ -70,18 +87,23 @@ export class BabelconnectClient {
70
87
  if (call)
71
88
  await this.doAnswer(call);
72
89
  }
90
+ /** End (or reject) a call by id. */
73
91
  hangup(callId) {
74
92
  this.send(new Command({ command: { case: "hangup", value: new Hangup({ callId }) } }));
75
93
  }
94
+ /** Mute or unmute the agent's own leg of a call. */
76
95
  mute(callId, on) {
77
96
  this.send(new Command({ command: { case: "mute", value: new Mute({ callId, on }) } }));
78
97
  }
98
+ /** Put a call on hold or retrieve it. */
79
99
  hold(callId, on) {
80
100
  this.send(new Command({ command: { case: "hold", value: new Hold({ callId, on }) } }));
81
101
  }
102
+ /** Send DTMF tones into the call (e.g. an IVR menu choice). Valid characters: `0`–`9`, `*`, `#`, `A`–`D`. */
82
103
  sendDigits(callId, digits) {
83
104
  this.send(new Command({ command: { case: "dtmf", value: new SendDigits({ callId, digits }) } }));
84
105
  }
106
+ /** Set the outbound caller ID the consumer sees (choose from `agent.availableNumbers`). */
85
107
  setDisplayAs(number) {
86
108
  this.send(new Command({ command: { case: "setDisplayAs", value: new SetDisplayAs({ number }) } }));
87
109
  }
@@ -105,9 +127,11 @@ export class BabelconnectClient {
105
127
  }));
106
128
  }
107
129
  // --- Conferences ---
130
+ /** Open a conference around the current call. `hold` parks that call while you add members and consult. */
108
131
  startConference(hold = false) {
109
132
  this.send(new Command({ command: { case: "startConference", value: new StartConference({ hold }) } }));
110
133
  }
134
+ /** Invite a participant — pass exactly one of `agentId` or `number`. Starts a conference first if none is active. */
111
135
  addConferenceMember(opts) {
112
136
  this.send(new Command({
113
137
  command: {
@@ -116,45 +140,59 @@ export class BabelconnectClient {
116
140
  },
117
141
  }));
118
142
  }
143
+ /** Remove a member from the conference (moderator only). */
119
144
  kickConferenceMember(memberId) {
120
145
  this.send(new Command({ command: { case: "kickConferenceMember", value: new KickConferenceMember({ memberId }) } }));
121
146
  }
147
+ /** Hold or unhold an individual conference member (moderator only). */
122
148
  holdConferenceMember(memberId, on) {
123
149
  this.send(new Command({ command: { case: "holdConferenceMember", value: new HoldConferenceMember({ memberId, on }) } }));
124
150
  }
151
+ /** Mute or unmute an individual conference member (moderator only). */
125
152
  muteConferenceMember(memberId, on) {
126
153
  this.send(new Command({ command: { case: "muteConferenceMember", value: new MuteConferenceMember({ memberId, on }) } }));
127
154
  }
155
+ /** End the whole conference for everyone (moderator only). */
128
156
  endConference() {
129
157
  this.send(new Command({ command: { case: "endConference", value: new EndConference({}) } }));
130
158
  }
159
+ /** Drop only the agent's own leg; the other members stay connected. */
131
160
  leaveConference() {
132
161
  this.send(new Command({ command: { case: "leaveConference", value: new LeaveConference({}) } }));
133
162
  }
163
+ /** Add seconds to the after-call-work countdown (default 30). Show only when `wrapUp.canExtend`. */
134
164
  wrapUpExtend(seconds = 30) {
135
165
  this.send(new Command({ command: { case: "wrapUpExtend", value: new WrapUpExtend({ seconds }) } }));
136
166
  }
167
+ /** End after-call work early. Show only when `wrapUp.canCancel`. */
137
168
  wrapUpCancel() {
138
169
  this.send(new Command({ command: { case: "wrapUpCancel", value: new WrapUpCancel({}) } }));
139
170
  }
171
+ /** Clear a blocked line (busy / unreachable / declined) so new calls reach the agent again. */
140
172
  resetLineStatus() {
141
173
  this.send(new Command({ command: { case: "resetLineStatus", value: new ResetLineStatus({}) } }));
142
174
  }
175
+ /** Begin recording the current call. Gated on `agent.canRecord`. */
143
176
  startRecording(callId) {
144
177
  this.send(new Command({ command: { case: "startRecording", value: new StartRecording({ callId }) } }));
145
178
  }
179
+ /** Stop the call's active recording. */
146
180
  stopRecording(callId) {
147
181
  this.send(new Command({ command: { case: "stopRecording", value: new StopRecording({ callId }) } }));
148
182
  }
183
+ /** Toggle the "flagged" mark on the call's active recording. */
149
184
  flagRecording(callId) {
150
185
  this.send(new Command({ command: { case: "flagRecording", value: new FlagRecording({ callId }) } }));
151
186
  }
187
+ /** Replace the tags on the call's active recording (choose from `agent.availableTags`). */
152
188
  setRecordingTags(callId, tags) {
153
189
  this.send(new Command({ command: { case: "setRecordingTags", value: new SetRecordingTags({ callId, tags }) } }));
154
190
  }
191
+ /** Turn the in-browser WebRTC phone on or off. With it off, set an agent number so calls bridge there. */
155
192
  setWebrtc(on) {
156
193
  this.send(new Command({ command: { case: "setWebrtc", value: new SetWebrtc({ on }) } }));
157
194
  }
195
+ /** Set the agent's external phone number; the backend bridges calls there when WebRTC is off. */
158
196
  setAgentNumber(number) {
159
197
  this.send(new Command({ command: { case: "setAgentNumber", value: new SetAgentNumber({ number }) } }));
160
198
  }
@@ -2,7 +2,7 @@
2
2
  * `@babelforce/babelconnect-sdk/embed` — embed the babelconnect agent app (the
3
3
  * server-served Flutter web app) into a host page via an `<iframe>` and a two-way
4
4
  * `postMessage` bridge. See the Embedding guide at
5
- * https://babelforce.github.io/babelconnect-sdk-docs/ for the full protocol.
5
+ * https://babelforce.github.io/babelconnect-sdk/ for the full protocol.
6
6
  * The embedded app talks only to babelconnect-server.
7
7
  *
8
8
  * @example
@@ -2,7 +2,7 @@
2
2
  * `@babelforce/babelconnect-sdk/embed` — embed the babelconnect agent app (the
3
3
  * server-served Flutter web app) into a host page via an `<iframe>` and a two-way
4
4
  * `postMessage` bridge. See the Embedding guide at
5
- * https://babelforce.github.io/babelconnect-sdk-docs/ for the full protocol.
5
+ * https://babelforce.github.io/babelconnect-sdk/ for the full protocol.
6
6
  * The embedded app talks only to babelconnect-server.
7
7
  *
8
8
  * @example
@@ -1,6 +1,6 @@
1
1
  import { AgentView, type StateUpdate } from "./gen/babelconnect/v1/babelconnect_pb.js";
2
2
  /**
3
- * The client-side mirror of the server-authoritative {@link AgentView}.
3
+ * The client-side mirror of the server-authoritative `AgentView`.
4
4
  *
5
5
  * It applies `StateUpdate` snapshots and entity-level patches **mechanically** —
6
6
  * there is no domain logic here, by design: the server reduces, the client
@@ -1,6 +1,6 @@
1
1
  import { AgentView } from "./gen/babelconnect/v1/babelconnect_pb.js";
2
2
  /**
3
- * The client-side mirror of the server-authoritative {@link AgentView}.
3
+ * The client-side mirror of the server-authoritative `AgentView`.
4
4
  *
5
5
  * It applies `StateUpdate` snapshots and entity-level patches **mechanically** —
6
6
  * there is no domain logic here, by design: the server reduces, the client
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@babelforce/babelconnect-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.6.1",
4
4
  "description": "TypeScript SDK for babelconnect — server-authoritative agent state over gRPC-web, native WebRTC audio, and an embeddable widget (iframe + postMessage) for the Flutter web app.",
5
5
  "license": "Apache-2.0",
6
- "homepage": "https://babelforce.github.io/babelconnect-sdk-docs/",
6
+ "homepage": "https://babelforce.github.io/babelconnect-sdk/",
7
7
  "type": "module",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -39,8 +39,8 @@
39
39
  "devDependencies": {
40
40
  "@bufbuild/protoc-gen-es": "^1.10.1",
41
41
  "@connectrpc/protoc-gen-connect-es": "^1.6.1",
42
- "typedoc": "^0.27.0",
43
- "typedoc-plugin-markdown": "^4.4.0",
42
+ "typedoc": "~0.27.0",
43
+ "typedoc-plugin-markdown": "4.4.0",
44
44
  "typescript": "^5.6.0"
45
45
  },
46
46
  "publishConfig": {