@aiqa/sdk 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +1,50 @@
1
1
  import { Socket } from 'socket.io-client';
2
2
 
3
3
  /**
4
- * Rolled-up verdict over the *answers*: `critical_errors` if any critical fact
5
- * failed, otherwise `errors` if any fact failed, otherwise `no_errors`.
6
- * Questions that were never asked do not raise it, so a call where everything
7
- * was skipped and nothing was wrong reads `no_errors`.
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`.
8
7
  *
9
- * Distinct from the per-fact `VerificationStatus` — this one describes the
10
- * call, not an answer.
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.
11
12
  */
12
13
  type ApplicationVerificationStatus = "no_errors" | "errors" | "critical_errors";
13
- /** Verification tally for the application at the moment it was requested. */
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
+ */
14
19
  type ApplicationVerificationSummary = {
15
20
  status: ApplicationVerificationStatus;
16
21
  /** Facts whose answer did not match the expected one. */
17
22
  count_errors: number;
18
- /** Subset of `count_errors` whose question is marked critical. */
23
+ /** The facts in `count_errors` that you sent with `critical: true`. */
19
24
  count_critical_errors: number;
20
25
  /**
21
- * Facts on the application, full stop — verdict or not. Not a pass count and
22
- * not a count of what has been evaluated: `count_not_asked` and
23
- * `count_pending` are subsets of it, not separate buckets.
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.
24
29
  */
25
30
  count_total: number;
26
- /** Facts with a verdict of never-asked. Excludes the still-pending ones. */
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
+ */
27
35
  count_not_asked: number;
28
- /** Subset of `count_not_asked` whose question is marked critical. */
36
+ /** The facts in `count_not_asked` that you sent with `critical: true`. */
29
37
  count_critical_not_asked: number;
30
38
  /**
31
- * Facts still awaiting a verdict — added, but not resolved yet. During a live
32
- * call most facts sit here, and they drain into the other counters as the
33
- * call proceeds.
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.
34
41
  */
35
42
  count_pending: number;
36
- /** Facts the conduct review flagged; a matched fact can still be suspicious. */
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
+ */
37
48
  count_suspicious: number;
38
49
  };
