@hailer/mcp 0.1.16 → 0.2.1

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 (202) hide show
  1. package/dist/app.js +24 -20
  2. package/dist/core.d.ts +33 -9
  3. package/dist/core.js +279 -147
  4. package/dist/mcp/UserContextCache.js +18 -0
  5. package/dist/mcp/hailer-clients.d.ts +9 -1
  6. package/dist/mcp/hailer-clients.js +13 -3
  7. package/dist/mcp/signal-handler.js +1 -1
  8. package/dist/mcp/tool-registry.d.ts +3 -1
  9. package/dist/mcp/tool-registry.js +4 -1
  10. package/dist/mcp/tools/activity.js +43 -34
  11. package/dist/mcp/tools/bot-config/constants.d.ts +23 -0
  12. package/dist/mcp/tools/bot-config/constants.js +94 -0
  13. package/dist/mcp/tools/{bot-config.d.ts → bot-config/core.d.ts} +6 -6
  14. package/dist/mcp/tools/{bot-config.js → bot-config/core.js} +15 -15
  15. package/dist/mcp/tools/bot-config/index.d.ts +10 -0
  16. package/dist/mcp/tools/bot-config/index.js +59 -0
  17. package/dist/mcp/tools/bot-config/tools.d.ts +7 -0
  18. package/dist/mcp/tools/bot-config/tools.js +15 -0
  19. package/dist/mcp/tools/bot-config/types.d.ts +50 -0
  20. package/dist/mcp/tools/bot-config/types.js +6 -0
  21. package/dist/mcp/tools/bug-fixer-tools.d.ts +21 -0
  22. package/dist/mcp/tools/{giuseppe-tools.js → bug-fixer-tools.js} +61 -61
  23. package/dist/mcp/tools/user.js +10 -29
  24. package/dist/mcp/tools/workflow.js +36 -2
  25. package/dist/mcp/utils/data-transformers.d.ts +0 -8
  26. package/dist/mcp/utils/data-transformers.js +0 -28
  27. package/dist/mcp/utils/index.d.ts +4 -1
  28. package/dist/mcp/utils/index.js +17 -3
  29. package/dist/mcp/utils/pagination.d.ts +40 -0
  30. package/dist/mcp/utils/pagination.js +55 -0
  31. package/dist/mcp/utils/response-builder.d.ts +53 -0
  32. package/dist/mcp/utils/response-builder.js +110 -0
  33. package/dist/mcp/utils/tool-helpers.d.ts +0 -8
  34. package/dist/mcp/utils/tool-helpers.js +0 -24
  35. package/dist/mcp/utils/types.d.ts +1 -33
  36. package/dist/mcp/webhook-handler.d.ts +2 -2
  37. package/dist/mcp/webhook-handler.js +5 -3
  38. package/dist/mcp-server.d.ts +2 -2
  39. package/dist/mcp-server.js +167 -140
  40. package/package.json +1 -1
  41. package/REFACTOR_STATUS.md +0 -127
  42. package/dist/agents/bot-manager.d.ts +0 -48
  43. package/dist/agents/bot-manager.js +0 -254
  44. package/dist/agents/factory.d.ts +0 -150
  45. package/dist/agents/factory.js +0 -650
  46. package/dist/agents/giuseppe/ai.d.ts +0 -83
  47. package/dist/agents/giuseppe/ai.js +0 -466
  48. package/dist/agents/giuseppe/bot.d.ts +0 -110
  49. package/dist/agents/giuseppe/bot.js +0 -780
  50. package/dist/agents/giuseppe/config.d.ts +0 -25
  51. package/dist/agents/giuseppe/config.js +0 -227
  52. package/dist/agents/giuseppe/files.d.ts +0 -52
  53. package/dist/agents/giuseppe/files.js +0 -338
  54. package/dist/agents/giuseppe/git.d.ts +0 -48
  55. package/dist/agents/giuseppe/git.js +0 -298
  56. package/dist/agents/giuseppe/index.d.ts +0 -97
  57. package/dist/agents/giuseppe/index.js +0 -258
  58. package/dist/agents/giuseppe/lsp.d.ts +0 -113
  59. package/dist/agents/giuseppe/lsp.js +0 -485
  60. package/dist/agents/giuseppe/monitor.d.ts +0 -118
  61. package/dist/agents/giuseppe/monitor.js +0 -621
  62. package/dist/agents/giuseppe/prompt.d.ts +0 -5
  63. package/dist/agents/giuseppe/prompt.js +0 -94
  64. package/dist/agents/giuseppe/registries/pending-classification.d.ts +0 -28
  65. package/dist/agents/giuseppe/registries/pending-classification.js +0 -50
  66. package/dist/agents/giuseppe/registries/pending-fix.d.ts +0 -30
  67. package/dist/agents/giuseppe/registries/pending-fix.js +0 -42
  68. package/dist/agents/giuseppe/registries/pending.d.ts +0 -27
  69. package/dist/agents/giuseppe/registries/pending.js +0 -49
  70. package/dist/agents/giuseppe/specialist.d.ts +0 -47
  71. package/dist/agents/giuseppe/specialist.js +0 -237
  72. package/dist/agents/giuseppe/types.d.ts +0 -123
  73. package/dist/agents/giuseppe/types.js +0 -9
  74. package/dist/agents/hailer-expert/index.d.ts +0 -8
  75. package/dist/agents/hailer-expert/index.js +0 -14
  76. package/dist/agents/hal/daemon.d.ts +0 -142
  77. package/dist/agents/hal/daemon.js +0 -1103
  78. package/dist/agents/hal/definitions.d.ts +0 -55
  79. package/dist/agents/hal/definitions.js +0 -263
  80. package/dist/agents/hal/index.d.ts +0 -3
  81. package/dist/agents/hal/index.js +0 -8
  82. package/dist/agents/index.d.ts +0 -18
  83. package/dist/agents/index.js +0 -48
  84. package/dist/agents/shared/base.d.ts +0 -216
  85. package/dist/agents/shared/base.js +0 -846
  86. package/dist/agents/shared/services/agent-registry.d.ts +0 -107
  87. package/dist/agents/shared/services/agent-registry.js +0 -629
  88. package/dist/agents/shared/services/conversation-manager.d.ts +0 -50
  89. package/dist/agents/shared/services/conversation-manager.js +0 -136
  90. package/dist/agents/shared/services/mcp-client.d.ts +0 -56
  91. package/dist/agents/shared/services/mcp-client.js +0 -124
  92. package/dist/agents/shared/services/message-classifier.d.ts +0 -37
  93. package/dist/agents/shared/services/message-classifier.js +0 -187
  94. package/dist/agents/shared/services/message-formatter.d.ts +0 -89
  95. package/dist/agents/shared/services/message-formatter.js +0 -371
  96. package/dist/agents/shared/services/session-logger.d.ts +0 -106
  97. package/dist/agents/shared/services/session-logger.js +0 -446
  98. package/dist/agents/shared/services/tool-executor.d.ts +0 -41
  99. package/dist/agents/shared/services/tool-executor.js +0 -169
  100. package/dist/agents/shared/services/workspace-schema-cache.d.ts +0 -125
  101. package/dist/agents/shared/services/workspace-schema-cache.js +0 -578
  102. package/dist/agents/shared/specialist.d.ts +0 -91
  103. package/dist/agents/shared/specialist.js +0 -399
  104. package/dist/agents/shared/tool-schema-loader.d.ts +0 -62
  105. package/dist/agents/shared/tool-schema-loader.js +0 -232
  106. package/dist/agents/shared/types.d.ts +0 -327
  107. package/dist/agents/shared/types.js +0 -121
  108. package/dist/client/agents/base.d.ts +0 -207
  109. package/dist/client/agents/base.js +0 -744
  110. package/dist/client/agents/definitions.d.ts +0 -53
  111. package/dist/client/agents/definitions.js +0 -263
  112. package/dist/client/agents/orchestrator.d.ts +0 -141
  113. package/dist/client/agents/orchestrator.js +0 -1062
  114. package/dist/client/agents/specialist.d.ts +0 -86
  115. package/dist/client/agents/specialist.js +0 -340
  116. package/dist/client/bot-entrypoint.d.ts +0 -7
  117. package/dist/client/bot-entrypoint.js +0 -103
  118. package/dist/client/bot-manager.d.ts +0 -44
  119. package/dist/client/bot-manager.js +0 -173
  120. package/dist/client/bot-runner.d.ts +0 -35
  121. package/dist/client/bot-runner.js +0 -188
  122. package/dist/client/chat-agent-daemon.d.ts +0 -464
  123. package/dist/client/chat-agent-daemon.js +0 -1774
  124. package/dist/client/daemon-factory.d.ts +0 -106
  125. package/dist/client/daemon-factory.js +0 -301
  126. package/dist/client/factory.d.ts +0 -111
  127. package/dist/client/factory.js +0 -314
  128. package/dist/client/index.d.ts +0 -17
  129. package/dist/client/index.js +0 -38
  130. package/dist/client/multi-bot-manager.d.ts +0 -42
  131. package/dist/client/multi-bot-manager.js +0 -161
  132. package/dist/client/orchestrator-daemon.d.ts +0 -87
  133. package/dist/client/orchestrator-daemon.js +0 -444
  134. package/dist/client/server.d.ts +0 -8
  135. package/dist/client/server.js +0 -251
  136. package/dist/client/services/agent-registry.d.ts +0 -108
  137. package/dist/client/services/agent-registry.js +0 -630
  138. package/dist/client/services/conversation-manager.d.ts +0 -50
  139. package/dist/client/services/conversation-manager.js +0 -136
  140. package/dist/client/services/mcp-client.d.ts +0 -48
  141. package/dist/client/services/mcp-client.js +0 -105
  142. package/dist/client/services/message-classifier.d.ts +0 -37
  143. package/dist/client/services/message-classifier.js +0 -187
  144. package/dist/client/services/message-formatter.d.ts +0 -84
  145. package/dist/client/services/message-formatter.js +0 -353
  146. package/dist/client/services/session-logger.d.ts +0 -106
  147. package/dist/client/services/session-logger.js +0 -446
  148. package/dist/client/services/tool-executor.d.ts +0 -41
  149. package/dist/client/services/tool-executor.js +0 -169
  150. package/dist/client/services/workspace-schema-cache.d.ts +0 -149
  151. package/dist/client/services/workspace-schema-cache.js +0 -732
  152. package/dist/client/specialist-daemon.d.ts +0 -77
  153. package/dist/client/specialist-daemon.js +0 -197
  154. package/dist/client/specialists.d.ts +0 -53
  155. package/dist/client/specialists.js +0 -178
  156. package/dist/client/tool-schema-loader.d.ts +0 -62
  157. package/dist/client/tool-schema-loader.js +0 -232
  158. package/dist/client/types.d.ts +0 -327
  159. package/dist/client/types.js +0 -121
  160. package/dist/commands/seed-config.d.ts +0 -9
  161. package/dist/commands/seed-config.js +0 -372
  162. package/dist/lib/context-manager.d.ts +0 -111
  163. package/dist/lib/context-manager.js +0 -431
  164. package/dist/lib/prompt-length-manager.d.ts +0 -81
  165. package/dist/lib/prompt-length-manager.js +0 -457
  166. package/dist/mcp/tools/giuseppe-tools.d.ts +0 -21
  167. package/dist/modules/bug-reports/bug-config.d.ts +0 -25
  168. package/dist/modules/bug-reports/bug-config.js +0 -187
  169. package/dist/modules/bug-reports/bug-monitor.d.ts +0 -108
  170. package/dist/modules/bug-reports/bug-monitor.js +0 -510
  171. package/dist/modules/bug-reports/giuseppe-agent.d.ts +0 -58
  172. package/dist/modules/bug-reports/giuseppe-agent.js +0 -467
  173. package/dist/modules/bug-reports/giuseppe-ai.d.ts +0 -83
  174. package/dist/modules/bug-reports/giuseppe-ai.js +0 -466
  175. package/dist/modules/bug-reports/giuseppe-bot.d.ts +0 -110
  176. package/dist/modules/bug-reports/giuseppe-bot.js +0 -804
  177. package/dist/modules/bug-reports/giuseppe-daemon.d.ts +0 -80
  178. package/dist/modules/bug-reports/giuseppe-daemon.js +0 -617
  179. package/dist/modules/bug-reports/giuseppe-files.d.ts +0 -64
  180. package/dist/modules/bug-reports/giuseppe-files.js +0 -375
  181. package/dist/modules/bug-reports/giuseppe-git.d.ts +0 -48
  182. package/dist/modules/bug-reports/giuseppe-git.js +0 -298
  183. package/dist/modules/bug-reports/giuseppe-lsp.d.ts +0 -113
  184. package/dist/modules/bug-reports/giuseppe-lsp.js +0 -485
  185. package/dist/modules/bug-reports/giuseppe-prompt.d.ts +0 -5
  186. package/dist/modules/bug-reports/giuseppe-prompt.js +0 -94
  187. package/dist/modules/bug-reports/index.d.ts +0 -77
  188. package/dist/modules/bug-reports/index.js +0 -215
  189. package/dist/modules/bug-reports/pending-classification-registry.d.ts +0 -28
  190. package/dist/modules/bug-reports/pending-classification-registry.js +0 -50
  191. package/dist/modules/bug-reports/pending-fix-registry.d.ts +0 -30
  192. package/dist/modules/bug-reports/pending-fix-registry.js +0 -42
  193. package/dist/modules/bug-reports/pending-registry.d.ts +0 -27
  194. package/dist/modules/bug-reports/pending-registry.js +0 -49
  195. package/dist/modules/bug-reports/types.d.ts +0 -123
  196. package/dist/modules/bug-reports/types.js +0 -9
  197. package/dist/routes/agents.d.ts +0 -44
  198. package/dist/routes/agents.js +0 -311
  199. package/dist/services/agent-credential-store.d.ts +0 -73
  200. package/dist/services/agent-credential-store.js +0 -212
  201. package/dist/services/bug-monitor.d.ts +0 -23
  202. package/dist/services/bug-monitor.js +0 -275
