@hailer/mcp 0.1.17 → 0.2.2

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 (200) hide show
  1. package/dist/app.js +27 -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-server.d.ts +2 -2
  37. package/dist/mcp-server.js +161 -139
  38. package/package.json +1 -1
  39. package/REFACTOR_STATUS.md +0 -127
  40. package/dist/agents/bot-manager.d.ts +0 -48
  41. package/dist/agents/bot-manager.js +0 -254
  42. package/dist/agents/factory.d.ts +0 -150
  43. package/dist/agents/factory.js +0 -650
  44. package/dist/agents/giuseppe/ai.d.ts +0 -83
  45. package/dist/agents/giuseppe/ai.js +0 -466
  46. package/dist/agents/giuseppe/bot.d.ts +0 -110
  47. package/dist/agents/giuseppe/bot.js +0 -780
  48. package/dist/agents/giuseppe/config.d.ts +0 -25
  49. package/dist/agents/giuseppe/config.js +0 -227
  50. package/dist/agents/giuseppe/files.d.ts +0 -52
  51. package/dist/agents/giuseppe/files.js +0 -338
  52. package/dist/agents/giuseppe/git.d.ts +0 -48
  53. package/dist/agents/giuseppe/git.js +0 -298
  54. package/dist/agents/giuseppe/index.d.ts +0 -97
  55. package/dist/agents/giuseppe/index.js +0 -258
  56. package/dist/agents/giuseppe/lsp.d.ts +0 -113
  57. package/dist/agents/giuseppe/lsp.js +0 -485
  58. package/dist/agents/giuseppe/monitor.d.ts +0 -118
  59. package/dist/agents/giuseppe/monitor.js +0 -621
  60. package/dist/agents/giuseppe/prompt.d.ts +0 -5
  61. package/dist/agents/giuseppe/prompt.js +0 -94
  62. package/dist/agents/giuseppe/registries/pending-classification.d.ts +0 -28
  63. package/dist/agents/giuseppe/registries/pending-classification.js +0 -50
  64. package/dist/agents/giuseppe/registries/pending-fix.d.ts +0 -30
  65. package/dist/agents/giuseppe/registries/pending-fix.js +0 -42
  66. package/dist/agents/giuseppe/registries/pending.d.ts +0 -27
  67. package/dist/agents/giuseppe/registries/pending.js +0 -49
  68. package/dist/agents/giuseppe/specialist.d.ts +0 -47
  69. package/dist/agents/giuseppe/specialist.js +0 -237
  70. package/dist/agents/giuseppe/types.d.ts +0 -123
  71. package/dist/agents/giuseppe/types.js +0 -9
  72. package/dist/agents/hailer-expert/index.d.ts +0 -8
  73. package/dist/agents/hailer-expert/index.js +0 -14
  74. package/dist/agents/hal/daemon.d.ts +0 -142
  75. package/dist/agents/hal/daemon.js +0 -1103
  76. package/dist/agents/hal/definitions.d.ts +0 -55
  77. package/dist/agents/hal/definitions.js +0 -263
  78. package/dist/agents/hal/index.d.ts +0 -3
  79. package/dist/agents/hal/index.js +0 -8
  80. package/dist/agents/index.d.ts +0 -18
  81. package/dist/agents/index.js +0 -48
  82. package/dist/agents/shared/base.d.ts +0 -216
  83. package/dist/agents/shared/base.js +0 -846
  84. package/dist/agents/shared/services/agent-registry.d.ts +0 -107
  85. package/dist/agents/shared/services/agent-registry.js +0 -629
  86. package/dist/agents/shared/services/conversation-manager.d.ts +0 -50
  87. package/dist/agents/shared/services/conversation-manager.js +0 -136
  88. package/dist/agents/shared/services/mcp-client.d.ts +0 -56
  89. package/dist/agents/shared/services/mcp-client.js +0 -124
  90. package/dist/agents/shared/services/message-classifier.d.ts +0 -37
  91. package/dist/agents/shared/services/message-classifier.js +0 -187
  92. package/dist/agents/shared/services/message-formatter.d.ts +0 -89
  93. package/dist/agents/shared/services/message-formatter.js +0 -371
  94. package/dist/agents/shared/services/session-logger.d.ts +0 -106
  95. package/dist/agents/shared/services/session-logger.js +0 -446
  96. package/dist/agents/shared/services/tool-executor.d.ts +0 -41
  97. package/dist/agents/shared/services/tool-executor.js +0 -169
  98. package/dist/agents/shared/services/workspace-schema-cache.d.ts +0 -125
  99. package/dist/agents/shared/services/workspace-schema-cache.js +0 -578
  100. package/dist/agents/shared/specialist.d.ts +0 -91
  101. package/dist/agents/shared/specialist.js +0 -399
  102. package/dist/agents/shared/tool-schema-loader.d.ts +0 -62
  103. package/dist/agents/shared/tool-schema-loader.js +0 -232
  104. package/dist/agents/shared/types.d.ts +0 -327
  105. package/dist/agents/shared/types.js +0 -121
  106. package/dist/client/agents/base.d.ts +0 -207
  107. package/dist/client/agents/base.js +0 -744
  108. package/dist/client/agents/definitions.d.ts +0 -53
  109. package/dist/client/agents/definitions.js +0 -263
  110. package/dist/client/agents/orchestrator.d.ts +0 -141
  111. package/dist/client/agents/orchestrator.js +0 -1062
  112. package/dist/client/agents/specialist.d.ts +0 -86
  113. package/dist/client/agents/specialist.js +0 -340
  114. package/dist/client/bot-entrypoint.d.ts +0 -7
  115. package/dist/client/bot-entrypoint.js +0 -103
  116. package/dist/client/bot-manager.d.ts +0 -44
  117. package/dist/client/bot-manager.js +0 -173
  118. package/dist/client/bot-runner.d.ts +0 -35
  119. package/dist/client/bot-runner.js +0 -188
  120. package/dist/client/chat-agent-daemon.d.ts +0 -464
  121. package/dist/client/chat-agent-daemon.js +0 -1774
  122. package/dist/client/daemon-factory.d.ts +0 -106
  123. package/dist/client/daemon-factory.js +0 -301
  124. package/dist/client/factory.d.ts +0 -111
  125. package/dist/client/factory.js +0 -314
  126. package/dist/client/index.d.ts +0 -17
  127. package/dist/client/index.js +0 -38
  128. package/dist/client/multi-bot-manager.d.ts +0 -42
  129. package/dist/client/multi-bot-manager.js +0 -161
  130. package/dist/client/orchestrator-daemon.d.ts +0 -87
  131. package/dist/client/orchestrator-daemon.js +0 -444
  132. package/dist/client/server.d.ts +0 -8
  133. package/dist/client/server.js +0 -251
  134. package/dist/client/services/agent-registry.d.ts +0 -108
  135. package/dist/client/services/agent-registry.js +0 -630
  136. package/dist/client/services/conversation-manager.d.ts +0 -50
  137. package/dist/client/services/conversation-manager.js +0 -136
  138. package/dist/client/services/mcp-client.d.ts +0 -48
  139. package/dist/client/services/mcp-client.js +0 -105
  140. package/dist/client/services/message-classifier.d.ts +0 -37
  141. package/dist/client/services/message-classifier.js +0 -187
  142. package/dist/client/services/message-formatter.d.ts +0 -84
  143. package/dist/client/services/message-formatter.js +0 -353
  144. package/dist/client/services/session-logger.d.ts +0 -106
  145. package/dist/client/services/session-logger.js +0 -446
  146. package/dist/client/services/tool-executor.d.ts +0 -41
  147. package/dist/client/services/tool-executor.js +0 -169
  148. package/dist/client/services/workspace-schema-cache.d.ts +0 -149
  149. package/dist/client/services/workspace-schema-cache.js +0 -732
  150. package/dist/client/specialist-daemon.d.ts +0 -77
  151. package/dist/client/specialist-daemon.js +0 -197
  152. package/dist/client/specialists.d.ts +0 -53
  153. package/dist/client/specialists.js +0 -178
  154. package/dist/client/tool-schema-loader.d.ts +0 -62
  155. package/dist/client/tool-schema-loader.js +0 -232
  156. package/dist/client/types.d.ts +0 -327
  157. package/dist/client/types.js +0 -121
  158. package/dist/commands/seed-config.d.ts +0 -9
  159. package/dist/commands/seed-config.js +0 -372
  160. package/dist/lib/context-manager.d.ts +0 -111
  161. package/dist/lib/context-manager.js +0 -431
  162. package/dist/lib/prompt-length-manager.d.ts +0 -81
  163. package/dist/lib/prompt-length-manager.js +0 -457
  164. package/dist/mcp/tools/giuseppe-tools.d.ts +0 -21
  165. package/dist/modules/bug-reports/bug-config.d.ts +0 -25
  166. package/dist/modules/bug-reports/bug-config.js +0 -187
  167. package/dist/modules/bug-reports/bug-monitor.d.ts +0 -108
  168. package/dist/modules/bug-reports/bug-monitor.js +0 -510
  169. package/dist/modules/bug-reports/giuseppe-agent.d.ts +0 -58
  170. package/dist/modules/bug-reports/giuseppe-agent.js +0 -467
  171. package/dist/modules/bug-reports/giuseppe-ai.d.ts +0 -83
  172. package/dist/modules/bug-reports/giuseppe-ai.js +0 -466
  173. package/dist/modules/bug-reports/giuseppe-bot.d.ts +0 -110
  174. package/dist/modules/bug-reports/giuseppe-bot.js +0 -804
  175. package/dist/modules/bug-reports/giuseppe-daemon.d.ts +0 -80
  176. package/dist/modules/bug-reports/giuseppe-daemon.js +0 -617
  177. package/dist/modules/bug-reports/giuseppe-files.d.ts +0 -64
  178. package/dist/modules/bug-reports/giuseppe-files.js +0 -375
  179. package/dist/modules/bug-reports/giuseppe-git.d.ts +0 -48
  180. package/dist/modules/bug-reports/giuseppe-git.js +0 -298
  181. package/dist/modules/bug-reports/giuseppe-lsp.d.ts +0 -113
  182. package/dist/modules/bug-reports/giuseppe-lsp.js +0 -485
  183. package/dist/modules/bug-reports/giuseppe-prompt.d.ts +0 -5
  184. package/dist/modules/bug-reports/giuseppe-prompt.js +0 -94
  185. package/dist/modules/bug-reports/index.d.ts +0 -77
  186. package/dist/modules/bug-reports/index.js +0 -215
  187. package/dist/modules/bug-reports/pending-classification-registry.d.ts +0 -28
  188. package/dist/modules/bug-reports/pending-classification-registry.js +0 -50
  189. package/dist/modules/bug-reports/pending-fix-registry.d.ts +0 -30
  190. package/dist/modules/bug-reports/pending-fix-registry.js +0 -42
  191. package/dist/modules/bug-reports/pending-registry.d.ts +0 -27
  192. package/dist/modules/bug-reports/pending-registry.js +0 -49
  193. package/dist/modules/bug-reports/types.d.ts +0 -123
  194. package/dist/modules/bug-reports/types.js +0 -9
  195. package/dist/routes/agents.d.ts +0 -44
  196. package/dist/routes/agents.js +0 -311
  197. package/dist/services/agent-credential-store.d.ts +0 -73
  198. package/dist/services/agent-credential-store.js +0 -212
  199. package/dist/services/bug-monitor.d.ts +0 -23
  200. package/dist/services/bug-monitor.js +0 -275
