@absolutejs/voice 0.0.22-beta.20 → 0.0.22-beta.22
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.
|
@@ -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>"
|
package/dist/testing/index.js
CHANGED
|
@@ -4377,8 +4377,15 @@ var createVoiceProviderFailureSimulator = (options) => {
|
|
|
4377
4377
|
return {
|
|
4378
4378
|
mode,
|
|
4379
4379
|
provider,
|
|
4380
|
+
replayHref: options.replayHref === false ? undefined : typeof options.replayHref === "function" ? options.replayHref({
|
|
4381
|
+
provider,
|
|
4382
|
+
sessionId: session.id,
|
|
4383
|
+
turnId: turn.id
|
|
4384
|
+
}) : `${options.replayHref ?? "/api/voice-sessions"}/${encodeURIComponent(session.id)}/replay/htmx`,
|
|
4380
4385
|
result,
|
|
4381
|
-
|
|
4386
|
+
sessionId: session.id,
|
|
4387
|
+
status: "simulated",
|
|
4388
|
+
turnId: turn.id
|
|
4382
4389
|
};
|
|
4383
4390
|
};
|
|
4384
4391
|
return {
|
|
@@ -12,8 +12,11 @@ export type VoiceProviderFailureSimulationContext<TProvider extends string = str
|
|
|
12
12
|
export type VoiceProviderFailureSimulationResult<TProvider extends string = string, TResult = unknown> = {
|
|
13
13
|
mode: VoiceProviderFailureSimulationMode;
|
|
14
14
|
provider: TProvider;
|
|
15
|
+
replayHref?: string;
|
|
15
16
|
result: VoiceAgentModelOutput<TResult>;
|
|
17
|
+
sessionId: string;
|
|
16
18
|
status: 'simulated';
|
|
19
|
+
turnId: string;
|
|
17
20
|
};
|
|
18
21
|
type ProviderListResolver<TContext, TSession extends VoiceSessionRecord, TProvider extends string> = readonly TProvider[] | ((input: VoiceAgentModelInput<TContext, TSession>) => readonly TProvider[] | Promise<readonly TProvider[]>);
|
|
19
22
|
export type VoiceProviderFailureSimulatorOptions<TContext extends VoiceProviderFailureSimulationContext<TProvider>, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown, TProvider extends string = string> = {
|
|
@@ -25,6 +28,11 @@ export type VoiceProviderFailureSimulatorOptions<TContext extends VoiceProviderF
|
|
|
25
28
|
providerHealth?: boolean | VoiceProviderRouterHealthOptions;
|
|
26
29
|
providerLabel?: (provider: TProvider) => string;
|
|
27
30
|
providers: readonly TProvider[];
|
|
31
|
+
replayHref?: false | string | ((input: {
|
|
32
|
+
provider: TProvider;
|
|
33
|
+
sessionId: string;
|
|
34
|
+
turnId: string;
|
|
35
|
+
}) => string);
|
|
28
36
|
response?: (input: {
|
|
29
37
|
mode: VoiceProviderFailureSimulationMode;
|
|
30
38
|
provider: TProvider;
|