@aiqa/sdk 2.1.0-develop.3 → 2.1.0-develop.5
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 +302 -202
- package/dist/browser/browser.d.ts +114 -97
- package/dist/browser/browser.js +17 -1
- package/dist/browser/browser.js.map +1 -1
- package/dist/node/node.d.ts +114 -97
- package/dist/node/node.js +17 -1
- package/dist/node/node.js.map +1 -1
- package/package.json +1 -1
package/dist/node/node.d.ts
CHANGED
|
@@ -1,16 +1,72 @@
|
|
|
1
1
|
import { Socket } from 'socket.io-client';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Overall result for the call: `critical_errors` if a fact you sent with
|
|
5
|
+
* `critical: true` failed, `errors` if any other fact failed, else
|
|
6
|
+
* `no_errors`.
|
|
7
|
+
*
|
|
8
|
+
* Only answers count. A question that was never asked never raises it, so a
|
|
9
|
+
* call where nothing was asked reads `no_errors`.
|
|
10
|
+
*
|
|
11
|
+
* Not the same as `VerificationStatus`, which describes a single fact.
|
|
12
|
+
*/
|
|
13
|
+
type ApplicationVerificationStatus = "no_errors" | "errors" | "critical_errors";
|
|
14
|
+
/**
|
|
15
|
+
* How the facts on one application are counted up. None of these is a count of
|
|
16
|
+
* facts that passed, and they overlap — to show a pass count, count the facts
|
|
17
|
+
* whose `verification_status` is `matched` in `getFacts()`.
|
|
18
|
+
*/
|
|
19
|
+
type ApplicationVerificationSummary = {
|
|
20
|
+
status: ApplicationVerificationStatus;
|
|
21
|
+
/** Facts whose answer did not match the expected one. */
|
|
22
|
+
count_errors: number;
|
|
23
|
+
/** The facts in `count_errors` that you sent with `critical: true`. */
|
|
24
|
+
count_critical_errors: number;
|
|
25
|
+
/**
|
|
26
|
+
* Every fact on the application, checked or not. The other counters are
|
|
27
|
+
* subsets of it and can overlap each other, so no subtraction from
|
|
28
|
+
* `count_total` yields a pass count.
|
|
29
|
+
*/
|
|
30
|
+
count_total: number;
|
|
31
|
+
/**
|
|
32
|
+
* Facts whose question was never asked. Excludes the still-pending ones, but
|
|
33
|
+
* overlaps `count_errors`: a fact never asked that came back wrong is in both.
|
|
34
|
+
*/
|
|
35
|
+
count_not_asked: number;
|
|
36
|
+
/** The facts in `count_not_asked` that you sent with `critical: true`. */
|
|
37
|
+
count_critical_not_asked: number;
|
|
38
|
+
/**
|
|
39
|
+
* Facts added but not resolved yet. During a live call most facts sit here
|
|
40
|
+
* and move into the other counters as their results arrive.
|
|
41
|
+
*/
|
|
42
|
+
count_pending: number;
|
|
43
|
+
/**
|
|
44
|
+
* Facts flagged as suspicious when the call is reviewed — for instance the
|
|
45
|
+
* agent leading the customer to the expected answer. Independent of the
|
|
46
|
+
* answer: a matched fact can be flagged. Reads 0 while the call is running.
|
|
47
|
+
*/
|
|
48
|
+
count_suspicious: number;
|
|
49
|
+
};
|
|
3
50
|
type Application = {
|
|
4
51
|
application_id: string;
|
|
5
52
|
client_name: string;
|
|
6
53
|
client_phone_number: string;
|
|
7
54
|
agent_id: string;
|
|
55
|
+
/** Comes back empty. Set an agent name with `updateConversation()`. */
|
|
8
56
|
agent_first_name: string;
|
|
57
|
+
/** Comes back empty. Set an agent name with `updateConversation()`. */
|
|
9
58
|
agent_last_name: string;
|
|
59
|
+
/**
|
|
60
|
+
* How the call is going so far. When it is missing there is no summary —
|
|
61
|
+
* which is not the same as all zeros — and the fields above may then be the
|
|
62
|
+
* ones from authentication, without an `updateConversation()` you made since.
|
|
63
|
+
*/
|
|
64
|
+
verification?: ApplicationVerificationSummary;
|
|
10
65
|
};
|
|
11
66
|
declare enum Methods {
|
|
12
67
|
AUTHENTICATE = "AUTHENTICATE",
|
|
13
68
|
GET_FACTS = "GET_FACTS",
|
|
69
|
+
GET_APPLICATION = "GET_APPLICATION",
|
|
14
70
|
START_RECORDING = "START_RECORDING",
|
|
15
71
|
STOP_RECORDING = "STOP_RECORDING",
|
|
16
72
|
IS_RECORDING = "IS_RECORDING",
|
|
@@ -41,7 +97,7 @@ type UpdateConversationInput = {
|
|
|
41
97
|
advisorName?: string;
|
|
42
98
|
agentGroups?: string[];
|
|
43
99
|
};
|
|
44
|
-
/**
|
|
100
|
+
/** Only the fields you sent come back in `conversation`. */
|
|
45
101
|
type UpdateConversationResult = {
|
|
46
102
|
success: boolean;
|
|
47
103
|
conversation: {
|
|
@@ -86,11 +142,10 @@ type ApplicationFactAnswerFormat = {
|
|
|
86
142
|
type ApplicationFactInput = {
|
|
87
143
|
id: string;
|
|
88
144
|
/**
|
|
89
|
-
* Stable identifier for the underlying question, shared across applications
|
|
90
|
-
* conversations. When provided it
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* dashboard are scoped per `questionId`.
|
|
145
|
+
* Stable identifier for the underlying question, shared across applications
|
|
146
|
+
* and conversations. When provided it identifies the question instead of
|
|
147
|
+
* `id`. Keep it consistent across calls: whatever AIQA has tuned for a
|
|
148
|
+
* question is attached to this identity.
|
|
94
149
|
*/
|
|
95
150
|
questionId?: string;
|
|
96
151
|
question: string;
|
|
@@ -99,35 +154,41 @@ type ApplicationFactInput = {
|
|
|
99
154
|
category_id?: string;
|
|
100
155
|
category_name?: string;
|
|
101
156
|
language?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Mark the question critical: its failures land in `count_critical_errors`,
|
|
159
|
+
* and one of them sets the call's `status` to `critical_errors`.
|
|
160
|
+
*/
|
|
102
161
|
critical?: boolean;
|
|
103
162
|
is_skipped?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Your own identifiers for this fact — a form field ID, a section name,
|
|
165
|
+
* anything that lets your UI map the result back to the right place.
|
|
166
|
+
* `getFacts()` returns it unchanged — `{}` for a fact you added without
|
|
167
|
+
* one — and it plays no part in verification.
|
|
168
|
+
*
|
|
169
|
+
* Keys and values must all be strings, and each value is limited to 1024
|
|
170
|
+
* characters. A payload that breaks either rule is rejected.
|
|
171
|
+
*/
|
|
104
172
|
metadata?: Record<string, string>;
|
|
105
173
|
};
|
|
106
174
|
type QuestionStatus = "searching" | "asked" | "not_asked";
|
|
107
175
|
/**
|
|
108
|
-
* Per-fact verification state.
|
|
176
|
+
* Per-fact verification state. Handle any value you don't recognize as
|
|
177
|
+
* `processing`.
|
|
109
178
|
*
|
|
110
|
-
*
|
|
111
|
-
* the
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* - `
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* - `
|
|
122
|
-
*
|
|
123
|
-
* clarifications (e.g. spellings, "I mean…");
|
|
124
|
-
* resolves to `matched`/`unmatched`
|
|
125
|
-
* - `pending_confirmation_unmatched` same as above but the held verdict is
|
|
126
|
-
* `unmatched`; UI can show "we heard X but it
|
|
127
|
-
* doesn't match, waiting to confirm" instead
|
|
128
|
-
* of a hard red verdict
|
|
129
|
-
* - `matched` terminal: answer matched expected
|
|
130
|
-
* - `unmatched` terminal: budget exhausted with no match
|
|
179
|
+
* - `processing` queued, or nothing to go on yet
|
|
180
|
+
* - `awaiting_question` the agent hasn't asked the question yet
|
|
181
|
+
* - `awaiting_answer` asked, the customer hasn't answered yet
|
|
182
|
+
* - `partial` partial evidence so far (e.g. "305" of "30521")
|
|
183
|
+
* - `pending_confirmation_matched` a matching answer is held briefly in case
|
|
184
|
+
* the customer corrects it mid-answer
|
|
185
|
+
* (spellings, "I mean…"); resolves to
|
|
186
|
+
* `matched`/`unmatched`
|
|
187
|
+
* - `pending_confirmation_unmatched` same, with an unmatched answer held; show
|
|
188
|
+
* "we heard X but it doesn't match, waiting
|
|
189
|
+
* to confirm" rather than a hard result
|
|
190
|
+
* - `matched` final: the answer matched
|
|
191
|
+
* - `unmatched` final: the answer did not match
|
|
131
192
|
*/
|
|
132
193
|
type VerificationStatus = "processing" | "awaiting_question" | "awaiting_answer" | "partial" | "pending_confirmation_matched" | "pending_confirmation_unmatched" | "matched" | "unmatched";
|
|
133
194
|
type ApplicationFact = ApplicationFactInput & {
|
|
@@ -138,7 +199,7 @@ type ApplicationFact = ApplicationFactInput & {
|
|
|
138
199
|
flagged: boolean;
|
|
139
200
|
};
|
|
140
201
|
interface AddFactResult {
|
|
141
|
-
/** Conversation the fact was attached to.
|
|
202
|
+
/** Conversation the fact was attached to. */
|
|
142
203
|
conversation_id?: string;
|
|
143
204
|
/** Echo of the original question text from the fact input. */
|
|
144
205
|
question?: string;
|
|
@@ -149,48 +210,33 @@ interface AddFactResult {
|
|
|
149
210
|
is_valid_answer: boolean;
|
|
150
211
|
question_asked?: boolean;
|
|
151
212
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* Renamed from `match_score` to disambiguate from the answer-side score.
|
|
213
|
+
* How closely the agent's utterance matched the expected question, on a 0–1
|
|
214
|
+
* or a 0–100 scale. Higher is closer.
|
|
155
215
|
*/
|
|
156
216
|
question_match_score?: number;
|
|
157
217
|
/**
|
|
158
|
-
* 0–1 score
|
|
159
|
-
*
|
|
160
|
-
* (numeric-prefix ratio, matched-components ratio). Undefined when no
|
|
161
|
-
* partial signal exists or for terminal results before this rolls out.
|
|
218
|
+
* 0–1 score for how closely the customer's answer matched the expected one.
|
|
219
|
+
* Undefined when there is no partial signal to score.
|
|
162
220
|
*/
|
|
163
221
|
answer_match_score?: number;
|
|
164
222
|
metadata?: Record<string, string>;
|
|
165
223
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* resolves on terminals. Optional during the rollout window for
|
|
169
|
-
* backwards compatibility with older backends.
|
|
224
|
+
* The final state: `matched` or `unmatched` whenever it is present. Fall
|
|
225
|
+
* back to `is_valid_answer` when it is missing.
|
|
170
226
|
*/
|
|
171
227
|
verification_status?: VerificationStatus;
|
|
172
228
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* generalise to addresses, names, dates, etc.
|
|
229
|
+
* Component labels describing which parts of the expected answer
|
|
230
|
+
* matched. Currently `["prefix"]` / `["suffix"]` for numeric facts;
|
|
231
|
+
* treat the set as open-ended.
|
|
177
232
|
*/
|
|
178
233
|
matched_components?: string[];
|
|
179
234
|
missing_components?: string[];
|
|
180
235
|
}
|
|
181
236
|
/**
|
|
182
|
-
* Payload of the `FACT_VERIFIED`
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* non-terminal (`partial`, `awaiting_question`, `awaiting_answer`,
|
|
186
|
-
* `pending_confirmation_matched`, `pending_confirmation_unmatched`,
|
|
187
|
-
* `processing`) AND terminal (`matched`, `unmatched`).
|
|
188
|
-
*
|
|
189
|
-
* Subscribe with:
|
|
190
|
-
* sdk.on("FACT_VERIFIED", (payload: FactVerifiedPayload) => {...});
|
|
191
|
-
*
|
|
192
|
-
* `addFact()`'s Promise resolves only on terminals; this event stream
|
|
193
|
-
* is the channel for rendering live progress in the agent UI.
|
|
237
|
+
* Payload of the `FACT_VERIFIED` event, which fires on every state change —
|
|
238
|
+
* see `VerificationStatus`. Use it to show progress; `addFact()` resolves
|
|
239
|
+
* only once a fact is done.
|
|
194
240
|
*/
|
|
195
241
|
interface FactVerifiedPayload {
|
|
196
242
|
factId: string;
|
|
@@ -200,12 +246,7 @@ interface FactVerifiedPayload {
|
|
|
200
246
|
answer_match_score?: number;
|
|
201
247
|
matched_components?: string[];
|
|
202
248
|
missing_components?: string[];
|
|
203
|
-
/**
|
|
204
|
-
* Inner data payload. Shape matches `AddFactResult` (minus the
|
|
205
|
-
* top-level envelope fields) so consumers can reuse the same
|
|
206
|
-
* rendering code for the terminal addFact() resolution and the
|
|
207
|
-
* broadcast event.
|
|
208
|
-
*/
|
|
249
|
+
/** Inner payload, shaped like `AddFactResult`. */
|
|
209
250
|
data?: AddFactResult;
|
|
210
251
|
error?: string;
|
|
211
252
|
}
|
|
@@ -213,47 +254,26 @@ type FlagFactResult = {
|
|
|
213
254
|
success: boolean;
|
|
214
255
|
};
|
|
215
256
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* `dialog_act_confidence` band.
|
|
220
|
-
*
|
|
221
|
-
* Mirrors `DialogAct` in
|
|
222
|
-
* `libs/types/src/utterance-enrichment.ts` on the backend.
|
|
257
|
+
* What the utterance appears to be doing in the conversation. A best-effort
|
|
258
|
+
* guess: display it if it helps, but do not gate behaviour on it. Its
|
|
259
|
+
* confidence band is `dialog_act_confidence`.
|
|
223
260
|
*/
|
|
224
261
|
type DialogAct = "question" | "answer" | "acknowledgement" | "filler" | "other";
|
|
225
262
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* two are unrelated and conflating them is a documented drift hazard on
|
|
229
|
-
* the backend.
|
|
230
|
-
*
|
|
231
|
-
* Mirrors `DialogActConfidence` in
|
|
232
|
-
* `libs/types/src/utterance-enrichment.ts` on the backend.
|
|
263
|
+
* Confidence band for `dialog_act` only. Unrelated to the numeric
|
|
264
|
+
* `confidence` field on the same utterance — do not compare the two.
|
|
233
265
|
*/
|
|
234
266
|
type DialogActConfidence = "high" | "medium" | "low";
|
|
235
267
|
/**
|
|
236
|
-
*
|
|
237
|
-
* gateway (`apps/realtime-verification/src/socket/realtimeVerification.gateway.output.dto.ts`)
|
|
238
|
-
* and the `Utterance` interface in `libs/types/src/common.ts` field for
|
|
239
|
-
* field. Sent over the wire by the `TRANSCRIPTION_UPDATED` broadcast.
|
|
268
|
+
* An utterance from the `TRANSCRIPTION_UPDATED` event.
|
|
240
269
|
*
|
|
241
|
-
*
|
|
242
|
-
* pre-cutover utterances (persisted before backend PR #234) lack them.
|
|
243
|
-
* Treat any missing or nullish value as "unknown" — NOT as a deliberate
|
|
244
|
-
* negative signal. `is_ivr_filler_candidate === false` in particular
|
|
245
|
-
* does NOT round-trip through `undefined`, so consumer logic that wants
|
|
246
|
-
* "definitely not a filler" must check `=== false` after confirming the
|
|
247
|
-
* field is present.
|
|
270
|
+
* A missing optional field means "unknown", not "no".
|
|
248
271
|
*/
|
|
249
272
|
type Utterance = {
|
|
250
|
-
/**
|
|
273
|
+
/** Sort utterances by this: ids sort in chronological order. */
|
|
251
274
|
id: string;
|
|
252
275
|
call_id: number;
|
|
253
|
-
/**
|
|
254
|
-
* NOT YET IMPLEMENTED — currently hardcoded to 0 at write sites on
|
|
255
|
-
* the backend. Do not use for sorting; sort by `id` (UUIDv7) instead.
|
|
256
|
-
*/
|
|
276
|
+
/** Always 0. Sort by `id`, not this. */
|
|
257
277
|
order: number;
|
|
258
278
|
is_agent: boolean | null;
|
|
259
279
|
speaker: number;
|
|
@@ -269,10 +289,7 @@ type Utterance = {
|
|
|
269
289
|
spoken_digits_normalized?: string | null;
|
|
270
290
|
vendor?: string | null;
|
|
271
291
|
};
|
|
272
|
-
/**
|
|
273
|
-
* Payload of the `TRANSCRIPTION_UPDATED` broadcast event. Mirrors
|
|
274
|
-
* `TranscriptionUpdateResponseDto` on the gateway.
|
|
275
|
-
*/
|
|
292
|
+
/** Payload of the `TRANSCRIPTION_UPDATED` broadcast event. */
|
|
276
293
|
type TranscriptionUpdate = {
|
|
277
294
|
policyNumber: string;
|
|
278
295
|
conversationId: string;
|
|
@@ -328,4 +345,4 @@ declare class AiQaSdk implements IAiqaSdk {
|
|
|
328
345
|
private isManagerEvent;
|
|
329
346
|
}
|
|
330
347
|
|
|
331
|
-
export { type AddFactResult, AiQaSdk, type Application, type ApplicationFact, type ApplicationFactAnswerChoice, type ApplicationFactAnswerFormat, type ApplicationFactInput, ConversationLanguage, type DialogAct, type DialogActConfidence, FactAnswerFormatType, type FactVerifiedPayload, type FlagFactResult, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type TranscriptionUpdate, type UpdateConversationInput, type UpdateConversationResult, type Utterance, type VerificationStatus };
|
|
348
|
+
export { type AddFactResult, AiQaSdk, type Application, type ApplicationFact, type ApplicationFactAnswerChoice, type ApplicationFactAnswerFormat, type ApplicationFactInput, type ApplicationVerificationStatus, type ApplicationVerificationSummary, ConversationLanguage, type DialogAct, type DialogActConfidence, FactAnswerFormatType, type FactVerifiedPayload, type FlagFactResult, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type TranscriptionUpdate, type UpdateConversationInput, type UpdateConversationResult, type Utterance, type VerificationStatus };
|
package/dist/node/node.js
CHANGED
|
@@ -5,6 +5,7 @@ import { io } from "socket.io-client";
|
|
|
5
5
|
var Methods = /* @__PURE__ */ ((Methods2) => {
|
|
6
6
|
Methods2["AUTHENTICATE"] = "AUTHENTICATE";
|
|
7
7
|
Methods2["GET_FACTS"] = "GET_FACTS";
|
|
8
|
+
Methods2["GET_APPLICATION"] = "GET_APPLICATION";
|
|
8
9
|
Methods2["START_RECORDING"] = "START_RECORDING";
|
|
9
10
|
Methods2["STOP_RECORDING"] = "STOP_RECORDING";
|
|
10
11
|
Methods2["IS_RECORDING"] = "IS_RECORDING";
|
|
@@ -61,7 +62,7 @@ var compareVersions = (left, right) => {
|
|
|
61
62
|
// package.json
|
|
62
63
|
var package_default = {
|
|
63
64
|
name: "@aiqa/sdk",
|
|
64
|
-
version: "2.1.0-develop.
|
|
65
|
+
version: "2.1.0-develop.4",
|
|
65
66
|
main: "dist/node/node.js",
|
|
66
67
|
module: "dist/node/node.js",
|
|
67
68
|
types: "dist/node/node.d.ts",
|
|
@@ -145,6 +146,9 @@ var DEFAULT_URL = "ws://localhost:3025/ws";
|
|
|
145
146
|
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
146
147
|
var RUNTIME = typeof window !== "undefined" && typeof window.document !== "undefined" ? "browser" : "node";
|
|
147
148
|
var USER_AGENT = RUNTIME === "browser" ? typeof navigator !== "undefined" ? navigator.userAgent : "browser/unknown" : typeof process !== "undefined" ? `node ${process.version} ${process.platform}` : "node/unknown";
|
|
149
|
+
function isRequestTimeout(error, method) {
|
|
150
|
+
return error instanceof Error && error.message === `Request timed out for ${method}`;
|
|
151
|
+
}
|
|
148
152
|
function isThenable(value) {
|
|
149
153
|
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
150
154
|
}
|
|
@@ -352,6 +356,18 @@ var AiQaSdk = class {
|
|
|
352
356
|
});
|
|
353
357
|
}
|
|
354
358
|
async getApplication() {
|
|
359
|
+
try {
|
|
360
|
+
const result = await this.sendMessage("GET_APPLICATION" /* GET_APPLICATION */);
|
|
361
|
+
const application = result && result.data !== void 0 ? result.data : result;
|
|
362
|
+
if (application && application.application_id !== void 0) {
|
|
363
|
+
return application;
|
|
364
|
+
}
|
|
365
|
+
throw new Error("GET_APPLICATION returned no application");
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (!isRequestTimeout(error, "GET_APPLICATION" /* GET_APPLICATION */)) {
|
|
368
|
+
throw error;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
355
371
|
if (this.cachedApplication) {
|
|
356
372
|
return this.cachedApplication;
|
|
357
373
|
}
|
package/dist/node/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shared.ts","../../src/types.ts","../../src/utils/compareVersions.ts","../../package.json"],"sourcesContent":["import { io, Socket } from \"socket.io-client\";\nimport {\n Methods,\n Application,\n ApplicationFact,\n ApplicationFactInput,\n SdkEvent,\n IAiqaSdk,\n AddFactResult,\n FlagFactResult,\n SetConversationProductResult,\n SetConversationLanguageResult,\n UpdateConversationInput,\n UpdateConversationResult,\n ConversationLanguage,\n} from \"./types.js\";\nimport { compareVersions } from \"./utils/compareVersions.js\";\n// @ts-ignore - compiled builds resolve this at build time\nimport pkg from \"../package.json\";\n\nconst SDK_VERSION = (pkg as { version?: string }).version ?? \"0.0.1\";\nconst DEFAULT_URL = \"ws://localhost:3025/ws\";\nconst DEFAULT_TIMEOUT_MS = 60000; // 1 minute\n\nconst RUNTIME: \"browser\" | \"node\" =\n typeof window !== \"undefined\" && typeof window.document !== \"undefined\"\n ? \"browser\"\n : \"node\";\n\nconst USER_AGENT: string =\n RUNTIME === \"browser\"\n ? typeof navigator !== \"undefined\"\n ? navigator.userAgent\n : \"browser/unknown\"\n : typeof process !== \"undefined\"\n ? `node ${process.version} ${process.platform}`\n : \"node/unknown\";\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return (\n value !== null &&\n typeof value === \"object\" &&\n typeof (value as PromiseLike<unknown>).then === \"function\"\n );\n}\n\n// Fires the trailing ack callback (when present) after delivering the\n// payload to user code. Throws and async rejections are routed to\n// console.error — propagating them would skip subsequent listeners in\n// @socket.io/component-emitter's untryCatched loop.\n//\n// Auto-parses string args as JSON. The backend's broadcast emits\n// (`FACT_VERIFIED`, `TRANSCRIPTION_UPDATED`, `CALL_STATUS_UPDATED`) all\n// send `JSON.stringify(...)` payloads, but `FactVerifiedPayload` and\n// friends are typed as plain objects. Without this parse, a consumer\n// writing `payload.factId` would read a property off a string and get\n// `undefined`. Strings that don't parse (e.g. a primitive event name)\n// pass through unchanged.\nexport function wrapEventHandler(\n callback: (...args: any[]) => any,\n): (...args: any[]) => void {\n return (...args: any[]) => {\n const last = args[args.length - 1];\n const hasAck = typeof last === \"function\";\n const rawPayload = hasAck ? args.slice(0, -1) : args;\n const payload = rawPayload.map((arg) => {\n if (typeof arg !== \"string\") return arg;\n try {\n return JSON.parse(arg);\n } catch {\n return arg;\n }\n });\n try {\n const handlerResult = callback(...payload);\n if (isThenable(handlerResult)) {\n handlerResult.then(undefined, (err) => {\n // eslint-disable-next-line no-console\n console.error(\"[AiQaSdk] async event handler rejected:\", err);\n });\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\"[AiQaSdk] event handler threw:\", err);\n } finally {\n if (hasAck) {\n try {\n last();\n } catch {\n /* swallow */\n }\n }\n }\n };\n}\n\nclass AiQaSdk implements IAiqaSdk {\n socket: Socket | null = null;\n url: string;\n applicationId: string;\n applicationSecretKey: string;\n cachedApplication?: Application;\n internalListeners: Map<SdkEvent, Set<(...args: any[]) => void>>;\n internalEvents: Set<SdkEvent>;\n // event → originalCallback → Set<wrappedCallback> registered on\n // socket.io. A Set per (event, callback) so that subscribing the\n // same fn twice registers two wrappers and two off() calls clear\n // both.\n private wrappersByEvent: Map<\n SdkEvent,\n Map<(...args: any[]) => any, Set<(...args: any[]) => void>>\n > = new Map();\n\n constructor(applicationId: string, applicationSecret: string, url?: string) {\n this.url = url ?? DEFAULT_URL;\n this.internalListeners = new Map();\n this.internalEvents = new Set([\"authenticated\"]);\n\n if (applicationId && applicationSecret) {\n this.applicationId = applicationId;\n this.applicationSecretKey = applicationSecret;\n } else {\n throw new Error(\"Application id and application secret are required\");\n }\n }\n\n on(name: SdkEvent, callback: (...args: any[]) => any) {\n if (this.internalEvents.has(name)) {\n if (!this.internalListeners.has(name)) {\n this.internalListeners.set(name, new Set());\n }\n this.internalListeners.get(name)!.add(callback);\n return;\n }\n\n if (!this.socket) {\n throw new Error(\"Not connected\");\n }\n\n if (this.isManagerEvent(name)) {\n this.socket.io.on(name, callback);\n } else {\n const wrapped = wrapEventHandler(callback);\n let wrappersByCallback = this.wrappersByEvent.get(name);\n if (!wrappersByCallback) {\n wrappersByCallback = new Map();\n this.wrappersByEvent.set(name, wrappersByCallback);\n }\n let wrappers = wrappersByCallback.get(callback);\n if (!wrappers) {\n wrappers = new Set();\n wrappersByCallback.set(callback, wrappers);\n }\n wrappers.add(wrapped);\n this.socket.on(name, wrapped);\n }\n }\n\n off(name: SdkEvent, callback?: (...args: any[]) => any) {\n if (this.internalEvents.has(name)) {\n if (!callback) {\n this.internalListeners.delete(name);\n return;\n }\n const handlers = this.internalListeners.get(name);\n if (handlers) {\n handlers.delete(callback);\n if (handlers.size === 0) {\n this.internalListeners.delete(name);\n }\n }\n return;\n }\n\n if (!this.socket) {\n throw new Error(\"Not connected\");\n }\n\n if (this.isManagerEvent(name)) {\n this.socket.io.off(name, callback);\n return;\n }\n\n if (!callback) {\n this.socket.off(name);\n this.wrappersByEvent.delete(name);\n return;\n }\n\n const wrappersByCallback = this.wrappersByEvent.get(name);\n const wrappers = wrappersByCallback?.get(callback);\n if (wrappers && wrappers.size > 0) {\n const wrapped = wrappers.values().next().value as (\n ...args: any[]\n ) => void;\n wrappers.delete(wrapped);\n this.socket.off(name, wrapped);\n if (wrappers.size === 0) {\n wrappersByCallback!.delete(callback);\n if (wrappersByCallback!.size === 0) {\n this.wrappersByEvent.delete(name);\n }\n }\n } else {\n this.socket.off(name, callback);\n }\n }\n\n connect() {\n if (!this.url) {\n return;\n }\n\n const url = new URL(this.url);\n\n const socketOptions: any = {\n reconnectionDelayMax: 10000,\n path: url.pathname,\n // WebSocket only, skipping engine.io's default HTTP long-polling phase.\n // Some embedders sit behind proxies/security gateways that duplicate the\n // polling GETs across a fleet; the concurrent polls violate engine.io's\n // one-inflight-poll-per-session rule and tear the session down, so every\n // poll then returns \"Session ID unknown\" (HTTP 400) and the client never\n // authenticates. A single WebSocket has no repeated requests to duplicate.\n transports: [\"websocket\"],\n };\n\n this.socket = io(url.origin, socketOptions);\n\n this.socket.on(\"connect\", () => {\n this.authenticate();\n });\n\n this.socket.on(\n \"app_version\",\n wrapEventHandler((payload: any) => {\n const minVersion = payload?.min;\n const maxVersion = payload?.max;\n\n if (minVersion || maxVersion) {\n const tooLow = minVersion\n ? compareVersions(SDK_VERSION, minVersion) < 0\n : false;\n const tooHigh = maxVersion\n ? compareVersions(SDK_VERSION, maxVersion) > 0\n : false;\n if (tooLow || tooHigh) {\n const error = new Error(\n `SDK version ${SDK_VERSION} is not supported. Supported range: ${minVersion || \"-\"} to ${maxVersion || \"-\"}.`,\n );\n this.socket!.disconnect();\n this.socket!.emit(\"error\", error);\n }\n }\n }),\n );\n }\n\n disconnect() {\n if (this.socket) {\n this.socket.disconnect();\n }\n this.wrappersByEvent.clear();\n }\n\n sendMessage(method: Methods, data?: any): Promise<any> {\n return new Promise((resolve, reject) => {\n if (!this.socket || !this.socket.connected) {\n reject(new Error(\"Socket is not connected\"));\n return;\n }\n\n const requestId = this.createRequestId();\n let timeout: ReturnType<typeof setTimeout> | undefined;\n const handler = (payload: any) => {\n if (timeout) {\n clearTimeout(timeout);\n }\n this.socket!.off(requestId, handler);\n let parsed = payload;\n if (typeof payload === \"string\") {\n try {\n parsed = JSON.parse(payload);\n } catch (error) {\n parsed = payload;\n }\n }\n\n if (parsed && parsed.error !== undefined) {\n reject(parsed.error);\n return;\n }\n\n // Return the full parsed envelope. Every caller below\n // (addFact, getFacts, flagFact, set*) already does its own\n // `result.data !== undefined ? result.data : result` unwrap,\n // so removing the unwrap here is behaviourally a no-op for\n // them — but it exposes top-level envelope fields like\n // `verification_status` to addFact() so the terminal\n // resolution can carry them alongside the inner data block.\n resolve(parsed);\n };\n\n this.socket.on(requestId, handler);\n\n const payload =\n data && typeof data === \"object\"\n ? { ...data, requestId }\n : { requestId, data };\n this.socket.emit(method, JSON.stringify(payload));\n\n timeout = setTimeout(() => {\n this.socket!.off(requestId, handler);\n reject(new Error(`Request timed out for ${method}`));\n }, DEFAULT_TIMEOUT_MS);\n });\n }\n\n async getApplication(): Promise<Application> {\n if (this.cachedApplication) {\n return this.cachedApplication;\n }\n throw new Error(\n \"Application is not available yet. Wait for authentication to complete.\",\n );\n }\n\n async getFacts(): Promise<ApplicationFact[]> {\n const result = await this.sendMessage(Methods.GET_FACTS);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async addFact(fact: ApplicationFactInput): Promise<AddFactResult> {\n const payload = {\n ...fact,\n critical: fact.critical ?? false,\n is_skipped: fact.is_skipped ?? false,\n };\n const result = await this.sendMessage(Methods.ADD_FACT, payload);\n if (!result) return result;\n const inner = result.data !== undefined ? result.data : result;\n\n // Older backends emit only `data` (or even a primitive like\n // `true`). New backends emit a `FactVerifiedResponseDto` envelope\n // carrying `verification_status` / `matched_components` /\n // `missing_components` at the top level ALONGSIDE the inner\n // `FactVerifiedDataDto`. Merge the envelope onto the resolved\n // value so callers awaiting addFact() see the full terminal\n // shape without subscribing to the broadcast `FACT_VERIFIED`\n // event. Skip the merge when the envelope is absent OR when inner\n // is not an object — spreading a primitive (`{ ...true }`) would\n // silently turn the resolution into `{}`.\n const hasEnvelope =\n result.verification_status !== undefined ||\n result.matched_components !== undefined ||\n result.missing_components !== undefined;\n if (!hasEnvelope || typeof inner !== \"object\" || inner === null) {\n return inner;\n }\n const merged = { ...inner } as AddFactResult;\n if (result.verification_status !== undefined) {\n merged.verification_status = result.verification_status;\n }\n if (result.matched_components !== undefined) {\n merged.matched_components = result.matched_components;\n }\n if (result.missing_components !== undefined) {\n merged.missing_components = result.missing_components;\n }\n return merged;\n }\n\n async flagFact(factId: string): Promise<FlagFactResult> {\n const result = await this.sendMessage(Methods.FLAG_FACT, {\n factId,\n });\n return result && result.data !== undefined ? result.data : result;\n }\n\n async setConversationProduct(\n product: string,\n ): Promise<SetConversationProductResult> {\n const result = await this.sendMessage(Methods.SET_CONVERSATION_PRODUCT, {\n product,\n });\n return result && result.data !== undefined ? result.data : result;\n }\n\n async setConversationLanguage(\n language: ConversationLanguage,\n ): Promise<SetConversationLanguageResult> {\n const result = await this.sendMessage(Methods.SET_CONVERSATION_LANGUAGE, {\n language,\n });\n return result && result.data !== undefined ? result.data : result;\n }\n\n async updateConversation(\n input: UpdateConversationInput,\n ): Promise<UpdateConversationResult> {\n const result = await this.sendMessage(Methods.UPDATE_CONVERSATION, input);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async authenticate(): Promise<void> {\n try {\n const result = await this.sendMessage(Methods.AUTHENTICATE, {\n applicationId: this.applicationId,\n applicationSecretKey: this.applicationSecretKey,\n sdkVersion: SDK_VERSION,\n runtime: RUNTIME,\n userAgent: USER_AGENT,\n });\n\n const application =\n result && result.data !== undefined ? result.data : result;\n\n this.cachedApplication = application;\n\n this.emitInternal(\"authenticated\", application);\n } catch (error) {\n this.socket!.emit(\"error\", error);\n }\n }\n\n async startRecording(): Promise<boolean> {\n const result = await this.sendMessage(Methods.START_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async stopRecording(): Promise<boolean> {\n const result = await this.sendMessage(Methods.STOP_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async isRecordingNow(): Promise<boolean> {\n // @TODO: track it from the server, should be sent on successfull connect\n const result = await this.sendMessage(Methods.IS_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n private emitInternal(name: SdkEvent, ...args: any[]) {\n const handlers = this.internalListeners.get(name);\n if (!handlers) {\n return;\n }\n handlers.forEach((handler) => handler(...args));\n }\n\n private createRequestId() {\n return `req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;\n }\n\n private isManagerEvent(name: SdkEvent) {\n return (\n name === \"reconnect_attempt\" ||\n name === \"reconnect_error\" ||\n name === \"reconnect_failed\" ||\n name === \"error\"\n );\n }\n}\n\nexport default AiQaSdk;\n","export type Application = {\n application_id: string;\n client_name: string;\n client_phone_number: string;\n agent_id: string;\n agent_first_name: string;\n agent_last_name: string;\n};\n\nexport enum Methods {\n AUTHENTICATE = \"AUTHENTICATE\",\n GET_FACTS = \"GET_FACTS\",\n START_RECORDING = \"START_RECORDING\",\n STOP_RECORDING = \"STOP_RECORDING\",\n IS_RECORDING = \"IS_RECORDING\",\n ADD_FACT = \"ADD_FACT\",\n FLAG_FACT = \"FLAG_FACT\",\n SET_CONVERSATION_PRODUCT = \"SET_CONVERSATION_PRODUCT\",\n SET_CONVERSATION_LANGUAGE = \"SET_CONVERSATION_LANGUAGE\",\n UPDATE_CONVERSATION = \"UPDATE_CONVERSATION\",\n}\n\nexport type SetConversationProductResult = {\n success: boolean;\n product: string;\n};\n\nexport type SetConversationLanguageResult = {\n success: boolean;\n language: string;\n};\n\nexport type UpdateConversationInput = {\n policyNumber?: string;\n insuredPhone?: string;\n clientName?: string;\n clientPhone?: string;\n clientEmail?: string;\n clientId?: string;\n agentId?: string;\n agentName?: string;\n advisorId?: string;\n advisorName?: string;\n agentGroups?: string[];\n};\n\n/** Echo of the patched subset — only the fields you sent come back. */\nexport type UpdateConversationResult = {\n success: boolean;\n conversation: {\n policy_number?: string;\n insured_phone?: string;\n client_name?: string;\n client_phone?: string;\n client_email?: string;\n client_id?: string;\n agent_id?: string;\n agent_name?: string;\n advisor_id?: string;\n advisor_name?: string;\n agent_groups?: string[];\n };\n};\n\nexport enum ConversationLanguage {\n EN = \"en\",\n ES = \"es\",\n FR = \"fr\",\n}\n\nexport type SdkEvent =\n | Methods\n | \"connect\"\n | \"disconnect\"\n | \"close\"\n | \"error\"\n | \"reconnect_attempt\"\n | \"reconnect_error\"\n | \"reconnect_failed\"\n | \"authenticated\"\n | \"app_version\"\n // Broadcast channel for every server-side verification event,\n // non-terminal OR terminal. Subscribe with\n // `sdk.on(\"FACT_VERIFIED\", cb)` to receive progress\n // (`awaiting_question`, `awaiting_answer`, `partial`,\n // `pending_confirmation_matched`, `pending_confirmation_unmatched`)\n // alongside the terminal (`matched`, `unmatched`)\n // verdicts. `addFact()`'s Promise resolves only on the terminal —\n // this event stream is the way to render progress.\n //\n // Uppercase matches the backend's `SocketEvents.FACT_VERIFIED`\n // constant (`apps/realtime-verification/src/socket/utils.ts`).\n | \"FACT_VERIFIED\"\n // Broadcast channel for every persisted utterance, real-time.\n // Subscribe with `sdk.on(\"TRANSCRIPTION_UPDATED\", cb)` to receive\n // `TranscriptionUpdate` payloads as transcripts land.\n //\n // Uppercase matches the backend's `SocketEvents.TRANSCRIPTION_UPDATED`\n // constant (`apps/realtime-verification/src/socket/utils.ts`).\n | \"TRANSCRIPTION_UPDATED\";\n\nexport enum FactAnswerFormatType {\n string = \"STRING\",\n number = \"NUMBER\",\n integer = \"INT\",\n float = \"FLOAT\",\n bool = \"BOOL\",\n list = \"LIST\",\n strict = \"STRICT\",\n single_choice = \"SINGLE_CHOICE\",\n multiple_choices = \"MULTIPLE_CHOICES\",\n}\n\nexport type ApplicationFactAnswerChoice = {\n key: string;\n text: string;\n};\n\nexport type ApplicationFactAnswerFormat = {\n type: FactAnswerFormatType;\n choices?: ApplicationFactAnswerChoice[];\n};\n\nexport type ApplicationFactInput = {\n id: string;\n /**\n * Stable identifier for the underlying question, shared across applications and\n * conversations. When provided it is used to look up (or create) the matching\n * question row in the database instead of `id`. Keep this consistent across\n * calls — accuracy improvements and remaps configured in the management\n * dashboard are scoped per `questionId`.\n */\n questionId?: string;\n question: string;\n expected_answer: any;\n answer_format: ApplicationFactAnswerFormat;\n\n category_id?: string;\n category_name?: string;\n language?: string;\n\n critical?: boolean;\n is_skipped?: boolean;\n metadata?: Record<string, string>;\n};\n\nexport type QuestionStatus = \"searching\" | \"asked\" | \"not_asked\";\n\n/**\n * Per-fact verification state.\n *\n * Extended from the original three-state shape to carry progress signals\n * the backend already detects but previously could not express. Consumers\n * that switch on this value MUST treat unknown strings as \"processing\"\n * (default fall-through) so older SDK builds keep working after the\n * backend starts emitting the additive states.\n *\n * Semantics:\n * - `processing` generic, just queued or transcription not ready\n * - `awaiting_question` agent hasn't asked the question yet\n * - `awaiting_answer` question asked, customer hasn't answered yet\n * - `partial` partial evidence; backend still working on it\n * - `pending_confirmation_matched` backend has a matching answer but is\n * holding a settling window for mid-answer\n * clarifications (e.g. spellings, \"I mean…\");\n * resolves to `matched`/`unmatched`\n * - `pending_confirmation_unmatched` same as above but the held verdict is\n * `unmatched`; UI can show \"we heard X but it\n * doesn't match, waiting to confirm\" instead\n * of a hard red verdict\n * - `matched` terminal: answer matched expected\n * - `unmatched` terminal: budget exhausted with no match\n */\nexport type VerificationStatus =\n | \"processing\"\n | \"awaiting_question\"\n | \"awaiting_answer\"\n | \"partial\"\n | \"pending_confirmation_matched\"\n | \"pending_confirmation_unmatched\"\n | \"matched\"\n | \"unmatched\";\n\nexport type ApplicationFact = ApplicationFactInput & {\n ai_answer?: any;\n question_status: QuestionStatus;\n verification_status: VerificationStatus;\n /** True once `flagFact(factId)` has been called for this fact. */\n flagged: boolean;\n};\n\nexport interface AddFactResult {\n /** Conversation the fact was attached to. Useful for cross-fact correlation in agent UIs. */\n conversation_id?: string;\n /** Echo of the original question text from the fact input. */\n question?: string;\n /** Echo of the resolved `answer_format.type` (e.g. \"STRING\", \"NUMBER\", \"SINGLE_CHOICE\"). */\n answer_type?: string;\n agent_answer?: string;\n ai_answer?: string;\n is_valid_answer: boolean;\n question_asked?: boolean;\n /**\n * 0–1 (or 0–100 — scale matches the configured similarity method).\n * Similarity between the agent's utterance and the expected question.\n * Renamed from `match_score` to disambiguate from the answer-side score.\n */\n question_match_score?: number;\n /**\n * 0–1 score derived from how well the customer's answer matched expected.\n * Populated by the verification queue from partial-match heuristics\n * (numeric-prefix ratio, matched-components ratio). Undefined when no\n * partial signal exists or for terminal results before this rolls out.\n */\n answer_match_score?: number;\n metadata?: Record<string, string>;\n /**\n * Top-level state at terminal resolution. Always one of `matched`\n * or `unmatched` because the `addFact()` Promise only\n * resolves on terminals. Optional during the rollout window for\n * backwards compatibility with older backends.\n */\n verification_status?: VerificationStatus;\n /**\n * Per-fact partial-match breakdown carried through from the\n * verification queue's component-wise comparators. For numeric-prefix\n * facts these are `[\"prefix\"]` / `[\"suffix\"]`; future work will\n * generalise to addresses, names, dates, etc.\n */\n matched_components?: string[];\n missing_components?: string[];\n}\n\n/**\n * Payload of the `FACT_VERIFIED` broadcast event.\n *\n * Fires on EVERY state transition the verification queue produces —\n * non-terminal (`partial`, `awaiting_question`, `awaiting_answer`,\n * `pending_confirmation_matched`, `pending_confirmation_unmatched`,\n * `processing`) AND terminal (`matched`, `unmatched`).\n *\n * Subscribe with:\n * sdk.on(\"FACT_VERIFIED\", (payload: FactVerifiedPayload) => {...});\n *\n * `addFact()`'s Promise resolves only on terminals; this event stream\n * is the channel for rendering live progress in the agent UI.\n */\nexport interface FactVerifiedPayload {\n factId: string;\n success: boolean;\n verification_status?: VerificationStatus;\n question_match_score?: number;\n answer_match_score?: number;\n matched_components?: string[];\n missing_components?: string[];\n /**\n * Inner data payload. Shape matches `AddFactResult` (minus the\n * top-level envelope fields) so consumers can reuse the same\n * rendering code for the terminal addFact() resolution and the\n * broadcast event.\n */\n data?: AddFactResult;\n error?: string;\n}\n\nexport type FlagFactResult = {\n success: boolean;\n};\n\n/**\n * Coarse dialog-act label produced by the backend's `UtteranceEnricher`.\n * Advisory only — do not gate production behaviour on this value; the\n * enricher emits its best-effort categorical guess plus a separate\n * `dialog_act_confidence` band.\n *\n * Mirrors `DialogAct` in\n * `libs/types/src/utterance-enrichment.ts` on the backend.\n */\nexport type DialogAct =\n | \"question\"\n | \"answer\"\n | \"acknowledgement\"\n | \"filler\"\n | \"other\";\n\n/**\n * Categorical confidence band for `dialog_act` ONLY. Named distinctly\n * from the numeric STT `confidence` field on the same utterance — the\n * two are unrelated and conflating them is a documented drift hazard on\n * the backend.\n *\n * Mirrors `DialogActConfidence` in\n * `libs/types/src/utterance-enrichment.ts` on the backend.\n */\nexport type DialogActConfidence = \"high\" | \"medium\" | \"low\";\n\n/**\n * Persisted utterance shape — matches `TranscriptionUtteranceDto` on the\n * gateway (`apps/realtime-verification/src/socket/realtimeVerification.gateway.output.dto.ts`)\n * and the `Utterance` interface in `libs/types/src/common.ts` field for\n * field. Sent over the wire by the `TRANSCRIPTION_UPDATED` broadcast.\n *\n * The 7 enricher classification fields are all optional because\n * pre-cutover utterances (persisted before backend PR #234) lack them.\n * Treat any missing or nullish value as \"unknown\" — NOT as a deliberate\n * negative signal. `is_ivr_filler_candidate === false` in particular\n * does NOT round-trip through `undefined`, so consumer logic that wants\n * \"definitely not a filler\" must check `=== false` after confirming the\n * field is present.\n */\nexport type Utterance = {\n /** UUIDv7 — chronologically sortable. Use `id` (NOT `order`) for sorting. */\n id: string;\n call_id: number;\n /**\n * NOT YET IMPLEMENTED — currently hardcoded to 0 at write sites on\n * the backend. Do not use for sorting; sort by `id` (UUIDv7) instead.\n */\n order: number;\n is_agent: boolean | null;\n speaker: number;\n text: string;\n text_en: string | null;\n start_time: number;\n end_time: number;\n dialog_act?: DialogAct;\n dialog_act_confidence?: DialogActConfidence;\n confidence?: number | null;\n top_alt_margin?: number | null;\n is_ivr_filler_candidate?: boolean;\n spoken_digits_normalized?: string | null;\n vendor?: string | null;\n};\n\n/**\n * Payload of the `TRANSCRIPTION_UPDATED` broadcast event. Mirrors\n * `TranscriptionUpdateResponseDto` on the gateway.\n */\nexport type TranscriptionUpdate = {\n policyNumber: string;\n conversationId: string;\n utterance: Utterance;\n};\n\nexport type SdkError = {\n code:\n | \"INVALID_CONFIG\"\n | \"CONNECTION_ERROR\"\n | \"TIMEOUT\"\n | \"SERVER_ERROR\"\n | \"UNEXPECTED_RESPONSE\";\n message: string;\n details?: any;\n};\n\nexport abstract class IAiqaSdk {\n abstract connect(): void;\n abstract disconnect(): void;\n\n abstract on(eventName: string, callback: (...args: any[]) => any): void;\n abstract off(eventName: string, callback?: (...args: any[]) => any): void;\n\n abstract getApplication(): Promise<Application>;\n abstract addFact(fact: ApplicationFactInput): Promise<AddFactResult>;\n abstract flagFact(factId: string): Promise<FlagFactResult>;\n abstract getFacts(): Promise<ApplicationFact[]>;\n abstract setConversationProduct(\n product: string,\n ): Promise<SetConversationProductResult>;\n abstract setConversationLanguage(\n language: ConversationLanguage,\n ): Promise<SetConversationLanguageResult>;\n abstract updateConversation(\n input: UpdateConversationInput,\n ): Promise<UpdateConversationResult>;\n}\n","const splitVersion = (value: string) => {\n const [core] = value.split(\"-\", 2);\n return core.split(\".\").map((part) => Number(part));\n};\n\nexport const compareVersions = (left: string, right: string): number => {\n const leftParts = splitVersion(left);\n const rightParts = splitVersion(right);\n const maxLength = Math.max(leftParts.length, rightParts.length);\n\n for (let i = 0; i < maxLength; i += 1) {\n const l = leftParts[i] ?? 0;\n const r = rightParts[i] ?? 0;\n if (l > r) {\n return 1;\n }\n if (l < r) {\n return -1;\n }\n }\n\n return 0;\n};\n","{\n \"name\": \"@aiqa/sdk\",\n \"version\": \"2.1.0-develop.2\",\n \"main\": \"dist/node/node.js\",\n \"module\": \"dist/node/node.js\",\n \"types\": \"dist/node/node.d.ts\",\n \"engines\": {\n \"node\": \">=18\"\n },\n \"scripts\": {\n \"build\": \"tsup && node -e \\\"const fs=require('fs');['dist/node/node','dist/browser/browser'].forEach(f=>{const mts=f+'.d.mts';const ts=f+'.d.ts';if(fs.existsSync(mts)){fs.renameSync(mts,ts);}});\\\"\",\n \"commitlint\": \"commitlint\",\n \"dev:node\": \"tsx src/node.ts\",\n \"lint\": \"tsc --noEmit -p tsconfig.json\",\n \"format\": \"prettier --check \\\"{src,tests}/**/*.{ts,tsx,js,json,md,yml,yaml}\\\" \\\"*.{js,json,md,yml,yaml,ts}\\\" --ignore-path .prettierignore\",\n \"release\": \"semantic-release\",\n \"start:node\": \"node dist/node/node.js\",\n \"serve:browser\": \"serve .\",\n \"test\": \"jest\",\n \"prepare\": \"husky\",\n \"lint-staged\": \"lint-staged\"\n },\n \"lint-staged\": {\n \"*.{ts,tsx,js,json,md,yml,yaml}\": [\n \"prettier --write\"\n ]\n },\n \"exports\": {\n \".\": {\n \"node\": {\n \"import\": \"./dist/node/node.js\",\n \"types\": \"./dist/node/node.d.ts\"\n },\n \"browser\": {\n \"import\": \"./dist/browser/browser.js\",\n \"types\": \"./dist/browser/browser.d.ts\"\n },\n \"default\": \"./dist/node/node.js\"\n }\n },\n \"private\": false,\n \"license\": \"MIT\",\n \"author\": \"AIQA\",\n \"description\": \"TypeScript/JavaScript SDK for interacting with the AIQA.\",\n \"keywords\": [\n \"aiqa\",\n \"sdk\"\n ],\n \"files\": [\n \"dist\"\n ],\n \"devDependencies\": {\n \"@commitlint/cli\": \"^20.4.4\",\n \"@commitlint/config-conventional\": \"^20.4.4\",\n \"@jest/globals\": \"^29.7.0\",\n \"@semantic-release/commit-analyzer\": \"^13.0.1\",\n \"@semantic-release/git\": \"^10.0.1\",\n \"@semantic-release/npm\": \"^12.0.2\",\n \"@semantic-release/release-notes-generator\": \"^14.1.0\",\n \"@types/node\": \"^22.0.0\",\n \"conventional-changelog-conventionalcommits\": \"^9.3.0\",\n \"esbuild\": \"^0.23.0\",\n \"husky\": \"^9.1.7\",\n \"jest\": \"^29.7.0\",\n \"lint-staged\": \"^16.4.0\",\n \"prettier\": \"^3.8.1\",\n \"semantic-release\": \"^24.2.9\",\n \"serve\": \"^14.2.3\",\n \"socket.io\": \"^4.7.5\",\n \"ts-jest\": \"^29.2.3\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^8.0.0\",\n \"tsx\": \"^4.0.0\",\n \"typescript\": \"^5.7.0\"\n },\n \"dependencies\": {\n \"socket.io-client\": \"^4.7.5\"\n }\n}\n"],"mappings":";AAAA,SAAS,UAAkB;;;ACSpB,IAAK,UAAL,kBAAKA,aAAL;AACL,EAAAA,SAAA,kBAAe;AACf,EAAAA,SAAA,eAAY;AACZ,EAAAA,SAAA,qBAAkB;AAClB,EAAAA,SAAA,oBAAiB;AACjB,EAAAA,SAAA,kBAAe;AACf,EAAAA,SAAA,cAAW;AACX,EAAAA,SAAA,eAAY;AACZ,EAAAA,SAAA,8BAA2B;AAC3B,EAAAA,SAAA,+BAA4B;AAC5B,EAAAA,SAAA,yBAAsB;AAVZ,SAAAA;AAAA,GAAA;AAuDL,IAAK,uBAAL,kBAAKC,0BAAL;AACL,EAAAA,sBAAA,QAAK;AACL,EAAAA,sBAAA,QAAK;AACL,EAAAA,sBAAA,QAAK;AAHK,SAAAA;AAAA,GAAA;AAqCL,IAAK,uBAAL,kBAAKC,0BAAL;AACL,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,aAAU;AACV,EAAAA,sBAAA,WAAQ;AACR,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,mBAAgB;AAChB,EAAAA,sBAAA,sBAAmB;AATT,SAAAA;AAAA,GAAA;AA8PL,IAAe,WAAf,MAAwB;AAoB/B;;;ACvXA,IAAM,eAAe,CAAC,UAAkB;AACtC,QAAM,CAAC,IAAI,IAAI,MAAM,MAAM,KAAK,CAAC;AACjC,SAAO,KAAK,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC;AACnD;AAEO,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":3,"sources":["../../src/shared.ts","../../src/types.ts","../../src/utils/compareVersions.ts","../../package.json"],"sourcesContent":["import { io, Socket } from \"socket.io-client\";\nimport {\n Methods,\n Application,\n ApplicationFact,\n ApplicationFactInput,\n SdkEvent,\n IAiqaSdk,\n AddFactResult,\n FlagFactResult,\n SetConversationProductResult,\n SetConversationLanguageResult,\n UpdateConversationInput,\n UpdateConversationResult,\n ConversationLanguage,\n} from \"./types.js\";\nimport { compareVersions } from \"./utils/compareVersions.js\";\n// @ts-ignore - compiled builds resolve this at build time\nimport pkg from \"../package.json\";\n\nconst SDK_VERSION = (pkg as { version?: string }).version ?? \"0.0.1\";\nconst DEFAULT_URL = \"ws://localhost:3025/ws\";\nconst DEFAULT_TIMEOUT_MS = 60000; // 1 minute\n\nconst RUNTIME: \"browser\" | \"node\" =\n typeof window !== \"undefined\" && typeof window.document !== \"undefined\"\n ? \"browser\"\n : \"node\";\n\nconst USER_AGENT: string =\n RUNTIME === \"browser\"\n ? typeof navigator !== \"undefined\"\n ? navigator.userAgent\n : \"browser/unknown\"\n : typeof process !== \"undefined\"\n ? `node ${process.version} ${process.platform}`\n : \"node/unknown\";\n\nfunction isRequestTimeout(error: unknown, method: Methods): boolean {\n return (\n error instanceof Error &&\n error.message === `Request timed out for ${method}`\n );\n}\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return (\n value !== null &&\n typeof value === \"object\" &&\n typeof (value as PromiseLike<unknown>).then === \"function\"\n );\n}\n\n// Fires the trailing ack callback (when present) after delivering the\n// payload to user code. Throws and async rejections are routed to\n// console.error — propagating them would skip subsequent listeners in\n// @socket.io/component-emitter's untryCatched loop.\n//\n// Auto-parses string args as JSON. The backend's broadcast emits\n// (`FACT_VERIFIED`, `TRANSCRIPTION_UPDATED`, `CALL_STATUS_UPDATED`) all\n// send `JSON.stringify(...)` payloads, but `FactVerifiedPayload` and\n// friends are typed as plain objects. Without this parse, a consumer\n// writing `payload.factId` would read a property off a string and get\n// `undefined`. Strings that don't parse (e.g. a primitive event name)\n// pass through unchanged.\nexport function wrapEventHandler(\n callback: (...args: any[]) => any,\n): (...args: any[]) => void {\n return (...args: any[]) => {\n const last = args[args.length - 1];\n const hasAck = typeof last === \"function\";\n const rawPayload = hasAck ? args.slice(0, -1) : args;\n const payload = rawPayload.map((arg) => {\n if (typeof arg !== \"string\") return arg;\n try {\n return JSON.parse(arg);\n } catch {\n return arg;\n }\n });\n try {\n const handlerResult = callback(...payload);\n if (isThenable(handlerResult)) {\n handlerResult.then(undefined, (err) => {\n // eslint-disable-next-line no-console\n console.error(\"[AiQaSdk] async event handler rejected:\", err);\n });\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\"[AiQaSdk] event handler threw:\", err);\n } finally {\n if (hasAck) {\n try {\n last();\n } catch {\n /* swallow */\n }\n }\n }\n };\n}\n\nclass AiQaSdk implements IAiqaSdk {\n socket: Socket | null = null;\n url: string;\n applicationId: string;\n applicationSecretKey: string;\n cachedApplication?: Application;\n internalListeners: Map<SdkEvent, Set<(...args: any[]) => void>>;\n internalEvents: Set<SdkEvent>;\n // event → originalCallback → Set<wrappedCallback> registered on\n // socket.io. A Set per (event, callback) so that subscribing the\n // same fn twice registers two wrappers and two off() calls clear\n // both.\n private wrappersByEvent: Map<\n SdkEvent,\n Map<(...args: any[]) => any, Set<(...args: any[]) => void>>\n > = new Map();\n\n constructor(applicationId: string, applicationSecret: string, url?: string) {\n this.url = url ?? DEFAULT_URL;\n this.internalListeners = new Map();\n this.internalEvents = new Set([\"authenticated\"]);\n\n if (applicationId && applicationSecret) {\n this.applicationId = applicationId;\n this.applicationSecretKey = applicationSecret;\n } else {\n throw new Error(\"Application id and application secret are required\");\n }\n }\n\n on(name: SdkEvent, callback: (...args: any[]) => any) {\n if (this.internalEvents.has(name)) {\n if (!this.internalListeners.has(name)) {\n this.internalListeners.set(name, new Set());\n }\n this.internalListeners.get(name)!.add(callback);\n return;\n }\n\n if (!this.socket) {\n throw new Error(\"Not connected\");\n }\n\n if (this.isManagerEvent(name)) {\n this.socket.io.on(name, callback);\n } else {\n const wrapped = wrapEventHandler(callback);\n let wrappersByCallback = this.wrappersByEvent.get(name);\n if (!wrappersByCallback) {\n wrappersByCallback = new Map();\n this.wrappersByEvent.set(name, wrappersByCallback);\n }\n let wrappers = wrappersByCallback.get(callback);\n if (!wrappers) {\n wrappers = new Set();\n wrappersByCallback.set(callback, wrappers);\n }\n wrappers.add(wrapped);\n this.socket.on(name, wrapped);\n }\n }\n\n off(name: SdkEvent, callback?: (...args: any[]) => any) {\n if (this.internalEvents.has(name)) {\n if (!callback) {\n this.internalListeners.delete(name);\n return;\n }\n const handlers = this.internalListeners.get(name);\n if (handlers) {\n handlers.delete(callback);\n if (handlers.size === 0) {\n this.internalListeners.delete(name);\n }\n }\n return;\n }\n\n if (!this.socket) {\n throw new Error(\"Not connected\");\n }\n\n if (this.isManagerEvent(name)) {\n this.socket.io.off(name, callback);\n return;\n }\n\n if (!callback) {\n this.socket.off(name);\n this.wrappersByEvent.delete(name);\n return;\n }\n\n const wrappersByCallback = this.wrappersByEvent.get(name);\n const wrappers = wrappersByCallback?.get(callback);\n if (wrappers && wrappers.size > 0) {\n const wrapped = wrappers.values().next().value as (\n ...args: any[]\n ) => void;\n wrappers.delete(wrapped);\n this.socket.off(name, wrapped);\n if (wrappers.size === 0) {\n wrappersByCallback!.delete(callback);\n if (wrappersByCallback!.size === 0) {\n this.wrappersByEvent.delete(name);\n }\n }\n } else {\n this.socket.off(name, callback);\n }\n }\n\n connect() {\n if (!this.url) {\n return;\n }\n\n const url = new URL(this.url);\n\n const socketOptions: any = {\n reconnectionDelayMax: 10000,\n path: url.pathname,\n // WebSocket only, skipping engine.io's default HTTP long-polling phase.\n // Some embedders sit behind proxies/security gateways that duplicate the\n // polling GETs across a fleet; the concurrent polls violate engine.io's\n // one-inflight-poll-per-session rule and tear the session down, so every\n // poll then returns \"Session ID unknown\" (HTTP 400) and the client never\n // authenticates. A single WebSocket has no repeated requests to duplicate.\n transports: [\"websocket\"],\n };\n\n this.socket = io(url.origin, socketOptions);\n\n this.socket.on(\"connect\", () => {\n this.authenticate();\n });\n\n this.socket.on(\n \"app_version\",\n wrapEventHandler((payload: any) => {\n const minVersion = payload?.min;\n const maxVersion = payload?.max;\n\n if (minVersion || maxVersion) {\n const tooLow = minVersion\n ? compareVersions(SDK_VERSION, minVersion) < 0\n : false;\n const tooHigh = maxVersion\n ? compareVersions(SDK_VERSION, maxVersion) > 0\n : false;\n if (tooLow || tooHigh) {\n const error = new Error(\n `SDK version ${SDK_VERSION} is not supported. Supported range: ${minVersion || \"-\"} to ${maxVersion || \"-\"}.`,\n );\n this.socket!.disconnect();\n this.socket!.emit(\"error\", error);\n }\n }\n }),\n );\n }\n\n disconnect() {\n if (this.socket) {\n this.socket.disconnect();\n }\n this.wrappersByEvent.clear();\n }\n\n sendMessage(method: Methods, data?: any): Promise<any> {\n return new Promise((resolve, reject) => {\n if (!this.socket || !this.socket.connected) {\n reject(new Error(\"Socket is not connected\"));\n return;\n }\n\n const requestId = this.createRequestId();\n let timeout: ReturnType<typeof setTimeout> | undefined;\n const handler = (payload: any) => {\n if (timeout) {\n clearTimeout(timeout);\n }\n this.socket!.off(requestId, handler);\n let parsed = payload;\n if (typeof payload === \"string\") {\n try {\n parsed = JSON.parse(payload);\n } catch (error) {\n parsed = payload;\n }\n }\n\n if (parsed && parsed.error !== undefined) {\n reject(parsed.error);\n return;\n }\n\n // Return the full parsed envelope. Every caller below\n // (addFact, getFacts, flagFact, set*) already does its own\n // `result.data !== undefined ? result.data : result` unwrap,\n // so removing the unwrap here is behaviourally a no-op for\n // them — but it exposes top-level envelope fields like\n // `verification_status` to addFact() so the terminal\n // resolution can carry them alongside the inner data block.\n resolve(parsed);\n };\n\n this.socket.on(requestId, handler);\n\n const payload =\n data && typeof data === \"object\"\n ? { ...data, requestId }\n : { requestId, data };\n this.socket.emit(method, JSON.stringify(payload));\n\n timeout = setTimeout(() => {\n this.socket!.off(requestId, handler);\n reject(new Error(`Request timed out for ${method}`));\n }, DEFAULT_TIMEOUT_MS);\n });\n }\n\n async getApplication(): Promise<Application> {\n try {\n const result = await this.sendMessage(Methods.GET_APPLICATION);\n const application =\n result && result.data !== undefined ? result.data : result;\n if (application && application.application_id !== undefined) {\n return application;\n }\n throw new Error(\"GET_APPLICATION returned no application\");\n } catch (error) {\n // Only a server that predates GET_APPLICATION is worth absorbing: it\n // never answers, so the request can only end in a timeout. Anything else\n // — a rejected request, a dropped socket, a server-side failure — is a\n // real error, and swallowing it would hand back the authentication\n // snapshot as though it were live.\n if (!isRequestTimeout(error, Methods.GET_APPLICATION)) {\n throw error;\n }\n }\n\n // Never overwritten by this method, so it stays the snapshot taken at\n // authentication: identity fields only, no `verification`. That absence is\n // the signal the caller reads — a stale summary would be indistinguishable\n // from a live one.\n if (this.cachedApplication) {\n return this.cachedApplication;\n }\n throw new Error(\n \"Application is not available yet. Wait for authentication to complete.\",\n );\n }\n\n async getFacts(): Promise<ApplicationFact[]> {\n const result = await this.sendMessage(Methods.GET_FACTS);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async addFact(fact: ApplicationFactInput): Promise<AddFactResult> {\n const payload = {\n ...fact,\n critical: fact.critical ?? false,\n is_skipped: fact.is_skipped ?? false,\n };\n const result = await this.sendMessage(Methods.ADD_FACT, payload);\n if (!result) return result;\n const inner = result.data !== undefined ? result.data : result;\n\n // Older backends emit only `data` (or even a primitive like\n // `true`). New backends emit a `FactVerifiedResponseDto` envelope\n // carrying `verification_status` / `matched_components` /\n // `missing_components` at the top level ALONGSIDE the inner\n // `FactVerifiedDataDto`. Merge the envelope onto the resolved\n // value so callers awaiting addFact() see the full terminal\n // shape without subscribing to the broadcast `FACT_VERIFIED`\n // event. Skip the merge when the envelope is absent OR when inner\n // is not an object — spreading a primitive (`{ ...true }`) would\n // silently turn the resolution into `{}`.\n const hasEnvelope =\n result.verification_status !== undefined ||\n result.matched_components !== undefined ||\n result.missing_components !== undefined;\n if (!hasEnvelope || typeof inner !== \"object\" || inner === null) {\n return inner;\n }\n const merged = { ...inner } as AddFactResult;\n if (result.verification_status !== undefined) {\n merged.verification_status = result.verification_status;\n }\n if (result.matched_components !== undefined) {\n merged.matched_components = result.matched_components;\n }\n if (result.missing_components !== undefined) {\n merged.missing_components = result.missing_components;\n }\n return merged;\n }\n\n async flagFact(factId: string): Promise<FlagFactResult> {\n const result = await this.sendMessage(Methods.FLAG_FACT, {\n factId,\n });\n return result && result.data !== undefined ? result.data : result;\n }\n\n async setConversationProduct(\n product: string,\n ): Promise<SetConversationProductResult> {\n const result = await this.sendMessage(Methods.SET_CONVERSATION_PRODUCT, {\n product,\n });\n return result && result.data !== undefined ? result.data : result;\n }\n\n async setConversationLanguage(\n language: ConversationLanguage,\n ): Promise<SetConversationLanguageResult> {\n const result = await this.sendMessage(Methods.SET_CONVERSATION_LANGUAGE, {\n language,\n });\n return result && result.data !== undefined ? result.data : result;\n }\n\n async updateConversation(\n input: UpdateConversationInput,\n ): Promise<UpdateConversationResult> {\n const result = await this.sendMessage(Methods.UPDATE_CONVERSATION, input);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async authenticate(): Promise<void> {\n try {\n const result = await this.sendMessage(Methods.AUTHENTICATE, {\n applicationId: this.applicationId,\n applicationSecretKey: this.applicationSecretKey,\n sdkVersion: SDK_VERSION,\n runtime: RUNTIME,\n userAgent: USER_AGENT,\n });\n\n const application =\n result && result.data !== undefined ? result.data : result;\n\n this.cachedApplication = application;\n\n this.emitInternal(\"authenticated\", application);\n } catch (error) {\n this.socket!.emit(\"error\", error);\n }\n }\n\n async startRecording(): Promise<boolean> {\n const result = await this.sendMessage(Methods.START_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async stopRecording(): Promise<boolean> {\n const result = await this.sendMessage(Methods.STOP_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async isRecordingNow(): Promise<boolean> {\n // @TODO: track it from the server, should be sent on successfull connect\n const result = await this.sendMessage(Methods.IS_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n private emitInternal(name: SdkEvent, ...args: any[]) {\n const handlers = this.internalListeners.get(name);\n if (!handlers) {\n return;\n }\n handlers.forEach((handler) => handler(...args));\n }\n\n private createRequestId() {\n return `req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;\n }\n\n private isManagerEvent(name: SdkEvent) {\n return (\n name === \"reconnect_attempt\" ||\n name === \"reconnect_error\" ||\n name === \"reconnect_failed\" ||\n name === \"error\"\n );\n }\n}\n\nexport default AiQaSdk;\n","/**\n * Overall result for the call: `critical_errors` if a fact you sent with\n * `critical: true` failed, `errors` if any other fact failed, else\n * `no_errors`.\n *\n * Only answers count. A question that was never asked never raises it, so a\n * call where nothing was asked reads `no_errors`.\n *\n * Not the same as `VerificationStatus`, which describes a single fact.\n */\nexport type ApplicationVerificationStatus =\n | \"no_errors\"\n | \"errors\"\n | \"critical_errors\";\n\n/**\n * How the facts on one application are counted up. None of these is a count of\n * facts that passed, and they overlap — to show a pass count, count the facts\n * whose `verification_status` is `matched` in `getFacts()`.\n */\nexport type ApplicationVerificationSummary = {\n status: ApplicationVerificationStatus;\n /** Facts whose answer did not match the expected one. */\n count_errors: number;\n /** The facts in `count_errors` that you sent with `critical: true`. */\n count_critical_errors: number;\n /**\n * Every fact on the application, checked or not. The other counters are\n * subsets of it and can overlap each other, so no subtraction from\n * `count_total` yields a pass count.\n */\n count_total: number;\n /**\n * Facts whose question was never asked. Excludes the still-pending ones, but\n * overlaps `count_errors`: a fact never asked that came back wrong is in both.\n */\n count_not_asked: number;\n /** The facts in `count_not_asked` that you sent with `critical: true`. */\n count_critical_not_asked: number;\n /**\n * Facts added but not resolved yet. During a live call most facts sit here\n * and move into the other counters as their results arrive.\n */\n count_pending: number;\n /**\n * Facts flagged as suspicious when the call is reviewed — for instance the\n * agent leading the customer to the expected answer. Independent of the\n * answer: a matched fact can be flagged. Reads 0 while the call is running.\n */\n count_suspicious: number;\n};\n\nexport type Application = {\n application_id: string;\n client_name: string;\n client_phone_number: string;\n agent_id: string;\n /** Comes back empty. Set an agent name with `updateConversation()`. */\n agent_first_name: string;\n /** Comes back empty. Set an agent name with `updateConversation()`. */\n agent_last_name: string;\n /**\n * How the call is going so far. When it is missing there is no summary —\n * which is not the same as all zeros — and the fields above may then be the\n * ones from authentication, without an `updateConversation()` you made since.\n */\n verification?: ApplicationVerificationSummary;\n};\n\nexport enum Methods {\n AUTHENTICATE = \"AUTHENTICATE\",\n GET_FACTS = \"GET_FACTS\",\n GET_APPLICATION = \"GET_APPLICATION\",\n START_RECORDING = \"START_RECORDING\",\n STOP_RECORDING = \"STOP_RECORDING\",\n IS_RECORDING = \"IS_RECORDING\",\n ADD_FACT = \"ADD_FACT\",\n FLAG_FACT = \"FLAG_FACT\",\n SET_CONVERSATION_PRODUCT = \"SET_CONVERSATION_PRODUCT\",\n SET_CONVERSATION_LANGUAGE = \"SET_CONVERSATION_LANGUAGE\",\n UPDATE_CONVERSATION = \"UPDATE_CONVERSATION\",\n}\n\nexport type SetConversationProductResult = {\n success: boolean;\n product: string;\n};\n\nexport type SetConversationLanguageResult = {\n success: boolean;\n language: string;\n};\n\nexport type UpdateConversationInput = {\n policyNumber?: string;\n insuredPhone?: string;\n clientName?: string;\n clientPhone?: string;\n clientEmail?: string;\n clientId?: string;\n agentId?: string;\n agentName?: string;\n advisorId?: string;\n advisorName?: string;\n agentGroups?: string[];\n};\n\n/** Only the fields you sent come back in `conversation`. */\nexport type UpdateConversationResult = {\n success: boolean;\n conversation: {\n policy_number?: string;\n insured_phone?: string;\n client_name?: string;\n client_phone?: string;\n client_email?: string;\n client_id?: string;\n agent_id?: string;\n agent_name?: string;\n advisor_id?: string;\n advisor_name?: string;\n agent_groups?: string[];\n };\n};\n\nexport enum ConversationLanguage {\n EN = \"en\",\n ES = \"es\",\n FR = \"fr\",\n}\n\nexport type SdkEvent =\n | Methods\n | \"connect\"\n | \"disconnect\"\n | \"close\"\n | \"error\"\n | \"reconnect_attempt\"\n | \"reconnect_error\"\n | \"reconnect_failed\"\n | \"authenticated\"\n | \"app_version\"\n // Every verification state change, for every fact. Payload:\n // `FactVerifiedPayload`.\n | \"FACT_VERIFIED\"\n // Every utterance, as it is transcribed. Payload: `TranscriptionUpdate`.\n | \"TRANSCRIPTION_UPDATED\";\n\nexport enum FactAnswerFormatType {\n string = \"STRING\",\n number = \"NUMBER\",\n integer = \"INT\",\n float = \"FLOAT\",\n bool = \"BOOL\",\n list = \"LIST\",\n strict = \"STRICT\",\n single_choice = \"SINGLE_CHOICE\",\n multiple_choices = \"MULTIPLE_CHOICES\",\n}\n\nexport type ApplicationFactAnswerChoice = {\n key: string;\n text: string;\n};\n\nexport type ApplicationFactAnswerFormat = {\n type: FactAnswerFormatType;\n choices?: ApplicationFactAnswerChoice[];\n};\n\nexport type ApplicationFactInput = {\n id: string;\n /**\n * Stable identifier for the underlying question, shared across applications\n * and conversations. When provided it identifies the question instead of\n * `id`. Keep it consistent across calls: whatever AIQA has tuned for a\n * question is attached to this identity.\n */\n questionId?: string;\n question: string;\n expected_answer: any;\n answer_format: ApplicationFactAnswerFormat;\n\n category_id?: string;\n category_name?: string;\n language?: string;\n\n /**\n * Mark the question critical: its failures land in `count_critical_errors`,\n * and one of them sets the call's `status` to `critical_errors`.\n */\n critical?: boolean;\n is_skipped?: boolean;\n /**\n * Your own identifiers for this fact — a form field ID, a section name,\n * anything that lets your UI map the result back to the right place.\n * `getFacts()` returns it unchanged — `{}` for a fact you added without\n * one — and it plays no part in verification.\n *\n * Keys and values must all be strings, and each value is limited to 1024\n * characters. A payload that breaks either rule is rejected.\n */\n metadata?: Record<string, string>;\n};\n\nexport type QuestionStatus = \"searching\" | \"asked\" | \"not_asked\";\n\n/**\n * Per-fact verification state. Handle any value you don't recognize as\n * `processing`.\n *\n * - `processing` queued, or nothing to go on yet\n * - `awaiting_question` the agent hasn't asked the question yet\n * - `awaiting_answer` asked, the customer hasn't answered yet\n * - `partial` partial evidence so far (e.g. \"305\" of \"30521\")\n * - `pending_confirmation_matched` a matching answer is held briefly in case\n * the customer corrects it mid-answer\n * (spellings, \"I mean…\"); resolves to\n * `matched`/`unmatched`\n * - `pending_confirmation_unmatched` same, with an unmatched answer held; show\n * \"we heard X but it doesn't match, waiting\n * to confirm\" rather than a hard result\n * - `matched` final: the answer matched\n * - `unmatched` final: the answer did not match\n */\nexport type VerificationStatus =\n | \"processing\"\n | \"awaiting_question\"\n | \"awaiting_answer\"\n | \"partial\"\n | \"pending_confirmation_matched\"\n | \"pending_confirmation_unmatched\"\n | \"matched\"\n | \"unmatched\";\n\nexport type ApplicationFact = ApplicationFactInput & {\n ai_answer?: any;\n question_status: QuestionStatus;\n verification_status: VerificationStatus;\n /** True once `flagFact(factId)` has been called for this fact. */\n flagged: boolean;\n};\n\nexport interface AddFactResult {\n /** Conversation the fact was attached to. */\n conversation_id?: string;\n /** Echo of the original question text from the fact input. */\n question?: string;\n /** Echo of the resolved `answer_format.type` (e.g. \"STRING\", \"NUMBER\", \"SINGLE_CHOICE\"). */\n answer_type?: string;\n agent_answer?: string;\n ai_answer?: string;\n is_valid_answer: boolean;\n question_asked?: boolean;\n /**\n * How closely the agent's utterance matched the expected question, on a 0–1\n * or a 0–100 scale. Higher is closer.\n */\n question_match_score?: number;\n /**\n * 0–1 score for how closely the customer's answer matched the expected one.\n * Undefined when there is no partial signal to score.\n */\n answer_match_score?: number;\n metadata?: Record<string, string>;\n /**\n * The final state: `matched` or `unmatched` whenever it is present. Fall\n * back to `is_valid_answer` when it is missing.\n */\n verification_status?: VerificationStatus;\n /**\n * Component labels describing which parts of the expected answer\n * matched. Currently `[\"prefix\"]` / `[\"suffix\"]` for numeric facts;\n * treat the set as open-ended.\n */\n matched_components?: string[];\n missing_components?: string[];\n}\n\n/**\n * Payload of the `FACT_VERIFIED` event, which fires on every state change —\n * see `VerificationStatus`. Use it to show progress; `addFact()` resolves\n * only once a fact is done.\n */\nexport interface FactVerifiedPayload {\n factId: string;\n success: boolean;\n verification_status?: VerificationStatus;\n question_match_score?: number;\n answer_match_score?: number;\n matched_components?: string[];\n missing_components?: string[];\n /** Inner payload, shaped like `AddFactResult`. */\n data?: AddFactResult;\n error?: string;\n}\n\nexport type FlagFactResult = {\n success: boolean;\n};\n\n/**\n * What the utterance appears to be doing in the conversation. A best-effort\n * guess: display it if it helps, but do not gate behaviour on it. Its\n * confidence band is `dialog_act_confidence`.\n */\nexport type DialogAct =\n | \"question\"\n | \"answer\"\n | \"acknowledgement\"\n | \"filler\"\n | \"other\";\n\n/**\n * Confidence band for `dialog_act` only. Unrelated to the numeric\n * `confidence` field on the same utterance — do not compare the two.\n */\nexport type DialogActConfidence = \"high\" | \"medium\" | \"low\";\n\n/**\n * An utterance from the `TRANSCRIPTION_UPDATED` event.\n *\n * A missing optional field means \"unknown\", not \"no\".\n */\nexport type Utterance = {\n /** Sort utterances by this: ids sort in chronological order. */\n id: string;\n call_id: number;\n /** Always 0. Sort by `id`, not this. */\n order: number;\n is_agent: boolean | null;\n speaker: number;\n text: string;\n text_en: string | null;\n start_time: number;\n end_time: number;\n dialog_act?: DialogAct;\n dialog_act_confidence?: DialogActConfidence;\n confidence?: number | null;\n top_alt_margin?: number | null;\n is_ivr_filler_candidate?: boolean;\n spoken_digits_normalized?: string | null;\n vendor?: string | null;\n};\n\n/** Payload of the `TRANSCRIPTION_UPDATED` broadcast event. */\nexport type TranscriptionUpdate = {\n policyNumber: string;\n conversationId: string;\n utterance: Utterance;\n};\n\nexport type SdkError = {\n code:\n | \"INVALID_CONFIG\"\n | \"CONNECTION_ERROR\"\n | \"TIMEOUT\"\n | \"SERVER_ERROR\"\n | \"UNEXPECTED_RESPONSE\";\n message: string;\n details?: any;\n};\n\nexport abstract class IAiqaSdk {\n abstract connect(): void;\n abstract disconnect(): void;\n\n abstract on(eventName: string, callback: (...args: any[]) => any): void;\n abstract off(eventName: string, callback?: (...args: any[]) => any): void;\n\n abstract getApplication(): Promise<Application>;\n abstract addFact(fact: ApplicationFactInput): Promise<AddFactResult>;\n abstract flagFact(factId: string): Promise<FlagFactResult>;\n abstract getFacts(): Promise<ApplicationFact[]>;\n abstract setConversationProduct(\n product: string,\n ): Promise<SetConversationProductResult>;\n abstract setConversationLanguage(\n language: ConversationLanguage,\n ): Promise<SetConversationLanguageResult>;\n abstract updateConversation(\n input: UpdateConversationInput,\n ): Promise<UpdateConversationResult>;\n}\n","const splitVersion = (value: string) => {\n const [core] = value.split(\"-\", 2);\n return core.split(\".\").map((part) => Number(part));\n};\n\nexport const compareVersions = (left: string, right: string): number => {\n const leftParts = splitVersion(left);\n const rightParts = splitVersion(right);\n const maxLength = Math.max(leftParts.length, rightParts.length);\n\n for (let i = 0; i < maxLength; i += 1) {\n const l = leftParts[i] ?? 0;\n const r = rightParts[i] ?? 0;\n if (l > r) {\n return 1;\n }\n if (l < r) {\n return -1;\n }\n }\n\n return 0;\n};\n","{\n \"name\": \"@aiqa/sdk\",\n \"version\": \"2.1.0-develop.4\",\n \"main\": \"dist/node/node.js\",\n \"module\": \"dist/node/node.js\",\n \"types\": \"dist/node/node.d.ts\",\n \"engines\": {\n \"node\": \">=18\"\n },\n \"scripts\": {\n \"build\": \"tsup && node -e \\\"const fs=require('fs');['dist/node/node','dist/browser/browser'].forEach(f=>{const mts=f+'.d.mts';const ts=f+'.d.ts';if(fs.existsSync(mts)){fs.renameSync(mts,ts);}});\\\"\",\n \"commitlint\": \"commitlint\",\n \"dev:node\": \"tsx src/node.ts\",\n \"lint\": \"tsc --noEmit -p tsconfig.json\",\n \"format\": \"prettier --check \\\"{src,tests}/**/*.{ts,tsx,js,json,md,yml,yaml}\\\" \\\"*.{js,json,md,yml,yaml,ts}\\\" --ignore-path .prettierignore\",\n \"release\": \"semantic-release\",\n \"start:node\": \"node dist/node/node.js\",\n \"serve:browser\": \"serve .\",\n \"test\": \"jest\",\n \"prepare\": \"husky\",\n \"lint-staged\": \"lint-staged\"\n },\n \"lint-staged\": {\n \"*.{ts,tsx,js,json,md,yml,yaml}\": [\n \"prettier --write\"\n ]\n },\n \"exports\": {\n \".\": {\n \"node\": {\n \"import\": \"./dist/node/node.js\",\n \"types\": \"./dist/node/node.d.ts\"\n },\n \"browser\": {\n \"import\": \"./dist/browser/browser.js\",\n \"types\": \"./dist/browser/browser.d.ts\"\n },\n \"default\": \"./dist/node/node.js\"\n }\n },\n \"private\": false,\n \"license\": \"MIT\",\n \"author\": \"AIQA\",\n \"description\": \"TypeScript/JavaScript SDK for interacting with the AIQA.\",\n \"keywords\": [\n \"aiqa\",\n \"sdk\"\n ],\n \"files\": [\n \"dist\"\n ],\n \"devDependencies\": {\n \"@commitlint/cli\": \"^20.4.4\",\n \"@commitlint/config-conventional\": \"^20.4.4\",\n \"@jest/globals\": \"^29.7.0\",\n \"@semantic-release/commit-analyzer\": \"^13.0.1\",\n \"@semantic-release/git\": \"^10.0.1\",\n \"@semantic-release/npm\": \"^12.0.2\",\n \"@semantic-release/release-notes-generator\": \"^14.1.0\",\n \"@types/node\": \"^22.0.0\",\n \"conventional-changelog-conventionalcommits\": \"^9.3.0\",\n \"esbuild\": \"^0.23.0\",\n \"husky\": \"^9.1.7\",\n \"jest\": \"^29.7.0\",\n \"lint-staged\": \"^16.4.0\",\n \"prettier\": \"^3.8.1\",\n \"semantic-release\": \"^24.2.9\",\n \"serve\": \"^14.2.3\",\n \"socket.io\": \"^4.7.5\",\n \"ts-jest\": \"^29.2.3\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^8.0.0\",\n \"tsx\": \"^4.0.0\",\n \"typescript\": \"^5.7.0\"\n },\n \"dependencies\": {\n \"socket.io-client\": \"^4.7.5\"\n }\n}\n"],"mappings":";AAAA,SAAS,UAAkB;;;ACqEpB,IAAK,UAAL,kBAAKA,aAAL;AACL,EAAAA,SAAA,kBAAe;AACf,EAAAA,SAAA,eAAY;AACZ,EAAAA,SAAA,qBAAkB;AAClB,EAAAA,SAAA,qBAAkB;AAClB,EAAAA,SAAA,oBAAiB;AACjB,EAAAA,SAAA,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