@@ -1,464 +0,0 @@
1
- /**
2
- * Chat Agent Daemon
3
- *
4
- * A persistent LLM conversation that monitors all workspace chats.
5
- * The LLM maintains context across messages and decides what to respond to.
6
- *
7
- * Architecture:
8
- * - One daemon per bot client
9
- * - Subscribes to ALL messenger.new signals (not filtered)
10
- * - LLM sees every message with priority markers
11
- * - LLM decides: RESPOND / IGNORE / ACTION
12
- */
13
- import Anthropic from "@anthropic-ai/sdk";
14
- import { BotClient } from "./bot-manager";
15
- import { HailerSignal } from "../mcp/signal-handler";
16
- import { Logger } from "../lib/logger";
17
- import { ToolSchemaLoader } from "./tool-schema-loader";
18
- /** Agent Directory workflow - registry of all bot agents */
19
- export declare const AGENT_DIRECTORY: {
20
- readonly workflowId: "694a35b5b8b5c5f8030788e3";
21
- readonly phases: {
22
- readonly agentBuilder: "694a35b5b8b5c5f8030788f7";
23
- readonly deployed: "694a35b5b8b5c5f8030788fb";
24
- readonly retired: "694a35b5b8b5c5f8030788fc";
25
- };
26
- readonly fields: {
27
- readonly firstName: "694a35b5b8b5c5f8030788ea";
28
- readonly lastName: "694a35b5b8b5c5f8030788eb";
29
- readonly description: "694a35b5b8b5c5f8030788f6";
30
- readonly hailerProfile: "694a35b5b8b5c5f8030788f2";
31
- readonly email: "694a35b5b8b5c5f8030788f3";
32
- readonly password: "694a35b5b8b5c5f8030788f4";
33
- readonly team: "694a35b5b8b5c5f8030788e7";
34
- readonly supervisor: "694a35b5b8b5c5f8030788e8";
35
- readonly memory: "694a35b5b8b5c5f8030788f5";
36
- readonly position: "694a35b5b8b5c5f8030788e5";
37
- readonly startDate: "694a35b5b8b5c5f8030788ec";
38
- };
39
- };
40
- /** Session Log workflow - tracks agent actions */
41
- export declare const SESSION_LOG: {
42
- readonly workflowId: "694a35b5b8b5c5f803078915";
43
- readonly phases: {
44
- readonly active: "694a35b5b8b5c5f803078941";
45
- readonly archive: "694a35b5b8b5c5f803078942";
46
- };
47
- readonly fields: {
48
- readonly contextSummary: "694a35b5b8b5c5f80307893c";
49
- readonly previousLog: "694a35b5b8b5c5f80307893d";
50
- readonly linkedWork: "694a35b5b8b5c5f80307893e";
51
- readonly cost: "694a35b5b8b5c5f80307893f";
52
- readonly madeBy: "694a35b5b8b5c5f803078940";
53
- };
54
- };
55
- /** Positions workflow - job descriptions/roles for agents */
56
- export declare const POSITIONS: {
57
- readonly workflowId: "694a35b5b8b5c5f8030788e4";
58
- readonly phases: {
59
- readonly active: "694a35b5b8b5c5f80307890f";
60
- };
61
- readonly fields: {
62
- readonly purpose: "694a35b5b8b5c5f803078901";
63
- readonly personaTone: "694a35b5b8b5c5f803078903";
64
- readonly coreCapabilities: "694a35b5b8b5c5f803078904";
65
- readonly contextAwareness: "694a35b5b8b5c5f803078905";
66
- readonly taskHandling: "694a35b5b8b5c5f803078906";
67
- readonly infoRetrieval: "694a35b5b8b5c5f803078907";
68
- readonly boundaries: "694a35b5b8b5c5f803078908";
69
- readonly userInteraction: "694a35b5b8b5c5f803078909";
70
- readonly errorHandling: "694a35b5b8b5c5f80307890a";
71
- readonly learning: "694a35b5b8b5c5f80307890b";
72
- readonly escalation: "694a35b5b8b5c5f80307890c";
73
- readonly auditLogging: "694a35b5b8b5c5f80307890d";
74
- readonly agentCount: "694a35b5b8b5c5f803078902";
75
- readonly multiAllowed: "694a35b5b8b5c5f80307890e";
76
- };
77
- };
78
- /** Teams workflow - groups of agents */
79
- export declare const TEAMS: {
80
- readonly workflowId: "694a35b5b8b5c5f8030788e6";
81
- readonly phases: {
82
- readonly active: "694a35b5b8b5c5f80307891a";
83
- };
84
- readonly fields: {
85
- readonly info: "694a35b5b8b5c5f803078919";
86
- readonly leader: "694a35b5b8b5c5f8030788e9";
87
- };
88
- };
89
- /** Tool Registry workflow - MCP server configurations */
90
- export declare const TOOL_REGISTRY: {
91
- readonly workflowId: "694a35b5b8b5c5f803078922";
92
- readonly phases: {
93
- readonly active: "694a35b5b8b5c5f803078927";
94
- };
95
- readonly fields: {
96
- readonly baseUrl: "694a35b5b8b5c5f803078923";
97
- readonly protocolVersion: "694a35b5b8b5c5f803078924";
98
- readonly toolRegistry: "694a35b5b8b5c5f803078925";
99
- readonly logEntryBy: "694a35b5b8b5c5f803078926";
100
- };
101
- };
102
- /** MCP Config workflow - per-agent MCP configuration */
103
- export declare const MCP_CONFIG: {
104
- readonly workflowId: "694a35b5b8b5c5f803078928";
105
- readonly phases: {
106
- readonly active: "694a35b5b8b5c5f80307893b";
107
- };
108
- readonly fields: {
109
- readonly agentName: "694a35b5b8b5c5f803078929";
110
- readonly agentId: "694a35b5b8b5c5f80307892a";
111
- readonly publicKey: "694a35b5b8b5c5f80307892c";
112
- readonly accessTo: "694a35b5b8b5c5f80307892b";
113
- readonly authToken: "694a35b5b8b5c5f80307892d";
114
- readonly apiKey: "694a35b5b8b5c5f80307892e";
115
- readonly workspaceId: "694a35b5b8b5c5f803078934";
116
- readonly permissions: "694a35b5b8b5c5f803078935";
117
- readonly sessionId: "694a35b5b8b5c5f803078936";
118
- readonly resourceLimits: "694a35b5b8b5c5f803078937";
119
- readonly loggingEndpoint: "694a35b5b8b5c5f803078938";
120
- readonly callbackUrl: "694a35b5b8b5c5f803078939";
121
- readonly customContext: "694a35b5b8b5c5f80307893a";
122
- readonly permCreate: "694a35b5b8b5c5f803078930";
123
- readonly permRead: "694a35b5b8b5c5f803078931";
124
- readonly permUpdate: "694a35b5b8b5c5f803078932";
125
- readonly permDelete: "694a35b5b8b5c5f803078933";
126
- };
127
- };
128
- /** Session usage metrics */
129
- export interface SessionMetrics {
130
- inputTokens: number;
131
- outputTokens: number;
132
- toolCalls: number;
133
- messagesProcessed: number;
134
- responsesPosted: number;
135
- }
136
- /** Per-activity session tracking */
137
- export interface ActivitySession {
138
- activityId: string;
139
- activityName: string;
140
- discussionId: string;
141
- startTime: number;
142
- lastActivityTime: number;
143
- metrics: SessionMetrics;
144
- actions: string[];
145
- previousLogId: string | null;
146
- /** Compact conversation log: "User: ...", "Bot: ..." */
147
- conversation: string[];
148
- }
149
- export type MessagePriority = "high" | "normal" | "low";
150
- export interface IncomingMessage {
151
- id: string;
152
- discussionId: string;
153
- discussionName?: string;
154
- linkedActivityId?: string;
155
- linkedActivityName?: string;
156
- senderId: string;
157
- senderName: string;
158
- content: string;
159
- timestamp: number;
160
- priority: MessagePriority;
161
- priorityReason: string;
162
- isReplyToBot: boolean;
163
- isMention: boolean;
164
- isDirectMessage: boolean;
165
- }
166
- export type LlmDecision = {
167
- action: "respond";
168
- discussionId: string;
169
- content: string;
170
- } | {
171
- action: "ignore";
172
- reason: string;
173
- } | {
174
- action: "tool_call";
175
- toolName: string;
176
- args: any;
177
- } | {
178
- action: "thinking";
179
- content: string;
180
- };
181
- interface ConversationMessage {
182
- role: "user" | "assistant";
183
- content: string | any[];
184
- }
185
- export interface ChatAgentDaemonConfig {
186
- botClient: BotClient;
187
- mcpServerUrl: string;
188
- anthropicApiKey: string;
189
- model?: string;
190
- maxContextMessages?: number;
191
- }
192
- export declare class ChatAgentDaemon {
193
- protected logger: Logger;
194
- protected client: Anthropic;
195
- protected botClient: BotClient;
196
- protected config: ChatAgentDaemonConfig;
197
- protected toolSchemaLoader: ToolSchemaLoader;
198
- protected conversationMessages: ConversationMessage[];
199
- protected isProcessing: boolean;
200
- protected messageQueue: IncomingMessage[];
201
- protected processedMessageIds: Set<string>;
202
- protected toolIndex: any[];
203
- protected minimalTools: any[];
204
- protected loadedToolSchemas: Map<string, any>;
205
- /** This agent's activity ID in the Agent Directory */
206
- protected agentDirectoryId: string | null;
207
- /** This agent's Position activity ID */
208
- protected positionId: string | null;
209
- /** Shared Team activity ID for AI agents */
210
- protected teamId: string | null;
211
- /** MCP Server Tool Registry activity ID (shared) */
212
- protected toolRegistryId: string | null;
213
- /** This agent's MCP Config activity ID */
214
- protected mcpConfigId: string | null;
215
- /** Per-activity session tracking (activityId -> session) */
216
- protected activitySessions: Map<string, ActivitySession>;
217
- /** Global session log chain ID (for overall continuity) */
218
- protected lastGlobalLogId: string | null;
219
- /** Timer for checking idle sessions */
220
- protected idleCheckTimer: NodeJS.Timeout | null;
221
- /** Current discussion context for tracking */
222
- protected currentDiscussionId: string | null;
223
- protected currentLinkedActivityId: string | null;
224
- constructor(config: ChatAgentDaemonConfig);
225
- /**
226
- * Initialize the daemon - load tools and subscribe to signals
227
- */
228
- initialize(): Promise<void>;
229
- /**
230
- * Handle incoming signal from Hailer
231
- */
232
- private handleSignal;
233
- /**
234
- * Extract and classify incoming message from signal
235
- * Override in subclasses to customize message filtering
236
- */
237
- protected extractIncomingMessage(signal: HailerSignal): Promise<IncomingMessage | null>;
238
- /**
239
- * Check if message mentions this bot
240
- */
241
- private checkMention;
242
- /**
243
- * Check if message is a reply to one of our messages
244
- */
245
- private checkReplyToBot;
246
- /**
247
- * Check if this is a 1:1 DM with the bot
248
- */
249
- private checkDirectMessage;
250
- /**
251
- * Get user's display name from workspace cache
252
- */
253
- private getUserDisplayName;
254
- /**
255
- * Format a Hailer tag for mentioning a user or activity
256
- * Hailer requires ZWNBSP (U+FEFF) around the tag
257
- */
258
- private formatHailerTag;
259
- /**
260
- * Extract link metadata from hailerTag formatted content
261
- * Returns array of links for the messenger.send API
262
- */
263
- private extractTagLinks;
264
- /**
265
- * Look up user by ID and create a Hailer tag
266
- */
267
- private createUserTagById;
268
- /**
269
- * Look up user by name and create a Hailer tag
270
- */
271
- private createUserTagByName;
272
- /**
273
- * Convert @mentions and #activity tags in response to Hailer tags
274
- * Supports:
275
- * - @userId (24-char hex MongoDB ID) → user tag
276
- * - @"Full Name" (quoted name lookup) → user tag
277
- * - @FirstName (single word name lookup) → user tag
278
- * - #activityId (24-char hex) → activity tag
279
- * - #"Activity Name" (quoted) → activity tag (requires lookup)
280
- */
281
- private convertMentionsToTags;
282
- /**
283
- * Resolve user tags - look up names for IDs via API when not in cache
284
- * Handles @userId (24-char hex) format
285
- */
286
- private resolveUserTags;
287
- /**
288
- * Resolve activity tags - look up names for IDs and IDs for names
289
- * Handles both #activityId and #"Activity Name" formats
290
- */
291
- private resolveActivityTags;
292
- /**
293
- * Process queued messages through the LLM
294
- */
295
- private processQueue;
296
- /**
297
- * Process a single message through the persistent LLM conversation
298
- */
299
- private processMessage;
300
- /**
301
- * Format incoming message for LLM consumption
302
- */
303
- private formatIncomingMessage;
304
- /**
305
- * Execute tool calls and continue the conversation
306
- * Simple passthrough - just execute tools and return results to LLM
307
- */
308
- protected executeToolsAndContinue(toolUseBlocks: Anthropic.ToolUseBlock[], originalMessage: IncomingMessage): Promise<void>;
309
- /**
310
- * Handle LLM response
311
- * Override in subclasses to customize response handling
312
- */
313
- protected handleLlmResponse(response: Anthropic.Message, originalMessage: IncomingMessage): Promise<void>;
314
- /**
315
- * Post a response to a discussion
316
- * Automatically converts @mentions and #activity tags to Hailer tags
317
- * Includes links metadata required for tags to work
318
- */
319
- protected postResponse(discussionId: string, content: string): Promise<void>;
320
- /**
321
- * Manage conversation context size - summarize if too large
322
- */
323
- private manageContextSize;
324
- /**
325
- * Get the system prompt for the daemon
326
- * MUST be overridden in subclasses
327
- */
328
- protected getSystemPrompt(): string;
329
- /**
330
- * Fetch tool schema from MCP server
331
- */
332
- private fetchToolSchema;
333
- /**
334
- * Call MCP tool
335
- */
336
- protected callMcpTool(name: string, args: any): Promise<any>;
337
- /**
338
- * Stop the daemon
339
- * Flushes all pending activity sessions before stopping
340
- */
341
- stop(): Promise<void>;
342
- /**
343
- * Get current conversation state (for debugging)
344
- */
345
- getConversationState(): {
346
- messageCount: number;
347
- queueLength: number;
348
- lastMessages: Array<{
349
- role: string;
350
- preview: string;
351
- timestamp?: string;
352
- }>;
353
- isProcessing: boolean;
354
- };
355
- /**
356
- * Get full conversation for deep debugging
357
- */
358
- getFullConversation(): ConversationMessage[];
359
- /**
360
- * Get agent's display name (override in subclass for custom names)
361
- */
362
- protected getAgentName(): {
363
- firstName: string;
364
- lastName: string;
365
- };
366
- /**
367
- * Get agent's description/system prompt (override in subclass)
368
- */
369
- protected getAgentDescription(): string;
370
- /**
371
- * Get default team ID from workspace cache
372
- * Returns the first available team, or undefined if no teams exist
373
- *
374
- * Teams structure in init is: { teams: { workspaceId: { teamId: teamData, ... } } }
375
- */
376
- protected getDefaultTeamId(): string | undefined;
377
- /**
378
- * Register this agent in the Agent Directory
379
- * Called during initialize() - finds existing entry or creates new one
380
- */
381
- protected registerAgentInDirectory(): Promise<void>;
382
- /**
383
- * Find existing agent entry by email
384
- */
385
- private findAgentByEmail;
386
- /**
387
- * Update agent's Hailer profile reference
388
- */
389
- private updateAgentProfile;
390
- /**
391
- * Register all agent data across all workflows
392
- * Orchestrates: Agent Directory, Position, Team, Tool Registry, MCP Config
393
- */
394
- protected registerAllAgentData(): Promise<void>;
395
- /**
396
- * Get agent's Position details (override in subclass for custom positions)
397
- */
398
- protected getPositionDetails(): {
399
- name: string;
400
- purpose: string;
401
- personaTone: string;
402
- coreCapabilities: string;
403
- boundaries: string;
404
- };
405
- /**
406
- * Register/find shared Team for AI agents
407
- */
408
- protected registerTeam(): Promise<void>;
409
- /**
410
- * Register MCP server in Tool Registry
411
- */
412
- protected registerToolRegistry(): Promise<void>;
413
- /**
414
- * Register Position for this agent
415
- */
416
- protected registerPosition(): Promise<void>;
417
- /**
418
- * Register MCP Config for this agent
419
- */
420
- protected registerMcpConfig(): Promise<void>;
421
- /**
422
- * Link Agent Directory entry to Position and Team
423
- */
424
- protected linkAgentToPositionAndTeam(): Promise<void>;
425
- /**
426
- * Extract activity ID from MCP tool response text
427
- */
428
- private extractActivityId;
429
- /**
430
- * Get or create an activity session for tracking
431
- */
432
- protected getOrCreateActivitySession(message: IncomingMessage): ActivitySession;
433
- /**
434
- * Check for idle sessions and flush them
435
- * Called periodically by timer
436
- */
437
- protected checkAndFlushIdleSessions(): Promise<void>;
438
- /**
439
- * Flush a single activity session to the session log
440
- */
441
- protected flushActivitySession(key: string, session: ActivitySession): Promise<void>;
442
- /**
443
- * Flush all active sessions (called on shutdown)
444
- */
445
- protected flushAllSessions(): Promise<void>;
446
- /**
447
- * Build summary for an activity session
448
- */
449
- private buildActivitySessionSummary;
450
- /**
451
- * Generate brief summary from session actions
452
- */
453
- private generateBriefSummaryFromActions;
454
- /**
455
- * Get all active session metrics (for monitoring)
456
- */
457
- getActiveSessions(): Map<string, ActivitySession>;
458
- /**
459
- * Get agent directory ID
460
- */
461
- getAgentDirectoryId(): string | null;
462
- }
463
- export {};
464
- //# sourceMappingURL=chat-agent-daemon.d.ts.map