@8btc/office-assistant-mcp 0.0.8 → 0.0.10
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/index.cjs +59 -35
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -15,8 +15,8 @@ const index_js = require("@modelcontextprotocol/sdk/server/index.js");
|
|
|
15
15
|
const types_js = require("@modelcontextprotocol/sdk/types.js");
|
|
16
16
|
const ReactDOMServer = require("react-dom/server");
|
|
17
17
|
const qrcode_react = require("qrcode.react");
|
|
18
|
-
const zod = require("zod");
|
|
19
18
|
const winston = require("winston");
|
|
19
|
+
const zod = require("zod");
|
|
20
20
|
const zodToJsonSchema$1 = require("zod-to-json-schema");
|
|
21
21
|
const fs = require("fs");
|
|
22
22
|
const fsPromises = require("fs/promises");
|
|
@@ -74950,6 +74950,21 @@ const CodeBlock = ({ inline, className, children, ...props }) => {
|
|
|
74950
74950
|
}
|
|
74951
74951
|
) }) : /* @__PURE__ */ jsxRuntime.jsx("code", { ...props, className, children });
|
|
74952
74952
|
};
|
|
74953
|
+
const imgRegex = /!\[(.*?)\]\((.*?)\)/g;
|
|
74954
|
+
const windowsPattern = /[a-zA-Z]:(?:\\|\/)[^\s"'`<>|?*]*(?:[\\/][^\s"'`<>|?*]*)*/g;
|
|
74955
|
+
const replaceMarkdown = (mdContent) => {
|
|
74956
|
+
return mdContent.replaceAll(imgRegex, (m) => {
|
|
74957
|
+
let match;
|
|
74958
|
+
let result = "";
|
|
74959
|
+
while ((match = imgRegex.exec(m)) !== null) {
|
|
74960
|
+
const [, alt, src] = match;
|
|
74961
|
+
if (windowsPattern.test(src)) {
|
|
74962
|
+
result = `})`;
|
|
74963
|
+
}
|
|
74964
|
+
}
|
|
74965
|
+
return result || m;
|
|
74966
|
+
});
|
|
74967
|
+
};
|
|
74953
74968
|
const MarkdownRenderer = (props) => {
|
|
74954
74969
|
const { markDownContent } = props;
|
|
74955
74970
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -74965,7 +74980,7 @@ const MarkdownRenderer = (props) => {
|
|
|
74965
74980
|
]
|
|
74966
74981
|
],
|
|
74967
74982
|
components: { code: CodeBlock },
|
|
74968
|
-
children: markDownContent || ""
|
|
74983
|
+
children: replaceMarkdown(markDownContent || "")
|
|
74969
74984
|
}
|
|
74970
74985
|
);
|
|
74971
74986
|
};
|
|
@@ -76821,6 +76836,37 @@ const renderFullHtml = (segment) => {
|
|
|
76821
76836
|
`;
|
|
76822
76837
|
};
|
|
76823
76838
|
const getQrcodeUrl = () => process$1.env.QRCODE_URL || "https://reactjs.org/";
|
|
76839
|
+
const logger = winston.createLogger({
|
|
76840
|
+
level: "info",
|
|
76841
|
+
format: winston.format.json(),
|
|
76842
|
+
defaultMeta: { service: "user-service" },
|
|
76843
|
+
transports: [
|
|
76844
|
+
//
|
|
76845
|
+
// - Write all logs with importance level of `error` or higher to `error.log`
|
|
76846
|
+
// (i.e., error, fatal, but not other levels)
|
|
76847
|
+
//
|
|
76848
|
+
new winston.transports.File({
|
|
76849
|
+
dirname: "logs",
|
|
76850
|
+
filename: "office.loggererror.log",
|
|
76851
|
+
level: "error"
|
|
76852
|
+
}),
|
|
76853
|
+
//
|
|
76854
|
+
// - Write all logs with importance level of `info` or higher to `combined.log`
|
|
76855
|
+
// (i.e., fatal, error, warn, and info, but not trace)
|
|
76856
|
+
//
|
|
76857
|
+
new winston.transports.File({
|
|
76858
|
+
dirname: "logs",
|
|
76859
|
+
filename: "office.logercombined.log"
|
|
76860
|
+
})
|
|
76861
|
+
]
|
|
76862
|
+
});
|
|
76863
|
+
if (process.env.NODE_ENV !== "production") {
|
|
76864
|
+
logger.add(
|
|
76865
|
+
new winston.transports.Console({
|
|
76866
|
+
format: winston.format.simple()
|
|
76867
|
+
})
|
|
76868
|
+
);
|
|
76869
|
+
}
|
|
76824
76870
|
async function generateBasePdf(data) {
|
|
76825
76871
|
return [
|
|
76826
76872
|
{
|
|
@@ -76851,6 +76897,7 @@ const renderCover = (data) => {
|
|
|
76851
76897
|
};
|
|
76852
76898
|
const renderSegment = (data) => {
|
|
76853
76899
|
const html2 = ReactDOMServer.renderToString(/* @__PURE__ */ jsxRuntime.jsx(Segment, { data }));
|
|
76900
|
+
logger.error(html2);
|
|
76854
76901
|
return renderFullHtml(html2);
|
|
76855
76902
|
};
|
|
76856
76903
|
const renderEnd = (data) => {
|
|
@@ -76883,37 +76930,6 @@ const basePdfSchema = {
|
|
|
76883
76930
|
zod.z.object({
|
|
76884
76931
|
...basePdfSchema
|
|
76885
76932
|
});
|
|
76886
|
-
const logger = winston.createLogger({
|
|
76887
|
-
level: "info",
|
|
76888
|
-
format: winston.format.json(),
|
|
76889
|
-
defaultMeta: { service: "user-service" },
|
|
76890
|
-
transports: [
|
|
76891
|
-
//
|
|
76892
|
-
// - Write all logs with importance level of `error` or higher to `error.log`
|
|
76893
|
-
// (i.e., error, fatal, but not other levels)
|
|
76894
|
-
//
|
|
76895
|
-
new winston.transports.File({
|
|
76896
|
-
dirname: "logs",
|
|
76897
|
-
filename: "office.loggererror.log",
|
|
76898
|
-
level: "error"
|
|
76899
|
-
}),
|
|
76900
|
-
//
|
|
76901
|
-
// - Write all logs with importance level of `info` or higher to `combined.log`
|
|
76902
|
-
// (i.e., fatal, error, warn, and info, but not trace)
|
|
76903
|
-
//
|
|
76904
|
-
new winston.transports.File({
|
|
76905
|
-
dirname: "logs",
|
|
76906
|
-
filename: "office.logercombined.log"
|
|
76907
|
-
})
|
|
76908
|
-
]
|
|
76909
|
-
});
|
|
76910
|
-
if (process.env.NODE_ENV !== "production") {
|
|
76911
|
-
logger.add(
|
|
76912
|
-
new winston.transports.Console({
|
|
76913
|
-
format: winston.format.simple()
|
|
76914
|
-
})
|
|
76915
|
-
);
|
|
76916
|
-
}
|
|
76917
76933
|
const zodToJsonSchema = (schema) => {
|
|
76918
76934
|
return zodToJsonSchema$1.zodToJsonSchema(zod.z.object(schema), {
|
|
76919
76935
|
rejectedAdditionalProperties: void 0,
|
|
@@ -77003,7 +77019,11 @@ const extractAllImageSrc = (html2) => {
|
|
|
77003
77019
|
const srcs = [];
|
|
77004
77020
|
let match;
|
|
77005
77021
|
while ((match = regex.exec(html2)) !== null) {
|
|
77006
|
-
if (
|
|
77022
|
+
if (!match[1].startsWith("data:image/")) {
|
|
77023
|
+
logger.info("extractAllImageSrc match[0]:" + match[0], match[1]);
|
|
77024
|
+
logger.info("extractAllImageSrc match[1]:" + match[1]);
|
|
77025
|
+
}
|
|
77026
|
+
if (isLocalPath(decodeURIComponent(match[1]))) {
|
|
77007
77027
|
srcs.push(match[1]);
|
|
77008
77028
|
}
|
|
77009
77029
|
}
|
|
@@ -77041,7 +77061,7 @@ const createPage = async (page, item) => {
|
|
|
77041
77061
|
);
|
|
77042
77062
|
const _html = html2.replaceAll(reg, (m) => {
|
|
77043
77063
|
const item2 = localFileInfoList.find(
|
|
77044
|
-
(info) => m.indexOf(info
|
|
77064
|
+
(info) => m.indexOf(info?.src || "") !== -1
|
|
77045
77065
|
);
|
|
77046
77066
|
if (item2) {
|
|
77047
77067
|
return m.replace(
|
|
@@ -77232,6 +77252,10 @@ const tool = {
|
|
|
77232
77252
|
const toolHandler = async (args) => {
|
|
77233
77253
|
try {
|
|
77234
77254
|
logger.info(`start: ${(/* @__PURE__ */ new Date()).getTime()}`);
|
|
77255
|
+
try {
|
|
77256
|
+
logger.info(JSON.stringify(args));
|
|
77257
|
+
} catch (e) {
|
|
77258
|
+
}
|
|
77235
77259
|
const generatedTemplates = await generateBasePdf(args);
|
|
77236
77260
|
const pdfUrl = await generatePDF({
|
|
77237
77261
|
list: generatedTemplates,
|