@productbrain/mcp 0.0.1-beta.38 → 0.0.1-beta.39
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/{chunk-7LEGOXN4.js → chunk-7VJP2IMS.js} +4 -4
- package/dist/{chunk-7LEGOXN4.js.map → chunk-7VJP2IMS.js.map} +1 -1
- package/dist/{chunk-FPFNMME7.js → chunk-XCKGFYDP.js} +16 -23
- package/dist/chunk-XCKGFYDP.js.map +1 -0
- package/dist/http.js +2 -2
- package/dist/index.js +35 -30
- package/dist/index.js.map +1 -1
- package/dist/{smart-capture-OLIFSERN.js → smart-capture-E53YEHHO.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-FPFNMME7.js.map +0 -1
- /package/dist/{smart-capture-OLIFSERN.js.map → smart-capture-E53YEHHO.js.map} +0 -0
package/dist/http.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SERVER_VERSION,
|
|
3
3
|
createProductBrainServer
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XCKGFYDP.js";
|
|
5
5
|
import {
|
|
6
6
|
bootstrapHttp,
|
|
7
7
|
runWithAuth
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-7VJP2IMS.js";
|
|
9
9
|
import {
|
|
10
10
|
initAnalytics,
|
|
11
11
|
shutdownAnalytics
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
SERVER_VERSION,
|
|
4
4
|
createProductBrainServer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XCKGFYDP.js";
|
|
6
6
|
import {
|
|
7
7
|
bootstrap,
|
|
8
8
|
getAgentSessionId,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
orphanAgentSession,
|
|
11
11
|
recoverSessionState,
|
|
12
12
|
startAgentSession
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7VJP2IMS.js";
|
|
14
14
|
import {
|
|
15
15
|
initAnalytics,
|
|
16
16
|
shutdownAnalytics,
|
|
@@ -34,6 +34,36 @@ if (!process.env.CONVEX_SITE_URL && !process.env.PRODUCTBRAIN_API_KEY) {
|
|
|
34
34
|
} catch {
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
var withTimeout = (p, ms) => Promise.race([p, new Promise((r) => setTimeout(r, ms))]);
|
|
38
|
+
var shuttingDown = false;
|
|
39
|
+
async function gracefulShutdown() {
|
|
40
|
+
if (shuttingDown) return;
|
|
41
|
+
shuttingDown = true;
|
|
42
|
+
process.stderr.write("[MCP] Graceful shutdown initiated.\n");
|
|
43
|
+
const hardExit = setTimeout(() => process.exit(1), 3e3);
|
|
44
|
+
try {
|
|
45
|
+
if (getAgentSessionId()) await withTimeout(orphanAgentSession(), 1500);
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
await withTimeout(shutdownAnalytics(), 1e3);
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
clearTimeout(hardExit);
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
process.on("SIGINT", gracefulShutdown);
|
|
56
|
+
process.on("SIGTERM", gracefulShutdown);
|
|
57
|
+
process.on("unhandledRejection", (reason) => {
|
|
58
|
+
const msg = reason instanceof Error ? reason.message : String(reason);
|
|
59
|
+
process.stderr.write(`[MCP] Unhandled rejection: ${msg}
|
|
60
|
+
`);
|
|
61
|
+
});
|
|
62
|
+
process.on("uncaughtException", (err) => {
|
|
63
|
+
process.stderr.write(`[MCP] Uncaught exception: ${err.stack ?? err.message}
|
|
64
|
+
`);
|
|
65
|
+
gracefulShutdown();
|
|
66
|
+
});
|
|
37
67
|
bootstrap();
|
|
38
68
|
initAnalytics();
|
|
39
69
|
var server = createProductBrainServer();
|
|
@@ -42,15 +72,10 @@ transport.onerror = (error) => {
|
|
|
42
72
|
process.stderr.write(`[MCP] Transport error: ${error.message}
|
|
43
73
|
`);
|
|
44
74
|
};
|
|
75
|
+
process.stderr.write("[MCP] Starting server.\n");
|
|
45
76
|
await server.connect(transport);
|
|
46
|
-
process.
|
|
47
|
-
|
|
48
|
-
process.stderr.write(`[MCP] Unhandled rejection: ${msg}
|
|
49
|
-
`);
|
|
50
|
-
});
|
|
51
|
-
process.on("uncaughtException", (err) => {
|
|
52
|
-
process.stderr.write(`[MCP] Uncaught exception: ${err.stack ?? err.message}
|
|
53
|
-
`);
|
|
77
|
+
process.stderr.write("[MCP] Server connected.\n");
|
|
78
|
+
process.stdin.on("end", () => {
|
|
54
79
|
gracefulShutdown();
|
|
55
80
|
});
|
|
56
81
|
getWorkspaceId().then(async (wsId) => {
|
|
@@ -66,24 +91,4 @@ getWorkspaceId().then(async (wsId) => {
|
|
|
66
91
|
}).catch(() => {
|
|
67
92
|
process.stderr.write("[MCP] Workspace resolution deferred \u2014 will retry on first tool call.\n");
|
|
68
93
|
});
|
|
69
|
-
var shuttingDown = false;
|
|
70
|
-
async function gracefulShutdown() {
|
|
71
|
-
if (shuttingDown) return;
|
|
72
|
-
shuttingDown = true;
|
|
73
|
-
setTimeout(() => process.exit(1), 3e3).unref();
|
|
74
|
-
try {
|
|
75
|
-
if (getAgentSessionId()) await orphanAgentSession();
|
|
76
|
-
} catch {
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
await shutdownAnalytics();
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
|
-
process.exit(0);
|
|
83
|
-
}
|
|
84
|
-
process.on("SIGINT", gracefulShutdown);
|
|
85
|
-
process.on("SIGTERM", gracefulShutdown);
|
|
86
|
-
process.stdin.on("end", () => {
|
|
87
|
-
gracefulShutdown();
|
|
88
|
-
});
|
|
89
94
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nimport {\n getWorkspaceId,\n bootstrap,\n orphanAgentSession,\n startAgentSession,\n getAgentSessionId,\n recoverSessionState,\n} from \"./client.js\";\nimport { initAnalytics, trackSessionStarted, shutdownAnalytics } from \"./analytics.js\";\nimport { createProductBrainServer, SERVER_VERSION } from \"./server.js\";\n\nif (!process.env.CONVEX_SITE_URL && !process.env.PRODUCTBRAIN_API_KEY) {\n try {\n const envPath = resolve(process.cwd(), \".env.mcp\");\n for (const line of readFileSync(envPath, \"utf-8\").split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n process.env[trimmed.slice(0, eqIdx)] ??= trimmed.slice(eqIdx + 1);\n }\n } catch {\n // .env.mcp not found — rely on env vars being set by the launcher\n }\n}\n\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nimport {\n getWorkspaceId,\n bootstrap,\n orphanAgentSession,\n startAgentSession,\n getAgentSessionId,\n recoverSessionState,\n} from \"./client.js\";\nimport { initAnalytics, trackSessionStarted, shutdownAnalytics } from \"./analytics.js\";\nimport { createProductBrainServer, SERVER_VERSION } from \"./server.js\";\n\nif (!process.env.CONVEX_SITE_URL && !process.env.PRODUCTBRAIN_API_KEY) {\n try {\n const envPath = resolve(process.cwd(), \".env.mcp\");\n for (const line of readFileSync(envPath, \"utf-8\").split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n process.env[trimmed.slice(0, eqIdx)] ??= trimmed.slice(eqIdx + 1);\n }\n } catch {\n // .env.mcp not found — rely on env vars being set by the launcher\n }\n}\n\nconst withTimeout = <T>(p: Promise<T>, ms: number): Promise<T | void> =>\n Promise.race([p, new Promise<void>((r) => setTimeout(r, ms))]);\n\nlet shuttingDown = false;\nasync function gracefulShutdown() {\n if (shuttingDown) return;\n shuttingDown = true;\n process.stderr.write(\"[MCP] Graceful shutdown initiated.\\n\");\n // Hard-exit guard — not unref'd so it fires even if event loop empties\n const hardExit = setTimeout(() => process.exit(1), 3_000);\n try {\n if (getAgentSessionId()) await withTimeout(orphanAgentSession(), 1_500);\n } catch {\n /* best-effort */\n }\n try {\n await withTimeout(shutdownAnalytics(), 1_000);\n } catch {\n /* best-effort */\n }\n clearTimeout(hardExit);\n process.exit(0);\n}\n\n// Register signal handlers BEFORE server.connect so they are always active\nprocess.on(\"SIGINT\", gracefulShutdown);\nprocess.on(\"SIGTERM\", gracefulShutdown);\nprocess.on(\"unhandledRejection\", (reason) => {\n const msg = reason instanceof Error ? reason.message : String(reason);\n process.stderr.write(`[MCP] Unhandled rejection: ${msg}\\n`);\n});\nprocess.on(\"uncaughtException\", (err) => {\n process.stderr.write(`[MCP] Uncaught exception: ${err.stack ?? err.message}\\n`);\n gracefulShutdown();\n});\n\nbootstrap();\ninitAnalytics();\n\nconst server = createProductBrainServer();\nconst transport = new StdioServerTransport();\ntransport.onerror = (error) => {\n process.stderr.write(`[MCP] Transport error: ${error.message}\\n`);\n};\nprocess.stderr.write(\"[MCP] Starting server.\\n\");\nawait server.connect(transport);\nprocess.stderr.write(\"[MCP] Server connected.\\n\");\n\nprocess.stdin.on(\"end\", () => {\n gracefulShutdown();\n});\n\ngetWorkspaceId()\n .then(async (wsId) => {\n trackSessionStarted(wsId, SERVER_VERSION);\n try {\n await startAgentSession();\n process.stderr.write(\"[MCP] Agent session started automatically.\\n\");\n } catch (err: any) {\n process.stderr.write(`[MCP] Auto session start failed: ${err.message}. Call session action=start manually.\\n`);\n await recoverSessionState();\n }\n })\n .catch(() => {\n process.stderr.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,QAAM,MAAM,kBAAkB,QAAQ,OAAO,UAAU,OAAO,MAAM;AACpE,UAAQ,OAAO,MAAM,8BAA8B,GAAG;AAAA,CAAI;AAC5D,CAAC;AACD,QAAQ,GAAG,qBAAqB,CAAC,QAAQ;AACvC,UAAQ,OAAO,MAAM,6BAA6B,IAAI,SAAS,IAAI,OAAO;AAAA,CAAI;AAC9E,mBAAiB;AACnB,CAAC;AAED,UAAU;AACV,cAAc;AAEd,IAAM,SAAS,yBAAyB;AACxC,IAAM,YAAY,IAAI,qBAAqB;AAC3C,UAAU,UAAU,CAAC,UAAU;AAC7B,UAAQ,OAAO,MAAM,0BAA0B,MAAM,OAAO;AAAA,CAAI;AAClE;AACA,QAAQ,OAAO,MAAM,0BAA0B;AAC/C,MAAM,OAAO,QAAQ,SAAS;AAC9B,QAAQ,OAAO,MAAM,2BAA2B;AAEhD,QAAQ,MAAM,GAAG,OAAO,MAAM;AAC5B,mBAAiB;AACnB,CAAC;AAED,eAAe,EACZ,KAAK,OAAO,SAAS;AACpB,sBAAoB,MAAM,cAAc;AACxC,MAAI;AACF,UAAM,kBAAkB;AACxB,YAAQ,OAAO,MAAM,8CAA8C;AAAA,EACrE,SAAS,KAAU;AACjB,YAAQ,OAAO,MAAM,oCAAoC,IAAI,OAAO;AAAA,CAAyC;AAC7G,UAAM,oBAAoB;AAAA,EAC5B;AACF,CAAC,EACA,MAAM,MAAM;AACX,UAAQ,OAAO,MAAM,6EAAwE;AAC/F,CAAC;","names":[]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
formatRubricVerdictSection,
|
|
10
10
|
registerSmartCaptureTools,
|
|
11
11
|
runContradictionCheck
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7VJP2IMS.js";
|
|
13
13
|
import "./chunk-TB24VJ4Z.js";
|
|
14
14
|
export {
|
|
15
15
|
batchCaptureOutputSchema,
|
|
@@ -23,4 +23,4 @@ export {
|
|
|
23
23
|
registerSmartCaptureTools,
|
|
24
24
|
runContradictionCheck
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=smart-capture-
|
|
26
|
+
//# sourceMappingURL=smart-capture-E53YEHHO.js.map
|