@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.
- package/dist/app.js +24 -20
- package/dist/core.d.ts +33 -9
- package/dist/core.js +279 -147
- package/dist/mcp/UserContextCache.js +18 -0
- package/dist/mcp/hailer-clients.d.ts +9 -1
- package/dist/mcp/hailer-clients.js +13 -3
- package/dist/mcp/signal-handler.js +1 -1
- package/dist/mcp/tool-registry.d.ts +3 -1
- package/dist/mcp/tool-registry.js +4 -1
- package/dist/mcp/tools/activity.js +43 -34
- package/dist/mcp/tools/bot-config/constants.d.ts +23 -0
- package/dist/mcp/tools/bot-config/constants.js +94 -0
- package/dist/mcp/tools/{bot-config.d.ts → bot-config/core.d.ts} +6 -6
- package/dist/mcp/tools/{bot-config.js → bot-config/core.js} +15 -15
- package/dist/mcp/tools/bot-config/index.d.ts +10 -0
- package/dist/mcp/tools/bot-config/index.js +59 -0
- package/dist/mcp/tools/bot-config/tools.d.ts +7 -0
- package/dist/mcp/tools/bot-config/tools.js +15 -0
- package/dist/mcp/tools/bot-config/types.d.ts +50 -0
- package/dist/mcp/tools/bot-config/types.js +6 -0
- package/dist/mcp/tools/bug-fixer-tools.d.ts +21 -0
- package/dist/mcp/tools/{giuseppe-tools.js → bug-fixer-tools.js} +61 -61
- package/dist/mcp/tools/user.js +10 -29
- package/dist/mcp/tools/workflow.js +36 -2
- package/dist/mcp/utils/data-transformers.d.ts +0 -8
- package/dist/mcp/utils/data-transformers.js +0 -28
- package/dist/mcp/utils/index.d.ts +4 -1
- package/dist/mcp/utils/index.js +17 -3
- package/dist/mcp/utils/pagination.d.ts +40 -0
- package/dist/mcp/utils/pagination.js +55 -0
- package/dist/mcp/utils/response-builder.d.ts +53 -0
- package/dist/mcp/utils/response-builder.js +110 -0
- package/dist/mcp/utils/tool-helpers.d.ts +0 -8
- package/dist/mcp/utils/tool-helpers.js +0 -24
- package/dist/mcp/utils/types.d.ts +1 -33
- package/dist/mcp/webhook-handler.d.ts +2 -2
- package/dist/mcp/webhook-handler.js +5 -3
- package/dist/mcp-server.d.ts +2 -2
- package/dist/mcp-server.js +167 -140
- package/package.json +1 -1
- package/REFACTOR_STATUS.md +0 -127
- package/dist/agents/bot-manager.d.ts +0 -48
- package/dist/agents/bot-manager.js +0 -254
- package/dist/agents/factory.d.ts +0 -150
- package/dist/agents/factory.js +0 -650
- package/dist/agents/giuseppe/ai.d.ts +0 -83
- package/dist/agents/giuseppe/ai.js +0 -466
- package/dist/agents/giuseppe/bot.d.ts +0 -110
- package/dist/agents/giuseppe/bot.js +0 -780
- package/dist/agents/giuseppe/config.d.ts +0 -25
- package/dist/agents/giuseppe/config.js +0 -227
- package/dist/agents/giuseppe/files.d.ts +0 -52
- package/dist/agents/giuseppe/files.js +0 -338
- package/dist/agents/giuseppe/git.d.ts +0 -48
- package/dist/agents/giuseppe/git.js +0 -298
- package/dist/agents/giuseppe/index.d.ts +0 -97
- package/dist/agents/giuseppe/index.js +0 -258
- package/dist/agents/giuseppe/lsp.d.ts +0 -113
- package/dist/agents/giuseppe/lsp.js +0 -485
- package/dist/agents/giuseppe/monitor.d.ts +0 -118
- package/dist/agents/giuseppe/monitor.js +0 -621
- package/dist/agents/giuseppe/prompt.d.ts +0 -5
- package/dist/agents/giuseppe/prompt.js +0 -94
- package/dist/agents/giuseppe/registries/pending-classification.d.ts +0 -28
- package/dist/agents/giuseppe/registries/pending-classification.js +0 -50
- package/dist/agents/giuseppe/registries/pending-fix.d.ts +0 -30
- package/dist/agents/giuseppe/registries/pending-fix.js +0 -42
- package/dist/agents/giuseppe/registries/pending.d.ts +0 -27
- package/dist/agents/giuseppe/registries/pending.js +0 -49
- package/dist/agents/giuseppe/specialist.d.ts +0 -47
- package/dist/agents/giuseppe/specialist.js +0 -237
- package/dist/agents/giuseppe/types.d.ts +0 -123
- package/dist/agents/giuseppe/types.js +0 -9
- package/dist/agents/hailer-expert/index.d.ts +0 -8
- package/dist/agents/hailer-expert/index.js +0 -14
- package/dist/agents/hal/daemon.d.ts +0 -142
- package/dist/agents/hal/daemon.js +0 -1103
- package/dist/agents/hal/definitions.d.ts +0 -55
- package/dist/agents/hal/definitions.js +0 -263
- package/dist/agents/hal/index.d.ts +0 -3
- package/dist/agents/hal/index.js +0 -8
- package/dist/agents/index.d.ts +0 -18
- package/dist/agents/index.js +0 -48
- package/dist/agents/shared/base.d.ts +0 -216
- package/dist/agents/shared/base.js +0 -846
- package/dist/agents/shared/services/agent-registry.d.ts +0 -107
- package/dist/agents/shared/services/agent-registry.js +0 -629
- package/dist/agents/shared/services/conversation-manager.d.ts +0 -50
- package/dist/agents/shared/services/conversation-manager.js +0 -136
- package/dist/agents/shared/services/mcp-client.d.ts +0 -56
- package/dist/agents/shared/services/mcp-client.js +0 -124
- package/dist/agents/shared/services/message-classifier.d.ts +0 -37
- package/dist/agents/shared/services/message-classifier.js +0 -187
- package/dist/agents/shared/services/message-formatter.d.ts +0 -89
- package/dist/agents/shared/services/message-formatter.js +0 -371
- package/dist/agents/shared/services/session-logger.d.ts +0 -106
- package/dist/agents/shared/services/session-logger.js +0 -446
- package/dist/agents/shared/services/tool-executor.d.ts +0 -41
- package/dist/agents/shared/services/tool-executor.js +0 -169
- package/dist/agents/shared/services/workspace-schema-cache.d.ts +0 -125
- package/dist/agents/shared/services/workspace-schema-cache.js +0 -578
- package/dist/agents/shared/specialist.d.ts +0 -91
- package/dist/agents/shared/specialist.js +0 -399
- package/dist/agents/shared/tool-schema-loader.d.ts +0 -62
- package/dist/agents/shared/tool-schema-loader.js +0 -232
- package/dist/agents/shared/types.d.ts +0 -327
- package/dist/agents/shared/types.js +0 -121
- package/dist/client/agents/base.d.ts +0 -207
- package/dist/client/agents/base.js +0 -744
- package/dist/client/agents/definitions.d.ts +0 -53
- package/dist/client/agents/definitions.js +0 -263
- package/dist/client/agents/orchestrator.d.ts +0 -141
- package/dist/client/agents/orchestrator.js +0 -1062
- package/dist/client/agents/specialist.d.ts +0 -86
- package/dist/client/agents/specialist.js +0 -340
- package/dist/client/bot-entrypoint.d.ts +0 -7
- package/dist/client/bot-entrypoint.js +0 -103
- package/dist/client/bot-manager.d.ts +0 -44
- package/dist/client/bot-manager.js +0 -173
- package/dist/client/bot-runner.d.ts +0 -35
- package/dist/client/bot-runner.js +0 -188
- package/dist/client/chat-agent-daemon.d.ts +0 -464
- package/dist/client/chat-agent-daemon.js +0 -1774
- package/dist/client/daemon-factory.d.ts +0 -106
- package/dist/client/daemon-factory.js +0 -301
- package/dist/client/factory.d.ts +0 -111
- package/dist/client/factory.js +0 -314
- package/dist/client/index.d.ts +0 -17
- package/dist/client/index.js +0 -38
- package/dist/client/multi-bot-manager.d.ts +0 -42
- package/dist/client/multi-bot-manager.js +0 -161
- package/dist/client/orchestrator-daemon.d.ts +0 -87
- package/dist/client/orchestrator-daemon.js +0 -444
- package/dist/client/server.d.ts +0 -8
- package/dist/client/server.js +0 -251
- package/dist/client/services/agent-registry.d.ts +0 -108
- package/dist/client/services/agent-registry.js +0 -630
- package/dist/client/services/conversation-manager.d.ts +0 -50
- package/dist/client/services/conversation-manager.js +0 -136
- package/dist/client/services/mcp-client.d.ts +0 -48
- package/dist/client/services/mcp-client.js +0 -105
- package/dist/client/services/message-classifier.d.ts +0 -37
- package/dist/client/services/message-classifier.js +0 -187
- package/dist/client/services/message-formatter.d.ts +0 -84
- package/dist/client/services/message-formatter.js +0 -353
- package/dist/client/services/session-logger.d.ts +0 -106
- package/dist/client/services/session-logger.js +0 -446
- package/dist/client/services/tool-executor.d.ts +0 -41
- package/dist/client/services/tool-executor.js +0 -169
- package/dist/client/services/workspace-schema-cache.d.ts +0 -149
- package/dist/client/services/workspace-schema-cache.js +0 -732
- package/dist/client/specialist-daemon.d.ts +0 -77
- package/dist/client/specialist-daemon.js +0 -197
- package/dist/client/specialists.d.ts +0 -53
- package/dist/client/specialists.js +0 -178
- package/dist/client/tool-schema-loader.d.ts +0 -62
- package/dist/client/tool-schema-loader.js +0 -232
- package/dist/client/types.d.ts +0 -327
- package/dist/client/types.js +0 -121
- package/dist/commands/seed-config.d.ts +0 -9
- package/dist/commands/seed-config.js +0 -372
- package/dist/lib/context-manager.d.ts +0 -111
- package/dist/lib/context-manager.js +0 -431
- package/dist/lib/prompt-length-manager.d.ts +0 -81
- package/dist/lib/prompt-length-manager.js +0 -457
- package/dist/mcp/tools/giuseppe-tools.d.ts +0 -21
- package/dist/modules/bug-reports/bug-config.d.ts +0 -25
- package/dist/modules/bug-reports/bug-config.js +0 -187
- package/dist/modules/bug-reports/bug-monitor.d.ts +0 -108
- package/dist/modules/bug-reports/bug-monitor.js +0 -510
- package/dist/modules/bug-reports/giuseppe-agent.d.ts +0 -58
- package/dist/modules/bug-reports/giuseppe-agent.js +0 -467
- package/dist/modules/bug-reports/giuseppe-ai.d.ts +0 -83
- package/dist/modules/bug-reports/giuseppe-ai.js +0 -466
- package/dist/modules/bug-reports/giuseppe-bot.d.ts +0 -110
- package/dist/modules/bug-reports/giuseppe-bot.js +0 -804
- package/dist/modules/bug-reports/giuseppe-daemon.d.ts +0 -80
- package/dist/modules/bug-reports/giuseppe-daemon.js +0 -617
- package/dist/modules/bug-reports/giuseppe-files.d.ts +0 -64
- package/dist/modules/bug-reports/giuseppe-files.js +0 -375
- package/dist/modules/bug-reports/giuseppe-git.d.ts +0 -48
- package/dist/modules/bug-reports/giuseppe-git.js +0 -298
- package/dist/modules/bug-reports/giuseppe-lsp.d.ts +0 -113
- package/dist/modules/bug-reports/giuseppe-lsp.js +0 -485
- package/dist/modules/bug-reports/giuseppe-prompt.d.ts +0 -5
- package/dist/modules/bug-reports/giuseppe-prompt.js +0 -94
- package/dist/modules/bug-reports/index.d.ts +0 -77
- package/dist/modules/bug-reports/index.js +0 -215
- package/dist/modules/bug-reports/pending-classification-registry.d.ts +0 -28
- package/dist/modules/bug-reports/pending-classification-registry.js +0 -50
- package/dist/modules/bug-reports/pending-fix-registry.d.ts +0 -30
- package/dist/modules/bug-reports/pending-fix-registry.js +0 -42
- package/dist/modules/bug-reports/pending-registry.d.ts +0 -27
- package/dist/modules/bug-reports/pending-registry.js +0 -49
- package/dist/modules/bug-reports/types.d.ts +0 -123
- package/dist/modules/bug-reports/types.js +0 -9
- package/dist/routes/agents.d.ts +0 -44
- package/dist/routes/agents.js +0 -311
- package/dist/services/agent-credential-store.d.ts +0 -73
- package/dist/services/agent-credential-store.js +0 -212
- package/dist/services/bug-monitor.d.ts +0 -23
- package/dist/services/bug-monitor.js +0 -275
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bug Fixer MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Bug-fixing tools for Bug Fixer specialist daemon.
|
|
5
|
+
* These tools handle file operations, git, and build commands.
|
|
6
|
+
*/
|
|
7
|
+
import { Tool } from "../tool-registry";
|
|
8
|
+
export declare const bugFixerFindAppTool: Tool;
|
|
9
|
+
export declare const bugFixerListFilesTool: Tool;
|
|
10
|
+
export declare const bugFixerReadFileTool: Tool;
|
|
11
|
+
export declare const bugFixerWriteFileTool: Tool;
|
|
12
|
+
export declare const bugFixerApplyFixTool: Tool;
|
|
13
|
+
export declare const bugFixerRunBuildTool: Tool;
|
|
14
|
+
export declare const bugFixerGitStatusTool: Tool;
|
|
15
|
+
export declare const bugFixerGitPullTool: Tool;
|
|
16
|
+
export declare const bugFixerGitCommitTool: Tool;
|
|
17
|
+
export declare const bugFixerGitPushTool: Tool;
|
|
18
|
+
export declare const bugFixerGitRevertTool: Tool;
|
|
19
|
+
export declare const bugFixerPublishAppTool: Tool;
|
|
20
|
+
export declare const bugFixerTools: Tool[];
|
|
21
|
+
//# sourceMappingURL=bug-fixer-tools.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Bug Fixer MCP Tools
|
|
4
4
|
*
|
|
5
|
-
* Bug-fixing tools for
|
|
5
|
+
* Bug-fixing tools for Bug Fixer specialist daemon.
|
|
6
6
|
* These tools handle file operations, git, and build commands.
|
|
7
7
|
*/
|
|
8
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -39,7 +39,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
};
|
|
40
40
|
})();
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
42
|
+
exports.bugFixerTools = exports.bugFixerPublishAppTool = exports.bugFixerGitRevertTool = exports.bugFixerGitPushTool = exports.bugFixerGitCommitTool = exports.bugFixerGitPullTool = exports.bugFixerGitStatusTool = exports.bugFixerRunBuildTool = exports.bugFixerApplyFixTool = exports.bugFixerWriteFileTool = exports.bugFixerReadFileTool = exports.bugFixerListFilesTool = exports.bugFixerFindAppTool = void 0;
|
|
43
43
|
const zod_1 = require("zod");
|
|
44
44
|
const child_process_1 = require("child_process");
|
|
45
45
|
const fs = __importStar(require("fs/promises"));
|
|
@@ -47,7 +47,7 @@ const path = __importStar(require("path"));
|
|
|
47
47
|
const tool_registry_1 = require("../tool-registry");
|
|
48
48
|
const logger_1 = require("../../lib/logger");
|
|
49
49
|
const config_1 = require("../../config");
|
|
50
|
-
const logger = (0, logger_1.createLogger)({ component: "
|
|
50
|
+
const logger = (0, logger_1.createLogger)({ component: "bug-fixer-tools" });
|
|
51
51
|
const appsBasePath = config_1.environment.DEV_APPS_PATH || process.cwd();
|
|
52
52
|
// Helper to scan for apps
|
|
53
53
|
async function scanApps() {
|
|
@@ -80,9 +80,9 @@ async function scanApps() {
|
|
|
80
80
|
return apps;
|
|
81
81
|
}
|
|
82
82
|
// Find App Tool
|
|
83
|
-
exports.
|
|
84
|
-
name: "
|
|
85
|
-
group: tool_registry_1.ToolGroup.
|
|
83
|
+
exports.bugFixerFindAppTool = {
|
|
84
|
+
name: "bug_fixer_find_app",
|
|
85
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
86
86
|
description: "Find a Hailer app project by name or from bug title",
|
|
87
87
|
schema: zod_1.z.object({
|
|
88
88
|
searchTerm: zod_1.z.string().describe("App name or bug title to search for").optional(),
|
|
@@ -108,9 +108,9 @@ exports.giuseppeFindAppTool = {
|
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
110
|
// List Files Tool
|
|
111
|
-
exports.
|
|
112
|
-
name: "
|
|
113
|
-
group: tool_registry_1.ToolGroup.
|
|
111
|
+
exports.bugFixerListFilesTool = {
|
|
112
|
+
name: "bug_fixer_list_files",
|
|
113
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
114
114
|
description: "List source files in a Hailer app project",
|
|
115
115
|
schema: zod_1.z.object({
|
|
116
116
|
appPath: zod_1.z.string().describe("Path to the app project")
|
|
@@ -148,9 +148,9 @@ exports.giuseppeListFilesTool = {
|
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
// Read File Tool
|
|
151
|
-
exports.
|
|
152
|
-
name: "
|
|
153
|
-
group: tool_registry_1.ToolGroup.
|
|
151
|
+
exports.bugFixerReadFileTool = {
|
|
152
|
+
name: "bug_fixer_read_file",
|
|
153
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
154
154
|
description: "Read a source file from the app",
|
|
155
155
|
schema: zod_1.z.object({
|
|
156
156
|
appPath: zod_1.z.string().describe("Path to the app project"),
|
|
@@ -172,9 +172,9 @@ exports.giuseppeReadFileTool = {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
// Write File Tool
|
|
175
|
-
exports.
|
|
176
|
-
name: "
|
|
177
|
-
group: tool_registry_1.ToolGroup.
|
|
175
|
+
exports.bugFixerWriteFileTool = {
|
|
176
|
+
name: "bug_fixer_write_file",
|
|
177
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
178
178
|
description: "Write/update a source file in the app",
|
|
179
179
|
schema: zod_1.z.object({
|
|
180
180
|
appPath: zod_1.z.string().describe("Path to the app project"),
|
|
@@ -186,7 +186,7 @@ exports.giuseppeWriteFileTool = {
|
|
|
186
186
|
const fullPath = path.join(args.appPath, args.filePath);
|
|
187
187
|
await fs.mkdir(path.dirname(fullPath), { recursive: true });
|
|
188
188
|
await fs.writeFile(fullPath, args.content, "utf-8");
|
|
189
|
-
logger.info("
|
|
189
|
+
logger.info("Bug Fixer wrote file", { filePath: args.filePath });
|
|
190
190
|
return {
|
|
191
191
|
content: [{ type: "text", text: JSON.stringify({ success: true, path: args.filePath }) }]
|
|
192
192
|
};
|
|
@@ -206,9 +206,9 @@ const fixFileSchema = zod_1.z.object({
|
|
|
206
206
|
replace: zod_1.z.string().optional().describe("For 'edit': the code to replace it with"),
|
|
207
207
|
content: zod_1.z.string().optional().describe("For 'create': the full file content")
|
|
208
208
|
});
|
|
209
|
-
exports.
|
|
210
|
-
name: "
|
|
211
|
-
group: tool_registry_1.ToolGroup.
|
|
209
|
+
exports.bugFixerApplyFixTool = {
|
|
210
|
+
name: "bug_fixer_apply_fix",
|
|
211
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
212
212
|
description: `Apply code fixes using search/replace pattern. More token-efficient than rewriting entire files.
|
|
213
213
|
|
|
214
214
|
**For 'edit' action:** Provide search (code to find) and replace (code to replace with).
|
|
@@ -263,7 +263,7 @@ Example:
|
|
|
263
263
|
const newContent = content.replace(fix.search, fix.replace);
|
|
264
264
|
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
265
265
|
modifiedFiles.push(fix.path);
|
|
266
|
-
logger.info("
|
|
266
|
+
logger.info("Bug Fixer applied fix (exact match)", { path: fix.path });
|
|
267
267
|
}
|
|
268
268
|
else {
|
|
269
269
|
// Try normalized whitespace match
|
|
@@ -285,7 +285,7 @@ Example:
|
|
|
285
285
|
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
286
286
|
modifiedFiles.push(fix.path);
|
|
287
287
|
found = true;
|
|
288
|
-
logger.info("
|
|
288
|
+
logger.info("Bug Fixer applied fix (normalized match)", { path: fix.path });
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
291
|
}
|
|
@@ -302,12 +302,12 @@ Example:
|
|
|
302
302
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
303
303
|
await fs.writeFile(filePath, fix.content, 'utf-8');
|
|
304
304
|
modifiedFiles.push(fix.path);
|
|
305
|
-
logger.info("
|
|
305
|
+
logger.info("Bug Fixer created file", { path: fix.path });
|
|
306
306
|
}
|
|
307
307
|
else if (fix.action === 'delete') {
|
|
308
308
|
await fs.unlink(filePath);
|
|
309
309
|
modifiedFiles.push(fix.path);
|
|
310
|
-
logger.info("
|
|
310
|
+
logger.info("Bug Fixer deleted file", { path: fix.path });
|
|
311
311
|
}
|
|
312
312
|
else {
|
|
313
313
|
errors.push(`${fix.path}: Invalid action or missing required fields`);
|
|
@@ -331,7 +331,7 @@ Example:
|
|
|
331
331
|
content: [{ type: "text", text: JSON.stringify({
|
|
332
332
|
success: true,
|
|
333
333
|
modifiedFiles,
|
|
334
|
-
message: `Applied ${modifiedFiles.length} fix(es). Run
|
|
334
|
+
message: `Applied ${modifiedFiles.length} fix(es). Run bug_fixer_run_build to verify.`
|
|
335
335
|
}) }]
|
|
336
336
|
};
|
|
337
337
|
}
|
|
@@ -343,9 +343,9 @@ Example:
|
|
|
343
343
|
}
|
|
344
344
|
};
|
|
345
345
|
// Run Build Tool
|
|
346
|
-
exports.
|
|
347
|
-
name: "
|
|
348
|
-
group: tool_registry_1.ToolGroup.
|
|
346
|
+
exports.bugFixerRunBuildTool = {
|
|
347
|
+
name: "bug_fixer_run_build",
|
|
348
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
349
349
|
description: "Run TypeScript build to check for errors",
|
|
350
350
|
schema: zod_1.z.object({
|
|
351
351
|
appPath: zod_1.z.string().describe("Path to the app project")
|
|
@@ -365,9 +365,9 @@ exports.giuseppeRunBuildTool = {
|
|
|
365
365
|
}
|
|
366
366
|
};
|
|
367
367
|
// Git Status Tool
|
|
368
|
-
exports.
|
|
369
|
-
name: "
|
|
370
|
-
group: tool_registry_1.ToolGroup.
|
|
368
|
+
exports.bugFixerGitStatusTool = {
|
|
369
|
+
name: "bug_fixer_git_status",
|
|
370
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
371
371
|
description: "Check git status - branch, changes, sync with remote",
|
|
372
372
|
schema: zod_1.z.object({
|
|
373
373
|
appPath: zod_1.z.string().describe("Path to the app project")
|
|
@@ -395,9 +395,9 @@ exports.giuseppeGitStatusTool = {
|
|
|
395
395
|
}
|
|
396
396
|
};
|
|
397
397
|
// Git Pull Tool
|
|
398
|
-
exports.
|
|
399
|
-
name: "
|
|
400
|
-
group: tool_registry_1.ToolGroup.
|
|
398
|
+
exports.bugFixerGitPullTool = {
|
|
399
|
+
name: "bug_fixer_git_pull",
|
|
400
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
401
401
|
description: "Pull latest changes from remote",
|
|
402
402
|
schema: zod_1.z.object({
|
|
403
403
|
appPath: zod_1.z.string().describe("Path to the app project")
|
|
@@ -417,9 +417,9 @@ exports.giuseppeGitPullTool = {
|
|
|
417
417
|
}
|
|
418
418
|
};
|
|
419
419
|
// Git Commit Tool
|
|
420
|
-
exports.
|
|
421
|
-
name: "
|
|
422
|
-
group: tool_registry_1.ToolGroup.
|
|
420
|
+
exports.bugFixerGitCommitTool = {
|
|
421
|
+
name: "bug_fixer_git_commit",
|
|
422
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
423
423
|
description: "Stage all changes and commit",
|
|
424
424
|
schema: zod_1.z.object({
|
|
425
425
|
appPath: zod_1.z.string().describe("Path to the app project"),
|
|
@@ -430,7 +430,7 @@ exports.giuseppeGitCommitTool = {
|
|
|
430
430
|
(0, child_process_1.execSync)("git add -A", { cwd: args.appPath });
|
|
431
431
|
(0, child_process_1.execSync)(`git commit -m "${args.message.replace(/"/g, '\\"')}"`, { cwd: args.appPath });
|
|
432
432
|
const hash = (0, child_process_1.execSync)("git rev-parse --short HEAD", { cwd: args.appPath, encoding: "utf-8" }).trim();
|
|
433
|
-
logger.info("
|
|
433
|
+
logger.info("Bug Fixer committed", { hash, message: args.message });
|
|
434
434
|
return {
|
|
435
435
|
content: [{ type: "text", text: JSON.stringify({ success: true, hash }) }]
|
|
436
436
|
};
|
|
@@ -443,9 +443,9 @@ exports.giuseppeGitCommitTool = {
|
|
|
443
443
|
}
|
|
444
444
|
};
|
|
445
445
|
// Git Push Tool
|
|
446
|
-
exports.
|
|
447
|
-
name: "
|
|
448
|
-
group: tool_registry_1.ToolGroup.
|
|
446
|
+
exports.bugFixerGitPushTool = {
|
|
447
|
+
name: "bug_fixer_git_push",
|
|
448
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
449
449
|
description: "Push commits to remote",
|
|
450
450
|
schema: zod_1.z.object({
|
|
451
451
|
appPath: zod_1.z.string().describe("Path to the app project")
|
|
@@ -465,9 +465,9 @@ exports.giuseppeGitPushTool = {
|
|
|
465
465
|
}
|
|
466
466
|
};
|
|
467
467
|
// Git Revert Tool
|
|
468
|
-
exports.
|
|
469
|
-
name: "
|
|
470
|
-
group: tool_registry_1.ToolGroup.
|
|
468
|
+
exports.bugFixerGitRevertTool = {
|
|
469
|
+
name: "bug_fixer_git_revert",
|
|
470
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
471
471
|
description: "Discard all uncommitted changes",
|
|
472
472
|
schema: zod_1.z.object({
|
|
473
473
|
appPath: zod_1.z.string().describe("Path to the app project")
|
|
@@ -487,9 +487,9 @@ exports.giuseppeGitRevertTool = {
|
|
|
487
487
|
}
|
|
488
488
|
};
|
|
489
489
|
// Publish App Tool
|
|
490
|
-
exports.
|
|
491
|
-
name: "
|
|
492
|
-
group: tool_registry_1.ToolGroup.
|
|
490
|
+
exports.bugFixerPublishAppTool = {
|
|
491
|
+
name: "bug_fixer_publish_app",
|
|
492
|
+
group: tool_registry_1.ToolGroup.BOT_INTERNAL,
|
|
493
493
|
description: "Publish app to Hailer production - ALWAYS ASK USER FIRST",
|
|
494
494
|
schema: zod_1.z.object({
|
|
495
495
|
appPath: zod_1.z.string().describe("Path to the app project")
|
|
@@ -508,18 +508,18 @@ exports.giuseppePublishAppTool = {
|
|
|
508
508
|
}
|
|
509
509
|
};
|
|
510
510
|
// Export all tools
|
|
511
|
-
exports.
|
|
512
|
-
exports.
|
|
513
|
-
exports.
|
|
514
|
-
exports.
|
|
515
|
-
exports.
|
|
516
|
-
exports.
|
|
517
|
-
exports.
|
|
518
|
-
exports.
|
|
519
|
-
exports.
|
|
520
|
-
exports.
|
|
521
|
-
exports.
|
|
522
|
-
exports.
|
|
523
|
-
exports.
|
|
511
|
+
exports.bugFixerTools = [
|
|
512
|
+
exports.bugFixerFindAppTool,
|
|
513
|
+
exports.bugFixerListFilesTool,
|
|
514
|
+
exports.bugFixerReadFileTool,
|
|
515
|
+
exports.bugFixerWriteFileTool,
|
|
516
|
+
exports.bugFixerApplyFixTool, // New: search/replace (preferred)
|
|
517
|
+
exports.bugFixerRunBuildTool,
|
|
518
|
+
exports.bugFixerGitStatusTool,
|
|
519
|
+
exports.bugFixerGitPullTool,
|
|
520
|
+
exports.bugFixerGitCommitTool,
|
|
521
|
+
exports.bugFixerGitPushTool,
|
|
522
|
+
exports.bugFixerGitRevertTool,
|
|
523
|
+
exports.bugFixerPublishAppTool,
|
|
524
524
|
];
|
|
525
|
-
//# sourceMappingURL=
|
|
525
|
+
//# sourceMappingURL=bug-fixer-tools.js.map
|
package/dist/mcp/tools/user.js
CHANGED
|
@@ -57,15 +57,9 @@ exports.searchWorkspaceUsersTool = {
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
if (matchingUsers.length === 0) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
type: "text",
|
|
64
|
-
text: `❌ No users found matching "${args.query}" in the current workspace.\n\n` +
|
|
65
|
-
`💡 Available users:\n${context.workspaceCache.users.map((u) => `- ${u.fullName} (${u.id})`).join("\n")}`,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
};
|
|
60
|
+
const availableUsers = context.workspaceCache.users.map((u) => `- ${u.fullName} (${u.id})`).join("\n");
|
|
61
|
+
return (0, index_1.textResponse)(`❌ No users found matching "${args.query}" in the current workspace.\n\n` +
|
|
62
|
+
`💡 Available users:\n${availableUsers}`);
|
|
69
63
|
}
|
|
70
64
|
const userList = matchingUsers.map((user) => ({
|
|
71
65
|
id: user.id,
|
|
@@ -73,29 +67,16 @@ exports.searchWorkspaceUsersTool = {
|
|
|
73
67
|
firstName: user.firstname,
|
|
74
68
|
lastName: user.lastname,
|
|
75
69
|
}));
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.map((user) => `• **${user.name}**\n - ID: \`${user.id}\`\n - Use this ID for assignment or followers`)
|
|
83
|
-
.join("\n\n") +
|
|
84
|
-
`\n\n💡 Use these IDs in create_activity fields or followerIds parameters.`,
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
};
|
|
70
|
+
const formattedUsers = userList
|
|
71
|
+
.map((user) => `• **${user.name}**\n - ID: \`${user.id}\`\n - Use this ID for assignment or followers`)
|
|
72
|
+
.join("\n\n");
|
|
73
|
+
return (0, index_1.textResponse)(`✅ Found ${matchingUsers.length} user(s) matching "${args.query}":\n\n` +
|
|
74
|
+
formattedUsers +
|
|
75
|
+
`\n\n💡 Use these IDs in create_activity fields or followerIds parameters.`);
|
|
88
76
|
}
|
|
89
77
|
catch (error) {
|
|
90
78
|
logger.error("Error searching workspace users", error);
|
|
91
|
-
return {
|
|
92
|
-
content: [
|
|
93
|
-
{
|
|
94
|
-
type: "text",
|
|
95
|
-
text: `❌ Error searching users: ${(0, tool_helpers_1.extractErrorMessage)(error)}`,
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
};
|
|
79
|
+
return (0, index_1.errorResponse)(`Error searching users: ${(0, index_1.getErrorMessage)(error)}`);
|
|
99
80
|
}
|
|
100
81
|
},
|
|
101
82
|
};
|
|
@@ -64,6 +64,15 @@ exports.getWorkflowSchemaTool = {
|
|
|
64
64
|
}),
|
|
65
65
|
async execute(args, context) {
|
|
66
66
|
try {
|
|
67
|
+
// Validate phaseId format early - must be 24-char MongoDB ID, not a simple number
|
|
68
|
+
if (args.phaseId && args.phaseId.length !== 24) {
|
|
69
|
+
return {
|
|
70
|
+
content: [{
|
|
71
|
+
type: "text",
|
|
72
|
+
text: `Invalid phaseId "${args.phaseId}" - must be a 24-character ID.\n\n**How to get valid phase IDs:**\n1. Call \`list_workflow_phases\` with the workflowId first\n2. Use the returned phase IDs (24 characters like "691ffdf84217e9e8434e56a5")\n\n**Example:**\n\`\`\`\nlist_workflow_phases({ workflowId: "${args.workflowId}" })\n\`\`\``,
|
|
73
|
+
}],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
67
76
|
// Use cached workflow data from context.init (already fetched during initialization)
|
|
68
77
|
const workflow = context.init.processes?.find(p => p._id === args.workflowId);
|
|
69
78
|
if (!workflow) {
|
|
@@ -352,7 +361,9 @@ exports.listWorkflowsTool = {
|
|
|
352
361
|
// ============================================================================
|
|
353
362
|
// TOOL 1: INSTALL WORKFLOW
|
|
354
363
|
// ============================================================================
|
|
355
|
-
const installWorkflowDescription = `Install workflow from template
|
|
364
|
+
const installWorkflowDescription = `Install workflow from template
|
|
365
|
+
|
|
366
|
+
**Field types:** text, textarea, numeric, numericunit, date, datetime, textpredefinedoptions (for dropdowns - NOT 'select'!), activitylink, users, teams, country, subheader`;
|
|
356
367
|
const installWorkflowSchema = zod_1.z.object({
|
|
357
368
|
workspaceId: zod_1.z
|
|
358
369
|
.string()
|
|
@@ -377,7 +388,7 @@ const installWorkflowSchema = zod_1.z.object({
|
|
|
377
388
|
]).describe("Field type"),
|
|
378
389
|
key: zod_1.z.string().optional().describe("Readable field name (like SQL column name) - RECOMMENDED"),
|
|
379
390
|
required: zod_1.z.boolean().optional().describe("Whether field is required"),
|
|
380
|
-
data: zod_1.z.array(zod_1.z.string()).optional().describe("For
|
|
391
|
+
data: zod_1.z.array(zod_1.z.string()).optional().describe("For textpredefinedoptions: string array like [\"Low\", \"Medium\", \"High\"]. For activitylink: target workflow IDs"),
|
|
381
392
|
placeholder: zod_1.z.string().optional().describe("Placeholder text"),
|
|
382
393
|
unit: zod_1.z.string().optional().describe("Unit for numeric/textunit fields"),
|
|
383
394
|
description: zod_1.z.string().optional().describe("Field description"),
|
|
@@ -440,6 +451,20 @@ exports.installWorkflowTool = {
|
|
|
440
451
|
args.workflowTemplates
|
|
441
452
|
]);
|
|
442
453
|
logger.debug('Workflow installation successful', { result });
|
|
454
|
+
// Refresh context.init.processes cache so new workflows are immediately available
|
|
455
|
+
try {
|
|
456
|
+
const freshInit = await context.client.socket.request('v2.core.init', [['processes']]);
|
|
457
|
+
if (freshInit.processes) {
|
|
458
|
+
context.init.processes = freshInit.processes;
|
|
459
|
+
logger.info('Refreshed workflow cache after installation', {
|
|
460
|
+
workflowCount: freshInit.processes.length
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
catch (refreshError) {
|
|
465
|
+
logger.warn('Failed to refresh workflow cache after installation', { error: refreshError });
|
|
466
|
+
// Non-fatal - the workflow was created, just cache is stale
|
|
467
|
+
}
|
|
443
468
|
// Build success response
|
|
444
469
|
let responseText = `✅ **Workflow Installation Successful**\n\n`;
|
|
445
470
|
responseText += `**Workspace:** ${workspaceId}\n`;
|
|
@@ -1217,6 +1242,15 @@ exports.updateWorkflowPhaseTool = {
|
|
|
1217
1242
|
apiKey: context.apiKey.substring(0, 8) + '...'
|
|
1218
1243
|
});
|
|
1219
1244
|
try {
|
|
1245
|
+
// Validate phaseId format early - must be 24-char MongoDB ID, not a simple number
|
|
1246
|
+
if (args.phaseId && args.phaseId.length !== 24) {
|
|
1247
|
+
return {
|
|
1248
|
+
content: [{
|
|
1249
|
+
type: "text",
|
|
1250
|
+
text: `Invalid phaseId "${args.phaseId}" - must be a 24-character ID.\n\n**How to get valid phase IDs:**\n1. Call \`list_workflow_phases\` with the workflowId first\n2. Use the returned phase IDs (24 characters like "691ffdf84217e9e8434e56a5")\n\n**Example:**\n\`\`\`\nlist_workflow_phases({ workflowId: "${args.workflowId}" })\n\`\`\``,
|
|
1251
|
+
}],
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1220
1254
|
// Get current workspace from cached init data
|
|
1221
1255
|
let workspaceId = args.workspaceId;
|
|
1222
1256
|
if (!workspaceId) {
|
|
@@ -87,16 +87,8 @@ export declare function formatTimestamp(timestamp: number | string | Date): stri
|
|
|
87
87
|
* Formats user name from user info
|
|
88
88
|
*/
|
|
89
89
|
export declare function formatUserName(user: UserInfo | undefined, fallbackId: string): string;
|
|
90
|
-
/**
|
|
91
|
-
* Gets the first phase ID from workflow (for defaults)
|
|
92
|
-
*/
|
|
93
|
-
export declare function getFirstPhaseId(workflow: WorkflowInfo): string | null;
|
|
94
90
|
/**
|
|
95
91
|
* Formats activity data for MCP response
|
|
96
92
|
*/
|
|
97
93
|
export declare function formatActivityListResponse(activities: CleanActivity[], workflow: WorkflowInfo, phaseName?: string): string;
|
|
98
|
-
/**
|
|
99
|
-
* Creates a simplified activity format for search results
|
|
100
|
-
*/
|
|
101
|
-
export declare function transformActivityForSearch(activity: any): any;
|
|
102
94
|
//# sourceMappingURL=data-transformers.d.ts.map
|
|
@@ -14,9 +14,7 @@ exports.transformPhases = transformPhases;
|
|
|
14
14
|
exports.transformWorkflowFields = transformWorkflowFields;
|
|
15
15
|
exports.formatTimestamp = formatTimestamp;
|
|
16
16
|
exports.formatUserName = formatUserName;
|
|
17
|
-
exports.getFirstPhaseId = getFirstPhaseId;
|
|
18
17
|
exports.formatActivityListResponse = formatActivityListResponse;
|
|
19
|
-
exports.transformActivityForSearch = transformActivityForSearch;
|
|
20
18
|
/**
|
|
21
19
|
* Transforms raw activity data into clean, structured format
|
|
22
20
|
*/
|
|
@@ -157,13 +155,6 @@ function formatUserName(user, fallbackId) {
|
|
|
157
155
|
const fullName = `${user.firstname || ''} ${user.lastname || ''}`.trim();
|
|
158
156
|
return fullName || user.email || `User ${fallbackId}`;
|
|
159
157
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Gets the first phase ID from workflow (for defaults)
|
|
162
|
-
*/
|
|
163
|
-
function getFirstPhaseId(workflow) {
|
|
164
|
-
const phases = Object.values(workflow.phases);
|
|
165
|
-
return phases.length > 0 ? phases[0]._id : null;
|
|
166
|
-
}
|
|
167
158
|
/**
|
|
168
159
|
* Formats activity data for MCP response
|
|
169
160
|
*/
|
|
@@ -172,23 +163,4 @@ function formatActivityListResponse(activities, workflow, phaseName) {
|
|
|
172
163
|
const phaseInfo = phaseName ? ` (phase: ${phaseName})` : '';
|
|
173
164
|
return `✅ Found ${count} activities in workflow "${workflow.name}"${phaseInfo}\n\n${JSON.stringify(activities, null, 2)}`;
|
|
174
165
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Creates a simplified activity format for search results
|
|
177
|
-
*/
|
|
178
|
-
function transformActivityForSearch(activity) {
|
|
179
|
-
return {
|
|
180
|
-
_id: activity._id,
|
|
181
|
-
name: activity.name,
|
|
182
|
-
workflow: {
|
|
183
|
-
_id: activity.process?._id,
|
|
184
|
-
name: activity.process?.name,
|
|
185
|
-
},
|
|
186
|
-
currentPhase: {
|
|
187
|
-
_id: activity.currentPhase?._id,
|
|
188
|
-
name: activity.currentPhase?.name,
|
|
189
|
-
},
|
|
190
|
-
created: activity.created?.humanReadable,
|
|
191
|
-
updated: activity.updated?.humanReadable,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
166
|
//# sourceMappingURL=data-transformers.js.map
|
|
@@ -8,6 +8,9 @@ export { HailerApiError, makeApiCall, handleApiResponse, createErrorResponse, cr
|
|
|
8
8
|
export type { ApiCallOptions } from './api-errors';
|
|
9
9
|
export { HailerApiClient } from './hailer-api-client';
|
|
10
10
|
export type { RestCallConfig } from './hailer-api-client';
|
|
11
|
-
export { transformActivity, transformActivities, transformFields, transformFieldValue, findFieldByKey, transformWorkflow, transformPhases, transformWorkflowFields, formatTimestamp, formatUserName,
|
|
11
|
+
export { transformActivity, transformActivities, transformFields, transformFieldValue, findFieldByKey, transformWorkflow, transformPhases, transformWorkflowFields, formatTimestamp, formatUserName, formatActivityListResponse, } from './data-transformers';
|
|
12
|
+
export { textResponse, errorResponse, successResponse, jsonResponse, paginatedResponse, listResponse, getErrorMessage, withErrorHandling, isErrorResponse } from './response-builder';
|
|
13
|
+
export { normalizePagination, calculatePaginationMeta, formatPaginationText } from './pagination';
|
|
14
|
+
export type { PaginationMeta, PaginationOptions } from './pagination';
|
|
12
15
|
export type * from './types';
|
|
13
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mcp/utils/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides centralized access to all utility functions and types
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.formatPaginationText = exports.calculatePaginationMeta = exports.normalizePagination = exports.isErrorResponse = exports.withErrorHandling = exports.getErrorMessage = exports.listResponse = exports.paginatedResponse = exports.jsonResponse = exports.successResponse = exports.errorResponse = exports.textResponse = exports.formatActivityListResponse = exports.formatUserName = exports.formatTimestamp = exports.transformWorkflowFields = exports.transformPhases = exports.transformWorkflow = exports.findFieldByKey = exports.transformFieldValue = exports.transformFields = exports.transformActivities = exports.transformActivity = exports.HailerApiClient = exports.createSuccessResponse = exports.createErrorResponse = exports.handleApiResponse = exports.makeApiCall = exports.HailerApiError = exports.LogTag = exports.LogLevel = exports.logger = exports.createLogger = void 0;
|
|
8
8
|
// Logging utilities
|
|
9
9
|
var logger_1 = require("../../lib/logger");
|
|
10
10
|
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_1.createLogger; } });
|
|
@@ -33,7 +33,21 @@ Object.defineProperty(exports, "transformPhases", { enumerable: true, get: funct
|
|
|
33
33
|
Object.defineProperty(exports, "transformWorkflowFields", { enumerable: true, get: function () { return data_transformers_1.transformWorkflowFields; } });
|
|
34
34
|
Object.defineProperty(exports, "formatTimestamp", { enumerable: true, get: function () { return data_transformers_1.formatTimestamp; } });
|
|
35
35
|
Object.defineProperty(exports, "formatUserName", { enumerable: true, get: function () { return data_transformers_1.formatUserName; } });
|
|
36
|
-
Object.defineProperty(exports, "getFirstPhaseId", { enumerable: true, get: function () { return data_transformers_1.getFirstPhaseId; } });
|
|
37
36
|
Object.defineProperty(exports, "formatActivityListResponse", { enumerable: true, get: function () { return data_transformers_1.formatActivityListResponse; } });
|
|
38
|
-
|
|
37
|
+
// Response builders
|
|
38
|
+
var response_builder_1 = require("./response-builder");
|
|
39
|
+
Object.defineProperty(exports, "textResponse", { enumerable: true, get: function () { return response_builder_1.textResponse; } });
|
|
40
|
+
Object.defineProperty(exports, "errorResponse", { enumerable: true, get: function () { return response_builder_1.errorResponse; } });
|
|
41
|
+
Object.defineProperty(exports, "successResponse", { enumerable: true, get: function () { return response_builder_1.successResponse; } });
|
|
42
|
+
Object.defineProperty(exports, "jsonResponse", { enumerable: true, get: function () { return response_builder_1.jsonResponse; } });
|
|
43
|
+
Object.defineProperty(exports, "paginatedResponse", { enumerable: true, get: function () { return response_builder_1.paginatedResponse; } });
|
|
44
|
+
Object.defineProperty(exports, "listResponse", { enumerable: true, get: function () { return response_builder_1.listResponse; } });
|
|
45
|
+
Object.defineProperty(exports, "getErrorMessage", { enumerable: true, get: function () { return response_builder_1.getErrorMessage; } });
|
|
46
|
+
Object.defineProperty(exports, "withErrorHandling", { enumerable: true, get: function () { return response_builder_1.withErrorHandling; } });
|
|
47
|
+
Object.defineProperty(exports, "isErrorResponse", { enumerable: true, get: function () { return response_builder_1.isErrorResponse; } });
|
|
48
|
+
// Pagination utilities
|
|
49
|
+
var pagination_1 = require("./pagination");
|
|
50
|
+
Object.defineProperty(exports, "normalizePagination", { enumerable: true, get: function () { return pagination_1.normalizePagination; } });
|
|
51
|
+
Object.defineProperty(exports, "calculatePaginationMeta", { enumerable: true, get: function () { return pagination_1.calculatePaginationMeta; } });
|
|
52
|
+
Object.defineProperty(exports, "formatPaginationText", { enumerable: true, get: function () { return pagination_1.formatPaginationText; } });
|
|
39
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination Helper Utility
|
|
3
|
+
*
|
|
4
|
+
* Centralized pagination logic for MCP tools.
|
|
5
|
+
*/
|
|
6
|
+
export interface PaginationMeta {
|
|
7
|
+
currentPage: number;
|
|
8
|
+
pageSize: number;
|
|
9
|
+
totalItems?: number;
|
|
10
|
+
totalPages?: number;
|
|
11
|
+
hasNextPage: boolean;
|
|
12
|
+
hasPrevPage: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface PaginationOptions {
|
|
15
|
+
page?: number;
|
|
16
|
+
limit?: number;
|
|
17
|
+
defaultLimit?: number;
|
|
18
|
+
maxLimit?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Normalize pagination options with defaults
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizePagination(options?: PaginationOptions): {
|
|
24
|
+
page: number;
|
|
25
|
+
limit: number;
|
|
26
|
+
offset: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Calculate pagination metadata from results
|
|
30
|
+
*/
|
|
31
|
+
export declare function calculatePaginationMeta(itemCount: number, options: {
|
|
32
|
+
page: number;
|
|
33
|
+
limit: number;
|
|
34
|
+
totalCount?: number;
|
|
35
|
+
}): PaginationMeta;
|
|
36
|
+
/**
|
|
37
|
+
* Format pagination info as markdown text
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatPaginationText(meta: PaginationMeta): string;
|
|
40
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pagination Helper Utility
|
|
4
|
+
*
|
|
5
|
+
* Centralized pagination logic for MCP tools.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.normalizePagination = normalizePagination;
|
|
9
|
+
exports.calculatePaginationMeta = calculatePaginationMeta;
|
|
10
|
+
exports.formatPaginationText = formatPaginationText;
|
|
11
|
+
/**
|
|
12
|
+
* Normalize pagination options with defaults
|
|
13
|
+
*/
|
|
14
|
+
function normalizePagination(options = {}) {
|
|
15
|
+
const { page = 0, limit, defaultLimit = 50, maxLimit = 1000 } = options;
|
|
16
|
+
const normalizedLimit = Math.min(limit ?? defaultLimit, maxLimit);
|
|
17
|
+
const normalizedPage = Math.max(0, page);
|
|
18
|
+
return {
|
|
19
|
+
page: normalizedPage,
|
|
20
|
+
limit: normalizedLimit,
|
|
21
|
+
offset: normalizedPage * normalizedLimit
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Calculate pagination metadata from results
|
|
26
|
+
*/
|
|
27
|
+
function calculatePaginationMeta(itemCount, options) {
|
|
28
|
+
const { page, limit, totalCount } = options;
|
|
29
|
+
const totalPages = totalCount !== undefined
|
|
30
|
+
? Math.ceil(totalCount / limit)
|
|
31
|
+
: undefined;
|
|
32
|
+
return {
|
|
33
|
+
currentPage: page,
|
|
34
|
+
pageSize: limit,
|
|
35
|
+
totalItems: totalCount,
|
|
36
|
+
totalPages,
|
|
37
|
+
hasNextPage: itemCount === limit,
|
|
38
|
+
hasPrevPage: page > 0
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Format pagination info as markdown text
|
|
43
|
+
*/
|
|
44
|
+
function formatPaginationText(meta) {
|
|
45
|
+
const lines = [
|
|
46
|
+
`📊 **Page ${meta.currentPage + 1}${meta.totalPages ? ` of ${meta.totalPages}` : ''}**`,
|
|
47
|
+
`- Items on page: ${meta.pageSize}`,
|
|
48
|
+
];
|
|
49
|
+
if (meta.totalItems !== undefined) {
|
|
50
|
+
lines.push(`- Total items: ${meta.totalItems}`);
|
|
51
|
+
}
|
|
52
|
+
lines.push(`- Has more: ${meta.hasNextPage ? 'Yes (increase page number)' : 'No'}`);
|
|
53
|
+
return lines.join('\n');
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=pagination.js.map
|