@@ -1,106 +0,0 @@
1
- /**
2
- * Daemon Factory
3
- *
4
- * Creates and manages agent daemons in orchestrator mode:
5
- * - One orchestrator (HAL) handles general conversation
6
- * - Specialist daemons handle complex domain-specific tasks
7
- */
8
- import { ChatAgentDaemon } from "./chat-agent-daemon";
9
- import { OrchestratorDaemon } from "./orchestrator-daemon";
10
- import { SpecialistDaemon } from "./specialist-daemon";
11
- import { MultiBotManager } from "./multi-bot-manager";
12
- export interface DaemonManagerOptions {
13
- mcpServerUrl: string;
14
- anthropicApiKey: string;
15
- model?: string;
16
- /**
17
- * Enable orchestrator mode (default: true)
18
- * Set to false only for legacy compatibility
19
- */
20
- orchestratorMode?: boolean;
21
- /**
22
- * Email of the bot to use as orchestrator (defaults to first bot)
23
- */
24
- orchestratorEmail?: string;
25
- /**
26
- * Map of specialist key to bot email (e.g., { hailerExpert: "expert@bot.com" })
27
- */
28
- specialistEmails?: Record<string, string>;
29
- }
30
- /**
31
- * Manages orchestrator + specialist daemons
32
- */
33
- export declare class DaemonManager {
34
- private daemons;
35
- private orchestrator;
36
- private specialists;
37
- private botManager;
38
- private options;
39
- constructor(botManager: MultiBotManager, options: DaemonManagerOptions);
40
- /**
41
- * Start all daemons (orchestrator + specialists)
42
- */
43
- startAll(): Promise<void>;
44
- /**
45
- * Orchestrator mode: one orchestrator (HAL) + specialist daemons
46
- */
47
- private startOrchestratorMode;
48
- /**
49
- * Stop all daemons
50
- * Flushes session logs for each daemon before stopping
51
- */
52
- stopAll(): Promise<void>;
53
- /**
54
- * Get daemon for a specific bot
55
- */
56
- getDaemon(botId: string): ChatAgentDaemon | undefined;
57
- /**
58
- * Get status of all daemons
59
- */
60
- getStatus(): Array<{
61
- botId: string;
62
- state: any;
63
- }>;
64
- /**
65
- * Log current status to console (for monitoring)
66
- */
67
- logStatus(): void;
68
- /**
69
- * Get orchestrator instance (only in orchestrator mode)
70
- */
71
- getOrchestrator(): OrchestratorDaemon | null;
72
- /**
73
- * Get specialist by key (only in orchestrator mode)
74
- */
75
- getSpecialist(key: string): SpecialistDaemon | undefined;
76
- /**
77
- * Check if running in orchestrator mode
78
- */
79
- isOrchestratorMode(): boolean;
80
- /**
81
- * Start periodic status logging
82
- */
83
- startStatusLogging(intervalMs?: number): NodeJS.Timeout;
84
- }
85
- export interface CreateDaemonManagerOptions {
86
- /** Enable orchestrator mode */
87
- orchestratorMode?: boolean;
88
- /** Email of orchestrator bot (defaults to first) */
89
- orchestratorEmail?: string;
90
- /** Map specialist keys to bot emails */
91
- specialistEmails?: Record<string, string>;
92
- }
93
- /**
94
- * Create and start the daemon manager
95
- * This is the main entry point for daemon mode
96
- *
97
- * @param options - Optional settings for orchestrator mode
98
- */
99
- export declare function createDaemonManager(options?: CreateDaemonManagerOptions): Promise<DaemonManager | null>;
100
- /**
101
- * Quick start function for testing
102
- *
103
- * @param orchestratorMode - Enable orchestrator mode (default: true)
104
- */
105
- export declare function startDaemonMode(orchestratorMode?: boolean): Promise<void>;
106
- //# sourceMappingURL=daemon-factory.d.ts.map
@@ -1,301 +0,0 @@
1
- "use strict";
2
- /**
3
- * Daemon Factory
4
- *
5
- * Creates and manages agent daemons in orchestrator mode:
6
- * - One orchestrator (HAL) handles general conversation
7
- * - Specialist daemons handle complex domain-specific tasks
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.DaemonManager = void 0;
11
- exports.createDaemonManager = createDaemonManager;
12
- exports.startDaemonMode = startDaemonMode;
13
- const orchestrator_daemon_1 = require("./orchestrator-daemon");
14
- const specialist_daemon_1 = require("./specialist-daemon");
15
- const specialists_1 = require("./specialists");
16
- const multi_bot_manager_1 = require("./multi-bot-manager");
17
- const config_1 = require("../config");
18
- const logger_1 = require("../lib/logger");
19
- const logger = (0, logger_1.createLogger)({ component: "DaemonFactory" });
20
- /**
21
- * Manages orchestrator + specialist daemons
22
- */
23
- class DaemonManager {
24
- daemons = new Map();
25
- orchestrator = null;
26
- specialists = new Map();
27
- botManager;
28
- options;
29
- constructor(botManager, options) {
30
- this.botManager = botManager;
31
- this.options = options;
32
- }
33
- /**
34
- * Start all daemons (orchestrator + specialists)
35
- */
36
- async startAll() {
37
- await this.startOrchestratorMode();
38
- }
39
- /**
40
- * Orchestrator mode: one orchestrator (HAL) + specialist daemons
41
- */
42
- async startOrchestratorMode() {
43
- const botClients = this.botManager.getAllBotClients();
44
- logger.info("Starting daemons in ORCHESTRATOR mode", {
45
- botCount: botClients.length,
46
- });
47
- // Find orchestrator bot
48
- let orchestratorClient;
49
- const specialistClients = new Map();
50
- for (const botClient of botClients) {
51
- const email = botClient.config.email;
52
- // Check if this is the orchestrator
53
- if (this.options.orchestratorEmail === email ||
54
- (!this.options.orchestratorEmail && !orchestratorClient)) {
55
- orchestratorClient = botClient;
56
- continue;
57
- }
58
- // Check if this matches a specialist
59
- if (this.options.specialistEmails) {
60
- for (const [specialistKey, specialistEmail] of Object.entries(this.options.specialistEmails)) {
61
- if (email === specialistEmail) {
62
- specialistClients.set(specialistKey, botClient);
63
- break;
64
- }
65
- }
66
- }
67
- else {
68
- // Auto-assign to first available specialist
69
- for (const specialistKey of Object.keys(specialists_1.SPECIALISTS)) {
70
- if (!specialistClients.has(specialistKey)) {
71
- specialistClients.set(specialistKey, botClient);
72
- break;
73
- }
74
- }
75
- }
76
- }
77
- if (!orchestratorClient) {
78
- throw new Error("No orchestrator bot found");
79
- }
80
- // Create specialist user ID map for orchestrator
81
- const specialistUserIds = new Map();
82
- for (const [key, client] of specialistClients) {
83
- specialistUserIds.set(key, client.userId);
84
- }
85
- // Start orchestrator
86
- const orchestratorConfig = {
87
- botClient: orchestratorClient,
88
- mcpServerUrl: this.options.mcpServerUrl,
89
- anthropicApiKey: this.options.anthropicApiKey,
90
- model: this.options.model,
91
- specialistUserIds,
92
- };
93
- this.orchestrator = new orchestrator_daemon_1.OrchestratorDaemon(orchestratorConfig);
94
- await this.orchestrator.initialize();
95
- // Register specialist user IDs with orchestrator
96
- for (const [key, userId] of specialistUserIds) {
97
- this.orchestrator.registerSpecialistUserId(key, userId);
98
- }
99
- this.daemons.set(orchestratorClient.userId, this.orchestrator);
100
- logger.info("Orchestrator started", {
101
- botId: orchestratorClient.userId,
102
- email: orchestratorClient.config.email,
103
- specialistCount: specialistClients.size,
104
- });
105
- // Start specialist daemons
106
- for (const [specialistKey, botClient] of specialistClients) {
107
- const specialist = specialists_1.SPECIALISTS[specialistKey];
108
- if (!specialist) {
109
- logger.warn("Unknown specialist key", { key: specialistKey });
110
- continue;
111
- }
112
- // Set the bot user ID on the specialist config
113
- specialist.botUserId = botClient.userId;
114
- const specialistConfig = {
115
- botClient,
116
- mcpServerUrl: this.options.mcpServerUrl,
117
- anthropicApiKey: this.options.anthropicApiKey,
118
- model: specialist.model || this.options.model,
119
- specialist,
120
- };
121
- const specialistDaemon = new specialist_daemon_1.SpecialistDaemon(specialistConfig);
122
- await specialistDaemon.initialize();
123
- this.specialists.set(specialistKey, specialistDaemon);
124
- this.daemons.set(botClient.userId, specialistDaemon);
125
- logger.info("Specialist daemon started", {
126
- key: specialistKey,
127
- name: specialist.name,
128
- botId: botClient.userId,
129
- email: botClient.config.email,
130
- });
131
- }
132
- logger.info("Orchestrator mode started", {
133
- orchestratorId: orchestratorClient.userId,
134
- specialistCount: this.specialists.size,
135
- totalDaemons: this.daemons.size,
136
- });
137
- }
138
- /**
139
- * Stop all daemons
140
- * Flushes session logs for each daemon before stopping
141
- */
142
- async stopAll() {
143
- const stopPromises = Array.from(this.daemons.entries()).map(async ([botId, daemon]) => {
144
- await daemon.stop();
145
- logger.info("Daemon stopped", { botId });
146
- });
147
- await Promise.all(stopPromises);
148
- this.daemons.clear();
149
- }
150
- /**
151
- * Get daemon for a specific bot
152
- */
153
- getDaemon(botId) {
154
- return this.daemons.get(botId);
155
- }
156
- /**
157
- * Get status of all daemons
158
- */
159
- getStatus() {
160
- return Array.from(this.daemons.entries()).map(([botId, daemon]) => ({
161
- botId,
162
- state: daemon.getConversationState(),
163
- }));
164
- }
165
- /**
166
- * Log current status to console (for monitoring)
167
- */
168
- logStatus() {
169
- const status = this.getStatus();
170
- if (this.options.orchestratorMode) {
171
- logger.info("=== ORCHESTRATOR MODE STATUS ===");
172
- // Log orchestrator
173
- if (this.orchestrator) {
174
- const orchStatus = this.orchestrator.getOrchestratorStatus();
175
- logger.info("ORCHESTRATOR (HAL):", {
176
- messages: orchStatus.conversationState.messageCount,
177
- queue: orchStatus.conversationState.queueLength,
178
- processing: orchStatus.conversationState.isProcessing,
179
- specialists: orchStatus.specialists.filter(s => s.available).length,
180
- });
181
- }
182
- // Log specialists
183
- for (const [key, specialist] of this.specialists) {
184
- const specStatus = specialist.getSpecialistStatus();
185
- logger.info(`SPECIALIST [${key}] ${specStatus.name}:`, {
186
- messages: specStatus.conversationState.messageCount,
187
- queue: specStatus.conversationState.queueLength,
188
- processing: specStatus.conversationState.isProcessing,
189
- });
190
- }
191
- }
192
- else {
193
- logger.info("=== DAEMON STATUS ===");
194
- for (const { botId, state } of status) {
195
- logger.info(`Bot ${botId.substring(0, 8)}...`, {
196
- messages: state.messageCount,
197
- queue: state.queueLength,
198
- processing: state.isProcessing,
199
- });
200
- if (state.lastMessages.length > 0) {
201
- logger.info("Last messages:");
202
- for (const msg of state.lastMessages) {
203
- logger.info(` [${msg.role}] ${msg.preview}`);
204
- }
205
- }
206
- }
207
- }
208
- logger.info("=====================");
209
- }
210
- /**
211
- * Get orchestrator instance (only in orchestrator mode)
212
- */
213
- getOrchestrator() {
214
- return this.orchestrator;
215
- }
216
- /**
217
- * Get specialist by key (only in orchestrator mode)
218
- */
219
- getSpecialist(key) {
220
- return this.specialists.get(key);
221
- }
222
- /**
223
- * Check if running in orchestrator mode
224
- */
225
- isOrchestratorMode() {
226
- return !!this.options.orchestratorMode;
227
- }
228
- /**
229
- * Start periodic status logging
230
- */
231
- startStatusLogging(intervalMs = 30000) {
232
- return setInterval(() => {
233
- this.logStatus();
234
- }, intervalMs);
235
- }
236
- }
237
- exports.DaemonManager = DaemonManager;
238
- /**
239
- * Create and start the daemon manager
240
- * This is the main entry point for daemon mode
241
- *
242
- * @param options - Optional settings for orchestrator mode
243
- */
244
- async function createDaemonManager(options) {
245
- const appConfig = (0, config_1.createApplicationConfig)();
246
- const mcpClientConfig = appConfig.mcpClient;
247
- if (!mcpClientConfig) {
248
- logger.error("MCP Client not configured - cannot start daemon mode");
249
- return null;
250
- }
251
- // Find Anthropic API key from providers
252
- const anthropicProvider = mcpClientConfig.providers.find(p => p.type === "anthropic");
253
- if (!anthropicProvider) {
254
- logger.error("Anthropic provider not configured - daemon mode requires Anthropic");
255
- return null;
256
- }
257
- // Create bot manager
258
- const botManager = new multi_bot_manager_1.MultiBotManager(mcpClientConfig.botConfigs);
259
- await botManager.initializeAllHailerClientsFromConfig();
260
- // Check environment for orchestrator mode (defaults to TRUE)
261
- const orchestratorMode = options?.orchestratorMode ??
262
- process.env.DAEMON_ORCHESTRATOR_MODE !== "false";
263
- // Create daemon manager
264
- const daemonManager = new DaemonManager(botManager, {
265
- mcpServerUrl: mcpClientConfig.mcpServerUrl,
266
- anthropicApiKey: anthropicProvider.apiKey,
267
- model: anthropicProvider.model,
268
- orchestratorMode,
269
- orchestratorEmail: options?.orchestratorEmail,
270
- specialistEmails: options?.specialistEmails,
271
- });
272
- // Start all daemons
273
- await daemonManager.startAll();
274
- return daemonManager;
275
- }
276
- /**
277
- * Quick start function for testing
278
- *
279
- * @param orchestratorMode - Enable orchestrator mode (default: true)
280
- */
281
- async function startDaemonMode(orchestratorMode = true) {
282
- logger.info("Starting Chat Agent Daemon Mode (ORCHESTRATOR)...");
283
- const manager = await createDaemonManager({ orchestratorMode });
284
- if (!manager) {
285
- logger.error("Failed to create daemon manager");
286
- process.exit(1);
287
- }
288
- // Handle shutdown - await async stopAll() to flush session logs
289
- process.on("SIGINT", () => {
290
- logger.info("Shutting down daemons...");
291
- manager.stopAll().then(() => process.exit(0));
292
- });
293
- process.on("SIGTERM", () => {
294
- logger.info("Shutting down daemons...");
295
- manager.stopAll().then(() => process.exit(0));
296
- });
297
- logger.info("Chat Agent Daemon Mode (ORCHESTRATOR) running. Press Ctrl+C to stop.");
298
- // Start periodic status logging
299
- manager.startStatusLogging(60000);
300
- }
301
- //# sourceMappingURL=daemon-factory.js.map
@@ -1,111 +0,0 @@
1
- /**
2
- * Daemon Factory
3
- *
4
- * Creates and manages agent daemons in orchestrator mode:
5
- * - One orchestrator (HAL) handles general conversation
6
- * - Specialist daemons handle complex domain-specific tasks
7
- */
8
- import { ChatAgentDaemon } from "./agents/base";
9
- import { OrchestratorDaemon } from "./agents/orchestrator";
10
- import { SpecialistDaemon } from "./agents/specialist";
11
- import { MultiBotManager } from "./bot-manager";
12
- import { ConversationState } from "./types";
13
- export interface DaemonManagerOptions {
14
- mcpServerUrl: string;
15
- anthropicApiKey: string;
16
- model?: string;
17
- /**
18
- * Enable orchestrator mode (default: true)
19
- * Set to false only for legacy compatibility
20
- */
21
- orchestratorMode?: boolean;
22
- /**
23
- * Email of the bot to use as orchestrator (defaults to first bot)
24
- */
25
- orchestratorEmail?: string;
26
- /**
27
- * Map of specialist key to bot email (e.g., { hailerExpert: "expert@bot.com" })
28
- */
29
- specialistEmails?: Record<string, string>;
30
- }
31
- /**
32
- * Manages orchestrator + specialist daemons
33
- */
34
- export declare class DaemonManager {
35
- private daemons;
36
- private orchestrator;
37
- private specialists;
38
- private botManager;
39
- private options;
40
- constructor(botManager: MultiBotManager, options: DaemonManagerOptions);
41
- /**
42
- * Start all daemons (orchestrator + specialists)
43
- */
44
- startAll(): Promise<void>;
45
- /**
46
- * Orchestrator mode: one orchestrator (HAL) + specialist daemons
47
- */
48
- private startOrchestratorMode;
49
- /**
50
- * Stop all daemons
51
- * Flushes session logs for each daemon before stopping
52
- */
53
- stopAll(): Promise<void>;
54
- /**
55
- * Get daemon for a specific bot
56
- */
57
- getDaemon(botId: string): ChatAgentDaemon | undefined;
58
- /**
59
- * Get status of all daemons
60
- */
61
- getStatus(): Array<{
62
- botId: string;
63
- state: ConversationState;
64
- }>;
65
- /**
66
- * Log current status to console (for monitoring)
67
- */
68
- logStatus(): void;
69
- /**
70
- * Get orchestrator instance (only in orchestrator mode)
71
- */
72
- getOrchestrator(): OrchestratorDaemon | null;
73
- /**
74
- * Get specialist by key (only in orchestrator mode)
75
- */
76
- getSpecialist(key: string): SpecialistDaemon | undefined;
77
- /**
78
- * Check if running in orchestrator mode
79
- */
80
- isOrchestratorMode(): boolean;
81
- /**
82
- * Trigger HAL to respond in a discussion with context
83
- */
84
- triggerHalResponse(discussionId: string, activityId: string, context: string): Promise<void>;
85
- /**
86
- * Start periodic status logging
87
- */
88
- startStatusLogging(intervalMs?: number): NodeJS.Timeout;
89
- }
90
- export interface CreateDaemonManagerOptions {
91
- /** Enable orchestrator mode */
92
- orchestratorMode?: boolean;
93
- /** Email of orchestrator bot (defaults to first) */
94
- orchestratorEmail?: string;
95
- /** Map specialist keys to bot emails */
96
- specialistEmails?: Record<string, string>;
97
- }
98
- /**
99
- * Create and start the daemon manager
100
- * This is the main entry point for daemon mode
101
- *
102
- * @param options - Optional settings for orchestrator mode
103
- */
104
- export declare function createDaemonManager(options?: CreateDaemonManagerOptions): Promise<DaemonManager | null>;
105
- /**
106
- * Quick start function for testing
107
- *
108
- * @param orchestratorMode - Enable orchestrator mode (default: true)
109
- */
110
- export declare function startDaemonMode(orchestratorMode?: boolean): Promise<void>;
111
- //# sourceMappingURL=factory.d.ts.map