@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.
Files changed (161) hide show
  1. package/package.json +5 -2
  2. package/.env.development +0 -6
  3. package/.env.test +0 -7
  4. package/.prettierrc.json +0 -11
  5. package/context_system.md +0 -498
  6. package/eslint.config.mjs +0 -38
  7. package/scripts/chat_server +0 -8
  8. package/scripts/git_message +0 -31
  9. package/scripts/git_wip +0 -21
  10. package/scripts/pr_message +0 -18
  11. package/scripts/pr_review +0 -16
  12. package/scripts/setup_chat +0 -90
  13. package/scripts/shutdown_chat_server +0 -42
  14. package/scripts/start_chat_server +0 -24
  15. package/scripts/sudomcp_import +0 -23
  16. package/scripts/test_chat +0 -327
  17. package/src/agent/agent.ts +0 -699
  18. package/src/agent/agentUtils.ts +0 -286
  19. package/src/agent/compressingContextManager.ts +0 -129
  20. package/src/agent/context.ts +0 -265
  21. package/src/agent/contextWithWorkspace.ts +0 -162
  22. package/src/agent/documentSummarizer.ts +0 -157
  23. package/src/agent/dummyLLM.ts +0 -130
  24. package/src/agent/iAgentEventHandler.ts +0 -64
  25. package/src/agent/imageGenLLM.ts +0 -101
  26. package/src/agent/imageGenerator.ts +0 -45
  27. package/src/agent/iplatform.ts +0 -18
  28. package/src/agent/llm.ts +0 -74
  29. package/src/agent/mcpServerManager.ts +0 -541
  30. package/src/agent/nullAgentEventHandler.ts +0 -26
  31. package/src/agent/nullPlatform.ts +0 -13
  32. package/src/agent/openAI.ts +0 -123
  33. package/src/agent/openAILLM.ts +0 -99
  34. package/src/agent/openAILLMStreaming.ts +0 -648
  35. package/src/agent/promptProvider.ts +0 -87
  36. package/src/agent/repeatLLM.ts +0 -62
  37. package/src/agent/sudoMcpServerManager.ts +0 -361
  38. package/src/agent/test_data/harrypotter.txt +0 -6065
  39. package/src/agent/tokenAuth.ts +0 -50
  40. package/src/agent/tokenCounter.test.ts +0 -243
  41. package/src/agent/tokenCounter.ts +0 -483
  42. package/src/agent/toolSettings.ts +0 -24
  43. package/src/agent/tools/calculatorTool.ts +0 -50
  44. package/src/agent/tools/contentExtractors/htmlToText.ts +0 -61
  45. package/src/agent/tools/contentExtractors/pdfToText.ts +0 -60
  46. package/src/agent/tools/datetimeTool.ts +0 -41
  47. package/src/agent/tools/fileManager/fileManagerTool.ts +0 -199
  48. package/src/agent/tools/fileManager/index.ts +0 -50
  49. package/src/agent/tools/fileManager/memoryFileManager.ts +0 -120
  50. package/src/agent/tools/fileManager/mimeTypes.ts +0 -60
  51. package/src/agent/tools/fileManager/prompt.ts +0 -38
  52. package/src/agent/tools/fileManager/types.ts +0 -189
  53. package/src/agent/tools/index.ts +0 -49
  54. package/src/agent/tools/openUrlTool.ts +0 -62
  55. package/src/agent/tools/renderTool.ts +0 -92
  56. package/src/agent/tools/utils.ts +0 -74
  57. package/src/agent/tools/webSearch.ts +0 -138
  58. package/src/agent/tools/webSearchTool.ts +0 -44
  59. package/src/chat/client/chatClient.ts +0 -967
  60. package/src/chat/client/connection.test.ts +0 -241
  61. package/src/chat/client/connection.ts +0 -286
  62. package/src/chat/client/constants.ts +0 -1
  63. package/src/chat/client/index.ts +0 -21
  64. package/src/chat/client/interfaces.ts +0 -34
  65. package/src/chat/client/sessionClient.ts +0 -574
  66. package/src/chat/client/sessionFiles.ts +0 -142
  67. package/src/chat/client/teamManager.ts +0 -29
  68. package/src/chat/constants.ts +0 -6
  69. package/src/chat/data/apiKeyManager.ts +0 -76
  70. package/src/chat/data/dataModels.ts +0 -107
  71. package/src/chat/data/database.ts +0 -997
  72. package/src/chat/data/dbMcpServerConfigs.ts +0 -59
  73. package/src/chat/data/dbSessionFiles.ts +0 -107
  74. package/src/chat/data/dbSessionMessages.ts +0 -102
  75. package/src/chat/protocol/connectionMessages.ts +0 -49
  76. package/src/chat/protocol/constants.ts +0 -55
  77. package/src/chat/protocol/errors.ts +0 -16
  78. package/src/chat/protocol/messages.ts +0 -899
  79. package/src/chat/server/README.md +0 -127
  80. package/src/chat/server/chatContextManager.ts +0 -660
  81. package/src/chat/server/connectionManager.test.ts +0 -246
  82. package/src/chat/server/connectionManager.ts +0 -506
  83. package/src/chat/server/conversation.ts +0 -319
  84. package/src/chat/server/errorUtils.ts +0 -28
  85. package/src/chat/server/imageGeneratorTools.ts +0 -179
  86. package/src/chat/server/openAIRouterLLM.ts +0 -168
  87. package/src/chat/server/openSession.ts +0 -1945
  88. package/src/chat/server/openSessionMessageSender.ts +0 -4
  89. package/src/chat/server/promptRefiner.ts +0 -106
  90. package/src/chat/server/server.ts +0 -178
  91. package/src/chat/server/sessionFileManager.ts +0 -151
  92. package/src/chat/server/sessionRegistry.test.ts +0 -137
  93. package/src/chat/server/sessionRegistry.ts +0 -1553
  94. package/src/chat/server/test-utils/mockFactories.ts +0 -422
  95. package/src/chat/server/titleGenerator.test.ts +0 -103
  96. package/src/chat/server/titleGenerator.ts +0 -143
  97. package/src/chat/server/tools.ts +0 -170
  98. package/src/chat/utils/agentSessionMap.ts +0 -76
  99. package/src/chat/utils/approvalManager.ts +0 -189
  100. package/src/chat/utils/asyncLock.ts +0 -43
  101. package/src/chat/utils/asyncQueue.ts +0 -62
  102. package/src/chat/utils/multiAsyncQueue.ts +0 -66
  103. package/src/chat/utils/responseAwaiter.ts +0 -181
  104. package/src/chat/utils/userResolver.ts +0 -48
  105. package/src/chat/utils/websocket.ts +0 -16
  106. package/src/index.ts +0 -0
  107. package/src/test/agent.test.ts +0 -584
  108. package/src/test/approvalManager.test.ts +0 -141
  109. package/src/test/chatContextManager.test.ts +0 -552
  110. package/src/test/clientServerConnection.test.ts +0 -205
  111. package/src/test/compressingContextManager.test.ts +0 -77
  112. package/src/test/context.test.ts +0 -150
  113. package/src/test/contextTestTools.ts +0 -95
  114. package/src/test/conversation.test.ts +0 -109
  115. package/src/test/db.test.ts +0 -363
  116. package/src/test/dbMcpServerConfigs.test.ts +0 -112
  117. package/src/test/dbSessionFiles.test.ts +0 -258
  118. package/src/test/dbSessionMessages.test.ts +0 -85
  119. package/src/test/dbTestTools.ts +0 -157
  120. package/src/test/imageLoad.test.ts +0 -15
  121. package/src/test/mcpServerManager.test.ts +0 -114
  122. package/src/test/multiAsyncQueue.test.ts +0 -183
  123. package/src/test/openaiStreaming.test.ts +0 -177
  124. package/src/test/prompt.test.ts +0 -27
  125. package/src/test/promptProvider.test.ts +0 -33
  126. package/src/test/responseAwaiter.test.ts +0 -103
  127. package/src/test/sudoMcpServerManager.test.ts +0 -63
  128. package/src/test/testTools.ts +0 -176
  129. package/src/test/tools.test.ts +0 -64
  130. package/src/tool/agentChat.ts +0 -203
  131. package/src/tool/agentMain.ts +0 -180
  132. package/src/tool/chatMain.ts +0 -621
  133. package/src/tool/commandPrompt.ts +0 -264
  134. package/src/tool/files.ts +0 -82
  135. package/src/tool/main.ts +0 -25
  136. package/src/tool/nodePlatform.ts +0 -73
  137. package/src/tool/options.ts +0 -144
  138. package/src/tool/prompt.ts +0 -101
  139. package/test_data/background_test_profile.json +0 -6
  140. package/test_data/background_test_script.json +0 -11
  141. package/test_data/dummyllm_script_crash.json +0 -32
  142. package/test_data/dummyllm_script_image_gen.json +0 -19
  143. package/test_data/dummyllm_script_image_gen_fe.json +0 -29
  144. package/test_data/dummyllm_script_invoke_image_gen_tool.json +0 -37
  145. package/test_data/dummyllm_script_render_tool.json +0 -29
  146. package/test_data/dummyllm_script_simplecalc.json +0 -28
  147. package/test_data/dummyllm_script_test_auto_approve.json +0 -81
  148. package/test_data/dummyllm_script_test_simplecalc_addition.json +0 -29
  149. package/test_data/frog.png +0 -0
  150. package/test_data/frog.png.b64 +0 -1
  151. package/test_data/git_message_profile.json +0 -4
  152. package/test_data/git_wip_system.txt +0 -5
  153. package/test_data/image_gen_test_profile.json +0 -5
  154. package/test_data/pr_message_profile.json +0 -4
  155. package/test_data/pr_review_profile.json +0 -4
  156. package/test_data/prompt_simplecalc.txt +0 -1
  157. package/test_data/simplecalc_profile.json +0 -4
  158. package/test_data/sudomcp_import_profile.json +0 -4
  159. package/test_data/test_script_profile.json +0 -8
  160. package/tsconfig.json +0 -13
  161. 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
- }
@@ -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
- };