@ragwalla/agents-sdk 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ragwalla
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,332 @@
1
+ # Ragwalla Agents SDK - TypeScript
2
+
3
+ The official TypeScript SDK for the Ragwalla Agents API. Build powerful AI applications with agents, real-time chat, vector search, and more.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ragwalla/agents-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Ragwalla } from '@ragwalla/agents-sdk';
15
+
16
+ const ragwalla = new Ragwalla({
17
+ apiKey: process.env.RAGWALLA_API_KEY!
18
+ });
19
+
20
+ // Create an agent
21
+ const agent = await ragwalla.agents.create({
22
+ name: 'My Assistant',
23
+ instructions: 'You are a helpful AI assistant.'
24
+ });
25
+
26
+ // Chat with the agent
27
+ const response = await ragwalla.agents.createChatCompletion(agent.id, {
28
+ messages: [{ role: 'user', content: 'Hello!' }]
29
+ });
30
+
31
+ console.log(response.choices[0].message.content);
32
+ ```
33
+
34
+ ## Features
35
+
36
+ - ✅ **Agent Management** - Create, update, and manage AI agents
37
+ - ✅ **Chat Completions** - Both streaming and non-streaming
38
+ - ✅ **Real-time WebSocket** - Live chat with automatic reconnection
39
+ - ✅ **Vector Search** - Semantic search across knowledge bases
40
+ - ✅ **Tool Management** - Attach functions and assistants to agents
41
+ - ✅ **Quota Management** - Track usage and limits
42
+ - ✅ **TypeScript Native** - Full type safety and IntelliSense
43
+ - ✅ **Error Handling** - Comprehensive error types
44
+ - ✅ **Automatic Retries** - Built-in retry logic for failed requests
45
+
46
+ ## Configuration
47
+
48
+ ```typescript
49
+ const ragwalla = new Ragwalla({
50
+ apiKey: 'your-api-key', // Required
51
+ baseURL: 'https://api.ragwalla.com', // Optional, defaults to this
52
+ timeout: 30000 // Optional, request timeout in ms
53
+ });
54
+ ```
55
+
56
+ ## Agent Management
57
+
58
+ ### Create an Agent
59
+
60
+ ```typescript
61
+ const agent = await ragwalla.agents.create({
62
+ name: 'Customer Support Agent',
63
+ description: 'Handles customer inquiries',
64
+ model: 'gpt-4',
65
+ instructions: 'You are a helpful customer support representative.',
66
+ tools: ['tool_id_1', 'tool_id_2'],
67
+ metadata: {
68
+ department: 'support',
69
+ version: '1.0'
70
+ }
71
+ });
72
+ ```
73
+
74
+ ### List Agents
75
+
76
+ ```typescript
77
+ const agents = await ragwalla.agents.list({
78
+ limit: 10,
79
+ order: 'desc'
80
+ });
81
+
82
+ console.log(agents.data); // Array of agents
83
+ ```
84
+
85
+ ### Update an Agent
86
+
87
+ ```typescript
88
+ const updatedAgent = await ragwalla.agents.update(agent.id, {
89
+ instructions: 'Updated instructions for the agent'
90
+ });
91
+ ```
92
+
93
+ ### Delete an Agent
94
+
95
+ ```typescript
96
+ await ragwalla.agents.delete(agent.id);
97
+ ```
98
+
99
+ ## Chat Completions
100
+
101
+ ### Non-streaming Chat
102
+
103
+ ```typescript
104
+ const response = await ragwalla.agents.createChatCompletion(agent.id, {
105
+ messages: [
106
+ { role: 'user', content: 'What is the weather like?' }
107
+ ],
108
+ max_tokens: 150,
109
+ temperature: 0.7
110
+ });
111
+
112
+ console.log(response.choices[0].message.content);
113
+ ```
114
+
115
+ ### Streaming Chat
116
+
117
+ ```typescript
118
+ const stream = await ragwalla.agents.createChatCompletionStream(agent.id, {
119
+ messages: [
120
+ { role: 'user', content: 'Write a story about AI' }
121
+ ],
122
+ stream: true,
123
+ max_tokens: 500
124
+ });
125
+
126
+ const reader = stream.getReader();
127
+ while (true) {
128
+ const { done, value } = await reader.read();
129
+ if (done) break;
130
+
131
+ if (value.choices?.[0]?.message?.content) {
132
+ process.stdout.write(value.choices[0].message.content);
133
+ }
134
+ }
135
+ ```
136
+
137
+ ## Real-time WebSocket Chat
138
+
139
+ ### Basic WebSocket Usage
140
+
141
+ ```typescript
142
+ // Get connection token
143
+ const tokenResponse = await ragwalla.agents.getToken({
144
+ agent_id: agent.id,
145
+ expires_in: 3600
146
+ });
147
+
148
+ // Create WebSocket connection
149
+ const ws = ragwalla.createWebSocket();
150
+
151
+ // Set up event listeners
152
+ ws.on('connected', () => {
153
+ console.log('Connected to agent');
154
+ });
155
+
156
+ ws.on('message', (message) => {
157
+ console.log('Agent:', message.content);
158
+ });
159
+
160
+ ws.on('error', (error) => {
161
+ console.error('Error:', error);
162
+ });
163
+
164
+ // Connect and send message
165
+ await ws.connect(agent.id, 'main', tokenResponse.token);
166
+ ws.sendMessage({
167
+ role: 'user',
168
+ content: 'Hello via WebSocket!'
169
+ });
170
+ ```
171
+
172
+ ### WebSocket Events
173
+
174
+ The WebSocket client emits the following events:
175
+
176
+ - `connected` - Successfully connected to agent
177
+ - `message` - New message from agent
178
+ - `tokenUsage` - Token usage information
179
+ - `error` - Error occurred
180
+ - `disconnected` - Connection closed
181
+ - `reconnectFailed` - Reconnection attempts failed
182
+
183
+ ## Vector Search
184
+
185
+ ### Simple Search
186
+
187
+ ```typescript
188
+ const results = await ragwalla.vectorStores.search('vector_store_id', {
189
+ query: 'How to use the API?',
190
+ top_k: 5,
191
+ include_metadata: true
192
+ });
193
+
194
+ results.data.forEach(result => {
195
+ console.log(`Score: ${result.score}`);
196
+ console.log(`Content: ${result.content}`);
197
+ });
198
+ ```
199
+
200
+ ### Advanced Search with Filters
201
+
202
+ ```typescript
203
+ const results = await ragwalla.vectorStores.searchExtended('vector_store_id', {
204
+ query: 'JavaScript examples',
205
+ top_k: 3,
206
+ filter: {
207
+ language: 'javascript',
208
+ category: 'tutorial'
209
+ },
210
+ extended_query: 'Find JavaScript SDK usage examples',
211
+ search_type: 'similarity_score_threshold',
212
+ search_kwargs: {
213
+ score_threshold: 0.8
214
+ }
215
+ });
216
+ ```
217
+
218
+ ## Tool Management
219
+
220
+ ### List Agent Tools
221
+
222
+ ```typescript
223
+ const tools = await ragwalla.agents.listTools(agent.id);
224
+ console.log(tools.data);
225
+ ```
226
+
227
+ ### Attach a Tool
228
+
229
+ ```typescript
230
+ const tool = await ragwalla.agents.attachTool(agent.id, {
231
+ type: 'function',
232
+ function: {
233
+ name: 'get_weather',
234
+ description: 'Get current weather for a location',
235
+ parameters: {
236
+ type: 'object',
237
+ properties: {
238
+ location: {
239
+ type: 'string',
240
+ description: 'The city and state'
241
+ }
242
+ },
243
+ required: ['location']
244
+ }
245
+ }
246
+ });
247
+ ```
248
+
249
+ ### Detach a Tool
250
+
251
+ ```typescript
252
+ await ragwalla.agents.detachTool(agent.id, tool.id);
253
+ ```
254
+
255
+ ## Quota Management
256
+
257
+ ### Check Quota
258
+
259
+ ```typescript
260
+ const quotaCheck = await ragwalla.quota.check({
261
+ userId: 'user_123',
262
+ action: 'chat_completion'
263
+ });
264
+
265
+ if (quotaCheck.allowed) {
266
+ // Proceed with action
267
+ } else {
268
+ console.log('Quota exceeded');
269
+ }
270
+ ```
271
+
272
+ ### Send Quota Event
273
+
274
+ ```typescript
275
+ await ragwalla.quota.sendEvent('worker_id', {
276
+ action: 'message_sent',
277
+ metadata: {
278
+ tokens_used: 150,
279
+ model: 'gpt-4'
280
+ }
281
+ });
282
+ ```
283
+
284
+ ## Error Handling
285
+
286
+ The SDK throws `RagwallaAPIError` for API-related errors:
287
+
288
+ ```typescript
289
+ import { RagwallaAPIError } from '@ragwalla/agents-sdk';
290
+
291
+ try {
292
+ const agent = await ragwalla.agents.retrieve('invalid_id');
293
+ } catch (error) {
294
+ if (error instanceof RagwallaAPIError) {
295
+ console.log('API Error:', error.message);
296
+ console.log('Status:', error.status);
297
+ console.log('Type:', error.type);
298
+ console.log('Code:', error.code);
299
+ }
300
+ }
301
+ ```
302
+
303
+ ## Examples
304
+
305
+ Check the `examples/` directory for complete usage examples:
306
+
307
+ - `basic-usage.ts` - Basic agent operations
308
+ - `streaming-chat.ts` - Streaming chat completions
309
+ - `websocket-chat.ts` - Real-time WebSocket communication
310
+ - `vector-search.ts` - Vector store search examples
311
+
312
+ ## Environment Variables
313
+
314
+ Set your API key as an environment variable:
315
+
316
+ ```bash
317
+ export RAGWALLA_API_KEY=your_api_key_here
318
+ ```
319
+
320
+ ## TypeScript Support
321
+
322
+ The SDK is written in TypeScript and provides full type definitions. All API responses and request parameters are fully typed for the best development experience.
323
+
324
+ ## Support
325
+
326
+ For issues and questions:
327
+ - GitHub Issues: [ragwalla-agents-sdk issues](https://github.com/ragwalla/agents-sdk/issues)
328
+ - Documentation: [Ragwalla Docs](https://docs.ragwalla.com)
329
+
330
+ ## License
331
+
332
+ MIT License
@@ -0,0 +1,22 @@
1
+ import { RagwallaConfig, RagwallaError } from '../types';
2
+ export declare class HTTPClient {
3
+ private apiKey;
4
+ private baseURL;
5
+ private timeout;
6
+ constructor(config: RagwallaConfig);
7
+ private getHeaders;
8
+ private handleResponse;
9
+ get<T>(path: string, params?: Record<string, any>): Promise<T>;
10
+ post<T>(path: string, data?: any): Promise<T>;
11
+ put<T>(path: string, data?: any): Promise<T>;
12
+ delete<T>(path: string): Promise<T>;
13
+ postEventStream<T>(path: string, data?: any): Promise<ReadableStream<T>>;
14
+ }
15
+ export declare class RagwallaAPIError extends Error implements RagwallaError {
16
+ readonly type: string;
17
+ readonly code?: string;
18
+ readonly param?: string;
19
+ readonly status?: number;
20
+ constructor(message: string, status?: number, type?: string, code?: string, param?: string);
21
+ }
22
+ //# sourceMappingURL=http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/client/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzD,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,cAAc;IAMlC,OAAO,CAAC,UAAU;YAQJ,cAAc;IAoBtB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IA0B9D,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAmB7C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAmB5C,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAkBnC,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CA8C/E;AAED,qBAAa,gBAAiB,SAAQ,KAAM,YAAW,aAAa;IAClE,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAG9B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM;CASjB"}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RagwallaAPIError = exports.HTTPClient = void 0;
4
+ class HTTPClient {
5
+ constructor(config) {
6
+ this.apiKey = config.apiKey;
7
+ this.baseURL = config.baseURL || 'https://api.ragwalla.com';
8
+ this.timeout = config.timeout || 30000;
9
+ }
10
+ getHeaders() {
11
+ return {
12
+ 'Authorization': `Bearer ${this.apiKey}`,
13
+ 'Content-Type': 'application/json',
14
+ 'User-Agent': 'ragwalla-agents-sdk-typescript/1.0.0'
15
+ };
16
+ }
17
+ async handleResponse(response) {
18
+ if (!response.ok) {
19
+ const error = await response.json().catch(() => ({}));
20
+ throw new RagwallaAPIError(error.message || `HTTP ${response.status}`, response.status, error.type, error.code, error.param);
21
+ }
22
+ const contentType = response.headers.get('content-type');
23
+ if (contentType && contentType.includes('application/json')) {
24
+ return response.json();
25
+ }
26
+ return response.text();
27
+ }
28
+ async get(path, params) {
29
+ const url = new URL(path, this.baseURL);
30
+ if (params) {
31
+ Object.entries(params).forEach(([key, value]) => {
32
+ if (value !== undefined && value !== null) {
33
+ url.searchParams.append(key, String(value));
34
+ }
35
+ });
36
+ }
37
+ const controller = new AbortController();
38
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
39
+ try {
40
+ const response = await fetch(url.toString(), {
41
+ method: 'GET',
42
+ headers: this.getHeaders(),
43
+ signal: controller.signal
44
+ });
45
+ return this.handleResponse(response);
46
+ }
47
+ finally {
48
+ clearTimeout(timeoutId);
49
+ }
50
+ }
51
+ async post(path, data) {
52
+ const url = new URL(path, this.baseURL);
53
+ const controller = new AbortController();
54
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
55
+ try {
56
+ const response = await fetch(url.toString(), {
57
+ method: 'POST',
58
+ headers: this.getHeaders(),
59
+ body: data ? JSON.stringify(data) : undefined,
60
+ signal: controller.signal
61
+ });
62
+ return this.handleResponse(response);
63
+ }
64
+ finally {
65
+ clearTimeout(timeoutId);
66
+ }
67
+ }
68
+ async put(path, data) {
69
+ const url = new URL(path, this.baseURL);
70
+ const controller = new AbortController();
71
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
72
+ try {
73
+ const response = await fetch(url.toString(), {
74
+ method: 'PUT',
75
+ headers: this.getHeaders(),
76
+ body: data ? JSON.stringify(data) : undefined,
77
+ signal: controller.signal
78
+ });
79
+ return this.handleResponse(response);
80
+ }
81
+ finally {
82
+ clearTimeout(timeoutId);
83
+ }
84
+ }
85
+ async delete(path) {
86
+ const url = new URL(path, this.baseURL);
87
+ const controller = new AbortController();
88
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
89
+ try {
90
+ const response = await fetch(url.toString(), {
91
+ method: 'DELETE',
92
+ headers: this.getHeaders(),
93
+ signal: controller.signal
94
+ });
95
+ return this.handleResponse(response);
96
+ }
97
+ finally {
98
+ clearTimeout(timeoutId);
99
+ }
100
+ }
101
+ async postEventStream(path, data) {
102
+ const url = new URL(path, this.baseURL);
103
+ const response = await fetch(url.toString(), {
104
+ method: 'POST',
105
+ headers: {
106
+ ...this.getHeaders(),
107
+ 'Accept': 'text/event-stream',
108
+ },
109
+ body: data ? JSON.stringify(data) : undefined,
110
+ });
111
+ if (!response.ok) {
112
+ const error = await response.json().catch(() => ({}));
113
+ throw new RagwallaAPIError(error.message || `HTTP ${response.status}`, response.status, error.type, error.code, error.param);
114
+ }
115
+ if (!response.body) {
116
+ throw new Error('No response body');
117
+ }
118
+ return response.body.pipeThrough(new TransformStream({
119
+ transform(chunk, controller) {
120
+ const decoder = new TextDecoder();
121
+ const text = decoder.decode(chunk);
122
+ const lines = text.split('\n');
123
+ for (const line of lines) {
124
+ if (line.startsWith('data: ')) {
125
+ try {
126
+ const data = JSON.parse(line.slice(6));
127
+ controller.enqueue(data);
128
+ }
129
+ catch (e) {
130
+ // Skip invalid JSON
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }));
136
+ }
137
+ }
138
+ exports.HTTPClient = HTTPClient;
139
+ class RagwallaAPIError extends Error {
140
+ constructor(message, status, type, code, param) {
141
+ super(message);
142
+ this.name = 'RagwallaAPIError';
143
+ this.status = status;
144
+ this.type = type || 'api_error';
145
+ this.code = code;
146
+ this.param = param;
147
+ }
148
+ }
149
+ exports.RagwallaAPIError = RagwallaAPIError;
150
+ //# sourceMappingURL=http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/client/http-client.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAKrB,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,0BAA0B,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC;IACzC,CAAC;IAEO,UAAU;QAChB,OAAO;YACL,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;YACxC,cAAc,EAAE,kBAAkB;YAClC,YAAY,EAAE,sCAAsC;SACrD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,cAAc,CAAI,QAAkB;QAChD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC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,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;wBAC9B,IAAI,CAAC;4BACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;4BACvC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;wBAC3B,CAAC;wBAAC,OAAO,CAAC,EAAE,CAAC;4BACX,oBAAoB;wBACtB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAvKD,gCAuKC;AAED,MAAa,gBAAiB,SAAQ,KAAK;IAMzC,YACE,OAAe,EACf,MAAe,EACf,IAAa,EACb,IAAa,EACb,KAAc;QAEd,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AApBD,4CAoBC"}
@@ -0,0 +1,51 @@
1
+ import { ChatMessage } from '../types';
2
+ export interface WebSocketConfig {
3
+ baseURL?: string;
4
+ reconnectAttempts?: number;
5
+ reconnectDelay?: number;
6
+ }
7
+ export declare class RagwallaWebSocket {
8
+ private ws;
9
+ private baseURL;
10
+ private reconnectAttempts;
11
+ private reconnectDelay;
12
+ private currentAttempts;
13
+ private isManuallyDisconnected;
14
+ private listeners;
15
+ constructor(config?: WebSocketConfig);
16
+ /**
17
+ * Connect to an agent's WebSocket endpoint
18
+ */
19
+ connect(agentId: string, connectionId: string, token: string): Promise<void>;
20
+ /**
21
+ * Disconnect from the WebSocket
22
+ */
23
+ disconnect(): void;
24
+ /**
25
+ * Send a chat message to the agent
26
+ */
27
+ sendMessage(message: ChatMessage): void;
28
+ /**
29
+ * Send raw data to the WebSocket
30
+ */
31
+ send(data: any): void;
32
+ /**
33
+ * Check if WebSocket is connected
34
+ */
35
+ isConnected(): boolean;
36
+ /**
37
+ * Add event listener
38
+ */
39
+ on(event: string, listener: Function): void;
40
+ /**
41
+ * Remove event listener
42
+ */
43
+ off(event: string, listener: Function): void;
44
+ /**
45
+ * Remove all listeners for an event
46
+ */
47
+ removeAllListeners(event?: string): void;
48
+ private emit;
49
+ private handleMessage;
50
+ }
51
+ //# sourceMappingURL=websocket-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket-client.d.ts","sourceRoot":"","sources":["../../src/client/websocket-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,SAAS,CAAyC;gBAE9C,MAAM,GAAE,eAAoB;IAMxC;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4ClF;;OAEG;IACH,UAAU,IAAI,IAAI;IAQlB;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAcvC;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAQrB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAO3C;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAO5C;;OAEG;IACH,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAQxC,OAAO,CAAC,IAAI;IAaZ,OAAO,CAAC,aAAa;CAkBtB"}