nexus-prime 7.9.13 → 7.9.14
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.
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PassThrough } from 'stream';
|
|
2
|
+
let primedStdioInput = null;
|
|
3
|
+
let primedStdioInputStarted = false;
|
|
4
|
+
let primedStdioInputReady = false;
|
|
5
|
+
let primedStdioInputEnded = false;
|
|
6
|
+
const primedStdioChunks = [];
|
|
7
|
+
export function primeMcpStdioInput() {
|
|
8
|
+
if (primedStdioInputStarted || process.stdin.isTTY)
|
|
9
|
+
return;
|
|
10
|
+
primedStdioInputStarted = true;
|
|
11
|
+
process.stdin.on('data', (chunk) => {
|
|
12
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
13
|
+
if (primedStdioInput && primedStdioInputReady) {
|
|
14
|
+
primedStdioInput.write(buffer);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
primedStdioChunks.push(buffer);
|
|
18
|
+
});
|
|
19
|
+
process.stdin.on('end', () => {
|
|
20
|
+
primedStdioInputEnded = true;
|
|
21
|
+
if (primedStdioInput && primedStdioInputReady)
|
|
22
|
+
primedStdioInput.end();
|
|
23
|
+
});
|
|
24
|
+
process.stdin.on('error', (error) => primedStdioInput?.destroy(error));
|
|
25
|
+
process.stdin.resume();
|
|
26
|
+
}
|
|
27
|
+
export function getMcpStdioInput() {
|
|
28
|
+
if (primedStdioInputStarted && !primedStdioInput) {
|
|
29
|
+
primedStdioInput = new PassThrough();
|
|
30
|
+
}
|
|
31
|
+
return primedStdioInput ?? process.stdin;
|
|
32
|
+
}
|
|
33
|
+
export function flushPrimedMcpStdioInput() {
|
|
34
|
+
if (!primedStdioInput)
|
|
35
|
+
return;
|
|
36
|
+
primedStdioInputReady = true;
|
|
37
|
+
for (const chunk of primedStdioChunks.splice(0)) {
|
|
38
|
+
primedStdioInput.write(chunk);
|
|
39
|
+
}
|
|
40
|
+
if (primedStdioInputEnded)
|
|
41
|
+
primedStdioInput.end();
|
|
42
|
+
}
|
|
43
|
+
if (process.argv[2] === 'mcp') {
|
|
44
|
+
primeMcpStdioInput();
|
|
45
|
+
}
|
|
@@ -30,6 +30,7 @@ import { getFallbackRuntime, getFallbackOrchestrator, getGuardrailEngine, normal
|
|
|
30
30
|
import { dispatchMcpToolCall } from './mcp/dispatch.js';
|
|
31
31
|
import { LifecyclePolicy } from '../../engines/lifecycle-policy.js';
|
|
32
32
|
import { startWatchdog } from './mcp/watchdog.js';
|
|
33
|
+
import { getMcpStdioInput } from './mcp/stdio-buffer.js';
|
|
33
34
|
// Derive project root from this file's location (dist/agents/adapters/mcp.js → project root)
|
|
34
35
|
const __filename = fileURLToPath(import.meta.url);
|
|
35
36
|
const PROJECT_ROOT = path.resolve(path.dirname(__filename), '..', '..', '..');
|
|
@@ -1152,7 +1153,7 @@ export class MCPAdapter {
|
|
|
1152
1153
|
return scanSourceFilesUtil(cwd, this.scanCache);
|
|
1153
1154
|
}
|
|
1154
1155
|
async connect() {
|
|
1155
|
-
const transport = new StdioServerTransport();
|
|
1156
|
+
const transport = new StdioServerTransport(getMcpStdioInput(), process.stdout);
|
|
1156
1157
|
await this.server.connect(transport);
|
|
1157
1158
|
this.connected = true;
|
|
1158
1159
|
startWatchdog();
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Nexus Prime CLI
|
|
4
4
|
*/
|
|
5
5
|
import 'dotenv/config';
|
|
6
|
+
import { flushPrimedMcpStdioInput, primeMcpStdioInput } from './agents/adapters/mcp/stdio-buffer.js';
|
|
6
7
|
import { Command } from 'commander';
|
|
7
8
|
import { createNexusPrime } from './index.js';
|
|
8
9
|
import { TokenSupremacyEngine, formatReadingPlan } from './engines/token-supremacy.js';
|
|
@@ -813,6 +814,7 @@ program
|
|
|
813
814
|
.option('--standalone', 'Skip daemon detection, run in-process (debug mode)')
|
|
814
815
|
.action(async (options) => {
|
|
815
816
|
// stdio transport requires strict JSON-RPC on stdout — no console.log here.
|
|
817
|
+
primeMcpStdioInput();
|
|
816
818
|
const workspaceContext = resolveWorkspaceContext({ workspaceRoot: getWorkspaceRoot() });
|
|
817
819
|
const caller = detectCallerIDE();
|
|
818
820
|
process.env.NEXUS_DAEMON_AUTOSPAWN ??= '0';
|
|
@@ -955,6 +957,7 @@ program
|
|
|
955
957
|
throw new Error('MCP adapter did not become ready before the startup deadline.');
|
|
956
958
|
}
|
|
957
959
|
await startup;
|
|
960
|
+
flushPrimedMcpStdioInput();
|
|
958
961
|
console.error('Nexus Prime MCP Server running on stdio (standalone)');
|
|
959
962
|
console.error('Memory persistence: active (~/.nexus-prime/memory.db)');
|
|
960
963
|
const shutdown = async (signal) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexus-prime",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.14",
|
|
4
4
|
"description": "Local-first MCP control plane for coding agents with bootstrap-orchestrate execution, memory fabric, token budgeting, and worktree-backed swarms",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|