@voice-session/web 0.1.0
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/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/index.cjs +41 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/licenses/APACHE-2.0.txt +202 -0
- package/licenses/NOTICE +7 -0
- package/package.json +45 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
type AgentState = "connecting" | "listening" | "thinking" | "speaking" | "ended";
|
|
2
|
+
type TranscriptRole = "user" | "assistant";
|
|
3
|
+
type TranscriptEvent = {
|
|
4
|
+
role: TranscriptRole;
|
|
5
|
+
text: string;
|
|
6
|
+
final: boolean;
|
|
7
|
+
};
|
|
8
|
+
type RealtimeSessionEvents = {
|
|
9
|
+
transcript: TranscriptEvent;
|
|
10
|
+
agent_state: AgentState;
|
|
11
|
+
ended: undefined;
|
|
12
|
+
error: Error;
|
|
13
|
+
level: number;
|
|
14
|
+
};
|
|
15
|
+
type TokenSessionOptions = {
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
clientToken: string;
|
|
18
|
+
};
|
|
19
|
+
type DirectSessionOptions = {
|
|
20
|
+
url: string;
|
|
21
|
+
token: string;
|
|
22
|
+
};
|
|
23
|
+
type RealtimeSessionOptions = TokenSessionOptions | DirectSessionOptions;
|
|
24
|
+
type StartOptions = {
|
|
25
|
+
microphone?: boolean;
|
|
26
|
+
};
|
|
27
|
+
type EventHandler<K extends keyof RealtimeSessionEvents> = (payload: RealtimeSessionEvents[K]) => void;
|
|
28
|
+
|
|
29
|
+
declare class RealtimeSession {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(options: RealtimeSessionOptions);
|
|
32
|
+
on<K extends keyof RealtimeSessionEvents>(event: K, handler: EventHandler<K>): () => void;
|
|
33
|
+
off<K extends keyof RealtimeSessionEvents>(event: K, handler: EventHandler<K>): void;
|
|
34
|
+
start(options?: StartOptions): Promise<void>;
|
|
35
|
+
end(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { type AgentState, type DirectSessionOptions, type EventHandler, RealtimeSession, type RealtimeSessionEvents, type RealtimeSessionOptions, type StartOptions, type TokenSessionOptions, type TranscriptEvent, type TranscriptRole };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
type AgentState = "connecting" | "listening" | "thinking" | "speaking" | "ended";
|
|
2
|
+
type TranscriptRole = "user" | "assistant";
|
|
3
|
+
type TranscriptEvent = {
|
|
4
|
+
role: TranscriptRole;
|
|
5
|
+
text: string;
|
|
6
|
+
final: boolean;
|
|
7
|
+
};
|
|
8
|
+
type RealtimeSessionEvents = {
|
|
9
|
+
transcript: TranscriptEvent;
|
|
10
|
+
agent_state: AgentState;
|
|
11
|
+
ended: undefined;
|
|
12
|
+
error: Error;
|
|
13
|
+
level: number;
|
|
14
|
+
};
|
|
15
|
+
type TokenSessionOptions = {
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
clientToken: string;
|
|
18
|
+
};
|
|
19
|
+
type DirectSessionOptions = {
|
|
20
|
+
url: string;
|
|
21
|
+
token: string;
|
|
22
|
+
};
|
|
23
|
+
type RealtimeSessionOptions = TokenSessionOptions | DirectSessionOptions;
|
|
24
|
+
type StartOptions = {
|
|
25
|
+
microphone?: boolean;
|
|
26
|
+
};
|
|
27
|
+
type EventHandler<K extends keyof RealtimeSessionEvents> = (payload: RealtimeSessionEvents[K]) => void;
|
|
28
|
+
|
|
29
|
+
declare class RealtimeSession {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(options: RealtimeSessionOptions);
|
|
32
|
+
on<K extends keyof RealtimeSessionEvents>(event: K, handler: EventHandler<K>): () => void;
|
|
33
|
+
off<K extends keyof RealtimeSessionEvents>(event: K, handler: EventHandler<K>): void;
|
|
34
|
+
start(options?: StartOptions): Promise<void>;
|
|
35
|
+
end(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { type AgentState, type DirectSessionOptions, type EventHandler, RealtimeSession, type RealtimeSessionEvents, type RealtimeSessionOptions, type StartOptions, type TokenSessionOptions, type TranscriptEvent, type TranscriptRole };
|