@absolutejs/voice 0.0.22-beta.204 → 0.0.22-beta.206

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.
@@ -2931,9 +2931,127 @@ VoiceTraceTimelineService = __decorateElement(_init, 0, "VoiceTraceTimelineServi
2931
2931
  __runInitializers(_init, 1, VoiceTraceTimelineService);
2932
2932
  __decoratorMetadata(_init, VoiceTraceTimelineService);
2933
2933
  let _VoiceTraceTimelineService = VoiceTraceTimelineService;
2934
- // src/angular/voice-turn-latency.service.ts
2934
+ // src/angular/voice-agent-squad-status.service.ts
2935
2935
  import { computed as computed12, Injectable as Injectable13, signal as signal13 } from "@angular/core";
2936
2936
 
2937
+ // src/client/agentSquadStatus.ts
2938
+ var getString = (value) => typeof value === "string" && value.trim() ? value.trim() : undefined;
2939
+ var getPayloadString = (event, key) => getString(event.payload?.[key]);
2940
+ var eventStatus = (event) => {
2941
+ const status = getPayloadString(event, "status");
2942
+ if (status === "blocked")
2943
+ return "blocked";
2944
+ if (status === "unknown-target")
2945
+ return "unknown-target";
2946
+ if (status === "allowed")
2947
+ return "handoff";
2948
+ return event.type === "agent.result" ? "active" : "handoff";
2949
+ };
2950
+ var deriveSessionSpecialist = (session) => {
2951
+ const events = [...session.events].sort((left, right) => left.at - right.at);
2952
+ const agentEvents = events.filter((event) => event.type === "agent.handoff" || event.type === "agent.context" || event.type === "agent.result" || event.type === "agent.model");
2953
+ const latest = agentEvents.at(-1);
2954
+ if (!latest) {
2955
+ return {
2956
+ lastEventAt: session.lastEventAt,
2957
+ sessionId: session.sessionId,
2958
+ status: "idle"
2959
+ };
2960
+ }
2961
+ const handoffEvents = events.filter((event) => event.type === "agent.handoff");
2962
+ const lastHandoff = handoffEvents.at(-1);
2963
+ const latestAgentId = getPayloadString(latest, "agentId");
2964
+ const handoffStatus = lastHandoff ? eventStatus(lastHandoff) : undefined;
2965
+ const currentTarget = handoffStatus === "blocked" || handoffStatus === "unknown-target" ? getPayloadString(lastHandoff, "fromAgentId") ?? latestAgentId : getPayloadString(lastHandoff ?? latest, "targetAgentId") ?? latestAgentId;
2966
+ return {
2967
+ fromAgentId: getPayloadString(lastHandoff ?? latest, "fromAgentId"),
2968
+ lastEventAt: latest.at,
2969
+ reason: getPayloadString(lastHandoff ?? latest, "reason") ?? getPayloadString(latest, "handoffTarget"),
2970
+ sessionId: session.sessionId,
2971
+ status: lastHandoff ? eventStatus(lastHandoff) : "active",
2972
+ summary: getPayloadString(lastHandoff ?? latest, "summary"),
2973
+ targetAgentId: currentTarget,
2974
+ turnId: latest.turnId
2975
+ };
2976
+ };
2977
+ var buildVoiceAgentSquadStatusReport = (timeline, options = {}) => {
2978
+ const sessions = (timeline?.sessions ?? []).filter((session) => !options.sessionId || session.sessionId === options.sessionId).map(deriveSessionSpecialist).sort((left, right) => (right.lastEventAt ?? 0) - (left.lastEventAt ?? 0));
2979
+ const active = sessions.filter((session) => session.status !== "idle");
2980
+ return {
2981
+ active,
2982
+ checkedAt: timeline?.checkedAt,
2983
+ current: active[0] ?? sessions[0],
2984
+ sessionCount: sessions.length,
2985
+ sessions
2986
+ };
2987
+ };
2988
+ var createVoiceAgentSquadStatusStore = (path = "/api/voice-traces", options = {}) => {
2989
+ const timelineStore = createVoiceTraceTimelineStore(path, options);
2990
+ const getReport = () => buildVoiceAgentSquadStatusReport(timelineStore.getSnapshot().report, {
2991
+ sessionId: options.sessionId
2992
+ });
2993
+ const getSnapshot = () => {
2994
+ const snapshot = timelineStore.getSnapshot();
2995
+ return {
2996
+ error: snapshot.error,
2997
+ isLoading: snapshot.isLoading,
2998
+ report: getReport(),
2999
+ updatedAt: snapshot.updatedAt
3000
+ };
3001
+ };
3002
+ return {
3003
+ close: timelineStore.close,
3004
+ getServerSnapshot: getSnapshot,
3005
+ getSnapshot,
3006
+ refresh: timelineStore.refresh,
3007
+ subscribe: timelineStore.subscribe
3008
+ };
3009
+ };
3010
+
3011
+ // src/angular/voice-agent-squad-status.service.ts
3012
+ var _dec = [
3013
+ Injectable13({ providedIn: "root" })
3014
+ ];
3015
+ var _init = __decoratorStart(undefined);
3016
+
3017
+ class VoiceAgentSquadStatusService {
3018
+ connect(path = "/api/voice-traces", options = {}) {
3019
+ const store = createVoiceAgentSquadStatusStore(path, options);
3020
+ const errorSignal = signal13(null);
3021
+ const isLoadingSignal = signal13(false);
3022
+ const reportSignal = signal13(undefined);
3023
+ const updatedAtSignal = signal13(undefined);
3024
+ const sync = () => {
3025
+ const snapshot = store.getSnapshot();
3026
+ errorSignal.set(snapshot.error);
3027
+ isLoadingSignal.set(snapshot.isLoading);
3028
+ reportSignal.set(snapshot.report);
3029
+ updatedAtSignal.set(snapshot.updatedAt);
3030
+ };
3031
+ const unsubscribe = store.subscribe(sync);
3032
+ sync();
3033
+ store.refresh().catch(() => {});
3034
+ return {
3035
+ close: () => {
3036
+ unsubscribe();
3037
+ store.close();
3038
+ },
3039
+ current: computed12(() => reportSignal()?.current),
3040
+ error: computed12(() => errorSignal()),
3041
+ isLoading: computed12(() => isLoadingSignal()),
3042
+ refresh: store.refresh,
3043
+ report: computed12(() => reportSignal()),
3044
+ updatedAt: computed12(() => updatedAtSignal())
3045
+ };
3046
+ }
3047
+ }
3048
+ VoiceAgentSquadStatusService = __decorateElement(_init, 0, "VoiceAgentSquadStatusService", _dec, VoiceAgentSquadStatusService);
3049
+ __runInitializers(_init, 1, VoiceAgentSquadStatusService);
3050
+ __decoratorMetadata(_init, VoiceAgentSquadStatusService);
3051
+ let _VoiceAgentSquadStatusService = VoiceAgentSquadStatusService;
3052
+ // src/angular/voice-turn-latency.service.ts
3053
+ import { computed as computed13, Injectable as Injectable14, signal as signal14 } from "@angular/core";
3054
+
2937
3055
  // src/client/turnLatency.ts
2938
3056
  var fetchVoiceTurnLatency = async (path = "/api/turn-latency", options = {}) => {
2939
3057
  const fetchImpl = options.fetch ?? globalThis.fetch;
@@ -3039,17 +3157,17 @@ var createVoiceTurnLatencyStore = (path = "/api/turn-latency", options = {}) =>
3039
3157
 
3040
3158
  // src/angular/voice-turn-latency.service.ts
3041
3159
  var _dec = [
3042
- Injectable13({ providedIn: "root" })
3160
+ Injectable14({ providedIn: "root" })
3043
3161
  ];
3044
3162
  var _init = __decoratorStart(undefined);
3045
3163
 
3046
3164
  class VoiceTurnLatencyService {
3047
3165
  connect(path = "/api/turn-latency", options = {}) {
3048
3166
  const store = createVoiceTurnLatencyStore(path, options);
3049
- const errorSignal = signal13(null);
3050
- const isLoadingSignal = signal13(false);
3051
- const reportSignal = signal13(undefined);
3052
- const updatedAtSignal = signal13(undefined);
3167
+ const errorSignal = signal14(null);
3168
+ const isLoadingSignal = signal14(false);
3169
+ const reportSignal = signal14(undefined);
3170
+ const updatedAtSignal = signal14(undefined);
3053
3171
  const sync = () => {
3054
3172
  const snapshot = store.getSnapshot();
3055
3173
  errorSignal.set(snapshot.error);
@@ -3065,12 +3183,12 @@ class VoiceTurnLatencyService {
3065
3183
  unsubscribe();
3066
3184
  store.close();
3067
3185
  },
3068
- error: computed12(() => errorSignal()),
3069
- isLoading: computed12(() => isLoadingSignal()),
3186
+ error: computed13(() => errorSignal()),
3187
+ isLoading: computed13(() => isLoadingSignal()),
3070
3188
  refresh: store.refresh,
3071
- report: computed12(() => reportSignal()),
3189
+ report: computed13(() => reportSignal()),
3072
3190
  runProof: store.runProof,
3073
- updatedAt: computed12(() => updatedAtSignal())
3191
+ updatedAt: computed13(() => updatedAtSignal())
3074
3192
  };
3075
3193
  }
3076
3194
  }
@@ -3079,7 +3197,7 @@ __runInitializers(_init, 1, VoiceTurnLatencyService);
3079
3197
  __decoratorMetadata(_init, VoiceTurnLatencyService);
3080
3198
  let _VoiceTurnLatencyService = VoiceTurnLatencyService;
3081
3199
  // src/angular/voice-turn-quality.service.ts
3082
- import { computed as computed13, Injectable as Injectable14, signal as signal14 } from "@angular/core";
3200
+ import { computed as computed14, Injectable as Injectable15, signal as signal15 } from "@angular/core";
3083
3201
 
3084
3202
  // src/client/turnQuality.ts
3085
3203
  var fetchVoiceTurnQuality = async (path = "/api/turn-quality", options = {}) => {
@@ -3162,17 +3280,17 @@ var createVoiceTurnQualityStore = (path = "/api/turn-quality", options = {}) =>
3162
3280
 
3163
3281
  // src/angular/voice-turn-quality.service.ts
3164
3282
  var _dec = [
3165
- Injectable14({ providedIn: "root" })
3283
+ Injectable15({ providedIn: "root" })
3166
3284
  ];
3167
3285
  var _init = __decoratorStart(undefined);
3168
3286
 
3169
3287
  class VoiceTurnQualityService {
3170
3288
  connect(path = "/api/turn-quality", options = {}) {
3171
3289
  const store = createVoiceTurnQualityStore(path, options);
3172
- const errorSignal = signal14(null);
3173
- const isLoadingSignal = signal14(false);
3174
- const reportSignal = signal14(undefined);
3175
- const updatedAtSignal = signal14(undefined);
3290
+ const errorSignal = signal15(null);
3291
+ const isLoadingSignal = signal15(false);
3292
+ const reportSignal = signal15(undefined);
3293
+ const updatedAtSignal = signal15(undefined);
3176
3294
  const sync = () => {
3177
3295
  const snapshot = store.getSnapshot();
3178
3296
  errorSignal.set(snapshot.error);
@@ -3188,11 +3306,11 @@ class VoiceTurnQualityService {
3188
3306
  unsubscribe();
3189
3307
  store.close();
3190
3308
  },
3191
- error: computed13(() => errorSignal()),
3192
- isLoading: computed13(() => isLoadingSignal()),
3309
+ error: computed14(() => errorSignal()),
3310
+ isLoading: computed14(() => isLoadingSignal()),
3193
3311
  refresh: store.refresh,
3194
- report: computed13(() => reportSignal()),
3195
- updatedAt: computed13(() => updatedAtSignal())
3312
+ report: computed14(() => reportSignal()),
3313
+ updatedAt: computed14(() => updatedAtSignal())
3196
3314
  };
3197
3315
  }
3198
3316
  }
@@ -3201,7 +3319,7 @@ __runInitializers(_init, 1, VoiceTurnQualityService);
3201
3319
  __decoratorMetadata(_init, VoiceTurnQualityService);
3202
3320
  let _VoiceTurnQualityService = VoiceTurnQualityService;
3203
3321
  // src/angular/voice-workflow-status.service.ts
3204
- import { computed as computed14, Injectable as Injectable15, signal as signal15 } from "@angular/core";
3322
+ import { computed as computed15, Injectable as Injectable16, signal as signal16 } from "@angular/core";
3205
3323
 
3206
3324
  // src/client/workflowStatus.ts
3207
3325
  var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
@@ -3284,17 +3402,17 @@ var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options =
3284
3402
 
3285
3403
  // src/angular/voice-workflow-status.service.ts
3286
3404
  var _dec = [
3287
- Injectable15({ providedIn: "root" })
3405
+ Injectable16({ providedIn: "root" })
3288
3406
  ];
3289
3407
  var _init = __decoratorStart(undefined);
3290
3408
 
3291
3409
  class VoiceWorkflowStatusService {
3292
3410
  connect(path = "/evals/scenarios/json", options = {}) {
3293
3411
  const store = createVoiceWorkflowStatusStore(path, options);
3294
- const errorSignal = signal15(null);
3295
- const isLoadingSignal = signal15(false);
3296
- const reportSignal = signal15(undefined);
3297
- const updatedAtSignal = signal15(undefined);
3412
+ const errorSignal = signal16(null);
3413
+ const isLoadingSignal = signal16(false);
3414
+ const reportSignal = signal16(undefined);
3415
+ const updatedAtSignal = signal16(undefined);
3298
3416
  const sync = () => {
3299
3417
  const snapshot = store.getSnapshot();
3300
3418
  errorSignal.set(snapshot.error);
@@ -3312,11 +3430,11 @@ class VoiceWorkflowStatusService {
3312
3430
  unsubscribe();
3313
3431
  store.close();
3314
3432
  },
3315
- error: computed14(() => errorSignal()),
3316
- isLoading: computed14(() => isLoadingSignal()),
3433
+ error: computed15(() => errorSignal()),
3434
+ isLoading: computed15(() => isLoadingSignal()),
3317
3435
  refresh: store.refresh,
3318
- report: computed14(() => reportSignal()),
3319
- updatedAt: computed14(() => updatedAtSignal())
3436
+ report: computed15(() => reportSignal()),
3437
+ updatedAt: computed15(() => updatedAtSignal())
3320
3438
  };
3321
3439
  }
3322
3440
  }
@@ -3339,5 +3457,6 @@ export {
3339
3457
  VoiceLiveOpsService,
3340
3458
  VoiceDeliveryRuntimeService,
3341
3459
  VoiceControllerService,
3342
- VoiceCampaignDialerProofService
3460
+ VoiceCampaignDialerProofService,
3461
+ VoiceAgentSquadStatusService
3343
3462
  };
@@ -0,0 +1,12 @@
1
+ import { type VoiceAgentSquadStatusClientOptions, type VoiceAgentSquadStatusReport } from '../client/agentSquadStatus';
2
+ export declare class VoiceAgentSquadStatusService {
3
+ connect(path?: string, options?: VoiceAgentSquadStatusClientOptions): {
4
+ close: () => void;
5
+ current: import("@angular/core").Signal<import("../client").VoiceAgentSquadSpecialist | undefined>;
6
+ error: import("@angular/core").Signal<string | null>;
7
+ isLoading: import("@angular/core").Signal<boolean>;
8
+ refresh: () => Promise<import("..").VoiceTraceTimelineReport | null>;
9
+ report: import("@angular/core").Signal<VoiceAgentSquadStatusReport | undefined>;
10
+ updatedAt: import("@angular/core").Signal<number | undefined>;
11
+ };
12
+ }
@@ -0,0 +1,37 @@
1
+ import type { VoiceTraceTimelineReport } from '../traceTimeline';
2
+ import { type VoiceTraceTimelineClientOptions } from './traceTimeline';
3
+ export type VoiceAgentSquadSpecialistStatus = 'active' | 'blocked' | 'handoff' | 'idle' | 'unknown-target';
4
+ export type VoiceAgentSquadSpecialist = {
5
+ fromAgentId?: string;
6
+ lastEventAt?: number;
7
+ reason?: string;
8
+ sessionId: string;
9
+ status: VoiceAgentSquadSpecialistStatus;
10
+ summary?: string;
11
+ targetAgentId?: string;
12
+ turnId?: string;
13
+ };
14
+ export type VoiceAgentSquadStatusReport = {
15
+ active: VoiceAgentSquadSpecialist[];
16
+ checkedAt?: number;
17
+ current?: VoiceAgentSquadSpecialist;
18
+ sessionCount: number;
19
+ sessions: VoiceAgentSquadSpecialist[];
20
+ };
21
+ export type VoiceAgentSquadStatusSnapshot = {
22
+ error: string | null;
23
+ isLoading: boolean;
24
+ report: VoiceAgentSquadStatusReport;
25
+ updatedAt?: number;
26
+ };
27
+ export type VoiceAgentSquadStatusClientOptions = VoiceTraceTimelineClientOptions & {
28
+ sessionId?: string;
29
+ };
30
+ export declare const buildVoiceAgentSquadStatusReport: (timeline: VoiceTraceTimelineReport | null | undefined, options?: Pick<VoiceAgentSquadStatusClientOptions, "sessionId">) => VoiceAgentSquadStatusReport;
31
+ export declare const createVoiceAgentSquadStatusStore: (path?: string, options?: VoiceAgentSquadStatusClientOptions) => {
32
+ close: () => void;
33
+ getServerSnapshot: () => VoiceAgentSquadStatusSnapshot;
34
+ getSnapshot: () => VoiceAgentSquadStatusSnapshot;
35
+ refresh: () => Promise<VoiceTraceTimelineReport | null>;
36
+ subscribe: (listener: () => void) => () => void;
37
+ };
@@ -0,0 +1,24 @@
1
+ import { type VoiceAgentSquadSpecialist, type VoiceAgentSquadStatusClientOptions, type VoiceAgentSquadStatusSnapshot } from './agentSquadStatus';
2
+ export type VoiceAgentSquadStatusViewModel = {
3
+ current?: VoiceAgentSquadSpecialist;
4
+ description: string;
5
+ error: string | null;
6
+ isLoading: boolean;
7
+ label: string;
8
+ sessionCount: number;
9
+ sessions: VoiceAgentSquadSpecialist[];
10
+ title: string;
11
+ updatedAt?: number;
12
+ };
13
+ export type VoiceAgentSquadStatusWidgetOptions = VoiceAgentSquadStatusClientOptions & {
14
+ description?: string;
15
+ title?: string;
16
+ };
17
+ export declare const createVoiceAgentSquadStatusViewModel: (snapshot: VoiceAgentSquadStatusSnapshot, options?: VoiceAgentSquadStatusWidgetOptions) => VoiceAgentSquadStatusViewModel;
18
+ export declare const renderVoiceAgentSquadStatusHTML: (snapshot: VoiceAgentSquadStatusSnapshot, options?: VoiceAgentSquadStatusWidgetOptions) => string;
19
+ export declare const getVoiceAgentSquadStatusCSS: () => string;
20
+ export declare const mountVoiceAgentSquadStatus: (element: Element | null, path?: string, options?: VoiceAgentSquadStatusWidgetOptions) => {
21
+ close: () => void;
22
+ refresh: () => Promise<import("..").VoiceTraceTimelineReport | null>;
23
+ };
24
+ export declare const defineVoiceAgentSquadStatusElement: (tagName?: string, options?: VoiceAgentSquadStatusWidgetOptions) => void;
@@ -26,6 +26,7 @@ export { createVoiceTurnQualityStore, fetchVoiceTurnQuality } from './turnQualit
26
26
  export { createVoiceTurnLatencyStore, fetchVoiceTurnLatency, runVoiceTurnLatencyProof } from './turnLatency';
27
27
  export { createVoiceCampaignDialerProofStore, fetchVoiceCampaignDialerProofStatus, runVoiceCampaignDialerProofAction } from './campaignDialerProof';
28
28
  export { createVoiceTraceTimelineStore, fetchVoiceTraceTimeline } from './traceTimeline';
29
+ export { buildVoiceAgentSquadStatusReport, createVoiceAgentSquadStatusStore } from './agentSquadStatus';
29
30
  export { createVoiceProviderSimulationControlsStore } from './providerSimulationControls';
30
31
  export { bindVoiceProviderSimulationControls, createVoiceProviderSimulationControlsViewModel, defineVoiceProviderSimulationControlsElement, mountVoiceProviderSimulationControls, renderVoiceProviderSimulationControlsHTML } from './providerSimulationControlsWidget';
31
32
  export { createVoiceProviderStatusViewModel, defineVoiceProviderStatusElement, getVoiceProviderStatusCSS, mountVoiceProviderStatus, renderVoiceProviderStatusHTML } from './providerStatusWidget';
@@ -34,6 +35,7 @@ export { createVoiceProviderContractsViewModel, defineVoiceProviderContractsElem
34
35
  export { createVoiceTurnQualityViewModel, defineVoiceTurnQualityElement, getVoiceTurnQualityCSS, mountVoiceTurnQuality, renderVoiceTurnQualityHTML } from './turnQualityWidget';
35
36
  export { createVoiceTurnLatencyViewModel, defineVoiceTurnLatencyElement, mountVoiceTurnLatency, renderVoiceTurnLatencyHTML } from './turnLatencyWidget';
36
37
  export { createVoiceTraceTimelineViewModel, defineVoiceTraceTimelineElement, getVoiceTraceTimelineCSS, mountVoiceTraceTimeline, renderVoiceTraceTimelineWidgetHTML } from './traceTimelineWidget';
38
+ export { createVoiceAgentSquadStatusViewModel, defineVoiceAgentSquadStatusElement, getVoiceAgentSquadStatusCSS, mountVoiceAgentSquadStatus, renderVoiceAgentSquadStatusHTML } from './agentSquadStatusWidget';
37
39
  export { createVoiceWorkflowStatusStore, fetchVoiceWorkflowStatus } from './workflowStatus';
38
40
  export type { VoiceOpsStatusClientOptions, VoiceOpsStatusSnapshot } from './opsStatus';
39
41
  export type { VoiceOpsActionCenterClientOptions, VoiceOpsActionCenterPresetOptions, VoiceOpsActionCenterSnapshot, VoiceOpsActionDescriptor, VoiceOpsActionMethod, VoiceOpsActionRunResult } from './opsActionCenter';
@@ -56,6 +58,7 @@ export type { VoiceTurnQualityClientOptions, VoiceTurnQualitySnapshot } from './
56
58
  export type { VoiceTurnLatencyClientOptions, VoiceTurnLatencySnapshot } from './turnLatency';
57
59
  export type { VoiceCampaignDialerProofClientOptions, VoiceCampaignDialerProofSnapshot } from './campaignDialerProof';
58
60
  export type { VoiceTraceTimelineClientOptions, VoiceTraceTimelineSnapshot } from './traceTimeline';
61
+ export type { VoiceAgentSquadSpecialist, VoiceAgentSquadSpecialistStatus, VoiceAgentSquadStatusClientOptions, VoiceAgentSquadStatusReport, VoiceAgentSquadStatusSnapshot } from './agentSquadStatus';
59
62
  export type { VoiceProviderSimulationControlsOptions, VoiceProviderSimulationControlsSnapshot, VoiceProviderSimulationProvider } from './providerSimulationControls';
60
63
  export type { VoiceProviderSimulationControlsViewModel } from './providerSimulationControlsWidget';
61
64
  export type { VoiceProviderStatusCardView, VoiceProviderStatusViewModel, VoiceProviderStatusWidgetOptions } from './providerStatusWidget';
@@ -64,4 +67,5 @@ export type { VoiceProviderContractRowView, VoiceProviderContractsViewModel, Voi
64
67
  export type { VoiceTurnQualityCardView, VoiceTurnQualityViewModel, VoiceTurnQualityWidgetOptions } from './turnQualityWidget';
65
68
  export type { VoiceTurnLatencyCardView, VoiceTurnLatencyViewModel, VoiceTurnLatencyWidgetOptions } from './turnLatencyWidget';
66
69
  export type { VoiceTraceTimelineSessionView, VoiceTraceTimelineViewModel, VoiceTraceTimelineWidgetOptions } from './traceTimelineWidget';
70
+ export type { VoiceAgentSquadStatusViewModel, VoiceAgentSquadStatusWidgetOptions } from './agentSquadStatusWidget';
67
71
  export type { VoiceWorkflowStatusClientOptions, VoiceWorkflowStatusSnapshot } from './workflowStatus';
@@ -4881,6 +4881,79 @@ var createVoiceTraceTimelineStore = (path = "/api/voice-traces", options = {}) =
4881
4881
  }
4882
4882
  };
4883
4883
  };
4884
+ // src/client/agentSquadStatus.ts
4885
+ var getString = (value) => typeof value === "string" && value.trim() ? value.trim() : undefined;
4886
+ var getPayloadString = (event, key) => getString(event.payload?.[key]);
4887
+ var eventStatus = (event) => {
4888
+ const status = getPayloadString(event, "status");
4889
+ if (status === "blocked")
4890
+ return "blocked";
4891
+ if (status === "unknown-target")
4892
+ return "unknown-target";
4893
+ if (status === "allowed")
4894
+ return "handoff";
4895
+ return event.type === "agent.result" ? "active" : "handoff";
4896
+ };
4897
+ var deriveSessionSpecialist = (session) => {
4898
+ const events = [...session.events].sort((left, right) => left.at - right.at);
4899
+ const agentEvents = events.filter((event) => event.type === "agent.handoff" || event.type === "agent.context" || event.type === "agent.result" || event.type === "agent.model");
4900
+ const latest = agentEvents.at(-1);
4901
+ if (!latest) {
4902
+ return {
4903
+ lastEventAt: session.lastEventAt,
4904
+ sessionId: session.sessionId,
4905
+ status: "idle"
4906
+ };
4907
+ }
4908
+ const handoffEvents = events.filter((event) => event.type === "agent.handoff");
4909
+ const lastHandoff = handoffEvents.at(-1);
4910
+ const latestAgentId = getPayloadString(latest, "agentId");
4911
+ const handoffStatus = lastHandoff ? eventStatus(lastHandoff) : undefined;
4912
+ const currentTarget = handoffStatus === "blocked" || handoffStatus === "unknown-target" ? getPayloadString(lastHandoff, "fromAgentId") ?? latestAgentId : getPayloadString(lastHandoff ?? latest, "targetAgentId") ?? latestAgentId;
4913
+ return {
4914
+ fromAgentId: getPayloadString(lastHandoff ?? latest, "fromAgentId"),
4915
+ lastEventAt: latest.at,
4916
+ reason: getPayloadString(lastHandoff ?? latest, "reason") ?? getPayloadString(latest, "handoffTarget"),
4917
+ sessionId: session.sessionId,
4918
+ status: lastHandoff ? eventStatus(lastHandoff) : "active",
4919
+ summary: getPayloadString(lastHandoff ?? latest, "summary"),
4920
+ targetAgentId: currentTarget,
4921
+ turnId: latest.turnId
4922
+ };
4923
+ };
4924
+ var buildVoiceAgentSquadStatusReport = (timeline, options = {}) => {
4925
+ const sessions = (timeline?.sessions ?? []).filter((session) => !options.sessionId || session.sessionId === options.sessionId).map(deriveSessionSpecialist).sort((left, right) => (right.lastEventAt ?? 0) - (left.lastEventAt ?? 0));
4926
+ const active = sessions.filter((session) => session.status !== "idle");
4927
+ return {
4928
+ active,
4929
+ checkedAt: timeline?.checkedAt,
4930
+ current: active[0] ?? sessions[0],
4931
+ sessionCount: sessions.length,
4932
+ sessions
4933
+ };
4934
+ };
4935
+ var createVoiceAgentSquadStatusStore = (path = "/api/voice-traces", options = {}) => {
4936
+ const timelineStore = createVoiceTraceTimelineStore(path, options);
4937
+ const getReport = () => buildVoiceAgentSquadStatusReport(timelineStore.getSnapshot().report, {
4938
+ sessionId: options.sessionId
4939
+ });
4940
+ const getSnapshot = () => {
4941
+ const snapshot = timelineStore.getSnapshot();
4942
+ return {
4943
+ error: snapshot.error,
4944
+ isLoading: snapshot.isLoading,
4945
+ report: getReport(),
4946
+ updatedAt: snapshot.updatedAt
4947
+ };
4948
+ };
4949
+ return {
4950
+ close: timelineStore.close,
4951
+ getServerSnapshot: getSnapshot,
4952
+ getSnapshot,
4953
+ refresh: timelineStore.refresh,
4954
+ subscribe: timelineStore.subscribe
4955
+ };
4956
+ };
4884
4957
  // src/client/providerSimulationControls.ts
4885
4958
  var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
4886
4959
  const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
@@ -5702,6 +5775,96 @@ var defineVoiceTraceTimelineElement = (tagName = "absolute-voice-trace-timeline"
5702
5775
  }
5703
5776
  });
