@xalia/agent 0.6.10 → 0.6.11
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/package.json +5 -2
- package/.env.development +0 -6
- package/.env.test +0 -7
- package/.prettierrc.json +0 -11
- package/context_system.md +0 -498
- package/eslint.config.mjs +0 -38
- package/scripts/chat_server +0 -8
- package/scripts/git_message +0 -31
- package/scripts/git_wip +0 -21
- package/scripts/pr_message +0 -18
- package/scripts/pr_review +0 -16
- package/scripts/setup_chat +0 -90
- package/scripts/shutdown_chat_server +0 -42
- package/scripts/start_chat_server +0 -24
- package/scripts/sudomcp_import +0 -23
- package/scripts/test_chat +0 -327
- package/src/agent/agent.ts +0 -699
- package/src/agent/agentUtils.ts +0 -286
- package/src/agent/compressingContextManager.ts +0 -129
- package/src/agent/context.ts +0 -265
- package/src/agent/contextWithWorkspace.ts +0 -162
- package/src/agent/documentSummarizer.ts +0 -157
- package/src/agent/dummyLLM.ts +0 -130
- package/src/agent/iAgentEventHandler.ts +0 -64
- package/src/agent/imageGenLLM.ts +0 -101
- package/src/agent/imageGenerator.ts +0 -45
- package/src/agent/iplatform.ts +0 -18
- package/src/agent/llm.ts +0 -74
- package/src/agent/mcpServerManager.ts +0 -541
- package/src/agent/nullAgentEventHandler.ts +0 -26
- package/src/agent/nullPlatform.ts +0 -13
- package/src/agent/openAI.ts +0 -123
- package/src/agent/openAILLM.ts +0 -99
- package/src/agent/openAILLMStreaming.ts +0 -648
- package/src/agent/promptProvider.ts +0 -87
- package/src/agent/repeatLLM.ts +0 -62
- package/src/agent/sudoMcpServerManager.ts +0 -361
- package/src/agent/test_data/harrypotter.txt +0 -6065
- package/src/agent/tokenAuth.ts +0 -50
- package/src/agent/tokenCounter.test.ts +0 -243
- package/src/agent/tokenCounter.ts +0 -483
- package/src/agent/toolSettings.ts +0 -24
- package/src/agent/tools/calculatorTool.ts +0 -50
- package/src/agent/tools/contentExtractors/htmlToText.ts +0 -61
- package/src/agent/tools/contentExtractors/pdfToText.ts +0 -60
- package/src/agent/tools/datetimeTool.ts +0 -41
- package/src/agent/tools/fileManager/fileManagerTool.ts +0 -199
- package/src/agent/tools/fileManager/index.ts +0 -50
- package/src/agent/tools/fileManager/memoryFileManager.ts +0 -120
- package/src/agent/tools/fileManager/mimeTypes.ts +0 -60
- package/src/agent/tools/fileManager/prompt.ts +0 -38
- package/src/agent/tools/fileManager/types.ts +0 -189
- package/src/agent/tools/index.ts +0 -49
- package/src/agent/tools/openUrlTool.ts +0 -62
- package/src/agent/tools/renderTool.ts +0 -92
- package/src/agent/tools/utils.ts +0 -74
- package/src/agent/tools/webSearch.ts +0 -138
- package/src/agent/tools/webSearchTool.ts +0 -44
- package/src/chat/client/chatClient.ts +0 -967
- package/src/chat/client/connection.test.ts +0 -241
- package/src/chat/client/connection.ts +0 -286
- package/src/chat/client/constants.ts +0 -1
- package/src/chat/client/index.ts +0 -21
- package/src/chat/client/interfaces.ts +0 -34
- package/src/chat/client/sessionClient.ts +0 -574
- package/src/chat/client/sessionFiles.ts +0 -142
- package/src/chat/client/teamManager.ts +0 -29
- package/src/chat/constants.ts +0 -6
- package/src/chat/data/apiKeyManager.ts +0 -76
- package/src/chat/data/dataModels.ts +0 -107
- package/src/chat/data/database.ts +0 -997
- package/src/chat/data/dbMcpServerConfigs.ts +0 -59
- package/src/chat/data/dbSessionFiles.ts +0 -107
- package/src/chat/data/dbSessionMessages.ts +0 -102
- package/src/chat/protocol/connectionMessages.ts +0 -49
- package/src/chat/protocol/constants.ts +0 -55
- package/src/chat/protocol/errors.ts +0 -16
- package/src/chat/protocol/messages.ts +0 -899
- package/src/chat/server/README.md +0 -127
- package/src/chat/server/chatContextManager.ts +0 -660
- package/src/chat/server/connectionManager.test.ts +0 -246
- package/src/chat/server/connectionManager.ts +0 -506
- package/src/chat/server/conversation.ts +0 -319
- package/src/chat/server/errorUtils.ts +0 -28
- package/src/chat/server/imageGeneratorTools.ts +0 -179
- package/src/chat/server/openAIRouterLLM.ts +0 -168
- package/src/chat/server/openSession.ts +0 -1945
- package/src/chat/server/openSessionMessageSender.ts +0 -4
- package/src/chat/server/promptRefiner.ts +0 -106
- package/src/chat/server/server.ts +0 -178
- package/src/chat/server/sessionFileManager.ts +0 -151
- package/src/chat/server/sessionRegistry.test.ts +0 -137
- package/src/chat/server/sessionRegistry.ts +0 -1553
- package/src/chat/server/test-utils/mockFactories.ts +0 -422
- package/src/chat/server/titleGenerator.test.ts +0 -103
- package/src/chat/server/titleGenerator.ts +0 -143
- package/src/chat/server/tools.ts +0 -170
- package/src/chat/utils/agentSessionMap.ts +0 -76
- package/src/chat/utils/approvalManager.ts +0 -189
- package/src/chat/utils/asyncLock.ts +0 -43
- package/src/chat/utils/asyncQueue.ts +0 -62
- package/src/chat/utils/multiAsyncQueue.ts +0 -66
- package/src/chat/utils/responseAwaiter.ts +0 -181
- package/src/chat/utils/userResolver.ts +0 -48
- package/src/chat/utils/websocket.ts +0 -16
- package/src/index.ts +0 -0
- package/src/test/agent.test.ts +0 -584
- package/src/test/approvalManager.test.ts +0 -141
- package/src/test/chatContextManager.test.ts +0 -552
- package/src/test/clientServerConnection.test.ts +0 -205
- package/src/test/compressingContextManager.test.ts +0 -77
- package/src/test/context.test.ts +0 -150
- package/src/test/contextTestTools.ts +0 -95
- package/src/test/conversation.test.ts +0 -109
- package/src/test/db.test.ts +0 -363
- package/src/test/dbMcpServerConfigs.test.ts +0 -112
- package/src/test/dbSessionFiles.test.ts +0 -258
- package/src/test/dbSessionMessages.test.ts +0 -85
- package/src/test/dbTestTools.ts +0 -157
- package/src/test/imageLoad.test.ts +0 -15
- package/src/test/mcpServerManager.test.ts +0 -114
- package/src/test/multiAsyncQueue.test.ts +0 -183
- package/src/test/openaiStreaming.test.ts +0 -177
- package/src/test/prompt.test.ts +0 -27
- package/src/test/promptProvider.test.ts +0 -33
- package/src/test/responseAwaiter.test.ts +0 -103
- package/src/test/sudoMcpServerManager.test.ts +0 -63
- package/src/test/testTools.ts +0 -176
- package/src/test/tools.test.ts +0 -64
- package/src/tool/agentChat.ts +0 -203
- package/src/tool/agentMain.ts +0 -180
- package/src/tool/chatMain.ts +0 -621
- package/src/tool/commandPrompt.ts +0 -264
- package/src/tool/files.ts +0 -82
- package/src/tool/main.ts +0 -25
- package/src/tool/nodePlatform.ts +0 -73
- package/src/tool/options.ts +0 -144
- package/src/tool/prompt.ts +0 -101
- package/test_data/background_test_profile.json +0 -6
- package/test_data/background_test_script.json +0 -11
- package/test_data/dummyllm_script_crash.json +0 -32
- package/test_data/dummyllm_script_image_gen.json +0 -19
- package/test_data/dummyllm_script_image_gen_fe.json +0 -29
- package/test_data/dummyllm_script_invoke_image_gen_tool.json +0 -37
- package/test_data/dummyllm_script_render_tool.json +0 -29
- package/test_data/dummyllm_script_simplecalc.json +0 -28
- package/test_data/dummyllm_script_test_auto_approve.json +0 -81
- package/test_data/dummyllm_script_test_simplecalc_addition.json +0 -29
- package/test_data/frog.png +0 -0
- package/test_data/frog.png.b64 +0 -1
- package/test_data/git_message_profile.json +0 -4
- package/test_data/git_wip_system.txt +0 -5
- package/test_data/image_gen_test_profile.json +0 -5
- package/test_data/pr_message_profile.json +0 -4
- package/test_data/pr_review_profile.json +0 -4
- package/test_data/prompt_simplecalc.txt +0 -1
- package/test_data/simplecalc_profile.json +0 -4
- package/test_data/sudomcp_import_profile.json +0 -4
- package/test_data/test_script_profile.json +0 -8
- package/tsconfig.json +0 -13
- package/vitest.config.ts +0 -39
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { McpServerConfiguration } from "@xalia/xmcp/sdk";
|
|
2
|
-
import { DbClientBase } from "./database";
|
|
3
|
-
|
|
4
|
-
export class DbMcpServerConfigs extends DbClientBase {
|
|
5
|
-
async clearConfigsForUser(user_uuid: string): Promise<void> {
|
|
6
|
-
const { error } = await this.client
|
|
7
|
-
.from("user_server_configs")
|
|
8
|
-
.delete()
|
|
9
|
-
.eq("user_uuid", user_uuid);
|
|
10
|
-
if (error) {
|
|
11
|
-
throw error;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async deleteConfigForUser(
|
|
16
|
-
user_uuid: string,
|
|
17
|
-
server_name: string
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
const { error } = await this.client
|
|
20
|
-
.from("user_server_configs")
|
|
21
|
-
.delete()
|
|
22
|
-
.eq("user_uuid", user_uuid)
|
|
23
|
-
.eq("server_name", server_name);
|
|
24
|
-
if (error) {
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async getConfigForUser(
|
|
30
|
-
user_uuid: string,
|
|
31
|
-
server_name: string
|
|
32
|
-
): Promise<McpServerConfiguration | undefined> {
|
|
33
|
-
const { error, data } = await this.client
|
|
34
|
-
.from("user_server_configs")
|
|
35
|
-
.select("config")
|
|
36
|
-
.eq("user_uuid", user_uuid)
|
|
37
|
-
.eq("server_name", server_name)
|
|
38
|
-
.maybeSingle();
|
|
39
|
-
if (error) {
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return data ? (data.config as McpServerConfiguration) : undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async setConfigForUser(
|
|
47
|
-
user_uuid: string,
|
|
48
|
-
server_name: string,
|
|
49
|
-
config: McpServerConfiguration
|
|
50
|
-
): Promise<void> {
|
|
51
|
-
const payload = { user_uuid, server_name, config };
|
|
52
|
-
const { error } = await this.client
|
|
53
|
-
.from("user_server_configs")
|
|
54
|
-
.upsert([payload], { onConflict: "user_uuid,server_name" });
|
|
55
|
-
if (error) {
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { strict as assert } from "assert";
|
|
2
|
-
|
|
3
|
-
import type * as supabase from "../../../../supabase/database.types";
|
|
4
|
-
|
|
5
|
-
import { DbClientBase } from "./database";
|
|
6
|
-
import {
|
|
7
|
-
SessionFileDescriptor,
|
|
8
|
-
ParsedContent,
|
|
9
|
-
getSessionFileMimeTypeFromDataUrl,
|
|
10
|
-
isSessionFileMimeType,
|
|
11
|
-
isParsedContent,
|
|
12
|
-
} from "../../agent/tools/fileManager";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A DB client for SessionFileManager
|
|
16
|
-
*/
|
|
17
|
-
export class DbSessionFiles extends DbClientBase {
|
|
18
|
-
async clearFiles(session_uuid: string): Promise<void> {
|
|
19
|
-
const { error } = await this.client
|
|
20
|
-
.from("session_files")
|
|
21
|
-
.delete()
|
|
22
|
-
.eq("session_uuid", session_uuid);
|
|
23
|
-
if (error) {
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async getFilesForSession(
|
|
29
|
-
session_uuid: string
|
|
30
|
-
): Promise<SessionFileDescriptor[]> {
|
|
31
|
-
const { data, error } = await this.client
|
|
32
|
-
.from("session_files")
|
|
33
|
-
.select("name, summary, mime_type, parsed_content")
|
|
34
|
-
.eq("session_uuid", session_uuid);
|
|
35
|
-
if (error) {
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return data.map((fd) => {
|
|
40
|
-
assert(isSessionFileMimeType(fd.mime_type));
|
|
41
|
-
const desc: SessionFileDescriptor = {
|
|
42
|
-
name: fd.name as string,
|
|
43
|
-
mime_type: fd.mime_type,
|
|
44
|
-
summary: (fd.summary as string) || undefined,
|
|
45
|
-
};
|
|
46
|
-
if (isParsedContent(fd.parsed_content)) {
|
|
47
|
-
desc.parsed_content = fd.parsed_content;
|
|
48
|
-
}
|
|
49
|
-
return desc;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async getFileContent(
|
|
54
|
-
session_uuid: string,
|
|
55
|
-
name: string
|
|
56
|
-
): Promise<string | undefined> {
|
|
57
|
-
const { data, error } = await this.client
|
|
58
|
-
.from("session_files")
|
|
59
|
-
.select("data_url")
|
|
60
|
-
.eq("session_uuid", session_uuid)
|
|
61
|
-
.eq("name", name)
|
|
62
|
-
.maybeSingle<{
|
|
63
|
-
data_url: supabase.Tables<"session_files">["data_url"];
|
|
64
|
-
}>();
|
|
65
|
-
if (error) {
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return data ? data.data_url : undefined;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async setFileContent(
|
|
73
|
-
session_uuid: string,
|
|
74
|
-
name: string,
|
|
75
|
-
summary: string | undefined,
|
|
76
|
-
data_url: string,
|
|
77
|
-
parsed_content?: ParsedContent
|
|
78
|
-
): Promise<void> {
|
|
79
|
-
const mime_type = getSessionFileMimeTypeFromDataUrl(data_url);
|
|
80
|
-
const payload: supabase.TablesUpdate<"session_files"> = {
|
|
81
|
-
session_uuid,
|
|
82
|
-
name,
|
|
83
|
-
summary,
|
|
84
|
-
mime_type,
|
|
85
|
-
data_url,
|
|
86
|
-
parsed_content: parsed_content ?? null,
|
|
87
|
-
};
|
|
88
|
-
const { error } = await this.client
|
|
89
|
-
.from("session_files")
|
|
90
|
-
.upsert([payload], { onConflict: "session_uuid,name" });
|
|
91
|
-
|
|
92
|
-
if (error) {
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async deleteFile(session_uuid: string, name: string): Promise<void> {
|
|
98
|
-
const { error } = await this.client
|
|
99
|
-
.from("session_files")
|
|
100
|
-
.delete()
|
|
101
|
-
.eq("session_uuid", session_uuid)
|
|
102
|
-
.eq("name", name);
|
|
103
|
-
if (error) {
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { DbClientBase } from "./database";
|
|
2
|
-
import { SessionMessage } from "./dataModels";
|
|
3
|
-
|
|
4
|
-
export class DbSessionMessages extends DbClientBase {
|
|
5
|
-
async clearConversation(session_uuid: string): Promise<void> {
|
|
6
|
-
const { error } = await this.client
|
|
7
|
-
.from("session_messages")
|
|
8
|
-
.delete()
|
|
9
|
-
.eq("session_uuid", session_uuid);
|
|
10
|
-
if (error) {
|
|
11
|
-
throw error;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async getConversation(
|
|
16
|
-
session_uuid: string,
|
|
17
|
-
numEntries: number,
|
|
18
|
-
beforeIndex?: number
|
|
19
|
-
): Promise<SessionMessage[]> {
|
|
20
|
-
// Query all message for the given session, ordered high-to-low by
|
|
21
|
-
// message_idx, limited to `numEntries`. If `beforeIndex` is given, it
|
|
22
|
-
// means we get messages with `message_idx < beforeIndex`
|
|
23
|
-
|
|
24
|
-
let query = this.client
|
|
25
|
-
.from("session_messages")
|
|
26
|
-
.select("message_idx,sender_uuid,is_for_llm,content")
|
|
27
|
-
.eq("session_uuid", session_uuid);
|
|
28
|
-
if (beforeIndex) {
|
|
29
|
-
query = query.lt("message_idx", beforeIndex);
|
|
30
|
-
}
|
|
31
|
-
query = query.order("message_idx", { ascending: false }).limit(numEntries);
|
|
32
|
-
|
|
33
|
-
const { data, error } = await query;
|
|
34
|
-
if (error) {
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// To get the newest N messages, we've orded by index largest to smallest
|
|
39
|
-
// (newest first), but caller wants the message first to last, hence
|
|
40
|
-
// reverse the array.
|
|
41
|
-
|
|
42
|
-
return data
|
|
43
|
-
.map(({ sender_uuid, ...rest }) => {
|
|
44
|
-
return typeof sender_uuid === "string"
|
|
45
|
-
? {
|
|
46
|
-
sender_uuid,
|
|
47
|
-
...rest,
|
|
48
|
-
}
|
|
49
|
-
: { ...rest };
|
|
50
|
-
})
|
|
51
|
-
.reverse();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async append(
|
|
55
|
-
session_uuid: string,
|
|
56
|
-
messages: SessionMessage[]
|
|
57
|
-
): Promise<void> {
|
|
58
|
-
const payload = messages.map((m) => {
|
|
59
|
-
return { ...m, session_uuid };
|
|
60
|
-
});
|
|
61
|
-
const { error } = await this.client
|
|
62
|
-
.from("session_messages")
|
|
63
|
-
.insert(payload);
|
|
64
|
-
if (error) {
|
|
65
|
-
throw error;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async searchMessages(
|
|
70
|
-
userUuid: string,
|
|
71
|
-
searchQuery: string,
|
|
72
|
-
limit = 50
|
|
73
|
-
): Promise<
|
|
74
|
-
Array<{
|
|
75
|
-
session_uuid: string;
|
|
76
|
-
message_idx: number;
|
|
77
|
-
sender_uuid?: string;
|
|
78
|
-
content: unknown;
|
|
79
|
-
match_snippet: string;
|
|
80
|
-
}>
|
|
81
|
-
> {
|
|
82
|
-
type SearchResult = {
|
|
83
|
-
session_uuid: string;
|
|
84
|
-
message_idx: number;
|
|
85
|
-
sender_uuid?: string;
|
|
86
|
-
content: unknown;
|
|
87
|
-
match_snippet: string;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const result = await this.client.rpc("search_session_messages", {
|
|
91
|
-
p_user_uuid: userUuid,
|
|
92
|
-
p_search_query: searchQuery,
|
|
93
|
-
p_limit: limit,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
if (result.error) {
|
|
97
|
-
throw result.error;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return (result.data as SearchResult[] | null) || [];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Connection-level Client Messages
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
export type ClientConnectionData<T> = {
|
|
6
|
-
t: "data";
|
|
7
|
-
d: T;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ClientConnectionPong = {
|
|
11
|
-
t: "pong";
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type ClientConnectionMessage<T> =
|
|
15
|
-
| ClientConnectionData<T> // TODO: generic
|
|
16
|
-
| ClientConnectionPong;
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
// Connection-Level Server Messages (Transport)
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Response to connection init
|
|
24
|
-
*/
|
|
25
|
-
export type ServerConnectionReady = {
|
|
26
|
-
t: "ready";
|
|
27
|
-
c_id: string; // TODO: remove
|
|
28
|
-
user_uuid: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type ServerConnectionError = {
|
|
32
|
-
t: "error";
|
|
33
|
-
e: string;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type ServerConnectionPing = {
|
|
37
|
-
t: "ping";
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type ServerConnectionData<T> = {
|
|
41
|
-
t: "data";
|
|
42
|
-
d: T;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type ServerConnectionMessage<T> =
|
|
46
|
-
| ServerConnectionReady
|
|
47
|
-
| ServerConnectionError
|
|
48
|
-
| ServerConnectionPing
|
|
49
|
-
| ServerConnectionData<T>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Protocol constants for the multi-session chat system
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Current version of the agent package
|
|
7
|
-
*/
|
|
8
|
-
export const AGENT_VERSION = "0.5.9";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Protocol version for WebSocket communication
|
|
12
|
-
*/
|
|
13
|
-
export const PROTOCOL_VERSION = AGENT_VERSION;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Client version sent in connection handshake
|
|
17
|
-
*/
|
|
18
|
-
export const CLIENT_VERSION = AGENT_VERSION;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Server version sent in connection handshake responses
|
|
22
|
-
*/
|
|
23
|
-
export const SERVER_VERSION = AGENT_VERSION;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Default message queue limits
|
|
27
|
-
*/
|
|
28
|
-
export const DEFAULT_MESSAGE_QUEUE_SIZE = 100;
|
|
29
|
-
export const DEFAULT_USER_MESSAGE_QUEUE_SIZE = 10;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Connection timeouts (in milliseconds)
|
|
33
|
-
*/
|
|
34
|
-
export const CONNECTION_READY_TIMEOUT = 2000; // 2 seconds
|
|
35
|
-
export const MESSAGE_PROCESSING_TIMEOUT = 10000; // 10 seconds
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* WebSocket close codes used by the chat system
|
|
39
|
-
* see: https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1
|
|
40
|
-
*/
|
|
41
|
-
export const CHAT_CLOSE_CODES = {
|
|
42
|
-
NORMAL_CLOSURE: 1000,
|
|
43
|
-
GOING_AWAY: 1001,
|
|
44
|
-
PROTOCOL_ERROR: 1002,
|
|
45
|
-
INVALID_DATA: 1007,
|
|
46
|
-
// 4000-4999: application-defined error codes
|
|
47
|
-
AUTH_FAILED: 4003,
|
|
48
|
-
SESSION_ERROR: 4402,
|
|
49
|
-
RATE_LIMITED: 4403,
|
|
50
|
-
} as const;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Maximum message size in bytes
|
|
54
|
-
*/
|
|
55
|
-
export const MAX_MESSAGE_SIZE = 64 * 1024; // 64KB
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An error resulting the the connection being closed
|
|
3
|
-
*/
|
|
4
|
-
export class ChatFatalError extends Error {}
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* An error to be reported, but not resulting in termination of the
|
|
8
|
-
* connection.
|
|
9
|
-
*/
|
|
10
|
-
export class ChatErrorMessage extends Error {}
|
|
11
|
-
|
|
12
|
-
export class UserAlreadyConnected extends ChatFatalError {
|
|
13
|
-
constructor() {
|
|
14
|
-
super("User already connected to the conversation");
|
|
15
|
-
}
|
|
16
|
-
}
|