@absolutejs/voice 0.0.22-beta.290 → 0.0.22-beta.292

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.
@@ -0,0 +1,8 @@
1
+ import { type VoiceReadinessFailuresClientOptions } from '../client/readinessFailures';
2
+ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceReadinessFailuresClientOptions) => {
3
+ refresh: () => Promise<import("..").VoiceProductionReadinessReport | undefined>;
4
+ error: string | null;
5
+ isLoading: boolean;
6
+ report?: import("..").VoiceProductionReadinessReport;
7
+ updatedAt?: number;
8
+ };
@@ -0,0 +1,7 @@
1
+ import type { VoiceReadinessFailuresClientOptions } from '../client/readinessFailures';
2
+ export declare const createVoiceReadinessFailures: (path?: string, options?: VoiceReadinessFailuresClientOptions) => {
3
+ close: () => void;
4
+ getSnapshot: () => import("../client").VoiceReadinessFailuresSnapshot;
5
+ refresh: () => Promise<import("..").VoiceProductionReadinessReport | undefined>;
6
+ subscribe: (listener: () => void) => () => void;
7
+ };
@@ -5,6 +5,7 @@ export { createVoiceLiveOps } from './createVoiceLiveOps';
5
5
  export { createVoiceOpsStatus } from './createVoiceOpsStatus';
6
6
  export { createVoicePlatformCoverage } from './createVoicePlatformCoverage';
7
7
  export { createVoiceProofTrends } from './createVoiceProofTrends';
8
+ export { createVoiceReadinessFailures } from './createVoiceReadinessFailures';
8
9
  export { createVoiceProviderSimulationControls } from './createVoiceProviderSimulationControls';
9
10
  export { createVoiceProviderCapabilities } from './createVoiceProviderCapabilities';
10
11
  export { createVoiceProviderContracts } from './createVoiceProviderContracts';
@@ -2588,6 +2588,91 @@ var createVoiceProofTrends = (path = "/api/voice/proof-trends", options = {}) =>
2588
2588
  subscribe: store.subscribe
2589
2589
  };
2590
2590
  };
2591
+ // src/client/readinessFailures.ts
2592
+ var fetchVoiceReadinessFailures = async (path = "/api/production-readiness", options = {}) => {
2593
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2594
+ const response = await fetchImpl(path);
2595
+ if (!response.ok) {
2596
+ throw new Error(`Voice readiness failed: HTTP ${response.status}`);
2597
+ }
2598
+ return await response.json();
2599
+ };
2600
+ var createVoiceReadinessFailuresStore = (path = "/api/production-readiness", options = {}) => {
2601
+ const listeners = new Set;
2602
+ let closed = false;
2603
+ let timer;
2604
+ let snapshot = {
2605
+ error: null,
2606
+ isLoading: false
2607
+ };
2608
+ const emit = () => {
2609
+ for (const listener of listeners) {
2610
+ listener();
2611
+ }
2612
+ };
2613
+ const refresh = async () => {
2614
+ if (closed) {
2615
+ return snapshot.report;
2616
+ }
2617
+ snapshot = { ...snapshot, error: null, isLoading: true };
2618
+ emit();
2619
+ try {
2620
+ const report = await fetchVoiceReadinessFailures(path, options);
2621
+ snapshot = {
2622
+ error: null,
2623
+ isLoading: false,
2624
+ report,
2625
+ updatedAt: Date.now()
2626
+ };
2627
+ emit();
2628
+ return report;
2629
+ } catch (error) {
2630
+ snapshot = {
2631
+ ...snapshot,
2632
+ error: error instanceof Error ? error.message : String(error),
2633
+ isLoading: false
2634
+ };
2635
+ emit();
2636
+ throw error;
2637
+ }
2638
+ };
2639
+ const close = () => {
2640
+ closed = true;
2641
+ if (timer) {
2642
+ clearInterval(timer);
2643
+ timer = undefined;
2644
+ }
2645
+ listeners.clear();
2646
+ };
2647
+ if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
2648
+ timer = setInterval(() => {
2649
+ refresh().catch(() => {});
2650
+ }, options.intervalMs);
2651
+ }
2652
+ return {
2653
+ close,
2654
+ getServerSnapshot: () => snapshot,
2655
+ getSnapshot: () => snapshot,
2656
+ refresh,
2657
+ subscribe: (listener) => {
2658
+ listeners.add(listener);
2659
+ return () => {
2660
+ listeners.delete(listener);
2661
+ };
2662
+ }
2663
+ };
2664
+ };
2665
+
2666
+ // src/svelte/createVoiceReadinessFailures.ts
2667
+ var createVoiceReadinessFailures = (path = "/api/production-readiness", options = {}) => {
2668
+ const store = createVoiceReadinessFailuresStore(path, options);
2669
+ return {
2670
+ close: store.close,
2671
+ getSnapshot: store.getSnapshot,
2672
+ refresh: store.refresh,
2673
+ subscribe: store.subscribe
2674
+ };
2675
+ };
2591
2676
  // src/client/providerSimulationControls.ts
