@hailer/mcp 0.1.17 → 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 (200) 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-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,91 +0,0 @@
1
- /**
2
- * Specialist Daemon
3
- *
4
- * A lightweight daemon for specialist bots that only responds when @mentioned.
5
- * Specialists are invited to discussions by the orchestrator (HAL) to handle
6
- * specific complex tasks.
7
- *
8
- * Key differences from ChatAgentDaemon:
9
- * - Only responds when @mentioned (not all messages)
10
- * - Has specialized system prompt from Specialist config
11
- * - More tool-focused, less conversational
12
- */
13
- import { ChatAgentDaemon, ChatAgentDaemonConfig, IncomingMessage } from "./base";
14
- import { Specialist } from "../hal/definitions";
15
- import { HailerSignal } from "../../mcp/signal-handler";
16
- import { ToolInput } from "./types";
17
- export interface SpecialistDaemonConfig extends ChatAgentDaemonConfig {
18
- /** The specialist configuration */
19
- specialist: Specialist;
20
- }
21
- export declare class SpecialistDaemon extends ChatAgentDaemon {
22
- private specialistLogger;
23
- private specialist;
24
- private lastResponseTime;
25
- private minResponseGap;
26
- constructor(config: SpecialistDaemonConfig);
27
- /**
28
- * Override agent name for Agent Directory - uses specialist's configured name
29
- */
30
- protected getAgentName(): {
31
- firstName: string;
32
- lastName: string;
33
- };
34
- /**
35
- * Override agent description for Agent Directory - uses specialist's expertise
36
- */
37
- protected getAgentDescription(): string;
38
- /**
39
- * Override Position details for Specialist - uses specialist's expertise
40
- */
41
- protected getPositionDetails(): {
42
- name: string;
43
- purpose: string;
44
- personaTone: string;
45
- coreCapabilities: string;
46
- boundaries: string;
47
- };
48
- /**
49
- * Specialist gets more tools for complex operations
50
- */
51
- protected getToolWhitelist(): string[];
52
- /**
53
- * Force compact output for schema tools (avoid verbose field dumps in discussions)
54
- */
55
- protected preprocessToolInput(toolName: string, input: ToolInput): ToolInput;
56
- /**
57
- * Override to only process messages where we're @mentioned
58
- */
59
- protected extractIncomingMessage(signal: HailerSignal): Promise<IncomingMessage | null>;
60
- /**
61
- * Check if this specialist is mentioned in the message
62
- * Supports various mention formats:
63
- * - @"Specialist Name"
64
- * - @SpecialistName (no spaces)
65
- * - Direct user tag [hailerTag|Name](userId)
66
- */
67
- private isMentionedInMessage;
68
- /**
69
- * Override system prompt with specialist-specific prompt
70
- */
71
- protected getSystemPrompt(): string;
72
- /**
73
- * Track response time for rate limiting
74
- */
75
- protected postResponse(discussionId: string, content: string): Promise<void>;
76
- /**
77
- * Get specialist status
78
- */
79
- getSpecialistStatus(): {
80
- name: string;
81
- expertise: string[];
82
- conversationState: ReturnType<ChatAgentDaemon["getConversationState"]>;
83
- lastResponseTime: number;
84
- };
85
- /**
86
- * Trigger specialist to respond in a discussion with specific context
87
- * Used for proactive responses (e.g., bug detection triggering Giuseppe)
88
- */
89
- respondWithContext(discussionId: string, activityId: string, contextMessage: string): Promise<void>;
90
- }
91
- //# sourceMappingURL=specialist.d.ts.map
@@ -1,399 +0,0 @@
1
- "use strict";
2
- /**
3
- * Specialist Daemon
4
- *
5
- * A lightweight daemon for specialist bots that only responds when @mentioned.
6
- * Specialists are invited to discussions by the orchestrator (HAL) to handle
7
- * specific complex tasks.
8
- *
9
- * Key differences from ChatAgentDaemon:
10
- * - Only responds when @mentioned (not all messages)
11
- * - Has specialized system prompt from Specialist config
12
- * - More tool-focused, less conversational
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SpecialistDaemon = void 0;
16
- const base_1 = require("./base");
17
- const logger_1 = require("../../lib/logger");
18
- class SpecialistDaemon extends base_1.ChatAgentDaemon {
19
- specialistLogger;
20
- specialist;
21
- lastResponseTime = 0;
22
- minResponseGap = 2000; // 2 seconds minimum between responses
23
- constructor(config) {
24
- super(config);
25
- this.specialist = config.specialist;
26
- this.specialistLogger = (0, logger_1.createLogger)({
27
- component: "SpecialistDaemon",
28
- botId: config.botClient.userId,
29
- specialistName: config.specialist.name,
30
- });
31
- }
32
- // ===== AGENT DIRECTORY OVERRIDES =====
33
- /**
34
- * Override agent name for Agent Directory - uses specialist's configured name
35
- */
36
- getAgentName() {
37
- const nameParts = this.specialist.name.split(" ");
38
- const firstName = nameParts[0] || "Specialist";
39
- const lastName = nameParts.slice(1).join(" ") || "Bot";
40
- return { firstName, lastName };
41
- }
42
- /**
43
- * Override agent description for Agent Directory - uses specialist's expertise
44
- */
45
- getAgentDescription() {
46
- return `${this.specialist.name} - Specialist bot.\n\nExpertise: ${this.specialist.expertise.join(", ")}\n\n${this.specialist.systemPrompt.substring(0, 500)}...`;
47
- }
48
- /**
49
- * Override Position details for Specialist - uses specialist's expertise
50
- */
51
- getPositionDetails() {
52
- return {
53
- name: `${this.specialist.name} Position`,
54
- purpose: `Specialist bot for: ${this.specialist.expertise.join(", ")}`,
55
- personaTone: "Technical, precise, and data-focused. Responds with structured results.",
56
- coreCapabilities: this.specialist.expertise.map(e => `- ${e}`).join("\n"),
57
- boundaries: "- Only respond when explicitly @mentioned\n- Never fabricate data - always use tools\n- Stay focused on specialty area\n- Hand back to orchestrator when done",
58
- };
59
- }
60
- /**
61
- * Specialist gets more tools for complex operations
62
- */
63
- getToolWhitelist() {
64
- return [
65
- // All orchestrator tools
66
- "list_workflows",
67
- "list_workflow_phases",
68
- "get_workflow_schema",
69
- "list_workflows_minimal",
70
- "list_activities",
71
- "show_activity_by_id",
72
- "count_activities",
73
- "create_activity",
74
- "update_activity",
75
- "join_discussion",
76
- "add_discussion_message",
77
- "invite_discussion_members",
78
- "fetch_discussion_messages",
79
- "get_activity_from_discussion",
80
- "list_my_discussions",
81
- "search_workspace_users",
82
- // Insight tools
83
- "list_insights",
84
- "get_insight_data",
85
- "preview_insight",
86
- "create_insight",
87
- "update_insight",
88
- "remove_insight",
89
- // Workflow config
90
- "update_workflow_field",
91
- "update_workflow_phase",
92
- "install_workflow",
93
- "remove_workflow",
94
- // Template tools
95
- "list_templates",
96
- "get_template",
97
- "create_template",
98
- "install_template",
99
- // Other
100
- "upload_files",
101
- "test_function_field",
102
- ];
103
- }
104
- /**
105
- * Force compact output for schema tools (avoid verbose field dumps in discussions)
106
- */
107
- preprocessToolInput(toolName, input) {
108
- if (toolName === "get_workflow_schema") {
109
- return { ...input, compact: true };
110
- }
111
- return input;
112
- }
113
- /**
114
- * Override to only process messages where we're @mentioned
115
- */
116
- async extractIncomingMessage(signal) {
117
- // Get base message extraction
118
- const message = await super.extractIncomingMessage(signal);
119
- if (!message)
120
- return null;
121
- // Specialists only respond when mentioned
122
- if (!this.isMentionedInMessage(message)) {
123
- this.specialistLogger.debug("Message doesn't mention specialist, ignoring", {
124
- discussion: message.discussionId,
125
- from: message.senderName,
126
- });
127
- return null;
128
- }
129
- // Rate limit responses
130
- const now = Date.now();
131
- if (now - this.lastResponseTime < this.minResponseGap) {
132
- this.specialistLogger.debug("Rate limiting specialist response", {
133
- timeSinceLastResponse: now - this.lastResponseTime,
134
- });
135
- return null;
136
- }
137
- // Mark as high priority since we're explicitly mentioned
138
- message.priority = "high";
139
- message.priorityReason = `Specialist ${this.specialist.name} was tagged`;
140
- this.specialistLogger.info("Specialist mentioned, processing message", {
141
- discussion: message.discussionId,
142
- from: message.senderName,
143
- preview: message.content.substring(0, 50),
144
- });
145
- return message;
146
- }
147
- /**
148
- * Check if this specialist is mentioned in the message
149
- * Supports various mention formats:
150
- * - @"Specialist Name"
151
- * - @SpecialistName (no spaces)
152
- * - Direct user tag [hailerTag|Name](userId)
153
- */
154
- isMentionedInMessage(message) {
155
- const content = message.content;
156
- const name = this.specialist.name;
157
- const userId = this.botClient.userId;
158
- // Check for hailerTag mention (most reliable)
159
- const hailerTagPattern = new RegExp(`\\[hailerTag\\|[^\\]]*\\]\\(${userId}\\)`, "i");
160
- if (hailerTagPattern.test(content)) {
161
- return true;
162
- }
163
- // Check for @"Name" mention
164
- if (content.includes(`@"${name}"`)) {
165
- return true;
166
- }
167
- // Check for @Name (no spaces version)
168
- const nameNoSpaces = name.replace(/\s+/g, "");
169
- if (content.includes(`@${nameNoSpaces}`)) {
170
- return true;
171
- }
172
- // Check for @Name (first word)
173
- const firstName = name.split(" ")[0];
174
- if (content.includes(`@${firstName}`)) {
175
- return true;
176
- }
177
- // Check message.isMention (set by parent class)
178
- if (message.isMention) {
179
- return true;
180
- }
181
- return false;
182
- }
183
- /**
184
- * Override system prompt with specialist-specific prompt
185
- */
186
- getSystemPrompt() {
187
- const now = new Date();
188
- return `${this.specialist.systemPrompt}
189
-
190
- <current_time>${now.toISOString()}</current_time>
191
-
192
- <bot_info>
193
- Bot ID: ${this.botClient.userId}
194
- Name: ${this.specialist.name}
195
- </bot_info>
196
-
197
- <response_rules>
198
- - You were invited to this discussion to help with a specific task
199
- - Read HAL's handoff message to understand what's needed
200
- - Use MCP tools to complete the task - NEVER fabricate data
201
- - Respond with clear, structured results
202
- - Include activity links using #activityId format
203
- - Be concise and technical - data first, explanation second
204
- </response_rules>
205
-
206
- <tool_parameters>
207
- <context_ids>
208
- Extract IDs from the incoming tag and HAL's handoff:
209
- - activityId attribute → show_activity_by_id, update_activity
210
- - discussionId attribute → get_activity_from_discussion
211
- - workflowId, fieldId → insight tools
212
- </context_ids>
213
-
214
- <never_do>
215
- - Call tools with empty parameters {}
216
- - Use field LABELS as fieldIds (fieldId must be 24-char hex)
217
- - Guess IDs - always extract from context
218
- </never_do>
219
-
220
- <update_activity_formats>
221
- - Single mode: use activityId parameter
222
- - Bulk mode: use _id inside activities array (NOT activityId)
223
- </update_activity_formats>
224
-
225
- <field_values>
226
- - numericunit: 78 (NOT {"type":"numericunit","value":78})
227
- - activitylink: "abc123..." (NOT {"_id":"abc123","name":"..."})
228
- </field_values>
229
- </tool_parameters>
230
-
231
- <insight_tools>
232
- <critical>
233
- - fieldId MUST be 24-character hex ID, NOT the field label!
234
- - Field names must be SQL-safe: no spaces (use camelCase)
235
- </critical>
236
-
237
- <create_insight_format>
238
- sources: [{
239
- name: "tableAlias",
240
- workflowId: "691ffdf84217e9e8434e56ad",
241
- fields: [
242
- { name: "playerName", fieldId: "691ffdf84217e9e8434e56b1" },
243
- { name: "injuryType", fieldId: "691ffdf84217e9e8434e56b2" }
244
- ]
245
- }]
246
- </create_insight_format>
247
-
248
- <hailer_sql_syntax>
249
- Hailer insights: fields are mapped in sources.fields, then referenced by ALIAS in query.
250
-
251
- HOW IT WORKS:
252
- 1. Define fields in sources: { name: "playerName", fieldId: "691fff..." }
253
- 2. Use the NAME (alias) in SQL: SELECT playerName FROM tableName
254
-
255
- SELECT columns - use the field ALIAS names you defined:
256
- - playerName, injuryType ← custom fields (by alias)
257
- - name ← built-in activity name
258
-
259
- Column aliases with spaces need quotes:
260
- - playerName as "Player Name"
261
- - injuryType as "Injury Type"
262
-
263
- LIMITATIONS - DO NOT USE:
264
- - Phase filtering (no _phase column)
265
- - Date functions like NOW(), date('now'), CURRENT_DATE
266
- - Complex WHERE clauses with dates
267
-
268
- Keep queries SIMPLE: SELECT, FROM, basic WHERE (string comparisons), ORDER BY.
269
- Users can filter via UI "Show Filters" button.
270
- </hailer_sql_syntax>
271
-
272
- <correct_query_example>
273
- sources: [{
274
- name: "injuries",
275
- workflowId: "691ffdf84217e9e8434e56ad",
276
- fields: [
277
- { name: "playerName", fieldId: "691ffdf84217e9e8434e5694" },
278
- { name: "injuryType", fieldId: "691ffdf84217e9e8434e5695" }
279
- ]
280
- }]
281
-
282
- query: "SELECT playerName as \\"Player\\", injuryType as \\"Injury Type\\" FROM injuries ORDER BY playerName ASC"
283
-
284
- WRONG (will fail):
285
- - WHERE expectedRecovery > date('now')
286
- - WHERE _phase = 'phaseId'
287
- - SELECT FIELD(fieldId) as column
288
- </correct_query_example>
289
-
290
- <where_to_get_ids>
291
- HAL's handoff contains workflowId, fieldIds, and phaseIds. Use them exactly.
292
- If not provided, call get_workflow_schema AND list_workflow_phases.
293
- </where_to_get_ids>
294
- </insight_tools>
295
-
296
- <response_format>
297
- When you complete a task, respond with:
298
- <respond discussion="DISCUSSION_ID">
299
- [Status emoji] [Brief summary]
300
-
301
- **What I did:**
302
- - Step 1: ...
303
- - Step 2: ...
304
-
305
- **Results:**
306
- [Data, links, or confirmation]
307
-
308
- **Next steps (if applicable):**
309
- [Suggestions for follow-up]
310
- </respond>
311
-
312
- If you need clarification:
313
- <respond discussion="DISCUSSION_ID">
314
- I need more information to complete this task:
315
- - Question 1?
316
- - Question 2?
317
- </respond>
318
- </response_format>`;
319
- }
320
- /**
321
- * Track response time for rate limiting
322
- */
323
- async postResponse(discussionId, content) {
324
- await super.postResponse(discussionId, content);
325
- this.lastResponseTime = Date.now();
326
- }
327
- /**
328
- * Get specialist status
329
- */
330
- getSpecialistStatus() {
331
- return {
332
- name: this.specialist.name,
333
- expertise: this.specialist.expertise,
334
- conversationState: this.getConversationState(),
335
- lastResponseTime: this.lastResponseTime,
336
- };
337
- }
338
- /**
339
- * Trigger specialist to respond in a discussion with specific context
340
- * Used for proactive responses (e.g., bug detection triggering Giuseppe)
341
- */
342
- async respondWithContext(discussionId, activityId, contextMessage) {
343
- this.specialistLogger.info('Triggering contextual response', { discussionId, activityId });
344
- try {
345
- // Join the discussion first using MCP tool
346
- // Note: join_discussion expects activityId to find the linked discussion
347
- const joinResult = await this.callMcpTool("join_discussion", { activityId });
348
- const joinResultText = joinResult?.content?.[0]?.text || '';
349
- this.specialistLogger.debug('Join discussion result', {
350
- activityId,
351
- resultPreview: joinResultText.substring(0, 200)
352
- });
353
- // Get workspace ID from bot client cache
354
- const workspaceId = this.botClient.workspaceCache?.currentWorkspace?._id || '';
355
- if (!workspaceId) {
356
- this.specialistLogger.warn('No workspace ID available from cache');
357
- }
358
- // Create a synthetic incoming message with the context
359
- const syntheticMessage = {
360
- id: `synthetic-${Date.now()}`,
361
- discussionId,
362
- linkedActivityId: activityId,
363
- workspaceId,
364
- content: contextMessage,
365
- senderName: 'System',
366
- senderId: 'system',
367
- timestamp: Date.now(),
368
- priority: 'high',
369
- priorityReason: 'system_notification',
370
- isReplyToBot: false,
371
- isMention: true, // Treat as mention so specialist responds
372
- isDirectMessage: false,
373
- };
374
- this.specialistLogger.info('Queuing synthetic message for LLM pipeline', {
375
- discussionId,
376
- activityId,
377
- contentLength: contextMessage.length
378
- });
379
- // Process through normal LLM pipeline
380
- await this['processMessage'](syntheticMessage);
381
- this.specialistLogger.info('Contextual response completed', { discussionId, activityId });
382
- }
383
- catch (error) {
384
- // Properly serialize error for logging
385
- const errorMessage = error instanceof Error ? error.message : String(error);
386
- const errorStack = error instanceof Error ? error.stack : undefined;
387
- this.specialistLogger.error('Failed to respond with context', {
388
- discussionId,
389
- activityId,
390
- errorMessage,
391
- errorStack
392
- });
393
- // Re-throw so caller knows it failed
394
- throw error;
395
- }
396
- }
397
- }
398
- exports.SpecialistDaemon = SpecialistDaemon;
399
- //# sourceMappingURL=specialist.js.map
@@ -1,62 +0,0 @@
1
- /**
2
- * Tool Schema Loader
3
- *
4
- * Manages MCP tool discovery, schema loading, and filtering.
5
- * Shared between all LLM providers (Anthropic, OpenAI, etc.)
6
- *
7
- * Key Features:
8
- * - Load lightweight tool index from MCP server
9
- * - Filter tools by groups (READ, WRITE, PLAYGROUND)
10
- * - Load full schemas on-demand (token-efficient)
11
- * - Cache loaded schemas
12
- */
13
- import { ToolGroup } from '../../mcp/tool-registry';
14
- import { JsonSchema } from './types';
15
- import Anthropic from '@anthropic-ai/sdk';
16
- export interface ToolIndexEntry {
17
- name: string;
18
- category: string;
19
- description: string;
20
- }
21
- export interface ToolDefinition {
22
- name: string;
23
- description: string;
24
- input_schema: JsonSchema;
25
- }
26
- export interface LoadToolsOptions {
27
- mcpServerUrl: string;
28
- mcpServerApiKey: string;
29
- allowedGroups: ToolGroup[];
30
- allowedTools?: string[];
31
- excludeMessageFetchTools?: boolean;
32
- }
33
- export declare class ToolSchemaLoader {
34
- private toolSchemaCache;
35
- /**
36
- * Load tool index with filtering
37
- * Returns lightweight tool list with optional exclusions
38
- */
39
- loadToolIndex(options: LoadToolsOptions): Promise<ToolIndexEntry[]>;
40
- /**
41
- * Load full schema for a specific tool on-demand
42
- */
43
- loadToolSchema(mcpServerUrl: string, mcpServerApiKey: string, toolName: string): Promise<any>;
44
- /**
45
- * Convert tool index to minimal tool definitions (stubs)
46
- * Full schemas will be loaded on-demand when needed
47
- */
48
- toMinimalToolDefinitions(toolIndex: ToolIndexEntry[]): Anthropic.Tool[];
49
- /**
50
- * Get count of loaded schemas
51
- */
52
- getLoadedSchemaCount(): number;
53
- /**
54
- * Clear schema cache
55
- */
56
- clearCache(): void;
57
- /**
58
- * Fetch tool index from MCP server
59
- */
60
- private fetchMcpToolIndex;
61
- }
62
- //# sourceMappingURL=tool-schema-loader.d.ts.map