@pinecall/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.
@@ -0,0 +1,100 @@
1
+ import { V as VoiceSessionOptions, a as VoiceSessionState } from '../types-CKfTJcH8.cjs';
2
+ export { C as CallPhase, S as SessionStatus, T as ToolCallEvent, b as ToolResultEvent, c as ToolUI, d as TranscriptMessage } from '../types-CKfTJcH8.cjs';
3
+
4
+ /**
5
+ * VoiceSession — Framework-agnostic WebRTC voice client for Pinecall agents.
6
+ *
7
+ * Extends EventTarget. Two ways to consume:
8
+ * 1. session.subscribe(cb) + session.getState() — for React useSyncExternalStore
9
+ * 2. session.addEventListener('status' | 'phase' | 'message' | 'error' | 'event' | 'change', cb)
10
+ *
11
+ * WebRTC flow: token → ICE → mic → PeerConnection → DataChannel → SDP offer/answer
12
+ */
13
+
14
+ declare class VoiceSession extends EventTarget {
15
+ private opts;
16
+ private state;
17
+ private listeners;
18
+ private pc;
19
+ private stream;
20
+ private audio;
21
+ private dc;
22
+ private timer;
23
+ private ping;
24
+ private startedAt;
25
+ private botWords;
26
+ constructor(opts: VoiceSessionOptions);
27
+ /** Read-only snapshot of current state (stable reference until next mutation). */
28
+ getState(): Readonly<VoiceSessionState>;
29
+ /** Subscribe to ANY state change (for React useSyncExternalStore). */
30
+ subscribe(listener: () => void): () => void;
31
+ private setState;
32
+ private setMessages;
33
+ private cleanup;
34
+ connect(): Promise<void>;
35
+ private handleDataChannelMessage;
36
+ disconnect(): void;
37
+ toggleMute(): void;
38
+ setMuted(muted: boolean): void;
39
+ /**
40
+ * Send a configuration update via DataChannel during an active call.
41
+ * Use this for mid-call language/voice/STT switching.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * session.configure({ voice: "coral", stt: "deepgram", language: "es" });
46
+ * ```
47
+ */
48
+ configure(config: Record<string, unknown>): void;
49
+ /**
50
+ * Inject text into the conversation as if the user spoke it.
51
+ *
52
+ * Use this for click-based interactions in tool UIs (e.g., selecting a
53
+ * calendar slot). The server routes the text to the LLM, producing the
54
+ * same effect as the user speaking.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * session.sendText("I'd like the 10:00 AM slot");
59
+ * ```
60
+ */
61
+ sendText(text: string): void;
62
+ /**
63
+ * Remove a tool UI entry from state.
64
+ *
65
+ * Call this after the user interacts with a tool UI (e.g., selects a slot)
66
+ * to dismiss the rendered component from the transcript.
67
+ */
68
+ dismissTool(toolCallId: string): void;
69
+ /**
70
+ * Set or clear a keyed context block in the LLM system prompt.
71
+ *
72
+ * Use this to inject dynamic UI state (form data, selections, etc.)
73
+ * into the agent's prompt so it can see what the user is doing on screen.
74
+ * Each key is a named section — setting the same key replaces its value.
75
+ * Pass `null` to remove a context key.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * // Inject form state so the agent sees what's filled
80
+ * session.setContext("contact_form", JSON.stringify({
81
+ * name: "John",
82
+ * email: "john@example.com",
83
+ * phone: "",
84
+ * }));
85
+ *
86
+ * // Clear when form is submitted
87
+ * session.setContext("contact_form", null);
88
+ * ```
89
+ */
90
+ setContext(key: string, value: string | null): void;
91
+ /**
92
+ * Update session options before the next `connect()` call.
93
+ * Has no effect on an already-connected session — use `configure()` for that.
94
+ */
95
+ updateOptions(patch: Partial<Pick<VoiceSessionOptions, "config" | "metadata">>): void;
96
+ /** Tear down the session and clear subscribers. After this, do not reuse. */
97
+ destroy(): void;
98
+ }
99
+
100
+ export { VoiceSession, VoiceSessionOptions, VoiceSessionState };
@@ -0,0 +1,100 @@
1
+ import { V as VoiceSessionOptions, a as VoiceSessionState } from '../types-CKfTJcH8.js';
2
+ export { C as CallPhase, S as SessionStatus, T as ToolCallEvent, b as ToolResultEvent, c as ToolUI, d as TranscriptMessage } from '../types-CKfTJcH8.js';
3
+
4
+ /**
5
+ * VoiceSession — Framework-agnostic WebRTC voice client for Pinecall agents.
6
+ *
7
+ * Extends EventTarget. Two ways to consume:
8
+ * 1. session.subscribe(cb) + session.getState() — for React useSyncExternalStore
9
+ * 2. session.addEventListener('status' | 'phase' | 'message' | 'error' | 'event' | 'change', cb)
10
+ *
11
+ * WebRTC flow: token → ICE → mic → PeerConnection → DataChannel → SDP offer/answer
12
+ */
13
+
14
+ declare class VoiceSession extends EventTarget {
15
+ private opts;
16
+ private state;
17
+ private listeners;
18
+ private pc;
19
+ private stream;
20
+ private audio;
21
+ private dc;
22
+ private timer;
23
+ private ping;
24
+ private startedAt;
25
+ private botWords;
26
+ constructor(opts: VoiceSessionOptions);
27
+ /** Read-only snapshot of current state (stable reference until next mutation). */
28
+ getState(): Readonly<VoiceSessionState>;
29
+ /** Subscribe to ANY state change (for React useSyncExternalStore). */
30
+ subscribe(listener: () => void): () => void;
31
+ private setState;
32
+ private setMessages;
33
+ private cleanup;
34
+ connect(): Promise<void>;
35
+ private handleDataChannelMessage;
36
+ disconnect(): void;
37
+ toggleMute(): void;
38
+ setMuted(muted: boolean): void;
39
+ /**
40
+ * Send a configuration update via DataChannel during an active call.
41
+ * Use this for mid-call language/voice/STT switching.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * session.configure({ voice: "coral", stt: "deepgram", language: "es" });
46
+ * ```
47
+ */
48
+ configure(config: Record<string, unknown>): void;
49
+ /**
50
+ * Inject text into the conversation as if the user spoke it.
51
+ *
52
+ * Use this for click-based interactions in tool UIs (e.g., selecting a
53
+ * calendar slot). The server routes the text to the LLM, producing the
54
+ * same effect as the user speaking.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * session.sendText("I'd like the 10:00 AM slot");
59
+ * ```
60
+ */
61
+ sendText(text: string): void;
62
+ /**
63
+ * Remove a tool UI entry from state.
64
+ *
65
+ * Call this after the user interacts with a tool UI (e.g., selects a slot)
66
+ * to dismiss the rendered component from the transcript.
67
+ */
68
+ dismissTool(toolCallId: string): void;
69
+ /**
70
+ * Set or clear a keyed context block in the LLM system prompt.
71
+ *
72
+ * Use this to inject dynamic UI state (form data, selections, etc.)
73
+ * into the agent's prompt so it can see what the user is doing on screen.
74
+ * Each key is a named section — setting the same key replaces its value.
75
+ * Pass `null` to remove a context key.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * // Inject form state so the agent sees what's filled
80
+ * session.setContext("contact_form", JSON.stringify({
81
+ * name: "John",
82
+ * email: "john@example.com",
83
+ * phone: "",
84
+ * }));
85
+ *
86
+ * // Clear when form is submitted
87
+ * session.setContext("contact_form", null);
88
+ * ```
89
+ */
90
+ setContext(key: string, value: string | null): void;
91
+ /**
92
+ * Update session options before the next `connect()` call.
93
+ * Has no effect on an already-connected session — use `configure()` for that.
94
+ */
95
+ updateOptions(patch: Partial<Pick<VoiceSessionOptions, "config" | "metadata">>): void;
96
+ /** Tear down the session and clear subscribers. After this, do not reuse. */
97
+ destroy(): void;
98
+ }
99
+
100
+ export { VoiceSession, VoiceSessionOptions, VoiceSessionState };
@@ -0,0 +1,3 @@
1
+ export { VoiceSession } from '../chunk-LPRH4KOL.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}