mulmocast-vision 0.0.6 → 0.0.7
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 +17 -0
- package/lib/commons.d.ts +15 -2
- package/lib/commons.js +16 -3
- package/lib/mcp/cli.d.ts +2 -0
- package/lib/mcp/cli.js +21 -0
- package/lib/mcp/core.d.ts +25 -0
- package/lib/mcp/core.js +61 -0
- package/lib/mcp/server.js +5 -61
- package/lib/podcast.d.ts +1 -0
- package/lib/podcast.js +123 -0
- package/lib/presentationHandlers/html.d.ts +81 -320
- package/lib/presentationHandlers/html.js +5 -5
- package/lib/presentationHandlers/html_class.d.ts +81 -87
- package/lib/presentationHandlers/html_class.js +7 -7
- package/lib/presentationHandlers/vision_data_class.d.ts +98 -0
- package/lib/presentationHandlers/vision_data_class.js +255 -0
- package/lib/runner.js +1 -1
- package/lib/test.d.ts +1 -0
- package/lib/test.js +74 -0
- package/lib/type.d.ts +17 -0
- package/lib/type.js +2 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -84,6 +84,23 @@ yarn run build
|
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
mcp設定
|
|
87
|
+
|
|
88
|
+
for dev
|
|
89
|
+
```
|
|
90
|
+
"mulmocast-vision": {
|
|
91
|
+
"command": "npx",
|
|
92
|
+
"args": [
|
|
93
|
+
"mulmocast-vision",
|
|
94
|
+
"page"
|
|
95
|
+
],
|
|
96
|
+
"transport": {
|
|
97
|
+
"stdio": true
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
for dev
|
|
87
104
|
```
|
|
88
105
|
"mulmocast-vision": {
|
|
89
106
|
"command": "env",
|
package/lib/commons.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
+
import { type OpenAITool } from "./type";
|
|
1
2
|
export declare const functionNameToTemplateName: (functionName: string) => string;
|
|
2
3
|
export declare const templateNameTofunctionName: (templateName: string) => string;
|
|
3
|
-
export declare const toolsToTemplateNames: (tools:
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const toolsToTemplateNames: (tools: OpenAITool[]) => string[];
|
|
5
|
+
export declare const openAIToolsToAnthropicTools: (tools: OpenAITool[]) => {
|
|
6
|
+
tools: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: string;
|
|
11
|
+
required: string[];
|
|
12
|
+
properties: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
export declare const convertTools: (tools: OpenAITool[]) => {
|
|
5
17
|
type: string;
|
|
6
18
|
function: {
|
|
7
19
|
name: string;
|
|
@@ -18,3 +30,4 @@ export declare const convertTools: (tools: any[]) => {
|
|
|
18
30
|
};
|
|
19
31
|
};
|
|
20
32
|
}[];
|
|
33
|
+
export declare const generateUniqueId: () => string;
|
package/lib/commons.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// utils for browser and node.
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.convertTools = exports.toolsToTemplateNames = exports.templateNameTofunctionName = exports.functionNameToTemplateName = void 0;
|
|
3
|
+
exports.generateUniqueId = exports.convertTools = exports.openAIToolsToAnthropicTools = exports.toolsToTemplateNames = exports.templateNameTofunctionName = exports.functionNameToTemplateName = void 0;
|
|
5
4
|
const functionNameToTemplateName = (functionName) => {
|
|
6
5
|
const tmpName = functionName.replace(/^create/, "");
|
|
7
6
|
const fileName = tmpName.charAt(0).toLowerCase() + tmpName.slice(1);
|
|
@@ -18,6 +17,15 @@ const toolsToTemplateNames = (tools) => {
|
|
|
18
17
|
});
|
|
19
18
|
};
|
|
20
19
|
exports.toolsToTemplateNames = toolsToTemplateNames;
|
|
20
|
+
const openAIToolsToAnthropicTools = (tools) => {
|
|
21
|
+
return {
|
|
22
|
+
tools: tools.map((tool) => {
|
|
23
|
+
const { name, description, parameters } = tool.function;
|
|
24
|
+
return { name, description, inputSchema: parameters };
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.openAIToolsToAnthropicTools = openAIToolsToAnthropicTools;
|
|
21
29
|
const convertTools = (tools) => {
|
|
22
30
|
return tools.map((tool) => {
|
|
23
31
|
const { name, description, parameters } = tool.function;
|
|
@@ -29,7 +37,6 @@ const convertTools = (tools) => {
|
|
|
29
37
|
description: "What the presenter will say for this slide (1–3 sentences).",
|
|
30
38
|
},
|
|
31
39
|
};
|
|
32
|
-
console.log(newProperties);
|
|
33
40
|
return {
|
|
34
41
|
type: "function",
|
|
35
42
|
function: {
|
|
@@ -45,3 +52,9 @@ const convertTools = (tools) => {
|
|
|
45
52
|
});
|
|
46
53
|
};
|
|
47
54
|
exports.convertTools = convertTools;
|
|
55
|
+
const generateUniqueId = () => {
|
|
56
|
+
const now = Date.now();
|
|
57
|
+
const random = Math.random().toString(36).slice(-10);
|
|
58
|
+
return `${now}-${random}`;
|
|
59
|
+
};
|
|
60
|
+
exports.generateUniqueId = generateUniqueId;
|
package/lib/mcp/cli.d.ts
ADDED
package/lib/mcp/cli.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const core_1 = require("./core");
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const main = async () => {
|
|
13
|
+
const rootDir = (0, utils_1.getRootDir)();
|
|
14
|
+
const documentsDir = path_1.default.join(os_1.default.homedir(), "Documents");
|
|
15
|
+
const outputDir = path_1.default.join(documentsDir, "mulmocast-vision");
|
|
16
|
+
(0, utils_1.mkdir)(outputDir);
|
|
17
|
+
const server = (0, core_1.getServer)(rootDir, outputDir);
|
|
18
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
19
|
+
await server.connect(transport);
|
|
20
|
+
};
|
|
21
|
+
main();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
export declare const getServer: (rootDir: string, outputDir: string) => Server<{
|
|
4
|
+
method: string;
|
|
5
|
+
params?: {
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
_meta?: {
|
|
8
|
+
[x: string]: unknown;
|
|
9
|
+
progressToken?: string | number | undefined;
|
|
10
|
+
} | undefined;
|
|
11
|
+
} | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
method: string;
|
|
14
|
+
params?: {
|
|
15
|
+
[x: string]: unknown;
|
|
16
|
+
_meta?: {
|
|
17
|
+
[x: string]: unknown;
|
|
18
|
+
} | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
[x: string]: unknown;
|
|
22
|
+
_meta?: {
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
} | undefined;
|
|
25
|
+
}>;
|
package/lib/mcp/core.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getServer = void 0;
|
|
5
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
6
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
7
|
+
const tools_1 = require("../tools");
|
|
8
|
+
const html_class_1 = require("../presentationHandlers/html_class");
|
|
9
|
+
const commons_1 = require("../commons");
|
|
10
|
+
const getServer = (rootDir, outputDir) => {
|
|
11
|
+
const server = new index_js_1.Server({
|
|
12
|
+
name: "mulmocast-vision-mcp",
|
|
13
|
+
version: "0.1.0",
|
|
14
|
+
}, {
|
|
15
|
+
capabilities: {
|
|
16
|
+
tools: {},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// List available tools
|
|
20
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
21
|
+
return (0, commons_1.openAIToolsToAnthropicTools)(tools_1.tools);
|
|
22
|
+
});
|
|
23
|
+
const handler = new html_class_1.htmlPlugin({ outputDir, rootDir });
|
|
24
|
+
// Handle tool calls
|
|
25
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
26
|
+
const { name, arguments: args } = request.params;
|
|
27
|
+
try {
|
|
28
|
+
if (name in handler) {
|
|
29
|
+
const key = name;
|
|
30
|
+
const method = handler[key];
|
|
31
|
+
if (typeof method === "function") {
|
|
32
|
+
const fileName = (0, commons_1.generateUniqueId)();
|
|
33
|
+
await method(args, { functionName: name, outputFileName: fileName });
|
|
34
|
+
return {
|
|
35
|
+
content: [
|
|
36
|
+
{
|
|
37
|
+
type: "text",
|
|
38
|
+
text: `html generated successfully to: ${outputDir} ${fileName}`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Unknown command: ${name}.`);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: `Error: ${errorMessage}`,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
isError: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return server;
|
|
60
|
+
};
|
|
61
|
+
exports.getServer = getServer;
|
package/lib/mcp/server.js
CHANGED
|
@@ -1,72 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
5
4
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
-
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
7
5
|
const graphai_1 = require("graphai");
|
|
8
|
-
const tools_1 = require("../tools");
|
|
9
|
-
const html_class_1 = require("../presentationHandlers/html_class");
|
|
10
6
|
const utils_1 = require("../utils");
|
|
11
|
-
const
|
|
12
|
-
name: "mulmocast-vision-mcp",
|
|
13
|
-
version: "0.1.0",
|
|
14
|
-
}, {
|
|
15
|
-
capabilities: {
|
|
16
|
-
tools: {},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
// List available tools
|
|
20
|
-
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
21
|
-
return {
|
|
22
|
-
tools: tools_1.tools.map((tool) => {
|
|
23
|
-
const { name, description, parameters } = tool.function;
|
|
24
|
-
return { name, description, inputSchema: parameters };
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
const rootDir = (0, utils_1.getRootDir)();
|
|
29
|
-
const outputDir = (0, utils_1.getOutDir)();
|
|
30
|
-
(0, utils_1.mkdir)(outputDir);
|
|
31
|
-
const handler = new html_class_1.htmlPlugin({ outputDir, rootDir });
|
|
32
|
-
let index = 0;
|
|
33
|
-
// Handle tool calls
|
|
34
|
-
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
35
|
-
const { name, arguments: args } = request.params;
|
|
36
|
-
try {
|
|
37
|
-
if (name in handler) {
|
|
38
|
-
const key = name;
|
|
39
|
-
const method = handler[key];
|
|
40
|
-
if (typeof method === "function") {
|
|
41
|
-
index = index + 1;
|
|
42
|
-
await method(args, { name, index });
|
|
43
|
-
return {
|
|
44
|
-
content: [
|
|
45
|
-
{
|
|
46
|
-
type: "text",
|
|
47
|
-
text: `html generated successfully to: ${outputDir}`,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
throw new Error(`Unknown command: ${name}.`);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
57
|
-
return {
|
|
58
|
-
content: [
|
|
59
|
-
{
|
|
60
|
-
type: "text",
|
|
61
|
-
text: `Error: ${errorMessage}`,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
isError: true,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
});
|
|
7
|
+
const core_1 = require("./core");
|
|
68
8
|
// Start the server
|
|
69
9
|
async function main() {
|
|
10
|
+
const rootDir = (0, utils_1.getRootDir)();
|
|
11
|
+
const outputDir = (0, utils_1.getOutDir)();
|
|
12
|
+
(0, utils_1.mkdir)(outputDir);
|
|
13
|
+
const server = (0, core_1.getServer)(rootDir, outputDir);
|
|
70
14
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
71
15
|
await server.connect(transport);
|
|
72
16
|
graphai_1.GraphAILogger.error("MulmoCast Vision MCP Server running on stdio");
|
package/lib/podcast.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "dotenv/config";
|
package/lib/podcast.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
require("dotenv/config");
|
|
40
|
+
const openai_agent_1 = require("@graphai/openai_agent");
|
|
41
|
+
const agents = __importStar(require("@graphai/vanilla"));
|
|
42
|
+
const graphai_1 = require("graphai");
|
|
43
|
+
const html_class_1 = require("./presentationHandlers/html_class");
|
|
44
|
+
const runner_1 = require("./runner");
|
|
45
|
+
const utils_1 = require("./utils");
|
|
46
|
+
const fs_1 = __importDefault(require("fs"));
|
|
47
|
+
const path_1 = __importDefault(require("path"));
|
|
48
|
+
const text = fs_1.default.readFileSync(path_1.default.resolve(__dirname, "../tests/text.md"), "utf-8");
|
|
49
|
+
console.log(text);
|
|
50
|
+
const main = async () => {
|
|
51
|
+
const data = {
|
|
52
|
+
version: 0.5,
|
|
53
|
+
concurrency: 4,
|
|
54
|
+
nodes: {
|
|
55
|
+
text: {
|
|
56
|
+
value: text,
|
|
57
|
+
},
|
|
58
|
+
llm: {
|
|
59
|
+
agent: "openAIAgent",
|
|
60
|
+
inputs: {
|
|
61
|
+
prompt: ":text",
|
|
62
|
+
},
|
|
63
|
+
params: {},
|
|
64
|
+
},
|
|
65
|
+
script: {
|
|
66
|
+
//isResult: true,
|
|
67
|
+
agent: "copyAgent",
|
|
68
|
+
params: {
|
|
69
|
+
namedKey: "script",
|
|
70
|
+
},
|
|
71
|
+
inputs: {
|
|
72
|
+
script: ":llm.text.codeBlock().jsonParse()",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
map: {
|
|
76
|
+
inputs: {
|
|
77
|
+
rows: ":script.beats",
|
|
78
|
+
},
|
|
79
|
+
agent: "mapAgent",
|
|
80
|
+
isResult: true,
|
|
81
|
+
graph: {
|
|
82
|
+
version: 0.5,
|
|
83
|
+
concurrency: 4,
|
|
84
|
+
nodes: {
|
|
85
|
+
data: {
|
|
86
|
+
isResult: true,
|
|
87
|
+
agent: "copyAgent",
|
|
88
|
+
inputs: {
|
|
89
|
+
row: ":row",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
/*
|
|
94
|
+
llm: {
|
|
95
|
+
agent: "openAIAgent",
|
|
96
|
+
inputs: {
|
|
97
|
+
prompt: ":text"
|
|
98
|
+
},
|
|
99
|
+
params: {},
|
|
100
|
+
},
|
|
101
|
+
*/
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
const graphai = new graphai_1.GraphAI(data, { ...agents, openAIAgent: openai_agent_1.openAIAgent });
|
|
107
|
+
const res = await graphai.run();
|
|
108
|
+
console.log(JSON.stringify(res, null, 2));
|
|
109
|
+
const rootDir = (0, utils_1.getRootDir)();
|
|
110
|
+
const outputDir = (0, utils_1.getOutDir)();
|
|
111
|
+
(0, utils_1.mkdir)(outputDir);
|
|
112
|
+
/// if (res) {
|
|
113
|
+
if (false) {
|
|
114
|
+
console.log(JSON.stringify(res.tool_calls, null, 2));
|
|
115
|
+
const handler = new html_class_1.htmlPlugin({ outputDir, rootDir });
|
|
116
|
+
(0, runner_1.toolsRunner)(handler, res.tool_calls);
|
|
117
|
+
(0, utils_1.writeJSONData)(outputDir, res.tool_calls);
|
|
118
|
+
}
|
|
119
|
+
// toolsRunner(presentationHandlers, res.tool_calls);
|
|
120
|
+
// for debug
|
|
121
|
+
// presentationHandlers.writeJSONData(res.tool_calls);
|
|
122
|
+
};
|
|
123
|
+
main();
|