39
50
  type Application = {
@@ -41,12 +52,14 @@ type Application = {
41
52
  client_name: string;
42
53
  client_phone_number: string;
43
54
  agent_id: string;
55
+ /** Comes back empty. Set an agent name with `updateConversation()`. */
44
56
  agent_first_name: string;
57
+ /** Comes back empty. Set an agent name with `updateConversation()`. */
45
58
  agent_last_name: string;
46
59
  /**
47
- * Absent only when the server predates this field, in which case
48
- * `getApplication()` served its cached authentication snapshot. Treat the
49
- * absence as "no live data", never as a zeroed summary.
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.
50
63
  */
51
64
  verification?: ApplicationVerificationSummary;
52
65
  };
@@ -84,7 +97,7 @@ type UpdateConversationInput = {
84
97
  advisorName?: string;
85
98
  agentGroups?: string[];
86
99
  };
87
- /** Echo of the patched subset — only the fields you sent come back. */
100
+ /** Only the fields you sent come back in `conversation`. */
88
101
  type UpdateConversationResult = {
89
102
  success: boolean;
90
103
  conversation: {
@@ -129,11 +142,10 @@ type ApplicationFactAnswerFormat = {
129
142
  type ApplicationFactInput = {
130
143
  id: string;
131
144
  /**
132
- * Stable identifier for the underlying question, shared across applications and
133
- * conversations. When provided it is used to look up (or create) the matching
134
- * question row in the database instead of `id`. Keep this consistent across
135
- * calls — accuracy improvements and remaps configured in the management
136
- * 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.
137
149
  */
138
150
  questionId?: string;
139
151
  question: string;
@@ -142,35 +154,41 @@ type ApplicationFactInput = {
142
154
  category_id?: string;
143
155
  category_name?: string;
144
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
+ */
145
161
  critical?: boolean;
146
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
+ */
147
172
  metadata?: Record<string, string>;
148
173
  };
149
174
  type QuestionStatus = "searching" | "asked" | "not_asked";
150
175
  /**
151
- * Per-fact verification state.
176
+ * Per-fact verification state. Handle any value you don't recognize as
177
+ * `processing`.
152
178
  *
153
- * Extended from the original three-state shape to carry progress signals
154
- * the backend already detects but previously could not express. Consumers
155
- * that switch on this value MUST treat unknown strings as "processing"
156
- * (default fall-through) so older SDK builds keep working after the
157
- * backend starts emitting the additive states.
158
- *
159
- * Semantics:
160
- * - `processing` generic, just queued or transcription not ready
161
- * - `awaiting_question` agent hasn't asked the question yet
162
- * - `awaiting_answer` question asked, customer hasn't answered yet
163
- * - `partial` partial evidence; backend still working on it
164
- * - `pending_confirmation_matched` backend has a matching answer but is
165
- * holding a settling window for mid-answer
166
- * clarifications (e.g. spellings, "I mean…");
167
- * resolves to `matched`/`unmatched`
168
- * - `pending_confirmation_unmatched` same as above but the held verdict is
169
- * `unmatched`; UI can show "we heard X but it
170
- * doesn't match, waiting to confirm" instead
171
- * of a hard red verdict
172
- * - `matched` terminal: answer matched expected
173
- * - `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
174
192
  */
175
193
  type VerificationStatus = "processing" | "awaiting_question" | "awaiting_answer" | "partial" | "pending_confirmation_matched" | "pending_confirmation_unmatched" | "matched" | "unmatched";
176
194
  type ApplicationFact = ApplicationFactInput & {
@@ -181,7 +199,7 @@ type ApplicationFact = ApplicationFactInput & {
181
199
  flagged: boolean;
182
200
  };
183
201
  interface AddFactResult {
184
- /** Conversation the fact was attached to. Useful for cross-fact correlation in agent UIs. */
202
+ /** Conversation the fact was attached to. */
185
203
  conversation_id?: string;
186
204
  /** Echo of the original question text from the fact input. */
187
205
  question?: string;
@@ -192,24 +210,19 @@ interface AddFactResult {
192
210
  is_valid_answer: boolean;
193
211
  question_asked?: boolean;
194
212
  /**
195
- * 0–1 (or 0–100 — scale matches the configured similarity method).
196
- * Similarity between the agent's utterance and the expected question.
197
- * 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.
198
215
  */
199
216
  question_match_score?: number;
200
217
  /**
201
- * 0–1 score derived from how well the customer's answer matched expected.
202
- * Derived from partial-match heuristics (numeric-prefix ratio,
203
- * matched-components ratio). Undefined when no partial signal exists,
204
- * or on older server versions.
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.
205
220
  */
206
221
  answer_match_score?: number;
207
222
  metadata?: Record<string, string>;
208
223
  /**
209
- * Top-level state at terminal resolution. Always one of `matched`
210
- * or `unmatched` because the `addFact()` Promise only
211
- * resolves on terminals. Optional for compatibility with older
212
- * server versions.
224
+ * The final state: `matched` or `unmatched` whenever it is present. Fall
225
+ * back to `is_valid_answer` when it is missing.
213
226
  */
214
227
  verification_status?: VerificationStatus;
215
228
  /**
@@ -221,18 +234,9 @@ interface AddFactResult {
221
234
  missing_components?: string[];
222
235
  }
223
236
  /**
224
- * Payload of the `FACT_VERIFIED` broadcast event.
225
- *
226
- * Fires on EVERY state transition the server produces —
227
- * non-terminal (`partial`, `awaiting_question`, `awaiting_answer`,
228
- * `pending_confirmation_matched`, `pending_confirmation_unmatched`,
229
- * `processing`) AND terminal (`matched`, `unmatched`).
230
- *
231
- * Subscribe with:
232
- * sdk.on("FACT_VERIFIED", (payload: FactVerifiedPayload) => {...});
233
- *
234
- * `addFact()`'s Promise resolves only on terminals; this event stream
235
- * 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.
236
240
  */
237
241
  interface FactVerifiedPayload {
238
242
  factId: string;
@@ -242,12 +246,7 @@ interface FactVerifiedPayload {
242
246
  answer_match_score?: number;
243
247
  matched_components?: string[];
244
248
  missing_components?: string[];
245
- /**
246
- * Inner data payload. Shape matches `AddFactResult` (minus the
247
- * top-level envelope fields) so consumers can reuse the same
248
- * rendering code for the terminal addFact() resolution and the
249
- * broadcast event.
250
- */
249
+ /** Inner payload, shaped like `AddFactResult`. */
251
250
  data?: AddFactResult;
252
251
  error?: string;
253
252
  }
@@ -255,38 +254,26 @@ type FlagFactResult = {
255
254
  success: boolean;
256
255
  };
257
256
  /**
258
- * Coarse dialog-act label classified server-side. Advisory only — do
259
- * not gate production behaviour on this value; it is a best-effort
260
- * categorical guess, paired with a separate `dialog_act_confidence`
261
- * band.
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`.
262
260
  */
263
261
  type DialogAct = "question" | "answer" | "acknowledgement" | "filler" | "other";
264
262
  /**
265
- * Categorical confidence band for `dialog_act` ONLY. Named distinctly
266
- * from the numeric STT `confidence` field on the same utterance — the
267
- * two are unrelated, so do not compare or conflate them.
263
+ * Confidence band for `dialog_act` only. Unrelated to the numeric
264
+ * `confidence` field on the same utterance — do not compare the two.
268
265
  */
269
266
  type DialogActConfidence = "high" | "medium" | "low";
270
267
  /**
271
- * Persisted utterance shape, sent over the wire by the
272
- * `TRANSCRIPTION_UPDATED` broadcast.
268
+ * An utterance from the `TRANSCRIPTION_UPDATED` event.
273
269
  *
274
- * The 7 classification fields are all optional because utterances
275
- * persisted by older server versions lack them.
276
- * Treat any missing or nullish value as "unknown" — NOT as a deliberate
277
- * negative signal. `is_ivr_filler_candidate === false` in particular
278
- * does NOT round-trip through `undefined`, so consumer logic that wants
279
- * "definitely not a filler" must check `=== false` after confirming the
280
- * field is present.
270
+ * A missing optional field means "unknown", not "no".
281
271
  */
282
272
  type Utterance = {
283
- /** UUIDv7 — chronologically sortable. Use `id` (NOT `order`) for sorting. */
273
+ /** Sort utterances by this: ids sort in chronological order. */
284
274
  id: string;
285
275
  call_id: number;
286
- /**
287
- * Reserved — currently always 0. Do not use for sorting; sort by `id`
288
- * (UUIDv7) instead.
289
- */
276
+ /** Always 0. Sort by `id`, not this. */
290
277
  order: number;
291
278
  is_agent: boolean | null;
292
279
  speaker: number;
@@ -302,10 +289,7 @@ type Utterance = {
302
289
  spoken_digits_normalized?: string | null;
303
290
  vendor?: string | null;
304
291
  };
305
- /**
306
- * Payload of the `TRANSCRIPTION_UPDATED` broadcast event. Mirrors
307
- * `TranscriptionUpdateResponseDto` on the gateway.
308
- */
292
+ /** Payload of the `TRANSCRIPTION_UPDATED` broadcast event. */
309
293
  type TranscriptionUpdate = {
310
294
  policyNumber: string;
311
295
  conversationId: string;
@@ -3398,7 +3398,7 @@ var compareVersions = (left, right) => {
3398
3398
  // package.json
3399
3399
  var package_default = {
3400
3400
  name: "@aiqa/sdk",
3401
- version: "2.1.0",
3401
+ version: "2.1.0-develop.5",
3402
3402
  main: "dist/node/node.js",
3403
3403
  module: "dist/node/node.js",
3404
3404
  types: "dist/node/node.d.ts",