@hailer/mcp 1.0.22 → 1.0.24
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.
- package/.env.example +7 -26
- package/dist/app.js +10 -40
- package/dist/bot/chat-bot.js +1 -0
- package/dist/cli.d.ts +1 -9
- package/dist/cli.js +2 -71
- package/dist/config.d.ts +3 -96
- package/dist/config.js +6 -146
- package/dist/core.d.ts +0 -46
- package/dist/core.js +2 -351
- package/dist/lib/logger.js +2 -8
- package/dist/mcp/UserContextCache.js +10 -13
- package/dist/mcp/hailer-clients.js +11 -12
- package/dist/mcp/signal-handler.js +2 -18
- package/dist/mcp/tool-registry.d.ts +0 -4
- package/dist/mcp/tool-registry.js +1 -78
- package/dist/mcp/tools/activity.js +54 -6
- package/dist/mcp/tools/discussion.js +0 -25
- package/dist/mcp/tools/user.d.ts +4 -2
- package/dist/mcp/tools/user.js +48 -4
- package/dist/mcp/tools/workflow.js +40 -109
- package/dist/mcp/webhook-handler.d.ts +3 -64
- package/dist/mcp/webhook-handler.js +7 -214
- package/dist/mcp-server.d.ts +0 -4
- package/dist/mcp-server.js +18 -229
- package/package.json +9 -10
- package/.claude/skills/client-bot-architecture/skill.md +0 -340
- package/dist/commands/setup.d.ts +0 -11
- package/dist/commands/setup.js +0 -319
- package/scripts/test-hal-tools.ts +0 -154
package/.env.example
CHANGED
|
@@ -62,32 +62,13 @@
|
|
|
62
62
|
# Default: false (nuclear tools completely hidden)
|
|
63
63
|
# ENABLE_NUCLEAR_TOOLS=true
|
|
64
64
|
|
|
65
|
-
|
|
66
65
|
# ==============================================
|
|
67
|
-
#
|
|
66
|
+
# METRICS ADMIN API
|
|
68
67
|
# ==============================================
|
|
69
68
|
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
|
|
77
|
-
# MCP Server URL (for client to call our own tools)
|
|
78
|
-
MCP_SERVER_URL=http://localhost:3030/api/mcp
|
|
79
|
-
#MCP_CLIENT_API_KEY=your-api-key
|
|
80
|
-
|
|
81
|
-
# MCP Agent User IDs (required for agent tagging - get these from Hailer)
|
|
82
|
-
MCP_CLIENT_AGENT_IDS='[]'
|
|
83
|
-
|
|
84
|
-
# Bot Features (optional, defaults to true)
|
|
85
|
-
TOKEN_USAGE_BOT_ENABLED=false
|
|
86
|
-
AGENT_ACTIVITY_BOT_ENABLED=false
|
|
87
|
-
|
|
88
|
-
# Adaptive Documentation Bot (automatically improves tool descriptions based on errors)
|
|
89
|
-
ADAPTIVE_DOCUMENTATION_BOT_ENABLED=false
|
|
90
|
-
ADAPTIVE_AUTO_UPDATE=false
|
|
91
|
-
ADAPTIVE_UPDATE_INTERVAL=60000
|
|
92
|
-
ADAPTIVE_MIN_ERROR_COUNT=3
|
|
93
|
-
ADAPTIVE_SKILL_GENERATION=false
|
|
69
|
+
# Metrics Admin API (for workspace/user search - requires whitelisted Hailer user)
|
|
70
|
+
# These credentials are used for privileged metrics operations like searching all workspaces
|
|
71
|
+
# Only whitelisted users can make these API calls
|
|
72
|
+
# METRICS_ADMIN_EMAIL=admin@example.com
|
|
73
|
+
# METRICS_ADMIN_PASSWORD=your-password
|
|
74
|
+
# METRICS_ADMIN_API_URL=https://api.hailer.com
|
package/dist/app.js
CHANGED
|
@@ -25,8 +25,7 @@ const user_1 = require("./mcp/tools/user");
|
|
|
25
25
|
const workflow_1 = require("./mcp/tools/workflow");
|
|
26
26
|
const insight_1 = require("./mcp/tools/insight");
|
|
27
27
|
const app_1 = require("./mcp/tools/app");
|
|
28
|
-
|
|
29
|
-
// This allows the npm package to work without these modules
|
|
28
|
+
const metrics_1 = require("./mcp/tools/metrics");
|
|
30
29
|
// For stdio mode, create standalone ToolRegistry
|
|
31
30
|
// For HTTP mode, use Core which has its own ToolRegistry
|
|
32
31
|
const toolRegistry = isStdioMode ? new tool_registry_1.ToolRegistry({ enableNuclearTools: config_1.environment.ENABLE_NUCLEAR_TOOLS }) : null;
|
|
@@ -48,6 +47,9 @@ addTool(activity_1.listActivitiesTool);
|
|
|
48
47
|
addTool(activity_1.showActivityByIdTool);
|
|
49
48
|
addTool(activity_1.createActivityTool);
|
|
50
49
|
addTool(activity_1.updateActivityTool);
|
|
50
|
+
// core.addTool(searchActivitiesTool);
|
|
51
|
+
// core.addTool(filterActivitiesTool);
|
|
52
|
+
// core.addTool(activityToolsGuideTool);
|
|
51
53
|
addTool(discussion_1.listMyDiscussionsTool);
|
|
52
54
|
addTool(discussion_1.fetchDiscussionMessagesTool);
|
|
53
55
|
addTool(discussion_1.fetchPreviousDiscussionMessagesTool);
|
|
@@ -56,6 +58,7 @@ addTool(discussion_1.leaveDiscussionTool);
|
|
|
56
58
|
addTool(discussion_1.addDiscussionMessageTool);
|
|
57
59
|
addTool(discussion_1.inviteDiscussionMembersTool);
|
|
58
60
|
addTool(discussion_1.getActivityFromDiscussionTool);
|
|
61
|
+
addTool(user_1.listMyWorkspacesTool);
|
|
59
62
|
addTool(user_1.searchWorkspaceUsersTool);
|
|
60
63
|
addTool(user_1.getWorkspaceBalanceTool);
|
|
61
64
|
addTool(workflow_1.getWorkflowSchemaTool);
|
|
@@ -99,44 +102,11 @@ addTool(app_1.getProductManifestTool);
|
|
|
99
102
|
// Marketplace app tools
|
|
100
103
|
addTool(app_1.publishAppTool);
|
|
101
104
|
addTool(app_1.installMarketplaceAppTool);
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
addTool(listBotsConfigTool);
|
|
108
|
-
addTool(enableBotTool);
|
|
109
|
-
addTool(disableBotTool);
|
|
110
|
-
addTool(checkSpecialistStatusTool);
|
|
111
|
-
// Dynamic import bug-fixer tools
|
|
112
|
-
const {
|
|
113
|
-
// Low-level tools
|
|
114
|
-
bugFixerFindAppTool, bugFixerListFilesTool, bugFixerReadFileTool, bugFixerWriteFileTool, bugFixerApplyFixTool, bugFixerRunBuildTool, bugFixerGitStatusTool, bugFixerGitPullTool, bugFixerGitCommitTool, bugFixerGitPushTool, bugFixerGitRevertTool, bugFixerPublishAppTool,
|
|
115
|
-
// High-level workflow tools (LLM-driven)
|
|
116
|
-
bugFixerAnalyzeBugTool, bugFixerStartFixTool, bugFixerMarkDeclinedTool, bugFixerPublishFixTool, bugFixerRetryFixTool, markBugDeclinedTool, markBugFixedTool } = require('./mcp/tools/bug-fixer-tools');
|
|
117
|
-
// Low-level tools
|
|
118
|
-
addTool(bugFixerFindAppTool);
|
|
119
|
-
addTool(bugFixerListFilesTool);
|
|
120
|
-
addTool(bugFixerReadFileTool);
|
|
121
|
-
addTool(bugFixerWriteFileTool);
|
|
122
|
-
addTool(bugFixerApplyFixTool);
|
|
123
|
-
addTool(bugFixerRunBuildTool);
|
|
124
|
-
addTool(bugFixerGitStatusTool);
|
|
125
|
-
addTool(bugFixerGitPullTool);
|
|
126
|
-
addTool(bugFixerGitCommitTool);
|
|
127
|
-
addTool(bugFixerGitPushTool);
|
|
128
|
-
addTool(bugFixerGitRevertTool);
|
|
129
|
-
addTool(bugFixerPublishAppTool);
|
|
130
|
-
// High-level workflow tools (LLM-driven)
|
|
131
|
-
addTool(bugFixerAnalyzeBugTool);
|
|
132
|
-
addTool(bugFixerStartFixTool);
|
|
133
|
-
addTool(bugFixerMarkDeclinedTool);
|
|
134
|
-
addTool(bugFixerPublishFixTool);
|
|
135
|
-
addTool(bugFixerRetryFixTool);
|
|
136
|
-
addTool(markBugDeclinedTool);
|
|
137
|
-
addTool(markBugFixedTool);
|
|
138
|
-
logger.info('Bot-internal tools registered (MCP_CLIENT_ENABLED=true)');
|
|
139
|
-
}
|
|
105
|
+
// Metrics tools
|
|
106
|
+
addTool(metrics_1.queryMetricTool);
|
|
107
|
+
addTool(metrics_1.listMetricsTool);
|
|
108
|
+
addTool(metrics_1.searchWorkspaceForMetricsTool);
|
|
109
|
+
addTool(metrics_1.searchUserForMetricsTool);
|
|
140
110
|
logger.info('All tools registered successfully');
|
|
141
111
|
// Start the appropriate server based on transport mode
|
|
142
112
|
if (isStdioMode && toolRegistry) {
|
package/dist/bot/chat-bot.js
CHANGED
|
@@ -65,6 +65,7 @@ class HailerChatBot {
|
|
|
65
65
|
this.toolRegistry.addTool(discussion_1.inviteDiscussionMembersTool);
|
|
66
66
|
this.toolRegistry.addTool(discussion_1.getActivityFromDiscussionTool);
|
|
67
67
|
// User tools
|
|
68
|
+
this.toolRegistry.addTool(user_1.listMyWorkspacesTool);
|
|
68
69
|
this.toolRegistry.addTool(user_1.searchWorkspaceUsersTool);
|
|
69
70
|
this.toolRegistry.addTool(user_1.getWorkspaceBalanceTool);
|
|
70
71
|
// Workflow tools
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
* CLI entry point for @hailer/mcp
|
|
4
|
-
*
|
|
5
|
-
* Commands:
|
|
6
|
-
* setup - Interactive setup wizard for Claude Desktop
|
|
7
|
-
* (none) - Start MCP server (stdio mode for Claude Desktop)
|
|
8
|
-
*/
|
|
9
|
-
declare const args: string[];
|
|
10
|
-
declare const command: string;
|
|
2
|
+
import './app';
|
|
11
3
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.js
CHANGED
|
@@ -1,74 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* Commands:
|
|
7
|
-
* setup - Interactive setup wizard for Claude Desktop
|
|
8
|
-
* (none) - Start MCP server (stdio mode for Claude Desktop)
|
|
9
|
-
*/
|
|
10
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
-
var ownKeys = function(o) {
|
|
28
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
-
var ar = [];
|
|
30
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
return ownKeys(o);
|
|
34
|
-
};
|
|
35
|
-
return function (mod) {
|
|
36
|
-
if (mod && mod.__esModule) return mod;
|
|
37
|
-
var result = {};
|
|
38
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
-
__setModuleDefault(result, mod);
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
|
-
const args = process.argv.slice(2);
|
|
44
|
-
const command = args[0];
|
|
45
|
-
if (command === 'setup') {
|
|
46
|
-
// Run setup wizard
|
|
47
|
-
Promise.resolve().then(() => __importStar(require('./commands/setup'))).then(({ runSetup }) => {
|
|
48
|
-
runSetup().catch((err) => {
|
|
49
|
-
console.error('Setup failed:', err.message);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
else if (command === 'help' || command === '--help' || command === '-h') {
|
|
55
|
-
console.log(`
|
|
56
|
-
@hailer/mcp - Hailer MCP Server for Claude Desktop
|
|
57
|
-
|
|
58
|
-
Usage:
|
|
59
|
-
hailer-mcp Start MCP server (stdio mode)
|
|
60
|
-
hailer-mcp setup Configure Claude Desktop integration
|
|
61
|
-
|
|
62
|
-
Commands:
|
|
63
|
-
setup Interactive setup wizard for Claude Desktop
|
|
64
|
-
help Show this help message
|
|
65
|
-
|
|
66
|
-
For more information, see: https://github.com/hailer/hailer-mcp
|
|
67
|
-
`);
|
|
68
|
-
process.exit(0);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// Default: start MCP server
|
|
72
|
-
Promise.resolve().then(() => __importStar(require('./app')));
|
|
73
|
-
}
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
require("./app");
|
|
74
5
|
//# sourceMappingURL=cli.js.map
|
package/dist/config.d.ts
CHANGED
|
@@ -14,15 +14,13 @@
|
|
|
14
14
|
* - Development defaults for seamless local setup
|
|
15
15
|
*/
|
|
16
16
|
import { ToolGroup } from './mcp/tool-registry';
|
|
17
|
-
export declare const APP_VERSION: string;
|
|
18
17
|
/**
|
|
19
18
|
* Validated environment - single source of truth
|
|
20
19
|
*/
|
|
21
20
|
export declare const environment: {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
LOG_LEVEL: "error" | "debug" | "info" | "warn";
|
|
22
|
+
NODE_ENV: "production" | "development" | "test";
|
|
24
23
|
DISABLE_MCP_SERVER: boolean;
|
|
25
|
-
MCP_CLIENT_ENABLED: boolean;
|
|
26
24
|
ENABLE_NUCLEAR_TOOLS: boolean;
|
|
27
25
|
PORT: number;
|
|
28
26
|
CORS_ORIGINS: string[];
|
|
@@ -31,32 +29,8 @@ export declare const environment: {
|
|
|
31
29
|
password: string;
|
|
32
30
|
apiBaseUrl: string;
|
|
33
31
|
}>;
|
|
34
|
-
MCP_SERVER_URL: string;
|
|
35
|
-
MCP_CLIENT_API_KEY: string;
|
|
36
|
-
MCP_CLIENT_AGENT_IDS: string[];
|
|
37
|
-
TOKEN_USAGE_BOT_ENABLED: boolean;
|
|
38
|
-
AGENT_ACTIVITY_BOT_ENABLED: boolean;
|
|
39
|
-
CHAT_BOT_MODE: "full" | "minimal" | "assistant";
|
|
40
|
-
ADAPTIVE_DOCUMENTATION_BOT_ENABLED: boolean;
|
|
41
|
-
ADAPTIVE_AUTO_UPDATE: boolean;
|
|
42
|
-
ADAPTIVE_UPDATE_INTERVAL: number;
|
|
43
|
-
ADAPTIVE_MIN_ERROR_COUNT: number;
|
|
44
|
-
ADAPTIVE_SKILL_GENERATION: boolean;
|
|
45
|
-
BOT_API_BASE_URL: string;
|
|
46
|
-
MCP_EXCLUDE_TRANSLATIONS: boolean;
|
|
47
|
-
MCP_COMPACT_DATA: boolean;
|
|
48
|
-
MCP_INCLUDE_WORKSPACE_NAMES: boolean;
|
|
49
|
-
CONTEXT_SAFETY_MARGIN_PERCENT: number;
|
|
50
|
-
CONTEXT_ENABLE_AUTO_SUMMARIZATION: boolean;
|
|
51
|
-
CONTEXT_MAX_SUMMARIZATION_CHUNKS: number;
|
|
52
|
-
TOKEN_BILLING_ENABLED: boolean;
|
|
53
32
|
WORKSPACE_CONFIG_PATH?: string | undefined;
|
|
54
33
|
DEV_APPS_PATH?: string | undefined;
|
|
55
|
-
DEV_APPS_PATHS?: string | undefined;
|
|
56
|
-
OPENAI_API_KEY?: string | undefined;
|
|
57
|
-
OPENAI_API_BASE?: string | undefined;
|
|
58
|
-
OPENAI_MODEL?: string | undefined;
|
|
59
|
-
ANTHROPIC_API_KEY?: string | undefined;
|
|
60
34
|
};
|
|
61
35
|
/**
|
|
62
36
|
* Mask sensitive data for safe logging
|
|
@@ -75,21 +49,12 @@ export interface HailerAccount {
|
|
|
75
49
|
allowedTools?: string[];
|
|
76
50
|
allowedGroups?: ToolGroup[];
|
|
77
51
|
}
|
|
78
|
-
export interface LlmProvider {
|
|
79
|
-
name: string;
|
|
80
|
-
type: 'openai' | 'anthropic' | 'assistant';
|
|
81
|
-
apiKey: string;
|
|
82
|
-
baseURL?: string;
|
|
83
|
-
model: string;
|
|
84
|
-
enabled: boolean;
|
|
85
|
-
}
|
|
86
52
|
export interface ServerConfig {
|
|
87
53
|
port: number;
|
|
88
54
|
corsOrigins: string[];
|
|
89
55
|
enableMcpServer: boolean;
|
|
90
|
-
enableClient: boolean;
|
|
91
56
|
}
|
|
92
|
-
/** MCP context optimization settings
|
|
57
|
+
/** MCP context optimization settings */
|
|
93
58
|
export interface McpConfig {
|
|
94
59
|
excludeTranslations: boolean;
|
|
95
60
|
excludeSystemMessages: boolean;
|
|
@@ -97,31 +62,6 @@ export interface McpConfig {
|
|
|
97
62
|
compactUserData: boolean;
|
|
98
63
|
includeWorkspaceNamesInTools: boolean;
|
|
99
64
|
}
|
|
100
|
-
/** Context management configuration */
|
|
101
|
-
export interface ContextConfig {
|
|
102
|
-
safetyMarginPercent: number;
|
|
103
|
-
enableAutoSummarization: boolean;
|
|
104
|
-
maxSummarizationChunks: number;
|
|
105
|
-
}
|
|
106
|
-
/** MCP Client configuration (replaces client/config.ts exports) */
|
|
107
|
-
export interface McpClientConfig {
|
|
108
|
-
enabled: boolean;
|
|
109
|
-
mcpServerUrl: string;
|
|
110
|
-
mcpServerApiKey: string;
|
|
111
|
-
providers: LlmProvider[];
|
|
112
|
-
mcpAgentIds: string[];
|
|
113
|
-
botConfigs: BotClientConfig[];
|
|
114
|
-
enableDirectMessages: boolean;
|
|
115
|
-
tokenUsageBotEnabled: boolean;
|
|
116
|
-
agentActivityBotEnabled: boolean;
|
|
117
|
-
}
|
|
118
|
-
/** Bot client configuration for MultiBotManager compatibility */
|
|
119
|
-
export interface BotClientConfig {
|
|
120
|
-
email: string;
|
|
121
|
-
password: string;
|
|
122
|
-
apiBaseUrl: string;
|
|
123
|
-
mcpServerApiKey: string;
|
|
124
|
-
}
|
|
125
65
|
/**
|
|
126
66
|
* Universal Application Configuration
|
|
127
67
|
*
|
|
@@ -135,39 +75,10 @@ export declare class ApplicationConfig {
|
|
|
135
75
|
* Efficient Map-based Hailer accounts (replaces CLIENT_CONFIGS array)
|
|
136
76
|
*/
|
|
137
77
|
get hailerAccounts(): Record<string, HailerAccount>;
|
|
138
|
-
get llmProviders(): LlmProvider[];
|
|
139
78
|
/**
|
|
140
79
|
* MCP context optimization settings
|
|
141
80
|
*/
|
|
142
81
|
get mcpConfig(): McpConfig;
|
|
143
|
-
/**
|
|
144
|
-
* Context management settings for token limits and summarization
|
|
145
|
-
*/
|
|
146
|
-
get contextConfig(): ContextConfig;
|
|
147
|
-
/**
|
|
148
|
-
* Adaptive Documentation Bot configuration
|
|
149
|
-
*/
|
|
150
|
-
get adaptiveDocumentation(): {
|
|
151
|
-
enabled: boolean;
|
|
152
|
-
autoUpdate: boolean;
|
|
153
|
-
updateInterval: number;
|
|
154
|
-
minErrorCount: number;
|
|
155
|
-
skillGeneration: boolean;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Token billing configuration for real-time usage billing per workspace
|
|
159
|
-
*/
|
|
160
|
-
get tokenBilling(): {
|
|
161
|
-
enabled: boolean;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Bot API base URL for daemon/bot connections
|
|
165
|
-
*/
|
|
166
|
-
get botApiBaseUrl(): string;
|
|
167
|
-
/**
|
|
168
|
-
* Create MCP Client configuration (replaces createMcpClientConfig())
|
|
169
|
-
*/
|
|
170
|
-
get mcpClient(): McpClientConfig | null;
|
|
171
82
|
/**
|
|
172
83
|
* Find account by API key - O(1) lookup (replaces getClientConfig())
|
|
173
84
|
* This is the key efficiency improvement that eliminates array filtering
|
|
@@ -177,10 +88,6 @@ export declare class ApplicationConfig {
|
|
|
177
88
|
* Alternative method with null return (safer)
|
|
178
89
|
*/
|
|
179
90
|
findAccountByApiKey(apiKey: string): HailerAccount | null;
|
|
180
|
-
/**
|
|
181
|
-
* Get enabled LLM providers only
|
|
182
|
-
*/
|
|
183
|
-
getEnabledLlmProviders(): LlmProvider[];
|
|
184
91
|
}
|
|
185
92
|
/**
|
|
186
93
|
* Create application configuration
|
package/dist/config.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - Development defaults for seamless local setup
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.ApplicationConfig = exports.environment =
|
|
18
|
+
exports.ApplicationConfig = exports.environment = void 0;
|
|
19
19
|
exports.maskSensitiveData = maskSensitiveData;
|
|
20
20
|
exports.maskEmail = maskEmail;
|
|
21
21
|
exports.createApplicationConfig = createApplicationConfig;
|
|
@@ -23,9 +23,6 @@ const zod_1 = require("zod");
|
|
|
23
23
|
const dotenv_1 = require("dotenv");
|
|
24
24
|
// Load environment variables
|
|
25
25
|
(0, dotenv_1.config)({ path: '.env.local' });
|
|
26
|
-
// Package version - read dynamically to avoid hardcoding
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
28
|
-
exports.APP_VERSION = require('../package.json').version;
|
|
29
26
|
// ================================================================================
|
|
30
27
|
// ENVIRONMENT VALIDATION
|
|
31
28
|
// ================================================================================
|
|
@@ -126,7 +123,6 @@ const environmentSchema = zod_1.z.object({
|
|
|
126
123
|
LOG_LEVEL: zod_1.z.enum(['debug', 'info', 'warn', 'error']).default('info'),
|
|
127
124
|
// Service control
|
|
128
125
|
DISABLE_MCP_SERVER: zod_1.z.string().transform(v => v === 'true').default('false'),
|
|
129
|
-
MCP_CLIENT_ENABLED: zod_1.z.string().transform(v => v === 'true').default('false'),
|
|
130
126
|
ENABLE_NUCLEAR_TOOLS: zod_1.z.string().transform(v => v === 'true').default('false'),
|
|
131
127
|
// Server
|
|
132
128
|
PORT: zod_1.z.string().transform(v => parseInt(v) || 3030).default('3030'),
|
|
@@ -137,40 +133,6 @@ const environmentSchema = zod_1.z.object({
|
|
|
137
133
|
WORKSPACE_CONFIG_PATH: zod_1.z.string().optional(),
|
|
138
134
|
// Development apps path (for scaffolding Hailer apps outside the repo)
|
|
139
135
|
DEV_APPS_PATH: zod_1.z.string().optional(),
|
|
140
|
-
// Multiple app directories for Bug Fixer - comma-separated paths
|
|
141
|
-
// Example: DEV_APPS_PATHS=/path/to/apps,/path/to/other/apps
|
|
142
|
-
DEV_APPS_PATHS: zod_1.z.string().optional(),
|
|
143
|
-
// LLM providers
|
|
144
|
-
OPENAI_API_KEY: zod_1.z.string().min(1).optional(),
|
|
145
|
-
OPENAI_API_BASE: zod_1.z.string().url().optional(),
|
|
146
|
-
OPENAI_MODEL: zod_1.z.string().optional(),
|
|
147
|
-
ANTHROPIC_API_KEY: zod_1.z.string().min(1).optional(),
|
|
148
|
-
// MCP client settings
|
|
149
|
-
MCP_SERVER_URL: zod_1.z.string().url().default('http://localhost:3030/api/mcp'),
|
|
150
|
-
MCP_CLIENT_API_KEY: zod_1.z.string(),
|
|
151
|
-
MCP_CLIENT_AGENT_IDS: jsonArraySchema(zod_1.z.string()).default('[]'),
|
|
152
|
-
// Bot features
|
|
153
|
-
TOKEN_USAGE_BOT_ENABLED: zod_1.z.string().transform(v => v !== 'false').default('true'),
|
|
154
|
-
AGENT_ACTIVITY_BOT_ENABLED: zod_1.z.string().transform(v => v !== 'false').default('true'),
|
|
155
|
-
// Chat bot mode: 'full' = all tools, 'minimal' = chat tools only, 'assistant' = no tools (knowledge-based help)
|
|
156
|
-
CHAT_BOT_MODE: zod_1.z.enum(['full', 'minimal', 'assistant']).default('full'),
|
|
157
|
-
ADAPTIVE_DOCUMENTATION_BOT_ENABLED: zod_1.z.string().transform(v => v === 'true').default('false'),
|
|
158
|
-
ADAPTIVE_AUTO_UPDATE: zod_1.z.string().transform(v => v === 'true').default('false'),
|
|
159
|
-
ADAPTIVE_UPDATE_INTERVAL: zod_1.z.string().transform(v => parseInt(v) || 60000).default('60000'),
|
|
160
|
-
ADAPTIVE_MIN_ERROR_COUNT: zod_1.z.string().transform(v => parseInt(v) || 3).default('3'),
|
|
161
|
-
ADAPTIVE_SKILL_GENERATION: zod_1.z.string().transform(v => v === 'true').default('false'), // Chat bot can't use skills
|
|
162
|
-
// Bot API Base URL (for daemon/bot connections)
|
|
163
|
-
BOT_API_BASE_URL: zod_1.z.string().url().default('https://api.hailer.com'),
|
|
164
|
-
// MCP context optimization (replaces mcp-config.ts)
|
|
165
|
-
MCP_EXCLUDE_TRANSLATIONS: zod_1.z.string().transform(v => v !== 'false').default('true'),
|
|
166
|
-
MCP_COMPACT_DATA: zod_1.z.string().transform(v => v !== 'false').default('true'),
|
|
167
|
-
MCP_INCLUDE_WORKSPACE_NAMES: zod_1.z.string().transform(v => v !== 'false').default('true'),
|
|
168
|
-
// Context management & token limits
|
|
169
|
-
CONTEXT_SAFETY_MARGIN_PERCENT: zod_1.z.string().transform(v => parseInt(v) || 25).default('25'),
|
|
170
|
-
CONTEXT_ENABLE_AUTO_SUMMARIZATION: zod_1.z.string().transform(v => v !== 'false').default('true'),
|
|
171
|
-
CONTEXT_MAX_SUMMARIZATION_CHUNKS: zod_1.z.string().transform(v => parseInt(v) || 10).default('10'),
|
|
172
|
-
// Token billing (real-time usage billing per workspace via Hailer API)
|
|
173
|
-
TOKEN_BILLING_ENABLED: zod_1.z.string().transform(v => v === 'true').default('false'),
|
|
174
136
|
});
|
|
175
137
|
/**
|
|
176
138
|
* Get process environment
|
|
@@ -256,7 +218,6 @@ class ApplicationConfig {
|
|
|
256
218
|
port: exports.environment.PORT,
|
|
257
219
|
corsOrigins: exports.environment.CORS_ORIGINS,
|
|
258
220
|
enableMcpServer: !exports.environment.DISABLE_MCP_SERVER,
|
|
259
|
-
enableClient: exports.environment.MCP_CLIENT_ENABLED,
|
|
260
221
|
};
|
|
261
222
|
}
|
|
262
223
|
/**
|
|
@@ -265,111 +226,16 @@ class ApplicationConfig {
|
|
|
265
226
|
get hailerAccounts() {
|
|
266
227
|
return exports.environment.CLIENT_CONFIGS;
|
|
267
228
|
}
|
|
268
|
-
get llmProviders() {
|
|
269
|
-
const providers = [];
|
|
270
|
-
if (exports.environment.OPENAI_API_KEY || exports.environment.OPENAI_API_BASE) {
|
|
271
|
-
const isAssistantMode = exports.environment.CHAT_BOT_MODE === 'assistant';
|
|
272
|
-
providers.push({
|
|
273
|
-
name: isAssistantMode ? 'mcp-assistant' : (exports.environment.OPENAI_API_BASE ? 'local-llm' : 'openai-gpt4o'),
|
|
274
|
-
type: isAssistantMode ? 'assistant' : 'openai',
|
|
275
|
-
apiKey: exports.environment.OPENAI_API_KEY || 'not-needed',
|
|
276
|
-
baseURL: exports.environment.OPENAI_API_BASE,
|
|
277
|
-
model: exports.environment.OPENAI_MODEL || 'gpt-4o',
|
|
278
|
-
enabled: true,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
if (exports.environment.ANTHROPIC_API_KEY) {
|
|
282
|
-
providers.push({
|
|
283
|
-
name: 'anthropic-claude',
|
|
284
|
-
type: 'anthropic',
|
|
285
|
-
apiKey: exports.environment.ANTHROPIC_API_KEY,
|
|
286
|
-
model: 'claude-haiku-4-5-20251001', // Haiku 4.5 - fast and cheap
|
|
287
|
-
enabled: true,
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
return providers;
|
|
291
|
-
}
|
|
292
|
-
// ===== MCP CONFIGURATION (replaces mcp-config.ts) =====
|
|
293
229
|
/**
|
|
294
230
|
* MCP context optimization settings
|
|
295
231
|
*/
|
|
296
232
|
get mcpConfig() {
|
|
297
233
|
return {
|
|
298
|
-
excludeTranslations:
|
|
299
|
-
excludeSystemMessages: true,
|
|
300
|
-
excludeEmptyFields: true,
|
|
301
|
-
compactUserData:
|
|
302
|
-
includeWorkspaceNamesInTools:
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Context management settings for token limits and summarization
|
|
307
|
-
*/
|
|
308
|
-
get contextConfig() {
|
|
309
|
-
return {
|
|
310
|
-
safetyMarginPercent: exports.environment.CONTEXT_SAFETY_MARGIN_PERCENT,
|
|
311
|
-
enableAutoSummarization: exports.environment.CONTEXT_ENABLE_AUTO_SUMMARIZATION,
|
|
312
|
-
maxSummarizationChunks: exports.environment.CONTEXT_MAX_SUMMARIZATION_CHUNKS,
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Adaptive Documentation Bot configuration
|
|
317
|
-
*/
|
|
318
|
-
get adaptiveDocumentation() {
|
|
319
|
-
return {
|
|
320
|
-
enabled: exports.environment.ADAPTIVE_DOCUMENTATION_BOT_ENABLED,
|
|
321
|
-
autoUpdate: exports.environment.ADAPTIVE_AUTO_UPDATE,
|
|
322
|
-
updateInterval: exports.environment.ADAPTIVE_UPDATE_INTERVAL,
|
|
323
|
-
minErrorCount: exports.environment.ADAPTIVE_MIN_ERROR_COUNT,
|
|
324
|
-
skillGeneration: exports.environment.ADAPTIVE_SKILL_GENERATION,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Token billing configuration for real-time usage billing per workspace
|
|
329
|
-
*/
|
|
330
|
-
get tokenBilling() {
|
|
331
|
-
return {
|
|
332
|
-
enabled: exports.environment.TOKEN_BILLING_ENABLED,
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Bot API base URL for daemon/bot connections
|
|
337
|
-
*/
|
|
338
|
-
get botApiBaseUrl() {
|
|
339
|
-
return exports.environment.BOT_API_BASE_URL;
|
|
340
|
-
}
|
|
341
|
-
// ===== CLIENT CONFIGURATION (replaces client/config.ts) =====
|
|
342
|
-
/**
|
|
343
|
-
* Create MCP Client configuration (replaces createMcpClientConfig())
|
|
344
|
-
*/
|
|
345
|
-
get mcpClient() {
|
|
346
|
-
const accounts = this.hailerAccounts;
|
|
347
|
-
const providers = this.llmProviders;
|
|
348
|
-
if (Object.keys(accounts).length === 0) {
|
|
349
|
-
console.warn('No Hailer accounts configured - MCP Client will be disabled');
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
if (providers.length === 0) {
|
|
353
|
-
console.warn('No LLM providers configured - MCP Client will be disabled');
|
|
354
|
-
return null;
|
|
355
|
-
}
|
|
356
|
-
// Convert Map format to BotClientConfig array for MultiBotManager compatibility
|
|
357
|
-
const botConfigs = Object.entries(accounts).map(([apiKey, account]) => ({
|
|
358
|
-
email: account.email,
|
|
359
|
-
password: account.password,
|
|
360
|
-
apiBaseUrl: account.apiBaseUrl,
|
|
361
|
-
mcpServerApiKey: apiKey,
|
|
362
|
-
}));
|
|
363
|
-
return {
|
|
364
|
-
enabled: exports.environment.MCP_CLIENT_ENABLED,
|
|
365
|
-
mcpServerUrl: exports.environment.MCP_SERVER_URL,
|
|
366
|
-
mcpServerApiKey: exports.environment.MCP_CLIENT_API_KEY,
|
|
367
|
-
providers,
|
|
368
|
-
mcpAgentIds: exports.environment.MCP_CLIENT_AGENT_IDS,
|
|
369
|
-
botConfigs,
|
|
370
|
-
enableDirectMessages: true,
|
|
371
|
-
tokenUsageBotEnabled: exports.environment.TOKEN_USAGE_BOT_ENABLED,
|
|
372
|
-
agentActivityBotEnabled: exports.environment.AGENT_ACTIVITY_BOT_ENABLED,
|
|
234
|
+
excludeTranslations: true,
|
|
235
|
+
excludeSystemMessages: true,
|
|
236
|
+
excludeEmptyFields: true,
|
|
237
|
+
compactUserData: true,
|
|
238
|
+
includeWorkspaceNamesInTools: true,
|
|
373
239
|
};
|
|
374
240
|
}
|
|
375
241
|
// ===== UTILITY METHODS =====
|
|
@@ -393,12 +259,6 @@ class ApplicationConfig {
|
|
|
393
259
|
findAccountByApiKey(apiKey) {
|
|
394
260
|
return this.hailerAccounts[apiKey] || null;
|
|
395
261
|
}
|
|
396
|
-
/**
|
|
397
|
-
* Get enabled LLM providers only
|
|
398
|
-
*/
|
|
399
|
-
getEnabledLlmProviders() {
|
|
400
|
-
return this.llmProviders.filter(provider => provider.enabled);
|
|
401
|
-
}
|
|
402
262
|
}
|
|
403
263
|
exports.ApplicationConfig = ApplicationConfig;
|
|
404
264
|
// ================================================================================
|
package/dist/core.d.ts
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core class for Hailer MCP Server
|
|
3
3
|
* Pure orchestrator - manages application lifecycle and service coordination
|
|
4
|
-
* Separated from Express server implementation for better architecture
|
|
5
4
|
*/
|
|
6
5
|
import { Tool } from './mcp/tool-registry';
|
|
7
|
-
import type { ConversationState } from './agents/shared/types';
|
|
8
|
-
/** Status returned by DaemonManager.getStatus() */
|
|
9
|
-
interface DaemonStatus {
|
|
10
|
-
botId: string;
|
|
11
|
-
state: ConversationState;
|
|
12
|
-
}
|
|
13
6
|
export declare class Core {
|
|
14
7
|
private logger;
|
|
15
8
|
private appConfig;
|
|
16
9
|
private toolRegistry;
|
|
17
10
|
private mcpServer?;
|
|
18
|
-
private daemonManagers;
|
|
19
|
-
private statusLogIntervals;
|
|
20
|
-
private daemonInitInProgress;
|
|
21
|
-
private initialDaemonReady;
|
|
22
11
|
constructor();
|
|
23
12
|
/**
|
|
24
13
|
* Public API for external tool registration
|
|
@@ -27,42 +16,7 @@ export declare class Core {
|
|
|
27
16
|
addTool(tool: Tool): void;
|
|
28
17
|
start(): Promise<void>;
|
|
29
18
|
private startMCPServer;
|
|
30
|
-
/**
|
|
31
|
-
* Start MCP Client (daemons) for all workspaces with enabled orchestrators
|
|
32
|
-
*/
|
|
33
|
-
private startMCPClient;
|
|
34
|
-
/**
|
|
35
|
-
* Start Bug Fixer in standalone mode (no orchestrator/AI Hub needed)
|
|
36
|
-
* Uses BUG_FIXER_EMAIL and BUG_FIXER_PASSWORD env vars
|
|
37
|
-
*/
|
|
38
|
-
private startStandaloneBugFixer;
|
|
39
|
-
private initBotConfig;
|
|
40
|
-
/**
|
|
41
|
-
* Register webhook handler for bot config updates
|
|
42
|
-
* Called early so webhooks can trigger daemon start even if initial start failed
|
|
43
|
-
*/
|
|
44
|
-
private registerWebhookHandler;
|
|
45
|
-
/**
|
|
46
|
-
* Attempt to restart daemon mode when bot state changes
|
|
47
|
-
* Stops existing daemon for a specific workspace and starts fresh with updated configuration
|
|
48
|
-
* Includes retry logic for transient connection failures
|
|
49
|
-
*
|
|
50
|
-
* @param retryCount - Number of retry attempts made so far
|
|
51
|
-
* @param workspaceId - REQUIRED workspace ID to restart daemon for
|
|
52
|
-
*/
|
|
53
|
-
private attemptDaemonRestart;
|
|
54
|
-
/**
|
|
55
|
-
* Initialize daemon for a specific workspace
|
|
56
|
-
*
|
|
57
|
-
* @param workspaceId - REQUIRED workspace ID to initialize daemon for
|
|
58
|
-
*/
|
|
59
|
-
private initializeDaemonMode;
|
|
60
|
-
/**
|
|
61
|
-
* Get daemon status for all workspaces (for HTTP endpoint)
|
|
62
|
-
*/
|
|
63
|
-
getDaemonStatus(): Record<string, DaemonStatus[]>;
|
|
64
19
|
stop(): Promise<void>;
|
|
65
20
|
setupGracefulShutdown(): void;
|
|
66
21
|
}
|
|
67
|
-
export {};
|
|
68
22
|
//# sourceMappingURL=core.d.ts.map
|