@poolse/native 3.8.0 → 3.10.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +127 -9
  3. package/android/src/main/AndroidManifest.xml +4 -0
  4. package/android/src/main/java/dev/poolse/callcore/CallCoreRuntime.kt +8 -0
  5. package/android/src/main/java/dev/poolse/callcore/Ports.kt +47 -1
  6. package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +3 -3
  7. package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +112 -10
  8. package/android/src/main/java/dev/poolse/callcore/android/CallHttpClient.kt +3 -0
  9. package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +21 -1
  10. package/android/src/main/java/dev/poolse/callcore/android/CallVideo.kt +14 -0
  11. package/android/src/main/java/dev/poolse/callcore/android/EscalationNotification.kt +475 -0
  12. package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +9 -4
  13. package/android/src/main/java/dev/poolse/callcore/android/MeetingNotification.kt +127 -0
  14. package/android/src/main/java/dev/poolse/callcore/android/PoolseIncomingCall.kt +9 -0
  15. package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +9 -0
  16. package/android/src/main/java/dev/poolse/callcore/android/SnapshotJson.kt +23 -0
  17. package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +17 -1
  18. package/android/src/main/livekit/java/dev/poolse/callcore/livekit/LiveKitMediaPort.kt +174 -11
  19. package/dist/index.cjs +33 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +197 -23
  22. package/dist/index.d.ts +197 -23
  23. package/dist/index.js +26 -1
  24. package/dist/index.js.map +1 -1
  25. package/ios/Core/CallCoreRuntime.swift +8 -0
  26. package/ios/Core/CallHttpClient.swift +11 -1
  27. package/ios/Core/Ports.swift +47 -2
  28. package/ios/Core/SnapshotEncoding.swift +39 -4
  29. package/ios/Module/PoolseCallsModule.swift +28 -1
  30. package/ios/Platform/CallCore.swift +68 -2
  31. package/ios/Platform/CallKitController.swift +1 -1
  32. package/ios/Platform/EscalationNotifications.swift +195 -0
  33. package/ios/Platform/LiveKitMediaPort.swift +178 -15
  34. package/ios/Platform/MessageNotifications.swift +60 -1
  35. package/ios/Platform/VoipPush.swift +11 -2
  36. package/package.json +1 -1
  37. package/src/index.ts +231 -23
package/CHANGELOG.md CHANGED
@@ -2,6 +2,61 @@
2
2
 
3
3
  Formerly `@poolse/react-native-calls` (0.x).
4
4
 
