@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,29 +0,0 @@
|
|
|
1
|
-
import { ClientTeamInfo } from "./chatClient";
|
|
2
|
-
import { AgentSessionData } from "../data/dataModels";
|
|
3
|
-
|
|
4
|
-
export interface ITeamManager {
|
|
5
|
-
/**
|
|
6
|
-
* Get the map of teams, keys are team UUIDs
|
|
7
|
-
*/
|
|
8
|
-
getTeams(): Map<string, ClientTeamInfo>;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Get the current team ID
|
|
12
|
-
*/
|
|
13
|
-
getCurrentTeamId(): string | undefined;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Get the current team info
|
|
17
|
-
*/
|
|
18
|
-
getCurrentTeamInfo(): ClientTeamInfo | undefined;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Set the current team ID
|
|
22
|
-
*/
|
|
23
|
-
setCurrentTeamId(teamUuid: string): void;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get the agent session map of a user
|
|
27
|
-
*/
|
|
28
|
-
getUserAgentSessionMap(): Map<string, AgentSessionData>;
|
|
29
|
-
}
|
package/src/chat/constants.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// Shared constants that can be imported by both frontend and backend.
|
|
2
|
-
// Keep this file free of Node.js-specific dependencies.
|
|
3
|
-
|
|
4
|
-
// Well-known filename for the canvas workspace image that gets auto-saved
|
|
5
|
-
// when the user sends a message while on the canvas tab.
|
|
6
|
-
export const CANVAS_WORKSPACE_FILENAME = "_canvas_workspace.png";
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// TODO:
|
|
2
|
-
// - lru-cache
|
|
3
|
-
|
|
4
|
-
import { Database, UserData } from "./database";
|
|
5
|
-
import { getLogger } from "@xalia/xmcp/sdk";
|
|
6
|
-
|
|
7
|
-
const logger = getLogger();
|
|
8
|
-
|
|
9
|
-
const API_KEY_ALPHABET =
|
|
10
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
11
|
-
|
|
12
|
-
export class ApiKeyManager {
|
|
13
|
-
constructor(private db: Database) {}
|
|
14
|
-
|
|
15
|
-
public static PREFIX = "xmcp";
|
|
16
|
-
|
|
17
|
-
public async verifyApiKey(apiKey: string): Promise<UserData | undefined> {
|
|
18
|
-
// TODO: Cache this
|
|
19
|
-
logger.info(`[ApiKeyManager] Verifying API key: ${apiKey}`);
|
|
20
|
-
const userInfo = await this.db.getUserDataFromApiKey(apiKey);
|
|
21
|
-
logger.info(`[ApiKeyManager] User info: ${JSON.stringify(userInfo)}`);
|
|
22
|
-
return userInfo;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Creates a standard api key of the form:
|
|
27
|
-
*
|
|
28
|
-
* <prefix>_<[A-Z][a-z][0-9]+....>
|
|
29
|
-
*
|
|
30
|
-
* matching the format used in the mcppro backend
|
|
31
|
-
*/
|
|
32
|
-
public static createApiKey(
|
|
33
|
-
prefix: string = ApiKeyManager.PREFIX,
|
|
34
|
-
length: number = 32
|
|
35
|
-
): string {
|
|
36
|
-
// See mcppro/app/server/api_key.py:
|
|
37
|
-
//
|
|
38
|
-
// def create_api_key(prefix: str, length: int = 32) -> str:
|
|
39
|
-
// ...
|
|
40
|
-
|
|
41
|
-
const chars = Array.from({ length }, () => {
|
|
42
|
-
const i = Math.floor(Math.random() * API_KEY_ALPHABET.length);
|
|
43
|
-
return API_KEY_ALPHABET[i];
|
|
44
|
-
}).join("");
|
|
45
|
-
return `${prefix}_${chars}`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Creates an api key of the form:
|
|
50
|
-
*
|
|
51
|
-
* <prefix>_<[A-Z][a-z][0-9]+....>/<payload>
|
|
52
|
-
*
|
|
53
|
-
* where <payload> is used to convey extra data.
|
|
54
|
-
*/
|
|
55
|
-
public static createApiKeyWithPayload(
|
|
56
|
-
prefix: string,
|
|
57
|
-
payload: string,
|
|
58
|
-
length: number = 32
|
|
59
|
-
): string {
|
|
60
|
-
return `${ApiKeyManager.createApiKey(prefix, length)}_${payload}`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Parse token (containing an api and optional payload)
|
|
65
|
-
*/
|
|
66
|
-
public static parseToken(token: string): {
|
|
67
|
-
prefix: string;
|
|
68
|
-
apiKey: string;
|
|
69
|
-
payload: string | undefined;
|
|
70
|
-
} {
|
|
71
|
-
const [prefix, apiKeyVal, payload] = token.split("_");
|
|
72
|
-
const apiKey = `${prefix}_${apiKeyVal}`;
|
|
73
|
-
|
|
74
|
-
return { prefix, apiKey, payload };
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { SavedAgentProfile } from "@xalia/xmcp/sdk";
|
|
2
|
-
import { MessageParam } from "../../agent/llm";
|
|
3
|
-
|
|
4
|
-
export type AttachedFile = {
|
|
5
|
-
name: string;
|
|
6
|
-
data_url: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type UserMessageData = {
|
|
10
|
-
message?: string | undefined;
|
|
11
|
-
imageB64?: string | undefined;
|
|
12
|
-
attachedFiles?: AttachedFile[] | undefined;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type TeamRole = "owner" | "participant";
|
|
16
|
-
|
|
17
|
-
export type TeamParticipant = {
|
|
18
|
-
user_uuid: string;
|
|
19
|
-
nickname: string;
|
|
20
|
-
email: string;
|
|
21
|
-
role: TeamRole;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type SessionMessage = {
|
|
25
|
-
message_idx: number;
|
|
26
|
-
sender_uuid?: string;
|
|
27
|
-
is_for_llm: boolean;
|
|
28
|
-
content: MessageParam;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type LLMSessionMessage = {
|
|
32
|
-
message_idx: number;
|
|
33
|
-
sender_uuid: string;
|
|
34
|
-
content: MessageParam;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Checkpoint data for a specific conversation.
|
|
39
|
-
*/
|
|
40
|
-
export type SessionCheckpoint = {
|
|
41
|
-
/**
|
|
42
|
-
* Index of last message included in this checkpoint.
|
|
43
|
-
*/
|
|
44
|
-
message_idx: number;
|
|
45
|
-
/**
|
|
46
|
-
* Summary of the conversation up to and including `message_idx`.
|
|
47
|
-
*/
|
|
48
|
-
summary: string;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Session data required to create a new session.
|
|
53
|
-
*/
|
|
54
|
-
export type SessionCreateData = {
|
|
55
|
-
session_uuid: string;
|
|
56
|
-
title: string;
|
|
57
|
-
agent_profile_uuid: string;
|
|
58
|
-
user_uuid: string;
|
|
59
|
-
|
|
60
|
-
team_uuid?: string | undefined;
|
|
61
|
-
participants?: Array<TeamParticipant>;
|
|
62
|
-
access_token?: string;
|
|
63
|
-
agent_paused: boolean;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/*
|
|
67
|
-
* Description of (unjoined) sessions.
|
|
68
|
-
*/
|
|
69
|
-
export type SessionDescriptor = SessionCreateData & {
|
|
70
|
-
updated_at: string;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Data for existing session, including any workspace data
|
|
75
|
-
*/
|
|
76
|
-
export type SessionData = SessionDescriptor & {
|
|
77
|
-
workspace?: UserMessageData | undefined;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export type AgentSessionData = {
|
|
81
|
-
agent_profile: SavedAgentProfile;
|
|
82
|
-
sessions: SessionDescriptor[];
|
|
83
|
-
updated_at: number;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Team sessions for ServerSessionList response
|
|
88
|
-
*/
|
|
89
|
-
export type TeamInfo = {
|
|
90
|
-
team_uuid: string;
|
|
91
|
-
team_name: string;
|
|
92
|
-
owner_uuid: string;
|
|
93
|
-
participants: Array<TeamParticipant>;
|
|
94
|
-
sessions: Array<SessionDescriptor>;
|
|
95
|
-
agents: Array<SavedAgentProfile>;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Map from user_uuid to role
|
|
100
|
-
*/
|
|
101
|
-
export type SessionParticipantMap = Map<string, TeamParticipant>;
|
|
102
|
-
|
|
103
|
-
export type CustomMcpServerDescriptor = {
|
|
104
|
-
name: string;
|
|
105
|
-
description: string;
|
|
106
|
-
url: string;
|
|
107
|
-
};
|