@telnyx/ai-agent-lib 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/README.md +3 -0
- package/dist/agent-state.d.ts +3 -0
- package/dist/audio-stream-monitor.d.ts +11 -0
- package/dist/client.d.ts +27 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4795 -0
- package/dist/message.d.ts +45 -0
- package/dist/react/agent-state-auto-update.d.ts +1 -0
- package/dist/react/client-context.d.ts +5 -0
- package/dist/react/connection-state-auto-update.d.ts +1 -0
- package/dist/react/conversation-auto-update.d.ts +1 -0
- package/dist/react/transcript-auto-update.d.ts +1 -0
- package/dist/react/use-agent-state.d.ts +3 -0
- package/dist/react/use-client-connection-state.d.ts +3 -0
- package/dist/react/use-client.d.ts +1 -0
- package/dist/react/use-conversation.d.ts +3 -0
- package/dist/react/use-transcript.d.ts +3 -0
- package/dist/transcript.d.ts +9 -0
- package/dist/types.d.ts +19 -0
- package/dist/util.d.ts +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type TranscriptMessage = {
|
|
2
|
+
id: string;
|
|
3
|
+
jsonrpc: "2.0";
|
|
4
|
+
method: "ai_conversation";
|
|
5
|
+
params: {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare function isTranscriptMessage(msg: unknown): msg is TranscriptMessage;
|
|
10
|
+
export type ResponseTextDelta = {
|
|
11
|
+
id: string;
|
|
12
|
+
jsonrpc: "2.0";
|
|
13
|
+
method: "ai_conversation";
|
|
14
|
+
params: {
|
|
15
|
+
content_index: number;
|
|
16
|
+
delta: string;
|
|
17
|
+
item_id: string;
|
|
18
|
+
output_index: number;
|
|
19
|
+
response_id: string;
|
|
20
|
+
type: "response.text.delta";
|
|
21
|
+
};
|
|
22
|
+
voice_sdk_id: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function isResponseTextDelta(message: unknown): message is ResponseTextDelta;
|
|
25
|
+
export type ConversationItemCreatedMessage = {
|
|
26
|
+
id: string;
|
|
27
|
+
jsonrpc: "2.0";
|
|
28
|
+
method: "ai_conversation";
|
|
29
|
+
params: {
|
|
30
|
+
item: {
|
|
31
|
+
content: {
|
|
32
|
+
transcript: string;
|
|
33
|
+
type: "input_audio";
|
|
34
|
+
}[];
|
|
35
|
+
id: string;
|
|
36
|
+
role: string;
|
|
37
|
+
status: string;
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
previous_item_id: string;
|
|
41
|
+
type: "conversation.item.created";
|
|
42
|
+
};
|
|
43
|
+
voice_sdk_id: string;
|
|
44
|
+
};
|
|
45
|
+
export declare function isConversationItemCreatedMessage(message: unknown): message is ConversationItemCreatedMessage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AgentStateAutoUpdate(): null;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PropsWithChildren } from "react";
|
|
2
|
+
import type { TelnyxAIAgentConstructorParams } from "../client";
|
|
3
|
+
import { TelnyxAIAgent } from "../client";
|
|
4
|
+
export declare const ClientContext: import("react").Context<TelnyxAIAgent | null>;
|
|
5
|
+
export declare const TelnyxAIAgentProvider: ({ children, agentId, environment, versionId, }: PropsWithChildren & TelnyxAIAgentConstructorParams) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ConnectionStateAutoUpdate(): null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ConversationAutoUpdate: () => null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TranscriptAutoUpdate(): null;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type ConnectionState = "connecting" | "connected" | "disconnected" | "error";
|
|
2
|
+
export declare function useConnectionState(): ConnectionState;
|
|
3
|
+
export declare function useSetConnectionState(): (args_0: ConnectionState | ((prev: ConnectionState) => ConnectionState)) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useClient: () => import("..").TelnyxAIAgent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import EventEmitter from "eventemitter3";
|
|
2
|
+
import type { TranscriptEvents, TranscriptItem } from "./types";
|
|
3
|
+
import { TelnyxRTC } from "@telnyx/webrtc";
|
|
4
|
+
export declare class Transcription extends EventEmitter<TranscriptEvents> {
|
|
5
|
+
private telnyxRTC;
|
|
6
|
+
transcript: TranscriptItem[];
|
|
7
|
+
constructor(client: TelnyxRTC);
|
|
8
|
+
private onSocketMessage;
|
|
9
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { INotification } from "@telnyx/webrtc";
|
|
2
|
+
export type TranscriptItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
role: "user" | "assistant";
|
|
5
|
+
content: string;
|
|
6
|
+
timestamp: Date;
|
|
7
|
+
};
|
|
8
|
+
export type AIAgentEvents = {
|
|
9
|
+
"agent.connected": () => void;
|
|
10
|
+
"agent.disconnected": () => void;
|
|
11
|
+
"agent.error": (error: Error) => void;
|
|
12
|
+
"transcript.item": (item: TranscriptItem) => void;
|
|
13
|
+
"conversation.update": (call: INotification) => void;
|
|
14
|
+
"conversation.agent.state": (state: AgentState) => void;
|
|
15
|
+
"agent.audio.mute": (muted: boolean) => void;
|
|
16
|
+
};
|
|
17
|
+
export type AgentState = "speaking" | "listening" | "thinking";
|
|
18
|
+
export type TranscriptEvents = Pick<AIAgentEvents, "transcript.item">;
|
|
19
|
+
export type AgentStateEvents = Pick<AIAgentEvents, "conversation.agent.state">;
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function debounce<T extends unknown[]>(fn: (...args: T) => void, delay: number): (...args: T) => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telnyx/ai-agent-lib",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "vite",
|
|
11
|
+
"build": "tsc -p tsconfig.build.json && vite build",
|
|
12
|
+
"lint": "eslint .",
|
|
13
|
+
"preview": "vite preview",
|
|
14
|
+
"release": "release-it"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@telnyx/webrtc": "^2.22.15",
|
|
18
|
+
"@types/node": "^24.1.0",
|
|
19
|
+
"eventemitter3": "^5.0.1",
|
|
20
|
+
"jotai": "^2.12.5",
|
|
21
|
+
"react": "^19.1.1",
|
|
22
|
+
"react-dom": "^19.1.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@eslint/js": "^9.30.1",
|
|
26
|
+
"@types/react": "^19.1.8",
|
|
27
|
+
"@types/react-dom": "^19.1.6",
|
|
28
|
+
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
29
|
+
"eslint": "^9.30.1",
|
|
30
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
31
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
32
|
+
"globals": "^16.3.0",
|
|
33
|
+
"release-it": "^19.0.4",
|
|
34
|
+
"typescript": "~5.8.3",
|
|
35
|
+
"typescript-eslint": "^8.35.1",
|
|
36
|
+
"vite": "^7.0.4"
|
|
37
|
+
}
|
|
38
|
+
}
|