@fluxy-chat/sdk 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 +71 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +48 -0
- package/dist/index.d.ts +293 -0
- package/dist/index.js +843 -0
- package/dist/message-stream.d.ts +34 -0
- package/dist/message-stream.js +150 -0
- package/dist/room-connection.d.ts +63 -0
- package/dist/room-connection.js +244 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fluxychat contributors
|
|
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,71 @@
|
|
|
1
|
+
# @fluxy-chat/sdk
|
|
2
|
+
|
|
3
|
+
Client for a **Fluxychat Worker** (self-hosted or [Fluxychat Cloud](https://github.com/AlessandroFare/fluxychat)): rooms, messages, WebSockets, agents, and optional React `useChat`.
|
|
4
|
+
|
|
5
|
+
The SDK talks to **your** Worker URL. It does **not** include LLM API keys — only your Fluxy **project API key** or **member JWT**.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @fluxy-chat/sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @fluxy-chat/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires **React 18+** if you use `useChat` (peer dependency).
|
|
16
|
+
|
|
17
|
+
## What you must configure
|
|
18
|
+
|
|
19
|
+
| Piece | Who sets it | Notes |
|
|
20
|
+
|--------|-------------|--------|
|
|
21
|
+
| **Worker `baseUrl`** | You | e.g. `https://fluxychat-worker.<account>.workers.dev` or your custom domain |
|
|
22
|
+
| **Project API key** (`fc_…`) | Worker / console | Mint JWTs via `POST /auth/token` with header `X-Fluxy-Api-Key` — **server-side only** |
|
|
23
|
+
| **Member JWT** | Your backend or Fluxychat console | Passed to `FluxyChatClient` / `useChat` as `token` |
|
|
24
|
+
| **LLM provider keys** | Worker secrets or console | For agents; never embed in the npm package |
|
|
25
|
+
|
|
26
|
+
### Minimal backend (mint JWT)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
curl -X POST "$WORKER_URL/auth/token" \
|
|
30
|
+
-H "Content-Type: application/json" \
|
|
31
|
+
-H "X-Fluxy-Api-Key: fc_your_project_key" \
|
|
32
|
+
-d '{"userId":"alice","roles":["member"],"ttlSeconds":3600}'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Use the returned `token` in the browser.
|
|
36
|
+
|
|
37
|
+
## Quick start (React)
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { FluxyChatClient, useChat } from "@fluxy-chat/sdk";
|
|
41
|
+
|
|
42
|
+
const client = new FluxyChatClient({
|
|
43
|
+
baseUrl: process.env.NEXT_PUBLIC_FLUXYCHAT_WORKER_URL!,
|
|
44
|
+
userId: "alice",
|
|
45
|
+
token: memberJwtFromYourBackend,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function Room({ roomId }: { roomId: string }) {
|
|
49
|
+
const { messages, sendMessage, connectionStatus } = useChat({ roomId, client });
|
|
50
|
+
// render messages…
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Self-host vs hosted cloud
|
|
55
|
+
|
|
56
|
+
- **Self-host:** deploy `apps/worker` from the [monorepo](https://github.com/AlessandroFare/fluxychat), run D1 migrations, set secrets. See `apps/worker/.dev.vars.example`.
|
|
57
|
+
- **Hosted cloud:** use the Fluxychat dashboard on Vercel; sign in with Clerk; project + API keys are provisioned for you.
|
|
58
|
+
|
|
59
|
+
Full operator docs: [docs/dashboard-integration.md](https://github.com/AlessandroFare/fluxychat/blob/main/docs/dashboard-integration.md).
|
|
60
|
+
|
|
61
|
+
## Agents
|
|
62
|
+
|
|
63
|
+
Agent invokes run on the Worker (`POST /agents/:id/invoke`). Configure provider keys on the Worker or per-project in the console. The SDK exposes REST helpers only.
|
|
64
|
+
|
|
65
|
+
## Support
|
|
66
|
+
|
|
67
|
+
Questions: [fluxychat@outlook.com](mailto:fluxychat@outlook.com) · Issues: [github.com/AlessandroFare/fluxychat/issues](https://github.com/AlessandroFare/fluxychat/issues)
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT — see [LICENSE](./LICENSE).
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Worker closes unauthorized / forbidden WebSocket joins with 1008. */
|
|
2
|
+
export declare const FLUXY_WS_CLOSE_POLICY = 1008;
|
|
3
|
+
/** Normal client-initiated close. */
|
|
4
|
+
export declare const FLUXY_WS_CLOSE_NORMAL = 1000;
|
|
5
|
+
export declare class FluxyAuthError extends Error {
|
|
6
|
+
readonly code = 1008;
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class FluxyConnectionError extends Error {
|
|
10
|
+
readonly code: number;
|
|
11
|
+
readonly reason: string;
|
|
12
|
+
constructor(code: number, reason?: string, message?: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class FluxySendError extends Error {
|
|
15
|
+
constructor(message?: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class FluxyTimeoutError extends Error {
|
|
18
|
+
readonly timeoutMs: number;
|
|
19
|
+
constructor(timeoutMs: number);
|
|
20
|
+
}
|
|
21
|
+
export declare function mapWebSocketCloseToError(code: number, reason?: string): Error | null;
|
|
22
|
+
export declare function computeReconnectBackoffMs(attempt: number, baseMs?: number, maxMs?: number): number;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Worker closes unauthorized / forbidden WebSocket joins with 1008. */
|
|
2
|
+
export const FLUXY_WS_CLOSE_POLICY = 1008;
|
|
3
|
+
/** Normal client-initiated close. */
|
|
4
|
+
export const FLUXY_WS_CLOSE_NORMAL = 1000;
|
|
5
|
+
export class FluxyAuthError extends Error {
|
|
6
|
+
constructor(message = "Authentication or room access failed (WebSocket close 1008). Check your JWT, API key, and room membership.") {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = FLUXY_WS_CLOSE_POLICY;
|
|
9
|
+
this.name = "FluxyAuthError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class FluxyConnectionError extends Error {
|
|
13
|
+
constructor(code, reason = "", message) {
|
|
14
|
+
super(message ?? `WebSocket closed unexpectedly (code ${code}${reason ? `: ${reason}` : ""}).`);
|
|
15
|
+
this.name = "FluxyConnectionError";
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.reason = reason;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class FluxySendError extends Error {
|
|
21
|
+
constructor(message = "Cannot send: WebSocket is not open.") {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "FluxySendError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class FluxyTimeoutError extends Error {
|
|
27
|
+
constructor(timeoutMs) {
|
|
28
|
+
super(`Operation timed out after ${timeoutMs}ms`);
|
|
29
|
+
this.name = "FluxyTimeoutError";
|
|
30
|
+
this.timeoutMs = timeoutMs;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function mapWebSocketCloseToError(code, reason = "") {
|
|
34
|
+
if (code === FLUXY_WS_CLOSE_NORMAL)
|
|
35
|
+
return null;
|
|
36
|
+
if (code === FLUXY_WS_CLOSE_POLICY) {
|
|
37
|
+
const text = reason.trim();
|
|
38
|
+
if (text.toLowerCase().includes("forbidden")) {
|
|
39
|
+
return new FluxyAuthError("You are not a member of this room (WebSocket close 1008 Forbidden). Join the room or use an admin JWT.");
|
|
40
|
+
}
|
|
41
|
+
return new FluxyAuthError();
|
|
42
|
+
}
|
|
43
|
+
return new FluxyConnectionError(code, reason);
|
|
44
|
+
}
|
|
45
|
+
export function computeReconnectBackoffMs(attempt, baseMs = 500, maxMs = 20000) {
|
|
46
|
+
const capped = Math.min(Math.max(attempt, 0), 6);
|
|
47
|
+
return Math.min(maxMs, baseMs * 2 ** capped);
|
|
48
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
export { FluxyAuthError, FluxyConnectionError, FluxySendError, FluxyTimeoutError, FLUXY_WS_CLOSE_NORMAL, FLUXY_WS_CLOSE_POLICY, computeReconnectBackoffMs, mapWebSocketCloseToError, } from "./errors";
|
|
2
|
+
export { FluxyChatRoomConnection, type FluxyRoomConnectionOptions, type FluxyRoomConnectionStatus, type FluxyWaitForOptions, } from "./room-connection";
|
|
3
|
+
export { FluxyMessageStream, type FluxyMessageStreamOptions } from "./message-stream";
|
|
4
|
+
import { FluxyChatRoomConnection, type FluxyRoomConnectionOptions } from "./room-connection";
|
|
5
|
+
export interface FluxyChatMessage {
|
|
6
|
+
id: number;
|
|
7
|
+
roomId: string;
|
|
8
|
+
userId: string;
|
|
9
|
+
senderId?: string;
|
|
10
|
+
content: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
parentId?: number | null;
|
|
13
|
+
editedAt?: string | null;
|
|
14
|
+
deletedAt?: string | null;
|
|
15
|
+
mentions?: string[];
|
|
16
|
+
preview?: {
|
|
17
|
+
url: string;
|
|
18
|
+
title?: string | null;
|
|
19
|
+
description?: string | null;
|
|
20
|
+
imageUrl?: string | null;
|
|
21
|
+
};
|
|
22
|
+
attachments?: FluxyChatAttachment[];
|
|
23
|
+
/** True while an agent (or user) is still streaming tokens into this message. */
|
|
24
|
+
streaming?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface FluxyChatAttachment {
|
|
27
|
+
id?: number;
|
|
28
|
+
kind: string;
|
|
29
|
+
url: string;
|
|
30
|
+
name: string;
|
|
31
|
+
sizeBytes?: number;
|
|
32
|
+
contentType?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface FluxyChatRoom {
|
|
35
|
+
id: string;
|
|
36
|
+
type: "dm" | "group" | "public";
|
|
37
|
+
name: string;
|
|
38
|
+
created_at: string;
|
|
39
|
+
}
|
|
40
|
+
export interface FluxyChatToolDefinition {
|
|
41
|
+
type: "function";
|
|
42
|
+
function: {
|
|
43
|
+
name: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
parameters?: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface FluxyChatAgent {
|
|
49
|
+
id: string;
|
|
50
|
+
projectId: string;
|
|
51
|
+
name: string;
|
|
52
|
+
handle?: string | null;
|
|
53
|
+
provider?: string | null;
|
|
54
|
+
model?: string | null;
|
|
55
|
+
capabilities?: string[];
|
|
56
|
+
config?: Record<string, unknown> | null;
|
|
57
|
+
systemPrompt?: string | null;
|
|
58
|
+
contextFetchUrl?: string | null;
|
|
59
|
+
toolExecuteUrl?: string | null;
|
|
60
|
+
toolsSchema?: FluxyChatToolDefinition[] | null;
|
|
61
|
+
rateLimitRpm?: number | null;
|
|
62
|
+
createdAt?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface FluxyChatToolCall {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
arguments: string;
|
|
68
|
+
}
|
|
69
|
+
export interface FluxyChatAgentRun {
|
|
70
|
+
id: string;
|
|
71
|
+
status: "queued" | "completed" | "failed";
|
|
72
|
+
latency_ms?: number;
|
|
73
|
+
input_tokens?: number;
|
|
74
|
+
output_tokens?: number;
|
|
75
|
+
estimated_cost?: number;
|
|
76
|
+
error?: string | null;
|
|
77
|
+
room_id?: string | null;
|
|
78
|
+
tool_calls?: FluxyChatToolCall[];
|
|
79
|
+
context_fetched?: boolean;
|
|
80
|
+
iterations?: number;
|
|
81
|
+
created_at: string;
|
|
82
|
+
}
|
|
83
|
+
export type FluxyChatEvent = {
|
|
84
|
+
type: "history";
|
|
85
|
+
messages: FluxyChatMessage[];
|
|
86
|
+
} | ({
|
|
87
|
+
type: "message";
|
|
88
|
+
} & FluxyChatMessage) | {
|
|
89
|
+
type: "edit";
|
|
90
|
+
id: number;
|
|
91
|
+
roomId: string;
|
|
92
|
+
userId: string;
|
|
93
|
+
content: string;
|
|
94
|
+
editedAt: string;
|
|
95
|
+
streaming?: boolean;
|
|
96
|
+
} | {
|
|
97
|
+
type: "stream";
|
|
98
|
+
op: "started";
|
|
99
|
+
id: number;
|
|
100
|
+
roomId: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: "reaction";
|
|
103
|
+
roomId: string;
|
|
104
|
+
userId: string;
|
|
105
|
+
messageId: number;
|
|
106
|
+
emoji: string;
|
|
107
|
+
op: "add" | "remove";
|
|
108
|
+
} | {
|
|
109
|
+
type: "read";
|
|
110
|
+
roomId: string;
|
|
111
|
+
userId: string;
|
|
112
|
+
messageId: number;
|
|
113
|
+
createdAt: string;
|
|
114
|
+
} | {
|
|
115
|
+
type: "delete";
|
|
116
|
+
id: number;
|
|
117
|
+
roomId: string;
|
|
118
|
+
userId: string;
|
|
119
|
+
deletedAt: string;
|
|
120
|
+
hard?: boolean;
|
|
121
|
+
} | {
|
|
122
|
+
type: "typing";
|
|
123
|
+
userId: string;
|
|
124
|
+
isTyping: boolean;
|
|
125
|
+
} | {
|
|
126
|
+
type: "agentTyping";
|
|
127
|
+
agentId: string;
|
|
128
|
+
isTyping: boolean;
|
|
129
|
+
} | {
|
|
130
|
+
type: "presence";
|
|
131
|
+
online: number;
|
|
132
|
+
users?: string[];
|
|
133
|
+
} | {
|
|
134
|
+
type: "error";
|
|
135
|
+
message: string;
|
|
136
|
+
};
|
|
137
|
+
export interface FluxyChatClientOptions {
|
|
138
|
+
baseUrl: string;
|
|
139
|
+
userId: string;
|
|
140
|
+
apiKey?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Optional JWT for authenticated REST calls (POST /messages, reactions, read, reports, etc).
|
|
143
|
+
* When provided, the SDK will prefer REST for writes and use WebSocket mainly for realtime updates.
|
|
144
|
+
*/
|
|
145
|
+
token?: string;
|
|
146
|
+
}
|
|
147
|
+
export declare class FluxyChatClient {
|
|
148
|
+
private baseUrl;
|
|
149
|
+
readonly userId: string;
|
|
150
|
+
readonly apiKey?: string;
|
|
151
|
+
readonly token?: string;
|
|
152
|
+
constructor(options: FluxyChatClientOptions);
|
|
153
|
+
isAuthenticated(): boolean;
|
|
154
|
+
private authHeaders;
|
|
155
|
+
connect(roomId: string): WebSocket;
|
|
156
|
+
/**
|
|
157
|
+
* Resilient room WebSocket with typed errors, exponential backoff reconnect,
|
|
158
|
+
* and optional REST history replay after reconnect.
|
|
159
|
+
*/
|
|
160
|
+
connectRoom(roomId: string, options?: FluxyRoomConnectionOptions): FluxyChatRoomConnection;
|
|
161
|
+
connectSSE(roomId: string): EventSource | null;
|
|
162
|
+
fetchMessages(roomId: string, limit?: number): Promise<FluxyChatMessage[]>;
|
|
163
|
+
listRooms(type?: string): Promise<FluxyChatRoom[]>;
|
|
164
|
+
createMessage(roomId: string, content: string, replyTo?: number | null, attachments?: FluxyChatAttachment[]): Promise<FluxyChatMessage | null>;
|
|
165
|
+
/**
|
|
166
|
+
* Upload to Worker `POST /upload` (requires JWT). Returns attachment fields for composing a message.
|
|
167
|
+
*/
|
|
168
|
+
uploadFile(roomId: string, file: File): Promise<FluxyChatAttachment>;
|
|
169
|
+
editMessageRest(messageId: number, content: string): Promise<void>;
|
|
170
|
+
deleteMessageRest(messageId: number): Promise<void>;
|
|
171
|
+
sendReactionRest(messageId: number, emoji: string, op?: "add" | "remove"): Promise<void>;
|
|
172
|
+
markReadRest(roomId: string, messageId: number): Promise<void>;
|
|
173
|
+
listAgents(): Promise<FluxyChatAgent[]>;
|
|
174
|
+
invokeAgentRest(agentId: string, roomId: string, content: string, options?: {
|
|
175
|
+
replyTo?: number | null;
|
|
176
|
+
stream?: boolean;
|
|
177
|
+
}): Promise<{
|
|
178
|
+
run: {
|
|
179
|
+
id: string;
|
|
180
|
+
status: string;
|
|
181
|
+
latencyMs?: number;
|
|
182
|
+
inputTokens?: number;
|
|
183
|
+
outputTokens?: number;
|
|
184
|
+
estimatedCost?: number;
|
|
185
|
+
iterations?: number;
|
|
186
|
+
toolCalls?: FluxyChatToolCall[];
|
|
187
|
+
createdAt: string;
|
|
188
|
+
};
|
|
189
|
+
message: FluxyChatMessage;
|
|
190
|
+
}>;
|
|
191
|
+
getAgentRuns(agentId: string, limit?: number): Promise<FluxyChatAgentRun[]>;
|
|
192
|
+
getAgent(agentId: string): Promise<FluxyChatAgent | null>;
|
|
193
|
+
createAgent(body: {
|
|
194
|
+
name: string;
|
|
195
|
+
handle?: string;
|
|
196
|
+
provider?: string;
|
|
197
|
+
model?: string;
|
|
198
|
+
systemPrompt?: string;
|
|
199
|
+
contextFetchUrl?: string;
|
|
200
|
+
toolExecuteUrl?: string;
|
|
201
|
+
toolsSchema?: unknown[];
|
|
202
|
+
rateLimitRpm?: number;
|
|
203
|
+
}): Promise<FluxyChatAgent>;
|
|
204
|
+
updateAgent(agentId: string, body: Record<string, unknown>): Promise<FluxyChatAgent>;
|
|
205
|
+
deleteAgent(agentId: string): Promise<void>;
|
|
206
|
+
createRoom(body: {
|
|
207
|
+
name: string;
|
|
208
|
+
type: string;
|
|
209
|
+
id?: string;
|
|
210
|
+
members?: {
|
|
211
|
+
userId: string;
|
|
212
|
+
role: string;
|
|
213
|
+
}[];
|
|
214
|
+
}): Promise<{
|
|
215
|
+
id: string;
|
|
216
|
+
type: string;
|
|
217
|
+
name: string;
|
|
218
|
+
created_at: string;
|
|
219
|
+
}>;
|
|
220
|
+
updateRoom(roomId: string, body: {
|
|
221
|
+
name?: string;
|
|
222
|
+
type?: string;
|
|
223
|
+
}): Promise<void>;
|
|
224
|
+
deleteRoom(roomId: string): Promise<void>;
|
|
225
|
+
addRoomMember(roomId: string, userId: string, role?: string): Promise<void>;
|
|
226
|
+
removeRoomMember(roomId: string, userId: string): Promise<void>;
|
|
227
|
+
registerWebhook(body: {
|
|
228
|
+
url: string;
|
|
229
|
+
eventTypes: string[];
|
|
230
|
+
secret?: string;
|
|
231
|
+
}): Promise<{
|
|
232
|
+
id: string;
|
|
233
|
+
projectId: string;
|
|
234
|
+
url: string;
|
|
235
|
+
secret?: string;
|
|
236
|
+
}>;
|
|
237
|
+
updateWebhook(webhookId: string, body: {
|
|
238
|
+
url?: string;
|
|
239
|
+
eventTypes?: string[];
|
|
240
|
+
secret?: string;
|
|
241
|
+
}): Promise<void>;
|
|
242
|
+
deleteWebhook(webhookId: string): Promise<void>;
|
|
243
|
+
}
|
|
244
|
+
export interface UseChatOptions {
|
|
245
|
+
roomId: string;
|
|
246
|
+
client: FluxyChatClient;
|
|
247
|
+
agentId?: string;
|
|
248
|
+
}
|
|
249
|
+
export declare function useChat({ roomId, client, agentId }: UseChatOptions): {
|
|
250
|
+
messages: FluxyChatMessage[];
|
|
251
|
+
online: number;
|
|
252
|
+
typingUsers: Record<string, boolean>;
|
|
253
|
+
seenBy: Record<number, string[]>;
|
|
254
|
+
onlineUsers: string[];
|
|
255
|
+
connected: boolean;
|
|
256
|
+
connectionStatus: "connecting" | "connected" | "reconnecting" | "disconnected" | "polling" | "sse";
|
|
257
|
+
reconnectAttempt: number;
|
|
258
|
+
connectionError: Error | null;
|
|
259
|
+
agentTyping: boolean;
|
|
260
|
+
typingAgentId: string | null;
|
|
261
|
+
reactions: Record<number, Record<string, number>>;
|
|
262
|
+
sendMessage: (content: string, replyTo?: number | null, attachments?: FluxyChatAttachment[]) => void;
|
|
263
|
+
setTyping: (isTyping: boolean) => void;
|
|
264
|
+
editMessage: (messageId: number, content: string) => void;
|
|
265
|
+
sendReaction: (messageId: number, emoji: string, op?: "add" | "remove") => void;
|
|
266
|
+
sendReadReceipt: (messageId: number) => void;
|
|
267
|
+
deleteMessage: (messageId: number) => void;
|
|
268
|
+
invokeAgent: (content: string, options?: {
|
|
269
|
+
agentId?: string;
|
|
270
|
+
replyTo?: number | null;
|
|
271
|
+
}) => Promise<{
|
|
272
|
+
run: {
|
|
273
|
+
id: string;
|
|
274
|
+
status: string;
|
|
275
|
+
latencyMs?: number;
|
|
276
|
+
inputTokens?: number;
|
|
277
|
+
outputTokens?: number;
|
|
278
|
+
estimatedCost?: number;
|
|
279
|
+
iterations?: number;
|
|
280
|
+
toolCalls?: FluxyChatToolCall[];
|
|
281
|
+
createdAt: string;
|
|
282
|
+
};
|
|
283
|
+
message: FluxyChatMessage;
|
|
284
|
+
}>;
|
|
285
|
+
};
|
|
286
|
+
export declare function useRooms(client: FluxyChatClient): {
|
|
287
|
+
rooms: (FluxyChatRoom & {
|
|
288
|
+
unreadCount?: number;
|
|
289
|
+
})[];
|
|
290
|
+
loading: boolean;
|
|
291
|
+
error: string | null;
|
|
292
|
+
reload: () => Promise<void>;
|
|
293
|
+
};
|