@absolutejs/voice 0.0.22-beta.5 → 0.0.22-beta.51
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/angular/index.d.ts +3 -0
- package/dist/angular/index.js +463 -43
- package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
- package/dist/angular/voice-provider-status.service.d.ts +12 -0
- package/dist/angular/voice-stream.service.d.ts +2 -0
- package/dist/angular/voice-workflow-status.service.d.ts +12 -0
- package/dist/appKit.d.ts +92 -0
- package/dist/assistantHealth.d.ts +81 -0
- package/dist/client/actions.d.ts +22 -0
- package/dist/client/appKitStatus.d.ts +19 -0
- package/dist/client/connection.d.ts +3 -0
- package/dist/client/htmxBootstrap.js +44 -2
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +285 -2
- package/dist/client/providerStatus.d.ts +19 -0
- package/dist/client/workflowStatus.d.ts +19 -0
- package/dist/diagnosticsRoutes.d.ts +44 -0
- package/dist/evalRoutes.d.ts +213 -0
- package/dist/handoff.d.ts +54 -0
- package/dist/handoffHealth.d.ts +94 -0
- package/dist/index.d.ts +32 -4
- package/dist/index.js +4425 -166
- package/dist/modelAdapters.d.ts +81 -0
- package/dist/opsConsoleRoutes.d.ts +77 -0
- package/dist/opsWebhook.d.ts +126 -0
- package/dist/providerAdapters.d.ts +37 -0
- package/dist/providerHealth.d.ts +79 -0
- package/dist/qualityRoutes.d.ts +76 -0
- package/dist/queue.d.ts +52 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +355 -11
- package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
- package/dist/react/useVoiceController.d.ts +2 -0
- package/dist/react/useVoiceProviderStatus.d.ts +8 -0
- package/dist/react/useVoiceStream.d.ts +2 -0
- package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
- package/dist/resilienceRoutes.d.ts +106 -0
- package/dist/sessionReplay.d.ts +175 -0
- package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
- package/dist/svelte/createVoiceProviderStatus.d.ts +8 -0
- package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
- package/dist/svelte/index.d.ts +3 -0
- package/dist/svelte/index.js +292 -3
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +1468 -7
- package/dist/testing/ioProviderSimulator.d.ts +41 -0
- package/dist/testing/providerSimulator.d.ts +44 -0
- package/dist/trace.d.ts +1 -1
- package/dist/types.d.ts +84 -2
- package/dist/vue/index.d.ts +3 -0
- package/dist/vue/index.js +412 -25
- package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
- package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
- package/dist/vue/useVoiceStream.d.ts +2 -0
- package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
- package/dist/workflowContract.d.ts +91 -0
- package/package.json +1 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type StoredVoiceTraceEvent, type VoiceTraceEvaluationOptions, type VoiceTraceEventStore, type VoiceTraceRedactionConfig, type VoiceTraceSummary, type VoiceTraceEvaluation } from './trace';
|
|
3
|
+
export type VoiceSessionReplayTurn = {
|
|
4
|
+
assistantReplies: string[];
|
|
5
|
+
committedText?: string;
|
|
6
|
+
errors: Array<Record<string, unknown>>;
|
|
7
|
+
id: string;
|
|
8
|
+
modelCalls: Array<Record<string, unknown>>;
|
|
9
|
+
tools: Array<Record<string, unknown>>;
|
|
10
|
+
transcripts: Array<{
|
|
11
|
+
isFinal: boolean;
|
|
12
|
+
text?: string;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
export type VoiceSessionReplay = {
|
|
16
|
+
evaluation: VoiceTraceEvaluation;
|
|
17
|
+
events: StoredVoiceTraceEvent[];
|
|
18
|
+
html: string;
|
|
19
|
+
markdown: string;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
summary: VoiceTraceSummary;
|
|
22
|
+
timeline: Array<{
|
|
23
|
+
at: number;
|
|
24
|
+
offsetMs?: number;
|
|
25
|
+
payload: Record<string, unknown>;
|
|
26
|
+
turnId?: string;
|
|
27
|
+
type: StoredVoiceTraceEvent['type'];
|
|
28
|
+
}>;
|
|
29
|
+
turns: VoiceSessionReplayTurn[];
|
|
30
|
+
};
|
|
31
|
+
export type VoiceSessionListStatus = 'failed' | 'healthy';
|
|
32
|
+
export type VoiceSessionListItem = {
|
|
33
|
+
endedAt?: number;
|
|
34
|
+
errorCount: number;
|
|
35
|
+
eventCount: number;
|
|
36
|
+
latestOutcome?: string;
|
|
37
|
+
providerErrors: Record<string, number>;
|
|
38
|
+
providers: string[];
|
|
39
|
+
replayHref: string;
|
|
40
|
+
sessionId: string;
|
|
41
|
+
startedAt?: number;
|
|
42
|
+
status: VoiceSessionListStatus;
|
|
43
|
+
transcriptCount: number;
|
|
44
|
+
turnCount: number;
|
|
45
|
+
};
|
|
46
|
+
export type VoiceSessionListOptions = {
|
|
47
|
+
events?: StoredVoiceTraceEvent[];
|
|
48
|
+
limit?: number;
|
|
49
|
+
provider?: string;
|
|
50
|
+
q?: string;
|
|
51
|
+
replayHref?: false | string | ((session: Omit<VoiceSessionListItem, 'replayHref'>) => string);
|
|
52
|
+
status?: VoiceSessionListStatus | 'all';
|
|
53
|
+
store?: VoiceTraceEventStore;
|
|
54
|
+
};
|
|
55
|
+
export type VoiceSessionListHTMLHandlerOptions = VoiceSessionListOptions & {
|
|
56
|
+
headers?: HeadersInit;
|
|
57
|
+
render?: (sessions: VoiceSessionListItem[]) => string | Promise<string>;
|
|
58
|
+
};
|
|
59
|
+
export type VoiceSessionListRoutesOptions = VoiceSessionListHTMLHandlerOptions & {
|
|
60
|
+
htmlPath?: false | string;
|
|
61
|
+
name?: string;
|
|
62
|
+
path?: string;
|
|
63
|
+
};
|
|
64
|
+
export type VoiceSessionReplayOptions = {
|
|
65
|
+
evaluation?: VoiceTraceEvaluationOptions;
|
|
66
|
+
events?: StoredVoiceTraceEvent[];
|
|
67
|
+
redact?: VoiceTraceRedactionConfig;
|
|
68
|
+
sessionId: string;
|
|
69
|
+
store?: VoiceTraceEventStore;
|
|
70
|
+
title?: string;
|
|
71
|
+
};
|
|
72
|
+
export type VoiceSessionReplayHTMLHandlerOptions = Omit<VoiceSessionReplayOptions, 'sessionId'> & {
|
|
73
|
+
headers?: HeadersInit;
|
|
74
|
+
render?: (replay: VoiceSessionReplay) => string | Promise<string>;
|
|
75
|
+
};
|
|
76
|
+
export type VoiceSessionReplayRoutesOptions = VoiceSessionReplayHTMLHandlerOptions & {
|
|
77
|
+
htmlPath?: false | string;
|
|
78
|
+
name?: string;
|
|
79
|
+
path?: string;
|
|
80
|
+
};
|
|
81
|
+
export declare const summarizeVoiceSessionReplay: (options: VoiceSessionReplayOptions) => Promise<VoiceSessionReplay>;
|
|
82
|
+
export declare const summarizeVoiceSessions: (options?: VoiceSessionListOptions) => Promise<VoiceSessionListItem[]>;
|
|
83
|
+
export declare const renderVoiceSessionsHTML: (sessions: VoiceSessionListItem[]) => string;
|
|
84
|
+
export declare const createVoiceSessionsJSONHandler: (options?: VoiceSessionListOptions) => ({ query }: {
|
|
85
|
+
query?: Record<string, string | undefined>;
|
|
86
|
+
}) => Promise<VoiceSessionListItem[]>;
|
|
87
|
+
export declare const createVoiceSessionsHTMLHandler: (options?: VoiceSessionListHTMLHandlerOptions) => ({ query }: {
|
|
88
|
+
query?: Record<string, string | undefined>;
|
|
89
|
+
}) => Promise<Response>;
|
|
90
|
+
export declare const createVoiceSessionListRoutes: (options?: VoiceSessionListRoutesOptions) => Elysia<"", {
|
|
91
|
+
decorator: {};
|
|
92
|
+
store: {};
|
|
93
|
+
derive: {};
|
|
94
|
+
resolve: {};
|
|
95
|
+
}, {
|
|
96
|
+
typebox: {};
|
|
97
|
+
error: {};
|
|
98
|
+
}, {
|
|
99
|
+
schema: {};
|
|
100
|
+
standaloneSchema: {};
|
|
101
|
+
macro: {};
|
|
102
|
+
macroFn: {};
|
|
103
|
+
parser: {};
|
|
104
|
+
response: {};
|
|
105
|
+
}, {
|
|
106
|
+
[x: string]: {
|
|
107
|
+
get: {
|
|
108
|
+
body: unknown;
|
|
109
|
+
params: {};
|
|
110
|
+
query: unknown;
|
|
111
|
+
headers: unknown;
|
|
112
|
+
response: {
|
|
113
|
+
200: VoiceSessionListItem[];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}, {
|
|
118
|
+
derive: {};
|
|
119
|
+
resolve: {};
|
|
120
|
+
schema: {};
|
|
121
|
+
standaloneSchema: {};
|
|
122
|
+
response: {};
|
|
123
|
+
}, {
|
|
124
|
+
derive: {};
|
|
125
|
+
resolve: {};
|
|
126
|
+
schema: {};
|
|
127
|
+
standaloneSchema: {};
|
|
128
|
+
response: {};
|
|
129
|
+
}>;
|
|
130
|
+
export declare const createVoiceSessionReplayJSONHandler: (options: Omit<VoiceSessionReplayOptions, "sessionId">) => ({ params }: {
|
|
131
|
+
params: Record<string, string | undefined>;
|
|
132
|
+
}) => Promise<VoiceSessionReplay>;
|
|
133
|
+
export declare const createVoiceSessionReplayHTMLHandler: (options: VoiceSessionReplayHTMLHandlerOptions) => ({ params }: {
|
|
134
|
+
params: Record<string, string | undefined>;
|
|
135
|
+
}) => Promise<Response>;
|
|
136
|
+
export declare const createVoiceSessionReplayRoutes: (options: VoiceSessionReplayRoutesOptions) => Elysia<"", {
|
|
137
|
+
decorator: {};
|
|
138
|
+
store: {};
|
|
139
|
+
derive: {};
|
|
140
|
+
resolve: {};
|
|
141
|
+
}, {
|
|
142
|
+
typebox: {};
|
|
143
|
+
error: {};
|
|
144
|
+
}, {
|
|
145
|
+
schema: {};
|
|
146
|
+
standaloneSchema: {};
|
|
147
|
+
macro: {};
|
|
148
|
+
macroFn: {};
|
|
149
|
+
parser: {};
|
|
150
|
+
response: {};
|
|
151
|
+
}, {
|
|
152
|
+
[x: string]: {
|
|
153
|
+
get: {
|
|
154
|
+
body: unknown;
|
|
155
|
+
params: {};
|
|
156
|
+
query: unknown;
|
|
157
|
+
headers: unknown;
|
|
158
|
+
response: {
|
|
159
|
+
200: VoiceSessionReplay;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
}, {
|
|
164
|
+
derive: {};
|
|
165
|
+
resolve: {};
|
|
166
|
+
schema: {};
|
|
167
|
+
standaloneSchema: {};
|
|
168
|
+
response: {};
|
|
169
|
+
}, {
|
|
170
|
+
derive: {};
|
|
171
|
+
resolve: {};
|
|
172
|
+
schema: {};
|
|
173
|
+
standaloneSchema: {};
|
|
174
|
+
response: {};
|
|
175
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VoiceAppKitStatusClientOptions } from '../client/appKitStatus';
|
|
2
|
+
export declare const createVoiceAppKitStatus: (path?: string, options?: VoiceAppKitStatusClientOptions) => {
|
|
3
|
+
close: () => void;
|
|
4
|
+
getServerSnapshot: () => import("../client").VoiceAppKitStatusSnapshot;
|
|
5
|
+
getSnapshot: () => import("../client").VoiceAppKitStatusSnapshot;
|
|
6
|
+
refresh: () => Promise<import("..").VoiceAppKitStatusReport | undefined>;
|
|
7
|
+
subscribe: (listener: () => void) => () => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VoiceProviderStatusClientOptions } from '../client/providerStatus';
|
|
2
|
+
export declare const createVoiceProviderStatus: <TProvider extends string = string>(path?: string, options?: VoiceProviderStatusClientOptions) => {
|
|
3
|
+
close: () => void;
|
|
4
|
+
getServerSnapshot: () => import("../client").VoiceProviderStatusSnapshot<TProvider>;
|
|
5
|
+
getSnapshot: () => import("../client").VoiceProviderStatusSnapshot<TProvider>;
|
|
6
|
+
refresh: () => Promise<import("..").VoiceProviderHealthSummary<TProvider>[]>;
|
|
7
|
+
subscribe: (listener: () => void) => () => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VoiceWorkflowStatusClientOptions } from '../client/workflowStatus';
|
|
2
|
+
export declare const createVoiceWorkflowStatus: (path?: string, options?: VoiceWorkflowStatusClientOptions) => {
|
|
3
|
+
close: () => void;
|
|
4
|
+
getServerSnapshot: () => import("../client").VoiceWorkflowStatusSnapshot;
|
|
5
|
+
getSnapshot: () => import("../client").VoiceWorkflowStatusSnapshot;
|
|
6
|
+
refresh: () => Promise<import("..").VoiceScenarioEvalReport | undefined>;
|
|
7
|
+
subscribe: (listener: () => void) => () => void;
|
|
8
|
+
};
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
export { createVoiceAppKitStatus } from './createVoiceAppKitStatus';
|
|
1
2
|
export { createVoiceStream } from './createVoiceStream';
|
|
3
|
+
export { createVoiceProviderStatus } from './createVoiceProviderStatus';
|
|
4
|
+
export { createVoiceWorkflowStatus } from './createVoiceWorkflowStatus';
|
|
2
5
|
export { createVoiceController } from '../client/controller';
|
package/dist/svelte/index.js
CHANGED
|
@@ -69,6 +69,87 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
|
69
69
|
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
// src/client/appKitStatus.ts
|
|
73
|
+
var fetchVoiceAppKitStatus = async (path = "/app-kit/status", options = {}) => {
|
|
74
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
75
|
+
const response = await fetchImpl(path);
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(`Voice app kit status failed: HTTP ${response.status}`);
|
|
78
|
+
}
|
|
79
|
+
return await response.json();
|
|
80
|
+
};
|
|
81
|
+
var createVoiceAppKitStatusStore = (path = "/app-kit/status", options = {}) => {
|
|
82
|
+
const listeners = new Set;
|
|
83
|
+
let closed = false;
|
|
84
|
+
let timer;
|
|
85
|
+
let snapshot = {
|
|
86
|
+
error: null,
|
|
87
|
+
isLoading: false
|
|
88
|
+
};
|
|
89
|
+
const emit = () => {
|
|
90
|
+
for (const listener of listeners) {
|
|
91
|
+
listener();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const refresh = async () => {
|
|
95
|
+
if (closed) {
|
|
96
|
+
return snapshot.report;
|
|
97
|
+
}
|
|
98
|
+
snapshot = {
|
|
99
|
+
...snapshot,
|
|
100
|
+
error: null,
|
|
101
|
+
isLoading: true
|
|
102
|
+
};
|
|
103
|
+
emit();
|
|
104
|
+
try {
|
|
105
|
+
const report = await fetchVoiceAppKitStatus(path, options);
|
|
106
|
+
snapshot = {
|
|
107
|
+
error: null,
|
|
108
|
+
isLoading: false,
|
|
109
|
+
report,
|
|
110
|
+
updatedAt: Date.now()
|
|
111
|
+
};
|
|
112
|
+
emit();
|
|
113
|
+
return report;
|
|
114
|
+
} catch (error) {
|
|
115
|
+
snapshot = {
|
|
116
|
+
...snapshot,
|
|
117
|
+
error: error instanceof Error ? error.message : String(error),
|
|
118
|
+
isLoading: false
|
|
119
|
+
};
|
|
120
|
+
emit();
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const close = () => {
|
|
125
|
+
closed = true;
|
|
126
|
+
if (timer) {
|
|
127
|
+
clearInterval(timer);
|
|
128
|
+
timer = undefined;
|
|
129
|
+
}
|
|
130
|
+
listeners.clear();
|
|
131
|
+
};
|
|
132
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
133
|
+
timer = setInterval(() => {
|
|
134
|
+
refresh().catch(() => {});
|
|
135
|
+
}, options.intervalMs);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
close,
|
|
139
|
+
getServerSnapshot: () => snapshot,
|
|
140
|
+
getSnapshot: () => snapshot,
|
|
141
|
+
refresh,
|
|
142
|
+
subscribe: (listener) => {
|
|
143
|
+
listeners.add(listener);
|
|
144
|
+
return () => {
|
|
145
|
+
listeners.delete(listener);
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/svelte/createVoiceAppKitStatus.ts
|
|
152
|
+
var createVoiceAppKitStatus = (path = "/app-kit/status", options = {}) => createVoiceAppKitStatusStore(path, options);
|
|
72
153
|
// src/client/actions.ts
|
|
73
154
|
var normalizeErrorMessage = (value) => {
|
|
74
155
|
if (typeof value === "string" && value.trim()) {
|
|
@@ -117,6 +198,12 @@ var serverMessageToAction = (message) => {
|
|
|
117
198
|
sessionId: message.sessionId,
|
|
118
199
|
type: "complete"
|
|
119
200
|
};
|
|
201
|
+
case "call_lifecycle":
|
|
202
|
+
return {
|
|
203
|
+
event: message.event,
|
|
204
|
+
sessionId: message.sessionId,
|
|
205
|
+
type: "call_lifecycle"
|
|
206
|
+
};
|
|
120
207
|
case "error":
|
|
121
208
|
return {
|
|
122
209
|
message: normalizeErrorMessage(message.message),
|
|
@@ -160,7 +247,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
|
|
|
160
247
|
var noop = () => {};
|
|
161
248
|
var noopUnsubscribe = () => noop;
|
|
162
249
|
var NOOP_CONNECTION = {
|
|
163
|
-
|
|
250
|
+
callControl: noop,
|
|
164
251
|
close: noop,
|
|
165
252
|
endTurn: noop,
|
|
166
253
|
getReadyState: () => WS_CLOSED,
|
|
@@ -168,6 +255,7 @@ var NOOP_CONNECTION = {
|
|
|
168
255
|
getSessionId: () => "",
|
|
169
256
|
send: noop,
|
|
170
257
|
sendAudio: noop,
|
|
258
|
+
start: () => {},
|
|
171
259
|
subscribe: noopUnsubscribe
|
|
172
260
|
};
|
|
173
261
|
var createSessionId = () => crypto.randomUUID();
|
|
@@ -189,6 +277,7 @@ var isVoiceServerMessage = (value) => {
|
|
|
189
277
|
switch (value.type) {
|
|
190
278
|
case "audio":
|
|
191
279
|
case "assistant":
|
|
280
|
+
case "call_lifecycle":
|
|
192
281
|
case "complete":
|
|
193
282
|
case "error":
|
|
194
283
|
case "final":
|
|
@@ -329,6 +418,12 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
329
418
|
const endTurn = () => {
|
|
330
419
|
send({ type: "end_turn" });
|
|
331
420
|
};
|
|
421
|
+
const callControl = (message) => {
|
|
422
|
+
send({
|
|
423
|
+
...message,
|
|
424
|
+
type: "call_control"
|
|
425
|
+
});
|
|
426
|
+
};
|
|
332
427
|
const close = () => {
|
|
333
428
|
clearTimers();
|
|
334
429
|
if (state.ws) {
|
|
@@ -346,7 +441,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
346
441
|
};
|
|
347
442
|
connect();
|
|
348
443
|
return {
|
|
349
|
-
|
|
444
|
+
callControl,
|
|
350
445
|
close,
|
|
351
446
|
endTurn,
|
|
352
447
|
getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
|
|
@@ -354,6 +449,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
354
449
|
getSessionId: () => state.sessionId,
|
|
355
450
|
send,
|
|
356
451
|
sendAudio,
|
|
452
|
+
start,
|
|
357
453
|
subscribe
|
|
358
454
|
};
|
|
359
455
|
};
|
|
@@ -362,6 +458,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
362
458
|
var createInitialState = () => ({
|
|
363
459
|
assistantAudio: [],
|
|
364
460
|
assistantTexts: [],
|
|
461
|
+
call: null,
|
|
365
462
|
error: null,
|
|
366
463
|
isConnected: false,
|
|
367
464
|
scenarioId: null,
|
|
@@ -405,6 +502,20 @@ var createVoiceStreamStore = () => {
|
|
|
405
502
|
status: "completed"
|
|
406
503
|
};
|
|
407
504
|
break;
|
|
505
|
+
case "call_lifecycle":
|
|
506
|
+
state = {
|
|
507
|
+
...state,
|
|
508
|
+
call: {
|
|
509
|
+
...state.call,
|
|
510
|
+
disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
|
|
511
|
+
endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
|
|
512
|
+
events: [...state.call?.events ?? [], action.event],
|
|
513
|
+
lastEventAt: action.event.at,
|
|
514
|
+
startedAt: state.call?.startedAt ?? action.event.at
|
|
515
|
+
},
|
|
516
|
+
sessionId: action.sessionId
|
|
517
|
+
};
|
|
518
|
+
break;
|
|
408
519
|
case "connected":
|
|
409
520
|
state = {
|
|
410
521
|
...state,
|
|
@@ -491,6 +602,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
491
602
|
}
|
|
492
603
|
});
|
|
493
604
|
return {
|
|
605
|
+
callControl(message) {
|
|
606
|
+
connection.callControl(message);
|
|
607
|
+
},
|
|
494
608
|
close() {
|
|
495
609
|
unsubscribeConnection();
|
|
496
610
|
connection.close();
|
|
@@ -534,6 +648,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
534
648
|
get assistantAudio() {
|
|
535
649
|
return store.getSnapshot().assistantAudio;
|
|
536
650
|
},
|
|
651
|
+
get call() {
|
|
652
|
+
return store.getSnapshot().call;
|
|
653
|
+
},
|
|
537
654
|
sendAudio(audio) {
|
|
538
655
|
connection.sendAudio(audio);
|
|
539
656
|
},
|
|
@@ -548,6 +665,169 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
548
665
|
|
|
549
666
|
// src/svelte/createVoiceStream.ts
|
|
550
667
|
var createVoiceStream2 = (path, options = {}) => createVoiceStream(path, options);
|
|
668
|
+
// src/client/providerStatus.ts
|
|
669
|
+
var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
|
|
670
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
671
|
+
const response = await fetchImpl(path);
|
|
672
|
+
if (!response.ok) {
|
|
673
|
+
throw new Error(`Voice provider status failed: HTTP ${response.status}`);
|
|
674
|
+
}
|
|
675
|
+
return await response.json();
|
|
676
|
+
};
|
|
677
|
+
var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
|
|
678
|
+
const listeners = new Set;
|
|
679
|
+
let closed = false;
|
|
680
|
+
let timer;
|
|
681
|
+
let snapshot = {
|
|
682
|
+
error: null,
|
|
683
|
+
isLoading: false,
|
|
684
|
+
providers: []
|
|
685
|
+
};
|
|
686
|
+
const emit = () => {
|
|
687
|
+
for (const listener of listeners) {
|
|
688
|
+
listener();
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
const refresh = async () => {
|
|
692
|
+
if (closed) {
|
|
693
|
+
return snapshot.providers;
|
|
694
|
+
}
|
|
695
|
+
snapshot = {
|
|
696
|
+
...snapshot,
|
|
697
|
+
error: null,
|
|
698
|
+
isLoading: true
|
|
699
|
+
};
|
|
700
|
+
emit();
|
|
701
|
+
try {
|
|
702
|
+
const providers = await fetchVoiceProviderStatus(path, options);
|
|
703
|
+
snapshot = {
|
|
704
|
+
error: null,
|
|
705
|
+
isLoading: false,
|
|
706
|
+
providers,
|
|
707
|
+
updatedAt: Date.now()
|
|
708
|
+
};
|
|
709
|
+
emit();
|
|
710
|
+
return providers;
|
|
711
|
+
} catch (error) {
|
|
712
|
+
snapshot = {
|
|
713
|
+
...snapshot,
|
|
714
|
+
error: error instanceof Error ? error.message : String(error),
|
|
715
|
+
isLoading: false
|
|
716
|
+
};
|
|
717
|
+
emit();
|
|
718
|
+
throw error;
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
const close = () => {
|
|
722
|
+
closed = true;
|
|
723
|
+
if (timer) {
|
|
724
|
+
clearInterval(timer);
|
|
725
|
+
timer = undefined;
|
|
726
|
+
}
|
|
727
|
+
listeners.clear();
|
|
728
|
+
};
|
|
729
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
730
|
+
timer = setInterval(() => {
|
|
731
|
+
refresh().catch(() => {});
|
|
732
|
+
}, options.intervalMs);
|
|
733
|
+
}
|
|
734
|
+
return {
|
|
735
|
+
close,
|
|
736
|
+
getServerSnapshot: () => snapshot,
|
|
737
|
+
getSnapshot: () => snapshot,
|
|
738
|
+
refresh,
|
|
739
|
+
subscribe: (listener) => {
|
|
740
|
+
listeners.add(listener);
|
|
741
|
+
return () => {
|
|
742
|
+
listeners.delete(listener);
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
// src/svelte/createVoiceProviderStatus.ts
|
|
749
|
+
var createVoiceProviderStatus = (path = "/api/provider-status", options = {}) => createVoiceProviderStatusStore(path, options);
|
|
750
|
+
// src/client/workflowStatus.ts
|
|
751
|
+
var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
|
|
752
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
753
|
+
const response = await fetchImpl(path);
|
|
754
|
+
if (!response.ok) {
|
|
755
|
+
throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
|
|
756
|
+
}
|
|
757
|
+
return await response.json();
|
|
758
|
+
};
|
|
759
|
+
var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
|
|
760
|
+
const listeners = new Set;
|
|
761
|
+
let closed = false;
|
|
762
|
+
let timer;
|
|
763
|
+
let snapshot = {
|
|
764
|
+
error: null,
|
|
765
|
+
isLoading: false
|
|
766
|
+
};
|
|
767
|
+
const emit = () => {
|
|
768
|
+
for (const listener of listeners) {
|
|
769
|
+
listener();
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
const refresh = async () => {
|
|
773
|
+
if (closed) {
|
|
774
|
+
return snapshot.report;
|
|
775
|
+
}
|
|
776
|
+
snapshot = {
|
|
777
|
+
...snapshot,
|
|
778
|
+
error: null,
|
|
779
|
+
isLoading: true
|
|
780
|
+
};
|
|
781
|
+
emit();
|
|
782
|
+
try {
|
|
783
|
+
const report = await fetchVoiceWorkflowStatus(path, options);
|
|
784
|
+
snapshot = {
|
|
785
|
+
error: null,
|
|
786
|
+
isLoading: false,
|
|
787
|
+
report,
|
|
788
|
+
updatedAt: Date.now()
|
|
789
|
+
};
|
|
790
|
+
emit();
|
|
791
|
+
return report;
|
|
792
|
+
} catch (error) {
|
|
793
|
+
snapshot = {
|
|
794
|
+
...snapshot,
|
|
795
|
+
error: error instanceof Error ? error.message : String(error),
|
|
796
|
+
isLoading: false
|
|
797
|
+
};
|
|
798
|
+
emit();
|
|
799
|
+
throw error;
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
const close = () => {
|
|
803
|
+
closed = true;
|
|
804
|
+
if (timer) {
|
|
805
|
+
clearInterval(timer);
|
|
806
|
+
timer = undefined;
|
|
807
|
+
}
|
|
808
|
+
listeners.clear();
|
|
809
|
+
};
|
|
810
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
811
|
+
timer = setInterval(() => {
|
|
812
|
+
refresh().catch(() => {});
|
|
813
|
+
}, options.intervalMs);
|
|
814
|
+
}
|
|
815
|
+
return {
|
|
816
|
+
close,
|
|
817
|
+
getServerSnapshot: () => snapshot,
|
|
818
|
+
getSnapshot: () => snapshot,
|
|
819
|
+
refresh,
|
|
820
|
+
subscribe: (listener) => {
|
|
821
|
+
listeners.add(listener);
|
|
822
|
+
return () => {
|
|
823
|
+
listeners.delete(listener);
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
// src/svelte/createVoiceWorkflowStatus.ts
|
|
830
|
+
var createVoiceWorkflowStatus = (path = "/evals/scenarios/json", options = {}) => createVoiceWorkflowStatusStore(path, options);
|
|
551
831
|
// src/client/htmx.ts
|
|
552
832
|
var DEFAULT_EVENT_NAME = "voice-refresh";
|
|
553
833
|
var DEFAULT_QUERY_PARAM = "sessionId";
|
|
@@ -1010,6 +1290,7 @@ var resolveVoiceRuntimePreset = (name = "default") => {
|
|
|
1010
1290
|
var createInitialState2 = (stream) => ({
|
|
1011
1291
|
assistantAudio: [...stream.assistantAudio],
|
|
1012
1292
|
assistantTexts: [...stream.assistantTexts],
|
|
1293
|
+
call: stream.call,
|
|
1013
1294
|
error: stream.error,
|
|
1014
1295
|
isConnected: stream.isConnected,
|
|
1015
1296
|
isRecording: false,
|
|
@@ -1039,6 +1320,7 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1039
1320
|
...state,
|
|
1040
1321
|
assistantAudio: [...stream.assistantAudio],
|
|
1041
1322
|
assistantTexts: [...stream.assistantTexts],
|
|
1323
|
+
call: stream.call,
|
|
1042
1324
|
error: stream.error,
|
|
1043
1325
|
isConnected: stream.isConnected,
|
|
1044
1326
|
partial: stream.partial,
|
|
@@ -1116,6 +1398,7 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1116
1398
|
bindHTMX(bindingOptions) {
|
|
1117
1399
|
return bindVoiceHTMX(stream, bindingOptions);
|
|
1118
1400
|
},
|
|
1401
|
+
callControl: (message) => stream.callControl(message),
|
|
1119
1402
|
close,
|
|
1120
1403
|
endTurn: () => stream.endTurn(),
|
|
1121
1404
|
get error() {
|
|
@@ -1168,10 +1451,16 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1168
1451
|
},
|
|
1169
1452
|
get assistantAudio() {
|
|
1170
1453
|
return state.assistantAudio;
|
|
1454
|
+
},
|
|
1455
|
+
get call() {
|
|
1456
|
+
return state.call;
|
|
1171
1457
|
}
|
|
1172
1458
|
};
|
|
1173
1459
|
};
|
|
1174
1460
|
export {
|
|
1461
|
+
createVoiceWorkflowStatus,
|
|
1175
1462
|
createVoiceStream2 as createVoiceStream,
|
|
1176
|
-
|
|
1463
|
+
createVoiceProviderStatus,
|
|
1464
|
+
createVoiceController,
|
|
1465
|
+
createVoiceAppKitStatus
|
|
1177
1466
|
};
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export * from './benchmark';
|
|
|
3
3
|
export * from './corrected';
|
|
4
4
|
export * from './duplex';
|
|
5
5
|
export * from './fixtures';
|
|
6
|
+
export * from './ioProviderSimulator';
|
|
7
|
+
export * from './providerSimulator';
|
|
6
8
|
export * from './resilience';
|
|
7
9
|
export * from './review';
|
|
8
10
|
export * from './sessionBenchmark';
|