@eigenpal/docx-editor-agents 1.5.0 → 1.6.0
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 +1 -1
- package/dist/ai-sdk/server.js +1 -1
- package/dist/ai-sdk/server.mjs +1 -1
- package/dist/bridge.d.mts +1 -1
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/bridge.mjs +1 -1
- package/dist/{chunk-HTMMNA3I.js → chunk-4C2IJ7OV.js} +20 -20
- package/dist/{chunk-XDZHYYU6.mjs → chunk-6RMDMHUK.mjs} +1 -1
- package/dist/{chunk-RI5S75JY.js → chunk-AO5SO6ZS.js} +4 -4
- package/dist/chunk-B56JZP3K.js +2 -0
- package/dist/{chunk-BFGKTTP7.mjs → chunk-CGBO6ID5.mjs} +1 -1
- package/dist/chunk-ICDWMZPG.mjs +75 -0
- package/dist/{chunk-HSVOT6AW.mjs → chunk-J773ZJGL.mjs} +5 -5
- package/dist/{chunk-EPRXZTIE.js → chunk-MMJQ47Q7.js} +1 -1
- package/dist/{chunk-24MVJKCP.mjs → chunk-MSKW7E36.mjs} +4 -4
- package/dist/{chunk-RYT33AHF.js → chunk-VAQTAQZG.js} +1 -1
- package/dist/chunk-WDPSOX2B.mjs +2 -0
- package/dist/{chunk-VPUAYS3Y.js → chunk-YU3OJ2DE.js} +5 -5
- package/dist/executor-3N3ESB3N.mjs +1 -0
- package/dist/executor-KLVHM2GK.js +1 -0
- package/dist/headless-BS5JJGVC.js +1 -0
- package/dist/{headless-6HFY6GHX.mjs → headless-GFPWSIA3.mjs} +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +3 -3
- package/dist/mcp.mjs +3 -3
- package/dist/react.d.mts +8 -8
- package/dist/react.d.ts +8 -8
- package/dist/react.js +2 -2
- package/dist/react.mjs +1 -1
- package/dist/{server-D1vJRNf0.d.mts → server-DP8QoY84.d.mts} +22 -0
- package/dist/{server-D1vJRNf0.d.ts → server-DP8QoY84.d.ts} +22 -0
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/server.mjs +1 -1
- package/dist/vue.js +6 -6
- package/dist/vue.mjs +226 -179
- package/package.json +1 -1
- package/dist/chunk-3XKOKAHP.mjs +0 -75
- package/dist/chunk-4I6U7BWX.mjs +0 -2
- package/dist/chunk-UTMAYI7M.js +0 -2
- package/dist/executor-SBR6X4JZ.mjs +0 -1
- package/dist/executor-ZTSOZMKE.js +0 -1
- package/dist/headless-HVIRJIN4.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {U as U$1,V,H as H$1,I,va}from'./chunk-
|
|
2
|
-
`)),
|
|
3
|
-
`),l=n.cellParaIds?.[e]?.[i];for(let
|
|
4
|
-
`)}function H(o,t,r){let n=[],a=new Set;for(let e of o.content){if(e.type==="commentRangeStart"&&r){a.add(e.id),n.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&r){a.has(e.id)&&(a.delete(e.id),n.push("[/comment]"));continue}if(e.type==="run")n.push(H$1(e));else if(e.type==="hyperlink")n.push(I(e));else if(m(e)){let i=b(e.content);e.type==="insertion"||e.type==="moveTo"?t&&n.push(`[+${i}+]{by:${e.info.author}}`):t?n.push(`[-${i}-]{by:${e.info.author}}`):n.push(i);}}return n.join("")}var C=class extends Error{constructor(t,r){let n=r!==void 0?` in paragraph ${r}`:" in document";super(`Text not found${n}: "${t}"`),this.name="TextNotFoundError";}},N=class extends Error{constructor(t){super(`Tracked change not found: id=${t}`),this.name="ChangeNotFoundError";}},R=class extends Error{constructor(t){super(`Comment not found: id=${t}`),this.name="CommentNotFoundError";}};function X(o){let t=[],r=0;for(let n=0;n<o.content.length;n++){let a=o.content[n];if(a.type==="run"){let e=H$1(a);t.push({contentIndex:n,run:a,text:e,startPos:r}),r+=e.length;}else if(a.type==="hyperlink")for(let e=0;e<a.children.length;e++){let i=a.children[e];if(i.type==="run"){let s=H$1(i);t.push({contentIndex:n,run:i,text:s,startPos:r}),r+=s.length;}}else if(m(a)){if(a.type==="insertion"||a.type==="moveTo")continue;for(let e=0;e<a.content.length;e++){let i=a.content[e];if(i.type==="run"){let s=H$1(i);t.push({contentIndex:n,run:i,text:s,startPos:r}),r+=s.length;}else if(i.type==="hyperlink"){for(let s of i.children)if(s.type==="run"){let
|
|
5
|
-
`)}function oe(o){let t=new Map,r=new Map;return F(o,(n,a)=>{for(let e of n.content)if(e.type==="commentRangeStart")r.set(e.id,{paragraphIndex:a,parts:[]});else if(e.type==="commentRangeEnd"){let i=r.get(e.id);i&&(t.set(e.id,{text:i.parts.join(""),paragraphIndex:i.paragraphIndex}),r.delete(e.id));}else if(e.type==="run"){let i=H$1(e);for(let s of r.values())s.parts.push(i);}else if(e.type==="hyperlink"){let i=e.children.filter(s=>s.type==="run").map(H$1).join("");for(let s of r.values())s.parts.push(i);}else if(m(e)){if(e.type==="insertion"||e.type==="moveTo")continue;let i=b(e.content);for(let s of r.values())s.parts.push(i);}}),t}function re(o){let t=o.toDocument().package?.document;if(!t)return new Map;let r=new Map,n=0;for(let a of t.content)if(a.type==="paragraph"){let e=a.paraId;r.set(e??String(n),n),n++;}else if(a.type==="table")for(let e of a.rows)for(let i of e.cells)for(let s of i.content)s.type==="paragraph"&&n++;else n++;return r}function ae(o){let t=[],r=n=>{for(let a of n.content)a.type==="text"&&t.push(a.text??"");};for(let n of o.content)if(n.type==="run")r(n);else if(n.type==="hyperlink")for(let a of n.children)a.type==="run"&&r(a);else if(n.type==="deletion"||n.type==="moveFrom"){for(let a of n.content)if(a.type==="run")r(a);else if(a.type==="hyperlink")for(let e of a.children)e.type==="run"&&r(e);}return t.join("")}function B(o,t){let n={type:"run",content:[{type:"text",text:t,preserveSpace:/^\s|\s$/.test(t)}]};return o.formatting&&(n.formatting={...o.formatting}),o.propertyChanges&&(n.propertyChanges=[...o.propertyChanges]),n}function ie(o){return o.content.map(t=>t.type==="text"?t.text:"").join("")}function M(o,t,r,n,a){let e=ie(o);if(!e)return;let i=a.value,s=i+e.length;n.push({run:o,parent:t,index:r,text:e,start:i,end:s}),a.value=s;}function K(o,t,r){o.children.forEach((n,a)=>{n.type==="run"&&M(n,o.children,a,t,r);});}function D(o,t){let r=[],n={value:0};return o.content.forEach((a,e)=>{a.type==="run"?M(a,o.content,e,r,n):a.type==="hyperlink"?K(a,r,n):(a.type==="deletion"||a.type==="moveFrom"||t&&(a.type==="insertion"||a.type==="moveTo"))&&a.content.forEach((i,s)=>{i.type==="run"?M(i,a.content,s,r,n):i.type==="hyperlink"&&K(i,r,n);});}),r}function se(o,t){let r={...o??{}};t.bold!==void 0&&(r.bold=t.bold||void 0),t.italic!==void 0&&(r.italic=t.italic||void 0),t.underline!==void 0&&(t.underline?r.underline={style:typeof t.underline=="object"&&t.underline.style?t.underline.style:"single"}:delete r.underline),t.strike!==void 0&&(r.strike=t.strike||void 0),t.color!==void 0&&(t.color&&(t.color.rgb||t.color.themeColor)?r.color={rgb:t.color.rgb,themeColor:t.color.themeColor}:delete r.color),t.highlight!==void 0&&(t.highlight?r.highlight=va(t.highlight)||t.highlight:delete r.highlight),t.fontSize!==void 0&&(t.fontSize>0?r.fontSize=m$1(t.fontSize):delete r.fontSize),t.fontFamily!==void 0&&(t.fontFamily&&(t.fontFamily.ascii||t.fontFamily.hAnsi)?r.fontFamily={ascii:t.fontFamily.ascii,hAnsi:t.fontFamily.hAnsi??t.fontFamily.ascii}:delete r.fontFamily);for(let n of Object.keys(r))r[n]===void 0&&delete r[n];return Object.keys(r).length>0?r:void 0}function S(o,t){o.formatting=se(o.formatting,t);}function
|
|
1
|
+
import {U as U$1,V,H as H$1,I,va}from'./chunk-ICDWMZPG.mjs';import {m as m$1}from'./chunk-6RMDMHUK.mjs';function m(o){return o.type==="insertion"||o.type==="deletion"||o.type==="moveFrom"||o.type==="moveTo"}function b(o){let t=[];for(let r of o)r.type==="run"?t.push(H$1(r)):r.type==="hyperlink"&&t.push(I(r));return t.join("")}function P(o,t){let r=0;for(let n of o.content)if(n.type==="paragraph"){if(r===t)return n;r++;}else if(n.type==="table"){for(let a of n.rows)for(let e of a.cells)for(let i of e.content)if(i.type==="paragraph"){if(r===t)return i;r++;}}else r++;throw new Error(`Paragraph index ${t} out of bounds (max: ${r-1})`)}function L(o,t,r){let n=0;for(let a of o)if(a.type==="paragraph"){if(r(a,n)===false)return;n++;}else if(a.type==="table"){for(let e of a.rows)for(let i of e.cells)for(let s of i.content)if(s.type==="paragraph"){if(r(s,n)===false)return;n++;}}else t&&n++;}function F(o,t){L(o.content,true,t);}function k(o,t){L(o.content,false,t);}function me(o,t={}){let{fromIndex:r,toIndex:n,includeTrackedChanges:a=true,includeCommentAnchors:e=true}=t,i=[],s=0;for(let c of o.content)if(c.type==="paragraph")j(s,r,n)&&i.push(q(c,s,a,e)),s++;else if(c.type==="table"){j(s,r,n)&&i.push(ee(c,s,a,e));for(let l of c.rows)for(let u of l.cells)for(let f of u.content)f.type==="paragraph"&&s++;}else s++;return i}function j(o,t,r){return (t===void 0||o>=t)&&(r===void 0||o<=r)}function q(o,t,r,n){let a=H(o,r,n),e=o.formatting?.styleId,i=o.paraId;return U$1(e)?{type:"heading",index:t,paraId:i,level:V(e)??1,text:a}:o.listRendering?{type:"list-item",index:t,paraId:i,text:a,listLevel:o.listRendering.level??0,listType:o.listRendering.isBullet?"bullet":"number"}:{type:"paragraph",index:t,paraId:i,text:a}}function ee(o,t,r,n){let a=[],e=[];for(let i of o.rows){let s=[],c=[];for(let l of i.cells){let u=[],f;for(let d of l.content)d.type==="paragraph"&&(f===void 0&&(f=d.paraId),u.push(H(d,r,n)));s.push(u.join(`
|
|
2
|
+
`)),c.push(f);}a.push(s),e.push(c);}return {type:"table",index:t,rows:a,cellParaIds:e}}function xe(o){let t=[],r=n=>n.paraId?n.paraId:String(n.index);for(let n of o)switch(n.type){case "heading":t.push(`[${r(n)}] (h${n.level}) ${n.text}`);break;case "paragraph":t.push(`[${r(n)}] ${n.text}`);break;case "list-item":{let a=" ".repeat(n.listLevel),e=n.listType==="bullet"?"\u2022":"-";t.push(`[${r(n)}] ${a}${e} ${n.text}`);break}case "table":{let a=n.index;for(let e=0;e<n.rows.length;e++)for(let i=0;i<n.rows[e].length;i++){let c=n.rows[e][i].split(`
|
|
3
|
+
`),l=n.cellParaIds?.[e]?.[i];for(let u=0;u<c.length;u++){let f=u===0&&l?l:String(a);t.push(`[${f}] (table, row ${e+1}, col ${i+1}) ${c[u]}`),a++;}}break}}return t.join(`
|
|
4
|
+
`)}function H(o,t,r){let n=[],a=new Set;for(let e of o.content){if(e.type==="commentRangeStart"&&r){a.add(e.id),n.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&r){a.has(e.id)&&(a.delete(e.id),n.push("[/comment]"));continue}if(e.type==="run")n.push(H$1(e));else if(e.type==="hyperlink")n.push(I(e));else if(m(e)){let i=b(e.content);e.type==="insertion"||e.type==="moveTo"?t&&n.push(`[+${i}+]{by:${e.info.author}}`):t?n.push(`[-${i}-]{by:${e.info.author}}`):n.push(i);}}return n.join("")}var C=class extends Error{constructor(t,r){let n=r!==void 0?` in paragraph ${r}`:" in document";super(`Text not found${n}: "${t}"`),this.name="TextNotFoundError";}},N=class extends Error{constructor(t){super(`Tracked change not found: id=${t}`),this.name="ChangeNotFoundError";}},R=class extends Error{constructor(t){super(`Comment not found: id=${t}`),this.name="CommentNotFoundError";}};function X(o){let t=[],r=0;for(let n=0;n<o.content.length;n++){let a=o.content[n];if(a.type==="run"){let e=H$1(a);t.push({contentIndex:n,run:a,text:e,startPos:r}),r+=e.length;}else if(a.type==="hyperlink")for(let e=0;e<a.children.length;e++){let i=a.children[e];if(i.type==="run"){let s=H$1(i);t.push({contentIndex:n,run:i,text:s,startPos:r}),r+=s.length;}}else if(m(a)){if(a.type==="insertion"||a.type==="moveTo")continue;for(let e=0;e<a.content.length;e++){let i=a.content[e];if(i.type==="run"){let s=H$1(i);t.push({contentIndex:n,run:i,text:s,startPos:r}),r+=s.length;}else if(i.type==="hyperlink"){for(let s of i.children)if(s.type==="run"){let c=H$1(s);t.push({contentIndex:n,run:s,text:c,startPos:r}),r+=c.length;}}}}}return t}function w(o){return X(o).map(t=>t.text).join("")}function te(o,t,r){let n=X(o),a=n.map(u=>u.text).join(""),e=ne(a,t);if(!e)throw new C(t,r);let i=-1,s=0;for(let u=0;u<n.length;u++)if(e.start<n[u].startPos+n[u].text.length){i=u,s=e.start-n[u].startPos;break}let c=-1,l=0;for(let u=n.length-1;u>=0;u--)if(e.end>n[u].startPos){c=u,l=e.end-n[u].startPos;break}if(i===-1||c===-1)throw new C(t,r);return {startRunIndex:n[i].contentIndex,startOffset:s,endRunIndex:n[c].contentIndex,endOffset:l}}function Pe(o,t,r){let n=te(o,t,r),{startRunIndex:a,endRunIndex:e}=n,{startOffset:i,endOffset:s}=n,c=o.content[e];if(c.type==="run"){let u=H$1(c);if(s<u.length){let f=z(u.slice(s),c);W(c,u.slice(0,s)),o.content.splice(e+1,0,f);}}let l=o.content[a];if(l.type==="run"&&i>0){let u=H$1(l),f=z(u.slice(0,i),l);W(l,u.slice(i)),o.content.splice(a,0,f),a++,e++;}return {startIndex:a,endIndex:e}}function z(o,t){return {type:"run",content:[{type:"text",text:o}],formatting:t.formatting?{...t.formatting}:void 0}}function W(o,t){let r=o.content.find(n=>n.type==="text");r&&(r.text=t);}function G(o){let t=[],r=[],n=true;for(let a=0;a<o.length;a++){let e=o[a];if(!"\u200B\u200C\u200D\uFEFF\xAD".includes(e)){if("\u201C\u201D\u201E\u201F".includes(e)&&(e='"'),"\u2018\u2019\u201A\u201B".includes(e)&&(e="'"),"\u2013\u2014\u2012\u2015".includes(e)&&(e="-"),e==="\u2026"){t.push(".",".","."),r.push(a,a,a),n=false;continue}if(/\s/.test(e)||e==="\xA0"){n||(t.push(" "),r.push(a),n=true);continue}t.push(e.toLowerCase()),r.push(a),n=false;}}return t.length>0&&t[t.length-1]===" "&&(t.pop(),r.pop()),{text:t.join(""),posMap:r}}function U(o,t,r,n){let a=o.posMap[t],e=o.posMap[t+r-1]+1;for(;e<n.length&&"\u200B\u200C\u200D\uFEFF\xAD".includes(n[e]);)e++;return {start:a,end:e}}function ne(o,t){if(!t||!o)return null;let r=o.indexOf(t);if(r!==-1)return {start:r,end:r+t.length};let n=G(o),a=G(t);if(!a.text)return null;let e=n.text.indexOf(a.text);if(e!==-1)return U(n,e,a.text.length,o);let i=a.text.split(" ");if(i.length>=3)for(let s=1;s<=Math.min(2,i.length-2);s++){let c=i.slice(0,-s).join(" "),l=n.text.indexOf(c);if(l!==-1)return U(n,l,c.length,o)}return null}function Fe(o,t,r){let n=new Map,a=(i,s,c)=>{let l=null;for(let u of i.content)if(m(u)){l===null&&(l=w(i));let f=b(u.content),d=u.info.id,x=`${c.noteType??"body"}:${c.noteId??""}:${d}`,g=n.get(x);g&&g.paragraphIndex===s?g.text+=f:n.set(x,{id:d,type:u.type,author:u.info.author,date:u.info.date??null,text:f,context:l,paragraphIndex:s,...c.noteId!==void 0?{noteId:c.noteId}:{},...c.noteType!==void 0?{noteType:c.noteType}:{}});}};if(F(o,(i,s)=>a(i,s,{})),t?.includeFootnotes&&r?.footnotes)for(let i of r.footnotes)k(i,(s,c)=>a(s,c,{noteId:i.id,noteType:"footnote"}));if(t?.includeEndnotes&&r?.endnotes)for(let i of r.endnotes)k(i,(s,c)=>a(s,c,{noteId:i.id,noteType:"endnote"}));return Array.from(n.values()).filter(i=>!(t?.author&&i.author!==t.author||t?.type&&i.type!==t.type))}function ke(o,t){let r=o.comments??[];if(r.length===0)return [];let n=oe(o),a=[],e=new Map;for(let s of r)if(s.parentId!==void 0){let c=e.get(s.parentId)??[];c.push(s),e.set(s.parentId,c);}else a.push(s);return a.map(s=>{let c=n.get(s.id),l=(e.get(s.id)??[]).map(u=>({id:u.id,author:u.author,date:u.date??null,text:J(u)}));return {id:s.id,author:s.author,date:s.date??null,text:J(s),anchoredText:c?.text??"",paragraphIndex:c?.paragraphIndex??-1,replies:l,done:s.done??false}}).filter(s=>!(t?.author&&s.author!==t.author||t?.done!==void 0&&s.done!==t.done))}function J(o){return o.content.map(t=>w(t)).join(`
|
|
5
|
+
`)}function oe(o){let t=new Map,r=new Map;return F(o,(n,a)=>{for(let e of n.content)if(e.type==="commentRangeStart")r.set(e.id,{paragraphIndex:a,parts:[]});else if(e.type==="commentRangeEnd"){let i=r.get(e.id);i&&(t.set(e.id,{text:i.parts.join(""),paragraphIndex:i.paragraphIndex}),r.delete(e.id));}else if(e.type==="run"){let i=H$1(e);for(let s of r.values())s.parts.push(i);}else if(e.type==="hyperlink"){let i=e.children.filter(s=>s.type==="run").map(H$1).join("");for(let s of r.values())s.parts.push(i);}else if(m(e)){if(e.type==="insertion"||e.type==="moveTo")continue;let i=b(e.content);for(let s of r.values())s.parts.push(i);}}),t}function re(o){let t=o.toDocument().package?.document;if(!t)return new Map;let r=new Map,n=0;for(let a of t.content)if(a.type==="paragraph"){let e=a.paraId;r.set(e??String(n),n),n++;}else if(a.type==="table")for(let e of a.rows)for(let i of e.cells)for(let s of i.content)s.type==="paragraph"&&n++;else n++;return r}function ae(o){let t=[],r=n=>{for(let a of n.content)a.type==="text"&&t.push(a.text??"");};for(let n of o.content)if(n.type==="run")r(n);else if(n.type==="hyperlink")for(let a of n.children)a.type==="run"&&r(a);else if(n.type==="deletion"||n.type==="moveFrom"){for(let a of n.content)if(a.type==="run")r(a);else if(a.type==="hyperlink")for(let e of a.children)e.type==="run"&&r(e);}return t.join("")}function B(o,t){let n={type:"run",content:[{type:"text",text:t,preserveSpace:/^\s|\s$/.test(t)}]};return o.formatting&&(n.formatting={...o.formatting}),o.propertyChanges&&(n.propertyChanges=[...o.propertyChanges]),n}function ie(o){return o.content.map(t=>t.type==="text"?t.text:"").join("")}function M(o,t,r,n,a){let e=ie(o);if(!e)return;let i=a.value,s=i+e.length;n.push({run:o,parent:t,index:r,text:e,start:i,end:s}),a.value=s;}function K(o,t,r){o.children.forEach((n,a)=>{n.type==="run"&&M(n,o.children,a,t,r);});}function D(o,t){let r=[],n={value:0};return o.content.forEach((a,e)=>{a.type==="run"?M(a,o.content,e,r,n):a.type==="hyperlink"?K(a,r,n):(a.type==="deletion"||a.type==="moveFrom"||t&&(a.type==="insertion"||a.type==="moveTo"))&&a.content.forEach((i,s)=>{i.type==="run"?M(i,a.content,s,r,n):i.type==="hyperlink"&&K(i,r,n);});}),r}function se(o,t){let r={...o??{}};t.bold!==void 0&&(r.bold=t.bold||void 0),t.italic!==void 0&&(r.italic=t.italic||void 0),t.underline!==void 0&&(t.underline?r.underline={style:typeof t.underline=="object"&&t.underline.style?t.underline.style:"single"}:delete r.underline),t.strike!==void 0&&(r.strike=t.strike||void 0),t.color!==void 0&&(t.color&&(t.color.rgb||t.color.themeColor)?r.color={rgb:t.color.rgb,themeColor:t.color.themeColor}:delete r.color),t.highlight!==void 0&&(t.highlight?r.highlight=va(t.highlight)||t.highlight:delete r.highlight),t.fontSize!==void 0&&(t.fontSize>0?r.fontSize=m$1(t.fontSize):delete r.fontSize),t.fontFamily!==void 0&&(t.fontFamily&&(t.fontFamily.ascii||t.fontFamily.hAnsi)?r.fontFamily={ascii:t.fontFamily.ascii,hAnsi:t.fontFamily.hAnsi??t.fontFamily.ascii}:delete r.fontFamily);for(let n of Object.keys(r))r[n]===void 0&&delete r[n];return Object.keys(r).length>0?r:void 0}function S(o,t){o.formatting=se(o.formatting,t);}function ce(o,t,r,n){let a=o.run.content.every(s=>s.type==="text");if(t<=0&&r>=o.text.length||!a){S(o.run,n);return}let e=[];t>0&&e.push(B(o.run,o.text.slice(0,t)));let i=B(o.run,o.text.slice(t,r));S(i,n),e.push(i),r<o.text.length&&e.push(B(o.run,o.text.slice(r))),o.parent.splice(o.index,1,...e);}function ue(o,t,r,n){let e=D(o,false).filter(i=>i.start<r&&i.end>t);if(e.length===0)return true;for(let i=e.length-1;i>=0;i--){let s=e[i];ce(s,Math.max(0,t-s.start),Math.min(s.text.length,r-s.start),n);}return true}function le(o,t){let r=D(o,true);for(let n of r)S(n.run,t);return true}function fe(o,t){if(!t)return null;let n=D(o,false).map(e=>e.text).join(""),a=n.indexOf(t);return a===-1||n.indexOf(t,a+1)!==-1?null:{from:a,to:a+t.length}}function pe(o,t){return o?!!o.styles?.some(r=>r.styleId===t&&r.type==="paragraph"):true}function De(o){let t=new Set,r=null;function n(){return r===null&&(r=re(o)),r}function a(){if(t.size===0)return;let e=o.getComments(),i=o.getChanges(),s={commentCount:e.length,changeCount:i.length,comments:e,changes:i};for(let c of t)try{c(s);}catch(l){console.error("reviewerBridge content listener threw:",l);}}return {getContentAsText(e){return o.getContentAsText(e)},getContent(e){return o.getContent(e)},getComments(e){return o.getComments(e)},getChanges(e){return o.getChanges(e)},findText(e,i){if(!e)return [];let s=i?.caseSensitive??false,c=i?.limit??20,l=s?e:e.toLowerCase(),u=o.toDocument().package?.document;if(!u)return [];let f=[],d=40,x=0;for(let g of u.content){if(f.length>=c)break;if(g.type==="table"){for(let Y of g.rows)for(let Z of Y.cells)for(let _ of Z.content)_.type==="paragraph"&&x++;continue}if(g.type!=="paragraph"){x++;continue}let E=g,Q=x++,y=ae(E),$=s?y:y.toLowerCase(),h=$.indexOf(l);if(h===-1||$.indexOf(l,h+1)!==-1)continue;let V=y.slice(h,h+e.length);f.push({paraId:E.paraId??String(Q),match:V,before:y.slice(Math.max(0,h-d),h),after:y.slice(h+e.length,h+e.length+d)});}return f},getSelection(){return null},addComment(e){let i=n().get(e.paraId);if(i===void 0)return null;try{let s=o.addComment({paragraphIndex:i,text:e.text,author:e.author,search:e.search});return a(),s}catch{return null}},replyTo(e,i){try{let s=o.replyTo(e,i);return a(),s}catch{return null}},resolveComment(e){let s=o.toDocument().package?.document?.comments?.find(c=>c.id===e);if(!s)throw new R(e);s.done=true,a();},proposeChange(e){let i=n().get(e.paraId);if(i===void 0)return false;let s=e.search==="",c=e.replaceWith==="";if(s&&c)return false;try{return s?o.proposeInsertion({paragraphIndex:i,insertText:e.replaceWith,author:e.author}):c?o.proposeDeletion({paragraphIndex:i,search:e.search,author:e.author}):o.replace({paragraphIndex:i,search:e.search,replaceWith:e.replaceWith,author:e.author}),a(),true}catch{return false}},scrollTo(e){return n().has(e)},applyFormatting(e){let i=n().get(e.paraId);if(i===void 0)return false;let s=o.toDocument().package?.document;if(!s)return false;try{let c=s?P(s,i):null;if(!c)return false;if(e.search){let l=fe(c,e.search);if(!l)return false;ue(c,l.from,l.to,e.marks);}else le(c,e.marks);return a(),true}catch{return false}},setParagraphStyle(e){let i=n().get(e.paraId);if(i===void 0)return false;let s=o.toDocument(),c=s.package?.document;if(!c||!pe(s.package?.styles,e.styleId))return false;try{let l=P(c,i);return l.formatting={...l.formatting??{},styleId:e.styleId},a(),true}catch{return false}},insertBreak(e){let i=n().get(e.paraId);if(i===void 0)return false;let s=o.toDocument().package?.document;if(!s)return false;try{let c=P(s,i);if(!c)return false;if(e.type==="sectionNextPage"||e.type==="sectionContinuous"){let f=e.type==="sectionNextPage"?"nextPage":"continuous";return c.sectionProperties={...c.sectionProperties??{},sectionStart:f},a(),true}let l=s.content.indexOf(c);if(l===-1)return false;let u={type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]};return s.content.splice(l+1,0,u),r=null,a(),true}catch{return false}},getPage(){return null},getPages(){return []},getTotalPages(){return 0},getCurrentPage(){return 0},onContentChange(e){return t.add(e),()=>{t.delete(e);}},onSelectionChange(){return ()=>{}}}}export{m as a,P as b,F as c,k as d,me as e,xe as f,C as g,N as h,R as i,te as j,Pe as k,Fe as l,ke as m,De as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var D=class{constructor(){this.plugins=new Map;this.commandHandlers=new Map;this.eventListeners=new Set;this.initialized=new Set;}register(e,o){let n=[];if(!e.id)return {success:false,error:"Plugin must have an id"};if(this.plugins.has(e.id))return {success:false,error:`Plugin '${e.id}' is already registered`};if(e.dependencies){for(let t of e.dependencies)if(!this.plugins.has(t))return {success:false,error:`Plugin '${e.id}' requires '${t}' which is not registered`}}if(e.commandHandlers)for(let[t,s]of Object.entries(e.commandHandlers)){if(this.commandHandlers.has(t)){let i=this.commandHandlers.get(t);n.push(`Command '${t}' from '${e.id}' overrides handler from '${i.pluginId}'`);}this.commandHandlers.set(t,{pluginId:e.id,handler:s});}if(this.plugins.set(e.id,e),e.initialize&&!this.initialized.has(e.id))try{let t=e.initialize();t instanceof Promise?t.then(()=>{this.initialized.add(e.id);}).catch(s=>{this.emit({type:"error",pluginId:e.id,error:s});}):this.initialized.add(e.id);}catch(t){this.emit({type:"error",pluginId:e.id,error:t});}return o?.debug&&console.log(`[PluginRegistry] Registered plugin: ${e.id}`),this.emit({type:"registered",plugin:e}),{success:true,plugin:e,warnings:n.length>0?n:void 0}}unregister(e){let o=this.plugins.get(e);if(!o)return false;for(let[n,t]of this.plugins)if(t.dependencies?.includes(e))return console.warn(`Cannot unregister '${e}': '${n}' depends on it`),false;for(let[n,{pluginId:t}]of this.commandHandlers)t===e&&this.commandHandlers.delete(n);if(o.destroy)try{let n=o.destroy();n instanceof Promise&&n.catch(t=>{this.emit({type:"error",pluginId:e,error:t});});}catch(n){this.emit({type:"error",pluginId:e,error:n});}return this.plugins.delete(e),this.initialized.delete(e),this.emit({type:"unregistered",pluginId:e}),true}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get size(){return this.plugins.size}getCommandHandler(e){return this.commandHandlers.get(e)?.handler}getCommandTypes(){return Array.from(this.commandHandlers.keys())}hasCommandHandler(e){return this.commandHandlers.has(e)}getMcpTools(){let e=[];for(let o of this.plugins.values())o.mcpTools&&e.push(...o.mcpTools);return e}getMcpToolsForPlugin(e){return this.plugins.get(e)?.mcpTools||[]}getMcpTool(e){for(let o of this.plugins.values())if(o.mcpTools){let n=o.mcpTools.find(t=>t.name===e);if(n)return n}}addEventListener(e){this.eventListeners.add(e);}removeEventListener(e){this.eventListeners.delete(e);}emit(e){for(let o of this.eventListeners)try{o(e);}catch(n){console.error("[PluginRegistry] Event listener error:",n);}}clear(){for(let e of this.plugins.values())if(e.destroy)try{e.destroy();}catch{}this.plugins.clear(),this.commandHandlers.clear(),this.initialized.clear();}getDebugInfo(){return {plugins:Array.from(this.plugins.keys()),commandTypes:Array.from(this.commandHandlers.keys()),mcpTools:this.getMcpTools().map(e=>e.name),initialized:Array.from(this.initialized)}}},C=new D;function U(r,e){return r.map(o=>C.register(o,e))}function W(r){return e=>C.register(e,r)}function h(r){return JSON.parse(JSON.stringify(r))}function g(r,e){let o=0;for(let n=0;n<r.content.length;n++)if(r.content[n].type==="paragraph"){if(o===e)return n;o++;}return -1}function y(r){let e="";for(let o of r.content)if(o.type==="run")for(let n of o.content)n.type==="text"&&(e+=n.text);else if(o.type==="hyperlink"){for(let n of o.children)if(n.type==="run")for(let t of n.content)t.type==="text"&&(e+=t.text);}return e}function T(r,e){return {type:"run",formatting:e,content:[{type:"text",text:r}]}}function I(r,e,o,n){let t=[],s=0,i=false;for(let a of r.content)if(a.type==="run"){let p=a.content.filter(l=>l.type==="text").map(l=>l.text).join(""),c=s,u=s+p.length;if(!i&&e>=c&&e<=u){let l=e-c;l>0&&t.push({...a,content:[{type:"text",text:p.slice(0,l)}]}),t.push(T(o,n||a.formatting)),l<p.length&&t.push({...a,content:[{type:"text",text:p.slice(l)}]}),i=true;}else t.push(a);s=u;}else t.push(a);return i||t.push(T(o,n)),t}function d(r,e,o){let n=[],t=0;for(let s of r.content)if(s.type==="run"){let i=s.content.filter(c=>c.type==="text").map(c=>c.text).join(""),a=t,p=t+i.length;if(p<=e||a>=o)n.push(s);else {let c="";a<e&&(c+=i.slice(0,e-a)),p>o&&(c+=i.slice(o-a)),c.length>0&&n.push({...s,content:[{type:"text",text:c}]});}t=p;}else n.push(s);return n}function w(r,e,o,n){let t=[],s=0;for(let i of r.content)if(i.type==="run"){let a=i.content.filter(u=>u.type==="text").map(u=>u.text).join(""),p=s,c=s+a.length;if(c<=e||p>=o)t.push(i);else if(p>=e&&c<=o)t.push({...i,formatting:{...i.formatting,...n}});else {let u=Math.max(e,p),l=Math.min(o,c);p<u&&t.push({...i,content:[{type:"text",text:a.slice(0,u-p)}]}),t.push({...i,formatting:{...i.formatting,...n},content:[{type:"text",text:a.slice(u-p,l-p)}]}),c>l&&t.push({...i,content:[{type:"text",text:a.slice(l-p)}]});}s=c;}else t.push(i);return t}function R(r,e){let o=h(r),n=o.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t];return s.content=I(s,e.position.offset,e.text,e.formatting),o}function _(r,e){let o=h(r),n=o.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=d(a,t.offset,s.offset),a.content=I(a,t.offset,e.text,e.formatting);}else {let i=g(n,t.paragraphIndex),a=n.content[i],p=y(a);a.content=d(a,t.offset,p.length),a.content=I(a,t.offset,e.text,e.formatting);let c=[];for(let u=t.paragraphIndex+1;u<=s.paragraphIndex;u++)c.push(g(n,u));for(let u=c.length-1;u>=0;u--)c[u]!==-1&&n.content.splice(c[u],1);}return o}function v(r,e){let o=h(r),n=o.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=d(a,t.offset,s.offset);}else {let i=g(n,t.paragraphIndex),a=n.content[i],p=y(a);a.content=d(a,t.offset,p.length);let c=g(n,s.paragraphIndex),u=n.content[c];u.content=d(u,0,s.offset),a.content.push(...u.content);let l=[];for(let f=t.paragraphIndex+1;f<=s.paragraphIndex;f++)l.push(g(n,f));for(let f=l.length-1;f>=0;f--)l[f]!==-1&&n.content.splice(l[f],1);}return o}function S(r,e){let o=h(r),n=o.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=w(a,t.offset,s.offset,e.formatting);}else for(let i=t.paragraphIndex;i<=s.paragraphIndex;i++){let a=g(n,i);if(a===-1)continue;let p=n.content[a],c=y(p),u=0,l=c.length;i===t.paragraphIndex&&(u=t.offset),i===s.paragraphIndex&&(l=s.offset),p.content=w(p,u,l,e.formatting);}return o}function N(r,e){let o=h(r),n=o.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t];if(s.formatting={...s.formatting,...e.formatting},"numPr"in e.formatting){let i=e.formatting.numPr;if(i&&i.numId!==void 0&&i.numId!==0){let a=i.ilvl??0,p=i.numId===1,c=p?"\u2022":"1.";if(o.package.numbering){let u=o.package.numbering.nums.find(l=>l.numId===i.numId);if(u){let l=o.package.numbering.abstractNums.find(f=>f.abstractNumId===u.abstractNumId);if(l){let f=l.levels.find(m=>m.ilvl===a);f&&(c=f.lvlText||c);}}}s.listRendering={level:a,numId:i.numId,marker:c,isBullet:p};}else delete s.listRendering;}return o}function A(r,e){let o=h(r),n=o.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t];return s.formatting={...s.formatting,styleId:e.styleId},o}function Q(r){return r/1440*96}function Y(r){return r/96*1440}function Z(r){return r==null||isNaN(r)?0:Math.round(r*96/914400)}function E(r){return Math.round(r/96*914400)}function ee(r){return Math.round(r/914400*1440)}function te(r){return Math.round(r/1440*914400)}function ne(r){return r/72*96}function re(r){return r/144*96}function oe(r){return r*2}function X(r,e=2){let o=Math.pow(10,e);return Math.round(r*o)/o}function ae(r){return `${X(r)}px`}function M(r,e){let o=h(r),n=o.package.document,t=[];for(let a=0;a<e.rows;a++){let p=[];for(let c=0;c<e.columns;c++){let u=e.data?.[a]?.[c]||"";p.push({type:"tableCell",content:[{type:"paragraph",content:u?[T(u)]:[]}]});}t.push({type:"tableRow",formatting:a===0&&e.hasHeader?{header:true}:void 0,cells:p});}let s={type:"table",rows:t},i=g(n,e.position.paragraphIndex);return i===-1?n.content.push(s):n.content.splice(i+1,0,s),o}function $(r,e){let o=h(r),n=o.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t],a={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:e.src,alt:e.alt,size:{width:E(e.width||100),height:E(e.height||100)},wrap:{type:"inline"}}}]},p=I(s,e.position.offset,"",void 0),c=false,u=0;for(let l=0;l<p.length;l++){let f=p[l];if(f.type==="run"){let m=f.content.filter(x=>x.type==="text").map(x=>x.text).join("");if(u+=m.length,!c&&u>=e.position.offset){p.splice(l+1,0,a),c=true;break}}}return c||p.push(a),s.content=p,o}function B(r,e){let o=h(r),n=o.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex!==s.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i],p=y(a),c=e.displayText||p.slice(t.offset,s.offset);a.content=d(a,t.offset,s.offset);let u={type:"hyperlink",href:e.url,tooltip:e.tooltip,children:[T(c)]},l=false,f=0,m=[];for(let x of a.content)if(x.type==="run"){let b=x.content.filter(P=>P.type==="text").map(P=>P.text).join(""),H=f+b.length;if(!l&&f<=t.offset&&t.offset<=H){let P=t.offset-f;P>0&&m.push({...x,content:[{type:"text",text:b.slice(0,P)}]}),m.push(u),P<b.length&&m.push({...x,content:[{type:"text",text:b.slice(P)}]}),l=true;}else m.push(x);f=H;}else m.push(x);return l||m.push(u),a.content=m,o}function F(r,e){let o=h(r),n=o.package.document,{start:t}=e.range,s=g(n,t.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=n.content[s],a=[];for(let p of i.content)if(p.type==="hyperlink")for(let c of p.children)c.type==="run"&&a.push(c);else a.push(p);return i.content=a,o}function k(r,e){let o=h(r),n=o.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t],i=y(s),a=d({content:[...s.content]},e.position.offset,i.length),p=d({content:[...s.content]},0,e.position.offset);s.content=a;let c={type:"paragraph",formatting:s.formatting,content:p};return n.content.splice(t+1,0,c),o}function L(r,e){let o=h(r),n=o.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t],i=[];for(let a=1;a<=e.count;a++){let p=g(n,e.paragraphIndex+a);if(p!==-1){let c=n.content[p];s.content.push(...c.content),i.push(p);}}for(let a=i.length-1;a>=0;a--)n.content.splice(i[a],1);return o}function V(r,e){return k(r,{position:e.position})}function z(r,e){let o=h(r);return o.templateVariables||(o.templateVariables=[]),o.templateVariables.includes(e.name)||o.templateVariables.push(e.name),o}function O(r,e){let o=h(r),n=o.package.document;function t(a){for(let p of a.content)if(p.type==="text")for(let[c,u]of Object.entries(e.values)){let l=new RegExp(`\\{${c}\\}`,"g");p.text=p.text.replace(l,u);}}function s(a){for(let p of a.content)if(p.type==="run")t(p);else if(p.type==="hyperlink")for(let c of p.children)c.type==="run"&&t(c);}function i(a){if(a.type==="paragraph")s(a);else if(a.type==="table")for(let p of a.rows)for(let c of p.cells)for(let u of c.content)i(u);}for(let a of n.content)i(a);return o}function j(r,e){let o=C.getCommandHandler(e.type);if(o)return o(r,e);switch(e.type){case "insertText":return R(r,e);case "replaceText":return _(r,e);case "deleteText":return v(r,e);case "formatText":return S(r,e);case "formatParagraph":return N(r,e);case "applyStyle":return A(r,e);case "insertTable":return M(r,e);case "insertImage":return $(r,e);case "insertHyperlink":return B(r,e);case "removeHyperlink":return F(r,e);case "insertParagraphBreak":return k(r,e);case "mergeParagraphs":return L(r,e);case "splitParagraph":return V(r,e);case "setVariable":return z(r,e);case "applyVariables":return O(r,e);default:{let n=e;throw new Error(`Unknown command type: ${n.type}`)}}}function ye(r,e){return e.reduce((o,n)=>j(o,n),r)}exports.a=D;exports.b=C;exports.c=U;exports.d=W;exports.e=Q;exports.f=Y;exports.g=Z;exports.h=E;exports.i=ee;exports.j=te;exports.k=ne;exports.l=re;exports.m=oe;exports.n=ae;exports.o=j;exports.p=ye;
|
|
1
|
+
'use strict';var D=class{constructor(){this.plugins=new Map;this.commandHandlers=new Map;this.eventListeners=new Set;this.initialized=new Set;}register(e,o){let n=[];if(!e.id)return {success:false,error:"Plugin must have an id"};if(this.plugins.has(e.id))return {success:false,error:`Plugin '${e.id}' is already registered`};if(e.dependencies){for(let t of e.dependencies)if(!this.plugins.has(t))return {success:false,error:`Plugin '${e.id}' requires '${t}' which is not registered`}}if(e.commandHandlers)for(let[t,s]of Object.entries(e.commandHandlers)){if(this.commandHandlers.has(t)){let i=this.commandHandlers.get(t);n.push(`Command '${t}' from '${e.id}' overrides handler from '${i.pluginId}'`);}this.commandHandlers.set(t,{pluginId:e.id,handler:s});}if(this.plugins.set(e.id,e),e.initialize&&!this.initialized.has(e.id))try{let t=e.initialize();t instanceof Promise?t.then(()=>{this.initialized.add(e.id);}).catch(s=>{this.emit({type:"error",pluginId:e.id,error:s});}):this.initialized.add(e.id);}catch(t){this.emit({type:"error",pluginId:e.id,error:t});}return o?.debug&&console.log(`[PluginRegistry] Registered plugin: ${e.id}`),this.emit({type:"registered",plugin:e}),{success:true,plugin:e,warnings:n.length>0?n:void 0}}unregister(e){let o=this.plugins.get(e);if(!o)return false;for(let[n,t]of this.plugins)if(t.dependencies?.includes(e))return console.warn(`Cannot unregister '${e}': '${n}' depends on it`),false;for(let[n,{pluginId:t}]of this.commandHandlers)t===e&&this.commandHandlers.delete(n);if(o.destroy)try{let n=o.destroy();n instanceof Promise&&n.catch(t=>{this.emit({type:"error",pluginId:e,error:t});});}catch(n){this.emit({type:"error",pluginId:e,error:n});}return this.plugins.delete(e),this.initialized.delete(e),this.emit({type:"unregistered",pluginId:e}),true}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get size(){return this.plugins.size}getCommandHandler(e){return this.commandHandlers.get(e)?.handler}getCommandTypes(){return Array.from(this.commandHandlers.keys())}hasCommandHandler(e){return this.commandHandlers.has(e)}getMcpTools(){let e=[];for(let o of this.plugins.values())o.mcpTools&&e.push(...o.mcpTools);return e}getMcpToolsForPlugin(e){return this.plugins.get(e)?.mcpTools||[]}getMcpTool(e){for(let o of this.plugins.values())if(o.mcpTools){let n=o.mcpTools.find(t=>t.name===e);if(n)return n}}addEventListener(e){this.eventListeners.add(e);}removeEventListener(e){this.eventListeners.delete(e);}emit(e){for(let o of this.eventListeners)try{o(e);}catch(n){console.error("[PluginRegistry] Event listener error:",n);}}clear(){for(let e of this.plugins.values())if(e.destroy)try{e.destroy();}catch{}this.plugins.clear(),this.commandHandlers.clear(),this.initialized.clear();}getDebugInfo(){return {plugins:Array.from(this.plugins.keys()),commandTypes:Array.from(this.commandHandlers.keys()),mcpTools:this.getMcpTools().map(e=>e.name),initialized:Array.from(this.initialized)}}},C=new D;function U(r,e){return r.map(o=>C.register(o,e))}function W(r){return e=>C.register(e,r)}function h(r){return JSON.parse(JSON.stringify(r))}function g(r,e){let o=0;for(let n=0;n<r.content.length;n++)if(r.content[n].type==="paragraph"){if(o===e)return n;o++;}return -1}function y(r){let e="";for(let o of r.content)if(o.type==="run")for(let n of o.content)n.type==="text"&&(e+=n.text);else if(o.type==="hyperlink"){for(let n of o.children)if(n.type==="run")for(let t of n.content)t.type==="text"&&(e+=t.text);}return e}function T(r,e){return {type:"run",formatting:e,content:[{type:"text",text:r}]}}function I(r,e,o,n){let t=[],s=0,i=false;for(let a of r.content)if(a.type==="run"){let p=a.content.filter(l=>l.type==="text").map(l=>l.text).join(""),c=s,u=s+p.length;if(!i&&e>=c&&e<=u){let l=e-c;l>0&&t.push({...a,content:[{type:"text",text:p.slice(0,l)}]}),t.push(T(o,n||a.formatting)),l<p.length&&t.push({...a,content:[{type:"text",text:p.slice(l)}]}),i=true;}else t.push(a);s=u;}else t.push(a);return i||t.push(T(o,n)),t}function d(r,e,o){let n=[],t=0;for(let s of r.content)if(s.type==="run"){let i=s.content.filter(c=>c.type==="text").map(c=>c.text).join(""),a=t,p=t+i.length;if(p<=e||a>=o)n.push(s);else {let c="";a<e&&(c+=i.slice(0,e-a)),p>o&&(c+=i.slice(o-a)),c.length>0&&n.push({...s,content:[{type:"text",text:c}]});}t=p;}else n.push(s);return n}function w(r,e,o,n){let t=[],s=0;for(let i of r.content)if(i.type==="run"){let a=i.content.filter(u=>u.type==="text").map(u=>u.text).join(""),p=s,c=s+a.length;if(c<=e||p>=o)t.push(i);else if(p>=e&&c<=o)t.push({...i,formatting:{...i.formatting,...n}});else {let u=Math.max(e,p),l=Math.min(o,c);p<u&&t.push({...i,content:[{type:"text",text:a.slice(0,u-p)}]}),t.push({...i,formatting:{...i.formatting,...n},content:[{type:"text",text:a.slice(u-p,l-p)}]}),c>l&&t.push({...i,content:[{type:"text",text:a.slice(l-p)}]});}s=c;}else t.push(i);return t}function R(r,e){let o=h(r),n=o.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t];return s.content=I(s,e.position.offset,e.text,e.formatting),o}function _(r,e){let o=h(r),n=o.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=d(a,t.offset,s.offset),a.content=I(a,t.offset,e.text,e.formatting);}else {let i=g(n,t.paragraphIndex),a=n.content[i],p=y(a);a.content=d(a,t.offset,p.length),a.content=I(a,t.offset,e.text,e.formatting);let c=[];for(let u=t.paragraphIndex+1;u<=s.paragraphIndex;u++)c.push(g(n,u));for(let u=c.length-1;u>=0;u--)c[u]!==-1&&n.content.splice(c[u],1);}return o}function v(r,e){let o=h(r),n=o.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=d(a,t.offset,s.offset);}else {let i=g(n,t.paragraphIndex),a=n.content[i],p=y(a);a.content=d(a,t.offset,p.length);let c=g(n,s.paragraphIndex),u=n.content[c];u.content=d(u,0,s.offset),a.content.push(...u.content);let l=[];for(let f=t.paragraphIndex+1;f<=s.paragraphIndex;f++)l.push(g(n,f));for(let f=l.length-1;f>=0;f--)l[f]!==-1&&n.content.splice(l[f],1);}return o}function S(r,e){let o=h(r),n=o.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=w(a,t.offset,s.offset,e.formatting);}else for(let i=t.paragraphIndex;i<=s.paragraphIndex;i++){let a=g(n,i);if(a===-1)continue;let p=n.content[a],c=y(p),u=0,l=c.length;i===t.paragraphIndex&&(u=t.offset),i===s.paragraphIndex&&(l=s.offset),p.content=w(p,u,l,e.formatting);}return o}function N(r,e){let o=h(r),n=o.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t];if(s.formatting={...s.formatting,...e.formatting},"numPr"in e.formatting){let i=e.formatting.numPr;if(i&&i.numId!==void 0&&i.numId!==0){let a=i.ilvl??0,p=i.numId===1,c=p?"\u2022":"1.";if(o.package.numbering){let u=o.package.numbering.nums.find(l=>l.numId===i.numId);if(u){let l=o.package.numbering.abstractNums.find(f=>f.abstractNumId===u.abstractNumId);if(l){let f=l.levels.find(m=>m.ilvl===a);f&&(c=f.lvlText||c);}}}s.listRendering={level:a,numId:i.numId,marker:c,isBullet:p};}else delete s.listRendering;}return o}function A(r,e){let o=h(r),n=o.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t];return s.formatting={...s.formatting,styleId:e.styleId},o}function Q(r){return r/1440*96}function Y(r){return r/96*1440}function Z(r){return r==null||isNaN(r)?0:Math.round(r*96/914400)}function E(r){return Math.round(r/96*914400)}function ee(r){return Math.round(r/914400*1440)}function te(r){return Math.round(r/1440*914400)}function ne(r){return r/72*96}function re(r){return r/144*96}function oe(r){return r*2}function X(r,e=2){let o=Math.pow(10,e);return Math.round(r*o)/o}function ae(r){return `${X(r)}px`}function M(r,e){let o=h(r),n=o.package.document,t=[];for(let a=0;a<e.rows;a++){let p=[];for(let c=0;c<e.columns;c++){let u=e.data?.[a]?.[c]||"";p.push({type:"tableCell",content:[{type:"paragraph",content:u?[T(u)]:[]}]});}t.push({type:"tableRow",formatting:a===0&&e.hasHeader?{header:true}:void 0,cells:p});}let s={type:"table",rows:t},i=g(n,e.position.paragraphIndex);return i===-1?n.content.push(s):n.content.splice(i+1,0,s),o}function $(r,e){let o=h(r),n=o.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t],a={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:e.src,alt:e.alt,size:{width:E(e.width||100),height:E(e.height||100)},wrap:{type:"inline"}}}]},p=I(s,e.position.offset,"",void 0),c=false,u=0;for(let l=0;l<p.length;l++){let f=p[l];if(f.type==="run"){let m=f.content.filter(x=>x.type==="text").map(x=>x.text).join("");if(u+=m.length,!c&&u>=e.position.offset){p.splice(l+1,0,a),c=true;break}}}return c||p.push(a),s.content=p,o}function B(r,e){let o=h(r),n=o.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex!==s.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i],p=y(a),c=e.displayText||p.slice(t.offset,s.offset);a.content=d(a,t.offset,s.offset);let u={type:"hyperlink",href:e.url,tooltip:e.tooltip,children:[T(c)]},l=false,f=0,m=[];for(let x of a.content)if(x.type==="run"){let b=x.content.filter(P=>P.type==="text").map(P=>P.text).join(""),H=f+b.length;if(!l&&f<=t.offset&&t.offset<=H){let P=t.offset-f;P>0&&m.push({...x,content:[{type:"text",text:b.slice(0,P)}]}),m.push(u),P<b.length&&m.push({...x,content:[{type:"text",text:b.slice(P)}]}),l=true;}else m.push(x);f=H;}else m.push(x);return l||m.push(u),a.content=m,o}function F(r,e){let o=h(r),n=o.package.document,{start:t}=e.range,s=g(n,t.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=n.content[s],a=[];for(let p of i.content)if(p.type==="hyperlink")for(let c of p.children)c.type==="run"&&a.push(c);else a.push(p);return i.content=a,o}function k(r,e){let o=h(r),n=o.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t],i=y(s),a=d({content:[...s.content]},e.position.offset,i.length),p=d({content:[...s.content]},0,e.position.offset);s.content=a;let c={type:"paragraph",formatting:s.formatting,content:p};return n.content.splice(t+1,0,c),o}function L(r,e){let o=h(r),n=o.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t],i=[];for(let a=1;a<=e.count;a++){let p=g(n,e.paragraphIndex+a);if(p!==-1){let c=n.content[p];s.content.push(...c.content),i.push(p);}}for(let a=i.length-1;a>=0;a--)n.content.splice(i[a],1);return o}function V(r,e){return k(r,{position:e.position})}function O(r,e){let o=h(r);return o.templateVariables||(o.templateVariables=[]),o.templateVariables.includes(e.name)||o.templateVariables.push(e.name),o}function z(r,e){let o=h(r),n=o.package.document;function t(a){for(let p of a.content)if(p.type==="text")for(let[c,u]of Object.entries(e.values)){let l=new RegExp(`\\{${c}\\}`,"g");p.text=p.text.replace(l,u);}}function s(a){for(let p of a.content)if(p.type==="run")t(p);else if(p.type==="hyperlink")for(let c of p.children)c.type==="run"&&t(c);}function i(a){if(a.type==="paragraph")s(a);else if(a.type==="table")for(let p of a.rows)for(let c of p.cells)for(let u of c.content)i(u);}for(let a of n.content)i(a);return o}function j(r,e){let o=C.getCommandHandler(e.type);if(o)return o(r,e);switch(e.type){case "insertText":return R(r,e);case "replaceText":return _(r,e);case "deleteText":return v(r,e);case "formatText":return S(r,e);case "formatParagraph":return N(r,e);case "applyStyle":return A(r,e);case "insertTable":return M(r,e);case "insertImage":return $(r,e);case "insertHyperlink":return B(r,e);case "removeHyperlink":return F(r,e);case "insertParagraphBreak":return k(r,e);case "mergeParagraphs":return L(r,e);case "splitParagraph":return V(r,e);case "setVariable":return O(r,e);case "applyVariables":return z(r,e);default:{let n=e;throw new Error(`Unknown command type: ${n.type}`)}}}function ye(r,e){return e.reduce((o,n)=>j(o,n),r)}exports.a=D;exports.b=C;exports.c=U;exports.d=W;exports.e=Q;exports.f=Y;exports.g=Z;exports.h=E;exports.i=ee;exports.j=te;exports.k=ne;exports.l=re;exports.m=oe;exports.n=ae;exports.o=j;exports.p=ye;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=["single","words","double","thick","dotted","dottedHeavy","dash","dashedHeavy","dashLong","dashLongHeavy","dotDash","dashDotHeavy","dotDotDash","dashDotDotHeavy","wave","wavyHeavy","wavyDouble","none"],o=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","red","white","yellow","none"],p={name:"apply_formatting",displayName:"Applying formatting",description:'Apply character formatting (bold, italic, underline, strike, color, highlight, font size, font family) to a paragraph or to a unique phrase within it. Pass `search` to scope the change to part of the paragraph; omit it to format the whole paragraph. Direct edit \u2014 does not create a tracked change. Pass `false` to clear a mark; omit a key to leave it untouched. Color uses `{rgb: "FF0000"}` (no hash) or `{themeColor: "accent1"}`. Font size is in points. Font family takes `{ascii, hAnsi}`.',inputSchema:{type:"object",properties:{paraId:{type:"string",description:"Paragraph id from read_document / find_text."},search:{type:"string",description:"Optional: format only this exact phrase within the paragraph (must be unique)."},marks:{type:"object",description:"Marks to set or clear. Omit a key to leave it untouched.",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{description:'true \u2192 single underline; false \u2192 clear; or { style: "single"|"double"|"thick"|"dotted"|"dottedHeavy"|"dash"|"dashedHeavy"|"dashLong"|"dashLongHeavy"|"dotDash"|"dashDotHeavy"|"dotDotDash"|"dashDotDotHeavy"|"wave"|"wavyHeavy"|"wavyDouble"|"words"|"none" }. Other values are rejected.'},strike:{type:"boolean"},color:{type:"object",description:'Either {rgb: "RRGGBB"} (no hash) or {themeColor: "accent1"|"text1"|...}.',properties:{rgb:{type:"string"},themeColor:{type:"string"}}},highlight:{type:"string",enum:[...o],description:"Highlight color \u2014 must be one of the Word-supported names: "+o.join(", ")+'. Pass "none" to clear. Hex values are rejected (Word does not accept hex for <w:highlight>).'},fontSize:{type:"number",description:"Size in points (e.g. 12, 14, 24)."},fontFamily:{type:"object",properties:{ascii:{type:"string"},hAnsi:{type:"string"}}}}}},required:["paraId","marks"]},handler:(e,r)=>{if(!e.marks||Object.keys(e.marks).length===0)return {success:false,error:"No marks provided. Specify at least one of bold/italic/etc."};let t=typeof e.marks.underline=="object"&&e.marks.underline!==null?e.marks.underline.style:void 0;if(t&&!c.includes(t))return {success:false,error:`Invalid underline.style "${t}". Must be one of: ${c.join(", ")}.`};let n=typeof e.marks.highlight=="string"?e.marks.highlight:void 0;if(n&&!o.includes(n))return {success:false,error:`Invalid highlight "${n}". Must be one of: ${o.join(", ")}. Hex values are not supported by Word's highlight attribute.`};let a=n==="none"?{...e.marks,highlight:""}:e.marks;return r.applyFormatting({paraId:e.paraId,search:e.search,marks:a})?{success:true,data:`Formatting applied to ${e.search?`"${e.search}" in ${e.paraId}`:e.paraId}.`}:{success:false,error:"Could not apply formatting. The paraId may not exist, or `search` is missing / ambiguous."}}},m={name:"set_paragraph_style",displayName:"Setting paragraph style",description:`Apply a paragraph style by id (e.g. "Heading1", "Heading2", "Title", "Quote", "Normal"). The styleId must exist in the document's style definitions \u2014 unknown ids are no-ops. Direct edit, not a tracked change.`,inputSchema:{type:"object",properties:{paraId:{type:"string",description:"Paragraph id from read_document / find_text."},styleId:{type:"string",description:'Style id (e.g. "Heading1", "Title", "Quote", "Normal").'}},required:["paraId","styleId"]},handler:(e,r)=>r.setParagraphStyle({paraId:e.paraId,styleId:e.styleId})?{success:true,data:`Style "${e.styleId}" applied to ${e.paraId}.`}:{success:false,error:`Could not set style. paraId "${e.paraId}" not found, or styleId "${e.styleId}" is not defined.`}};var i=["page","sectionNextPage","sectionContinuous"],u={page:"Page break",sectionNextPage:"Section break (next page)",sectionContinuous:"Section break (continuous)"},l={name:"insert_break",displayName:"Inserting break",description:'Insert a break after a paragraph (located by paraId). `type: "page"` adds a page break so following content starts on a new page. `type: "sectionNextPage"` starts a new document section on a new page. `type: "sectionContinuous"` starts a new section on the same page (use this to change column layout or margins from that point onward). The target paragraph becomes the end of its page/section and the next paragraph begins the new one. Direct edit \u2014 not a tracked change.',inputSchema:{type:"object",properties:{paraId:{type:"string",description:"Paragraph id from read_document / find_text. The break is inserted after this paragraph."},type:{type:"string",enum:[...i],description:'Break kind: "page" (page break), "sectionNextPage" (new section, new page), or "sectionContinuous" (new section, same page).'}},required:["paraId","type"]},handler:(e,r)=>i.includes(e.type)?r.insertBreak({paraId:e.paraId,type:e.type})?{success:true,data:`${u[e.type]} inserted after ${e.paraId}.`}:{success:false,error:`Could not insert break. paraId "${e.paraId}" not found.`}:{success:false,error:`Invalid break type "${e.type}". Must be one of: ${i.join(", ")}.`}};var g={name:"read_page",displayName:"Reading page",description:`Read the contents of one rendered page (1-indexed). Returns paragraphs on the page, each tagged with its stable paraId. Use this when the user asks "summarize page 3" or "comment on what's on this page".`,inputSchema:{type:"object",properties:{pageNumber:{type:"number",description:"1-indexed page number."}},required:["pageNumber"]},handler:(e,r)=>{let t=r.getPage(e.pageNumber);if(!t){let n=r.getTotalPages();return n===0?{success:false,error:"No pages rendered (headless mode or empty document)."}:{success:false,error:`Page ${e.pageNumber} does not exist (document has ${n} page${n===1?"":"s"}).`}}return {success:true,data:t.text||"(empty page)"}}},h={name:"read_pages",displayName:"Reading pages",description:"Read a contiguous range of rendered pages (1-indexed, inclusive). Returns paragraphs across the range, each tagged with paraId. Cheaper than calling read_page repeatedly \u2014 single round-trip.",inputSchema:{type:"object",properties:{from:{type:"number",description:"1-indexed start page (inclusive)."},to:{type:"number",description:"1-indexed end page (inclusive)."}},required:["from","to"]},handler:(e,r)=>{let t=r.getPages({from:e.from,to:e.to});if(t.length===0){let a=r.getTotalPages();return a===0?{success:false,error:"No pages rendered (headless mode or empty document)."}:{success:false,error:`No pages in range ${e.from}\u2013${e.to} (document has ${a} page${a===1?"":"s"}).`}}return {success:true,data:t.map(a=>`--- Page ${a.pageNumber} ---
|
|
2
2
|
${a.text||"(empty page)"}`).join(`
|
|
3
3
|
|
|
4
|
-
`)}}};var
|
|
4
|
+
`)}}};var y={name:"read_document",displayName:"Reading document",description:'Read the document content. Returns lines tagged with a stable paragraph id, e.g. "[2A1F3B] First paragraph". Use the bracketed id as `paraId` when commenting or suggesting changes \u2014 it survives edits, unlike ordinal indices. Returns the vanilla document (the doc as it exists right now, before any tracked suggestions are accepted): pending insertions are HIDDEN, pending deletions are shown as plain text (still part of the document until accepted), and comment markers are stripped. Use read_changes / read_comments to inspect what is pending.',inputSchema:{type:"object",properties:{fromIndex:{type:"number",description:"Start ordinal index (inclusive). Optional."},toIndex:{type:"number",description:"End ordinal index (inclusive). Optional."}}},handler:(e,r)=>({success:true,data:r.getContentAsText({fromIndex:e.fromIndex,toIndex:e.toIndex,includeTrackedChanges:false,includeCommentAnchors:false})})},f={name:"read_selection",displayName:"Reading selection",description:'Read the user\'s current cursor or selection. Returns the selected text, the paragraph it lives in, and that paragraph\'s `paraId`. Use this when the user asks "fix this" or "review what I have selected".',inputSchema:{type:"object",properties:{}},handler:(e,r)=>{let t=r.getSelection();return t?{success:true,data:t}:{success:false,error:"No selection (editor not focused)."}}},b={name:"find_text",displayName:"Finding text",description:"Locate paragraphs containing `query`. Returns up to `limit` handles, each with `paraId`, the matched substring, and surrounding context. Pass any returned `paraId` (and the `match` as `search`) to add_comment / suggest_change.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Text to find (substring match)."},caseSensitive:{type:"boolean",description:"Default: false."},limit:{type:"number",description:"Max paragraphs to return. Default: 20."}},required:["query"]},handler:(e,r)=>{let t=r.findText(e.query,{caseSensitive:e.caseSensitive,limit:e.limit});return t.length===0?{success:true,data:"No matches."}:{success:true,data:t}}},I={name:"read_comments",displayName:"Reading comments",description:"List all comments in the document with their paragraph anchors.",inputSchema:{type:"object",properties:{}},handler:(e,r)=>{let t=r.getComments();return t.length===0?{success:true,data:"No comments."}:{success:true,data:t.map(a=>`[Comment #${a.id}] ${a.author}: "${a.text}"`+(a.anchoredText?` (anchored to: "${a.anchoredText}")`:"")+(a.replies.length>0?`
|
|
5
5
|
`+a.replies.map(s=>` Reply by ${s.author}: "${s.text}"`).join(`
|
|
6
6
|
`):"")).join(`
|
|
7
|
-
`)}}},
|
|
8
|
-
`)}}},
|
|
7
|
+
`)}}},x={name:"read_changes",displayName:"Reading changes",description:"List tracked changes (insertions / deletions) currently in the document.",inputSchema:{type:"object",properties:{}},handler:(e,r)=>{let t=r.getChanges();return t.length===0?{success:true,data:"No tracked changes."}:{success:true,data:t.map(a=>`[Change #${a.id}] ${a.type} by ${a.author}: "${a.text}"`).join(`
|
|
8
|
+
`)}}},k={name:"add_comment",displayName:"Adding comment",description:"Attach a comment to a paragraph, optionally anchored to a unique phrase within it. The user sees it instantly in the comments sidebar.",inputSchema:{type:"object",properties:{paraId:{type:"string",description:"Paragraph id from read_document / find_text."},text:{type:"string",description:"Comment body."},search:{type:"string",description:"Optional: anchor to this exact phrase within the paragraph. Must be unique."}},required:["paraId","text"]},handler:(e,r)=>{let t=r.addComment({paraId:e.paraId,text:e.text,search:e.search});return t===null?{success:false,error:"Could not add comment. The paraId may not exist, or `search` is missing / ambiguous."}:{success:true,data:`Comment ${t} added on ${e.paraId}.`}}},T={name:"suggest_change",displayName:"Suggesting change",description:"Suggest a tracked change. Three modes: (1) replacement \u2014 `search` non-empty, `replaceWith` non-empty; (2) deletion \u2014 `search` non-empty, `replaceWith` empty; (3) insertion at paragraph end \u2014 `search` empty, `replaceWith` non-empty. The user can accept or reject in the editor UI.",inputSchema:{type:"object",properties:{paraId:{type:"string",description:"Paragraph id from read_document / find_text."},search:{type:"string",description:"Phrase to find (must be unique). Empty string = insert at paragraph end."},replaceWith:{type:"string",description:"Replacement text. Empty string = delete the matched phrase."}},required:["paraId","search","replaceWith"]},handler:(e,r)=>r.proposeChange({paraId:e.paraId,search:e.search,replaceWith:e.replaceWith})?e.search?e.replaceWith?{success:true,data:`Replacement proposed: "${e.search}" \u2192 "${e.replaceWith}" on ${e.paraId}.`}:{success:true,data:`Deletion proposed: "${e.search}" on ${e.paraId}.`}:{success:true,data:`Insertion proposed on ${e.paraId}.`}:{success:false,error:"Could not propose change. Possible causes: paraId not found; search missing or ambiguous; or the target overlaps an existing tracked change."}},v={name:"reply_comment",displayName:"Replying to comment",description:"Reply to an existing comment by id. Threaded under the original.",inputSchema:{type:"object",properties:{commentId:{type:"number",description:"Comment id from read_comments."},text:{type:"string",description:"Reply body."}},required:["commentId","text"]},handler:(e,r)=>{let t=r.replyTo(e.commentId,{text:e.text});return t===null?{success:false,error:`Comment #${e.commentId} not found.`}:{success:true,data:`Reply ${t} added to comment ${e.commentId}.`}}},$={name:"resolve_comment",displayName:"Resolving comment",description:"Mark a comment as resolved (done).",inputSchema:{type:"object",properties:{commentId:{type:"number",description:"Comment id from read_comments."}},required:["commentId"]},handler:(e,r)=>(r.resolveComment(e.commentId),{success:true,data:`Comment ${e.commentId} resolved.`})},D={name:"scroll",displayName:"Scrolling",description:"Scroll the editor to a paragraph by paraId. Does not move the user's cursor.",inputSchema:{type:"object",properties:{paraId:{type:"string",description:"Paragraph id from read_document / find_text."}},required:["paraId"]},handler:(e,r)=>r.scrollTo(e.paraId)?{success:true,data:`Scrolled to ${e.paraId}.`}:{success:false,error:`paraId ${e.paraId} not found.`}},d=[y,f,g,h,b,I,x,k,T,p,m,l,v,$,D];function j(e,r,t){let n=d.find(a=>a.name===e);if(!n)return {success:false,error:`Unknown tool: ${e}`};try{return n.handler(r,t)}catch(a){return {success:false,error:a instanceof Error?a.message:String(a)}}}function P(e){let r=d.find(n=>n.name===e);if(r?.displayName)return r.displayName;let t=e.replace(/_/g," ");return t.charAt(0).toUpperCase()+t.slice(1)}function H(){return d.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.inputSchema}}))}export{d as a,j as b,P as c,H as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkYU3OJ2DE_js=require('./chunk-YU3OJ2DE.js'),chunk4C2IJ7OV_js=require('./chunk-4C2IJ7OV.js');function y(n,e){let{paragraphIndex:t,author:o="AI",text:s,search:a}=e,r=chunkYU3OJ2DE_js.b(n,t),c=(n.comments??[]).map(m=>m.id),p=c.length>0?Math.max(...c)+1:1,i={id:p,author:o,date:new Date().toISOString(),content:[{type:"paragraph",content:[{type:"run",content:[{type:"text",text:s}]}],formatting:{}}]};if(n.comments||(n.comments=[]),n.comments.push(i),a){let m=chunkYU3OJ2DE_js.j(r,a,t);r.content.splice(m.endRunIndex+1,0,{type:"commentRangeEnd",id:p}),r.content.splice(m.startRunIndex,0,{type:"commentRangeStart",id:p});}else r.content.unshift({type:"commentRangeStart",id:p}),r.content.push({type:"commentRangeEnd",id:p});return p}function C(n,e,t){let o=n.comments??[];if(!o.find(p=>p.id===e))throw new chunkYU3OJ2DE_js.i(e);let a=o.map(p=>p.id),r=Math.max(...a)+1,c={id:r,author:t.author??"AI",date:new Date().toISOString(),parentId:e,content:[{type:"paragraph",content:[{type:"run",content:[{type:"text",text:t.text}]}],formatting:{}}]};return o.push(c),r}function N(n,e){let t=n.comments??[],o=t.find(r=>r.id===e);if(!o)throw new chunkYU3OJ2DE_js.i(e);let s=o.parentId!==void 0,a=new Set([e]);if(!s)for(let r of t)r.parentId===e&&a.add(r.id);n.comments=t.filter(r=>!a.has(r.id)),!s&&chunkYU3OJ2DE_js.c(n,r=>{for(let c=r.content.length-1;c>=0;c--){let p=r.content[c];(p.type==="commentRangeStart"||p.type==="commentRangeEnd")&&p.id===e&&r.content.splice(c,1);}});}function I(n,e,t){if(!W(n,e,"accept",t))throw new chunkYU3OJ2DE_js.h(typeof e=="number"?e:e.id)}function R(n,e,t){if(!W(n,e,"reject",t))throw new chunkYU3OJ2DE_js.h(typeof e=="number"?e:e.id)}function F(n,e,t){return G(n,"accept",e,t)}function M(n,e,t){return G(n,"reject",e,t)}function l(n,e,t){let o=0;for(let s=n.content.length-1;s>=0;s--){let a=n.content[s];chunkYU3OJ2DE_js.a(a)&&t(a)&&(J(n,s,a,e),o++);}return o}function W(n,e,t,o){if(typeof e!="number"&&e.noteType){let a=e.noteType==="footnote"?o?.footnotes:o?.endnotes,r=e.noteId!==void 0?a?.find(c=>c.id===e.noteId):void 0;return r?z(r,e.id,t):false}let s=typeof e=="number"?e:e.id;return q(n,s,t)}function G(n,e,t,o){let s=0;if(chunkYU3OJ2DE_js.c(n,a=>{s+=l(a,e,()=>true);}),t?.includeFootnotes&&o?.footnotes)for(let a of o.footnotes)chunkYU3OJ2DE_js.d(a,r=>{s+=l(r,e,()=>true);});if(t?.includeEndnotes&&o?.endnotes)for(let a of o.endnotes)chunkYU3OJ2DE_js.d(a,r=>{s+=l(r,e,()=>true);});return s}function q(n,e,t){let o=false;return chunkYU3OJ2DE_js.c(n,s=>{if(l(s,t,a=>a.info.id===e)>0&&(o=true),o)return false}),o}function z(n,e,t){let o=false;return chunkYU3OJ2DE_js.d(n,s=>{l(s,t,a=>a.info.id===e)>0&&(o=true);}),o}function J(n,e,t,o){if(t.type==="insertion"&&o==="accept"||t.type==="deletion"&&o==="reject"||t.type==="moveTo"&&o==="accept"||t.type==="moveFrom"&&o==="reject"){let a=t.content;n.content.splice(e,1,...a);}else n.content.splice(e,1);}function x(n,e){let{paragraphIndex:t,search:o,author:s="AI",replaceWith:a}=e,r=chunkYU3OJ2DE_js.b(n,t),{startIndex:c,endIndex:p}=chunkYU3OJ2DE_js.k(r,o,t),i=new Date().toISOString(),m=P(n),d=r.content.slice(c,p+1),v={type:"deletion",info:{id:m,author:s,date:i},content:d},b={type:"insertion",info:{id:m+1,author:s,date:i},content:[{type:"run",content:[{type:"text",text:a}]}]};r.content.splice(c,p-c+1,v,b);}function H(n,e){let{paragraphIndex:t,author:o="AI",insertText:s,position:a="after",search:r}=e,c=chunkYU3OJ2DE_js.b(n,t),p=new Date().toISOString(),m={type:"insertion",info:{id:P(n),author:o,date:p},content:[{type:"run",content:[{type:"text",text:s}]}]};if(r){let{startIndex:d,endIndex:v}=chunkYU3OJ2DE_js.k(c,r,t),b=a==="after"?v+1:d;c.content.splice(b,0,m);}else a==="before"?c.content.unshift(m):c.content.push(m);}function L(n,e){let{paragraphIndex:t,search:o,author:s="AI"}=e,a=chunkYU3OJ2DE_js.b(n,t),{startIndex:r,endIndex:c}=chunkYU3OJ2DE_js.k(a,o,t),p=new Date().toISOString(),i=P(n),m=a.content.slice(r,c+1),d={type:"deletion",info:{id:i,author:s,date:p},content:m};a.content.splice(r,c-r+1,d);}var S=new WeakMap;function P(n){let e=S.get(n);e===void 0&&(e=0,chunkYU3OJ2DE_js.c(n,o=>{for(let s of o.content)chunkYU3OJ2DE_js.a(s)&&(e=Math.max(e,s.info.id));}));let t=e+1;return S.set(n,t+1),t}function U(n,e,t="AI"){let o=[],s=0,a=0,r=0,c=0,p=0;for(let i of e.accept??[])try{I(n,i),s++;}catch(m){o.push({operation:"accept",id:i,error:m.message});}for(let i of e.reject??[])try{R(n,i),a++;}catch(m){o.push({operation:"reject",id:i,error:m.message});}for(let i of e.comments??[])try{y(n,{...i,author:i.author??t}),r++;}catch(m){o.push({operation:"comment",search:i.search,error:m.message});}for(let i of e.replies??[])try{C(n,i.commentId,{author:i.author??t,text:i.text}),c++;}catch(m){o.push({operation:"reply",id:i.commentId,error:m.message});}for(let i of e.proposals??[])try{x(n,{...i,author:i.author??t}),p++;}catch(m){o.push({operation:"proposal",search:i.search,error:m.message});}return {accepted:s,rejected:a,commentsAdded:r,repliesAdded:c,proposalsAdded:p,errors:o}}var X=class n{constructor(e,t="AI",o){let s=o??e.originalBuffer,{originalBuffer:a,...r}=e;this.doc=structuredClone(r),s&&(this.doc.originalBuffer=s),this.author=t;}static async fromBuffer(e,t="AI"){let o=await chunk4C2IJ7OV_js.w(e,{preloadFonts:false});return new n(o,t,e)}get body(){return this.doc.package.document}resolveAuthor(e){return e??this.author}getContent(e){return chunkYU3OJ2DE_js.e(this.body,e)}getContentAsText(e){return chunkYU3OJ2DE_js.f(chunkYU3OJ2DE_js.e(this.body,e))}getChanges(e){return chunkYU3OJ2DE_js.l(this.body,e,{footnotes:this.doc.package.footnotes,endnotes:this.doc.package.endnotes})}getComments(e){return chunkYU3OJ2DE_js.m(this.body,e)}addComment(e,t){let o=typeof e=="number"?{paragraphIndex:e,text:t,author:this.author}:{...e,author:this.resolveAuthor(e.author)};return y(this.body,o)}replyTo(e,t){let o=typeof t=="string"?{text:t,author:this.author}:{...t,author:this.resolveAuthor(t.author)};return C(this.body,e,o)}removeComment(e){N(this.body,e);}replace(e,t,o){let s=typeof e=="number"?{paragraphIndex:e,search:t,replaceWith:o,author:this.author}:{...e,author:this.resolveAuthor(e.author)};x(this.body,s);}proposeReplacement(e){this.replace(e);}proposeInsertion(e){H(this.body,{...e,author:this.resolveAuthor(e.author)});}proposeDeletion(e){L(this.body,{...e,author:this.resolveAuthor(e.author)});}acceptChange(e){I(this.body,e,this.changeNotes());}rejectChange(e){R(this.body,e,this.changeNotes());}acceptAll(e){return F(this.body,e,this.changeNotes())}rejectAll(e){return M(this.body,e,this.changeNotes())}changeNotes(){return {footnotes:this.doc.package.footnotes,endnotes:this.doc.package.endnotes}}applyReview(e){return U(this.body,e,this.author)}toDocument(){return this.doc}async toBuffer(){if(!this.doc.originalBuffer)throw new Error("Cannot create buffer: no original DOCX buffer was provided. Use DocxReviewer.fromBuffer() or pass originalBuffer to the constructor.");let{repackDocx:e}=await import('./headless-BS5JJGVC.js');return e(this.doc)}};exports.a=X;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {m,l,e,f}from'./chunk-J773ZJGL.mjs';function y(n){return !n||n.length===0?"":n.map(l=>{let s=l;return s?.content?s.content.map(e=>e.content?.map(t=>t.text||"").join("")||"").join(""):""}).join(`
|
|
2
|
+
`)}function u(n){let l=n.getEditorRef();if(l){let e=l.getDocument();if(e?.package?.document)return e.package.document}return n.getDocument()?.package?.document??null}function k(n,l$1="AI"){function s(e){return e??l$1}return {getContentAsText(e$1){let t=u(n);return t?f(e(t,e$1)):""},getContent(e$1){let t=u(n);return t?e(t,e$1):[]},getComments(e){let t=u(n);if(!t)return [];let r=m(t,e);if(r.length>0)return r;let i=n.getComments();if(i.length===0)return [];let a=new Map,g=[];for(let o of i)if(o.parentId){let p=a.get(o.parentId);p?p.push(o):a.set(o.parentId,[o]);}else g.push(o);let m$1=[];for(let o of g){if(e?.author&&o.author!==e.author||e?.done!==void 0&&(o.done??false)!==e.done)continue;let p=a.get(o.id)??[];m$1.push({id:o.id,author:o.author,date:o.date??null,text:y(o.content),anchoredText:"",paragraphIndex:-1,replies:p.map(c=>({id:c.id,author:c.author,date:c.date??null,text:y(c.content)})),done:o.done??false});}return m$1},getChanges(e){let t=u(n);return t?l(t,e):[]},findText(e,t){return n.findInDocument(e,t)},getSelection(){return n.getSelectionInfo()},addComment(e){return n.addComment({paraId:e.paraId,text:e.text,author:s(e.author),search:e.search})},replyTo(e,t){return n.replyToComment(e,t.text,s(t.author))},resolveComment(e){n.resolveComment(e);},proposeChange(e){return n.proposeChange({paraId:e.paraId,search:e.search,replaceWith:e.replaceWith,author:s(e.author)})},applyFormatting(e){return n.applyFormatting({paraId:e.paraId,search:e.search,marks:e.marks})},setParagraphStyle(e){return n.setParagraphStyle({paraId:e.paraId,styleId:e.styleId})},insertBreak(e){return n.insertBreak({paraId:e.paraId,type:e.type})},getPage(e){return n.getPageContent(e)},getPages(e){let t=n.getTotalPages(),r=Math.max(1,Math.min(e.from,t)),i=Math.max(r,Math.min(e.to,t)),a=[];for(let g=r;g<=i;g++){let m=n.getPageContent(g);m&&a.push(m);}return a},getTotalPages(){return n.getTotalPages()},getCurrentPage(){return n.getCurrentPage()},scrollTo(e){return n.scrollToParaId(e)},onContentChange(e){return n.onContentChange(()=>{let t=u(n),r=t?m(t):[],i=t?l(t):[];try{e({commentCount:r.length,changeCount:i.length,comments:r,changes:i});}catch(a){console.error("onContentChange listener threw:",a);}})},onSelectionChange(e){return n.onSelectionChange(()=>{try{e(n.getSelectionInfo());}catch(t){console.error("onSelectionChange listener threw:",t);}})}}}export{k as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
`)),
|
|
3
|
-
`),l=n.cellParaIds?.[e]?.[i];for(let
|
|
4
|
-
`)}function H(o,t,r){let n=[],a=new Set;for(let e of o.content){if(e.type==="commentRangeStart"&&r){a.add(e.id),n.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&r){a.has(e.id)&&(a.delete(e.id),n.push("[/comment]"));continue}if(e.type==="run")n.push(
|
|
5
|
-
`)}function oe(o){let t=new Map,r=new Map;return F(o,(n,a)=>{for(let e of n.content)if(e.type==="commentRangeStart")r.set(e.id,{paragraphIndex:a,parts:[]});else if(e.type==="commentRangeEnd"){let i=r.get(e.id);i&&(t.set(e.id,{text:i.parts.join(""),paragraphIndex:i.paragraphIndex}),r.delete(e.id));}else if(e.type==="run"){let i=
|
|
1
|
+
'use strict';var chunk4C2IJ7OV_js=require('./chunk-4C2IJ7OV.js'),chunkMMJQ47Q7_js=require('./chunk-MMJQ47Q7.js');function m(o){return o.type==="insertion"||o.type==="deletion"||o.type==="moveFrom"||o.type==="moveTo"}function b(o){let t=[];for(let r of o)r.type==="run"?t.push(chunk4C2IJ7OV_js.H(r)):r.type==="hyperlink"&&t.push(chunk4C2IJ7OV_js.I(r));return t.join("")}function P(o,t){let r=0;for(let n of o.content)if(n.type==="paragraph"){if(r===t)return n;r++;}else if(n.type==="table"){for(let a of n.rows)for(let e of a.cells)for(let i of e.content)if(i.type==="paragraph"){if(r===t)return i;r++;}}else r++;throw new Error(`Paragraph index ${t} out of bounds (max: ${r-1})`)}function L(o,t,r){let n=0;for(let a of o)if(a.type==="paragraph"){if(r(a,n)===false)return;n++;}else if(a.type==="table"){for(let e of a.rows)for(let i of e.cells)for(let s of i.content)if(s.type==="paragraph"){if(r(s,n)===false)return;n++;}}else t&&n++;}function F(o,t){L(o.content,true,t);}function k(o,t){L(o.content,false,t);}function me(o,t={}){let{fromIndex:r,toIndex:n,includeTrackedChanges:a=true,includeCommentAnchors:e=true}=t,i=[],s=0;for(let c of o.content)if(c.type==="paragraph")j(s,r,n)&&i.push(q(c,s,a,e)),s++;else if(c.type==="table"){j(s,r,n)&&i.push(ee(c,s,a,e));for(let l of c.rows)for(let u of l.cells)for(let f of u.content)f.type==="paragraph"&&s++;}else s++;return i}function j(o,t,r){return (t===void 0||o>=t)&&(r===void 0||o<=r)}function q(o,t,r,n){let a=H(o,r,n),e=o.formatting?.styleId,i=o.paraId;return chunk4C2IJ7OV_js.U(e)?{type:"heading",index:t,paraId:i,level:chunk4C2IJ7OV_js.V(e)??1,text:a}:o.listRendering?{type:"list-item",index:t,paraId:i,text:a,listLevel:o.listRendering.level??0,listType:o.listRendering.isBullet?"bullet":"number"}:{type:"paragraph",index:t,paraId:i,text:a}}function ee(o,t,r,n){let a=[],e=[];for(let i of o.rows){let s=[],c=[];for(let l of i.cells){let u=[],f;for(let d of l.content)d.type==="paragraph"&&(f===void 0&&(f=d.paraId),u.push(H(d,r,n)));s.push(u.join(`
|
|
2
|
+
`)),c.push(f);}a.push(s),e.push(c);}return {type:"table",index:t,rows:a,cellParaIds:e}}function xe(o){let t=[],r=n=>n.paraId?n.paraId:String(n.index);for(let n of o)switch(n.type){case "heading":t.push(`[${r(n)}] (h${n.level}) ${n.text}`);break;case "paragraph":t.push(`[${r(n)}] ${n.text}`);break;case "list-item":{let a=" ".repeat(n.listLevel),e=n.listType==="bullet"?"\u2022":"-";t.push(`[${r(n)}] ${a}${e} ${n.text}`);break}case "table":{let a=n.index;for(let e=0;e<n.rows.length;e++)for(let i=0;i<n.rows[e].length;i++){let c=n.rows[e][i].split(`
|
|
3
|
+
`),l=n.cellParaIds?.[e]?.[i];for(let u=0;u<c.length;u++){let f=u===0&&l?l:String(a);t.push(`[${f}] (table, row ${e+1}, col ${i+1}) ${c[u]}`),a++;}}break}}return t.join(`
|
|
4
|
+
`)}function H(o,t,r){let n=[],a=new Set;for(let e of o.content){if(e.type==="commentRangeStart"&&r){a.add(e.id),n.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&r){a.has(e.id)&&(a.delete(e.id),n.push("[/comment]"));continue}if(e.type==="run")n.push(chunk4C2IJ7OV_js.H(e));else if(e.type==="hyperlink")n.push(chunk4C2IJ7OV_js.I(e));else if(m(e)){let i=b(e.content);e.type==="insertion"||e.type==="moveTo"?t&&n.push(`[+${i}+]{by:${e.info.author}}`):t?n.push(`[-${i}-]{by:${e.info.author}}`):n.push(i);}}return n.join("")}var C=class extends Error{constructor(t,r){let n=r!==void 0?` in paragraph ${r}`:" in document";super(`Text not found${n}: "${t}"`),this.name="TextNotFoundError";}},N=class extends Error{constructor(t){super(`Tracked change not found: id=${t}`),this.name="ChangeNotFoundError";}},R=class extends Error{constructor(t){super(`Comment not found: id=${t}`),this.name="CommentNotFoundError";}};function X(o){let t=[],r=0;for(let n=0;n<o.content.length;n++){let a=o.content[n];if(a.type==="run"){let e=chunk4C2IJ7OV_js.H(a);t.push({contentIndex:n,run:a,text:e,startPos:r}),r+=e.length;}else if(a.type==="hyperlink")for(let e=0;e<a.children.length;e++){let i=a.children[e];if(i.type==="run"){let s=chunk4C2IJ7OV_js.H(i);t.push({contentIndex:n,run:i,text:s,startPos:r}),r+=s.length;}}else if(m(a)){if(a.type==="insertion"||a.type==="moveTo")continue;for(let e=0;e<a.content.length;e++){let i=a.content[e];if(i.type==="run"){let s=chunk4C2IJ7OV_js.H(i);t.push({contentIndex:n,run:i,text:s,startPos:r}),r+=s.length;}else if(i.type==="hyperlink"){for(let s of i.children)if(s.type==="run"){let c=chunk4C2IJ7OV_js.H(s);t.push({contentIndex:n,run:s,text:c,startPos:r}),r+=c.length;}}}}}return t}function w(o){return X(o).map(t=>t.text).join("")}function te(o,t,r){let n=X(o),a=n.map(u=>u.text).join(""),e=ne(a,t);if(!e)throw new C(t,r);let i=-1,s=0;for(let u=0;u<n.length;u++)if(e.start<n[u].startPos+n[u].text.length){i=u,s=e.start-n[u].startPos;break}let c=-1,l=0;for(let u=n.length-1;u>=0;u--)if(e.end>n[u].startPos){c=u,l=e.end-n[u].startPos;break}if(i===-1||c===-1)throw new C(t,r);return {startRunIndex:n[i].contentIndex,startOffset:s,endRunIndex:n[c].contentIndex,endOffset:l}}function Pe(o,t,r){let n=te(o,t,r),{startRunIndex:a,endRunIndex:e}=n,{startOffset:i,endOffset:s}=n,c=o.content[e];if(c.type==="run"){let u=chunk4C2IJ7OV_js.H(c);if(s<u.length){let f=z(u.slice(s),c);W(c,u.slice(0,s)),o.content.splice(e+1,0,f);}}let l=o.content[a];if(l.type==="run"&&i>0){let u=chunk4C2IJ7OV_js.H(l),f=z(u.slice(0,i),l);W(l,u.slice(i)),o.content.splice(a,0,f),a++,e++;}return {startIndex:a,endIndex:e}}function z(o,t){return {type:"run",content:[{type:"text",text:o}],formatting:t.formatting?{...t.formatting}:void 0}}function W(o,t){let r=o.content.find(n=>n.type==="text");r&&(r.text=t);}function G(o){let t=[],r=[],n=true;for(let a=0;a<o.length;a++){let e=o[a];if(!"\u200B\u200C\u200D\uFEFF\xAD".includes(e)){if("\u201C\u201D\u201E\u201F".includes(e)&&(e='"'),"\u2018\u2019\u201A\u201B".includes(e)&&(e="'"),"\u2013\u2014\u2012\u2015".includes(e)&&(e="-"),e==="\u2026"){t.push(".",".","."),r.push(a,a,a),n=false;continue}if(/\s/.test(e)||e==="\xA0"){n||(t.push(" "),r.push(a),n=true);continue}t.push(e.toLowerCase()),r.push(a),n=false;}}return t.length>0&&t[t.length-1]===" "&&(t.pop(),r.pop()),{text:t.join(""),posMap:r}}function U(o,t,r,n){let a=o.posMap[t],e=o.posMap[t+r-1]+1;for(;e<n.length&&"\u200B\u200C\u200D\uFEFF\xAD".includes(n[e]);)e++;return {start:a,end:e}}function ne(o,t){if(!t||!o)return null;let r=o.indexOf(t);if(r!==-1)return {start:r,end:r+t.length};let n=G(o),a=G(t);if(!a.text)return null;let e=n.text.indexOf(a.text);if(e!==-1)return U(n,e,a.text.length,o);let i=a.text.split(" ");if(i.length>=3)for(let s=1;s<=Math.min(2,i.length-2);s++){let c=i.slice(0,-s).join(" "),l=n.text.indexOf(c);if(l!==-1)return U(n,l,c.length,o)}return null}function Fe(o,t,r){let n=new Map,a=(i,s,c)=>{let l=null;for(let u of i.content)if(m(u)){l===null&&(l=w(i));let f=b(u.content),d=u.info.id,x=`${c.noteType??"body"}:${c.noteId??""}:${d}`,g=n.get(x);g&&g.paragraphIndex===s?g.text+=f:n.set(x,{id:d,type:u.type,author:u.info.author,date:u.info.date??null,text:f,context:l,paragraphIndex:s,...c.noteId!==void 0?{noteId:c.noteId}:{},...c.noteType!==void 0?{noteType:c.noteType}:{}});}};if(F(o,(i,s)=>a(i,s,{})),t?.includeFootnotes&&r?.footnotes)for(let i of r.footnotes)k(i,(s,c)=>a(s,c,{noteId:i.id,noteType:"footnote"}));if(t?.includeEndnotes&&r?.endnotes)for(let i of r.endnotes)k(i,(s,c)=>a(s,c,{noteId:i.id,noteType:"endnote"}));return Array.from(n.values()).filter(i=>!(t?.author&&i.author!==t.author||t?.type&&i.type!==t.type))}function ke(o,t){let r=o.comments??[];if(r.length===0)return [];let n=oe(o),a=[],e=new Map;for(let s of r)if(s.parentId!==void 0){let c=e.get(s.parentId)??[];c.push(s),e.set(s.parentId,c);}else a.push(s);return a.map(s=>{let c=n.get(s.id),l=(e.get(s.id)??[]).map(u=>({id:u.id,author:u.author,date:u.date??null,text:J(u)}));return {id:s.id,author:s.author,date:s.date??null,text:J(s),anchoredText:c?.text??"",paragraphIndex:c?.paragraphIndex??-1,replies:l,done:s.done??false}}).filter(s=>!(t?.author&&s.author!==t.author||t?.done!==void 0&&s.done!==t.done))}function J(o){return o.content.map(t=>w(t)).join(`
|
|
5
|
+
`)}function oe(o){let t=new Map,r=new Map;return F(o,(n,a)=>{for(let e of n.content)if(e.type==="commentRangeStart")r.set(e.id,{paragraphIndex:a,parts:[]});else if(e.type==="commentRangeEnd"){let i=r.get(e.id);i&&(t.set(e.id,{text:i.parts.join(""),paragraphIndex:i.paragraphIndex}),r.delete(e.id));}else if(e.type==="run"){let i=chunk4C2IJ7OV_js.H(e);for(let s of r.values())s.parts.push(i);}else if(e.type==="hyperlink"){let i=e.children.filter(s=>s.type==="run").map(chunk4C2IJ7OV_js.H).join("");for(let s of r.values())s.parts.push(i);}else if(m(e)){if(e.type==="insertion"||e.type==="moveTo")continue;let i=b(e.content);for(let s of r.values())s.parts.push(i);}}),t}function re(o){let t=o.toDocument().package?.document;if(!t)return new Map;let r=new Map,n=0;for(let a of t.content)if(a.type==="paragraph"){let e=a.paraId;r.set(e??String(n),n),n++;}else if(a.type==="table")for(let e of a.rows)for(let i of e.cells)for(let s of i.content)s.type==="paragraph"&&n++;else n++;return r}function ae(o){let t=[],r=n=>{for(let a of n.content)a.type==="text"&&t.push(a.text??"");};for(let n of o.content)if(n.type==="run")r(n);else if(n.type==="hyperlink")for(let a of n.children)a.type==="run"&&r(a);else if(n.type==="deletion"||n.type==="moveFrom"){for(let a of n.content)if(a.type==="run")r(a);else if(a.type==="hyperlink")for(let e of a.children)e.type==="run"&&r(e);}return t.join("")}function B(o,t){let n={type:"run",content:[{type:"text",text:t,preserveSpace:/^\s|\s$/.test(t)}]};return o.formatting&&(n.formatting={...o.formatting}),o.propertyChanges&&(n.propertyChanges=[...o.propertyChanges]),n}function ie(o){return o.content.map(t=>t.type==="text"?t.text:"").join("")}function M(o,t,r,n,a){let e=ie(o);if(!e)return;let i=a.value,s=i+e.length;n.push({run:o,parent:t,index:r,text:e,start:i,end:s}),a.value=s;}function K(o,t,r){o.children.forEach((n,a)=>{n.type==="run"&&M(n,o.children,a,t,r);});}function D(o,t){let r=[],n={value:0};return o.content.forEach((a,e)=>{a.type==="run"?M(a,o.content,e,r,n):a.type==="hyperlink"?K(a,r,n):(a.type==="deletion"||a.type==="moveFrom"||t&&(a.type==="insertion"||a.type==="moveTo"))&&a.content.forEach((i,s)=>{i.type==="run"?M(i,a.content,s,r,n):i.type==="hyperlink"&&K(i,r,n);});}),r}function se(o,t){let r={...o??{}};t.bold!==void 0&&(r.bold=t.bold||void 0),t.italic!==void 0&&(r.italic=t.italic||void 0),t.underline!==void 0&&(t.underline?r.underline={style:typeof t.underline=="object"&&t.underline.style?t.underline.style:"single"}:delete r.underline),t.strike!==void 0&&(r.strike=t.strike||void 0),t.color!==void 0&&(t.color&&(t.color.rgb||t.color.themeColor)?r.color={rgb:t.color.rgb,themeColor:t.color.themeColor}:delete r.color),t.highlight!==void 0&&(t.highlight?r.highlight=chunk4C2IJ7OV_js.va(t.highlight)||t.highlight:delete r.highlight),t.fontSize!==void 0&&(t.fontSize>0?r.fontSize=chunkMMJQ47Q7_js.m(t.fontSize):delete r.fontSize),t.fontFamily!==void 0&&(t.fontFamily&&(t.fontFamily.ascii||t.fontFamily.hAnsi)?r.fontFamily={ascii:t.fontFamily.ascii,hAnsi:t.fontFamily.hAnsi??t.fontFamily.ascii}:delete r.fontFamily);for(let n of Object.keys(r))r[n]===void 0&&delete r[n];return Object.keys(r).length>0?r:void 0}function S(o,t){o.formatting=se(o.formatting,t);}function ce(o,t,r,n){let a=o.run.content.every(s=>s.type==="text");if(t<=0&&r>=o.text.length||!a){S(o.run,n);return}let e=[];t>0&&e.push(B(o.run,o.text.slice(0,t)));let i=B(o.run,o.text.slice(t,r));S(i,n),e.push(i),r<o.text.length&&e.push(B(o.run,o.text.slice(r))),o.parent.splice(o.index,1,...e);}function ue(o,t,r,n){let e=D(o,false).filter(i=>i.start<r&&i.end>t);if(e.length===0)return true;for(let i=e.length-1;i>=0;i--){let s=e[i];ce(s,Math.max(0,t-s.start),Math.min(s.text.length,r-s.start),n);}return true}function le(o,t){let r=D(o,true);for(let n of r)S(n.run,t);return true}function fe(o,t){if(!t)return null;let n=D(o,false).map(e=>e.text).join(""),a=n.indexOf(t);return a===-1||n.indexOf(t,a+1)!==-1?null:{from:a,to:a+t.length}}function pe(o,t){return o?!!o.styles?.some(r=>r.styleId===t&&r.type==="paragraph"):true}function De(o){let t=new Set,r=null;function n(){return r===null&&(r=re(o)),r}function a(){if(t.size===0)return;let e=o.getComments(),i=o.getChanges(),s={commentCount:e.length,changeCount:i.length,comments:e,changes:i};for(let c of t)try{c(s);}catch(l){console.error("reviewerBridge content listener threw:",l);}}return {getContentAsText(e){return o.getContentAsText(e)},getContent(e){return o.getContent(e)},getComments(e){return o.getComments(e)},getChanges(e){return o.getChanges(e)},findText(e,i){if(!e)return [];let s=i?.caseSensitive??false,c=i?.limit??20,l=s?e:e.toLowerCase(),u=o.toDocument().package?.document;if(!u)return [];let f=[],d=40,x=0;for(let g of u.content){if(f.length>=c)break;if(g.type==="table"){for(let Y of g.rows)for(let Z of Y.cells)for(let _ of Z.content)_.type==="paragraph"&&x++;continue}if(g.type!=="paragraph"){x++;continue}let E=g,Q=x++,y=ae(E),$=s?y:y.toLowerCase(),h=$.indexOf(l);if(h===-1||$.indexOf(l,h+1)!==-1)continue;let V=y.slice(h,h+e.length);f.push({paraId:E.paraId??String(Q),match:V,before:y.slice(Math.max(0,h-d),h),after:y.slice(h+e.length,h+e.length+d)});}return f},getSelection(){return null},addComment(e){let i=n().get(e.paraId);if(i===void 0)return null;try{let s=o.addComment({paragraphIndex:i,text:e.text,author:e.author,search:e.search});return a(),s}catch{return null}},replyTo(e,i){try{let s=o.replyTo(e,i);return a(),s}catch{return null}},resolveComment(e){let s=o.toDocument().package?.document?.comments?.find(c=>c.id===e);if(!s)throw new R(e);s.done=true,a();},proposeChange(e){let i=n().get(e.paraId);if(i===void 0)return false;let s=e.search==="",c=e.replaceWith==="";if(s&&c)return false;try{return s?o.proposeInsertion({paragraphIndex:i,insertText:e.replaceWith,author:e.author}):c?o.proposeDeletion({paragraphIndex:i,search:e.search,author:e.author}):o.replace({paragraphIndex:i,search:e.search,replaceWith:e.replaceWith,author:e.author}),a(),true}catch{return false}},scrollTo(e){return n().has(e)},applyFormatting(e){let i=n().get(e.paraId);if(i===void 0)return false;let s=o.toDocument().package?.document;if(!s)return false;try{let c=s?P(s,i):null;if(!c)return false;if(e.search){let l=fe(c,e.search);if(!l)return false;ue(c,l.from,l.to,e.marks);}else le(c,e.marks);return a(),true}catch{return false}},setParagraphStyle(e){let i=n().get(e.paraId);if(i===void 0)return false;let s=o.toDocument(),c=s.package?.document;if(!c||!pe(s.package?.styles,e.styleId))return false;try{let l=P(c,i);return l.formatting={...l.formatting??{},styleId:e.styleId},a(),true}catch{return false}},insertBreak(e){let i=n().get(e.paraId);if(i===void 0)return false;let s=o.toDocument().package?.document;if(!s)return false;try{let c=P(s,i);if(!c)return false;if(e.type==="sectionNextPage"||e.type==="sectionContinuous"){let f=e.type==="sectionNextPage"?"nextPage":"continuous";return c.sectionProperties={...c.sectionProperties??{},sectionStart:f},a(),true}let l=s.content.indexOf(c);if(l===-1)return false;let u={type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]};return s.content.splice(l+1,0,u),r=null,a(),true}catch{return false}},getPage(){return null},getPages(){return []},getTotalPages(){return 0},getCurrentPage(){return 0},onContentChange(e){return t.add(e),()=>{t.delete(e);}},onSelectionChange(){return ()=>{}}}}exports.a=m;exports.b=P;exports.c=F;exports.d=k;exports.e=me;exports.f=xe;exports.g=C;exports.h=N;exports.i=R;exports.j=te;exports.k=Pe;exports.l=Fe;exports.m=ke;exports.n=De;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{o as executeCommand,p as executeCommands}from'./chunk-6RMDMHUK.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkMMJQ47Q7_js=require('./chunk-MMJQ47Q7.js');Object.defineProperty(exports,"executeCommand",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.o}});Object.defineProperty(exports,"executeCommands",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.p}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk4C2IJ7OV_js=require('./chunk-4C2IJ7OV.js'),chunk4QRVKNI4_js=require('./chunk-4QRVKNI4.js'),chunkMMJQ47Q7_js=require('./chunk-MMJQ47Q7.js');Object.defineProperty(exports,"ContentControlBoundError",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ga}});Object.defineProperty(exports,"ContentControlLockedError",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ea}});Object.defineProperty(exports,"ContentControlNotFoundError",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.da}});Object.defineProperty(exports,"ContentControlTypeError",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.fa}});Object.defineProperty(exports,"ContentControlValueError",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ja}});Object.defineProperty(exports,"DEFAULT_AI_ACTIONS",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Qa}});Object.defineProperty(exports,"DocumentAgent",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.x}});Object.defineProperty(exports,"RepeatingSectionError",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.oa}});Object.defineProperty(exports,"VERSION",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Sa}});Object.defineProperty(exports,"addRepeatingSectionItem",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.pa}});Object.defineProperty(exports,"attemptSelectiveSave",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.i}});Object.defineProperty(exports,"blendColors",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ha}});Object.defineProperty(exports,"buildExtendedSelectionContext",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.E}});Object.defineProperty(exports,"buildPatchedDocumentXml",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.h}});Object.defineProperty(exports,"buildSelectionContext",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.D}});Object.defineProperty(exports,"buildSelectionContextFromContext",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.B}});Object.defineProperty(exports,"colorsEqual",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ia}});Object.defineProperty(exports,"comparePositions",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Na}});Object.defineProperty(exports,"countCharacters",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.M}});Object.defineProperty(exports,"countWords",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.L}});Object.defineProperty(exports,"createAgent",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.y}});Object.defineProperty(exports,"createAgentFromDocument",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.z}});Object.defineProperty(exports,"createCollapsedRange",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ka}});Object.defineProperty(exports,"createCommand",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ra}});Object.defineProperty(exports,"createDocumentWithText",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ua}});Object.defineProperty(exports,"createDocx",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.f}});Object.defineProperty(exports,"createEmptyDocument",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ta}});Object.defineProperty(exports,"createRange",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.La}});Object.defineProperty(exports,"createRgbColor",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ea}});Object.defineProperty(exports,"createThemeColor",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Da}});Object.defineProperty(exports,"darkenColor",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Fa}});Object.defineProperty(exports,"detectVariables",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.j}});Object.defineProperty(exports,"detectVariablesDetailed",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.k}});Object.defineProperty(exports,"detectVariablesInBody",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.l}});Object.defineProperty(exports,"detectVariablesInParagraph",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.m}});Object.defineProperty(exports,"documentHasVariables",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.v}});Object.defineProperty(exports,"extractVariablesFromText",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.n}});Object.defineProperty(exports,"findContentControl",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ca}});Object.defineProperty(exports,"findContentControls",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ba}});Object.defineProperty(exports,"formatSdtDate",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ka}});Object.defineProperty(exports,"formatVariable",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.r}});Object.defineProperty(exports,"getActionDescription",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Pa}});Object.defineProperty(exports,"getActionLabel",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Oa}});Object.defineProperty(exports,"getAgentContext",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.A}});Object.defineProperty(exports,"getBlockIndexForParagraph",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.$}});Object.defineProperty(exports,"getBodyCharacterCount",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.O}});Object.defineProperty(exports,"getBodyText",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.K}});Object.defineProperty(exports,"getBodyWordCount",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.N}});Object.defineProperty(exports,"getContentControlText",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.aa}});Object.defineProperty(exports,"getContrastingColor",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ba}});Object.defineProperty(exports,"getDocumentSummary",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.C}});Object.defineProperty(exports,"getDocumentWatermark",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ra}});Object.defineProperty(exports,"getFormattingAtPosition",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.R}});Object.defineProperty(exports,"getHyperlinkAtPosition",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.T}});Object.defineProperty(exports,"getHyperlinkText",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.I}});Object.defineProperty(exports,"getParagraphAtIndex",{enumerable:true,get:function(){return chunk4C2IJ7OV_js._}});Object.defineProperty(exports,"getParagraphText",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.G}});Object.defineProperty(exports,"getParagraphs",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Z}});Object.defineProperty(exports,"getRunText",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.H}});Object.defineProperty(exports,"getSelectionFormattingSummary",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.F}});Object.defineProperty(exports,"getTableText",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.J}});Object.defineProperty(exports,"getTextAfter",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Q}});Object.defineProperty(exports,"getTextBefore",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.P}});Object.defineProperty(exports,"hasHyperlinks",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.X}});Object.defineProperty(exports,"hasImages",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.W}});Object.defineProperty(exports,"hasTables",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Y}});Object.defineProperty(exports,"hasTemplateVariables",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.o}});Object.defineProperty(exports,"isBlack",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.za}});Object.defineProperty(exports,"isHeadingStyle",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.U}});Object.defineProperty(exports,"isPositionInHyperlink",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.S}});Object.defineProperty(exports,"isPositionInRange",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ma}});Object.defineProperty(exports,"isRepeatingSection",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ma}});Object.defineProperty(exports,"isRepeatingSectionItem",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.na}});Object.defineProperty(exports,"isValidVariableName",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.p}});Object.defineProperty(exports,"isWhite",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Aa}});Object.defineProperty(exports,"isZodSchema",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ja}});Object.defineProperty(exports,"lightenColor",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ga}});Object.defineProperty(exports,"mapHexToHighlightName",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.va}});Object.defineProperty(exports,"parseColorString",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.Ca}});Object.defineProperty(exports,"parseDocx",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.w}});Object.defineProperty(exports,"parseHeadingLevel",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.V}});Object.defineProperty(exports,"parseVariable",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.s}});Object.defineProperty(exports,"removeContentControl",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ia}});Object.defineProperty(exports,"removeRepeatingSectionItem",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.qa}});Object.defineProperty(exports,"removeVariables",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.u}});Object.defineProperty(exports,"repackDocx",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.d}});Object.defineProperty(exports,"replaceVariables",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.t}});Object.defineProperty(exports,"resolveColor",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.wa}});Object.defineProperty(exports,"resolveHighlightColor",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.xa}});Object.defineProperty(exports,"resolveShadingColor",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ya}});Object.defineProperty(exports,"sanitizeVariableName",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.q}});Object.defineProperty(exports,"serializeDocumentBody",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.b}});Object.defineProperty(exports,"serializeDocx",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.c}});Object.defineProperty(exports,"serializeSectionProperties",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.a}});Object.defineProperty(exports,"setContentControlContent",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.ha}});Object.defineProperty(exports,"setContentControlValue",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.la}});Object.defineProperty(exports,"setDocumentWatermark",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.sa}});Object.defineProperty(exports,"updateMultipleFiles",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.e}});Object.defineProperty(exports,"validatePatchSafety",{enumerable:true,get:function(){return chunk4C2IJ7OV_js.g}});Object.defineProperty(exports,"createTemplateProcessor",{enumerable:true,get:function(){return chunk4QRVKNI4_js.j}});Object.defineProperty(exports,"getMissingVariables",{enumerable:true,get:function(){return chunk4QRVKNI4_js.g}});Object.defineProperty(exports,"getTemplateTags",{enumerable:true,get:function(){return chunk4QRVKNI4_js.e}});Object.defineProperty(exports,"previewTemplate",{enumerable:true,get:function(){return chunk4QRVKNI4_js.h}});Object.defineProperty(exports,"processTemplate",{enumerable:true,get:function(){return chunk4QRVKNI4_js.a}});Object.defineProperty(exports,"processTemplateAdvanced",{enumerable:true,get:function(){return chunk4QRVKNI4_js.i}});Object.defineProperty(exports,"processTemplateAsBlob",{enumerable:true,get:function(){return chunk4QRVKNI4_js.c}});Object.defineProperty(exports,"processTemplateDetailed",{enumerable:true,get:function(){return chunk4QRVKNI4_js.b}});Object.defineProperty(exports,"validateTemplate",{enumerable:true,get:function(){return chunk4QRVKNI4_js.f}});Object.defineProperty(exports,"PluginRegistry",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.a}});Object.defineProperty(exports,"createPluginRegistrar",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.d}});Object.defineProperty(exports,"emuToPixels",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.g}});Object.defineProperty(exports,"emuToTwips",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.i}});Object.defineProperty(exports,"executeCommand",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.o}});Object.defineProperty(exports,"executeCommands",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.p}});Object.defineProperty(exports,"formatPx",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.n}});Object.defineProperty(exports,"halfPointsToPixels",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.l}});Object.defineProperty(exports,"pixelsToEmu",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.h}});Object.defineProperty(exports,"pixelsToTwips",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.f}});Object.defineProperty(exports,"pluginRegistry",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.b}});Object.defineProperty(exports,"pointsToHalfPoints",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.m}});Object.defineProperty(exports,"pointsToPixels",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.k}});Object.defineProperty(exports,"registerPlugins",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.c}});Object.defineProperty(exports,"twipsToEmu",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.j}});Object.defineProperty(exports,"twipsToPixels",{enumerable:true,get:function(){return chunkMMJQ47Q7_js.e}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{ga as ContentControlBoundError,ea as ContentControlLockedError,da as ContentControlNotFoundError,fa as ContentControlTypeError,ja as ContentControlValueError,Qa as DEFAULT_AI_ACTIONS,x as DocumentAgent,oa as RepeatingSectionError,Sa as VERSION,pa as addRepeatingSectionItem,i as attemptSelectiveSave,Ha as blendColors,E as buildExtendedSelectionContext,h as buildPatchedDocumentXml,D as buildSelectionContext,B as buildSelectionContextFromContext,Ia as colorsEqual,Na as comparePositions,M as countCharacters,L as countWords,y as createAgent,z as createAgentFromDocument,Ka as createCollapsedRange,Ra as createCommand,ua as createDocumentWithText,f as createDocx,ta as createEmptyDocument,La as createRange,Ea as createRgbColor,Da as createThemeColor,Fa as darkenColor,j as detectVariables,k as detectVariablesDetailed,l as detectVariablesInBody,m as detectVariablesInParagraph,v as documentHasVariables,n as extractVariablesFromText,ca as findContentControl,ba as findContentControls,ka as formatSdtDate,r as formatVariable,Pa as getActionDescription,Oa as getActionLabel,A as getAgentContext,$ as getBlockIndexForParagraph,O as getBodyCharacterCount,K as getBodyText,N as getBodyWordCount,aa as getContentControlText,Ba as getContrastingColor,C as getDocumentSummary,ra as getDocumentWatermark,R as getFormattingAtPosition,T as getHyperlinkAtPosition,I as getHyperlinkText,_ as getParagraphAtIndex,G as getParagraphText,Z as getParagraphs,H as getRunText,F as getSelectionFormattingSummary,J as getTableText,Q as getTextAfter,P as getTextBefore,X as hasHyperlinks,W as hasImages,Y as hasTables,o as hasTemplateVariables,za as isBlack,U as isHeadingStyle,S as isPositionInHyperlink,Ma as isPositionInRange,ma as isRepeatingSection,na as isRepeatingSectionItem,p as isValidVariableName,Aa as isWhite,Ja as isZodSchema,Ga as lightenColor,va as mapHexToHighlightName,Ca as parseColorString,w as parseDocx,V as parseHeadingLevel,s as parseVariable,ia as removeContentControl,qa as removeRepeatingSectionItem,u as removeVariables,d as repackDocx,t as replaceVariables,wa as resolveColor,xa as resolveHighlightColor,ya as resolveShadingColor,q as sanitizeVariableName,b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties,ha as setContentControlContent,la as setContentControlValue,sa as setDocumentWatermark,e as updateMultipleFiles,g as validatePatchSafety}from'./chunk-
|
|
1
|
+
export{ga as ContentControlBoundError,ea as ContentControlLockedError,da as ContentControlNotFoundError,fa as ContentControlTypeError,ja as ContentControlValueError,Qa as DEFAULT_AI_ACTIONS,x as DocumentAgent,oa as RepeatingSectionError,Sa as VERSION,pa as addRepeatingSectionItem,i as attemptSelectiveSave,Ha as blendColors,E as buildExtendedSelectionContext,h as buildPatchedDocumentXml,D as buildSelectionContext,B as buildSelectionContextFromContext,Ia as colorsEqual,Na as comparePositions,M as countCharacters,L as countWords,y as createAgent,z as createAgentFromDocument,Ka as createCollapsedRange,Ra as createCommand,ua as createDocumentWithText,f as createDocx,ta as createEmptyDocument,La as createRange,Ea as createRgbColor,Da as createThemeColor,Fa as darkenColor,j as detectVariables,k as detectVariablesDetailed,l as detectVariablesInBody,m as detectVariablesInParagraph,v as documentHasVariables,n as extractVariablesFromText,ca as findContentControl,ba as findContentControls,ka as formatSdtDate,r as formatVariable,Pa as getActionDescription,Oa as getActionLabel,A as getAgentContext,$ as getBlockIndexForParagraph,O as getBodyCharacterCount,K as getBodyText,N as getBodyWordCount,aa as getContentControlText,Ba as getContrastingColor,C as getDocumentSummary,ra as getDocumentWatermark,R as getFormattingAtPosition,T as getHyperlinkAtPosition,I as getHyperlinkText,_ as getParagraphAtIndex,G as getParagraphText,Z as getParagraphs,H as getRunText,F as getSelectionFormattingSummary,J as getTableText,Q as getTextAfter,P as getTextBefore,X as hasHyperlinks,W as hasImages,Y as hasTables,o as hasTemplateVariables,za as isBlack,U as isHeadingStyle,S as isPositionInHyperlink,Ma as isPositionInRange,ma as isRepeatingSection,na as isRepeatingSectionItem,p as isValidVariableName,Aa as isWhite,Ja as isZodSchema,Ga as lightenColor,va as mapHexToHighlightName,Ca as parseColorString,w as parseDocx,V as parseHeadingLevel,s as parseVariable,ia as removeContentControl,qa as removeRepeatingSectionItem,u as removeVariables,d as repackDocx,t as replaceVariables,wa as resolveColor,xa as resolveHighlightColor,ya as resolveShadingColor,q as sanitizeVariableName,b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties,ha as setContentControlContent,la as setContentControlValue,sa as setDocumentWatermark,e as updateMultipleFiles,g as validatePatchSafety}from'./chunk-ICDWMZPG.mjs';export{j as createTemplateProcessor,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-UILTIEBD.mjs';export{a as PluginRegistry,d as createPluginRegistrar,g as emuToPixels,i as emuToTwips,o as executeCommand,p as executeCommands,n as formatPx,l as halfPointsToPixels,h as pixelsToEmu,f as pixelsToTwips,b as pluginRegistry,m as pointsToHalfPoints,k as pointsToPixels,c as registerPlugins,j as twipsToEmu,e as twipsToPixels}from'./chunk-6RMDMHUK.mjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
* @packageDocumentation
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
|
-
import { G as GetContentOptions, C as ContentBlock, a as CommentFilter, R as ReviewComment, b as ChangeFilter, c as ReviewChange, F as FoundMatch, S as SelectionInfo, A as AddCommentByParaIdOptions, d as ReplyOptions, P as ProposeChangeOptions, e as ApplyFormattingOptions, f as SetParagraphStyleOptions, g as PageContent, h as ContentChangeEvent, i as SelectionChangeEvent } from './server-
|
|
32
|
-
export { j as AgentToolDefinition, k as AgentToolResult, B as BatchError, l as BatchResult, m as BatchReviewOptions, D as DocxReviewer, n as agentTools, o as createReviewerBridge, p as executeToolCall, q as getToolSchemas } from './server-
|
|
31
|
+
import { G as GetContentOptions, C as ContentBlock, a as CommentFilter, R as ReviewComment, b as ChangeFilter, c as ReviewChange, F as FoundMatch, S as SelectionInfo, A as AddCommentByParaIdOptions, d as ReplyOptions, P as ProposeChangeOptions, e as ApplyFormattingOptions, f as SetParagraphStyleOptions, g as PageContent, h as ContentChangeEvent, i as SelectionChangeEvent } from './server-DP8QoY84.mjs';
|
|
32
|
+
export { j as AgentToolDefinition, k as AgentToolResult, B as BatchError, l as BatchResult, m as BatchReviewOptions, D as DocxReviewer, n as agentTools, o as createReviewerBridge, p as executeToolCall, q as getToolSchemas } from './server-DP8QoY84.mjs';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Error classes for @eigenpal/docx-editor-agents
|
|
@@ -75,6 +75,7 @@ declare class CommentNotFoundError extends Error {
|
|
|
75
75
|
* | `Document.onSelectionChanged.add()` | `onSelectionChange(listener)` |
|
|
76
76
|
* | `Range.font.bold` / `italic` / `color` / `size` / `name` | `applyFormatting({paraId, search?, marks})` |
|
|
77
77
|
* | `ParagraphFormat.style` / `applyStyle(...)` | `setParagraphStyle({paraId, styleId})` |
|
|
78
|
+
* | `Range.insertBreak(BreakType.*)` | `insertBreak({paraId, type})` |
|
|
78
79
|
*
|
|
79
80
|
* ## Beyond Word's surface (paged-document affordances)
|
|
80
81
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
* @packageDocumentation
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
|
-
import { G as GetContentOptions, C as ContentBlock, a as CommentFilter, R as ReviewComment, b as ChangeFilter, c as ReviewChange, F as FoundMatch, S as SelectionInfo, A as AddCommentByParaIdOptions, d as ReplyOptions, P as ProposeChangeOptions, e as ApplyFormattingOptions, f as SetParagraphStyleOptions, g as PageContent, h as ContentChangeEvent, i as SelectionChangeEvent } from './server-
|
|
32
|
-
export { j as AgentToolDefinition, k as AgentToolResult, B as BatchError, l as BatchResult, m as BatchReviewOptions, D as DocxReviewer, n as agentTools, o as createReviewerBridge, p as executeToolCall, q as getToolSchemas } from './server-
|
|
31
|
+
import { G as GetContentOptions, C as ContentBlock, a as CommentFilter, R as ReviewComment, b as ChangeFilter, c as ReviewChange, F as FoundMatch, S as SelectionInfo, A as AddCommentByParaIdOptions, d as ReplyOptions, P as ProposeChangeOptions, e as ApplyFormattingOptions, f as SetParagraphStyleOptions, g as PageContent, h as ContentChangeEvent, i as SelectionChangeEvent } from './server-DP8QoY84.js';
|
|
32
|
+
export { j as AgentToolDefinition, k as AgentToolResult, B as BatchError, l as BatchResult, m as BatchReviewOptions, D as DocxReviewer, n as agentTools, o as createReviewerBridge, p as executeToolCall, q as getToolSchemas } from './server-DP8QoY84.js';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Error classes for @eigenpal/docx-editor-agents
|
|
@@ -75,6 +75,7 @@ declare class CommentNotFoundError extends Error {
|
|
|
75
75
|
* | `Document.onSelectionChanged.add()` | `onSelectionChange(listener)` |
|
|
76
76
|
* | `Range.font.bold` / `italic` / `color` / `size` / `name` | `applyFormatting({paraId, search?, marks})` |
|
|
77
77
|
* | `ParagraphFormat.style` / `applyStyle(...)` | `setParagraphStyle({paraId, styleId})` |
|
|
78
|
+
* | `Range.insertBreak(BreakType.*)` | `insertBreak({paraId, type})` |
|
|
78
79
|
*
|
|
79
80
|
* ## Beyond Word's surface (paged-document affordances)
|
|
80
81
|
*
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkVAQTAQZG_js=require('./chunk-VAQTAQZG.js'),chunkYU3OJ2DE_js=require('./chunk-YU3OJ2DE.js'),chunkAO5SO6ZS_js=require('./chunk-AO5SO6ZS.js');Object.defineProperty(exports,"DocxReviewer",{enumerable:true,get:function(){return chunkVAQTAQZG_js.a}});Object.defineProperty(exports,"ChangeNotFoundError",{enumerable:true,get:function(){return chunkYU3OJ2DE_js.h}});Object.defineProperty(exports,"CommentNotFoundError",{enumerable:true,get:function(){return chunkYU3OJ2DE_js.i}});Object.defineProperty(exports,"TextNotFoundError",{enumerable:true,get:function(){return chunkYU3OJ2DE_js.g}});Object.defineProperty(exports,"createReviewerBridge",{enumerable:true,get:function(){return chunkYU3OJ2DE_js.n}});Object.defineProperty(exports,"agentTools",{enumerable:true,get:function(){return chunkAO5SO6ZS_js.a}});Object.defineProperty(exports,"executeToolCall",{enumerable:true,get:function(){return chunkAO5SO6ZS_js.b}});Object.defineProperty(exports,"getToolSchemas",{enumerable:true,get:function(){return chunkAO5SO6ZS_js.d}});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as DocxReviewer}from'./chunk-
|
|
1
|
+
export{a as DocxReviewer}from'./chunk-CGBO6ID5.mjs';export{h as ChangeNotFoundError,i as CommentNotFoundError,g as TextNotFoundError,n as createReviewerBridge}from'./chunk-J773ZJGL.mjs';export{a as agentTools,b as executeToolCall,d as getToolSchemas}from'./chunk-MSKW7E36.mjs';
|
package/dist/mcp.d.mts
CHANGED
package/dist/mcp.d.ts
CHANGED
package/dist/mcp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkAO5SO6ZS_js=require('./chunk-AO5SO6ZS.js');var i={ParseError:-32700,InvalidRequest:-32600,MethodNotFound:-32601,InvalidParams:-32602,InternalError:-32603};function v(t){return typeof t=="object"&&t!==null&&t.jsonrpc==="2.0"&&typeof t.method=="string"&&"id"in t}function I(t){return typeof t=="object"&&t!==null&&t.jsonrpc==="2.0"&&typeof t.method=="string"&&!("id"in t)}function u(t,r){return {jsonrpc:"2.0",id:t,result:r}}function p(t,r,e,o){return {jsonrpc:"2.0",id:t,error:o===void 0?{code:r,message:e}:{code:r,message:e,data:o}}}function y(t){let r=[],e=[],o=t.split(`
|
|
2
2
|
`),n=o.pop()??"";for(let c of o){let a=c.trim();if(a)try{r.push(JSON.parse(a));}catch{e.push(a);}}return {messages:r,parseErrors:e,rest:n}}function d(t){return JSON.stringify(t)+`
|
|
3
|
-
`}var T="2025-06-18",f=class{constructor(r,e={}){this.bridge=r,this.opts={name:e.name??"@eigenpal/docx-editor-agents",version:e.version??"0.0.0",protocolVersion:e.protocolVersion??T};}handle(r){if(!v(r))return null;let e=r;try{switch(e.method){case "initialize":return u(e.id,this.handleInitialize());case "tools/list":return u(e.id,this.handleToolsList());case "tools/call":return this.handleToolsCall(e);case "ping":return u(e.id,{});default:return p(e.id,i.MethodNotFound,`Method not found: ${e.method}`)}}catch(o){return p(e.id,i.InternalError,o instanceof Error?o.message:String(o))}}handleInitialize(){return {protocolVersion:this.opts.protocolVersion,capabilities:{tools:{}},serverInfo:{name:this.opts.name,version:this.opts.version}}}handleToolsList(){return {tools:
|
|
4
|
-
`);});if(!o||!n)throw new Error("runStdioServer: no input/output stream available. Pass options.input and options.output, or run inside a Node process with stdin/stdout.");let a=n,h=new
|
|
3
|
+
`}var T="2025-06-18",f=class{constructor(r,e={}){this.bridge=r,this.opts={name:e.name??"@eigenpal/docx-editor-agents",version:e.version??"0.0.0",protocolVersion:e.protocolVersion??T};}handle(r){if(!v(r))return null;let e=r;try{switch(e.method){case "initialize":return u(e.id,this.handleInitialize());case "tools/list":return u(e.id,this.handleToolsList());case "tools/call":return this.handleToolsCall(e);case "ping":return u(e.id,{});default:return p(e.id,i.MethodNotFound,`Method not found: ${e.method}`)}}catch(o){return p(e.id,i.InternalError,o instanceof Error?o.message:String(o))}}handleInitialize(){return {protocolVersion:this.opts.protocolVersion,capabilities:{tools:{}},serverInfo:{name:this.opts.name,version:this.opts.version}}}handleToolsList(){return {tools:chunkAO5SO6ZS_js.a.map(r=>({name:r.name,description:r.description,inputSchema:r.inputSchema}))}}handleToolsCall(r){let e=r.params;if(!e||typeof e.name!="string")return p(r.id,i.InvalidParams,'tools/call requires a "name" string');let o=e.arguments??{},n=chunkAO5SO6ZS_js.b(e.name,o,this.bridge),c=n.success?{content:[{type:"text",text:typeof n.data=="string"?n.data:JSON.stringify(n.data,null,2)}]}:{isError:true,content:[{type:"text",text:n.error??"Unknown tool error"}]};return u(r.id,c)}};var x=1024*1024;function C(t,r={}){let e=new f(t,r),o=r.input??(typeof process<"u"&&process.stdin?process.stdin:null),n=r.output??(typeof process<"u"&&process.stdout?process.stdout:null),c=r.log??(s=>{typeof process<"u"&&process.stderr&&process.stderr.write(s+`
|
|
4
|
+
`);});if(!o||!n)throw new Error("runStdioServer: no input/output stream available. Pass options.input and options.output, or run inside a Node process with stdin/stdout.");let a=n,h=new TextDecoder("utf-8"),l="",R=false;function w(s){let g=e.handle(s);g!==null&&a.write(d(g));}function J(s){if(R)return;if(l+=typeof s=="string"?s:h.decode(s,{stream:true}),l.length>x){l="",c(`MCP buffer overflow (>${x} bytes without newline) \u2014 dropped`),a.write(d(p(null,i.ParseError,"Frame too large")));return}let{messages:g,parseErrors:E,rest:k}=y(l);l=k;for(let m of g)w(m);for(let m of E)c(`MCP parse error: ${m}`),a.write(d(p(null,i.ParseError,"Parse error",m)));}return o.on("data",J),o.on("end",()=>{R=true;}),o.on("error",s=>{c(`MCP input error: ${s.message}`),R=true;}),{server:e,feed:J,close(){R=true;}}}exports.ErrorCode=i;exports.McpServer=f;exports.encodeFrame=d;exports.isJsonRpcNotification=I;exports.isJsonRpcRequest=v;exports.makeError=p;exports.makeSuccess=u;exports.parseFrames=y;exports.runStdioServer=C;
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a,b
|
|
1
|
+
import {a,b}from'./chunk-MSKW7E36.mjs';var i={ParseError:-32700,InvalidRequest:-32600,MethodNotFound:-32601,InvalidParams:-32602,InternalError:-32603};function v(t){return typeof t=="object"&&t!==null&&t.jsonrpc==="2.0"&&typeof t.method=="string"&&"id"in t}function I(t){return typeof t=="object"&&t!==null&&t.jsonrpc==="2.0"&&typeof t.method=="string"&&!("id"in t)}function u(t,r){return {jsonrpc:"2.0",id:t,result:r}}function p(t,r,e,o){return {jsonrpc:"2.0",id:t,error:o===void 0?{code:r,message:e}:{code:r,message:e,data:o}}}function y(t){let r=[],e=[],o=t.split(`
|
|
2
2
|
`),n=o.pop()??"";for(let c of o){let a=c.trim();if(a)try{r.push(JSON.parse(a));}catch{e.push(a);}}return {messages:r,parseErrors:e,rest:n}}function d(t){return JSON.stringify(t)+`
|
|
3
|
-
`}var T="2025-06-18",f=class{constructor(r,e={}){this.bridge=r,this.opts={name:e.name??"@eigenpal/docx-editor-agents",version:e.version??"0.0.0",protocolVersion:e.protocolVersion??T};}handle(r){if(!v(r))return null;let e=r;try{switch(e.method){case "initialize":return u(e.id,this.handleInitialize());case "tools/list":return u(e.id,this.handleToolsList());case "tools/call":return this.handleToolsCall(e);case "ping":return u(e.id,{});default:return p(e.id,i.MethodNotFound,`Method not found: ${e.method}`)}}catch(o){return p(e.id,i.InternalError,o instanceof Error?o.message:String(o))}}handleInitialize(){return {protocolVersion:this.opts.protocolVersion,capabilities:{tools:{}},serverInfo:{name:this.opts.name,version:this.opts.version}}}handleToolsList(){return {tools:a.map(r=>({name:r.name,description:r.description,inputSchema:r.inputSchema}))}}handleToolsCall(r){let e=r.params;if(!e||typeof e.name!="string")return p(r.id,i.InvalidParams,'tools/call requires a "name" string');let o=e.arguments??{},n=b
|
|
4
|
-
`);});if(!o||!n)throw new Error("runStdioServer: no input/output stream available. Pass options.input and options.output, or run inside a Node process with stdin/stdout.");let a=n,h=new
|
|
3
|
+
`}var T="2025-06-18",f=class{constructor(r,e={}){this.bridge=r,this.opts={name:e.name??"@eigenpal/docx-editor-agents",version:e.version??"0.0.0",protocolVersion:e.protocolVersion??T};}handle(r){if(!v(r))return null;let e=r;try{switch(e.method){case "initialize":return u(e.id,this.handleInitialize());case "tools/list":return u(e.id,this.handleToolsList());case "tools/call":return this.handleToolsCall(e);case "ping":return u(e.id,{});default:return p(e.id,i.MethodNotFound,`Method not found: ${e.method}`)}}catch(o){return p(e.id,i.InternalError,o instanceof Error?o.message:String(o))}}handleInitialize(){return {protocolVersion:this.opts.protocolVersion,capabilities:{tools:{}},serverInfo:{name:this.opts.name,version:this.opts.version}}}handleToolsList(){return {tools:a.map(r=>({name:r.name,description:r.description,inputSchema:r.inputSchema}))}}handleToolsCall(r){let e=r.params;if(!e||typeof e.name!="string")return p(r.id,i.InvalidParams,'tools/call requires a "name" string');let o=e.arguments??{},n=b(e.name,o,this.bridge),c=n.success?{content:[{type:"text",text:typeof n.data=="string"?n.data:JSON.stringify(n.data,null,2)}]}:{isError:true,content:[{type:"text",text:n.error??"Unknown tool error"}]};return u(r.id,c)}};var x=1024*1024;function C(t,r={}){let e=new f(t,r),o=r.input??(typeof process<"u"&&process.stdin?process.stdin:null),n=r.output??(typeof process<"u"&&process.stdout?process.stdout:null),c=r.log??(s=>{typeof process<"u"&&process.stderr&&process.stderr.write(s+`
|
|
4
|
+
`);});if(!o||!n)throw new Error("runStdioServer: no input/output stream available. Pass options.input and options.output, or run inside a Node process with stdin/stdout.");let a=n,h=new TextDecoder("utf-8"),l="",R=false;function w(s){let g=e.handle(s);g!==null&&a.write(d(g));}function J(s){if(R)return;if(l+=typeof s=="string"?s:h.decode(s,{stream:true}),l.length>x){l="",c(`MCP buffer overflow (>${x} bytes without newline) \u2014 dropped`),a.write(d(p(null,i.ParseError,"Frame too large")));return}let{messages:g,parseErrors:E,rest:k}=y(l);l=k;for(let m of g)w(m);for(let m of E)c(`MCP parse error: ${m}`),a.write(d(p(null,i.ParseError,"Parse error",m)));}return o.on("data",J),o.on("end",()=>{R=true;}),o.on("error",s=>{c(`MCP input error: ${s.message}`),R=true;}),{server:e,feed:J,close(){R=true;}}}export{i as ErrorCode,f as McpServer,d as encodeFrame,I as isJsonRpcNotification,v as isJsonRpcRequest,p as makeError,u as makeSuccess,y as parseFrames,C as runStdioServer};
|