5
+ ## [3.10.0] - 2026-11-23
6
+
7
+ ### Added
8
+
9
+ - Agents in calls (AGENTS_IN_CALLS.md): `participants` lists agents in the
10
+ call with `isAgent`, `agentLabel` and `agentMode` (token metadata `agent:
11
+ true`); they never keep a call alive (the alone check skips them) and an
12
+ agent joining is not someone answering.
13
+ - Escalations from the lock screen: Android posts the `agent_escalation`
14
+ data push natively with Approve / Decline / Answer (RemoteInput); iOS
15
+ registers the `poolse_agent_escalation` category (Approve, Decline and a
16
+ `UNTextInputNotificationAction` Answer). Both reply natively — `POST
17
+ /v1/agent-escalations/:id/reply` with the push's `reply_token`, no
18
+ session, no JS — and report through `onNotificationAction` with `action:
19
+ "escalation"` (`escalationId`, `decision`, `ok`, `error`); new
20
+ `onEscalationAction`. `messageReplyRequiresUnlock` covers these actions
21
+ too.
22
+
23
+ - Meeting rings (CA4): a ring push with `ring_type: "meeting"` and
24
+ `meeting_title` shows "Weekly sync is starting" on CallKit and on the
25
+ Android ring notification and screen, with Join / Not now buttons on
26
+ Android. `RingContext` gains `ringType`, `meetingTitle` and `meetingId`
27
+ (defaulted). Snapshots and `waiting` carry `ringType` and `meetingTitle`.
28
+ Custom Android ring activities get `EXTRA_RING_TYPE`, `EXTRA_MEETING_TITLE`
29
+ and `EXTRA_TITLE`.
30
+ - Meeting notices (MEETINGS.md §11.3). Android posts `type: "meeting"` data
31
+ pushes (`starting` with Join, `brief`) on a new "Meetings" channel. iOS
32
+ registers the `poolse_meeting` category with a Join action. A tap and Join
33
+ reach JS as a `CallAction` of type `open` / `join_meeting`, with the new
34
+ `scheduledMeetingId`. `takeCallAction` and `onCallAction` now work on iOS
35
+ too, for meeting notices.
36
+ - Noise suppression and background blur (CL7): `setNoiseSuppression`,
37
+ `noiseSuppressionSupported`, `setBackgroundBlur` and
38
+ `backgroundBlurSupported`. Snapshots carry `noiseSuppression` and
39
+ `backgroundBlur`. Blur works on iOS 15+ (LiveKit's
40
+ BackgroundBlurVideoProcessor). It is not available on Android yet.
41
+ - Move a call to this device (CL11): `moveCallHere(callId, options)`. The
42
+ device that lost the call gets `movedElsewhere: true` and ends with the new
43
+ reason `'moved'`, detected from LiveKit's duplicate-identity disconnect.
44
+
45
+ ## 3.9.0 — 2026-11-22
46
+
47
+ - Recording and transcripts (server docs/RECORDING.md). poolse's transcript
48
+ assistant (`poolse:…`, LiveKit kind agent) and LiveKit Egress's recorder
49
+ (`EG_…`, kind egress) are no longer reported as people: they are left out of
50
+ `participants`, video tiles, "someone answered" and the count that ends a
51
+ call left alone (SIP participants stay).
52
+ - Snapshots carry `canPublish`, `recording` and `transcription` (the
53
+ CallSummary's objects from answer / join / place / reconnect; `null` from a
54
+ server without them). New types `CallRecordingState`, `CallTranscriptionState`.
55
+ - Recording consent: when the server revokes publishing, the core stops
56
+ publishing without errors and keeps the mic / camera choices; when it comes
57
+ back it republishes them. `republish()` (for ConsentPrompt's `onAccepted`)
58
+ and `onCanPublishChange(cb)`.
59
+
5
60
  ## 3.8.0 — 2026-11-21
6
61
 
7
62
  - Several workspaces (servers) at once:
package/README.md CHANGED
@@ -109,6 +109,9 @@ The full API:
109
109
  - Several workspaces: `addServer`, `removeServer`, `listServers`,
110
110
  `serverOfNotification`, `DEFAULT_SERVER_ID`, `serverId` on `place` / `join`
111
111
  / `startRoom` and in snapshots, taps and action results (see below).
112
+ - Recording and transcripts: `snapshot.recording` / `snapshot.transcription`
113
+ (the server's state as of joining), `snapshot.canPublish`,
114
+ `onCanPublishChange`, `republish` (see below).
112
115
  - Socket forwarding (optional): `onCallFinished`, `onRingEnded`. Feed them
113
116
  from `@poolse/sdk` 3.1's user channel:
114
117
 
@@ -118,6 +121,89 @@ The full API:
118
121
  userChannel.onCallFinished((e) => calls.onCallFinished(e.call_id, e.reason));
119
122
  ```
120
123
 
124
+ ## Recording, consent and transcripts
125
+
126
+ When the server records or transcribes a call (docs/RECORDING.md on the
127
+ server), the core:
128
+
129
+ - leaves poolse's own participants out of everything it reports — the
130
+ transcript assistant (`poolse:assistant:…`, LiveKit kind agent) and the
131
+ recorder (LiveKit Egress, `EG_…`). They are never in
132
+ `snapshot.participants`, never get a video tile, never count as someone
133
+ answering, and don't keep a call alive when everyone else has left.
134
+ Phone (SIP) participants are listed as usual.
135
+ - carries the call's `recording` and `transcription` objects into the
136
+ snapshot, as the server sent them on answer / join / place and each
137
+ reconnect, so the indicator shows without another request. Later changes
138
+ come on the conversation socket (`recording:*`, `transcript:*`): use those
139
+ for anything after joining.
140
+ - follows the server's publish permission. With `consent: "required"`, the
141
+ server turns publishing off until you accept: `snapshot.canPublish` turns
142
+ `false`, nothing of yours goes out (you still hear and see the call), and
143
+ mute / camera taps are remembered rather than refused. Once you accept,
144
+ the server turns it back on and the core publishes the mic and camera as
145
+ you last had them. Call `republish()` from ConsentPrompt's `onAccepted` as
146
+ well; it is harmless before the permission is back.
147
+
148
+ ```ts
149
+ <ConsentPrompt onAccepted={() => calls.republish()} … />
150
+
151
+ const off = calls.onCanPublishChange((allowed) => setListenOnly(!allowed));
152
+ ```
153
+
154
+ ## Meetings: scheduled rings, background and noise, moving a call
155
+
156
+ **A meeting starting rings.** When a scheduled meeting is set to ring
157
+ everyone, the server sends the usual ring push with `ring_type: "meeting"`
158
+ and `meeting_title` (also `meeting_id`, `starts_at`). CallKit and the
159
+ Android ring screen then read "Weekly sync is starting" (with the
160
+ workspace, "Weekly sync is starting · Acme", when several are signed in),
161
+ and the Android buttons read Join / Not now. Answering joins the meeting's
162
+ room like any call. The snapshot says so too: `ringType: 'meeting'` and
163
+ `meetingTitle`, so the call screen can name the meeting.
164
+
165
+ **Meeting notices.** The server's "is starting" notice (for meetings set to
166
+ notify rather than ring) and the brief a few minutes before
167
+ (MEETINGS.md §11.3) are shown with the app closed. On Android the core posts
168
+ the `type: "meeting"` data push itself, on a "Meetings" channel, with the
169
+ workspace as subtext when several are signed in. "Starting" has a Join
170
+ button. A brief is replaced by that meeting's "starting" notice, and a
171
+ redelivered push is not posted twice. On iOS the server sends an alert push
172
+ with category `poolse_meeting`, and the core registers that category with a
173
+ Join action (`poolse_meeting_join`). On both platforms the tap and Join reach
174
+ the app as a `CallAction`: `{ type: 'open' | 'join_meeting', conversationId,
175
+ callId, media, serverId, scheduledMeetingId }`, through `takeCallAction()`
176
+ on a cold start and `onCallAction` while running. On Join, join the room
177
+ (`rooms.start(conversationId, media)` joins what is live). The core never
178
+ joins by itself.
179
+
180
+ **Noise suppression and background blur.**
181
+ `setNoiseSuppression(on)` / `noiseSuppressionSupported()`: on by default.
182
+ Android switches WebRTC's noise suppression on the microphone (echo
183
+ cancellation stays on). iOS uses Apple's voice processing, which does echo
184
+ cancellation and noise suppression together, so off bypasses both: offer
185
+ "off" only for headphones. `setBackgroundBlur(on)` /
186
+ `backgroundBlurSupported()`: iOS 15+ blurs behind you with Vision person
187
+ segmentation, kept across camera flips. Android has no blur yet: it needs an
188
+ ML Kit segmentation model, so it is planned for later, and
189
+ `backgroundBlurSupported()` is `false` there. Background pictures are not
190
+ available on native yet. The snapshot carries `noiseSuppression` and
191
+ `backgroundBlur`.
192
+
193
+ **Keep the call while you work.** Picture-in-picture for video calls is
194
+ `setPictureInPictureEnabled(true)` while a video call shows someone, and a
195
+ `<CallVideoView pictureInPicture>` on the main picture (iOS 15+); on Android
196
+ the whole activity floats (the plugin's `pictureInPicture` option), so draw
197
+ a compact layout while `isInPictureInPicture()`.
198
+
199
+ **Move a call to this device.**
200
+ `moveCallHere(callId, { conversationId, sessionToken, serverId? })` joins a
201
+ call you are on elsewhere from this device. The server keeps one device per
202
+ person in a call, so the other device is let go. Its snapshot gets
203
+ `movedElsewhere: true` and ends with `reason: 'moved'`: show "Moved to your
204
+ other device", not "Call ended". Offer it where `liveCalls` shows you already
205
+ in the call.
206
+
121
207
  ## Ringtone
122
208
 
123
209
  ```json
@@ -197,15 +283,18 @@ The ring notification's full-screen intent and heads-up tap start it with
197
283
  `FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP` and these extras (constants
198
284
  on `dev.poolse.callcore.android.PoolseIncomingCall`):
199
285
 
200
- | Extra | Key | Type |
201
- | ------------------------- | -------------------------- | ---------------------- |
202
- | `EXTRA_CALL_ID` | `poolse_call_id` | String |
203
- | `EXTRA_CONVERSATION_ID` | `poolse_conversation_id` | String |
204
- | `EXTRA_CONVERSATION_NAME` | `poolse_conversation_name` | String, may be null |
205
- | `EXTRA_CALLER_NAME` | `poolse_caller_name` | String, may be null |
206
- | `EXTRA_CALLER_AVATAR_URL` | `poolse_caller_avatar_url` | String, may be null |
207
- | `EXTRA_MEDIA` | `poolse_media` | `"audio"` or `"video"` |
208
- | `EXTRA_RING_DEADLINE` | `poolse_ring_deadline` | Long, epoch ms |
286
+ | Extra | Key | Type |
287
+ | ------------------------- | -------------------------- | --------------------------------------------------------------------- |
288
+ | `EXTRA_CALL_ID` | `poolse_call_id` | String |
289
+ | `EXTRA_CONVERSATION_ID` | `poolse_conversation_id` | String |
290
+ | `EXTRA_CONVERSATION_NAME` | `poolse_conversation_name` | String, may be null |
291
+ | `EXTRA_CALLER_NAME` | `poolse_caller_name` | String, may be null |
292
+ | `EXTRA_CALLER_AVATAR_URL` | `poolse_caller_avatar_url` | String, may be null |
293
+ | `EXTRA_MEDIA` | `poolse_media` | `"audio"` or `"video"` |
294
+ | `EXTRA_RING_DEADLINE` | `poolse_ring_deadline` | Long, epoch ms |
295
+ | `EXTRA_RING_TYPE` | `poolse_ring_type` | `"call"` or `"meeting"` |
296
+ | `EXTRA_MEETING_TITLE` | `poolse_meeting_title` | String or null |
297
+ | `EXTRA_TITLE` | `poolse_title` | The headline: "Weekly sync is starting", or the conversation / caller |
209
298
 
210
299
  plus an opaque `poolse_ring` bundle that the functions below read; pass them
211
300
  the Intent you were started with (and the new one in `onNewIntent`):
@@ -289,6 +378,35 @@ expo-notifications also hands these responses to its own JS listeners: in
289
378
  `addNotificationResponseReceivedListener`, ignore an `actionIdentifier` of
290
379
  `reply` or `mark_read` (only the default tap should open the chat).
291
380
 
381
+ ## Agents in calls and escalations
382
+
383
+ `participants` lists agents in the call (server docs/AGENTS_IN_CALLS.md)
384
+ with `isAgent: true`, `agentLabel` ("Scout", "Jasir's agent") and
385
+ `agentMode`; show them with the Agent badge, never as a person. They never
386
+ keep a call alive.
387
+
388
+ Your agent attending a meeting for you asks by push (`type:
389
+ "agent_escalation"`). The core shows it with **Approve**, **Decline** and
390
+ **Answer** (a text field) and replies natively — from the lock screen, app
391
+ closed, no session — with the push's `reply_token` to `POST
392
+ /v1/agent-escalations/:id/reply` on the push's server.
393
+
394
+ - **Android**: the data push is posted on the "Questions from your agent"
395
+ channel; it times out at `expires_at`. After a reply it reads "Approved —
396
+ your agent will say so." and goes; a failure says why and keeps the
397
+ actions while trying again can work.
398
+ - **iOS**: an alert push with category `poolse_agent_escalation`
399
+ (time-sensitive); the core registers the category (actions
400
+ `poolse_escalation_approve`, `poolse_escalation_decline`,
401
+ `poolse_escalation_answer`) beside `poolse_message`. A failure posts
402
+ "Couldn't send your answer" with the same actions. In
403
+ `addNotificationResponseReceivedListener`, ignore those action ids.
404
+
405
+ Results arrive as `onNotificationAction` (or `onEscalationAction`) with
406
+ `action: 'escalation'`, `escalationId`, `decision`, `ok`, `error`. The
407
+ token works once: a reply is retried only when no answer came back.
408
+ `messageReplyRequiresUnlock` makes these actions ask for the unlock too.
409
+
292
410
  ## Signed in to several workspaces
293
411
 
294
412
  The core can serve several API servers at once — one per workspace the user
@@ -30,6 +30,10 @@
30
30
  android:name="dev.poolse.callcore.android.MessageActionReceiver"
31
31
  android:exported="false" />
32
32
 
33
+ <receiver
34
+ android:name="dev.poolse.callcore.android.EscalationActionReceiver"
35
+ android:exported="false" />
36
+
33
37
  <service
34
38
  android:name="dev.poolse.callcore.android.CallForegroundService"
35
39
  android:exported="false"
@@ -143,6 +143,12 @@ class CallCoreRuntime(
143
143
  /** `room` or `call`, once the server's bundle says; null before. Runtime thread only. */
144
144
  val callKind: String? get() = bundle?.kind
145
145
 
146
+ /**
147
+ * The bundle's capture state (`recording`, `transcription` as JSON
148
+ * text), as of the last answer/join/place/reconnect. Runtime thread only.
149
+ */
150
+ val capture: Pair<String?, String?> get() = bundle?.recording to bundle?.transcription
151
+
146
152
  /**
147
153
  * The current call's id and control token — what authorizes acting on
148
154
  * the call itself (ringing more people in). Null with no session yet.
@@ -301,6 +307,8 @@ class CallCoreRuntime(
301
307
  fun switchCamera() = post { media.switchCamera() }
302
308
  fun setSpeaker(on: Boolean) = post { media.setSpeaker(on) }
303
309
  fun setAudioOutput(id: String) = post { media.setAudioOutput(id) }
310
+ /** Consent given: publish the mic/camera again (a no-op until the server allows it). */
311
+ fun republish() = post { media.republish() }
304
312
 
305
313
  /** Re-emit the current state (the bridge's roster/route changed). */
306
314
  fun reemit() = post { if (state.phase != Phase.IDLE) sink.emit(state) }
@@ -57,6 +57,13 @@ data class CallSessionBundle(
57
57
  val kind: String = "call",
58
58
  /** How many people the server says are being rung right now. */
59
59
  val ringing: Int = 0,
60
+ /**
61
+ * The CallSummary's `recording` / `transcription` objects as JSON text
62
+ * (docs/RECORDING.md), carried to the snapshot untouched; null from a
63
+ * server before them.
64
+ */
65
+ val recording: String? = null,
66
+ val transcription: String? = null,
60
67
  )
61
68
 
62
69
  /** LiveKit (or any SFU) — media only, no lifecycle opinions. */
@@ -78,6 +85,25 @@ interface MediaPort {
78
85
  * speaker toggle.
79
86
  */
80
87
  fun setAudioOutput(id: String) = setSpeaker(id == "speaker")
88
+
89
+ /**
90
+ * Publish the mic and camera again as the user last had them, once the
91
+ * server lets this participant publish (consent given, docs/RECORDING.md §5).
92
+ */
93
+ fun republish() {}
94
+ }
95
+
96
+ /**
97
+ * poolse's own participants in a room — the transcript assistant
98
+ * (`poolse:assistant:<call>`, kind AGENT) and LiveKit Egress's recorder
99
+ * (`EG_…`, kind EGRESS). They are not people: never in the roster, never
100
+ * counted as someone in the call (docs/RECORDING.md §7). SIP (phone)
101
+ * participants are people and stay.
102
+ */
103
+ object ServiceParticipants {
104
+ /** [kind]: LiveKit's participant kind, lowercased (`agent`, `egress`, `sip`, …). */
105
+ fun isService(identity: String, kind: String?): Boolean =
106
+ identity.startsWith("poolse:") || identity.startsWith("EG_") || kind == "agent" || kind == "egress"
81
107
  }
82
108
 
83
109
  /** The ring UX: CallStyle notification + full-screen activity + tones. */
@@ -120,7 +146,27 @@ data class RingContext(
120
146
  val serverId: String? = null,
121
147
  /** The push's `workspace_name`, for "Ana · Acme" when several servers are signed in. */
122
148
  val workspaceName: String? = null,
123
- )
149
+ /**
150
+ * The push's `ring_type`: `"meeting"` for a scheduled meeting starting
151
+ * (CA4), `"call"` (or null, older servers) for a person calling.
152
+ */
153
+ val ringType: String? = null,
154
+ /** The push's `meeting_title` ("Weekly sync"), meeting rings only. */
155
+ val meetingTitle: String? = null,
156
+ /** The push's `meeting_id`, meeting rings only. */
157
+ val meetingId: String? = null,
158
+ ) {
159
+ /** A scheduled meeting starting, not a person calling. */
160
+ val isMeeting: Boolean get() = ringType == "meeting"
161
+
162
+ /**
163
+ * What the ring surface names, before any workspace suffix: "Weekly
164
+ * sync is starting" for a meeting, else the conversation or caller.
165
+ */
166
+ val displayTitle: String?
167
+ get() = if (isMeeting) "${meetingTitle ?: conversationName ?: "Meeting"} is starting"
168
+ else conversationName ?: callerName
169
+ }
124
170
 
125
171
  /** Android: the phoneCall foreground service. iOS: the CallKit session. */
126
172
  interface CallSessionPort {
@@ -130,7 +130,7 @@ internal class AndroidRingSurface(
130
130
  val answer = incomingActivity(autoAnswer = true, requestOffset = 2)
131
131
 
132
132
  val caller = Person.Builder()
133
- .setName(ServerRegistry.ringTitle(context, ring, ring.conversationName ?: ring.callerName) ?: "Incoming call")
133
+ .setName(ServerRegistry.ringTitle(context, ring, ring.displayTitle) ?: "Incoming call")
134
134
  .setImportant(true)
135
135
  .build()
136
136
 
@@ -210,14 +210,14 @@ internal class AndroidRingSurface(
210
210
  PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
211
211
  )
212
212
 
213
- val who = ServerRegistry.ringTitle(context, ring, ring.conversationName ?: ring.callerName) ?: "Someone"
213
+ val who = ServerRegistry.ringTitle(context, ring, ring.displayTitle) ?: "Someone"
214
214
  val what = if (ring.media == "video") "video call" else "call"
215
215
  val notification = NotificationCompat.Builder(context, WAITING_CHANNEL_ID)
216
216
  .setSmallIcon(config.smallIcon)
217
217
  .setCategory(NotificationCompat.CATEGORY_CALL)
218
218
  .setPriority(NotificationCompat.PRIORITY_HIGH)
219
219
  .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
220
- .setContentTitle("$who — incoming $what")
220
+ .setContentTitle(if (ring.isMeeting) who else "$who — incoming $what")
221
221
  .setContentText("You're on a call. Answering ends it.")
222
222
  .setOngoing(true)
223
223
  .setAutoCancel(false)
@@ -89,6 +89,17 @@ class CallCore private constructor(context: Context) {
89
89
  private var audioOutputId: String? = null
90
90
  private var connectionQuality = "unknown"
91
91
  private var videoPaused = false
92
+ /** False while the server holds our media back (recording consent). */
93
+ private var canPublish = true
94
+ /** Capture processing (CL7): per process, not per call. */
95
+ private var noiseSuppression = true
96
+ private var backgroundBlur = false
97
+ /**
98
+ * This call was taken over by the same user on another device (CL11):
99
+ * the SFU replaced our participant (duplicate identity). The end that
100
+ * follows reads `reason: 'moved'`.
101
+ */
102
+ private var movedElsewhere = false
92
103
 
93
104
  /** Last snapshot emitted; read by the bridge's getCallState from any thread. */
94
105
  @Volatile private var lastSnapshot: Map<String, Any?>? = null
@@ -106,6 +117,9 @@ class CallCore private constructor(context: Context) {
106
117
  /** The push's `workspace_name` per ringing call. */
107
118
  private val ringWorkspaces = java.util.concurrent.ConcurrentHashMap<String, String>()
108
119
 
120
+ /** Meeting rings (CA4) per call: the meeting's title, "" when it has none. Absent: a person calling. */
121
+ private val ringMeetings = java.util.concurrent.ConcurrentHashMap<String, String>()
122
+
109
123
  /**
110
124
  * A ring arrived — from FCM (closed app) or the socket (open app).
111
125
  * Bound to its server before the runtime sees it: a busy-decline runs
@@ -122,6 +136,10 @@ class CallCore private constructor(context: Context) {
122
136
  if (ringWorkspaces.size > 16) ringWorkspaces.clear()
123
137
  ringWorkspaces[ring.callId] = it
124
138
  }
139
+ if (ring.isMeeting) {
140
+ if (ringMeetings.size > 16) ringMeetings.clear()
141
+ ringMeetings[ring.callId] = ring.meetingTitle ?: ""
142
+ }
125
143
  }
126
144
 
127
145
  /**
@@ -253,6 +271,34 @@ class CallCore private constructor(context: Context) {
253
271
  return true
254
272
  }
255
273
 
274
+ /**
275
+ * Noise suppression on the microphone (CL7), on by default. Kept
276
+ * across calls for this process. False when the engine can't change
277
+ * it (the signalling-only build).
278
+ */
279
+ fun setNoiseSuppression(on: Boolean): Boolean {
280
+ val source = media as? CaptureProcessingSource ?: return false
281
+ // On the runtime's (main) thread: the media port only touches its room there.
282
+ runtime.post { noiseSuppression = on; source.setNoiseSuppression(on) }
283
+ runtime.reemit()
284
+ return true
285
+ }
286
+
287
+ /** Background blur on the camera (CL7); a no-op where unsupported. */
288
+ fun setBackgroundBlur(on: Boolean): Boolean {
289
+ val source = media as? CaptureProcessingSource ?: return false
290
+ if (!source.backgroundBlurSupported) return false
291
+ runtime.post { backgroundBlur = on; source.setBackgroundBlur(on) }
292
+ runtime.reemit()
293
+ return true
294
+ }
295
+
296
+ val noiseSuppressionSupported: Boolean
297
+ get() = (media as? CaptureProcessingSource)?.noiseSuppressionSupported ?: false
298
+
299
+ val backgroundBlurSupported: Boolean
300
+ get() = (media as? CaptureProcessingSource)?.backgroundBlurSupported ?: false
301
+
256
302
  /** Whether this build's media engine can share the screen. */
257
303
  val screenShareSupported: Boolean get() = media is ScreenShareSource
258
304
 
@@ -276,6 +322,12 @@ class CallCore private constructor(context: Context) {
276
322
  */
277
323
  fun setAudioOutput(id: String) = runtime.setAudioOutput(id)
278
324
 
325
+ /**
326
+ * Consent given: publish the mic and camera again as the user last had
327
+ * them. Also happens by itself once the server lets us publish.
328
+ */
329
+ fun republish() = runtime.republish()
330
+
279
331
  /** The current call's id and control token. Any thread. */
280
332
  val control: Pair<String, String>? get() = runtime.control
281
333
 
@@ -320,15 +372,20 @@ class CallCore private constructor(context: Context) {
320
372
  conversationName = conversationName,
321
373
  kind = callKind,
322
374
  participants = roster.map {
323
- mapOf(
324
- "userId" to it.identity,
325
- "externalId" to it.externalId,
326
- "speaking" to it.speaking,
327
- "muted" to it.muted,
328
- "cameraOn" to it.cameraOn,
329
- "screenSharing" to it.screenSharing,
330
- "connectionQuality" to it.connectionQuality,
331
- )
375
+ buildMap<String, Any> {
376
+ put("userId", it.identity)
377
+ put("externalId", it.externalId)
378
+ put("speaking", it.speaking)
379
+ put("muted", it.muted)
380
+ put("cameraOn", it.cameraOn)
381
+ put("screenSharing", it.screenSharing)
382
+ put("connectionQuality", it.connectionQuality)
383
+ if (it.isAgent) {
384
+ put("isAgent", true)
385
+ it.agentLabel?.let { label -> put("agentLabel", label) }
386
+ it.agentMode?.let { mode -> put("agentMode", mode) }
387
+ }
388
+ }
332
389
  },
333
390
  audioRoute = audioRoute ?: if (loud(state)) "speaker" else "earpiece",
334
391
  audioOutputs = audioOutputs.map { mapOf("id" to it.id, "kind" to it.kind, "name" to it.name) },
@@ -340,6 +397,9 @@ class CallCore private constructor(context: Context) {
340
397
  connectionQuality = connectionQuality,
341
398
  videoPaused = videoPaused,
342
399
  screenSharing = screenSharing,
400
+ canPublish = canPublish,
401
+ recording = runtime.capture.first,
402
+ transcription = runtime.capture.second,
343
403
  )
344
404
  val withServers = snap?.let { withServers(it, state) }
345
405
  lastSnapshot = withServers
@@ -357,6 +417,16 @@ class CallCore private constructor(context: Context) {
357
417
  val out = snap.toMutableMap()
358
418
  out["serverId"] = serverId
359
419
  out["workspaceName"] = state.callId?.let { ringWorkspaces[it] } ?: servers.get(serverId)?.name
420
+ // A scheduled meeting that rang this device (CA4).
421
+ val meeting = state.callId?.let { ringMeetings[it] }
422
+ out["ringType"] = if (meeting != null) "meeting" else "call"
423
+ out["meetingTitle"] = meeting?.ifEmpty { null }
424
+ out["noiseSuppression"] = noiseSuppression
425
+ out["backgroundBlur"] = backgroundBlur
426
+ out["movedElsewhere"] = movedElsewhere
427
+ // Taken over by another of this user's devices: the machine ends it
428
+ // as `left` (CALL_CONTRACT.md §9); the app is told why.
429
+ if (movedElsewhere && state.phase == Phase.ENDED) out["reason"] = "moved"
360
430
  val waiting = snap["waiting"] as? Map<*, *>
361
431
  val ring = runtime.waitingRing
362
432
  if (waiting != null && ring != null) {
@@ -364,6 +434,8 @@ class CallCore private constructor(context: Context) {
364
434
  out["waiting"] = waiting.entries.associate { (k, v) -> k.toString() to v } + mapOf(
365
435
  "serverId" to waitingServer,
366
436
  "workspaceName" to (ring.workspaceName ?: servers.get(waitingServer)?.name),
437
+ "ringType" to (if (ring.isMeeting) "meeting" else "call"),
438
+ "meetingTitle" to ring.meetingTitle,
367
439
  )
368
440
  }
369
441
  return out
@@ -380,6 +452,7 @@ class CallCore private constructor(context: Context) {
380
452
  roster = emptyList()
381
453
  conversationName = null
382
454
  callKind = "call"
455
+ movedElsewhere = false
383
456
  mutedSelf = false
384
457
  // Reported by the media adapter once the camera is really published.
385
458
  cameraOn = false
@@ -390,6 +463,7 @@ class CallCore private constructor(context: Context) {
390
463
  audioOutputId = null
391
464
  connectionQuality = "unknown"
392
465
  videoPaused = false
466
+ canPublish = true
393
467
  }
394
468
 
395
469
  /**
@@ -445,7 +519,8 @@ class CallCore private constructor(context: Context) {
445
519
  override fun onRemoteJoined() = runtime.onRemoteJoined()
446
520
  override fun onParticipants(participants: List<MediaParticipant>) {
447
521
  runtime.post { roster = participants }
448
- runtime.onRemoteCount(participants.size)
522
+ // An agent keeps nobody company: a call left with only agents is over.
523
+ runtime.onRemoteCount(participants.count { !it.isAgent })
449
524
  runtime.reemit()
450
525
  }
451
526
  override fun onAudioRoute(route: String) {
@@ -456,6 +531,10 @@ class CallCore private constructor(context: Context) {
456
531
  runtime.post { cameraOn = on; cameraFacing = facing }
457
532
  runtime.reemit()
458
533
  }
534
+ override fun onCanPublish(allowed: Boolean) {
535
+ runtime.post { canPublish = allowed }
536
+ runtime.reemit()
537
+ }
459
538
  override fun onLocalScreen(on: Boolean) {
460
539
  runtime.post { screenSharing = on }
461
540
  runtime.reemit()
@@ -468,6 +547,9 @@ class CallCore private constructor(context: Context) {
468
547
  runtime.post { connectionQuality = quality; this@CallCore.videoPaused = videoPaused }
469
548
  runtime.reemit()
470
549
  }
550
+ override fun onMovedElsewhere() {
551
+ runtime.post { movedElsewhere = true }
552
+ }
471
553
  }
472
554
 
473
555
  private fun bringAppToFront(callId: String, from: Context?): Boolean {
@@ -726,6 +808,17 @@ interface MediaEvents {
726
808
  * whether incoming video is paused to keep the audio going.
727
809
  */
728
810
  fun onNetwork(quality: String, videoPaused: Boolean) {}
811
+ /**
812
+ * Whether the server lets us publish (false: recording consent not
813
+ * given yet, docs/RECORDING.md §5). Sent on every change.
814
+ */
815
+ fun onCanPublish(allowed: Boolean) {}
816
+ /**
817
+ * The SFU replaced us with the same user joining from another device
818
+ * ("move call to this device", CALL_CONTRACT.md §9). Sent just before
819
+ * [onLost].
820
+ */
821
+ fun onMovedElsewhere() {}
729
822
  }
730
823
 
731
824
  /** One place call audio can play — a snapshot `audioOutputs[]` entry. */
@@ -751,4 +844,13 @@ data class MediaParticipant(
751
844
  val externalId: String = identity,
752
845
  /** Their link to the SFU: `good` | `poor` | `lost` (dropped, coming back) | `unknown`. */
753
846
  val connectionQuality: String = "unknown",
847
+ /**
848
+ * An agent in the call (AGENTS_IN_CALLS.md §1): shown with the Agent
849
+ * badge, named [agentLabel], never counted as someone keeping the call up.
850
+ */
851
+ val isAgent: Boolean = false,
852
+ /** "Scout" / "Jasir's agent" — the agent token's `label`. */
853
+ val agentLabel: String? = null,
854
+ /** `notetaker` | `assistant` | `delegate`. */
855
+ val agentMode: String? = null,
754
856
  )
@@ -174,6 +174,7 @@ internal class CallHttpClient(
174
174
  livekitToken = livekit.getString("token"),
175
175
  controlToken = root.optStringOrNull("control_token") ?: current.controlToken,
176
176
  ringing = 0,
177
+ // recording / transcription: the current bundle's stand.
177
178
  )
178
179
  }
179
180
  return CallSessionBundle(
@@ -190,6 +191,8 @@ internal class CallHttpClient(
190
191
  ringing = call.optJSONObject("ring_states")?.let { states ->
191
192
  states.keys().asSequence().count { states.optString(it) == "ringing" }
192
193
  } ?: 0,
194
+ recording = call.optJSONObject("recording")?.toString() ?: current?.recording,
195
+ transcription = call.optJSONObject("transcription")?.toString() ?: current?.transcription,
193
196
  )
194
197
  }
195
198
 
@@ -14,7 +14,9 @@ import dev.poolse.callcore.RingContext
14
14
  *
15
15
  * Contract: data-only messages — rings with `type: "call"`, control
16
16
  * pushes (`ring_ended`, `finished`) and the missed-call notification
17
- * (`missed`) with `type: "call_event"` (CALL_CONTRACT.md §5).
17
+ * (`missed`) with `type: "call_event"` (CALL_CONTRACT.md §5); meeting
18
+ * notices with `type: "meeting"` (MEETINGS.md §11.3); an agent's question
19
+ * with `type: "agent_escalation"` (AGENTS_IN_CALLS.md §5).
18
20
  */
19
21
  class CallMessagingService : FirebaseMessagingService() {
20
22
 
@@ -46,6 +48,20 @@ class CallMessagingService : FirebaseMessagingService() {
46
48
  }
47
49
  return
48
50
  }
51
+ if (type == "meeting") {
52
+ // Scheduled-meeting notices (MEETINGS.md §11.3): "starting" with
53
+ // Join, and the brief. Always shown, even for the open chat.
54
+ if (CallCore.getOrNull(this) == null) return
55
+ MeetingNotification.show(this, data, CallCore.smallIcon(this))
56
+ return
57
+ }
58
+ if (type == "agent_escalation") {
59
+ // Your agent, attending a meeting for you, asks something
60
+ // (AGENTS_IN_CALLS.md §5): Approve / Decline / Answer from here.
61
+ if (CallCore.getOrNull(this) == null) return
62
+ EscalationNotification.show(this, data, CallCore.smallIcon(this))
63
+ return
64
+ }
49
65
  if (type != "call" && type != "call_event") {
50
66
  forwardToHost { it.onMessageReceived(message) }
51
67
  return
@@ -103,6 +119,10 @@ class CallMessagingService : FirebaseMessagingService() {
103
119
  // declined) on the server of its tenant.
104
120
  serverId = ServerRegistry.resolve(this@CallMessagingService, this["tenant_id"])?.id,
105
121
  workspaceName = this["workspace_name"]?.ifEmpty { null },
122
+ // A scheduled meeting starting (CA4): "Weekly sync is starting".
123
+ ringType = this["ring_type"]?.ifEmpty { null },
124
+ meetingTitle = this["meeting_title"]?.ifEmpty { null },
125
+ meetingId = this["meeting_id"]?.ifEmpty { null },
106
126
  )
107
127
  }
108
128
 
@@ -27,6 +27,20 @@ interface ScreenShareSource {
27
27
  fun setScreenShare(on: Boolean, permission: android.content.Intent?)
28
28
  }
29
29
 
30
+ /**
31
+ * Capture processing (CL7), for a media port that can change it mid-call.
32
+ * Noise suppression is the platform's (WebRTC's NS with echo
33
+ * cancellation kept on); background blur needs a video processor.
34
+ */
35
+ interface CaptureProcessingSource {
36
+ val noiseSuppressionSupported: Boolean get() = true
37
+ val backgroundBlurSupported: Boolean get() = false
38
+ /** On by default. Applies to the published microphone at once. */
39
+ fun setNoiseSuppression(on: Boolean)
40
+ /** A no-op where [backgroundBlurSupported] is false. */
41
+ fun setBackgroundBlur(on: Boolean) {}
42
+ }
43
+
30
44
  /** One on-screen video slot, bound to a participant's camera or shared screen. */
31
45
  interface CallVideoSurface {
32
46
  /** The Android view to host; it fills its parent. */