@mgamadeus/ddd-agents 0.6.0 → 0.6.2

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
@@ -293,20 +293,22 @@ What the application passes to `AgentVoiceCallProvider`:
293
293
  application whose routes are the trait's own paths with the agent space in the body of `open`; `baseApi` is the
294
294
  application's request layer as one function (`request({ url, method, body })` answering a Promise), for which
295
295
  `createAgentVoiceFetchBaseApi()` is the binding over `fetch`. An application whose `open` names its space in the path
296
- writes the six functions itself. A refused request rejects with the route's error code where
297
- `readAgentVoiceErrorCode` finds it (`error`, `data.error`, `code` or the message).
296
+ adds `buildOpenPath: (agentSpaceId) => string` (`AgentVoiceOpenPathBuilder`), the whole path of `open` for the space
297
+ the start was given (undefined when it named none); the body still carries `agentSpaceId`, the other five routes stay
298
+ below `apiPrefix`, and without the option `open` is `${apiPrefix}/open`. A refused request rejects with the route's
299
+ error code where `readAgentVoiceErrorCode` finds it (`error`, `data.error`, `code` or the message).
298
300
  - **`ringSource`** (`AgentVoiceRingSource`): the stream of the `agent.voice.ring` messages.
299
301
  `createAgentVoiceRingSource(accountRealtimePoll)` listens to the account realtime poll of `/ui` while the incoming
300
302
  call is mounted: a ring message that arrives rings, and one a read finds gone (answered or declined on another
301
303
  client, canceled) ends the ring on this client with that read instead of at its deadline. The poll stays the
302
- application's, which stops it. Given a function instead,
303
- `createAgentVoiceRingSource((onMessage) => createAccountRealtimePoll({ readAccountRealtime, onMessage }))`, the ring
304
- source starts the poll with its first subscriber and stops it with its last. An application with its own transport
304
+ application's, which creates and stops it; the ring source never stops it. An application with its own transport
305
305
  passes its own source (and reports a cleared ring through `onRingCleared`). Without a ring source nothing rings. The
306
306
  backend rings an account only while it knows one of its clients: the account read of the poll states the client's id
307
307
  (see `/ui`), with or without a `uiClient`.
308
308
  - **`onConversationOfCallChanged(conversationId, agentSpaceId)`**: called once per call when the conversation the call
