@absolutejs/voice 0.0.22-beta.60 → 0.0.22-beta.61
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/client/index.d.ts +4 -0
- package/dist/client/index.js +192 -12
- package/dist/client/providerSimulationControls.d.ts +33 -0
- package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
- package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +341 -70
- package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
- package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
- package/dist/svelte/index.d.ts +1 -0
- package/dist/svelte/index.js +207 -20
- package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +374 -82
- package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
- package/package.json +1 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export { createVoiceOpsStatusViewModel, defineVoiceOpsStatusElement, getVoiceOps
|
|
|
10
10
|
export { createVoiceRoutingStatusStore, fetchVoiceRoutingStatus } from './routingStatus';
|
|
11
11
|
export { createVoiceRoutingStatusViewModel, defineVoiceRoutingStatusElement, getVoiceRoutingStatusCSS, mountVoiceRoutingStatus, renderVoiceRoutingStatusHTML } from './routingStatusWidget';
|
|
12
12
|
export { createVoiceProviderStatusStore, fetchVoiceProviderStatus } from './providerStatus';
|
|
13
|
+
export { createVoiceProviderSimulationControlsStore } from './providerSimulationControls';
|
|
14
|
+
export { bindVoiceProviderSimulationControls, createVoiceProviderSimulationControlsViewModel, defineVoiceProviderSimulationControlsElement, mountVoiceProviderSimulationControls, renderVoiceProviderSimulationControlsHTML } from './providerSimulationControlsWidget';
|
|
13
15
|
export { createVoiceProviderStatusViewModel, defineVoiceProviderStatusElement, getVoiceProviderStatusCSS, mountVoiceProviderStatus, renderVoiceProviderStatusHTML } from './providerStatusWidget';
|
|
14
16
|
export { createVoiceWorkflowStatusStore, fetchVoiceWorkflowStatus } from './workflowStatus';
|
|
15
17
|
export type { VoiceAppKitStatusClientOptions, VoiceAppKitStatusSnapshot } from './appKitStatus';
|
|
@@ -17,5 +19,7 @@ export type { VoiceOpsStatusSurfaceView, VoiceOpsStatusViewModel, VoiceOpsStatus
|
|
|
17
19
|
export type { VoiceRoutingStatusClientOptions, VoiceRoutingStatusSnapshot } from './routingStatus';
|
|
18
20
|
export type { VoiceRoutingStatusViewModel, VoiceRoutingStatusWidgetOptions } from './routingStatusWidget';
|
|
19
21
|
export type { VoiceProviderStatusClientOptions, VoiceProviderStatusSnapshot } from './providerStatus';
|
|
22
|
+
export type { VoiceProviderSimulationControlsOptions, VoiceProviderSimulationControlsSnapshot, VoiceProviderSimulationProvider } from './providerSimulationControls';
|
|
23
|
+
export type { VoiceProviderSimulationControlsViewModel } from './providerSimulationControlsWidget';
|
|
20
24
|
export type { VoiceProviderStatusCardView, VoiceProviderStatusViewModel, VoiceProviderStatusWidgetOptions } from './providerStatusWidget';
|
|
21
25
|
export type { VoiceWorkflowStatusClientOptions, VoiceWorkflowStatusSnapshot } from './workflowStatus';
|
package/dist/client/index.js
CHANGED
|
@@ -2073,10 +2073,184 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
|
|
|
2073
2073
|
}
|
|
2074
2074
|
};
|
|
2075
2075
|
};
|
|
2076
|
+
// src/client/providerSimulationControls.ts
|
|
2077
|
+
var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
|
|
2078
|
+
const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
|
|
2079
|
+
const body = await response.json().catch(() => null);
|
|
2080
|
+
if (!response.ok) {
|
|
2081
|
+
const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice provider simulation failed: HTTP ${response.status}`;
|
|
2082
|
+
throw new Error(message);
|
|
2083
|
+
}
|
|
2084
|
+
return body;
|
|
2085
|
+
};
|
|
2086
|
+
var createVoiceProviderSimulationControlsStore = (options) => {
|
|
2087
|
+
const listeners = new Set;
|
|
2088
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2089
|
+
const pathPrefix = options.pathPrefix ?? `/api/${options.kind ?? "stt"}-simulate`;
|
|
2090
|
+
let closed = false;
|
|
2091
|
+
let snapshot = {
|
|
2092
|
+
error: null,
|
|
2093
|
+
isRunning: false,
|
|
2094
|
+
lastResult: null,
|
|
2095
|
+
mode: null,
|
|
2096
|
+
provider: null
|
|
2097
|
+
};
|
|
2098
|
+
const emit = () => {
|
|
2099
|
+
for (const listener of listeners) {
|
|
2100
|
+
listener();
|
|
2101
|
+
}
|
|
2102
|
+
};
|
|
2103
|
+
const run = async (provider, mode) => {
|
|
2104
|
+
if (closed) {
|
|
2105
|
+
return snapshot.lastResult;
|
|
2106
|
+
}
|
|
2107
|
+
snapshot = {
|
|
2108
|
+
...snapshot,
|
|
2109
|
+
error: null,
|
|
2110
|
+
isRunning: true,
|
|
2111
|
+
mode,
|
|
2112
|
+
provider
|
|
2113
|
+
};
|
|
2114
|
+
emit();
|
|
2115
|
+
try {
|
|
2116
|
+
const result = await postSimulation(pathPrefix, mode, provider, fetchImpl);
|
|
2117
|
+
snapshot = {
|
|
2118
|
+
error: null,
|
|
2119
|
+
isRunning: false,
|
|
2120
|
+
lastResult: result,
|
|
2121
|
+
mode,
|
|
2122
|
+
provider,
|
|
2123
|
+
updatedAt: Date.now()
|
|
2124
|
+
};
|
|
2125
|
+
emit();
|
|
2126
|
+
return result;
|
|
2127
|
+
} catch (error) {
|
|
2128
|
+
snapshot = {
|
|
2129
|
+
...snapshot,
|
|
2130
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2131
|
+
isRunning: false
|
|
2132
|
+
};
|
|
2133
|
+
emit();
|
|
2134
|
+
throw error;
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
const close = () => {
|
|
2138
|
+
closed = true;
|
|
2139
|
+
listeners.clear();
|
|
2140
|
+
};
|
|
2141
|
+
return {
|
|
2142
|
+
close,
|
|
2143
|
+
getServerSnapshot: () => snapshot,
|
|
2144
|
+
getSnapshot: () => snapshot,
|
|
2145
|
+
run,
|
|
2146
|
+
subscribe: (listener) => {
|
|
2147
|
+
listeners.add(listener);
|
|
2148
|
+
return () => {
|
|
2149
|
+
listeners.delete(listener);
|
|
2150
|
+
};
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2153
|
+
};
|
|
2154
|
+
// src/client/providerSimulationControlsWidget.ts
|
|
2155
|
+
var escapeHtml3 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2156
|
+
var formatKind = (kind) => (kind ?? "stt").toUpperCase();
|
|
2157
|
+
var createVoiceProviderSimulationControlsViewModel = (snapshot, options) => {
|
|
2158
|
+
const configuredProviders = options.providers.filter((provider) => provider.configured !== false);
|
|
2159
|
+
const fallbackReady = !options.fallbackRequiredProvider || configuredProviders.some((entry) => entry.provider === options.fallbackRequiredProvider);
|
|
2160
|
+
const failureProviders = (options.failureProviders ? options.failureProviders.map((provider) => ({ provider })) : configuredProviders).filter((provider) => configuredProviders.some((entry) => entry.provider === provider.provider));
|
|
2161
|
+
return {
|
|
2162
|
+
canSimulateFailure: configuredProviders.length > 0 && fallbackReady,
|
|
2163
|
+
description: options.failureMessage ?? `Simulate ${formatKind(options.kind)} provider failure and recovery without changing credentials.`,
|
|
2164
|
+
error: snapshot.error,
|
|
2165
|
+
failureProviders,
|
|
2166
|
+
isRunning: snapshot.isRunning,
|
|
2167
|
+
label: snapshot.isRunning ? `Running ${snapshot.mode ?? "simulation"}` : snapshot.lastResult ? `${snapshot.lastResult.provider} ${snapshot.lastResult.mode} simulated` : configuredProviders.length ? `${configuredProviders.length} configured` : "No configured providers",
|
|
2168
|
+
providers: configuredProviders,
|
|
2169
|
+
resultText: snapshot.lastResult ? JSON.stringify(snapshot.lastResult, null, 2) : null,
|
|
2170
|
+
title: options.title ?? `${formatKind(options.kind)} Failure Simulation`
|
|
2171
|
+
};
|
|
2172
|
+
};
|
|
2173
|
+
var renderVoiceProviderSimulationControlsHTML = (snapshot, options) => {
|
|
2174
|
+
const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
|
|
2175
|
+
const failureButtons = model.failureProviders.map((provider) => `<button type="button" data-voice-provider-fail="${escapeHtml3(provider.provider)}"${!model.canSimulateFailure || snapshot.isRunning ? " disabled" : ""}>Simulate ${escapeHtml3(provider.provider)} ${escapeHtml3(formatKind(options.kind))} failure</button>`).join("");
|
|
2176
|
+
const recoveryButtons = model.providers.map((provider) => `<button type="button" data-voice-provider-recover="${escapeHtml3(provider.provider)}"${snapshot.isRunning ? " disabled" : ""}>Mark ${escapeHtml3(provider.provider)} recovered</button>`).join("");
|
|
2177
|
+
return `<section class="absolute-voice-provider-simulation absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}">
|
|
2178
|
+
<header class="absolute-voice-provider-simulation__header">
|
|
2179
|
+
<span class="absolute-voice-provider-simulation__eyebrow">${escapeHtml3(model.title)}</span>
|
|
2180
|
+
<strong class="absolute-voice-provider-simulation__label">${escapeHtml3(model.label)}</strong>
|
|
2181
|
+
</header>
|
|
2182
|
+
<p class="absolute-voice-provider-simulation__description">${escapeHtml3(model.description)}</p>
|
|
2183
|
+
${model.canSimulateFailure ? "" : `<p class="absolute-voice-provider-simulation__empty">${escapeHtml3(options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure.")}</p>`}
|
|
2184
|
+
<div class="absolute-voice-provider-simulation__actions">${failureButtons}${recoveryButtons}</div>
|
|
2185
|
+
${snapshot.error ? `<p class="absolute-voice-provider-simulation__error">${escapeHtml3(snapshot.error)}</p>` : ""}
|
|
2186
|
+
${model.resultText ? `<pre class="absolute-voice-provider-simulation__result">${escapeHtml3(model.resultText)}</pre>` : ""}
|
|
2187
|
+
</section>`;
|
|
2188
|
+
};
|
|
2189
|
+
var bindVoiceProviderSimulationControls = (element, store) => {
|
|
2190
|
+
const onClick = (event) => {
|
|
2191
|
+
const target = event.target;
|
|
2192
|
+
if (!(target instanceof HTMLElement)) {
|
|
2193
|
+
return;
|
|
2194
|
+
}
|
|
2195
|
+
const failProvider = target.getAttribute("data-voice-provider-fail");
|
|
2196
|
+
const recoverProvider = target.getAttribute("data-voice-provider-recover");
|
|
2197
|
+
if (failProvider) {
|
|
2198
|
+
store.run(failProvider, "failure").catch(() => {});
|
|
2199
|
+
}
|
|
2200
|
+
if (recoverProvider) {
|
|
2201
|
+
store.run(recoverProvider, "recovery").catch(() => {});
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2204
|
+
element.addEventListener("click", onClick);
|
|
2205
|
+
return () => element.removeEventListener("click", onClick);
|
|
2206
|
+
};
|
|
2207
|
+
var mountVoiceProviderSimulationControls = (element, options) => {
|
|
2208
|
+
const store = createVoiceProviderSimulationControlsStore(options);
|
|
2209
|
+
const render = () => {
|
|
2210
|
+
element.innerHTML = renderVoiceProviderSimulationControlsHTML(store.getSnapshot(), options);
|
|
2211
|
+
};
|
|
2212
|
+
const unsubscribeStore = store.subscribe(render);
|
|
2213
|
+
const unsubscribeDom = bindVoiceProviderSimulationControls(element, store);
|
|
2214
|
+
render();
|
|
2215
|
+
return {
|
|
2216
|
+
close: () => {
|
|
2217
|
+
unsubscribeDom();
|
|
2218
|
+
unsubscribeStore();
|
|
2219
|
+
store.close();
|
|
2220
|
+
},
|
|
2221
|
+
run: store.run
|
|
2222
|
+
};
|
|
2223
|
+
};
|
|
2224
|
+
var defineVoiceProviderSimulationControlsElement = (tagName = "absolute-voice-provider-simulation") => {
|
|
2225
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
customElements.define(tagName, class AbsoluteVoiceProviderSimulationElement extends HTMLElement {
|
|
2229
|
+
mounted;
|
|
2230
|
+
connectedCallback() {
|
|
2231
|
+
const providers = (this.getAttribute("providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean).map((provider) => ({ provider }));
|
|
2232
|
+
const failureProviders = (this.getAttribute("failure-providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean);
|
|
2233
|
+
this.mounted = mountVoiceProviderSimulationControls(this, {
|
|
2234
|
+
failureProviders: failureProviders.length ? failureProviders : undefined,
|
|
2235
|
+
fallbackRequiredMessage: this.getAttribute("fallback-required-message") ?? undefined,
|
|
2236
|
+
fallbackRequiredProvider: this.getAttribute("fallback-required-provider") ?? undefined,
|
|
2237
|
+
failureMessage: this.getAttribute("failure-message") ?? undefined,
|
|
2238
|
+
kind: this.getAttribute("kind") ?? "stt",
|
|
2239
|
+
pathPrefix: this.getAttribute("path-prefix") ?? undefined,
|
|
2240
|
+
providers,
|
|
2241
|
+
title: this.getAttribute("title") ?? undefined
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
disconnectedCallback() {
|
|
2245
|
+
this.mounted?.close();
|
|
2246
|
+
this.mounted = undefined;
|
|
2247
|
+
}
|
|
2248
|
+
});
|
|
2249
|
+
};
|
|
2076
2250
|
// src/client/providerStatusWidget.ts
|
|
2077
2251
|
var DEFAULT_TITLE3 = "Voice Providers";
|
|
2078
2252
|
var DEFAULT_DESCRIPTION3 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
|
|
2079
|
-
var
|
|
2253
|
+
var escapeHtml4 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2080
2254
|
var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
2081
2255
|
var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
2082
2256
|
var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
|
|
@@ -2132,25 +2306,25 @@ var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
|
|
|
2132
2306
|
};
|
|
2133
2307
|
var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
|
|
2134
2308
|
const model = createVoiceProviderStatusViewModel(snapshot, options);
|
|
2135
|
-
const providers = model.providers.length ? `<div class="absolute-voice-provider-status__providers">${model.providers.map((provider) => `<article class="absolute-voice-provider-status__provider absolute-voice-provider-status__provider--${
|
|
2309
|
+
const providers = model.providers.length ? `<div class="absolute-voice-provider-status__providers">${model.providers.map((provider) => `<article class="absolute-voice-provider-status__provider absolute-voice-provider-status__provider--${escapeHtml4(provider.status)}">
|
|
2136
2310
|
<header>
|
|
2137
|
-
<strong>${
|
|
2138
|
-
<span>${
|
|
2311
|
+
<strong>${escapeHtml4(provider.label)}</strong>
|
|
2312
|
+
<span>${escapeHtml4(formatStatus(provider.status))}</span>
|
|
2139
2313
|
</header>
|
|
2140
|
-
<p>${
|
|
2314
|
+
<p>${escapeHtml4(provider.detail)}</p>
|
|
2141
2315
|
<dl>${provider.rows.map((row) => `<div>
|
|
2142
|
-
<dt>${
|
|
2143
|
-
<dd>${
|
|
2316
|
+
<dt>${escapeHtml4(row.label)}</dt>
|
|
2317
|
+
<dd>${escapeHtml4(row.value)}</dd>
|
|
2144
2318
|
</div>`).join("")}</dl>
|
|
2145
2319
|
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
|
|
2146
|
-
return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${
|
|
2320
|
+
return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml4(model.status)}">
|
|
2147
2321
|
<header class="absolute-voice-provider-status__header">
|
|
2148
|
-
<span class="absolute-voice-provider-status__eyebrow">${
|
|
2149
|
-
<strong class="absolute-voice-provider-status__label">${
|
|
2322
|
+
<span class="absolute-voice-provider-status__eyebrow">${escapeHtml4(model.title)}</span>
|
|
2323
|
+
<strong class="absolute-voice-provider-status__label">${escapeHtml4(model.label)}</strong>
|
|
2150
2324
|
</header>
|
|
2151
|
-
<p class="absolute-voice-provider-status__description">${
|
|
2325
|
+
<p class="absolute-voice-provider-status__description">${escapeHtml4(model.description)}</p>
|
|
2152
2326
|
${providers}
|
|
2153
|
-
${model.error ? `<p class="absolute-voice-provider-status__error">${
|
|
2327
|
+
${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml4(model.error)}</p>` : ""}
|
|
2154
2328
|
</section>`;
|
|
2155
2329
|
};
|
|
2156
2330
|
var getVoiceProviderStatusCSS = () => `.absolute-voice-provider-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-provider-status--error,.absolute-voice-provider-status--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-provider-status__header,.absolute-voice-provider-status__provider header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-status__label{font-size:24px;line-height:1}.absolute-voice-provider-status__description,.absolute-voice-provider-status__provider p,.absolute-voice-provider-status__provider dt,.absolute-voice-provider-status__empty{color:#514733}.absolute-voice-provider-status__providers{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-status__provider{background:#fff;border:1px solid #eee4d2;border-radius:16px;padding:14px}.absolute-voice-provider-status__provider--degraded,.absolute-voice-provider-status__provider--rate-limited,.absolute-voice-provider-status__provider--suppressed{border-color:#f2a7a7}.absolute-voice-provider-status__provider--recoverable{border-color:#fbbf24}.absolute-voice-provider-status__provider p{margin:10px 0}.absolute-voice-provider-status__provider dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-status__provider div{background:#fffaf0;border:1px solid #eee4d2;border-radius:12px;padding:8px}.absolute-voice-provider-status__provider dt{font-size:12px}.absolute-voice-provider-status__provider dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-status__empty{margin:14px 0 0}.absolute-voice-provider-status__error{color:#9f1239;font-weight:700}`;
|
|
@@ -2271,9 +2445,11 @@ var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options =
|
|
|
2271
2445
|
export {
|
|
2272
2446
|
renderVoiceRoutingStatusHTML,
|
|
2273
2447
|
renderVoiceProviderStatusHTML,
|
|
2448
|
+
renderVoiceProviderSimulationControlsHTML,
|
|
2274
2449
|
renderVoiceOpsStatusHTML,
|
|
2275
2450
|
mountVoiceRoutingStatus,
|
|
2276
2451
|
mountVoiceProviderStatus,
|
|
2452
|
+
mountVoiceProviderSimulationControls,
|
|
2277
2453
|
mountVoiceOpsStatus,
|
|
2278
2454
|
getVoiceRoutingStatusCSS,
|
|
2279
2455
|
getVoiceProviderStatusCSS,
|
|
@@ -2285,6 +2461,7 @@ export {
|
|
|
2285
2461
|
fetchVoiceAppKitStatus,
|
|
2286
2462
|
defineVoiceRoutingStatusElement,
|
|
2287
2463
|
defineVoiceProviderStatusElement,
|
|
2464
|
+
defineVoiceProviderSimulationControlsElement,
|
|
2288
2465
|
defineVoiceOpsStatusElement,
|
|
2289
2466
|
decodeVoiceAudioChunk,
|
|
2290
2467
|
createVoiceWorkflowStatusStore,
|
|
@@ -2293,6 +2470,8 @@ export {
|
|
|
2293
2470
|
createVoiceRoutingStatusStore,
|
|
2294
2471
|
createVoiceProviderStatusViewModel,
|
|
2295
2472
|
createVoiceProviderStatusStore,
|
|
2473
|
+
createVoiceProviderSimulationControlsViewModel,
|
|
2474
|
+
createVoiceProviderSimulationControlsStore,
|
|
2296
2475
|
createVoiceOpsStatusViewModel,
|
|
2297
2476
|
createVoiceDuplexController,
|
|
2298
2477
|
createVoiceController,
|
|
@@ -2300,6 +2479,7 @@ export {
|
|
|
2300
2479
|
createVoiceAudioPlayer,
|
|
2301
2480
|
createVoiceAppKitStatusStore,
|
|
2302
2481
|
createMicrophoneCapture,
|
|
2482
|
+
bindVoiceProviderSimulationControls,
|
|
2303
2483
|
bindVoiceHTMX,
|
|
2304
2484
|
bindVoiceBargeIn
|
|
2305
2485
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { VoiceIOProviderFailureSimulationMode, VoiceIOProviderFailureSimulationResult } from '../testing/ioProviderSimulator';
|
|
2
|
+
export type VoiceProviderSimulationProvider<TProvider extends string = string> = {
|
|
3
|
+
configured?: boolean;
|
|
4
|
+
provider: TProvider;
|
|
5
|
+
};
|
|
6
|
+
export type VoiceProviderSimulationControlsOptions<TProvider extends string = string> = {
|
|
7
|
+
fallbackRequiredMessage?: string;
|
|
8
|
+
fallbackRequiredProvider?: TProvider;
|
|
9
|
+
failureMessage?: string;
|
|
10
|
+
failureProviders?: readonly TProvider[];
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
intervalMs?: number;
|
|
13
|
+
kind?: 'stt' | 'tts' | string;
|
|
14
|
+
pathPrefix?: string;
|
|
15
|
+
providers: readonly VoiceProviderSimulationProvider<TProvider>[];
|
|
16
|
+
recoveryMessage?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
};
|
|
19
|
+
export type VoiceProviderSimulationControlsSnapshot<TProvider extends string = string> = {
|
|
20
|
+
error: string | null;
|
|
21
|
+
isRunning: boolean;
|
|
22
|
+
lastResult: VoiceIOProviderFailureSimulationResult<TProvider> | null;
|
|
23
|
+
mode: VoiceIOProviderFailureSimulationMode | null;
|
|
24
|
+
provider: TProvider | null;
|
|
25
|
+
updatedAt?: number;
|
|
26
|
+
};
|
|
27
|
+
export declare const createVoiceProviderSimulationControlsStore: <TProvider extends string = string>(options: VoiceProviderSimulationControlsOptions<TProvider>) => {
|
|
28
|
+
close: () => void;
|
|
29
|
+
getServerSnapshot: () => VoiceProviderSimulationControlsSnapshot<TProvider>;
|
|
30
|
+
getSnapshot: () => VoiceProviderSimulationControlsSnapshot<TProvider>;
|
|
31
|
+
run: (provider: TProvider, mode: VoiceIOProviderFailureSimulationMode) => Promise<VoiceIOProviderFailureSimulationResult<TProvider> | null>;
|
|
32
|
+
subscribe: (listener: () => void) => () => void;
|
|
33
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createVoiceProviderSimulationControlsStore, type VoiceProviderSimulationControlsOptions, type VoiceProviderSimulationControlsSnapshot, type VoiceProviderSimulationProvider } from './providerSimulationControls';
|
|
2
|
+
export type VoiceProviderSimulationControlsViewModel<TProvider extends string = string> = {
|
|
3
|
+
canSimulateFailure: boolean;
|
|
4
|
+
description: string;
|
|
5
|
+
error: string | null;
|
|
6
|
+
failureProviders: VoiceProviderSimulationProvider<TProvider>[];
|
|
7
|
+
isRunning: boolean;
|
|
8
|
+
label: string;
|
|
9
|
+
providers: VoiceProviderSimulationProvider<TProvider>[];
|
|
10
|
+
resultText: string | null;
|
|
11
|
+
title: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const createVoiceProviderSimulationControlsViewModel: <TProvider extends string = string>(snapshot: VoiceProviderSimulationControlsSnapshot<TProvider>, options: VoiceProviderSimulationControlsOptions<TProvider>) => VoiceProviderSimulationControlsViewModel<TProvider>;
|
|
14
|
+
export declare const renderVoiceProviderSimulationControlsHTML: <TProvider extends string = string>(snapshot: VoiceProviderSimulationControlsSnapshot<TProvider>, options: VoiceProviderSimulationControlsOptions<TProvider>) => string;
|
|
15
|
+
export declare const bindVoiceProviderSimulationControls: <TProvider extends string = string>(element: Element, store: ReturnType<typeof createVoiceProviderSimulationControlsStore<TProvider>>) => () => void;
|
|
16
|
+
export declare const mountVoiceProviderSimulationControls: <TProvider extends string = string>(element: Element, options: VoiceProviderSimulationControlsOptions<TProvider>) => {
|
|
17
|
+
close: () => void;
|
|
18
|
+
run: (provider: TProvider, mode: import("../testing").VoiceIOProviderFailureSimulationMode) => Promise<import("../testing").VoiceIOProviderFailureSimulationResult<TProvider> | null>;
|
|
19
|
+
};
|
|
20
|
+
export declare const defineVoiceProviderSimulationControlsElement: (tagName?: string) => void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { VoiceProviderSimulationControlsOptions } from '../client/providerSimulationControls';
|
|
2
|
+
export type VoiceProviderSimulationControlsProps<TProvider extends string = string> = VoiceProviderSimulationControlsOptions<TProvider> & {
|
|
3
|
+
className?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const VoiceProviderSimulationControls: <TProvider extends string = string>({ className, ...options }: VoiceProviderSimulationControlsProps<TProvider>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { VoiceOpsStatus } from './VoiceOpsStatus';
|
|
2
|
+
export { VoiceProviderSimulationControls } from './VoiceProviderSimulationControls';
|
|
2
3
|
export { VoiceProviderStatus } from './VoiceProviderStatus';
|
|
3
4
|
export { VoiceRoutingStatus } from './VoiceRoutingStatus';
|
|
4
5
|
export { useVoiceAppKitStatus } from './useVoiceAppKitStatus';
|
|
5
6
|
export { useVoiceStream } from './useVoiceStream';
|
|
6
7
|
export { useVoiceController } from './useVoiceController';
|
|
7
8
|
export { useVoiceProviderStatus } from './useVoiceProviderStatus';
|
|
9
|
+
export { useVoiceProviderSimulationControls } from './useVoiceProviderSimulationControls';
|
|
8
10
|
export { useVoiceRoutingStatus } from './useVoiceRoutingStatus';
|
|
9
11
|
export { useVoiceWorkflowStatus } from './useVoiceWorkflowStatus';
|