@tanstack/ai-client 0.18.3 → 0.18.4
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/esm/realtime-types.d.ts +2 -42
- package/package.json +2 -2
- package/src/realtime-types.ts +6 -72
|
@@ -1,45 +1,5 @@
|
|
|
1
|
-
import { AnyClientTool,
|
|
2
|
-
|
|
3
|
-
* Adapter interface for connecting to realtime providers.
|
|
4
|
-
* Each provider (OpenAI, ElevenLabs, etc.) implements this interface.
|
|
5
|
-
*/
|
|
6
|
-
export interface RealtimeAdapter {
|
|
7
|
-
/** Provider identifier */
|
|
8
|
-
provider: string;
|
|
9
|
-
/**
|
|
10
|
-
* Create a connection using the provided token
|
|
11
|
-
* @param token - The ephemeral token from the server
|
|
12
|
-
* @param clientTools - Optional client-side tools to register with the provider
|
|
13
|
-
* @returns A connection instance
|
|
14
|
-
*/
|
|
15
|
-
connect: (token: RealtimeToken, clientTools?: ReadonlyArray<AnyClientTool>) => Promise<RealtimeConnection>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Connection interface representing an active realtime session.
|
|
19
|
-
* Handles audio I/O, events, and session management.
|
|
20
|
-
*/
|
|
21
|
-
export interface RealtimeConnection {
|
|
22
|
-
/** Disconnect from the realtime session */
|
|
23
|
-
disconnect: () => Promise<void>;
|
|
24
|
-
/** Start capturing audio from the microphone */
|
|
25
|
-
startAudioCapture: () => Promise<void>;
|
|
26
|
-
/** Stop capturing audio */
|
|
27
|
-
stopAudioCapture: () => void;
|
|
28
|
-
/** Send a text message (fallback for when voice isn't available) */
|
|
29
|
-
sendText: (text: string) => void;
|
|
30
|
-
/** Send an image to the conversation */
|
|
31
|
-
sendImage: (imageData: string, mimeType: string) => void;
|
|
32
|
-
/** Send a tool execution result back to the provider */
|
|
33
|
-
sendToolResult: (callId: string, result: string) => void;
|
|
34
|
-
/** Update session configuration */
|
|
35
|
-
updateSession: (config: Partial<RealtimeSessionConfig>) => void;
|
|
36
|
-
/** Interrupt the current response */
|
|
37
|
-
interrupt: () => void;
|
|
38
|
-
/** Subscribe to connection events */
|
|
39
|
-
on: <TEvent extends RealtimeEvent>(event: TEvent, handler: RealtimeEventHandler<TEvent>) => () => void;
|
|
40
|
-
/** Get audio visualization data */
|
|
41
|
-
getAudioVisualization: () => AudioVisualization;
|
|
42
|
-
}
|
|
1
|
+
import { AnyClientTool, RealtimeAdapter, RealtimeMessage, RealtimeMode, RealtimeStatus, RealtimeToken } from '@tanstack/ai/client';
|
|
2
|
+
export type { RealtimeAdapter, RealtimeConnection } from '@tanstack/ai/client';
|
|
43
3
|
/**
|
|
44
4
|
* Options for the RealtimeClient
|
|
45
5
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-client",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.4",
|
|
4
4
|
"description": "Framework-agnostic headless client for TanStack AI chat, realtime sessions, streaming transports, and media generations.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"src"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@tanstack/ai": "0.
|
|
52
|
+
"@tanstack/ai": "0.35.0",
|
|
53
53
|
"@tanstack/ai-event-client": "0.6.6"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
package/src/realtime-types.ts
CHANGED
|
@@ -1,83 +1,17 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AnyClientTool,
|
|
3
|
-
|
|
4
|
-
RealtimeEvent,
|
|
5
|
-
RealtimeEventHandler,
|
|
3
|
+
RealtimeAdapter,
|
|
6
4
|
RealtimeMessage,
|
|
7
5
|
RealtimeMode,
|
|
8
|
-
RealtimeSessionConfig,
|
|
9
6
|
RealtimeStatus,
|
|
10
7
|
RealtimeToken,
|
|
11
8
|
} from '@tanstack/ai/client'
|
|
12
9
|
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* Adapter interface for connecting to realtime providers.
|
|
19
|
-
* Each provider (OpenAI, ElevenLabs, etc.) implements this interface.
|
|
20
|
-
*/
|
|
21
|
-
export interface RealtimeAdapter {
|
|
22
|
-
/** Provider identifier */
|
|
23
|
-
provider: string
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Create a connection using the provided token
|
|
27
|
-
* @param token - The ephemeral token from the server
|
|
28
|
-
* @param clientTools - Optional client-side tools to register with the provider
|
|
29
|
-
* @returns A connection instance
|
|
30
|
-
*/
|
|
31
|
-
connect: (
|
|
32
|
-
token: RealtimeToken,
|
|
33
|
-
clientTools?: ReadonlyArray<AnyClientTool>,
|
|
34
|
-
) => Promise<RealtimeConnection>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Connection interface representing an active realtime session.
|
|
39
|
-
* Handles audio I/O, events, and session management.
|
|
40
|
-
*/
|
|
41
|
-
export interface RealtimeConnection {
|
|
42
|
-
// Lifecycle
|
|
43
|
-
/** Disconnect from the realtime session */
|
|
44
|
-
disconnect: () => Promise<void>
|
|
45
|
-
|
|
46
|
-
// Audio I/O
|
|
47
|
-
/** Start capturing audio from the microphone */
|
|
48
|
-
startAudioCapture: () => Promise<void>
|
|
49
|
-
/** Stop capturing audio */
|
|
50
|
-
stopAudioCapture: () => void
|
|
51
|
-
|
|
52
|
-
// Text input
|
|
53
|
-
/** Send a text message (fallback for when voice isn't available) */
|
|
54
|
-
sendText: (text: string) => void
|
|
55
|
-
|
|
56
|
-
// Image input
|
|
57
|
-
/** Send an image to the conversation */
|
|
58
|
-
sendImage: (imageData: string, mimeType: string) => void
|
|
59
|
-
|
|
60
|
-
// Tool results
|
|
61
|
-
/** Send a tool execution result back to the provider */
|
|
62
|
-
sendToolResult: (callId: string, result: string) => void
|
|
63
|
-
|
|
64
|
-
// Session management
|
|
65
|
-
/** Update session configuration */
|
|
66
|
-
updateSession: (config: Partial<RealtimeSessionConfig>) => void
|
|
67
|
-
/** Interrupt the current response */
|
|
68
|
-
interrupt: () => void
|
|
69
|
-
|
|
70
|
-
// Events
|
|
71
|
-
/** Subscribe to connection events */
|
|
72
|
-
on: <TEvent extends RealtimeEvent>(
|
|
73
|
-
event: TEvent,
|
|
74
|
-
handler: RealtimeEventHandler<TEvent>,
|
|
75
|
-
) => () => void
|
|
76
|
-
|
|
77
|
-
// Audio visualization
|
|
78
|
-
/** Get audio visualization data */
|
|
79
|
-
getAudioVisualization: () => AudioVisualization
|
|
80
|
-
}
|
|
10
|
+
// The realtime adapter contract lives in `@tanstack/ai` (the shared layer both
|
|
11
|
+
// providers and this client depend on) so provider packages don't need to
|
|
12
|
+
// depend on `@tanstack/ai-client`. Re-exported here for backwards compatibility
|
|
13
|
+
// — `import { RealtimeAdapter } from '@tanstack/ai-client'` keeps working.
|
|
14
|
+
export type { RealtimeAdapter, RealtimeConnection } from '@tanstack/ai/client'
|
|
81
15
|
|
|
82
16
|
// ============================================================================
|
|
83
17
|
// Client Options
|