5704
5777
  };
5778
+ // src/client/agentSquadStatusWidget.ts
5779
+ var DEFAULT_TITLE11 = "Voice Agent Squad";
5780
+ var DEFAULT_DESCRIPTION11 = "Current specialist and recent handoffs from your self-hosted voice traces.";
5781
+ var escapeHtml15 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
5782
+ var labelFor = (current) => {
5783
+ if (!current)
5784
+ return "Waiting for specialist activity";
5785
+ if (current.status === "blocked")
5786
+ return "Handoff blocked";
5787
+ if (current.status === "unknown-target")
5788
+ return "Unknown specialist";
5789
+ if (current.targetAgentId)
5790
+ return `Current: ${current.targetAgentId}`;
5791
+ return "Specialist active";
5792
+ };
5793
+ var createVoiceAgentSquadStatusViewModel = (snapshot, options = {}) => ({
5794
+ current: snapshot.report.current,
5795
+ description: options.description ?? DEFAULT_DESCRIPTION11,
5796
+ error: snapshot.error,
5797
+ isLoading: snapshot.isLoading,
5798
+ label: snapshot.error ? "Unavailable" : labelFor(snapshot.report.current),
5799
+ sessionCount: snapshot.report.sessionCount,
5800
+ sessions: snapshot.report.sessions,
5801
+ title: options.title ?? DEFAULT_TITLE11,
5802
+ updatedAt: snapshot.updatedAt
5803
+ });
5804
+ var renderVoiceAgentSquadStatusHTML = (snapshot, options = {}) => {
5805
+ const model = createVoiceAgentSquadStatusViewModel(snapshot, options);
5806
+ const current = model.current;
5807
+ const rows = model.sessions.length ? model.sessions.slice(0, 5).map((session) => `<li>
5808
+ <span>${escapeHtml15(session.sessionId)}</span>
5809
+ <strong>${escapeHtml15(session.targetAgentId ?? "none")}</strong>
5810
+ <em>${escapeHtml15(session.status)}</em>
5811
+ ${session.summary || session.reason ? `<p>${escapeHtml15(session.summary ?? session.reason ?? "")}</p>` : ""}
5812
+ </li>`).join("") : "<li><span>No squad traces yet.</span><strong>Waiting</strong></li>";
5813
+ return `<section class="absolute-voice-agent-squad-status">
5814
+ <header>
5815
+ <span>${escapeHtml15(model.title)}</span>
5816
+ <strong>${escapeHtml15(model.label)}</strong>
5817
+ </header>
5818
+ <p>${escapeHtml15(model.description)}</p>
5819
+ <div>
5820
+ <span>Session</span><strong>${escapeHtml15(current?.sessionId ?? "n/a")}</strong>
5821
+ <span>From</span><strong>${escapeHtml15(current?.fromAgentId ?? "n/a")}</strong>
5822
+ <span>Status</span><strong>${escapeHtml15(current?.status ?? "idle")}</strong>
5823
+ </div>
5824
+ <ul>${rows}</ul>
5825
+ ${model.error ? `<p class="absolute-voice-agent-squad-status__error">${escapeHtml15(model.error)}</p>` : ""}
5826
+ </section>`;
5827
+ };
5828
+ var getVoiceAgentSquadStatusCSS = () => `.absolute-voice-agent-squad-status{border:1px solid #38bdf866;border-radius:20px;background:#0f172a;color:#f8fafc;padding:18px;font-family:inherit}.absolute-voice-agent-squad-status header{display:grid;gap:4px}.absolute-voice-agent-squad-status header span{color:#7dd3fc;font-size:12px;font-weight:900;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-agent-squad-status header strong{font-size:20px}.absolute-voice-agent-squad-status p{color:#cbd5e1}.absolute-voice-agent-squad-status div{display:grid;gap:6px;grid-template-columns:max-content 1fr;margin:14px 0}.absolute-voice-agent-squad-status div span{color:#94a3b8}.absolute-voice-agent-squad-status ul{display:grid;gap:8px;list-style:none;margin:0;padding:0}.absolute-voice-agent-squad-status li{background:#020617;border:1px solid #1e293b;border-radius:14px;padding:10px}.absolute-voice-agent-squad-status li span{color:#94a3b8;display:block;font-size:12px}.absolute-voice-agent-squad-status li strong{display:block}.absolute-voice-agent-squad-status li em{color:#7dd3fc;font-style:normal}.absolute-voice-agent-squad-status__error{color:#fecaca;font-weight:800}`;
5829
+ var mountVoiceAgentSquadStatus = (element, path = "/api/voice-traces", options = {}) => {
5830
+ if (!element) {
5831
+ throw new Error("mountVoiceAgentSquadStatus requires an element.");
5832
+ }
5833
+ const store = createVoiceAgentSquadStatusStore(path, options);
5834
+ const render = () => {
5835
+ element.innerHTML = `<style>${getVoiceAgentSquadStatusCSS()}</style>${renderVoiceAgentSquadStatusHTML(store.getSnapshot(), options)}`;
5836
+ };
5837
+ const unsubscribe = store.subscribe(render);
5838
+ render();
5839
+ store.refresh().catch(() => {});
5840
+ return {
5841
+ close: () => {
5842
+ unsubscribe();
5843
+ store.close();
5844
+ },
5845
+ refresh: store.refresh
5846
+ };
5847
+ };
5848
+ var defineVoiceAgentSquadStatusElement = (tagName = "absolute-voice-agent-squad-status", options = {}) => {
5849
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
5850
+ return;
5851
+ }
5852
+ customElements.define(tagName, class AbsoluteVoiceAgentSquadStatusElement extends HTMLElement {
5853
+ mounted;
5854
+ connectedCallback() {
5855
+ this.mounted = mountVoiceAgentSquadStatus(this, this.getAttribute("path") ?? "/api/voice-traces", {
5856
+ ...options,
5857
+ description: this.getAttribute("description") ?? options.description,
5858
+ sessionId: this.getAttribute("session-id") ?? options.sessionId,
5859
+ title: this.getAttribute("title") ?? options.title
5860
+ });
5861
+ }
5862
+ disconnectedCallback() {
5863
+ this.mounted?.close();
5864
+ this.mounted = undefined;
5865
+ }
5866
+ });
5867
+ };
5705
5868
  // src/client/workflowStatus.ts
