@hailer/mcp 0.1.8 → 0.1.9

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 (135) hide show
  1. package/.claude/agents/agent-dmitri-activity-crud.md +3 -1
  2. package/.claude/agents/agent-giuseppe-app-builder.md +11 -12
  3. package/.claude/agents/agent-kenji-data-reader.md +5 -3
  4. package/.claude/skills/hailer-app-builder/SKILL.md +506 -0
  5. package/.claude/skills/publish-hailer-app/SKILL.md +169 -0
  6. package/.claude/skills/tool-parameter-usage/SKILL.md +112 -0
  7. package/CLAUDE.md +6 -2
  8. package/REFACTOR_STATUS.md +127 -0
  9. package/dist/cli.js +0 -0
  10. package/dist/client/agents/base.d.ts +202 -0
  11. package/dist/client/agents/base.js +737 -0
  12. package/dist/client/agents/definitions.d.ts +53 -0
  13. package/dist/client/agents/definitions.js +178 -0
  14. package/dist/client/agents/orchestrator.d.ts +119 -0
  15. package/dist/client/agents/orchestrator.js +760 -0
  16. package/dist/client/agents/specialist.d.ts +86 -0
  17. package/dist/client/agents/specialist.js +340 -0
  18. package/dist/client/bot-manager.d.ts +44 -0
  19. package/dist/client/bot-manager.js +173 -0
  20. package/dist/client/chat-agent-daemon.d.ts +464 -0
  21. package/dist/client/chat-agent-daemon.js +1774 -0
  22. package/dist/client/daemon-factory.d.ts +106 -0
  23. package/dist/client/daemon-factory.js +301 -0
  24. package/dist/client/factory.d.ts +107 -0
  25. package/dist/client/factory.js +304 -0
  26. package/dist/client/index.d.ts +17 -0
  27. package/dist/client/index.js +38 -0
  28. package/dist/client/multi-bot-manager.d.ts +18 -0
  29. package/dist/client/multi-bot-manager.js +88 -1
  30. package/dist/client/orchestrator-daemon.d.ts +87 -0
  31. package/dist/client/orchestrator-daemon.js +444 -0
  32. package/dist/client/services/agent-registry.d.ts +108 -0
  33. package/dist/client/services/agent-registry.js +630 -0
  34. package/dist/client/services/conversation-manager.d.ts +50 -0
  35. package/dist/client/services/conversation-manager.js +136 -0
  36. package/dist/client/services/mcp-client.d.ts +48 -0
  37. package/dist/client/services/mcp-client.js +105 -0
  38. package/dist/client/services/message-classifier.d.ts +37 -0
  39. package/dist/client/services/message-classifier.js +187 -0
  40. package/dist/client/services/message-formatter.d.ts +84 -0
  41. package/dist/client/services/message-formatter.js +353 -0
  42. package/dist/client/services/session-logger.d.ts +106 -0
  43. package/dist/client/services/session-logger.js +446 -0
  44. package/dist/client/services/tool-executor.d.ts +41 -0
  45. package/dist/client/services/tool-executor.js +169 -0
  46. package/dist/client/services/workspace-schema-cache.d.ts +149 -0
  47. package/dist/client/services/workspace-schema-cache.js +732 -0
  48. package/dist/client/specialist-daemon.d.ts +77 -0
  49. package/dist/client/specialist-daemon.js +197 -0
  50. package/dist/client/specialists.d.ts +53 -0
  51. package/dist/client/specialists.js +178 -0
  52. package/dist/client/tool-schema-loader.d.ts +4 -3
  53. package/dist/client/tool-schema-loader.js +54 -8
  54. package/dist/client/types.d.ts +283 -55
  55. package/dist/client/types.js +113 -2
  56. package/dist/config.d.ts +1 -1
  57. package/dist/config.js +1 -1
  58. package/dist/core.d.ts +10 -2
  59. package/dist/core.js +43 -27
  60. package/dist/lib/logger.js +15 -3
  61. package/dist/mcp/UserContextCache.js +2 -2
  62. package/dist/mcp/hailer-clients.js +5 -5
  63. package/dist/mcp/signal-handler.js +27 -5
  64. package/dist/mcp/tools/activity.js +137 -65
  65. package/dist/mcp/tools/app-core.js +4 -140
  66. package/dist/mcp/tools/app-marketplace.js +15 -260
  67. package/dist/mcp/tools/app-member.js +2 -73
  68. package/dist/mcp/tools/app-scaffold.js +146 -87
  69. package/dist/mcp/tools/discussion.js +348 -73
  70. package/dist/mcp/tools/insight.js +74 -190
  71. package/dist/mcp/tools/workflow.js +20 -94
  72. package/dist/mcp/utils/hailer-api-client.d.ts +4 -2
  73. package/dist/mcp/utils/hailer-api-client.js +24 -10
  74. package/dist/mcp-server.d.ts +4 -0
  75. package/dist/mcp-server.js +24 -4
  76. package/dist/routes/agents.d.ts +44 -0
  77. package/dist/routes/agents.js +311 -0
  78. package/dist/services/agent-credential-store.d.ts +73 -0
  79. package/dist/services/agent-credential-store.js +212 -0
  80. package/lineup-manager/dist/assets/index-8ce6041d.css +1 -0
  81. package/lineup-manager/dist/assets/index-e168f265.js +600 -0
  82. package/lineup-manager/dist/index.html +15 -0
  83. package/lineup-manager/dist/manifest.json +17 -0
  84. package/lineup-manager/dist/vite.svg +1 -0
  85. package/package.json +1 -1
  86. package/dist/client/adaptive-documentation-bot.d.ts +0 -106
  87. package/dist/client/adaptive-documentation-bot.js +0 -464
  88. package/dist/client/adaptive-documentation-types.d.ts +0 -66
  89. package/dist/client/adaptive-documentation-types.js +0 -9
  90. package/dist/client/agent-activity-bot.d.ts +0 -51
  91. package/dist/client/agent-activity-bot.js +0 -166
  92. package/dist/client/agent-tracker.d.ts +0 -499
  93. package/dist/client/agent-tracker.js +0 -659
  94. package/dist/client/description-updater.d.ts +0 -56
  95. package/dist/client/description-updater.js +0 -259
  96. package/dist/client/log-parser.d.ts +0 -72
  97. package/dist/client/log-parser.js +0 -387
  98. package/dist/client/mcp-assistant.d.ts +0 -21
  99. package/dist/client/mcp-assistant.js +0 -58
  100. package/dist/client/mcp-client.d.ts +0 -50
  101. package/dist/client/mcp-client.js +0 -538
  102. package/dist/client/message-processor.d.ts +0 -35
  103. package/dist/client/message-processor.js +0 -357
  104. package/dist/client/providers/anthropic-provider.d.ts +0 -19
  105. package/dist/client/providers/anthropic-provider.js +0 -645
  106. package/dist/client/providers/assistant-provider.d.ts +0 -17
  107. package/dist/client/providers/assistant-provider.js +0 -51
  108. package/dist/client/providers/llm-provider.d.ts +0 -47
  109. package/dist/client/providers/llm-provider.js +0 -367
  110. package/dist/client/providers/openai-provider.d.ts +0 -23
  111. package/dist/client/providers/openai-provider.js +0 -630
  112. package/dist/client/simple-llm-caller.d.ts +0 -19
  113. package/dist/client/simple-llm-caller.js +0 -100
  114. package/dist/client/skill-generator.d.ts +0 -81
  115. package/dist/client/skill-generator.js +0 -386
  116. package/dist/client/test-adaptive-bot.d.ts +0 -9
  117. package/dist/client/test-adaptive-bot.js +0 -82
  118. package/dist/client/token-pricing.d.ts +0 -38
  119. package/dist/client/token-pricing.js +0 -127
  120. package/dist/client/token-tracker.d.ts +0 -232
  121. package/dist/client/token-tracker.js +0 -457
  122. package/dist/client/token-usage-bot.d.ts +0 -53
  123. package/dist/client/token-usage-bot.js +0 -153
  124. package/dist/client/tool-executor.d.ts +0 -69
  125. package/dist/client/tool-executor.js +0 -159
  126. package/dist/lib/materialize.d.ts +0 -3
  127. package/dist/lib/materialize.js +0 -101
  128. package/dist/lib/normalizedName.d.ts +0 -7
  129. package/dist/lib/normalizedName.js +0 -48
  130. package/dist/lib/terminal-prompt.d.ts +0 -9
  131. package/dist/lib/terminal-prompt.js +0 -108
  132. package/dist/mcp/tools/skill.d.ts +0 -10
  133. package/dist/mcp/tools/skill.js +0 -279
  134. package/dist/mcp/tools/workflow-template.d.ts +0 -19
  135. package/dist/mcp/tools/workflow-template.js +0 -822
