@absolutejs/voice 0.0.22-beta.20 → 0.0.22-beta.21
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/assistantHealth.d.ts +2 -0
- package/dist/index.js +20 -12
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export type VoiceAssistantHealthFailure = {
|
|
|
8
8
|
error?: string;
|
|
9
9
|
provider?: string;
|
|
10
10
|
rateLimited?: boolean;
|
|
11
|
+
replayHref?: string;
|
|
11
12
|
sessionId: string;
|
|
12
13
|
status?: string;
|
|
13
14
|
turnId?: string;
|
|
@@ -22,6 +23,7 @@ export type VoiceAssistantHealthSummaryOptions<TProvider extends string = string
|
|
|
22
23
|
events?: StoredVoiceTraceEvent[];
|
|
23
24
|
maxFailures?: number;
|
|
24
25
|
providers?: readonly TProvider[];
|
|
26
|
+
replayHref?: false | string | ((failure: Omit<VoiceAssistantHealthFailure, 'replayHref'>) => string);
|
|
25
27
|
store?: VoiceTraceEventStore;
|
|
26
28
|
};
|
|
27
29
|
export type VoiceAssistantHealthHTMLHandlerOptions<TProvider extends string = string> = VoiceAssistantHealthSummaryOptions<TProvider> & {
|
package/dist/index.js
CHANGED
|
@@ -6303,17 +6303,24 @@ var renderCountMap = (values) => {
|
|
|
6303
6303
|
].join("");
|
|
6304
6304
|
};
|
|
6305
6305
|
var getString2 = (value) => typeof value === "string" ? value : undefined;
|
|
6306
|
-
var getRecentFailures = (events, maxFailures) => events.filter((event) => event.type === "session.error" && (event.payload.providerStatus === "error" || typeof event.payload.error === "string") || event.type === "assistant.guardrail" && event.payload.action === "blocked").toReversed().slice(0, maxFailures).map((event) =>
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6306
|
+
var getRecentFailures = (events, maxFailures, replayHref) => events.filter((event) => event.type === "session.error" && (event.payload.providerStatus === "error" || typeof event.payload.error === "string") || event.type === "assistant.guardrail" && event.payload.action === "blocked").toReversed().slice(0, maxFailures).map((event) => {
|
|
6307
|
+
const failure = {
|
|
6308
|
+
at: event.at,
|
|
6309
|
+
assistantId: getString2(event.payload.assistantId),
|
|
6310
|
+
error: getString2(event.payload.error),
|
|
6311
|
+
provider: getString2(event.payload.provider),
|
|
6312
|
+
rateLimited: event.payload.rateLimited === true ? true : undefined,
|
|
6313
|
+
sessionId: event.sessionId,
|
|
6314
|
+
status: getString2(event.payload.providerStatus),
|
|
6315
|
+
turnId: event.turnId,
|
|
6316
|
+
type: event.type
|
|
6317
|
+
};
|
|
6318
|
+
const href = replayHref === false ? undefined : typeof replayHref === "function" ? replayHref(failure) : `${replayHref ?? "/api/voice-sessions"}/${encodeURIComponent(event.sessionId)}/replay/htmx`;
|
|
6319
|
+
return {
|
|
6320
|
+
...failure,
|
|
6321
|
+
replayHref: href
|
|
6322
|
+
};
|
|
6323
|
+
});
|
|
6317
6324
|
var summarizeVoiceAssistantHealth = async (options) => {
|
|
6318
6325
|
const events = options.events ?? await options.store?.list() ?? [];
|
|
6319
6326
|
return {
|
|
@@ -6322,7 +6329,7 @@ var summarizeVoiceAssistantHealth = async (options) => {
|
|
|
6322
6329
|
events,
|
|
6323
6330
|
providers: options.providers
|
|
6324
6331
|
}),
|
|
6325
|
-
recentFailures: getRecentFailures(events, options.maxFailures ?? 8)
|
|
6332
|
+
recentFailures: getRecentFailures(events, options.maxFailures ?? 8, options.replayHref)
|
|
6326
6333
|
};
|
|
6327
6334
|
};
|
|
6328
6335
|
var renderVoiceAssistantHealthHTML = (summary) => {
|
|
@@ -6356,6 +6363,7 @@ var renderVoiceAssistantHealthHTML = (summary) => {
|
|
|
6356
6363
|
`<span>${escapeHtml4(failure.status ?? (failure.rateLimited ? "rate-limited" : "error"))}</span>`,
|
|
6357
6364
|
failure.error ? `<p>${escapeHtml4(failure.error)}</p>` : "",
|
|
6358
6365
|
`<small>${escapeHtml4(failure.sessionId)}${failure.turnId ? ` / ${escapeHtml4(failure.turnId)}` : ""}</small>`,
|
|
6366
|
+
failure.replayHref ? `<p><a href="${escapeHtml4(failure.replayHref)}">Open replay</a></p>` : "",
|
|
6359
6367
|
"</article>"
|
|
6360
6368
|
].join("")),
|
|
6361
6369
|
"</div>"
|