309
- writes into is known; the application shows that conversation.
309
+ writes into is known; the application shows that conversation. The provider does it with
310
+ `useFollowAgentVoiceCallConversation(handler)`, which an application may also call itself in a component of its own
311
+ (a window that follows the call without the provider's handler).
310
312
 
311
313
  The call lives in a store at module level, so it goes on when the chat that shows it closes. `useAgentVoiceCall()`
312
314
  returns it: `phase` (`idle`, `connecting`, `live`, `ended`, `failed`), `callId`, `conversationId`, `lines` (what was
@@ -315,15 +317,27 @@ on every transcript delta. Actions: `startAgentVoiceCall({ agentSpaceId?, conver
315
317
  from the click: the microphone prompt needs the user's gesture), `hangUpAgentVoiceCall(reason?)`,
316
318
  `toggleAgentVoiceCallMute()`, `dismissAgentVoiceCallOutcome()`. The store asks for the microphone, opens the peer
317
319
  connection and the provider's event channel, reports the device status, and ends the call when the server says it ended.
320
+ A start that fails before `open` answers (a refused microphone, a refusal of `open` such as `no_ai_budget`) is the
321
+ store's `failed` phase with its `failureTextKey`, so every mounted band of that agent space shows it, inside a chat or
322
+ not.
318
323
 
319
324
  | Component | Where it goes | Props |
320
325
  |---|---|---|
321
326
  | `AgentVoiceCallProvider` | once, above every voice component, below the conversation client (`AgentsProvider`) | `api`, `ringSource`, `onConversationOfCallChanged` |
322
- | `AgentVoiceChatStartButton` | the chat input's send spot while nothing is typed | `agentSpaceId?`, `conversationId?`, `disabled?`, `testId?` |
323
- | `AgentVoiceCallBand` | over the chat input | `renderAgentSpot?(call)`, `agentSpaceId?`, `isPresented?` |
324
- | `AgentVoiceCallCaptions` | after the chat's message list, inside the chat | `agentSpaceId?`, `ownerMessageTheme?` |
325
- | `AgentVoiceInputGlow` | the chat input's underlay | `agentSpaceId?` |
326
- | `AgentVoiceIncomingCall` | once, outside the chat | `resolveCallerLabel?(ring)`, `renderAgentSpot?()` |
327
+ | `AgentVoiceChatStartButton` | the chat input's send spot while nothing is typed | `agentSpaceId?`, `conversationId?`, `disabled?`, `onStart?()`, `testId?` |
328
+ | `AgentVoiceCallBand` | over the chat input | `renderAgentSpot?(call)`, `agentSpaceId?`, `isPresented?`, `actions?`, `testId?` |
329
+ | `AgentVoiceCallCaptions` | after the chat's message list, inside the chat | `agentSpaceId?`, `ownerMessageTheme?`, `testId?` |
330
+ | `AgentVoiceInputGlow` | the chat input's underlay | `agentSpaceId?`, `testId?` |
331
+ | `AgentVoiceIncomingCall` | once, outside the chat | `resolveCallerLabel?(ring)`, `renderAgentSpot?()`, `zIndex?`, `testId?` |
332
+
333
+ - `onStart` of the start button runs in the click, synchronously, before the microphone prompt and `open`: the place
334
+ for what needs the user's gesture (opening a window for the chat). The button's label shows through the
335
+ environment's `Tooltip` when the application replaces it (`AgentsEnvironment.components.Tooltip`, with the text key
336
+ `Talk to %agentName%`); otherwise it is the button's `title`.
337
+ - `actions` of the band are the application's own controls, placed before the band's own buttons; they render only
338
+ while the band shows something (a call, a ring, a refused answer, an outcome).
339
+ - `zIndex` of the incoming call sets its stacking order over the page; without it the custom property
340
+ `--agents-voice-incoming-call-z-index` does.
327
341
 
328
342
  - The band also shows the agent's ring while a chat is in sight (`isPresented`); the incoming call then keeps its own
329
343
  card away. A surface that covers the chats reports it with `useAgentVoiceRingCover(true)`.
@@ -337,7 +351,10 @@ connection and the provider's event channel, reports the device status, and ends
337
351
  - The styles are part of `styles.css`. Every colour and size is a custom property starting with `--agents-voice-`,
338
352
  read with its default (`--agents-voice-surface`, `--agents-voice-on-surface`, `--agents-voice-end`,
339
353
  `--agents-voice-accept`, `--agents-voice-band-max-width`, `--agents-voice-glow-color-1` … `-4`, …; each component's
340
- SCSS module lists its own at the top). Test ids start with `agent-voice-`.
354
+ SCSS module lists its own at the top). Test ids start with `agent-voice-`; a component given `testId` takes it on its
355
+ root and `${testId}-<part>` on its inner elements (the band's `-mute`, `-end`, `-close`, …, the incoming call's
356
+ `-accept`, `-decline`, `-detail`, `-refusal`, the captions' `-caption-agent`, `-caption-owner`; the glow has no inner
357
+ test id), each component's docblock lists its parts.
341
358
 
342
359
  ### The admin screens of the calls (`/voice/admin`)
343
360
 
package/dist/styles.css CHANGED
@@ -5676,6 +5676,11 @@ thead + tbody .agents_row_VBlQR-:first-child {
5676
5676
  gap: 0.5rem;
5677
5677
  }
5678
5678
 
5679
+ /* The application's own controls (`actions`): part of the row, with the row's gap. */
5680
+ .agents_applicationActions_b5QBp8 {
5681
+ display: contents;
5682
+ }
5683
+
5679
5684
  /* A pill on the dark band. */
5680
5685
  .agents_action_z96Tb1 {
5681
5686
  position: relative;
@@ -5822,7 +5827,7 @@ thead + tbody .agents_row_VBlQR-:first-child {
5822
5827
  }/*
5823
5828
  * The incoming call: top centre, over every page. Custom properties, each read with its default:
5824
5829
  *
5825
- * --agents-voice-incoming-call-top, --agents-voice-incoming-call-z-index
5830
+ * --agents-voice-incoming-call-top, --agents-voice-incoming-call-z-index (the `zIndex` prop wins over it)
5826
5831
  * --agents-voice-card-surface, --agents-voice-card-text, --agents-voice-card-action-surface,
5827
5832
  * --agents-voice-card-padding, --agents-voice-card-radius, --agents-voice-card-shadow
5828
5833
  * --agents-voice-accept, --agents-voice-on-accept Accept
@@ -1,15 +1,15 @@
1
1
  export type { AgentVoiceAdminCall, AgentVoiceAdminCallDerivedValues, AgentVoiceAdminCallDirection, AgentVoiceAdminCallEndReason, AgentVoiceAdminCallIdArg, AgentVoiceAdminCallResponse, AgentVoiceAdminCallsArg, AgentVoiceAdminCallsResponse, AgentVoiceAdminCallState, AgentVoiceAdminChangeHistory, AgentVoiceAdminCurrency, AgentVoiceAdminElements, AgentVoiceAdminMoneyAmount, } from "../voice/admin/agent-voice-admin-types";
2
- export { AGENT_VOICE_ERROR_CODE_INVALID_OPEN_ANSWER, type AgentVoiceApi, AgentVoiceApiError, type AgentVoiceBaseApi, type AgentVoiceFetchOptions, type AgentVoiceRequest, buildAgentVoiceRequests, createAgentVoiceApi, type CreateAgentVoiceApiOptions, createAgentVoiceFetchBaseApi, type CreateAgentVoiceFetchBaseApiOptions, readAgentVoiceErrorCode, } from "../voice/agent-voice-api";
2
+ export { AGENT_VOICE_ERROR_CODE_INVALID_OPEN_ANSWER, type AgentVoiceApi, AgentVoiceApiError, type AgentVoiceBaseApi, type AgentVoiceFetchOptions, type AgentVoiceOpenPathBuilder, type AgentVoiceRequest, buildAgentVoiceRequests, createAgentVoiceApi, type CreateAgentVoiceApiOptions, createAgentVoiceFetchBaseApi, type CreateAgentVoiceFetchBaseApiOptions, readAgentVoiceErrorCode, } from "../voice/agent-voice-api";
3
3
  export { AGENT_VOICE_CALL_END_REASON_ENDED_BY_AGENT, AGENT_VOICE_CALL_END_REASON_LIMIT_REACHED, type AgentVoiceCallLine, type AgentVoiceCallPhase, type AgentVoiceCallSnapshot, type AgentVoiceCallSpeaker, bindAgentVoiceApi, checkAgentVoiceCallEndedOnServer, dismissAgentVoiceCallOutcome, endAgentVoiceCallFromServer, hangUpAgentVoiceCall, IDLE_AGENT_VOICE_CALL, isAgentVoiceCallActive, isAgentVoiceCallShownInAgentSpace, readAgentVoiceCallSnapshot, startAgentVoiceCall, type StartAgentVoiceCallParams, toggleAgentVoiceCallMute, useAgentVoiceCallSnapshot, useAgentVoiceCallValue, useIsAgentVoiceCallActive, } from "../voice/call/agent-voice-call-store";
4
4
  export { type AgentVoiceCall, useAgentVoiceCall } from "../voice/call/use-agent-voice-call";
5
5
  export { type AgentVoiceCallTurn, turnOfAgentVoiceCall } from "../voice/call/agent-voice-call-turn";
6
6
  export { formatAgentVoiceCallDuration } from "../voice/call/format-agent-voice-call-duration";
7
7
  export { useAgentVoiceCallElapsedSeconds } from "../voice/call/use-agent-voice-call-elapsed-seconds";
8
8
  export { type AgentVoiceConversationChangeSubscription, useAgentVoiceCallServerEnd, } from "../voice/call/use-agent-voice-call-server-end";
9
- export type { AgentVoiceConversationOfCallChangedHandler } from "../voice/call/use-follow-agent-voice-call-conversation";
9
+ export { type AgentVoiceConversationOfCallChangedHandler, useFollowAgentVoiceCallConversation, } from "../voice/call/use-follow-agent-voice-call-conversation";
10
10
  export { buildUnsavedAgentVoiceCallLines, type SavedAgentVoiceCallMessage, } from "../voice/call/build-unsaved-agent-voice-call-lines";
11
11
  export { AGENT_VOICE_RING_MESSAGE_TYPE, type AgentVoiceRing, pickRingingAgentVoiceCall, readAgentVoiceRingOfRealtimeMessage, } from "../voice/ring/agent-voice-ring";
12
- export { AgentVoiceAccountRealtimeRingSource, type AgentVoiceAccountRealtimePollStarter, type AgentVoiceRingSource, createAgentVoiceRingSource, } from "../voice/ring/agent-voice-ring-source";
12
+ export { AgentVoiceAccountRealtimeRingSource, type AgentVoiceRingSource, createAgentVoiceRingSource, } from "../voice/ring/agent-voice-ring-source";
13
13
  export { acceptAgentVoiceIncomingRing, type AgentVoiceIncomingRingSnapshot, declineAgentVoiceIncomingRing, pickAgentVoiceIncomingCard, readAgentVoiceIncomingRingSnapshot, useAgentVoiceIncomingRing, useAgentVoiceRingBandHost, useAgentVoiceRingCover, } from "../voice/ring/agent-voice-incoming-ring-store";
14
14
  export { AGENT_VOICE_ANSWER_REFUSAL_TEXT_KEYS, type AgentVoiceAnswerRefusal, } from "../voice/ring/answer-incoming-agent-voice-call";
15
15
  export { type AgentVoiceCallerLabel, type AgentVoiceCallerLabelTextKey, buildAgentVoiceCallerLabel, pickAgentVoiceCallerLabelTextKey, } from "../voice/ring/agent-voice-caller-label";
@@ -23,6 +23,18 @@ export interface AgentVoiceCallBandViewProps {
23
23
  incoming?: AgentVoiceCallIncomingRing;
24
24
  /** The application's avatar of the agent, before the name (while a call runs or the agent rings). */
25
25
  agentSpot?: ReactNode;
26
+ /**
27
+ * The application's own controls (a button that opens the chat in a window), in the band's row of buttons before
28
+ * the band's own. Rendered only while the band shows something (a call, a ring, a refused answer, an outcome).
29
+ * Default: none.
30
+ */
31
+ actions?: ReactNode;
32
+ /**
33
+ * The test id of the band; its inner elements take `${testId}-<part>` (`-status`, `-mute`, `-end`,
34
+ * `-incoming-decline`, `-incoming-accept`, `-incoming-refusal`, `-ended-status`, `-failure`, `-start-again`, `-close`,
35
+ * `-actions`). Default: `agent-voice-call-band`, the inner elements their fixed `agent-voice-call-…` ids.
36
+ */
37
+ testId?: string;
26
38
  }
27
39
  /**
28
40
  * The voice chat in the band over the chat input: before it, the agent asking to talk (Decline, Accept); during it,
@@ -40,6 +52,10 @@ export interface AgentVoiceCallBandProps {
40
52
  * and the incoming call shows its own card. Default true.
41
53
  */
42
54
  isPresented?: boolean;
55
+ /** The application's own controls in the band (see `AgentVoiceCallBandViewProps.actions`). Default: none. */
56
+ actions?: ReactNode;
57
+ /** The test id of the band and the prefix of its inner ids (see `AgentVoiceCallBandViewProps.testId`). */
58
+ testId?: string;
43
59
  }
44
60
  /**
45
61
  * The band of the agent ringing this client and of the running (or just finished) voice chat; renders nothing while
@@ -4,6 +4,12 @@ export interface AgentVoiceCallCaptionsProps {
4
4
  agentSpaceId?: number;
5
5
  /** The theme of the owner's line, as the chat renders the owner's messages. Default: the message component's own. */
6
6
  ownerMessageTheme?: ConversationMessageUserTheme;
7
+ /**
8
+ * The test id of the captions; the agent's and the owner's lines take `${testId}-caption-agent` and
9
+ * `${testId}-caption-owner`. Default: `agent-voice-call-captions`, the lines `agent-voice-call-caption-agent` and
10
+ * `agent-voice-call-caption-owner`.
11
+ */
12
+ testId?: string;
7
13
  }
8
14
  /**
9
15
  * The end of the chat while a voice chat runs: what is being said that the chat does not hold yet, streamed from the
@@ -5,11 +5,19 @@ export interface AgentVoiceChatStartButtonProps {
5
5
  conversationId?: number;
6
6
  /** The owner may not start a voice chat here (the application's own gate). */
7
7
  disabled?: boolean;
8
+ /**
9
+ * Called in the click, synchronously, before the voice chat starts (before the microphone prompt and `open`): the
10
+ * place for what needs the user's gesture, such as opening a window for the chat. Default: nothing.
11
+ */
12
+ onStart?: () => void;
8
13
  testId?: string;
9
14
  }
10
15
  /**
11
16
  * In a chat input's send spot while nothing is typed and no voice chat runs: starts a voice chat with the agent. An
12
17
  * input outside the chat uses it too; the application shows the call's conversation when the provider reports it
13
18
  * (`onConversationOfCallChanged`). Disabled while a voice chat is connecting or live.
19
+ *
20
+ * Its label shows through the environment's tooltip when the application replaces the package's `Tooltip`
21
+ * (`AgentsEnvironment.components.Tooltip`); otherwise it is the button's `title`, as the browser shows it.
14
22
  */
15
23
  export declare const AgentVoiceChatStartButton: (props: AgentVoiceChatStartButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -10,6 +10,17 @@ export interface AgentVoiceIncomingCallProps {
10
10
  resolveCallerLabel?: (ring: AgentVoiceRing) => AgentVoiceCallerLabel | undefined;
11
11
  /** The application's avatar of the agent on the card. Default: the voice chat's mark. */
12
12
  renderAgentSpot?: () => ReactNode;
13
+ /**
14
+ * The stacking order of the card over the page, for an application whose layers need another one than the custom
15
+ * property sets. Default: `--agents-voice-incoming-call-z-index` (itself defaulting to 2147483000).
16
+ */
17
+ zIndex?: number;
18
+ /**
19
+ * The test id of the card; its inner elements take `${testId}-<part>` (`-detail`, `-decline`, `-accept`) and the card
20
+ * of a refused answer `${testId}-refusal`. Default: `agent-voice-incoming-call`, the inner elements their fixed
21
+ * `agent-voice-incoming-call-…` ids.
22
+ */
23
+ testId?: string;
13
24
  }
14
25
  /**
15
26
  * The agent ringing the owner in the browser window: the one listener per client. While a ring is live it publishes it
@@ -1,6 +1,8 @@
1
1
  export interface AgentVoiceInputGlowProps {
2
2
  /** The chat's agent space, where the application has one: a voice chat running in another one glows nowhere here. */
3
3
  agentSpaceId?: number;
4
+ /** The test id of the glow's box (it has no inner element with a test id). Default: `agent-voice-input-glow`. */
5
+ testId?: string;
4
6
  }
5
7
  /**
6
8
  * The chat input's glow during a voice chat; renders nothing while no voice chat is connecting or live. Rendered as
@@ -1,4 +1,4 @@
1
- import type { AgentVoiceAdminCall, AgentVoiceAdminCallDerivedValues, AgentVoiceAdminCallDirection, AgentVoiceAdminCallEndReason, AgentVoiceAdminCallState, AgentVoiceAdminMoneyAmount } from "./agent-voice-admin-types";
1
+ import type { AgentVoiceAdminCall, AgentVoiceAdminCallDerivedValues, AgentVoiceAdminCallDirection, AgentVoiceAdminCallEndReason, AgentVoiceAdminCallState, AgentVoiceAdminElements, AgentVoiceAdminMoneyAmount } from "./agent-voice-admin-types";
2
2
  /** Where a call stands, as the server read it (`callState` of the answers). */
3
3
  export declare const AGENT_VOICE_CALL_STATE: Readonly<Record<AgentVoiceAdminCallState, import("@mgamadeus/ddd-admin-ui/logic").StatusDefinition>>;
4
4
  /** `AgentVoiceCall.endReason`: the reasons the call writes itself. A diagnostic value shows as it came. */
@@ -15,10 +15,11 @@ export declare const agentVoiceAdminCallStartTimeOf: (call: Pick<AgentVoiceAdmin
15
15
  /** How long a call lasted, from the moment it was answered to its end; null while it runs or when nobody answered. */
16
16
  export declare const agentVoiceAdminCallDurationInSecondsOf: (call: Pick<AgentVoiceAdminCall, "startedAt" | "endedAt">) => number | null;
17
17
  /**
18
- * What the server derived for the list's calls (the state, the costs), by call id. A call the answer names no entry
19
- * for has none here: its row then shows no state and no costs.
18
+ * What the server derived for the list's calls (the state, the costs), by call id: reads the set the list answer
19
+ * carries (`AgentVoiceAdminCallsResponse.agentVoiceCallDerivedValues`). A call the answer names no entry for has none
20
+ * here: its row then shows no state and no costs.
20
21
  */
21
- export declare const agentVoiceAdminCallDerivedValuesByCallIdOf: (agentVoiceCallDerivedValues: readonly AgentVoiceAdminCallDerivedValues[] | null | undefined) => ReadonlyMap<number, AgentVoiceAdminCallDerivedValues>;
22
+ export declare const agentVoiceAdminCallDerivedValuesByCallIdOf: (agentVoiceCallDerivedValues: AgentVoiceAdminElements<AgentVoiceAdminCallDerivedValues> | null | undefined) => ReadonlyMap<number, AgentVoiceAdminCallDerivedValues>;
22
23
  /** A call's costs, rounded, in the UI language. Call it at render time, so a language switch formats anew. */
23
24
  export declare const formatAgentVoiceAdminCallCosts: (bookedCosts: AgentVoiceAdminMoneyAmount) => string;
24
25
  /**
@@ -41,6 +41,7 @@ export interface AgentVoiceAdminCall {
41
41
  /** Present when the application's serializer settings keep it. */
42
42
  changeHistory?: AgentVoiceAdminChangeHistory | null;
43
43
  }
44
+ /** A set as the routes answer it: its entries are `elements`. */
44
45
  export interface AgentVoiceAdminElements<T> {
45
46
  elements?: T[];
46
47
  }
@@ -66,8 +67,11 @@ export interface AgentVoiceAdminCallDerivedValues {
66
67
  /** `GET /calls`: the calls the signed-in account may read, newest first. The answer carries no total count. */
67
68
  export interface AgentVoiceAdminCallsResponse {
68
69
  agentVoiceCalls: AgentVoiceAdminElements<AgentVoiceAdminCall>;
69
- /** One entry per call of `agentVoiceCalls.elements`, in the same order; joined by `callId`. */
70
- agentVoiceCallDerivedValues: AgentVoiceAdminCallDerivedValues[];
70
+ /**
71
+ * A set like `agentVoiceCalls`: one entry per call of `agentVoiceCalls.elements`, in the same order; joined by
72
+ * `callId`. An answer without a call carries the set with no entry.
73
+ */
74
+ agentVoiceCallDerivedValues: AgentVoiceAdminElements<AgentVoiceAdminCallDerivedValues>;
71
75
  }
72
76
  /** `GET /calls/{callId}`: one call with what a screen would otherwise compute or look up. */
73
77
  export interface AgentVoiceAdminCallResponse {
@@ -77,9 +77,21 @@ export interface CreateAgentVoiceApiOptions {
77
77
  baseApi: AgentVoiceBaseApi;
78
78
  /** Where the application mounts the voice session routes, without a trailing slash (`/api/agents/voiceSession`). */
79
79
  apiPrefix: string;
80
+ /**
81
+ * The whole path of `open`, for an application whose route names the agent space in its path:
82
+ * `(agentSpaceId) => "/api/spaces/" + agentSpaceId + "/voiceSession/open"`. `agentSpaceId` is what the start was
83
+ * given (undefined when it named none). The body is unchanged and still carries `agentSpaceId`; the other five routes
84
+ * stay below `apiPrefix`. Default: `${apiPrefix}/open`.
85
+ */
86
+ buildOpenPath?: AgentVoiceOpenPathBuilder;
80
87
  }
81
- /** The request of every operation, on `apiPrefix`, with the routes' own field names. Pure: nothing is sent. */
82
- export declare const buildAgentVoiceRequests: (apiPrefix: string) => {
88
+ /** The path of `open` for the agent space of the start (see `CreateAgentVoiceApiOptions.buildOpenPath`). */
89
+ export type AgentVoiceOpenPathBuilder = (agentSpaceId: number | undefined) => string;
90
+ /**
91
+ * The request of every operation, on `apiPrefix`, with the routes' own field names; `open` on `buildOpenPath` when
92
+ * given. Pure: nothing is sent.
93
+ */
94
+ export declare const buildAgentVoiceRequests: (apiPrefix: string, buildOpenPath?: AgentVoiceOpenPathBuilder) => {
83
95
  openSession: ({ agentSpaceId, sdpOffer, conversationId, callId, }: Parameters<AgentVoiceApi["openSession"]>[0]) => AgentVoiceRequest;
84
96
  hangUp: ({ callId, reason }: Parameters<AgentVoiceApi["hangUp"]>[0]) => AgentVoiceRequest;
85
97
  reportDeviceStatus: ({ callId, status, iceCandidateType, roundTripTimeMs, detail, occurredAtUnixMs, }: Parameters<AgentVoiceApi["reportDeviceStatus"]>[0]) => AgentVoiceRequest;
@@ -93,9 +105,9 @@ export declare const AGENT_VOICE_ERROR_CODE_INVALID_OPEN_ANSWER = "invalid_open_
93
105
  * The adapter for an application whose routes are the voice trait's own paths below `apiPrefix`, with the agent space
94
106
  * in the body of `open`:
95
107
  * `export const agentVoiceApi = createAgentVoiceApi({ baseApi, apiPrefix: "/api/agents/voiceSession" });`
96
- * An application whose `open` names its space another way (in the path) writes the six functions itself.
108
+ * An application whose `open` names the space in its path adds `buildOpenPath`.
97
109
  */
98
- export declare const createAgentVoiceApi: ({ baseApi, apiPrefix }: CreateAgentVoiceApiOptions) => AgentVoiceApi;
110
+ export declare const createAgentVoiceApi: ({ baseApi, apiPrefix, buildOpenPath }: CreateAgentVoiceApiOptions) => AgentVoiceApi;
99
111
  /** What every request carries from the application: headers, credentials, mode, cache. */
100
112
  export type AgentVoiceFetchOptions = Omit<RequestInit, "method" | "body">;
101
113
  export interface CreateAgentVoiceFetchBaseApiOptions {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The test id of an inner element of a voice component: `${testId}-<part>` when the application gave the component a
3
+ * `testId`, else the element's own fixed id (`agent-voice-…`), so an application that sets none sees the ids it had.
4
+ */
5
+ export declare const agentVoicePartTestId: (testId: string | undefined, part: string, defaultTestId: string) => string;
@@ -11,14 +11,6 @@ import { type AgentVoiceRing } from "./agent-voice-ring";
11
11
  export interface AgentVoiceRingSource {
12
12
  subscribe(onRing: (ring: AgentVoiceRing) => void, onRingCleared: (callId: number) => void): () => void;
13
13
  }
14
- /**
15
- * Starts the account realtime poll (`createAccountRealtimePoll` of `./ui`) with the arrival hook the ring source hands in:
16
- * `onMessage => createAccountRealtimePoll({ readAccountRealtime: client.getAccountRealtimeMessages, onMessage })`.
17
- * For an application that wants the poll to run only while a ring can show: the ring source starts it with its first
18
- * subscriber and stops it with its last. An application that reads further message types from the same poll passes
19
- * the poll itself instead and subscribes to it beside the ring source.
20
- */
21
- export type AgentVoiceAccountRealtimePollStarter = (onMessage: (message: AgentRealtimeMessageDelivery) => void) => AccountRealtimePoll;
22
14
  interface AgentVoiceRingSubscriber {
23
15
  onRing: (ring: AgentVoiceRing) => void;
24
16
  onRingCleared: (callId: number) => void;
@@ -34,20 +26,17 @@ interface AgentVoiceKnownRing {
34
26
  * declined on another client, canceled, past its deadline) as a cleared ring. A subscriber is told `onRingCleared`
35
27
  * only for a ring it was handed, as an arrival or in the hand-over when it subscribed.
36
28
  *
37
- * It listens while somebody is subscribed. Given the poll itself, it subscribes to it with the first subscriber and
38
- * leaves it with the last; the poll stays the application's, which stops it. Given a function that starts the poll, it
39
- * starts the poll with the first subscriber and stops it with the last.
29
+ * It listens while somebody is subscribed: it subscribes to the poll with the first subscriber and leaves it with the
30
+ * last. The poll stays the application's, which creates and stops it; the ring source never stops it.
40
31
  */
41
32
  export declare class AgentVoiceAccountRealtimeRingSource implements AgentVoiceRingSource {
42
- protected readonly accountRealtimePollOrStarter: AccountRealtimePoll | AgentVoiceAccountRealtimePollStarter;
33
+ protected readonly accountRealtimePoll: AccountRealtimePoll;
43
34
  protected readonly subscribers: Set<AgentVoiceRingSubscriber>;
44
35
  /** The rings delivered while it listens, by call: a subscriber that comes later still gets the ones in their deadline. */
45
36
  protected readonly knownRingsByCallId: Map<number, AgentVoiceKnownRing>;
46
- /** The poll a starter created; this source stops it. Undefined for a poll of the application. */
47
- protected startedAccountRealtimePoll: AccountRealtimePoll | undefined;
48
37
  /** Set while it listens to the poll. */
49
38
  protected unsubscribeFromAccountRealtimePoll: (() => void) | undefined;
50
- constructor(accountRealtimePollOrStarter: AccountRealtimePoll | AgentVoiceAccountRealtimePollStarter);
39
+ constructor(accountRealtimePoll: AccountRealtimePoll);
51
40
  subscribe(onRing: (ring: AgentVoiceRing) => void, onRingCleared: (callId: number) => void): () => void;
52
41
  /** Takes one message of the account's realtime messages; returns whether it was a ring. */
53
42
  acceptRealtimeMessage(message: AgentRealtimeMessageDelivery): boolean;
@@ -58,18 +47,14 @@ export declare class AgentVoiceAccountRealtimeRingSource implements AgentVoiceRi
58
47
  acceptClearedRealtimeMessage(message: AgentRealtimeMessageDelivery): boolean;
59
48
  /** Hands a ring to a subscriber and notes it on the known ring. */
60
49
  protected handRing(knownRing: AgentVoiceKnownRing, subscriber: AgentVoiceRingSubscriber): void;
61
- /**
62
- * The poll hands over the messages open now, then every arrival and every clear. A started poll delivers its
63
- * arrivals through the hook it was started with, so only the clears are subscribed there.
64
- */
50
+ /** The poll hands over the messages open now, then every arrival and the clear of every message it handed over. */
65
51
  protected listenToAccountRealtimePoll(): void;
66
52
  protected leaveAccountRealtimePoll(): void;
67
53
  }
68
54
  /**
69
55
  * The ring source over the account realtime poll of `./ui`:
70
- * `createAgentVoiceRingSource(createAccountRealtimePoll({ readAccountRealtime, … }))`. A function that starts the poll
71
- * (`AgentVoiceAccountRealtimePollStarter`) is taken as well. An application with its own ring transport passes its own
72
- * `AgentVoiceRingSource` instead.
56
+ * `createAgentVoiceRingSource(createAccountRealtimePoll({ readAccountRealtime, … }))`. An application with its own
57
+ * ring transport passes its own `AgentVoiceRingSource` instead.
73
58
  */
74
- export declare const createAgentVoiceRingSource: (accountRealtimePollOrStarter: AccountRealtimePoll | AgentVoiceAccountRealtimePollStarter) => AgentVoiceRingSource;
59
+ export declare const createAgentVoiceRingSource: (accountRealtimePoll: AccountRealtimePoll) => AgentVoiceRingSource;
75
60
  export {};
@@ -176,7 +176,7 @@ const agentVoiceAdminCallDurationInSecondsOf = (call) => {
176
176
  };
177
177
  const agentVoiceAdminCallDerivedValuesByCallIdOf = (agentVoiceCallDerivedValues) => {
178
178
  const derivedValuesByCallId = /* @__PURE__ */ new Map();
179
- for (const derivedValuesOfCall of agentVoiceCallDerivedValues ?? [])
179
+ for (const derivedValuesOfCall of agentVoiceCallDerivedValues?.elements ?? [])
180
180
  derivedValuesByCallId.set(derivedValuesOfCall.callId, derivedValuesOfCall);
181
181
  return derivedValuesByCallId;
182
182
  };