@@ -0,0 +1,53 @@
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
+ /** Display name (used in @mentions) */
14
+ name: string;
15
+ /** Hailer user ID of this bot (set at runtime from config) */
16
+ botUserId?: string;
17
+ /** Email of this bot (for matching with config) */
18
+ botEmail: string;
19
+ /** What this specialist is good at */
20
+ expertise: string[];
21
+ /** Regex patterns that trigger consideration of this specialist */
22
+ triggerPatterns: RegExp[];
23
+ /** Keywords that suggest this specialist (less strict than patterns) */
24
+ triggerKeywords: string[];
25
+ /** System prompt for this specialist when active */
26
+ systemPrompt: string;
27
+ /** Model to use (defaults to parent config) */
28
+ model?: string;
29
+ }
30
+ /**
31
+ * Registry of available specialists
32
+ * Key is the specialist identifier used internally
33
+ */
34
+ export declare const SPECIALISTS: Record<string, Specialist>;
35
+ /**
36
+ * Find a specialist that matches the given message content
37
+ * Returns the specialist if patterns match, null otherwise
38
+ */
39
+ export declare function findMatchingSpecialist(content: string): Specialist | null;
40
+ /**
41
+ * Check if content contains keywords suggesting a specialist might help
42
+ * Less strict than pattern matching - used for secondary consideration
43
+ */
44
+ export declare function hasSpecialistKeywords(content: string, specialist: Specialist): boolean;
45
+ /**
46
+ * Get specialist by key
47
+ */
48
+ export declare function getSpecialist(key: string): Specialist | undefined;
49
+ /**
50
+ * Get all specialist keys
51
+ */
52
+ export declare function getSpecialistKeys(): string[];
53
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1,178 @@
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
+ hailerExpert: {
25
+ name: "Hailer Expert",
26
+ botEmail: "", // Set from config at runtime
27
+ expertise: [
28
+ "workflow creation and management",
29
+ "activity bulk operations",
30
+ "insights and SQL reports",
31
+ "complex data queries",
32
+ "workflow configuration",
33
+ ],
34
+ triggerPatterns: [
35
+ // Workflow creation
36
+ /create\s+(a\s+)?(new\s+)?(workflow|pipeline|process|tracker)/i,
37
+ /set\s+up\s+(a\s+)?(new\s+)?(workflow|pipeline|process)/i,
38
+ /build\s+(me\s+)?(a\s+)?(workflow|pipeline|crm|tracker)/i,
39
+ // Insight/report creation
40
+ /create\s+(a\s+)?(new\s+)?(report|insight|dashboard)/i,
41
+ /set\s+up\s+(a\s+)?(report|insight|analytics)/i,
42
+ /build\s+(a\s+)?(report|dashboard)\s+(showing|for)/i,
43
+ // Bulk operations
44
+ /create\s+(\d{2,}|multiple|several|many)\s+(activities|tasks|records)/i,
45
+ /bulk\s+(create|update|import)/i,
46
+ /import\s+(\d+|these|the)\s+(activities|tasks|records|items)/i,
47
+ // Complex queries
48
+ /complex\s+(query|filter|search)/i,
49
+ /advanced\s+(search|filter)/i,
50
+ // Multi-step operations
51
+ /(and|then|also)\s+(create|set up|add)\s+(a\s+)?(report|insight|workflow)/i,
52
+ ],
53
+ triggerKeywords: [
54
+ "workflow",
55
+ "pipeline",
56
+ "insight",
57
+ "report",
58
+ "dashboard",
59
+ "bulk",
60
+ "import",
61
+ "phases",
62
+ "stages",
63
+ ],
64
+ systemPrompt: `<identity>
65
+ You are the Hailer Expert - a specialized assistant for Hailer workspace operations.
66
+ You were invited to this discussion by HAL to help with a specific task.
67
+ </identity>
68
+
69
+ <capabilities>
70
+ You have access to these MCP tools:
71
+
72
+ **Workflow Management:**
73
+ - list_workflows, list_workflows_minimal - See available workflows
74
+ - list_workflow_phases - See phases in a workflow
75
+ - get_workflow_schema - See fields and structure
76
+ - install_workflow - Create new workflows
77
+ - update_workflow_field - Modify workflow fields
78
+ - update_workflow_phase - Modify phases
79
+
80
+ **Activity Operations:**
81
+ - list_activities(workflowId, phaseId, filters?, fields?, search?, limit?) - Query activities
82
+ - show_activity_by_id(activityId) - Get activity details
83
+ - create_activity(workflowId, name, fields?) OR create_activity(workflowId, activities[{name, fields}]) - Create single/bulk
84
+ - update_activity(activityId, name?, fields?, phaseId?) - Update SINGLE activity
85
+ - update_activity(activities: [{_id, name?, fields?, phaseId?}]) - Update BULK (3+ activities)
86
+ - count_activities(workflowId, phaseId?) - Count activities
87
+
88
+ **CRITICAL for update_activity:**
89
+ - SINGLE: use "activityId" parameter (NOT "_id")
90
+ - BULK: use "activities" array, each object MUST have "_id" (the activity ID)
91
+
92
+ **Insights (SQL Reports):**
93
+ - list_insights - See existing insights
94
+ - create_insight - Create SQL-like reports
95
+ - preview_insight - Test SQL queries
96
+ - get_insight_data - Execute and get results
97
+
98
+ **Other:**
99
+ - search_workspace_users - Find users
100
+ - Discussion tools for chat
101
+ </capabilities>
102
+
103
+ <protocol>
104
+ 1. Read HAL's handoff message carefully - it contains the task context
105
+ 2. Plan the operations needed
106
+ 3. Execute using MCP tools - NEVER fabricate data
107
+ 4. Report back with:
108
+ - What you did
109
+ - Results with clickable links (#activityId format)
110
+ - Any follow-up suggestions
111
+ </protocol>
112
+
113
+ <response_format>
114
+ When completing a task:
115
+ <respond discussion="DISCUSSION_ID">
116
+ [Brief status emoji + summary]
117
+
118
+ **What I did:**
119
+ - Step 1: ...
120
+ - Step 2: ...
121
+
122
+ **Results:**
123
+ [Data, links, or confirmation]
124
+
125
+ **Next steps (optional):**
126
+ [Suggestions for follow-up]
127
+ </respond>
128
+ </response_format>
129
+
130
+ <rules>
131
+ - Only respond when @mentioned - you were invited for a specific task
132
+ - Always use tools - never make up data or IDs
133
+ - Use #activityId format for activity links (auto-resolves to names)
134
+ - Be concise and technical
135
+ - If a tool call fails, DO NOT retry with the same parameters - explain the error to the user
136
+ - If you get "activityId is required" error, you forgot to pass the activity ID - fix your parameters
137
+ - Maximum 5 tool calls per task - if you need more, ask the user to break it down
138
+ </rules>`,
139
+ },
140
+ };
141
+ /**
142
+ * Find a specialist that matches the given message content
143
+ * Returns the specialist if patterns match, null otherwise
144
+ */
145
+ function findMatchingSpecialist(content) {
146
+ for (const specialist of Object.values(exports.SPECIALISTS)) {
147
+ // Check trigger patterns (strict match)
148
+ for (const pattern of specialist.triggerPatterns) {
149
+ if (pattern.test(content)) {
150
+ return specialist;
151
+ }
152
+ }
153
+ }
154
+ return null;
155
+ }
156
+ /**
157
+ * Check if content contains keywords suggesting a specialist might help
158
+ * Less strict than pattern matching - used for secondary consideration
159
+ */
160
+ function hasSpecialistKeywords(content, specialist) {
161
+ const contentLower = content.toLowerCase();
162
+ const keywordCount = specialist.triggerKeywords.filter((kw) => contentLower.includes(kw.toLowerCase())).length;
163
+ // Require at least 2 keywords for a soft match
164
+ return keywordCount >= 2;
165
+ }
166
+ /**
167
+ * Get specialist by key
168
+ */
169
+ function getSpecialist(key) {
170
+ return exports.SPECIALISTS[key];
171
+ }
172
+ /**
173
+ * Get all specialist keys
174
+ */
175
+ function getSpecialistKeys() {
176
+ return Object.keys(exports.SPECIALISTS);
177
+ }
178
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Orchestrator Daemon (HAL)
3
+ *
4
+ * The main conversational bot that handles general chat and coordinates
5
+ * with specialist bots when tasks are too complex.
6
+ *
7
+ * HAL can:
8
+ * - Handle general conversation and simple queries
9
+ * - Detect when a task needs specialist help
10
+ * - Invite specialist bots to the discussion
11
+ * - Hand off context to specialists
12
+ * - Summarize specialist responses for users
13
+ */
14
+ import { ChatAgentDaemon, ChatAgentDaemonConfig, IncomingMessage } from "./base";
15
+ import { HailerSignal } from "../../mcp/signal-handler";
16
+ import { ToolInput } from "../types";
17
+ import Anthropic from "@anthropic-ai/sdk";
18
+ export interface OrchestratorDaemonConfig extends ChatAgentDaemonConfig {
19
+ /** Map of specialist key to their Hailer user ID */
20
+ specialistUserIds?: Map<string, string>;
21
+ }
22
+ export declare class OrchestratorDaemon extends ChatAgentDaemon {
23
+ private orchestratorLogger;
24
+ private specialists;
25
+ private activeSpecialistsInDiscussion;
26
+ private specialistUserIds;
27
+ private toolsUsedInCurrentMessage;
28
+ private lastToolsUsed;
29
+ private lastToolsFailed;
30
+ private static SILENT_SUCCESS_TOOLS;
31
+ private lastKnownActivityId;
32
+ private lastKnownActivityName;
33
+ private lastKnownActivityTime;
34
+ private static CONTEXT_MEMORY_TIMEOUT;
35
+ constructor(config: OrchestratorDaemonConfig);
36
+ /**
37
+ * Override agent name for Agent Directory
38
+ * Uses the actual Hailer user name from BotClient (set in workspace)
39
+ */
40
+ protected getAgentName(): {
41
+ firstName: string;
42
+ lastName: string;
43
+ };
44
+ /**
45
+ * Override agent description for Agent Directory
46
+ */
47
+ protected getAgentDescription(): string;
48
+ /**
49
+ * Override Position details for Orchestrator
50
+ */
51
+ protected getPositionDetails(): {
52
+ name: string;
53
+ purpose: string;
54
+ personaTone: string;
55
+ coreCapabilities: string;
56
+ boundaries: string;
57
+ };
58
+ /**
59
+ * Orchestrator only needs basic tools - complex ops go to specialists
60
+ */
61
+ protected getToolWhitelist(): string[];
62
+ /**
63
+ * Preprocess tool input - inject context for certain tools
64
+ * Uses cross-discussion memory to maintain context awareness
65
+ */
66
+ protected preprocessToolInput(toolName: string, input: ToolInput): ToolInput;
67
+ /**
68
+ * Override to detect tool failures for silent success feature
69
+ */
70
+ protected executeToolsAndContinue(toolUseBlocks: Anthropic.ToolUseBlock[], originalMessage: IncomingMessage): Promise<void>;
71
+ /**
72
+ * Update cross-discussion memory when processing messages
73
+ * Call this when entering an activity discussion to remember context
74
+ */
75
+ private updateContextMemory;
76
+ /**
77
+ * Override to update cross-discussion memory when entering activity discussions
78
+ */
79
+ protected extractIncomingMessage(signal: HailerSignal): Promise<IncomingMessage | null>;
80
+ /**
81
+ * Register a specialist's Hailer user ID
82
+ * Called during initialization when we know the specialist bot's user ID
83
+ */
84
+ registerSpecialistUserId(specialistKey: string, userId: string): void;
85
+ /**
86
+ * Check if a specialist is already active in a discussion
87
+ */
88
+ private isSpecialistActiveInDiscussion;
89
+ /**
90
+ * Mark a specialist as active in a discussion
91
+ */
92
+ private markSpecialistActive;
93
+ /**
94
+ * Invite a specialist to a discussion
95
+ */
96
+ private inviteSpecialist;
97
+ /**
98
+ * Override system prompt to include orchestrator capabilities
99
+ */
100
+ protected getSystemPrompt(): string;
101
+ /**
102
+ * Override response handling to detect specialist invitations
103
+ */
104
+ protected handleLlmResponse(response: Anthropic.Message, originalMessage: IncomingMessage): Promise<void>;
105
+ /**
106
+ * Get orchestrator status including specialist info
107
+ */
108
+ getOrchestratorStatus(): {
109
+ conversationState: ReturnType<ChatAgentDaemon["getConversationState"]>;
110
+ specialists: Array<{
111
+ key: string;
112
+ name: string;
113
+ available: boolean;
114
+ userId?: string;
115
+ }>;
116
+ activeInDiscussions: Record<string, string[]>;
117
+ };
118
+ }
119
+ //# sourceMappingURL=orchestrator.d.ts.map