mulmocast-vision 0.1.3 → 0.1.4
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/lib/commons.d.ts +1 -0
- package/lib/commons.js +14 -1
- package/lib/mcp.js +1 -2
- package/lib/presentationHandlers/html.d.ts +0 -1
- package/lib/presentationHandlers/html.js +4 -4
- package/lib/presentationHandlers/html_class.d.ts +4 -2
- package/lib/presentationHandlers/html_class.js +6 -4
- package/lib/tools/index.js +2 -2
- package/lib/utils.js +2 -2
- package/package.json +1 -1
package/lib/commons.d.ts
CHANGED
package/lib/commons.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateUniqueId = exports.convertTools = exports.openAIToolsToAnthropicTools = exports.toolsToTemplateNames = exports.templateNameTofunctionName = exports.functionNameToTemplateName = void 0;
|
|
3
|
+
exports.formattedDate = exports.generateUniqueId = exports.convertTools = exports.openAIToolsToAnthropicTools = exports.toolsToTemplateNames = exports.templateNameTofunctionName = exports.functionNameToTemplateName = void 0;
|
|
4
4
|
const functionNameToTemplateName = (functionName) => {
|
|
5
5
|
const tmpName = functionName.replace(/^create/, "");
|
|
6
6
|
const fileName = tmpName.charAt(0).toLowerCase() + tmpName.slice(1);
|
|
@@ -58,3 +58,16 @@ const generateUniqueId = () => {
|
|
|
58
58
|
return `${now}-${random}`;
|
|
59
59
|
};
|
|
60
60
|
exports.generateUniqueId = generateUniqueId;
|
|
61
|
+
const formattedDate = () => {
|
|
62
|
+
const now = new Date();
|
|
63
|
+
const formatted = [
|
|
64
|
+
now.getFullYear(),
|
|
65
|
+
String(now.getMonth() + 1).padStart(2, "0"),
|
|
66
|
+
String(now.getDate()).padStart(2, "0"),
|
|
67
|
+
String(now.getHours()).padStart(2, "0"),
|
|
68
|
+
String(now.getMinutes()).padStart(2, "0"),
|
|
69
|
+
String(now.getSeconds()).padStart(2, "0"),
|
|
70
|
+
].join("-");
|
|
71
|
+
return formatted;
|
|
72
|
+
};
|
|
73
|
+
exports.formattedDate = formattedDate;
|
package/lib/mcp.js
CHANGED
|
@@ -12,7 +12,7 @@ const utils_1 = require("./utils");
|
|
|
12
12
|
const getServer = (rootDir, outputDir) => {
|
|
13
13
|
const server = new index_js_1.Server({
|
|
14
14
|
name: "mulmocast-vision-mcp",
|
|
15
|
-
version: "0.1.
|
|
15
|
+
version: "0.1.4",
|
|
16
16
|
}, {
|
|
17
17
|
capabilities: {
|
|
18
18
|
tools: {},
|
|
@@ -61,7 +61,6 @@ exports.getServer = getServer;
|
|
|
61
61
|
const main = async () => {
|
|
62
62
|
const rootDir = (0, utils_1.getRootDir)();
|
|
63
63
|
const outputDir = (0, utils_1.getOutDir)();
|
|
64
|
-
(0, utils_1.mkdir)(outputDir);
|
|
65
64
|
const server = (0, exports.getServer)(rootDir, outputDir);
|
|
66
65
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
67
66
|
await server.connect(transport);
|
|
@@ -3,14 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.callNamedFunction =
|
|
6
|
+
exports.callNamedFunction = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const commons_1 = require("../commons");
|
|
10
10
|
const nunjucks_1 = __importDefault(require("nunjucks"));
|
|
11
11
|
const rootDir = (0, utils_1.getRootDir)();
|
|
12
|
-
|
|
13
|
-
(0, utils_1.mkdir)(exports.baseDir);
|
|
12
|
+
const baseDir = (0, utils_1.getOutDir)();
|
|
14
13
|
const filePath = (filename) => {
|
|
15
14
|
return path_1.default.resolve(rootDir, "./html/html/", `${filename}.html`);
|
|
16
15
|
};
|
|
@@ -19,8 +18,9 @@ const generateHtml = async (args, options) => {
|
|
|
19
18
|
if (!functionName) {
|
|
20
19
|
throw new Error("functionName is required");
|
|
21
20
|
}
|
|
21
|
+
(0, utils_1.mkdir)(baseDir);
|
|
22
22
|
const templateFileName = (0, commons_1.functionNameToTemplateName)(functionName);
|
|
23
|
-
const outfile = imageFilePath ?? path_1.default.resolve(
|
|
23
|
+
const outfile = imageFilePath ?? path_1.default.resolve(baseDir, `${outputFileName}.png`);
|
|
24
24
|
await (0, utils_1.createPage)(rootDir, outfile, nunjucks_1.default.render(filePath(templateFileName), args));
|
|
25
25
|
};
|
|
26
26
|
const callNamedFunction = async (functionName, args, options) => {
|
|
@@ -2,19 +2,21 @@ import { type PluginOptionParams, type ToolArgs } from "../type";
|
|
|
2
2
|
export declare class htmlPlugin {
|
|
3
3
|
protected outputDir: string;
|
|
4
4
|
protected rootDir: string;
|
|
5
|
+
protected htmlDir: string;
|
|
5
6
|
protected sessionDir: string;
|
|
6
7
|
protected templateOptions: any;
|
|
7
|
-
constructor({ outputDir, rootDir, templateOptions }: {
|
|
8
|
+
constructor({ outputDir, rootDir, templateOptions, htmlDir }: {
|
|
8
9
|
outputDir?: string;
|
|
9
10
|
rootDir?: string;
|
|
10
11
|
templateOptions?: any;
|
|
12
|
+
htmlDir?: string;
|
|
11
13
|
});
|
|
12
14
|
callNamedFunction: (functionName: string, args: ToolArgs, options: PluginOptionParams) => Promise<any>;
|
|
13
15
|
private generateHtml;
|
|
14
16
|
setDirectory: (args: ToolArgs, __options: PluginOptionParams) => Promise<{
|
|
15
17
|
text: string;
|
|
16
18
|
}>;
|
|
17
|
-
createPDF: (
|
|
19
|
+
createPDF: (args: ToolArgs, __options: PluginOptionParams) => Promise<{
|
|
18
20
|
text: string;
|
|
19
21
|
} | undefined>;
|
|
20
22
|
}
|
|
@@ -11,7 +11,7 @@ const utils_1 = require("../utils");
|
|
|
11
11
|
const commons_1 = require("../commons");
|
|
12
12
|
const nunjucks_1 = __importDefault(require("nunjucks"));
|
|
13
13
|
class htmlPlugin {
|
|
14
|
-
constructor({ outputDir, rootDir, templateOptions }) {
|
|
14
|
+
constructor({ outputDir, rootDir, templateOptions, htmlDir }) {
|
|
15
15
|
this.callNamedFunction = async (functionName, args, options) => {
|
|
16
16
|
const member = this[functionName];
|
|
17
17
|
if (member && typeof member === "function") {
|
|
@@ -25,7 +25,7 @@ class htmlPlugin {
|
|
|
25
25
|
throw new Error("functionName is required");
|
|
26
26
|
}
|
|
27
27
|
const templateFileName = (0, commons_1.functionNameToTemplateName)(functionName);
|
|
28
|
-
const templateFilePath = path_1.default.resolve(this.rootDir,
|
|
28
|
+
const templateFilePath = path_1.default.resolve(this.rootDir, `./html/${this.htmlDir}`, `${templateFileName}.html`);
|
|
29
29
|
const outfile = imageFilePath ?? path_1.default.resolve(this.outputDir, this.sessionDir, `${outputFileName}.png`);
|
|
30
30
|
const htmlFile = htmlFilePath ?? path_1.default.resolve(this.outputDir, this.sessionDir, `${outputFileName}.html`);
|
|
31
31
|
await (0, utils_1.createPage)(this.rootDir, outfile, nunjucks_1.default.render(templateFilePath, args), { htmlFile, ...this.templateOptions });
|
|
@@ -43,7 +43,8 @@ class htmlPlugin {
|
|
|
43
43
|
text: `set directory: ${this.sessionDir}`,
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
-
this.createPDF = async (
|
|
46
|
+
this.createPDF = async (args, __options) => {
|
|
47
|
+
const { filename } = args;
|
|
47
48
|
const imageWidth = 1536;
|
|
48
49
|
const imageHeight = 1024;
|
|
49
50
|
const pageWidth = imageWidth * 0.75; // 1152pt
|
|
@@ -66,7 +67,7 @@ class htmlPlugin {
|
|
|
66
67
|
right: 0,
|
|
67
68
|
},
|
|
68
69
|
});
|
|
69
|
-
doc.pipe(fs_1.default.createWriteStream(path_1.default.resolve(outputDir,
|
|
70
|
+
doc.pipe(fs_1.default.createWriteStream(path_1.default.resolve(outputDir, filename)));
|
|
70
71
|
files.forEach((f, i) => {
|
|
71
72
|
if (i > 0) {
|
|
72
73
|
doc.addPage({
|
|
@@ -87,6 +88,7 @@ class htmlPlugin {
|
|
|
87
88
|
this.outputDir = outputDir ?? (0, utils_1.getOutDir)();
|
|
88
89
|
this.rootDir = rootDir ?? (0, utils_1.getRootDir)();
|
|
89
90
|
this.sessionDir = "";
|
|
91
|
+
this.htmlDir = htmlDir ?? "html2";
|
|
90
92
|
this.templateOptions = templateOptions ?? {};
|
|
91
93
|
}
|
|
92
94
|
}
|
package/lib/tools/index.js
CHANGED
|
@@ -66,9 +66,9 @@ exports.mcp_tools = [
|
|
|
66
66
|
parameters: {
|
|
67
67
|
type: "object",
|
|
68
68
|
properties: {
|
|
69
|
-
|
|
69
|
+
filename: { type: "string", description: "pdf file name" },
|
|
70
70
|
},
|
|
71
|
-
required: ["
|
|
71
|
+
required: ["filename"],
|
|
72
72
|
},
|
|
73
73
|
},
|
|
74
74
|
},
|
package/lib/utils.js
CHANGED
|
@@ -8,6 +8,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const os_1 = __importDefault(require("os"));
|
|
10
10
|
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
11
|
+
const commons_1 = require("./commons");
|
|
11
12
|
const isCI = process.env.CI === "true";
|
|
12
13
|
const renderHTMLToImage = async (html, outputPath, width, height) => {
|
|
13
14
|
// Use Puppeteer to render HTML to an image
|
|
@@ -72,8 +73,7 @@ const getRootDir = () => {
|
|
|
72
73
|
exports.getRootDir = getRootDir;
|
|
73
74
|
const getOutDir = () => {
|
|
74
75
|
const documentsDir = path_1.default.join(os_1.default.homedir(), "Documents");
|
|
75
|
-
|
|
76
|
-
return path_1.default.join(documentsDir, "mulmocast-vision", String(now));
|
|
76
|
+
return path_1.default.join(documentsDir, "mulmocast-vision", (0, commons_1.formattedDate)());
|
|
77
77
|
};
|
|
78
78
|
exports.getOutDir = getOutDir;
|
|
79
79
|
const debugLogger = (data) => {
|