5706
5869
  var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
5707
5870
  const fetchImpl = options.fetch ?? globalThis.fetch;
@@ -5798,6 +5961,7 @@ export {
5798
5961
  renderVoiceOpsActionCenterHTML,
5799
5962
  renderVoiceLiveOpsHTML,
5800
5963
  renderVoiceDeliveryRuntimeHTML,
5964
+ renderVoiceAgentSquadStatusHTML,
5801
5965
  recordVoiceOpsActionResult,
5802
5966
  postVoiceLiveOpsAction,
5803
5967
  mountVoiceTurnQuality,
@@ -5813,6 +5977,7 @@ export {
5813
5977
  mountVoiceOpsActionCenter,
5814
5978
  mountVoiceLiveOps,
5815
5979
  mountVoiceDeliveryRuntime,
5980
+ mountVoiceAgentSquadStatus,
5816
5981
  getVoiceTurnQualityCSS,
5817
5982
  getVoiceTraceTimelineCSS,
5818
5983
  getVoiceRoutingStatusCSS,
@@ -5825,6 +5990,7 @@ export {
5825
5990
  getVoiceOpsActionCenterCSS,
5826
5991
  getVoiceLiveOpsCSS,
5827
5992
  getVoiceDeliveryRuntimeCSS,
5993
+ getVoiceAgentSquadStatusCSS,
5828
5994
  fetchVoiceWorkflowStatus,
5829
5995
  fetchVoiceTurnQuality,
5830
5996
  fetchVoiceTurnLatency,
@@ -5849,6 +6015,7 @@ export {
5849
6015
  defineVoiceOpsActionCenterElement,
5850
6016
  defineVoiceLiveOpsElement,
5851
6017
  defineVoiceDeliveryRuntimeElement,
6018
+ defineVoiceAgentSquadStatusElement,
5852
6019
  decodeVoiceAudioChunk,
5853
6020
  createVoiceWorkflowStatusStore,
5854
6021
  createVoiceTurnQualityViewModel,
@@ -5885,7 +6052,10 @@ export {
5885
6052
  createVoiceCampaignDialerProofStore,
5886
6053
  createVoiceBargeInMonitor,
5887
6054
  createVoiceAudioPlayer,
6055
+ createVoiceAgentSquadStatusViewModel,
6056
+ createVoiceAgentSquadStatusStore,
5888
6057
  createMicrophoneCapture,
6058
+ buildVoiceAgentSquadStatusReport,
5889
6059
  bindVoiceProviderSimulationControls,
5890
6060
  bindVoiceHTMX,
5891
6061
  bindVoiceBargeIn