2592
2677
  var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
2593
2678
  const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
@@ -5704,6 +5789,7 @@ export {
5704
5789
  createVoiceTraceTimeline,
5705
5790
  createVoiceStream2 as createVoiceStream,
5706
5791
  createVoiceRoutingStatus,
5792
+ createVoiceReadinessFailures,
5707
5793
  createVoiceProviderStatus,
5708
5794
  createVoiceProviderSimulationControls,
5709
5795
  createVoiceProviderContracts,
@@ -3791,6 +3791,7 @@ var createVoiceIOProviderFailureSimulator = (options) => {
3791
3791
  };
3792
3792
  };
3793
3793
  // src/modelAdapters.ts
3794
+ var isVoiceProviderRoutingPolicyPreset = (value) => value === "balanced" || value === "cost-cap" || value === "cost-first" || value === "latency-first" || value === "quality-first";
3794
3795
  var resolveVoiceProviderRoutingPolicyPreset = (preset, options = {}) => {
3795
3796
  switch (preset) {
3796
3797
  case "balanced":
@@ -3832,6 +3833,75 @@ var resolveVoiceProviderRoutingPolicyPreset = (preset, options = {}) => {
3832
3833
  };
3833
3834
  }
3834
3835
  };
3836
+ var resolveVoiceProviderRoutingPolicy = (policy) => {
3837
+ if (!policy) {
3838
+ return;
3839
+ }
3840
+ if (typeof policy === "string") {
3841
+ return isVoiceProviderRoutingPolicyPreset(policy) ? resolveVoiceProviderRoutingPolicyPreset(policy) : {
3842
+ strategy: policy
3843
+ };
3844
+ }
3845
+ return policy;
3846
+ };
3847
+ var mergeDefinedProviderPolicyFields = (base, surface) => {
3848
+ const next = {
3849
+ ...base ?? {}
3850
+ };
3851
+ if (surface.allowProviders !== undefined) {
3852
+ next.allowProviders = surface.allowProviders;
3853
+ }
3854
+ if (surface.fallbackMode !== undefined) {
3855
+ next.fallbackMode = surface.fallbackMode;
3856
+ }
3857
+ if (surface.maxCost !== undefined) {
3858
+ next.maxCost = surface.maxCost;
3859
+ }
3860
+ if (surface.maxLatencyMs !== undefined) {
3861
+ next.maxLatencyMs = surface.maxLatencyMs;
3862
+ }
3863
+ if (surface.minQuality !== undefined) {
3864
+ next.minQuality = surface.minQuality;
3865
+ }
3866
+ if (surface.strategy !== undefined) {
3867
+ next.strategy = surface.strategy;
3868
+ }
3869
+ if (surface.weights !== undefined) {
3870
+ next.weights = {
3871
+ ...base?.weights ?? {},
3872
+ ...surface.weights
3873
+ };
3874
+ }
3875
+ return next;
3876
+ };
3877
+ var createVoiceProviderOrchestrationProfile = (options) => {
3878
+ const surfaceNames = Object.keys(options.surfaces);
3879
+ const defaultSurface = options.defaultSurface ?? surfaceNames[0];
3880
+ if (!defaultSurface || !options.surfaces[defaultSurface]) {
3881
+ throw new Error("Voice provider orchestration profile has no surfaces.");
3882
+ }
3883
+ return {
3884
+ defaultSurface,
3885
+ id: options.id,
3886
+ resolve: (surface = defaultSurface) => {
3887
+ const config = options.surfaces[surface];
3888
+ if (!config) {
3889
+ throw new Error(`Voice provider orchestration profile ${options.id} has no surface "${surface}".`);
3890
+ }
3891
+ const policy = mergeDefinedProviderPolicyFields(resolveVoiceProviderRoutingPolicy(config.policy), config);
3892
+ return {
3893
+ allowProviders: config.allowProviders,
3894
+ fallback: config.fallback,
3895
+ fallbackMode: config.fallbackMode,
3896
+ policy,
3897
+ providerHealth: config.providerHealth,
3898
+ providerProfiles: config.providerProfiles,
3899
+ timeoutMs: config.timeoutMs
3900
+ };
3901
+ },
3902
+ surfaces: options.surfaces
3903
+ };
3904
+ };
3835
3905
  var OUTPUT_SCHEMA = {
3836
3906
  additionalProperties: false,
3837
3907
  properties: {
@@ -3999,19 +4069,23 @@ var createJSONVoiceAssistantModel = (options) => ({
3999
4069
  var createVoiceProviderRouter = (options) => {
4000
4070
  const providerIds = Object.keys(options.providers);
4001
4071
  const firstProvider = providerIds[0];
4002
- const policy = typeof options.policy === "string" ? options.policy === "balanced" || options.policy === "cost-cap" || options.policy === "cost-first" || options.policy === "latency-first" || options.policy === "quality-first" ? resolveVoiceProviderRoutingPolicyPreset(options.policy) : {
4003
- strategy: options.policy
4004
- } : options.policy;
4072
+ const orchestrationSurface = options.orchestrationProfile?.resolve(options.orchestrationSurface);
4073
+ const policy = resolveVoiceProviderRoutingPolicy(options.policy) ?? resolveVoiceProviderRoutingPolicy(orchestrationSurface?.policy);
4005
4074
  const strategy = policy?.strategy ?? "prefer-selected";
4006
- const fallbackMode = policy?.fallbackMode ?? options.fallbackMode ?? "provider-error";
4007
- const healthOptions = typeof options.providerHealth === "object" ? options.providerHealth : options.providerHealth ? {} : undefined;
4075
+ const fallbackMode = policy?.fallbackMode ?? options.fallbackMode ?? orchestrationSurface?.fallbackMode ?? "provider-error";
4076
+ const providerProfiles = {
4077
+ ...orchestrationSurface?.providerProfiles ?? {},
4078
+ ...options.providerProfiles ?? {}
4079
+ };
4080
+ const providerHealthOption = options.providerHealth ?? orchestrationSurface?.providerHealth;
4081
+ const healthOptions = typeof providerHealthOption === "object" ? providerHealthOption : providerHealthOption ? {} : undefined;
4008
4082
  const healthState = new Map;
4009
4083
  const now = () => healthOptions?.now?.() ?? Date.now();
4010
4084
  const failureThreshold = Math.max(1, healthOptions?.failureThreshold ?? 1);
4011
4085
  const cooldownMs = Math.max(0, healthOptions?.cooldownMs ?? 30000);
4012
4086
  const rateLimitCooldownMs = Math.max(0, healthOptions?.rateLimitCooldownMs ?? 60000);
4013
4087
  const getProviderTimeoutMs = (provider) => {
4014
- const timeoutMs = options.providerProfiles?.[provider]?.timeoutMs ?? options.timeoutMs;
4088
+ const timeoutMs = providerProfiles[provider]?.timeoutMs ?? options.timeoutMs ?? orchestrationSurface?.timeoutMs;
4015
4089
  return typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : undefined;
4016
4090
  };
4017
4091
  const getHealth = (provider) => {
@@ -4077,12 +4151,12 @@ var createVoiceProviderRouter = (options) => {
4077
4151
  return cloneHealth(provider);
4078
4152
  };
4079
4153
  const resolveAllowedProviders = async (input) => {
4080
- const allowProviders = policy?.allowProviders ?? options.allowProviders;
4154
+ const allowProviders = policy?.allowProviders ?? options.allowProviders ?? orchestrationSurface?.allowProviders;
4081
4155
  const allowed = typeof allowProviders === "function" ? await allowProviders(input) : allowProviders;
4082
4156
  return new Set(allowed ?? providerIds);
4083
4157
  };
4084
4158
  const passesBudgetFilters = (provider) => {
4085
- const profile = options.providerProfiles?.[provider];
4159
+ const profile = providerProfiles[provider];
4086
4160
  if (typeof policy?.maxCost === "number" && typeof profile?.cost === "number" && profile.cost > policy.maxCost) {
4087
4161
  return false;
4088
4162
  }
@@ -4095,7 +4169,7 @@ var createVoiceProviderRouter = (options) => {
4095
4169
  return true;
4096
4170
  };
4097
4171
  const getBalancedScore = (provider) => {
4098
- const profile = options.providerProfiles?.[provider];
4172
+ const profile = providerProfiles[provider];
4099
4173
  if (policy?.scoreProvider) {
4100
4174
  return policy.scoreProvider(provider, profile);
4101
4175
  }
@@ -4107,8 +4181,8 @@ var createVoiceProviderRouter = (options) => {
4107
4181
  return providers;
4108
4182
  }
4109
4183
  return [...providers].sort((left, right) => {
4110
- const leftProfile = options.providerProfiles?.[left];
4111
- const rightProfile = options.providerProfiles?.[right];
4184
+ const leftProfile = providerProfiles[left];
4185
+ const rightProfile = providerProfiles[right];
4112
4186
  if (strategy === "quality-first") {
4113
4187
  return (rightProfile?.quality ?? Number.MIN_SAFE_INTEGER) - (leftProfile?.quality ?? Number.MIN_SAFE_INTEGER) || (leftProfile?.priority ?? Number.MAX_SAFE_INTEGER) - (rightProfile?.priority ?? Number.MAX_SAFE_INTEGER) || (leftProfile?.latencyMs ?? Number.MAX_SAFE_INTEGER) - (rightProfile?.latencyMs ?? Number.MAX_SAFE_INTEGER) || (leftProfile?.cost ?? Number.MAX_SAFE_INTEGER) - (rightProfile?.cost ?? Number.MAX_SAFE_INTEGER);
4114
4188
  }
@@ -4123,7 +4197,8 @@ var createVoiceProviderRouter = (options) => {
4123
4197
  const resolveOrder = async (input) => {
4124
4198
  const selectedProvider = await options.selectProvider?.(input);
4125
4199
  const allowedProviders = await resolveAllowedProviders(input);
4126
- const fallbackOrder = typeof options.fallback === "function" ? await options.fallback(input) : options.fallback;
4200
+ const fallbackSource = options.fallback ?? orchestrationSurface?.fallback;
4201
+ const fallbackOrder = typeof fallbackSource === "function" ? await fallbackSource(input) : fallbackSource;
4127
4202
  const allowedRankedProviders = sortProviders([
4128
4203
  ...fallbackOrder ?? providerIds
4129
4204
  ]).filter((provider) => allowedProviders.has(provider));
@@ -0,0 +1,21 @@
1
+ export declare const VoiceReadinessFailures: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ description: StringConstructor;
3
+ intervalMs: NumberConstructor;
4
+ path: {
5
+ default: string;
6
+ type: StringConstructor;
7
+ };
8
+ title: StringConstructor;
9
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
10
+ [key: string]: any;
11
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
12
+ description: StringConstructor;
13
+ intervalMs: NumberConstructor;
14
+ path: {
15
+ default: string;
16
+ type: StringConstructor;
17
+ };
18
+ title: StringConstructor;
19
+ }>> & Readonly<{}>, {
20
+ path: string;
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -3,6 +3,7 @@ export { VoiceOpsActionCenter } from './VoiceOpsActionCenter';
3
3
  export { VoiceDeliveryRuntime } from './VoiceDeliveryRuntime';
4
4
  export { VoicePlatformCoverage } from './VoicePlatformCoverage';
5
5
  export { VoiceProofTrends } from './VoiceProofTrends';
6
+ export { VoiceReadinessFailures } from './VoiceReadinessFailures';
6
7
  export { VoiceProviderSimulationControls } from './VoiceProviderSimulationControls';
7
8
  export { VoiceProviderCapabilities } from './VoiceProviderCapabilities';
8
9
  export { VoiceProviderContracts } from './VoiceProviderContracts';
@@ -14,6 +15,7 @@ export { VoiceTurnQuality } from './VoiceTurnQuality';
14
15
  export { useVoiceOpsStatus } from './useVoiceOpsStatus';
15
16
  export { useVoicePlatformCoverage } from './useVoicePlatformCoverage';
16
17
  export { useVoiceProofTrends } from './useVoiceProofTrends';
18
+ export { useVoiceReadinessFailures } from './useVoiceReadinessFailures';
17
19
  export { useVoiceOpsActionCenter } from './useVoiceOpsActionCenter';
18
20
  export { useVoiceLiveOps } from './useVoiceLiveOps';
19
21
  export { useVoiceDeliveryRuntime } from './useVoiceDeliveryRuntime';