@eigenpal/docx-js-editor 0.0.11 → 0.0.13
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/DocumentAgent-Ci6_T-XM.d.ts +412 -0
- package/dist/DocumentAgent-DEGFgYEN.d.cts +412 -0
- package/dist/FindReplaceDialog-BAACAU67.cjs +1 -0
- package/dist/FindReplaceDialog-RWYDRWHF.js +1 -0
- package/dist/FootnotePropertiesDialog-BC6JIPDA.cjs +1 -0
- package/dist/FootnotePropertiesDialog-CWQF5EBK.js +1 -0
- package/dist/HyperlinkDialog-EG2BSLPD.cjs +1 -0
- package/dist/HyperlinkDialog-YAVK64F4.js +1 -0
- package/dist/ImagePositionDialog-IGYS5KMK.cjs +1 -0
- package/dist/ImagePositionDialog-S6SMH7XH.js +1 -0
- package/dist/ImagePropertiesDialog-UO5QUIBS.js +1 -0
- package/dist/ImagePropertiesDialog-VGV4E4SN.cjs +1 -0
- package/dist/TablePropertiesDialog-VBOU4DID.js +1 -0
- package/dist/TablePropertiesDialog-WRM47JI6.cjs +1 -0
- package/dist/{types-BALm1KBi.d.cts → agentApi-CbVUCZRu.d.cts} +1 -308
- package/dist/{types-BALm1KBi.d.ts → agentApi-CbVUCZRu.d.ts} +1 -308
- package/dist/chunk-2ASOEN3V.js +1 -0
- package/dist/chunk-6MBDPZVD.js +111 -0
- package/dist/chunk-6YLNNCRZ.cjs +10 -0
- package/dist/chunk-BVQ2QRHA.cjs +4 -0
- package/dist/chunk-COP5BIBZ.js +10 -0
- package/dist/chunk-CZ7W7MCM.cjs +2 -0
- package/dist/chunk-E6XDMUAM.js +4 -0
- package/dist/chunk-EMKABJPH.js +1 -0
- package/dist/{chunk-TRAQI6RX.cjs → chunk-EPCZ24TY.cjs} +5 -5
- package/dist/chunk-ESI4BSBF.js +1 -0
- package/dist/chunk-FLECKDK4.cjs +58 -0
- package/dist/chunk-ITWEFKGQ.cjs +1 -0
- package/dist/chunk-KESNGXGO.js +1 -0
- package/dist/chunk-KVAT5SVD.js +2 -0
- package/dist/chunk-L34XFLQZ.cjs +1 -0
- package/dist/chunk-M7F2CUUD.js +2 -0
- package/dist/chunk-MDPDH7KS.js +58 -0
- package/dist/chunk-MTX3EEBJ.js +258 -0
- package/dist/chunk-NT2REEAA.cjs +1 -0
- package/dist/{chunk-PM4Y7OFN.js → chunk-OTG4NABM.js} +5 -5
- package/dist/chunk-OW5H5DNE.cjs +1 -0
- package/dist/chunk-PJVI53AH.js +2 -0
- package/dist/chunk-PNMZPPPI.cjs +2 -0
- package/dist/chunk-SF53KLDZ.cjs +1 -0
- package/dist/chunk-TOI5W3HK.js +8 -0
- package/dist/chunk-UAVOWAIF.cjs +8 -0
- package/dist/chunk-VN7XH644.cjs +258 -0
- package/dist/chunk-W4DUKACP.cjs +111 -0
- package/dist/chunk-XS2AQFMF.cjs +2 -0
- package/dist/chunk-ZDYHAYN6.js +1 -0
- package/dist/clipboard-BOocwmAM.d.ts +539 -0
- package/dist/clipboard-Cx7cb3kX.d.cts +539 -0
- package/dist/{colorResolver-BNj-uZ58.d.ts → colorResolver-CIDiSPWd.d.cts} +3 -411
- package/dist/{colorResolver-DiMquGWR.d.cts → colorResolver-KXbUgzWC.d.ts} +3 -411
- package/dist/core-plugins.cjs +1 -1
- package/dist/core-plugins.d.cts +4 -3
- package/dist/core-plugins.d.ts +4 -3
- package/dist/core-plugins.js +1 -1
- package/dist/core.cjs +1 -0
- package/dist/core.d.cts +23 -0
- package/dist/core.d.ts +23 -0
- package/dist/core.js +1 -0
- package/dist/headless.cjs +2 -2
- package/dist/headless.d.cts +8 -175
- package/dist/headless.d.ts +8 -175
- package/dist/headless.js +1 -1
- package/dist/index.cjs +9 -378
- package/dist/index.d.cts +17 -4161
- package/dist/index.d.ts +17 -4161
- package/dist/index.js +9 -378
- package/dist/insertOperations-CzB5b-Of.d.ts +176 -0
- package/dist/insertOperations-DKVmCV32.d.cts +176 -0
- package/dist/mcp-cli.js +21 -21
- package/dist/mcp.cjs +10 -10
- package/dist/mcp.d.cts +2 -1
- package/dist/mcp.d.ts +2 -1
- package/dist/mcp.js +9 -9
- package/dist/processTemplate-BHBTDAIC.js +1 -0
- package/dist/processTemplate-QOEAXCKA.cjs +1 -0
- package/dist/react-Be1YOl4z.d.ts +1356 -0
- package/dist/react-DPuSVbgY.d.cts +1356 -0
- package/dist/react.cjs +1 -0
- package/dist/react.css +1 -0
- package/dist/react.d.cts +9 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.js +1 -0
- package/dist/{registry-CzqAPdui.d.ts → registry-D4tvj9f3.d.ts} +1 -1
- package/dist/{registry-BUTMLqSj.d.cts → registry-ngv6Bumt.d.cts} +1 -1
- package/dist/types-D96elyJF.d.cts +310 -0
- package/dist/types-xMzSPT4i.d.ts +310 -0
- package/dist/ui.cjs +1 -0
- package/dist/ui.d.cts +2103 -0
- package/dist/ui.d.ts +2103 -0
- package/dist/ui.js +1 -0
- package/dist/variableDetector-CPxKo9jP.d.cts +173 -0
- package/dist/variableDetector-DeM1N-_L.d.ts +173 -0
- package/package.json +85 -10
- package/dist/chunk-GQ4JYQWC.js +0 -58
- package/dist/chunk-H3JNHCD7.cjs +0 -10
- package/dist/chunk-L2UUZRZI.js +0 -10
- package/dist/chunk-QOIY4Y6N.cjs +0 -9
- package/dist/chunk-QYKJKSKZ.cjs +0 -58
- package/dist/chunk-TPUJJJWA.js +0 -9
package/dist/mcp.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkFLECKDK4_cjs=require('./chunk-FLECKDK4.cjs'),chunkA7VY2V4X_cjs=require('./chunk-A7VY2V4X.cjs'),chunkEPCZ24TY_cjs=require('./chunk-EPCZ24TY.cjs'),chunkXVFMG77A_cjs=require('./chunk-XVFMG77A.cjs');require('./chunk-RTESADL3.cjs');var u={type:"string",description:"Document ID returned from docx_load"},x={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},h={type:"object",properties:{start:x,end:x},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
|
|
2
2
|
Returns a document ID that can be used with other tools.
|
|
3
|
-
The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=n.buffer,a=await
|
|
4
|
-
Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await
|
|
3
|
+
The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=n.buffer,a=await chunkEPCZ24TY_cjs.p(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a,buffer:o,source:c,lastModified:Date.now()});let p=a.package.document.content.filter(l=>l.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:d,source:c,paragraphCount:p,message:"Document loaded successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to load document: ${t.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},C={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
|
|
4
|
+
Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await chunkFLECKDK4_cjs.d(c.document):t=await chunkFLECKDK4_cjs.e(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
|
|
5
5
|
Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r;return s.session.documents.has(e)?(s.session.documents.delete(e),{content:[{type:"text",text:JSON.stringify({documentId:e,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${e}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},k={name:"docx_get_info",description:`Get metadata and statistics about a document.
|
|
6
|
-
Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(
|
|
6
|
+
Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(y=>y.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
|
|
7
7
|
Returns all text concatenated with paragraph breaks.
|
|
8
8
|
Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:u,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(r,s)=>{let{documentId:e,maxLength:c=1e4}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let n=t.document.package.document,o=[];for(let p of n.content)p.type==="paragraph"?o.push(P(p)):p.type==="table"&&o.push("[TABLE]");let a=o.join(`
|
|
9
9
|
`),d=a.length>c;return d&&(a=a.slice(0,c)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:e,text:a,truncated:d,totalLength:d?o.join(`
|
|
10
10
|
`).length:a.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},J={name:"docx_insert_text",description:`Insert text at a specific position in the document.
|
|
11
|
-
Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:
|
|
12
|
-
Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:
|
|
13
|
-
Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:
|
|
14
|
-
Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:
|
|
15
|
-
Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkA7VY2V4X_cjs.a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var
|
|
16
|
-
`);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}exports.applyStyleTool=O;exports.closeDocumentTool=R;exports.coreMcpTools=
|
|
11
|
+
Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:x,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkA7VY2V4X_cjs.a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
|
|
12
|
+
Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:h,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkA7VY2V4X_cjs.a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
|
|
13
|
+
Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:h},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=chunkA7VY2V4X_cjs.a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
|
|
14
|
+
Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:h,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkA7VY2V4X_cjs.a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
|
|
15
|
+
Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkA7VY2V4X_cjs.a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var T=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of T)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=chunkXVFMG77A_cjs.b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function y(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:y,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
|
|
16
|
+
`);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}exports.applyStyleTool=O;exports.closeDocumentTool=R;exports.coreMcpTools=T;exports.createMcpServer=q;exports.deleteTextTool=j;exports.formatTextTool=E;exports.getDocumentInfoTool=k;exports.getDocumentTextTool=$;exports.handleJsonRpcRequest=F;exports.insertTextTool=J;exports.loadDocumentTool=D;exports.replaceTextTool=v;exports.saveDocumentTool=C;exports.startStdioServer=H;
|
package/dist/mcp.d.cts
CHANGED
package/dist/mcp.d.ts
CHANGED
package/dist/mcp.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {d,e}from'./chunk-
|
|
1
|
+
import {d,e}from'./chunk-MDPDH7KS.js';import {a}from'./chunk-MMJD2DLL.js';import {p}from'./chunk-OTG4NABM.js';import {b}from'./chunk-QHWHCIUW.js';import'./chunk-3IYNTJO5.js';var u={type:"string",description:"Document ID returned from docx_load"},x={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},h={type:"object",properties:{start:x,end:x},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
|
|
2
2
|
Returns a document ID that can be used with other tools.
|
|
3
|
-
The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o
|
|
3
|
+
The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=n.buffer,a=await p(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a,buffer:o,source:c,lastModified:Date.now()});let p$1=a.package.document.content.filter(l=>l.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:d,source:c,paragraphCount:p$1,message:"Document loaded successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to load document: ${t.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},C={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
|
|
4
4
|
Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e$1}=r,c=s.session.documents.get(e$1);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e$1}`}]};try{let t;c.buffer?t=await d(c.document):t=await e(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e$1,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
|
|
5
5
|
Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r;return s.session.documents.has(e)?(s.session.documents.delete(e),{content:[{type:"text",text:JSON.stringify({documentId:e,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${e}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},k={name:"docx_get_info",description:`Get metadata and statistics about a document.
|
|
6
|
-
Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(
|
|
6
|
+
Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(y=>y.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
|
|
7
7
|
Returns all text concatenated with paragraph breaks.
|
|
8
8
|
Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:u,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(r,s)=>{let{documentId:e,maxLength:c=1e4}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let n=t.document.package.document,o=[];for(let p of n.content)p.type==="paragraph"?o.push(P(p)):p.type==="table"&&o.push("[TABLE]");let a=o.join(`
|
|
9
9
|
`),d=a.length>c;return d&&(a=a.slice(0,c)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:e,text:a,truncated:d,totalLength:d?o.join(`
|
|
10
10
|
`).length:a.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},J={name:"docx_insert_text",description:`Insert text at a specific position in the document.
|
|
11
|
-
Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:
|
|
12
|
-
Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:
|
|
13
|
-
Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:
|
|
14
|
-
Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:
|
|
15
|
-
Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var
|
|
16
|
-
`);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}export{O as applyStyleTool,R as closeDocumentTool,
|
|
11
|
+
Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:x,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
|
|
12
|
+
Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:h,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
|
|
13
|
+
Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:h},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
|
|
14
|
+
Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:h,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
|
|
15
|
+
Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var T=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of T)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function y(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:y,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
|
|
16
|
+
`);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}export{O as applyStyleTool,R as closeDocumentTool,T as coreMcpTools,q as createMcpServer,j as deleteTextTool,E as formatTextTool,k as getDocumentInfoTool,$ as getDocumentTextTool,F as handleJsonRpcRequest,J as insertTextTool,D as loadDocumentTool,v as replaceTextTool,C as saveDocumentTool,H as startStdioServer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{j as createTemplateProcessor,k as default,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,d as processTemplateAndDownload,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-ESI4BSBF.js';import'./chunk-3IYNTJO5.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkITWEFKGQ_cjs=require('./chunk-ITWEFKGQ.cjs');require('./chunk-RTESADL3.cjs');Object.defineProperty(exports,"createTemplateProcessor",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.j}});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.k}});Object.defineProperty(exports,"getMissingVariables",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.g}});Object.defineProperty(exports,"getTemplateTags",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.e}});Object.defineProperty(exports,"previewTemplate",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.h}});Object.defineProperty(exports,"processTemplate",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.a}});Object.defineProperty(exports,"processTemplateAdvanced",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.i}});Object.defineProperty(exports,"processTemplateAndDownload",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.d}});Object.defineProperty(exports,"processTemplateAsBlob",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.c}});Object.defineProperty(exports,"processTemplateDetailed",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.b}});Object.defineProperty(exports,"validateTemplate",{enumerable:true,get:function(){return chunkITWEFKGQ_cjs.f}});
|