@8btc/office-assistant-mcp 0.0.9 → 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.
Files changed (2) hide show
  1. package/dist/index.cjs +51 -35
  2. 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 = `![${alt || ""}](${encodeURIComponent(src)})`;
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,
@@ -77007,7 +77023,7 @@ const extractAllImageSrc = (html2) => {
77007
77023
  logger.info("extractAllImageSrc match[0]:" + match[0], match[1]);
77008
77024
  logger.info("extractAllImageSrc match[1]:" + match[1]);
77009
77025
  }
77010
- if (isLocalPath(match[1])) {
77026
+ if (isLocalPath(decodeURIComponent(match[1]))) {
77011
77027
  srcs.push(match[1]);
77012
77028
  }
77013
77029
  }
@@ -77045,7 +77061,7 @@ const createPage = async (page, item) => {
77045
77061
  );
77046
77062
  const _html = html2.replaceAll(reg, (m) => {
77047
77063
  const item2 = localFileInfoList.find(
77048
- (info) => m.indexOf(info.src) !== -1
77064
+ (info) => m.indexOf(info?.src || "") !== -1
77049
77065
  );
77050
77066
  if (item2) {
77051
77067
  return m.replace(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8btc/office-assistant-mcp",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "办公agent辅助mcp工具",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",