@aiqa/sdk 1.4.0-develop.1 → 1.4.0-develop.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/browser.d.ts +79 -3
- package/dist/browser/browser.js +19 -3
- package/dist/browser/browser.js.map +1 -1
- package/dist/node/node.d.ts +79 -3
- package/dist/node/node.js +19 -3
- package/dist/node/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ declare enum ConversationLanguage {
|
|
|
32
32
|
ES = "es",
|
|
33
33
|
FR = "fr"
|
|
34
34
|
}
|
|
35
|
-
type SdkEvent = Methods | "connect" | "disconnect" | "close" | "error" | "reconnect_attempt" | "reconnect_error" | "reconnect_failed" | "authenticated" | "app_version";
|
|
35
|
+
type SdkEvent = Methods | "connect" | "disconnect" | "close" | "error" | "reconnect_attempt" | "reconnect_error" | "reconnect_failed" | "authenticated" | "app_version" | "fact_verified";
|
|
36
36
|
declare enum FactAnswerFormatType {
|
|
37
37
|
string = "STRING",
|
|
38
38
|
number = "NUMBER",
|
|
@@ -73,7 +73,25 @@ type ApplicationFactInput = {
|
|
|
73
73
|
metadata?: Record<string, string>;
|
|
74
74
|
};
|
|
75
75
|
type QuestionStatus = "searching" | "asked" | "not_asked";
|
|
76
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Per-fact verification state.
|
|
78
|
+
*
|
|
79
|
+
* Extended from the original three-state shape to carry progress signals
|
|
80
|
+
* the backend already detects but previously could not express. Consumers
|
|
81
|
+
* that switch on this value MUST treat unknown strings as "processing"
|
|
82
|
+
* (default fall-through) so older SDK builds keep working after the
|
|
83
|
+
* backend starts emitting the additive states.
|
|
84
|
+
*
|
|
85
|
+
* Semantics:
|
|
86
|
+
* - `processing` generic, just queued or transcription not ready
|
|
87
|
+
* - `awaiting_question` agent hasn't asked the question yet
|
|
88
|
+
* - `awaiting_answer` question asked, customer hasn't answered yet
|
|
89
|
+
* - `partial` partial evidence; backend still working on it
|
|
90
|
+
* - `matched` terminal: answer matched expected
|
|
91
|
+
* - `unmatched` terminal: budget exhausted with no match
|
|
92
|
+
* - `contradicted` terminal (future): customer contradicted expected
|
|
93
|
+
*/
|
|
94
|
+
type VerificationStatus = "processing" | "awaiting_question" | "awaiting_answer" | "partial" | "matched" | "unmatched" | "contradicted";
|
|
77
95
|
type ApplicationFact = ApplicationFactInput & {
|
|
78
96
|
ai_answer?: any;
|
|
79
97
|
question_status: QuestionStatus;
|
|
@@ -84,7 +102,65 @@ interface AddFactResult {
|
|
|
84
102
|
ai_answer?: string;
|
|
85
103
|
is_valid_answer: boolean;
|
|
86
104
|
question_asked?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* 0–1 (or 0–100 — scale matches the configured similarity method).
|
|
107
|
+
* Similarity between the agent's utterance and the expected question.
|
|
108
|
+
* Renamed from `match_score` to disambiguate from the answer-side score.
|
|
109
|
+
*/
|
|
110
|
+
question_match_score?: number;
|
|
111
|
+
/**
|
|
112
|
+
* 0–1 score derived from how well the customer's answer matched expected.
|
|
113
|
+
* Populated by the verification queue from partial-match heuristics
|
|
114
|
+
* (numeric-prefix ratio, matched-components ratio). Undefined when no
|
|
115
|
+
* partial signal exists or for terminal results before this rolls out.
|
|
116
|
+
*/
|
|
117
|
+
answer_match_score?: number;
|
|
87
118
|
metadata?: Record<string, string>;
|
|
119
|
+
/**
|
|
120
|
+
* Top-level state at terminal resolution. Always one of `matched`,
|
|
121
|
+
* `unmatched`, or `contradicted` because the `addFact()` Promise only
|
|
122
|
+
* resolves on terminals. Optional during the rollout window for
|
|
123
|
+
* backwards compatibility with older backends.
|
|
124
|
+
*/
|
|
125
|
+
verification_status?: VerificationStatus;
|
|
126
|
+
/**
|
|
127
|
+
* Per-fact partial-match breakdown carried through from the
|
|
128
|
+
* verification queue's component-wise comparators. For numeric-prefix
|
|
129
|
+
* facts these are `["prefix"]` / `["suffix"]`; future work will
|
|
130
|
+
* generalise to addresses, names, dates, etc.
|
|
131
|
+
*/
|
|
132
|
+
matched_components?: string[];
|
|
133
|
+
missing_components?: string[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Payload of the `fact_verified` broadcast event.
|
|
137
|
+
*
|
|
138
|
+
* Fires on EVERY state transition the verification queue produces —
|
|
139
|
+
* partial (`partial`, `awaiting_question`, `awaiting_answer`,
|
|
140
|
+
* `processing`) AND terminal (`matched`, `unmatched`, `contradicted`).
|
|
141
|
+
*
|
|
142
|
+
* Subscribe with:
|
|
143
|
+
* sdk.on("fact_verified", (payload: FactVerifiedPayload) => {...});
|
|
144
|
+
*
|
|
145
|
+
* `addFact()`'s Promise resolves only on terminals; this event stream
|
|
146
|
+
* is the channel for rendering live progress in the agent UI.
|
|
147
|
+
*/
|
|
148
|
+
interface FactVerifiedPayload {
|
|
149
|
+
factId: string;
|
|
150
|
+
success: boolean;
|
|
151
|
+
verification_status?: VerificationStatus;
|
|
152
|
+
question_match_score?: number;
|
|
153
|
+
answer_match_score?: number;
|
|
154
|
+
matched_components?: string[];
|
|
155
|
+
missing_components?: string[];
|
|
156
|
+
/**
|
|
157
|
+
* Inner data payload. Shape matches `AddFactResult` (minus the
|
|
158
|
+
* top-level envelope fields) so consumers can reuse the same
|
|
159
|
+
* rendering code for the terminal addFact() resolution and the
|
|
160
|
+
* broadcast event.
|
|
161
|
+
*/
|
|
162
|
+
data?: AddFactResult;
|
|
163
|
+
error?: string;
|
|
88
164
|
}
|
|
89
165
|
type FlagFactResult = {
|
|
90
166
|
success: boolean;
|
|
@@ -136,4 +212,4 @@ declare class AiQaSdk implements IAiqaSdk {
|
|
|
136
212
|
private isManagerEvent;
|
|
137
213
|
}
|
|
138
214
|
|
|
139
|
-
export { type AddFactResult, AiQaSdk, type Application, type ApplicationFact, type ApplicationFactAnswerChoice, type ApplicationFactAnswerFormat, type ApplicationFactInput, ConversationLanguage, FactAnswerFormatType, type FlagFactResult, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type VerificationStatus };
|
|
215
|
+
export { type AddFactResult, AiQaSdk, type Application, type ApplicationFact, type ApplicationFactAnswerChoice, type ApplicationFactAnswerFormat, type ApplicationFactInput, ConversationLanguage, FactAnswerFormatType, type FactVerifiedPayload, type FlagFactResult, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type VerificationStatus };
|
package/dist/browser/browser.js
CHANGED
|
@@ -3396,7 +3396,7 @@ var compareVersions = (left, right) => {
|
|
|
3396
3396
|
// package.json
|
|
3397
3397
|
var package_default = {
|
|
3398
3398
|
name: "@aiqa/sdk",
|
|
3399
|
-
version: "1.
|
|
3399
|
+
version: "1.4.0-develop.1",
|
|
3400
3400
|
main: "dist/node/node.js",
|
|
3401
3401
|
module: "dist/node/node.js",
|
|
3402
3402
|
types: "dist/node/node.d.ts",
|
|
@@ -3599,7 +3599,7 @@ var AiQaSdk = class {
|
|
|
3599
3599
|
reject(parsed.error);
|
|
3600
3600
|
return;
|
|
3601
3601
|
}
|
|
3602
|
-
resolve(parsed
|
|
3602
|
+
resolve(parsed);
|
|
3603
3603
|
};
|
|
3604
3604
|
this.socket.on(requestId, handler);
|
|
3605
3605
|
const payload = data && typeof data === "object" ? { ...data, requestId } : { requestId, data };
|
|
@@ -3629,7 +3629,23 @@ var AiQaSdk = class {
|
|
|
3629
3629
|
is_skipped: fact.is_skipped ?? false
|
|
3630
3630
|
};
|
|
3631
3631
|
const result = await this.sendMessage("ADD_FACT" /* ADD_FACT */, payload);
|
|
3632
|
-
|
|
3632
|
+
if (!result) return result;
|
|
3633
|
+
const inner = result.data !== void 0 ? result.data : result;
|
|
3634
|
+
const hasEnvelope = result.verification_status !== void 0 || result.matched_components !== void 0 || result.missing_components !== void 0;
|
|
3635
|
+
if (!hasEnvelope || typeof inner !== "object" || inner === null) {
|
|
3636
|
+
return inner;
|
|
3637
|
+
}
|
|
3638
|
+
const merged = { ...inner };
|
|
3639
|
+
if (result.verification_status !== void 0) {
|
|
3640
|
+
merged.verification_status = result.verification_status;
|
|
3641
|
+
}
|
|
3642
|
+
if (result.matched_components !== void 0) {
|
|
3643
|
+
merged.matched_components = result.matched_components;
|
|
3644
|
+
}
|
|
3645
|
+
if (result.missing_components !== void 0) {
|
|
3646
|
+
merged.missing_components = result.missing_components;
|
|
3647
|
+
}
|
|
3648
|
+
return merged;
|
|
3633
3649
|
}
|
|
3634
3650
|
async flagFact(factId) {
|
|
3635
3651
|
const result = await this.sendMessage("FLAG_FACT" /* FLAG_FACT */, {
|