@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,55 +0,0 @@
1
- /**
2
- * Specialist Bot Configuration
3
- *
4
- * Defines specialist bots that can be invited by the orchestrator (HAL)
5
- * when tasks are too complex for general handling.
6
- *
7
- * Each specialist has:
8
- * - Trigger patterns: When HAL should consider inviting them
9
- * - Expertise areas: What they're good at
10
- * - System prompt: How they behave when invited
11
- */
12
- export interface Specialist {
13
- /** Definition name (e.g., "Hailer Expert") - used internally */
14
- name: string;
15
- /** Actual Hailer user display name (e.g., "Claude Terminal") - used for @mentions */
16
- displayName?: string;
17
- /** Hailer user ID of this bot (set at runtime from config) */
18
- botUserId?: string;
19
- /** Email of this bot (for matching with config) */
20
- botEmail: string;
21
- /** What this specialist is good at */
22
- expertise: string[];
23
- /** Regex patterns that trigger consideration of this specialist */
24
- triggerPatterns: RegExp[];
25
- /** Keywords that suggest this specialist (less strict than patterns) */
26
- triggerKeywords: string[];
27
- /** System prompt for this specialist when active */
28
- systemPrompt: string;
29
- /** Model to use (defaults to parent config) */
30
- model?: string;
31
- }
32
- /**
33
- * Registry of available specialists
34
- * Key is the specialist identifier used internally
35
- */
36
- export declare const SPECIALISTS: Record<string, Specialist>;
37
- /**
38
- * Find a specialist that matches the given message content
39
- * Returns the specialist if patterns match, null otherwise
40
- */
41
- export declare function findMatchingSpecialist(content: string): Specialist | null;
42
- /**
43
- * Check if content contains keywords suggesting a specialist might help
44
- * Less strict than pattern matching - used for secondary consideration
45
- */
46
- export declare function hasSpecialistKeywords(content: string, specialist: Specialist): boolean;
47
- /**
48
- * Get specialist by key
49
- */
50
- export declare function getSpecialist(key: string): Specialist | undefined;
51
- /**
52
- * Get all specialist keys
53
- */
54
- export declare function getSpecialistKeys(): string[];
55
- //# sourceMappingURL=definitions.d.ts.map
@@ -1,263 +0,0 @@
1
- "use strict";
2
- /**
3
- * Specialist Bot Configuration
4
- *
5
- * Defines specialist bots that can be invited by the orchestrator (HAL)
6
- * when tasks are too complex for general handling.
7
- *
8
- * Each specialist has:
9
- * - Trigger patterns: When HAL should consider inviting them
10
- * - Expertise areas: What they're good at
11
- * - System prompt: How they behave when invited
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.SPECIALISTS = void 0;
15
- exports.findMatchingSpecialist = findMatchingSpecialist;
16
- exports.hasSpecialistKeywords = hasSpecialistKeywords;
17
- exports.getSpecialist = getSpecialist;
18
- exports.getSpecialistKeys = getSpecialistKeys;
19
- /**
20
- * Registry of available specialists
21
- * Key is the specialist identifier used internally
22
- */
23
- exports.SPECIALISTS = {
24
- giuseppe: {
25
- name: "Giuseppe",
26
- botEmail: "", // Set from config at runtime (uses same bot as orchestrator for now)
27
- expertise: [
28
- "bug fixing",
29
- "app debugging",
30
- "React/TypeScript fixes",
31
- "Hailer app development",
32
- "automated code repair",
33
- ],
34
- triggerPatterns: [
35
- // Bug reports
36
- /bug\s+(report|in|with|found)/i,
37
- /report\s+(a\s+)?bug/i,
38
- /found\s+(a\s+)?bug/i,
39
- /there('s|\s+is)\s+(a\s+)?bug/i,
40
- // Fix requests
41
- /fix\s+(the|this|my)\s+(bug|issue|problem|app)/i,
42
- /can\s+you\s+fix/i,
43
- /please\s+fix/i,
44
- // App issues
45
- /app\s+(is\s+)?(broken|not\s+working|crashing|laggy)/i,
46
- /(broken|crashing|laggy)\s+app/i,
47
- // Giuseppe mentions
48
- /giuseppe/i,
49
- /auto.?fix/i,
50
- ],
51
- triggerKeywords: [
52
- "bug",
53
- "fix",
54
- "broken",
55
- "issue",
56
- "error",
57
- "crash",
58
- "laggy",
59
- "not working",
60
- "giuseppe",
61
- ],
62
- systemPrompt: `<identity>
63
- You are Giuseppe - the autonomous bug fixing specialist.
64
- You were designed to automatically detect, analyze, and fix bugs in Hailer apps.
65
- </identity>
66
-
67
- <capabilities>
68
- **Automatic Bug Detection:**
69
- - I monitor the "Bug Reports" workflow for new bugs
70
- - When a bug is detected, I automatically:
71
- 1. Find the app project
72
- 2. Analyze the code
73
- 3. Generate a fix using Claude
74
- 4. Apply and test the fix
75
- 5. Ask for approval before publishing
76
-
77
- **Bug Report Workflow:**
78
- - Users create bug reports in the "Bug Reports" workflow
79
- - I pick them up automatically and start fixing
80
- - After the fix is ready, I ask the user to test
81
- - User replies "approved" → I publish to production
82
- - User replies "denied" → I ask what's wrong and retry
83
-
84
- **What I Can Fix:**
85
- - React/TypeScript compilation errors
86
- - Hailer app SDK issues
87
- - UI bugs and layout problems
88
- - State management issues
89
- - API integration bugs
90
- </capabilities>
91
-
92
- <how_to_use>
93
- To report a bug for me to fix:
94
- 1. Create a new activity in the "Bug Reports" workflow
95
- 2. Set the title to include the app name (e.g., "Bug Report - My App")
96
- 3. Describe the bug in detail
97
- 4. I'll automatically pick it up and start working on it!
98
-
99
- Or just tell HAL about a bug and ask to create a bug report.
100
- </how_to_use>
101
-
102
- <response_format>
103
- When asked about bugs or my capabilities:
104
- - Explain what I can do
105
- - Offer to create a bug report if they describe a bug
106
- - Tell them to check the Bug Reports workflow for status
107
- </response_format>`,
108
- },
109
- hailerExpert: {
110
- name: "Hailer Expert",
111
- botEmail: "", // Set from config at runtime
112
- expertise: [
113
- "workflow creation and management",
114
- "activity bulk operations",
115
- "insights and SQL reports",
116
- "complex data queries",
117
- "workflow configuration",
118
- ],
119
- triggerPatterns: [
120
- // Workflow creation
121
- /create\s+(a\s+)?(new\s+)?(workflow|pipeline|process|tracker)/i,
122
- /set\s+up\s+(a\s+)?(new\s+)?(workflow|pipeline|process)/i,
123
- /build\s+(me\s+)?(a\s+)?(workflow|pipeline|crm|tracker)/i,
124
- // Insight/report creation
125
- /create\s+(a\s+)?(new\s+)?(report|insight|dashboard)/i,
126
- /set\s+up\s+(a\s+)?(report|insight|analytics)/i,
127
- /build\s+(a\s+)?(report|dashboard)\s+(showing|for)/i,
128
- // Bulk operations
129
- /create\s+(\d{2,}|multiple|several|many)\s+(activities|tasks|records)/i,
130
- /bulk\s+(create|update|import)/i,
131
- /import\s+(\d+|these|the)\s+(activities|tasks|records|items)/i,
132
- // Complex queries
133
- /complex\s+(query|filter|search)/i,
134
- /advanced\s+(search|filter)/i,
135
- // Multi-step operations
136
- /(and|then|also)\s+(create|set up|add)\s+(a\s+)?(report|insight|workflow)/i,
137
- ],
138
- triggerKeywords: [
139
- "workflow",
140
- "pipeline",
141
- "insight",
142
- "report",
143
- "dashboard",
144
- "bulk",
145
- "import",
146
- "phases",
147
- "stages",
148
- ],
149
- systemPrompt: `<identity>
150
- You are the Hailer Expert - a specialized assistant for Hailer workspace operations.
151
- You were invited to this discussion by HAL to help with a specific task.
152
- </identity>
153
-
154
- <capabilities>
155
- You have access to these MCP tools:
156
-
157
- **Workflow Management:**
158
- - list_workflows, list_workflows_minimal - See available workflows
159
- - list_workflow_phases - See phases in a workflow
160
- - get_workflow_schema - See fields and structure
161
- - install_workflow(workflowTemplates: [{name, fields: {_1000: {label, type, key}}, phases: {_2000: {name, isInitial}}}]) - CREATE workflows from scratch (NOT marketplace)
162
- - update_workflow_field - Modify workflow fields
163
- - update_workflow_phase - Modify phases
164
-
165
- **Activity Operations:**
166
- - list_activities(workflowId, phaseId, filters?, fields?, search?, limit?) - Query activities
167
- - show_activity_by_id(activityId) - Get activity details
168
- - create_activity(workflowId, name, fields?) OR create_activity(workflowId, activities[{name, fields}]) - Create single/bulk
169
- - update_activity(activityId, name?, fields?, phaseId?) - Update SINGLE activity
170
- - update_activity(activities: [{_id, name?, fields?, phaseId?}]) - Update BULK (3+ activities)
171
- - count_activities(workflowId, phaseId?) - Count activities
172
-
173
- **CRITICAL for update_activity:**
174
- - SINGLE: use "activityId" parameter (NOT "_id")
175
- - BULK: use "activities" array, each object MUST have "_id" (the activity ID)
176
-
177
- **Insights (SQL Reports):**
178
- - list_insights - See existing insights
179
- - create_insight - Create SQL-like reports
180
- - preview_insight - Test SQL queries
181
- - get_insight_data - Execute and get results
182
-
183
- **Other:**
184
- - search_workspace_users - Find users
185
- - Discussion tools for chat
186
- </capabilities>
187
-
188
- <protocol>
189
- 1. Read HAL's handoff message carefully - it contains the task context
190
- 2. Plan the operations needed
191
- 3. Execute using MCP tools - NEVER fabricate data
192
- 4. Report back with:
193
- - What you did
194
- - Results with clickable links (#activityId format)
195
- - Any follow-up suggestions
196
- </protocol>
197
-
198
- <response_format>
199
- When completing a task:
200
- <respond discussion="DISCUSSION_ID">
201
- [Brief status emoji + summary]
202
-
203
- **What I did:**
204
- - Step 1: ...
205
- - Step 2: ...
206
-
207
- **Results:**
208
- [Data, links, or confirmation]
209
-
210
- **Next steps (optional):**
211
- [Suggestions for follow-up]
212
- </respond>
213
- </response_format>
214
-
215
- <rules>
216
- - Only respond when @mentioned - you were invited for a specific task
217
- - Always use tools - never make up data or IDs
218
- - Use #activityId format for activity links (auto-resolves to names)
219
- - Be concise and technical
220
- - If a tool call fails, DO NOT retry with the same parameters - explain the error to the user
221
- - If you get "activityId is required" error, you forgot to pass the activity ID - fix your parameters
222
- - Maximum 5 tool calls per task - if you need more, ask the user to break it down
223
- </rules>`,
224
- },
225
- };
226
- /**
227
- * Find a specialist that matches the given message content
228
- * Returns the specialist if patterns match, null otherwise
229
- */
230
- function findMatchingSpecialist(content) {
231
- for (const specialist of Object.values(exports.SPECIALISTS)) {
232
- // Check trigger patterns (strict match)
233
- for (const pattern of specialist.triggerPatterns) {
234
- if (pattern.test(content)) {
235
- return specialist;
236
- }
237
- }
238
- }
239
- return null;
240
- }
241
- /**
242
- * Check if content contains keywords suggesting a specialist might help
243
- * Less strict than pattern matching - used for secondary consideration
244
- */
245
- function hasSpecialistKeywords(content, specialist) {
246
- const contentLower = content.toLowerCase();
247
- const keywordCount = specialist.triggerKeywords.filter((kw) => contentLower.includes(kw.toLowerCase())).length;
248
- // Require at least 2 keywords for a soft match
249
- return keywordCount >= 2;
250
- }
251
- /**
252
- * Get specialist by key
253
- */
254
- function getSpecialist(key) {
255
- return exports.SPECIALISTS[key];
256
- }
257
- /**
258
- * Get all specialist keys
259
- */
260
- function getSpecialistKeys() {
261
- return Object.keys(exports.SPECIALISTS);
262
- }
263
- //# sourceMappingURL=definitions.js.map
@@ -1,3 +0,0 @@
1
- export { OrchestratorDaemon, OrchestratorDaemonConfig } from './daemon';
2
- export { SPECIALISTS, Specialist } from './definitions';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SPECIALISTS = exports.OrchestratorDaemon = void 0;
4
- var daemon_1 = require("./daemon");
5
- Object.defineProperty(exports, "OrchestratorDaemon", { enumerable: true, get: function () { return daemon_1.OrchestratorDaemon; } });
6
- var definitions_1 = require("./definitions");
7
- Object.defineProperty(exports, "SPECIALISTS", { enumerable: true, get: function () { return definitions_1.SPECIALISTS; } });
8
- //# sourceMappingURL=index.js.map
@@ -1,18 +0,0 @@
1
- /**
2
- * Hailer MCP Agents
3
- *
4
- * Each agent has its own folder with related code:
5
- * - hal/ - HAL orchestrator (coordinates specialists)
6
- * - giuseppe/ - Giuseppe bug fixer (autonomous code repair)
7
- * - hailer-expert/ - Hailer workspace specialist
8
- * - shared/ - Base classes and services used by all agents
9
- */
10
- export { ChatAgentDaemon, ChatAgentDaemonConfig } from './shared/base';
11
- export { SpecialistDaemon, SpecialistDaemonConfig } from './shared/specialist';
12
- export * from './shared/types';
13
- export { OrchestratorDaemon, OrchestratorDaemonConfig } from './hal';
14
- export { SPECIALISTS, Specialist } from './hal';
15
- export { GiuseppeModule } from './giuseppe';
16
- export { DaemonManager, DaemonManagerOptions, createDaemonManager, CreateDaemonManagerOptions, startDaemonMode } from './factory';
17
- export { MultiBotManager, BotClient } from './bot-manager';
18
- //# sourceMappingURL=index.d.ts.map
@@ -1,48 +0,0 @@
1
- "use strict";
2
- /**
3
- * Hailer MCP Agents
4
- *
5
- * Each agent has its own folder with related code:
6
- * - hal/ - HAL orchestrator (coordinates specialists)
7
- * - giuseppe/ - Giuseppe bug fixer (autonomous code repair)
8
- * - hailer-expert/ - Hailer workspace specialist
9
- * - shared/ - Base classes and services used by all agents
10
- */
11
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- var desc = Object.getOwnPropertyDescriptor(m, k);
14
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
- desc = { enumerable: true, get: function() { return m[k]; } };
16
- }
17
- Object.defineProperty(o, k2, desc);
18
- }) : (function(o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- }));
22
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.MultiBotManager = exports.startDaemonMode = exports.createDaemonManager = exports.DaemonManager = exports.GiuseppeModule = exports.SPECIALISTS = exports.OrchestratorDaemon = exports.SpecialistDaemon = exports.ChatAgentDaemon = void 0;
27
- // Shared
28
- var base_1 = require("./shared/base");
29
- Object.defineProperty(exports, "ChatAgentDaemon", { enumerable: true, get: function () { return base_1.ChatAgentDaemon; } });
30
- var specialist_1 = require("./shared/specialist");
31
- Object.defineProperty(exports, "SpecialistDaemon", { enumerable: true, get: function () { return specialist_1.SpecialistDaemon; } });
32
- __exportStar(require("./shared/types"), exports);
33
- // HAL (Orchestrator)
34
- var hal_1 = require("./hal");
35
- Object.defineProperty(exports, "OrchestratorDaemon", { enumerable: true, get: function () { return hal_1.OrchestratorDaemon; } });
36
- var hal_2 = require("./hal");
37
- Object.defineProperty(exports, "SPECIALISTS", { enumerable: true, get: function () { return hal_2.SPECIALISTS; } });
38
- // Giuseppe (Bug Fixer)
39
- var giuseppe_1 = require("./giuseppe");
40
- Object.defineProperty(exports, "GiuseppeModule", { enumerable: true, get: function () { return giuseppe_1.GiuseppeModule; } });
41
- // Factory
42
- var factory_1 = require("./factory");
43
- Object.defineProperty(exports, "DaemonManager", { enumerable: true, get: function () { return factory_1.DaemonManager; } });
44
- Object.defineProperty(exports, "createDaemonManager", { enumerable: true, get: function () { return factory_1.createDaemonManager; } });
45
- Object.defineProperty(exports, "startDaemonMode", { enumerable: true, get: function () { return factory_1.startDaemonMode; } });
46
- var bot_manager_1 = require("./bot-manager");
47
- Object.defineProperty(exports, "MultiBotManager", { enumerable: true, get: function () { return bot_manager_1.MultiBotManager; } });
48
- //# sourceMappingURL=index.js.map
@@ -1,216 +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, ToolIndexEntry } from "./tool-schema-loader";
18
- import { ToolInput, McpToolResult } from "./types";
19
- import { AgentRegistryService } from "./services/agent-registry";
20
- import { ConversationManager, ConversationMessage } from "./services/conversation-manager";
21
- import { McpClientService } from "./services/mcp-client";
22
- import { MessageFormatterService } from "./services/message-formatter";
23
- import { MessageClassifier } from "./services/message-classifier";
24
- import { SessionLoggerService } from "./services/session-logger";
25
- import { ToolExecutor } from "./services/tool-executor";
26
- import { WorkspaceSchemaCacheService } from "./services/workspace-schema-cache";
27
- import { SessionMetrics, ActivitySession, MessagePriority, IncomingMessage, ConversationState } from "./types";
28
- export type { IncomingMessage, MessagePriority, SessionMetrics, ActivitySession };
29
- export interface ChatAgentDaemonConfig {
30
- botClient: BotClient;
31
- mcpServerUrl: string;
32
- anthropicApiKey: string;
33
- model?: string;
34
- maxContextMessages?: number;
35
- }
36
- export declare class ChatAgentDaemon {
37
- protected logger: Logger;
38
- protected client: Anthropic;
39
- protected botClient: BotClient;
40
- protected config: ChatAgentDaemonConfig;
41
- protected toolSchemaLoader: ToolSchemaLoader;
42
- protected isProcessing: boolean;
43
- protected messageQueue: IncomingMessage[];
44
- protected processedMessageIds: Set<string>;
45
- private typingInterval;
46
- private typingDiscussionId;
47
- private static TYPING_REFRESH_MS;
48
- protected toolIndex: ToolIndexEntry[];
49
- protected minimalTools: Anthropic.Tool[];
50
- /** Message classifier - handles message extraction and priority classification */
51
- protected messageClassifier: MessageClassifier | null;
52
- /** Conversation manager - handles per-discussion context and LRU cache */
53
- protected conversationManager: ConversationManager | null;
54
- /** MCP client service - handles tool schema loading and execution */
55
- protected mcpClient: McpClientService | null;
56
- /** Tool executor - handles tool execution and write tracking */
57
- protected toolExecutor: ToolExecutor | null;
58
- /** Agent registration service - handles Agent Directory, Position, Team, etc. */
59
- protected registryService: AgentRegistryService | null;
60
- /** Message formatting service - handles tag resolution and formatting */
61
- protected messageFormatter: MessageFormatterService | null;
62
- /** Session logging service - handles activity session tracking */
63
- protected sessionLogger: SessionLoggerService | null;
64
- /** Workspace schema cache - dynamic workflow/field ID lookup */
65
- protected schemaCache: WorkspaceSchemaCacheService | null;
66
- /** Current discussion context for tracking */
67
- protected currentDiscussionId: string | null;
68
- protected currentLinkedActivityId: string | null;
69
- /** Unsubscribe function for messenger.new signals */
70
- private messengerUnsubscribe;
71
- /** Original API key for cleanup - stored at init because botClient.config may change */
72
- private originalApiKey;
73
- constructor(config: ChatAgentDaemonConfig);
74
- /**
75
- * Initialize the daemon - load tools and subscribe to signals
76
- */
77
- initialize(): Promise<void>;
78
- /**
79
- * Load existing discussions the bot is already a member of
80
- * This ensures the bot can respond to messages in discussions it was added to before startup
81
- */
82
- private loadExistingDiscussions;
83
- /**
84
- * Extract and classify incoming message from signal
85
- * Can be overridden in subclasses to customize filtering
86
- */
87
- protected extractIncomingMessage(signal: HailerSignal): Promise<IncomingMessage | null>;
88
- /**
89
- * Handle incoming signal from Hailer
90
- */
91
- private handleSignal;
92
- /**
93
- * Process queued messages through the LLM
94
- * Note: Uses flag-first pattern to prevent race conditions
95
- */
96
- private processQueue;
97
- /**
98
- * Process a single message through the persistent LLM conversation
99
- */
100
- private processMessage;
101
- /**
102
- * Format incoming message for LLM consumption
103
- */
104
- private formatIncomingMessage;
105
- /**
106
- * Load and inject memory for an activity into conversation context
107
- * Called when entering a new discussion that's linked to an activity
108
- */
109
- private injectMemoryForActivity;
110
- /**
111
- * Execute tool calls and continue the conversation
112
- * Simple passthrough - just execute tools and return results to LLM
113
- */
114
- protected executeToolsAndContinue(toolUseBlocks: Anthropic.ToolUseBlock[], originalMessage: IncomingMessage): Promise<void>;
115
- /**
116
- * Handle LLM response
117
- * Override in subclasses to customize response handling
118
- */
119
- protected handleLlmResponse(response: Anthropic.Message, originalMessage: IncomingMessage): Promise<void>;
120
- /**
121
- * Start typing indicator with auto-refresh interval
122
- * Keeps refreshing every 3 seconds until stopTypingIndicator is called
123
- */
124
- protected startTypingIndicator(discussionId: string): void;
125
- /**
126
- * Stop typing indicator and clear refresh interval
127
- */
128
- protected stopTypingIndicator(): void;
129
- /**
130
- * Send typing signal to Hailer API
131
- * API: messenger.set_discussion_typing_state(discussionId, typingState)
132
- */
133
- private sendTypingSignal;
134
- /**
135
- * Post a response to a discussion
136
- * Automatically converts @mentions and #activity tags to Hailer tags
137
- * Includes links metadata required for tags to work
138
- */
139
- protected postResponse(discussionId: string, content: string): Promise<void>;
140
- /**
141
- * Get the system prompt for the daemon
142
- * MUST be overridden in subclasses
143
- */
144
- protected getSystemPrompt(): string;
145
- /**
146
- * Get tools for LLM calls
147
- * Override in subclass to add custom tools (like trigger_giuseppe_retry)
148
- */
149
- protected getTools(): Anthropic.Tool[];
150
- /**
151
- * Get tool whitelist for this agent
152
- * Override in subclass to limit which tools are available
153
- * Return null for all tools, or array of tool names
154
- */
155
- protected getToolWhitelist(): string[] | null;
156
- /**
157
- * Preprocess tool input before execution
158
- * Override in subclass to inject context (e.g., sourceActivityId)
159
- * @param toolName - Name of the tool being called
160
- * @param input - Original tool input from LLM
161
- * @returns Processed input (may be modified)
162
- */
163
- protected preprocessToolInput(toolName: string, input: ToolInput): ToolInput;
164
- /**
165
- * Call MCP tool (delegates to McpClientService)
166
- * Protected for subclass access
167
- */
168
- protected callMcpTool(name: string, args: ToolInput): Promise<McpToolResult>;
169
- /**
170
- * Stop the daemon
171
- * Flushes all pending activity sessions before stopping
172
- */
173
- stop(): Promise<void>;
174
- /**
175
- * Get current conversation state (for debugging)
176
- */
177
- getConversationState(): ConversationState;
178
- /**
179
- * Get full conversation for a specific discussion (for debugging)
180
- */
181
- getFullConversation(discussionId?: string): ConversationMessage[];
182
- /**
183
- * Get agent's display name (override in subclass for custom names)
184
- * Default implementation uses the actual Hailer user name from BotClient
185
- */
186
- protected getAgentName(): {
187
- firstName: string;
188
- lastName: string;
189
- };
190
- /**
191
- * Get agent's description/system prompt (override in subclass)
192
- */
193
- protected getAgentDescription(): string;
194
- /**
195
- * Get default team ID from workspace cache
196
- * Returns the first available team, or undefined if no teams exist
197
- *
198
- * Teams structure in init is: { teams: { workspaceId: { teamId: teamData, ... } } }
199
- */
200
- protected getDefaultTeamId(): string | undefined;
201
- /**
202
- * Get agent's Position details (override in subclass for custom positions)
203
- */
204
- protected getPositionDetails(): {
205
- name: string;
206
- purpose: string;
207
- personaTone: string;
208
- coreCapabilities: string;
209
- boundaries: string;
210
- };
211
- /**
212
- * Get agent directory ID
213
- */
214
- getAgentDirectoryId(): string | null;
215
- }
216
- //# sourceMappingURL=base.d.ts.map