network-ai 3.9.0 → 4.0.0

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![CI](https://github.com/jovanSAPFIONEER/Network-AI/actions/workflows/ci.yml/badge.svg)](https://github.com/jovanSAPFIONEER/Network-AI/actions/workflows/ci.yml)
6
6
  [![CodeQL](https://github.com/jovanSAPFIONEER/Network-AI/actions/workflows/codeql.yml/badge.svg)](https://github.com/jovanSAPFIONEER/Network-AI/actions/workflows/codeql.yml)
7
- [![Release](https://img.shields.io/badge/release-v3.9.0-blue.svg)](https://github.com/jovanSAPFIONEER/Network-AI/releases)
7
+ [![Release](https://img.shields.io/badge/release-v4.0.0-blue.svg)](https://github.com/jovanSAPFIONEER/Network-AI/releases)
8
8
  [![npm](https://img.shields.io/npm/dw/network-ai.svg?label=npm%20downloads)](https://www.npmjs.com/package/network-ai)
9
9
  [![ClawHub](https://img.shields.io/badge/ClawHub-network--ai-orange.svg)](https://clawhub.ai/skills/network-ai)
10
10
  [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org)
@@ -13,7 +13,7 @@
13
13
  [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
14
14
  [![Socket](https://socket.dev/api/badge/npm/package/network-ai)](https://socket.dev/npm/package/network-ai/overview)
15
15
  [![AgentSkills](https://img.shields.io/badge/AgentSkills-compatible-orange.svg)](https://agentskills.io)
16
- [![Tests](https://img.shields.io/badge/tests-1095%20passing-brightgreen.svg)](#testing)
16
+ [![Tests](https://img.shields.io/badge/tests-1216%20passing-brightgreen.svg)](#testing)
17
17
  [![Adapters](https://img.shields.io/badge/frameworks-12%20supported-blueviolet.svg)](#adapter-system)
18
18
  [![RSS Feed](https://img.shields.io/badge/RSS-releases-orange?logo=rss)](https://github.com/jovanSAPFIONEER/Network-AI/releases.atom)
19
19
 
@@ -0,0 +1,266 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Network-AI MCP Server — Phase 6 Part 3
4
+ *
5
+ * Starts an HTTP/SSE server that exposes the full Network-AI tool suite to
6
+ * any MCP-compatible AI agent (Claude Desktop, Cursor, Cline, etc.).
7
+ *
8
+ * Usage:
9
+ * npx ts-node bin/mcp-server.ts [options]
10
+ * npx network-ai-server [options] (after clawhub publish)
11
+ *
12
+ * Options:
13
+ * --port <n> TCP port to listen on (default: 3001)
14
+ * --host <h> Hostname to bind to (default: 0.0.0.0)
15
+ * --board <name> Named blackboard to expose (default: main)
16
+ * --ceiling <n> Initial FederatedBudget token ceiling (default: 1_000_000)
17
+ * --no-budget Disable budget tools
18
+ * --no-token Disable token tools
19
+ * --no-extended Disable all extended tools (budget + token + audit)
20
+ * --no-control Disable control-plane tools
21
+ * --audit-log <path> Path to audit log file (default: ./data/audit_log.jsonl)
22
+ * --heartbeat <ms> SSE heartbeat interval in ms (default: 15000)
23
+ * --help Print this help text
24
+ *
25
+ * Connect any MCP client to:
26
+ * http://localhost:3001 (SSE stream — GET /sse)
27
+ * http://localhost:3001/mcp (JSON-RPC POST)
28
+ * http://localhost:3001/health (health check)
29
+ * http://localhost:3001/tools (list all tools)
30
+ *
31
+ * @module bin/mcp-server
32
+ * @version 4.0.0
33
+ */
34
+
35
+ import {
36
+ createSwarmOrchestrator,
37
+ FederatedBudget,
38
+ McpBlackboardBridge,
39
+ getConfig,
40
+ setConfig,
41
+ } from '../index';
42
+ import { SecureTokenManager } from '../security';
43
+ import {
44
+ McpSseServer,
45
+ McpCombinedBridge,
46
+ McpBlackboardBridgeAdapter,
47
+ } from '../lib/mcp-transport-sse';
48
+ import { ExtendedMcpTools } from '../lib/mcp-tools-extended';
49
+ import { ControlMcpTools } from '../lib/mcp-tools-control';
50
+
51
+ // ============================================================================
52
+ // ARGUMENT PARSING
53
+ // ============================================================================
54
+
55
+ interface ServerArgs {
56
+ port: number;
57
+ host: string;
58
+ board: string;
59
+ ceiling: number;
60
+ noBudget: boolean;
61
+ noToken: boolean;
62
+ noExtended: boolean;
63
+ noControl: boolean;
64
+ auditLog: string;
65
+ heartbeat: number;
66
+ help: boolean;
67
+ }
68
+
69
+ function parseArgs(argv: string[]): ServerArgs {
70
+ const args: ServerArgs = {
71
+ port: 3001,
72
+ host: '0.0.0.0',
73
+ board: 'main',
74
+ ceiling: 1_000_000,
75
+ noBudget: false,
76
+ noToken: false,
77
+ noExtended: false,
78
+ noControl: false,
79
+ auditLog: './data/audit_log.jsonl',
80
+ heartbeat: 15000,
81
+ help: false,
82
+ };
83
+
84
+ for (let i = 0; i < argv.length; i++) {
85
+ const arg = argv[i];
86
+ const next = argv[i + 1];
87
+ switch (arg) {
88
+ case '--port': args.port = parseInt(next ?? '3001', 10); i++; break;
89
+ case '--host': args.host = next ?? '0.0.0.0'; i++; break;
90
+ case '--board': args.board = next ?? 'main'; i++; break;
91
+ case '--ceiling': args.ceiling = parseFloat(next ?? '1000000'); i++; break;
92
+ case '--audit-log': args.auditLog = next ?? './data/audit_log.jsonl'; i++; break;
93
+ case '--heartbeat': args.heartbeat = parseInt(next ?? '15000', 10); i++; break;
94
+ case '--no-budget': args.noBudget = true; break;
95
+ case '--no-token': args.noToken = true; break;
96
+ case '--no-extended': args.noExtended = true; break;
97
+ case '--no-control': args.noControl = true; break;
98
+ case '--help': case '-h': args.help = true; break;
99
+ }
100
+ }
101
+ return args;
102
+ }
103
+
104
+ function printHelp(): void {
105
+ console.log(`
106
+ network-ai-server — Network-AI MCP Server v4.0.0
107
+
108
+ Usage: npx ts-node bin/mcp-server.ts [options]
109
+
110
+ Options:
111
+ --port <n> TCP port (default: 3001)
112
+ --host <h> Bind host (default: 0.0.0.0)
113
+ --board <name> Named blackboard to expose (default: main)
114
+ --ceiling <n> Budget token ceiling (default: 1000000)
115
+ --audit-log <path> Audit log path (default: ./data/audit_log.jsonl)
116
+ --heartbeat <ms> SSE heartbeat interval (default: 15000)
117
+ --no-budget Disable budget tools
118
+ --no-token Disable token tools
119
+ --no-extended Disable extended tools (budget + token + audit)
120
+ --no-control Disable control-plane tools
121
+ --help Show this help
122
+
123
+ Connect to:
124
+ GET http://localhost:3001/sse SSE stream
125
+ POST http://localhost:3001/mcp JSON-RPC 2.0 tool calls
126
+ GET http://localhost:3001/health Health check
127
+ GET http://localhost:3001/tools All available tools
128
+ `);
129
+ }
130
+
131
+ // ============================================================================
132
+ // MAIN
133
+ // ============================================================================
134
+
135
+ async function main(): Promise<void> {
136
+ const args = parseArgs(process.argv.slice(2));
137
+
138
+ if (args.help) {
139
+ printHelp();
140
+ process.exit(0);
141
+ }
142
+
143
+ console.log(`\n[network-ai-server] Starting MCP Server v4.0.0`);
144
+ console.log(`[network-ai-server] Board: ${args.board} | Port: ${args.port}`);
145
+
146
+ // --------------------------------------------------------------------------
147
+ // 1. Create orchestrator + blackboard
148
+ // --------------------------------------------------------------------------
149
+ const orchestrator = createSwarmOrchestrator();
150
+ const blackboard = orchestrator.getBlackboard(args.board);
151
+
152
+ // --------------------------------------------------------------------------
153
+ // 2. Create MCP bridge for blackboard tools (5 tools)
154
+ // --------------------------------------------------------------------------
155
+ const blackboardBridge = new McpBlackboardBridge(blackboard, { name: args.board });
156
+ const blackboardAdapter = new McpBlackboardBridgeAdapter(blackboardBridge);
157
+
158
+ // --------------------------------------------------------------------------
159
+ // 3. Create extended tools (budget + token + audit) — optional
160
+ // --------------------------------------------------------------------------
161
+ let extendedTools: ExtendedMcpTools | null = null;
162
+ if (!args.noExtended) {
163
+ const budget = !args.noBudget
164
+ ? new FederatedBudget({ ceiling: args.ceiling })
165
+ : undefined;
166
+
167
+ const tokenManager = !args.noToken
168
+ ? new SecureTokenManager()
169
+ : undefined;
170
+
171
+ extendedTools = new ExtendedMcpTools({
172
+ budget,
173
+ tokenManager,
174
+ auditLogPath: args.auditLog,
175
+ });
176
+
177
+ const toolsEnabled: string[] = [];
178
+ if (budget) toolsEnabled.push('budget (5 tools)');
179
+ if (tokenManager) toolsEnabled.push('token (3 tools)');
180
+ toolsEnabled.push('audit (2 tools)');
181
+ console.log(`[network-ai-server] Extended tools: ${toolsEnabled.join(', ')}`);
182
+ }
183
+
184
+ // --------------------------------------------------------------------------
185
+ // 4. Create control-plane tools — optional
186
+ // --------------------------------------------------------------------------
187
+ let controlTools: ControlMcpTools | null = null;
188
+ if (!args.noControl) {
189
+ // Get the live CONFIG reference via the exported accessor
190
+ const liveConfig = getConfig() as Record<string, unknown>;
191
+
192
+ // Create a proxy config object that both reads from and writes to CONFIG
193
+ const configProxy = new Proxy(liveConfig, {
194
+ get(_t, key: string) {
195
+ return getConfig(key);
196
+ },
197
+ set(_t, key: string, value: unknown) {
198
+ setConfig(key, value);
199
+ return true;
200
+ },
201
+ ownKeys() {
202
+ return Object.keys(getConfig() as object);
203
+ },
204
+ getOwnPropertyDescriptor(_t, key: string) {
205
+ return { value: getConfig(key), writable: true, enumerable: true, configurable: true };
206
+ },
207
+ }) as unknown as import('../lib/mcp-tools-control').IConfig;
208
+
209
+ controlTools = new ControlMcpTools({
210
+ config: configProxy,
211
+ blackboard: blackboard as unknown as import('../lib/mcp-tools-control').IControlBlackboard,
212
+ systemToken: 'system-orchestrator-token',
213
+ });
214
+
215
+ console.log(`[network-ai-server] Control tools: config (2), agent (3), fsm (1), info (1)`);
216
+ }
217
+
218
+ // --------------------------------------------------------------------------
219
+ // 5. Assemble combined bridge
220
+ // --------------------------------------------------------------------------
221
+ const combined = new McpCombinedBridge('network-ai');
222
+ combined.register(blackboardAdapter);
223
+ if (extendedTools) combined.register(extendedTools);
224
+ if (controlTools) combined.register(controlTools);
225
+
226
+ const totalTools = combined.allDefinitions().length;
227
+ console.log(`[network-ai-server] Total tools exposed: ${totalTools}`);
228
+
229
+ // --------------------------------------------------------------------------
230
+ // 6. Start SSE server
231
+ // --------------------------------------------------------------------------
232
+ const server = new McpSseServer(combined, {
233
+ port: args.port,
234
+ host: args.host,
235
+ heartbeatMs: args.heartbeat,
236
+ });
237
+
238
+ await server.listen();
239
+
240
+ const localUrl = `http://localhost:${args.port}`;
241
+ console.log(`\n[network-ai-server] ✓ Listening on ${localUrl}`);
242
+ console.log(`[network-ai-server] SSE stream : ${localUrl}/sse`);
243
+ console.log(`[network-ai-server] Tool calls : ${localUrl}/mcp (POST)`);
244
+ console.log(`[network-ai-server] Health : ${localUrl}/health`);
245
+ console.log(`[network-ai-server] All tools : ${localUrl}/tools\n`);
246
+ console.log(`[network-ai-server] Connect any MCP client to: ${localUrl}`);
247
+ console.log(`[network-ai-server] Press Ctrl+C to stop.\n`);
248
+
249
+ // --------------------------------------------------------------------------
250
+ // 7. Graceful shutdown
251
+ // --------------------------------------------------------------------------
252
+ const shutdown = async (signal: string): Promise<void> => {
253
+ console.log(`\n[network-ai-server] Received ${signal} — shutting down...`);
254
+ await server.close();
255
+ console.log('[network-ai-server] Server stopped. Goodbye.\n');
256
+ process.exit(0);
257
+ };
258
+
259
+ process.on('SIGINT', () => void shutdown('SIGINT'));
260
+ process.on('SIGTERM', () => void shutdown('SIGTERM'));
261
+ }
262
+
263
+ main().catch(err => {
264
+ console.error('\n[network-ai-server] Fatal error:', err instanceof Error ? err.message : String(err));
265
+ process.exit(1);
266
+ });
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Network-AI MCP Server — Phase 6 Part 3
4
+ *
5
+ * Starts an HTTP/SSE server that exposes the full Network-AI tool suite to
6
+ * any MCP-compatible AI agent (Claude Desktop, Cursor, Cline, etc.).
7
+ *
8
+ * Usage:
9
+ * npx ts-node bin/mcp-server.ts [options]
10
+ * npx network-ai-server [options] (after clawhub publish)
11
+ *
12
+ * Options:
13
+ * --port <n> TCP port to listen on (default: 3001)
14
+ * --host <h> Hostname to bind to (default: 0.0.0.0)
15
+ * --board <name> Named blackboard to expose (default: main)
16
+ * --ceiling <n> Initial FederatedBudget token ceiling (default: 1_000_000)
17
+ * --no-budget Disable budget tools
18
+ * --no-token Disable token tools
19
+ * --no-extended Disable all extended tools (budget + token + audit)
20
+ * --no-control Disable control-plane tools
21
+ * --audit-log <path> Path to audit log file (default: ./data/audit_log.jsonl)
22
+ * --heartbeat <ms> SSE heartbeat interval in ms (default: 15000)
23
+ * --help Print this help text
24
+ *
25
+ * Connect any MCP client to:
26
+ * http://localhost:3001 (SSE stream — GET /sse)
27
+ * http://localhost:3001/mcp (JSON-RPC POST)
28
+ * http://localhost:3001/health (health check)
29
+ * http://localhost:3001/tools (list all tools)
30
+ *
31
+ * @module bin/mcp-server
32
+ * @version 4.0.0
33
+ */
34
+ export {};
35
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../bin/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG"}
@@ -0,0 +1,248 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Network-AI MCP Server — Phase 6 Part 3
5
+ *
6
+ * Starts an HTTP/SSE server that exposes the full Network-AI tool suite to
7
+ * any MCP-compatible AI agent (Claude Desktop, Cursor, Cline, etc.).
8
+ *
9
+ * Usage:
10
+ * npx ts-node bin/mcp-server.ts [options]
11
+ * npx network-ai-server [options] (after clawhub publish)
12
+ *
13
+ * Options:
14
+ * --port <n> TCP port to listen on (default: 3001)
15
+ * --host <h> Hostname to bind to (default: 0.0.0.0)
16
+ * --board <name> Named blackboard to expose (default: main)
17
+ * --ceiling <n> Initial FederatedBudget token ceiling (default: 1_000_000)
18
+ * --no-budget Disable budget tools
19
+ * --no-token Disable token tools
20
+ * --no-extended Disable all extended tools (budget + token + audit)
21
+ * --no-control Disable control-plane tools
22
+ * --audit-log <path> Path to audit log file (default: ./data/audit_log.jsonl)
23
+ * --heartbeat <ms> SSE heartbeat interval in ms (default: 15000)
24
+ * --help Print this help text
25
+ *
26
+ * Connect any MCP client to:
27
+ * http://localhost:3001 (SSE stream — GET /sse)
28
+ * http://localhost:3001/mcp (JSON-RPC POST)
29
+ * http://localhost:3001/health (health check)
30
+ * http://localhost:3001/tools (list all tools)
31
+ *
32
+ * @module bin/mcp-server
33
+ * @version 4.0.0
34
+ */
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const index_1 = require("../index");
37
+ const security_1 = require("../security");
38
+ const mcp_transport_sse_1 = require("../lib/mcp-transport-sse");
39
+ const mcp_tools_extended_1 = require("../lib/mcp-tools-extended");
40
+ const mcp_tools_control_1 = require("../lib/mcp-tools-control");
41
+ function parseArgs(argv) {
42
+ const args = {
43
+ port: 3001,
44
+ host: '0.0.0.0',
45
+ board: 'main',
46
+ ceiling: 1_000_000,
47
+ noBudget: false,
48
+ noToken: false,
49
+ noExtended: false,
50
+ noControl: false,
51
+ auditLog: './data/audit_log.jsonl',
52
+ heartbeat: 15000,
53
+ help: false,
54
+ };
55
+ for (let i = 0; i < argv.length; i++) {
56
+ const arg = argv[i];
57
+ const next = argv[i + 1];
58
+ switch (arg) {
59
+ case '--port':
60
+ args.port = parseInt(next ?? '3001', 10);
61
+ i++;
62
+ break;
63
+ case '--host':
64
+ args.host = next ?? '0.0.0.0';
65
+ i++;
66
+ break;
67
+ case '--board':
68
+ args.board = next ?? 'main';
69
+ i++;
70
+ break;
71
+ case '--ceiling':
72
+ args.ceiling = parseFloat(next ?? '1000000');
73
+ i++;
74
+ break;
75
+ case '--audit-log':
76
+ args.auditLog = next ?? './data/audit_log.jsonl';
77
+ i++;
78
+ break;
79
+ case '--heartbeat':
80
+ args.heartbeat = parseInt(next ?? '15000', 10);
81
+ i++;
82
+ break;
83
+ case '--no-budget':
84
+ args.noBudget = true;
85
+ break;
86
+ case '--no-token':
87
+ args.noToken = true;
88
+ break;
89
+ case '--no-extended':
90
+ args.noExtended = true;
91
+ break;
92
+ case '--no-control':
93
+ args.noControl = true;
94
+ break;
95
+ case '--help':
96
+ case '-h':
97
+ args.help = true;
98
+ break;
99
+ }
100
+ }
101
+ return args;
102
+ }
103
+ function printHelp() {
104
+ console.log(`
105
+ network-ai-server — Network-AI MCP Server v4.0.0
106
+
107
+ Usage: npx ts-node bin/mcp-server.ts [options]
108
+
109
+ Options:
110
+ --port <n> TCP port (default: 3001)
111
+ --host <h> Bind host (default: 0.0.0.0)
112
+ --board <name> Named blackboard to expose (default: main)
113
+ --ceiling <n> Budget token ceiling (default: 1000000)
114
+ --audit-log <path> Audit log path (default: ./data/audit_log.jsonl)
115
+ --heartbeat <ms> SSE heartbeat interval (default: 15000)
116
+ --no-budget Disable budget tools
117
+ --no-token Disable token tools
118
+ --no-extended Disable extended tools (budget + token + audit)
119
+ --no-control Disable control-plane tools
120
+ --help Show this help
121
+
122
+ Connect to:
123
+ GET http://localhost:3001/sse SSE stream
124
+ POST http://localhost:3001/mcp JSON-RPC 2.0 tool calls
125
+ GET http://localhost:3001/health Health check
126
+ GET http://localhost:3001/tools All available tools
127
+ `);
128
+ }
129
+ // ============================================================================
130
+ // MAIN
131
+ // ============================================================================
132
+ async function main() {
133
+ const args = parseArgs(process.argv.slice(2));
134
+ if (args.help) {
135
+ printHelp();
136
+ process.exit(0);
137
+ }
138
+ console.log(`\n[network-ai-server] Starting MCP Server v4.0.0`);
139
+ console.log(`[network-ai-server] Board: ${args.board} | Port: ${args.port}`);
140
+ // --------------------------------------------------------------------------
141
+ // 1. Create orchestrator + blackboard
142
+ // --------------------------------------------------------------------------
143
+ const orchestrator = (0, index_1.createSwarmOrchestrator)();
144
+ const blackboard = orchestrator.getBlackboard(args.board);
145
+ // --------------------------------------------------------------------------
146
+ // 2. Create MCP bridge for blackboard tools (5 tools)
147
+ // --------------------------------------------------------------------------
148
+ const blackboardBridge = new index_1.McpBlackboardBridge(blackboard, { name: args.board });
149
+ const blackboardAdapter = new mcp_transport_sse_1.McpBlackboardBridgeAdapter(blackboardBridge);
150
+ // --------------------------------------------------------------------------
151
+ // 3. Create extended tools (budget + token + audit) — optional
152
+ // --------------------------------------------------------------------------
153
+ let extendedTools = null;
154
+ if (!args.noExtended) {
155
+ const budget = !args.noBudget
156
+ ? new index_1.FederatedBudget({ ceiling: args.ceiling })
157
+ : undefined;
158
+ const tokenManager = !args.noToken
159
+ ? new security_1.SecureTokenManager()
160
+ : undefined;
161
+ extendedTools = new mcp_tools_extended_1.ExtendedMcpTools({
162
+ budget,
163
+ tokenManager,
164
+ auditLogPath: args.auditLog,
165
+ });
166
+ const toolsEnabled = [];
167
+ if (budget)
168
+ toolsEnabled.push('budget (5 tools)');
169
+ if (tokenManager)
170
+ toolsEnabled.push('token (3 tools)');
171
+ toolsEnabled.push('audit (2 tools)');
172
+ console.log(`[network-ai-server] Extended tools: ${toolsEnabled.join(', ')}`);
173
+ }
174
+ // --------------------------------------------------------------------------
175
+ // 4. Create control-plane tools — optional
176
+ // --------------------------------------------------------------------------
177
+ let controlTools = null;
178
+ if (!args.noControl) {
179
+ // Get the live CONFIG reference via the exported accessor
180
+ const liveConfig = (0, index_1.getConfig)();
181
+ // Create a proxy config object that both reads from and writes to CONFIG
182
+ const configProxy = new Proxy(liveConfig, {
183
+ get(_t, key) {
184
+ return (0, index_1.getConfig)(key);
185
+ },
186
+ set(_t, key, value) {
187
+ (0, index_1.setConfig)(key, value);
188
+ return true;
189
+ },
190
+ ownKeys() {
191
+ return Object.keys((0, index_1.getConfig)());
192
+ },
193
+ getOwnPropertyDescriptor(_t, key) {
194
+ return { value: (0, index_1.getConfig)(key), writable: true, enumerable: true, configurable: true };
195
+ },
196
+ });
197
+ controlTools = new mcp_tools_control_1.ControlMcpTools({
198
+ config: configProxy,
199
+ blackboard: blackboard,
200
+ systemToken: 'system-orchestrator-token',
201
+ });
202
+ console.log(`[network-ai-server] Control tools: config (2), agent (3), fsm (1), info (1)`);
203
+ }
204
+ // --------------------------------------------------------------------------
205
+ // 5. Assemble combined bridge
206
+ // --------------------------------------------------------------------------
207
+ const combined = new mcp_transport_sse_1.McpCombinedBridge('network-ai');
208
+ combined.register(blackboardAdapter);
209
+ if (extendedTools)
210
+ combined.register(extendedTools);
211
+ if (controlTools)
212
+ combined.register(controlTools);
213
+ const totalTools = combined.allDefinitions().length;
214
+ console.log(`[network-ai-server] Total tools exposed: ${totalTools}`);
215
+ // --------------------------------------------------------------------------
216
+ // 6. Start SSE server
217
+ // --------------------------------------------------------------------------
218
+ const server = new mcp_transport_sse_1.McpSseServer(combined, {
219
+ port: args.port,
220
+ host: args.host,
221
+ heartbeatMs: args.heartbeat,
222
+ });
223
+ await server.listen();
224
+ const localUrl = `http://localhost:${args.port}`;
225
+ console.log(`\n[network-ai-server] ✓ Listening on ${localUrl}`);
226
+ console.log(`[network-ai-server] SSE stream : ${localUrl}/sse`);
227
+ console.log(`[network-ai-server] Tool calls : ${localUrl}/mcp (POST)`);
228
+ console.log(`[network-ai-server] Health : ${localUrl}/health`);
229
+ console.log(`[network-ai-server] All tools : ${localUrl}/tools\n`);
230
+ console.log(`[network-ai-server] Connect any MCP client to: ${localUrl}`);
231
+ console.log(`[network-ai-server] Press Ctrl+C to stop.\n`);
232
+ // --------------------------------------------------------------------------
233
+ // 7. Graceful shutdown
234
+ // --------------------------------------------------------------------------
235
+ const shutdown = async (signal) => {
236
+ console.log(`\n[network-ai-server] Received ${signal} — shutting down...`);
237
+ await server.close();
238
+ console.log('[network-ai-server] Server stopped. Goodbye.\n');
239
+ process.exit(0);
240
+ };
241
+ process.on('SIGINT', () => void shutdown('SIGINT'));
242
+ process.on('SIGTERM', () => void shutdown('SIGTERM'));
243
+ }
244
+ main().catch(err => {
245
+ console.error('\n[network-ai-server] Fatal error:', err instanceof Error ? err.message : String(err));
246
+ process.exit(1);
247
+ });
248
+ //# sourceMappingURL=mcp-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../bin/mcp-server.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;AAEH,oCAMkB;AAClB,0CAAiD;AACjD,gEAIkC;AAClC,kEAA6D;AAC7D,gEAA2D;AAoB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O,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACtG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -758,4 +758,32 @@ export declare function createSwarmOrchestrator(config?: Partial<typeof CONFIG>
758
758
  qualityThreshold?: number;
759
759
  aiReviewCallback?: AIReviewCallback;
760
760
  }): SwarmOrchestrator;
761
+ /**
762
+ * Read the current value of a CONFIG key, or the entire CONFIG snapshot.
763
+ *
764
+ * @example
765
+ * ```typescript
766
+ * const cfg = getConfig(); // { maxParallelAgents: Infinity, ... }
767
+ * const timeout = getConfig('defaultTimeout'); // 30000
768
+ * ```
769
+ */
770
+ export declare function getConfig(): Readonly<typeof CONFIG>;
771
+ export declare function getConfig(key: string): unknown;
772
+ /**
773
+ * Update a CONFIG key at runtime. Changes take effect immediately for all
774
+ * subsequent orchestrator operations.
775
+ *
776
+ * @example
777
+ * ```typescript
778
+ * setConfig('maxParallelAgents', 10);
779
+ * setConfig('enableTracing', false);
780
+ * ```
781
+ */
782
+ export declare function setConfig(key: string, value: unknown): void;
783
+ export { McpSseServer, McpSseTransport, McpCombinedBridge, McpBlackboardBridgeAdapter, } from './lib/mcp-transport-sse';
784
+ export type { McpToolProvider, McpSseServerOptions } from './lib/mcp-transport-sse';
785
+ export { ExtendedMcpTools } from './lib/mcp-tools-extended';
786
+ export type { IBudget, ITokenManager, ExtendedMcpToolsOptions } from './lib/mcp-tools-extended';
787
+ export { ControlMcpTools } from './lib/mcp-tools-control';
788
+ export type { IConfig, IAgentStatus, ControlMcpToolsOptions } from './lib/mcp-tools-control';
761
789
  //# sourceMappingURL=index.d.ts.map