bunqueue 2.4.8 → 2.5.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/README.md +45 -1
- package/dist/infrastructure/backup/s3BackupOperations.d.ts.map +1 -1
- package/dist/infrastructure/backup/s3BackupOperations.js +3 -1
- package/dist/infrastructure/backup/s3BackupOperations.js.map +1 -1
- package/dist/mcp/adapter.d.ts +341 -0
- package/dist/mcp/adapter.d.ts.map +1 -0
- package/dist/mcp/adapter.js +695 -0
- package/dist/mcp/adapter.js.map +1 -0
- package/dist/mcp/index.d.ts +26 -4
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +68 -87
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/resources.d.ts +8 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +96 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/tools/consumptionTools.d.ts +8 -0
- package/dist/mcp/tools/consumptionTools.d.ts.map +1 -0
- package/dist/mcp/tools/consumptionTools.js +95 -0
- package/dist/mcp/tools/consumptionTools.js.map +1 -0
- package/dist/mcp/tools/cronTools.d.ts +7 -0
- package/dist/mcp/tools/cronTools.d.ts.map +1 -0
- package/dist/mcp/tools/cronTools.js +52 -0
- package/dist/mcp/tools/cronTools.js.map +1 -0
- package/dist/mcp/tools/dlqTools.d.ts +7 -0
- package/dist/mcp/tools/dlqTools.d.ts.map +1 -0
- package/dist/mcp/tools/dlqTools.js +58 -0
- package/dist/mcp/tools/dlqTools.js.map +1 -0
- package/dist/mcp/tools/jobMgmtTools.d.ts +8 -0
- package/dist/mcp/tools/jobMgmtTools.d.ts.map +1 -0
- package/dist/mcp/tools/jobMgmtTools.js +62 -0
- package/dist/mcp/tools/jobMgmtTools.js.map +1 -0
- package/dist/mcp/tools/jobTools.d.ts +8 -0
- package/dist/mcp/tools/jobTools.d.ts.map +1 -0
- package/dist/mcp/tools/jobTools.js +115 -0
- package/dist/mcp/tools/jobTools.js.map +1 -0
- package/dist/mcp/tools/monitoringTools.d.ts +7 -0
- package/dist/mcp/tools/monitoringTools.d.ts.map +1 -0
- package/dist/mcp/tools/monitoringTools.js +93 -0
- package/dist/mcp/tools/monitoringTools.js.map +1 -0
- package/dist/mcp/tools/queueTools.d.ts +8 -0
- package/dist/mcp/tools/queueTools.d.ts.map +1 -0
- package/dist/mcp/tools/queueTools.js +126 -0
- package/dist/mcp/tools/queueTools.js.map +1 -0
- package/dist/mcp/tools/rateLimitTools.d.ts +7 -0
- package/dist/mcp/tools/rateLimitTools.d.ts.map +1 -0
- package/dist/mcp/tools/rateLimitTools.js +63 -0
- package/dist/mcp/tools/rateLimitTools.js.map +1 -0
- package/dist/mcp/tools/webhookTools.d.ts +7 -0
- package/dist/mcp/tools/webhookTools.d.ts.map +1 -0
- package/dist/mcp/tools/webhookTools.js +56 -0
- package/dist/mcp/tools/webhookTools.js.map +1 -0
- package/dist/mcp/tools/withErrorHandler.d.ts +21 -0
- package/dist/mcp/tools/withErrorHandler.d.ts.map +1 -0
- package/dist/mcp/tools/withErrorHandler.js +24 -0
- package/dist/mcp/tools/withErrorHandler.js.map +1 -0
- package/dist/mcp/tools/workerMgmtTools.d.ts +8 -0
- package/dist/mcp/tools/workerMgmtTools.d.ts.map +1 -0
- package/dist/mcp/tools/workerMgmtTools.js +33 -0
- package/dist/mcp/tools/workerMgmtTools.js.map +1 -0
- package/package.json +15 -13
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
+
/**
|
|
3
|
+
* MCP Tools - Rate Limiting & Concurrency Control
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { withErrorHandler } from './withErrorHandler';
|
|
7
|
+
export function registerRateLimitTools(server, backend) {
|
|
8
|
+
server.tool('bunqueue_set_rate_limit', 'Set rate limit for a queue (max jobs processed per second).', {
|
|
9
|
+
queue: z.string().describe('Queue name'),
|
|
10
|
+
limit: z.number().min(1).describe('Max jobs per second'),
|
|
11
|
+
}, withErrorHandler(async ({ queue, limit }) => {
|
|
12
|
+
await backend.setRateLimit(queue, limit);
|
|
13
|
+
return {
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
type: 'text',
|
|
17
|
+
text: JSON.stringify({ success: true, queue, rateLimit: limit }),
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
}));
|
|
22
|
+
server.tool('bunqueue_clear_rate_limit', 'Remove rate limit from a queue, allowing unlimited throughput.', {
|
|
23
|
+
queue: z.string().describe('Queue name'),
|
|
24
|
+
}, withErrorHandler(async ({ queue }) => {
|
|
25
|
+
await backend.clearRateLimit(queue);
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: JSON.stringify({ success: true, queue, message: 'Rate limit cleared' }),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}));
|
|
35
|
+
server.tool('bunqueue_set_concurrency', 'Set concurrency limit for a queue (max simultaneous active jobs).', {
|
|
36
|
+
queue: z.string().describe('Queue name'),
|
|
37
|
+
limit: z.number().min(1).describe('Max concurrent jobs'),
|
|
38
|
+
}, withErrorHandler(async ({ queue, limit }) => {
|
|
39
|
+
await backend.setConcurrency(queue, limit);
|
|
40
|
+
return {
|
|
41
|
+
content: [
|
|
42
|
+
{
|
|
43
|
+
type: 'text',
|
|
44
|
+
text: JSON.stringify({ success: true, queue, concurrency: limit }),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}));
|
|
49
|
+
server.tool('bunqueue_clear_concurrency', 'Remove concurrency limit from a queue.', {
|
|
50
|
+
queue: z.string().describe('Queue name'),
|
|
51
|
+
}, withErrorHandler(async ({ queue }) => {
|
|
52
|
+
await backend.clearConcurrency(queue);
|
|
53
|
+
return {
|
|
54
|
+
content: [
|
|
55
|
+
{
|
|
56
|
+
type: 'text',
|
|
57
|
+
text: JSON.stringify({ success: true, queue, message: 'Concurrency limit cleared' }),
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=rateLimitTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimitTools.js","sourceRoot":"","sources":["../../../src/mcp/tools/rateLimitTools.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,UAAU,sBAAsB,CAAC,MAAiB,EAAE,OAAmB;IAC3E,MAAM,CAAC,IAAI,CACT,yBAAyB,EACzB,6DAA6D,EAC7D;QACE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;QACxC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC;KACzD,EACD,gBAAgB,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1C,MAAM,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACzC,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iBACjE;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,2BAA2B,EAC3B,gEAAgE,EAChE;QACE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY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AAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;iBACrF;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools - Webhook Management
|
|
3
|
+
*/
|
|
4
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { McpBackend } from '../adapter';
|
|
6
|
+
export declare function registerWebhookTools(server: McpServer, backend: McpBackend): void;
|
|
7
|
+
//# sourceMappingURL=webhookTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhookTools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/webhookTools.ts"],"names":[],"mappings":"AACA;;GAEG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,QAyE1E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
+
/**
|
|
3
|
+
* MCP Tools - Webhook Management
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { withErrorHandler } from './withErrorHandler';
|
|
7
|
+
export function registerWebhookTools(server, backend) {
|
|
8
|
+
server.tool('bunqueue_add_webhook', 'Add a webhook to receive notifications for job events.', {
|
|
9
|
+
url: z.url().describe('Webhook URL to receive POST requests'),
|
|
10
|
+
events: z
|
|
11
|
+
.array(z.enum([
|
|
12
|
+
'job.completed',
|
|
13
|
+
'job.failed',
|
|
14
|
+
'job.progress',
|
|
15
|
+
'job.active',
|
|
16
|
+
'job.waiting',
|
|
17
|
+
'job.delayed',
|
|
18
|
+
]))
|
|
19
|
+
.describe('Events to subscribe to'),
|
|
20
|
+
queue: z.string().optional().describe('Limit to a specific queue (omit for all queues)'),
|
|
21
|
+
}, withErrorHandler(async ({ url, events, queue }) => {
|
|
22
|
+
const webhook = await backend.addWebhook(url, events, queue);
|
|
23
|
+
return {
|
|
24
|
+
content: [
|
|
25
|
+
{ type: 'text', text: JSON.stringify({ success: true, ...webhook }, null, 2) },
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}));
|
|
29
|
+
server.tool('bunqueue_remove_webhook', 'Remove a webhook by ID.', {
|
|
30
|
+
id: z.string().describe('Webhook ID to remove'),
|
|
31
|
+
}, withErrorHandler(async ({ id }) => {
|
|
32
|
+
const success = await backend.removeWebhook(id);
|
|
33
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success, id }) }] };
|
|
34
|
+
}));
|
|
35
|
+
server.tool('bunqueue_list_webhooks', 'List all registered webhooks.', {}, withErrorHandler(async () => {
|
|
36
|
+
const webhooks = await backend.listWebhooks();
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: 'text',
|
|
41
|
+
text: JSON.stringify({ count: webhooks.length, webhooks }, null, 2),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}));
|
|
46
|
+
server.tool('bunqueue_set_webhook_enabled', 'Enable or disable a webhook without removing it.', {
|
|
47
|
+
id: z.string().describe('Webhook ID'),
|
|
48
|
+
enabled: z.boolean().describe('Whether the webhook should be enabled'),
|
|
49
|
+
}, withErrorHandler(async ({ id, enabled }) => {
|
|
50
|
+
const success = await backend.setWebhookEnabled(id, enabled);
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: 'text', text: JSON.stringify({ success, id, enabled }) }],
|
|
53
|
+
};
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=webhookTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhookTools.js","sourceRoot":"","sources":["../../../src/mcp/tools/webhookTools.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,OAAmB;IACzE,MAAM,CAAC,IAAI,CACT,sBAAsB,EACtB,wDAAwD,EACxD;QACE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;QAC7D,MAAM,EAAE,CAAC;aACN,KAAK,CACJ,CAAC,CAAC,IAAI,CAAC;YACL,eAAe;YACf,YAAY;YACZ,cAAc;YACd,YAAY;YACZ,aAAa;YACb,aAAa;SACd,CAAC,CACH;aACA,QAAQ,CAAC,wBAAwB,CAAC;QACrC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;KACzF,EACD,gBAAgB,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;QAChD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAC7D,OAAO;YACL,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;aACxF;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,yBAAyB,EACzB,yBAAyB,EACzB;QACE,EAAE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Ae,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;SACrF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Error Handler
|
|
3
|
+
* Wraps tool handlers with try/catch to return proper MCP error responses.
|
|
4
|
+
*/
|
|
5
|
+
/** MCP tool result compatible with SDK's expected return type */
|
|
6
|
+
interface ToolResult {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: 'text';
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
isError?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Wraps an MCP tool handler with error handling.
|
|
16
|
+
* Catches exceptions and returns a proper MCP error response with isError: true
|
|
17
|
+
* instead of letting raw stack traces propagate to the AI agent.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withErrorHandler<T>(fn: (args: T) => Promise<ToolResult>): (args: T) => Promise<ToolResult>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=withErrorHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withErrorHandler.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/withErrorHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iEAAiE;AACjE,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,GACnC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAYlC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Error Handler
|
|
3
|
+
* Wraps tool handlers with try/catch to return proper MCP error responses.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Wraps an MCP tool handler with error handling.
|
|
7
|
+
* Catches exceptions and returns a proper MCP error response with isError: true
|
|
8
|
+
* instead of letting raw stack traces propagate to the AI agent.
|
|
9
|
+
*/
|
|
10
|
+
export function withErrorHandler(fn) {
|
|
11
|
+
return async (args) => {
|
|
12
|
+
try {
|
|
13
|
+
return await fn(args);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
17
|
+
return {
|
|
18
|
+
content: [{ type: 'text', text: JSON.stringify({ error: message }) }],
|
|
19
|
+
isError: true,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=withErrorHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withErrorHandler.js","sourceRoot":"","sources":["../../../src/mcp/tools/withErrorHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,EAAoC;IAEpC,OAAO,KAAK,EAAE,IAAO,EAAE,EAAE;QACvB,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;gBAC9E,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools - Worker Management
|
|
3
|
+
* Register, unregister, heartbeat workers
|
|
4
|
+
*/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import type { McpBackend } from '../adapter';
|
|
7
|
+
export declare function registerWorkerMgmtTools(server: McpServer, backend: McpBackend): void;
|
|
8
|
+
//# sourceMappingURL=workerMgmtTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerMgmtTools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/workerMgmtTools.ts"],"names":[],"mappings":"AACA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,QAyC7E"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
+
/**
|
|
3
|
+
* MCP Tools - Worker Management
|
|
4
|
+
* Register, unregister, heartbeat workers
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { withErrorHandler } from './withErrorHandler';
|
|
8
|
+
export function registerWorkerMgmtTools(server, backend) {
|
|
9
|
+
server.tool('bunqueue_register_worker', 'Register a new worker to process jobs from specified queues.', {
|
|
10
|
+
name: z.string().describe('Worker name/identifier'),
|
|
11
|
+
queues: z.array(z.string()).min(1).describe('Queues this worker will process'),
|
|
12
|
+
}, withErrorHandler(async ({ name, queues }) => {
|
|
13
|
+
const worker = await backend.registerWorker(name, queues);
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{ type: 'text', text: JSON.stringify({ success: true, worker }, null, 2) },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}));
|
|
20
|
+
server.tool('bunqueue_unregister_worker', 'Unregister a worker, removing it from the active workers list.', {
|
|
21
|
+
workerId: z.string().describe('Worker ID to unregister'),
|
|
22
|
+
}, withErrorHandler(async ({ workerId }) => {
|
|
23
|
+
const success = await backend.unregisterWorker(workerId);
|
|
24
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success, workerId }) }] };
|
|
25
|
+
}));
|
|
26
|
+
server.tool('bunqueue_worker_heartbeat', 'Send a heartbeat to keep a registered worker alive.', {
|
|
27
|
+
workerId: z.string().describe('Worker ID'),
|
|
28
|
+
}, withErrorHandler(async ({ workerId }) => {
|
|
29
|
+
const success = await backend.workerHeartbeat(workerId);
|
|
30
|
+
return { content: [{ type: 'text', text: JSON.stringify({ success, workerId }) }] };
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=workerMgmtTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerMgmtTools.js","sourceRoot":"","sources":["../../../src/mcp/tools/workerMgmtTools.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,UAAU,uBAAuB,CAAC,MAAiB,EAAE,OAAmB;IAC5E,MAAM,CAAC,IAAI,CACT,0BAA0B,EAC1B,8DAA8D,EAC9D;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACnD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CA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OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/F,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunqueue",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "High-performance job queue
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "High-performance job queue for Bun & AI agents. SQLite persistence, cron scheduling, priorities, retries, DLQ, webhooks, native MCP server. Zero external dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"types": "dist/main.d.ts",
|
|
@@ -58,23 +58,25 @@
|
|
|
58
58
|
"prepublishOnly": "bun run build:lib"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"
|
|
62
|
-
"croner": "^
|
|
61
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
62
|
+
"croner": "^10.0.1",
|
|
63
|
+
"msgpackr": "^1.11.8",
|
|
64
|
+
"zod": "^4.3.6"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
|
-
"@eslint/js": "^
|
|
66
|
-
"@types/bun": "
|
|
67
|
-
"bullmq": "^5.
|
|
68
|
-
"elysia": "^1.4.
|
|
69
|
-
"eslint": "^
|
|
67
|
+
"@eslint/js": "^10.0.1",
|
|
68
|
+
"@types/bun": "^1.3.9",
|
|
69
|
+
"bullmq": "^5.70.1",
|
|
70
|
+
"elysia": "^1.4.25",
|
|
71
|
+
"eslint": "^10.0.1",
|
|
70
72
|
"eslint-config-prettier": "^10.1.8",
|
|
71
|
-
"ioredis": "^5.9.
|
|
73
|
+
"ioredis": "^5.9.3",
|
|
72
74
|
"prettier": "^3.8.1",
|
|
73
|
-
"typescript": "^5.
|
|
74
|
-
"typescript-eslint": "^8.
|
|
75
|
+
"typescript": "^5.9.3",
|
|
76
|
+
"typescript-eslint": "^8.56.1"
|
|
75
77
|
},
|
|
76
78
|
"peerDependencies": {
|
|
77
|
-
"bun": "
|
|
79
|
+
"bun": "^1.3.9"
|
|
78
80
|
},
|
|
79
81
|
"keywords": [
|
|
80
82
|
"bun",
|