@eigenpal/docx-editor-agents 1.2.0 → 1.3.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/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-2OIX7TUX.mjs +75 -0
- package/dist/chunk-4W7OEW2I.js +75 -0
- package/dist/{chunk-DIXFGAF5.js → chunk-7PTBNHAH.js} +2 -2
- package/dist/chunk-LX3NJWKV.js +1 -0
- package/dist/chunk-NFAEIOLC.mjs +1 -0
- package/dist/chunk-P4DRISTP.mjs +5 -0
- package/dist/chunk-XUAUDUJU.js +5 -0
- package/dist/{chunk-HTU7NUTJ.mjs → chunk-YQIAKHOL.mjs} +2 -2
- package/dist/headless-ES4B5CTK.js +1 -0
- package/dist/headless-OEZEYHNL.mjs +1 -0
- package/dist/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- 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/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/{server-uM9UUIhk.d.mts → server-BaVhdHCd.d.mts} +192 -11
- package/dist/{server-uM9UUIhk.d.ts → server-BaVhdHCd.d.ts} +192 -11
- 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 +72 -56
- package/package.json +1 -1
- package/dist/chunk-6KT5LOQB.mjs +0 -1
- package/dist/chunk-B3LQVYMR.js +0 -74
- package/dist/chunk-L7LXQOTH.mjs +0 -74
- package/dist/chunk-MHUG23P6.js +0 -5
- package/dist/chunk-MK47WH2X.mjs +0 -5
- package/dist/chunk-NSFRE2VK.js +0 -1
- package/dist/headless-6C4JSKYY.mjs +0 -1
- package/dist/headless-VGNLVFAJ.js +0 -1
package/dist/vue.js
CHANGED
|
@@ -6,15 +6,15 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
6
6
|
@keyframes epAgentSpin {
|
|
7
7
|
to { transform: rotate(360deg); }
|
|
8
8
|
}
|
|
9
|
-
`,document.head.appendChild(e)}let s={flex:1,overflow:`auto`,padding:`16px 14px 8px`,display:`flex`,flexDirection:`column`,gap:`10px`},c={messageGroup:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`},userBubble:{background:`#0b57d0`,color:`#fff`,padding:`10px 14px`,borderRadius:`20px 20px 4px 20px`,fontSize:`13.5px`,lineHeight:1.5,alignSelf:`flex-end`,maxWidth:`88%`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontFamily:`'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif`},assistantBubble:{background:`#f0f4f9`,color:`#1f1f1f`,padding:`12px 16px`,borderRadius:`20px 20px 20px 4px`,fontSize:`13.5px`,lineHeight:1.55,alignSelf:`flex-start`,maxWidth:`92%`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontFamily:`'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif`},thinkingBubble:{background:`#f0f4f9`,padding:`12px 16px`,borderRadius:`20px 20px 20px 4px`,alignSelf:`flex-start`,display:`flex`,gap:`4px`,alignItems:`center`},dot:{width:`6px`,height:`6px`,borderRadius:`50%`,background:`#5f6368`,display:`inline-block`,animation:`epAgentDot 1.4s infinite ease-in-out`},errorBubble:{background:`#fce8e6`,color:`#b3261e`,padding:`10px 14px`,borderRadius:`16px`,fontSize:`12.5px`,alignSelf:`flex-start`,maxWidth:`92%`,whiteSpace:`pre-wrap`,fontFamily:`'Google Sans Text', system-ui, sans-serif`}};return(n,a)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:(0,e.normalizeClass)([`ep-agent-chat-log`,t.className]),style:s,role:`log`,"aria-live":`polite`,"aria-atomic":`false`},[i.value?(0,e.renderSlot)(n.$slots,`empty`,{key:0}):(0,e.createCommentVNode)(``,!0),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.messages,n=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:n.id,style:(0,e.normalizeStyle)(c.messageGroup),"data-role":n.role},[n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0?((0,e.openBlock)(),(0,e.createBlock)(p,{key:0,"tool-calls":n.toolCalls,streaming:n.status===`streaming`,"humanize-name":t.humanizeToolName,"max-visible-calls":t.maxVisibleCalls,"working-label":t.workingLabel,"summary-label":t.summaryLabel,"earlier-label":t.earlierLabel},null,8,[`tool-calls`,`streaming`,`humanize-name`,`max-visible-calls`,`working-label`,`summary-label`,`earlier-label`])):(0,e.createCommentVNode)(``,!0),n.text.length>0?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,style:(0,e.normalizeStyle)(n.role===`user`?c.userBubble:c.assistantBubble)},(0,e.toDisplayString)(n.text),5)):(0,e.createCommentVNode)(``,!0)],12,m))),128)),t.loading?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,style:(0,e.normalizeStyle)(c.thinkingBubble),"aria-label":t.thinkingLabel},[(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0s`})},null,4),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0.15s`})},null,4),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0.3s`})},null,4)],12,h)):(0,e.createCommentVNode)(``,!0),t.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:2,style:(0,e.normalizeStyle)(c.errorBubble),role:`alert`},(0,e.toDisplayString)(t.error),5)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,{ref_key:`endEl`,ref:r},null,512)],2))}}),v=[`value`,`placeholder`,`disabled`],y=[`aria-label`,`disabled`],b=(0,e.defineComponent)({__name:`AgentComposer`,props:{modelValue:{},disabled:{type:Boolean,default:!1},placeholder:{default:()=>n.agentPanel.composerPlaceholder},sendLabel:{default:()=>n.agentPanel.send},className:{default:``}},emits:[`update:modelValue`,`submit`],setup(t,{emit:n}){let r=t,i=n,a=(0,e.computed)(()=>r.modelValue.trim().length>0&&!r.disabled);function o(){a.value&&i(`submit`)}let s=(0,e.computed)(()=>({width:`36px`,height:`36px`,borderRadius:`50%`,border:`none`,background:`#0b57d0`,color:`#fff`,flexShrink:0,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,transition:`background 0.15s, opacity 0.15s, transform 0.15s`,opacity:a.value?1:.35,cursor:a.value?`pointer`:`not-allowed`})),c={composerWrap:{padding:`8px 12px 14px`,background:`#fff`,flex:`0 0 auto`},composerShell:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`6px 6px 6px 18px`,background:`#fff`,border:`1px solid #c4c7c5`,borderRadius:`28px`,boxShadow:`0 1px 2px rgba(60,64,67,0.04)`,transition:`border-color 0.15s, box-shadow 0.15s`,fontFamily:`'Google Sans Text', system-ui, sans-serif`},composerInput:{flex:1,padding:`8px 0`,fontSize:`14px`,border:`none`,outline:`none`,background:`transparent`,fontFamily:`inherit`,color:`#1f1f1f`},footnote:{fontSize:`11px`,color:`#5f6368`,textAlign:`center`,marginTop:`10px`,fontFamily:`'Google Sans Text', system-ui, sans-serif`}};return(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`form`,{class:(0,e.normalizeClass)([`ep-agent-composer`,t.className]),style:(0,e.normalizeStyle)(c.composerWrap),onSubmit:(0,e.withModifiers)(o,[`prevent`])},[(0,e.createElementVNode)(`div`,{style:(0,e.normalizeStyle)(c.composerShell)},[(0,e.createElementVNode)(`input`,{style:(0,e.normalizeStyle)(c.composerInput),value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,onInput:r[0]||=e=>i(`update:modelValue`,e.target.value)},null,44,v),(0,e.createElementVNode)(`button`,{type:`submit`,"aria-label":t.sendLabel,disabled:!a.value,style:(0,e.normalizeStyle)(s.value)},[...r[1]||=[(0,e.createElementVNode)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[(0,e.createElementVNode)(`path`,{d:`M12 19V5M5 12l7-7 7 7`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})],-1)]],12,y)],4),n.$slots.footnote?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,style:(0,e.normalizeStyle)(c.footnote)},[(0,e.renderSlot)(n.$slots,`footnote`)],4)):(0,e.createCommentVNode)(``,!0)],38))}}),x=[`disabled`],S=(0,e.defineComponent)({__name:`AgentSuggestionChip`,props:{label:{},disabled:{type:Boolean}},emits:[`click`],setup(t,{emit:n}){let r=n,i={textAlign:`left`,background:`#fff`,border:`1px solid #dadce0`,borderRadius:`18px`,padding:`10px 14px`,fontSize:`13px`,color:`#1f1f1f`,cursor:`pointer`,fontFamily:`'Google Sans Text', system-ui, sans-serif`,lineHeight:1.4,transition:`background 0.15s, border-color 0.15s, box-shadow 0.15s`,width:`100%`};return(n,a)=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{type:`button`,style:i,disabled:t.disabled,onClick:a[0]||=e=>r(`click`)},(0,e.toDisplayString)(t.label),9,x))}}),C=[`aria-label`],w={class:`ai-ctx-menu__header`,"aria-hidden":`true`},T=[`onMousedown`],E=[`innerHTML`],D={class:`ai-ctx-menu__label`},O={key:0,class:`ai-ctx-menu__custom`},k=[`placeholder`],A=(0,e.defineComponent)({__name:`AIContextMenu`,props:{isOpen:{type:Boolean},position:{},selectedText:{},showCustomPrompt:{type:Boolean,default:!0},labels:{default:()=>({})}},emits:[`close`,`action`],setup(t,{emit:r}){let i=t,a=r,o=(0,e.ref)(``),s=(0,e.ref)([]);(0,e.watch)(()=>i.isOpen,t=>{t&&(0,e.nextTick)(()=>s.value[0]?.focus())},{immediate:!0});let c=[{id:`rewrite`,icon:`✍`},{id:`expand`,icon:`↔`},{id:`summarize`,icon:`📝`},{id:`fixGrammar`,icon:`✔`},{id:`makeFormal`,icon:`👔`},{id:`makeCasual`,icon:`😊`},{id:`translate`,icon:`🌐`},{id:`explain`,icon:`💡`}],l=(0,e.computed)(()=>i.labels?.header??n.aiActions.header),u=(0,e.computed)(()=>i.labels?.customPlaceholder??n.aiActions.customPlaceholder);function d(e){return i.labels?.[e]||(n.aiActions[e]??e)}let f=(0,e.computed)(()=>{let e=i.position.x,t=i.position.y;return typeof window<`u`&&(e+220+10>window.innerWidth&&(e=window.innerWidth-220-10),t+360+10>window.innerHeight&&(t=window.innerHeight-360-10)),{position:`fixed`,left:`${e}px`,top:`${t}px`,zIndex:500}});function p(e){a(`action`,e,e===`custom`?o.value:void 0),o.value=``,a(`close`)}return(n,r)=>((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:`body`},[t.isOpen?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`ai-ctx-backdrop`,onMousedown:r[0]||=e=>a(`close`),onContextmenu:r[1]||=(0,e.withModifiers)(e=>a(`close`),[`prevent`])},null,32)):(0,e.createCommentVNode)(``,!0),t.isOpen?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,class:`ai-ctx-menu`,"aria-label":l.value,style:(0,e.normalizeStyle)(f.value),tabindex:`-1`,onContextmenu:r[4]||=(0,e.withModifiers)(()=>{},[`prevent`]),onKeydown:r[5]||=(0,e.withKeys)((0,e.withModifiers)(e=>a(`close`),[`stop`]),[`esc`])},[(0,e.createElementVNode)(`div`,w,(0,e.toDisplayString)(l.value),1),((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(c,t=>(0,e.createElementVNode)(`button`,{key:t.id,ref_for:!0,ref_key:`itemRefs`,ref:s,class:`ai-ctx-menu__item`,onMousedown:(0,e.withModifiers)(e=>p(t.id),[`prevent`])},[(0,e.createElementVNode)(`span`,{class:`ai-ctx-menu__icon`,innerHTML:t.icon},null,8,E),(0,e.createElementVNode)(`span`,D,(0,e.toDisplayString)(d(t.id)),1)],40,T)),64)),r[6]||=(0,e.createElementVNode)(`div`,{class:`ai-ctx-menu__divider`},null,-1),t.showCustomPrompt?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,O,[(0,e.withDirectives)((0,e.createElementVNode)(`input`,{"onUpdate:modelValue":r[2]||=e=>o.value=e,class:`ai-ctx-menu__input`,placeholder:u.value,onKeydown:r[3]||=(0,e.withKeys)((0,e.withModifiers)(e=>p(`custom`),[`prevent`]),[`enter`])},null,40,k),[[e.vModelText,o.value]])])):(0,e.createCommentVNode)(``,!0)],44,C)):(0,e.createCommentVNode)(``,!0)]))}}),j=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},M=j(A,[[`__scopeId`,`data-v-c30da7a7`]]),ee=[`aria-label`],te={class:`ai-preview__header`},ne={class:`ai-preview__title`},re=[`aria-label`],ie={key:0,class:`ai-preview__loading`},ae={key:1,class:`ai-preview__error`},oe={key:2,class:`ai-preview__content`},se={key:0,class:`ai-preview__diff`},ce={class:`ai-preview__diff-label`},le={class:`ai-preview__diff-text ai-preview__diff-text--old`},ue={class:`ai-preview__diff-label`},de={class:`ai-preview__diff-text ai-preview__diff-text--new`},N={key:1,class:`ai-preview__result`},P={key:3,class:`ai-preview__footer`},F=j((0,e.defineComponent)({__name:`AIResponsePreview`,props:{isVisible:{type:Boolean},originalText:{},responseText:{},action:{},isLoading:{type:Boolean},error:{default:void 0},allowEdit:{type:Boolean,default:!0},showDiff:{type:Boolean,default:!0},showRetry:{type:Boolean,default:!0},labels:{default:()=>({})}},emits:[`accept`,`reject`,`retry`],setup(t,{emit:r}){let i=t,a=r,o=(0,e.ref)(!1),s=(0,e.ref)(``),c=(0,e.computed)(()=>({loading:i.labels?.loading??n.aiPreview.loading,original:i.labels?.original??n.aiPreview.original,suggested:i.labels?.suggested??n.aiPreview.suggested,edit:i.labels?.edit??n.aiPreview.edit,discard:i.labels?.discard??n.aiPreview.discard,accept:i.labels?.accept??n.aiPreview.accept,retry:i.labels?.retry??n.aiPreview.retry,close:i.labels?.close??n.aiPreview.close})),l=(0,e.computed)(()=>i.labels?.actionTitles?.[i.action]||(n.aiPreview.labels[i.action]??n.aiPreview.defaultTitle));(0,e.watch)(()=>i.responseText,e=>{s.value=e,o.value=!1});function u(){a(`accept`,o.value?s.value:i.responseText)}return(n,r)=>t.isVisible?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`ai-preview`,role:`region`,"aria-label":l.value,tabindex:`-1`,onKeydown:r[5]||=(0,e.withKeys)((0,e.withModifiers)(e=>a(`reject`),[`stop`]),[`esc`])},[(0,e.createElementVNode)(`div`,te,[(0,e.createElementVNode)(`span`,ne,(0,e.toDisplayString)(l.value),1),(0,e.createElementVNode)(`button`,{class:`ai-preview__close`,"aria-label":c.value.close,onClick:r[0]||=e=>a(`reject`)},` ✕ `,8,re)]),t.isLoading?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ie,[r[6]||=(0,e.createElementVNode)(`span`,{class:`ai-preview__spinner`},null,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(c.value.loading),1)])):t.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ae,[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.error),1),t.showRetry?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`ai-preview__retry`,onMousedown:r[1]||=(0,e.withModifiers)(e=>a(`retry`),[`prevent`])},(0,e.toDisplayString)(c.value.retry),33)):(0,e.createCommentVNode)(``,!0)])):((0,e.openBlock)(),(0,e.createElementBlock)(`div`,oe,[t.showDiff?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,se,[(0,e.createElementVNode)(`div`,ce,(0,e.toDisplayString)(c.value.original),1),(0,e.createElementVNode)(`div`,le,(0,e.toDisplayString)(t.originalText),1),(0,e.createElementVNode)(`div`,ue,(0,e.toDisplayString)(c.value.suggested),1),(0,e.createElementVNode)(`div`,de,(0,e.toDisplayString)(t.responseText),1)])):((0,e.openBlock)(),(0,e.createElementBlock)(`div`,N,(0,e.toDisplayString)(t.responseText),1)),t.allowEdit&&o.value?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`textarea`,{key:2,"onUpdate:modelValue":r[2]||=e=>s.value=e,class:`ai-preview__textarea`,rows:`4`},null,512)),[[e.vModelText,s.value]]):(0,e.createCommentVNode)(``,!0)])),!t.isLoading&&!t.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,P,[t.allowEdit&&!o.value?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`ai-preview__btn`,onMousedown:r[3]||=(0,e.withModifiers)(e=>o.value=!0,[`prevent`])},(0,e.toDisplayString)(c.value.edit),33)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`button`,{class:`ai-preview__btn`,onMousedown:r[4]||=(0,e.withModifiers)(e=>a(`reject`),[`prevent`])},(0,e.toDisplayString)(c.value.discard),33),(0,e.createElementVNode)(`button`,{class:`ai-preview__btn ai-preview__btn--primary`,onMousedown:(0,e.withModifiers)(u,[`prevent`])},(0,e.toDisplayString)(c.value.accept),33)])):(0,e.createCommentVNode)(``,!0)],40,ee)):(0,e.createCommentVNode)(``,!0)}}),[[`__scopeId`,`data-v-1226b741`]]),I=[`single`,`words`,`double`,`thick`,`dotted`,`dottedHeavy`,`dash`,`dashedHeavy`,`dashLong`,`dashLongHeavy`,`dotDash`,`dashDotHeavy`,`dotDotDash`,`dashDotDotHeavy`,`wave`,`wavyHeavy`,`wavyDouble`,`none`],L=[`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`red`,`white`,`yellow`,`none`],R=[{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 — 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,t)=>({success:!0,data:t.getContentAsText({fromIndex:e.fromIndex,toIndex:e.toIndex,includeTrackedChanges:!1,includeCommentAnchors:!1})})},{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,t)=>{let n=t.getSelection();return n?{success:!0,data:n}:{success:!1,error:`No selection (editor not focused).`}}},{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,t)=>{let n=t.getPage(e.pageNumber);if(!n){let n=t.getTotalPages();return n===0?{success:!1,error:`No pages rendered (headless mode or empty document).`}:{success:!1,error:`Page ${e.pageNumber} does not exist (document has ${n} page${n===1?``:`s`}).`}}return{success:!0,data:n.text||`(empty page)`}}},{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 — 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,t)=>{let n=t.getPages({from:e.from,to:e.to});if(n.length===0){let n=t.getTotalPages();return n===0?{success:!1,error:`No pages rendered (headless mode or empty document).`}:{success:!1,error:`No pages in range ${e.from}–${e.to} (document has ${n} page${n===1?``:`s`}).`}}return{success:!0,data:n.map(e=>`--- Page ${e.pageNumber} ---\n${e.text||`(empty page)`}`).join(`
|
|
9
|
+
`,document.head.appendChild(e)}let s={flex:1,overflow:`auto`,padding:`16px 14px 8px`,display:`flex`,flexDirection:`column`,gap:`10px`},c={messageGroup:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`},userBubble:{background:`#0b57d0`,color:`#fff`,padding:`10px 14px`,borderRadius:`20px 20px 4px 20px`,fontSize:`13.5px`,lineHeight:1.5,alignSelf:`flex-end`,maxWidth:`88%`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontFamily:`'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif`},assistantBubble:{background:`#f0f4f9`,color:`#1f1f1f`,padding:`12px 16px`,borderRadius:`20px 20px 20px 4px`,fontSize:`13.5px`,lineHeight:1.55,alignSelf:`flex-start`,maxWidth:`92%`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontFamily:`'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif`},thinkingBubble:{background:`#f0f4f9`,padding:`12px 16px`,borderRadius:`20px 20px 20px 4px`,alignSelf:`flex-start`,display:`flex`,gap:`4px`,alignItems:`center`},dot:{width:`6px`,height:`6px`,borderRadius:`50%`,background:`#5f6368`,display:`inline-block`,animation:`epAgentDot 1.4s infinite ease-in-out`},errorBubble:{background:`#fce8e6`,color:`#b3261e`,padding:`10px 14px`,borderRadius:`16px`,fontSize:`12.5px`,alignSelf:`flex-start`,maxWidth:`92%`,whiteSpace:`pre-wrap`,fontFamily:`'Google Sans Text', system-ui, sans-serif`}};return(n,a)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:(0,e.normalizeClass)([`ep-agent-chat-log`,t.className]),style:s,role:`log`,"aria-live":`polite`,"aria-atomic":`false`},[i.value?(0,e.renderSlot)(n.$slots,`empty`,{key:0}):(0,e.createCommentVNode)(``,!0),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.messages,n=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:n.id,style:(0,e.normalizeStyle)(c.messageGroup),"data-role":n.role},[n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0?((0,e.openBlock)(),(0,e.createBlock)(p,{key:0,"tool-calls":n.toolCalls,streaming:n.status===`streaming`,"humanize-name":t.humanizeToolName,"max-visible-calls":t.maxVisibleCalls,"working-label":t.workingLabel,"summary-label":t.summaryLabel,"earlier-label":t.earlierLabel},null,8,[`tool-calls`,`streaming`,`humanize-name`,`max-visible-calls`,`working-label`,`summary-label`,`earlier-label`])):(0,e.createCommentVNode)(``,!0),n.text.length>0?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,style:(0,e.normalizeStyle)(n.role===`user`?c.userBubble:c.assistantBubble)},(0,e.toDisplayString)(n.text),5)):(0,e.createCommentVNode)(``,!0)],12,m))),128)),t.loading?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,style:(0,e.normalizeStyle)(c.thinkingBubble),"aria-label":t.thinkingLabel},[(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0s`})},null,4),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0.15s`})},null,4),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0.3s`})},null,4)],12,h)):(0,e.createCommentVNode)(``,!0),t.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:2,style:(0,e.normalizeStyle)(c.errorBubble),role:`alert`},(0,e.toDisplayString)(t.error),5)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,{ref_key:`endEl`,ref:r},null,512)],2))}}),v=[`value`,`placeholder`,`disabled`],y=[`aria-label`,`disabled`],b=(0,e.defineComponent)({__name:`AgentComposer`,props:{modelValue:{},disabled:{type:Boolean,default:!1},placeholder:{default:()=>n.agentPanel.composerPlaceholder},sendLabel:{default:()=>n.agentPanel.send},className:{default:``}},emits:[`update:modelValue`,`submit`],setup(t,{emit:n}){let r=t,i=n,a=(0,e.computed)(()=>r.modelValue.trim().length>0&&!r.disabled);function o(){a.value&&i(`submit`)}let s=(0,e.computed)(()=>({width:`36px`,height:`36px`,borderRadius:`50%`,border:`none`,background:`#0b57d0`,color:`#fff`,flexShrink:0,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,transition:`background 0.15s, opacity 0.15s, transform 0.15s`,opacity:a.value?1:.35,cursor:a.value?`pointer`:`not-allowed`})),c={composerWrap:{padding:`8px 12px 14px`,background:`#fff`,flex:`0 0 auto`},composerShell:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`6px 6px 6px 18px`,background:`#fff`,border:`1px solid #c4c7c5`,borderRadius:`28px`,boxShadow:`0 1px 2px rgba(60,64,67,0.04)`,transition:`border-color 0.15s, box-shadow 0.15s`,fontFamily:`'Google Sans Text', system-ui, sans-serif`},composerInput:{flex:1,padding:`8px 0`,fontSize:`14px`,border:`none`,outline:`none`,background:`transparent`,fontFamily:`inherit`,color:`#1f1f1f`},footnote:{fontSize:`11px`,color:`#5f6368`,textAlign:`center`,marginTop:`10px`,fontFamily:`'Google Sans Text', system-ui, sans-serif`}};return(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`form`,{class:(0,e.normalizeClass)([`ep-agent-composer`,t.className]),style:(0,e.normalizeStyle)(c.composerWrap),onSubmit:(0,e.withModifiers)(o,[`prevent`])},[(0,e.createElementVNode)(`div`,{style:(0,e.normalizeStyle)(c.composerShell)},[(0,e.createElementVNode)(`input`,{style:(0,e.normalizeStyle)(c.composerInput),value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,onInput:r[0]||=e=>i(`update:modelValue`,e.target.value)},null,44,v),(0,e.createElementVNode)(`button`,{type:`submit`,"aria-label":t.sendLabel,disabled:!a.value,style:(0,e.normalizeStyle)(s.value)},[...r[1]||=[(0,e.createElementVNode)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[(0,e.createElementVNode)(`path`,{d:`M12 19V5M5 12l7-7 7 7`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})],-1)]],12,y)],4),n.$slots.footnote?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,style:(0,e.normalizeStyle)(c.footnote)},[(0,e.renderSlot)(n.$slots,`footnote`)],4)):(0,e.createCommentVNode)(``,!0)],38))}}),x=[`disabled`],S=(0,e.defineComponent)({__name:`AgentSuggestionChip`,props:{label:{},disabled:{type:Boolean}},emits:[`click`],setup(t,{emit:n}){let r=n,i={textAlign:`left`,background:`#fff`,border:`1px solid #dadce0`,borderRadius:`18px`,padding:`10px 14px`,fontSize:`13px`,color:`#1f1f1f`,cursor:`pointer`,fontFamily:`'Google Sans Text', system-ui, sans-serif`,lineHeight:1.4,transition:`background 0.15s, border-color 0.15s, box-shadow 0.15s`,width:`100%`};return(n,a)=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{type:`button`,style:i,disabled:t.disabled,onClick:a[0]||=e=>r(`click`)},(0,e.toDisplayString)(t.label),9,x))}}),C=[`aria-label`],w={class:`ai-ctx-menu__header`,"aria-hidden":`true`},T=[`onMousedown`],E=[`innerHTML`],D={class:`ai-ctx-menu__label`},O={key:0,class:`ai-ctx-menu__custom`},k=[`placeholder`],A=(0,e.defineComponent)({__name:`AIContextMenu`,props:{isOpen:{type:Boolean},position:{},selectedText:{},showCustomPrompt:{type:Boolean,default:!0},labels:{default:()=>({})}},emits:[`close`,`action`],setup(t,{emit:r}){let i=t,a=r,o=(0,e.ref)(``),s=(0,e.ref)([]);(0,e.watch)(()=>i.isOpen,t=>{t&&(0,e.nextTick)(()=>s.value[0]?.focus())},{immediate:!0});let c=[{id:`rewrite`,icon:`✍`},{id:`expand`,icon:`↔`},{id:`summarize`,icon:`📝`},{id:`fixGrammar`,icon:`✔`},{id:`makeFormal`,icon:`👔`},{id:`makeCasual`,icon:`😊`},{id:`translate`,icon:`🌐`},{id:`explain`,icon:`💡`}],l=(0,e.computed)(()=>i.labels?.header??n.aiActions.header),u=(0,e.computed)(()=>i.labels?.customPlaceholder??n.aiActions.customPlaceholder);function d(e){return i.labels?.[e]||(n.aiActions[e]??e)}let f=(0,e.computed)(()=>{let e=i.position.x,t=i.position.y;return typeof window<`u`&&(e+220+10>window.innerWidth&&(e=window.innerWidth-220-10),t+360+10>window.innerHeight&&(t=window.innerHeight-360-10)),{position:`fixed`,left:`${e}px`,top:`${t}px`,zIndex:500}});function p(e){a(`action`,e,e===`custom`?o.value:void 0),o.value=``,a(`close`)}return(n,r)=>((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:`body`},[t.isOpen?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`ai-ctx-backdrop`,onMousedown:r[0]||=e=>a(`close`),onContextmenu:r[1]||=(0,e.withModifiers)(e=>a(`close`),[`prevent`])},null,32)):(0,e.createCommentVNode)(``,!0),t.isOpen?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,class:`ai-ctx-menu`,"aria-label":l.value,style:(0,e.normalizeStyle)(f.value),tabindex:`-1`,onContextmenu:r[4]||=(0,e.withModifiers)(()=>{},[`prevent`]),onKeydown:r[5]||=(0,e.withKeys)((0,e.withModifiers)(e=>a(`close`),[`stop`]),[`esc`])},[(0,e.createElementVNode)(`div`,w,(0,e.toDisplayString)(l.value),1),((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(c,t=>(0,e.createElementVNode)(`button`,{key:t.id,ref_for:!0,ref_key:`itemRefs`,ref:s,class:`ai-ctx-menu__item`,onMousedown:(0,e.withModifiers)(e=>p(t.id),[`prevent`])},[(0,e.createElementVNode)(`span`,{class:`ai-ctx-menu__icon`,innerHTML:t.icon},null,8,E),(0,e.createElementVNode)(`span`,D,(0,e.toDisplayString)(d(t.id)),1)],40,T)),64)),r[6]||=(0,e.createElementVNode)(`div`,{class:`ai-ctx-menu__divider`},null,-1),t.showCustomPrompt?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,O,[(0,e.withDirectives)((0,e.createElementVNode)(`input`,{"onUpdate:modelValue":r[2]||=e=>o.value=e,class:`ai-ctx-menu__input`,placeholder:u.value,onKeydown:r[3]||=(0,e.withKeys)((0,e.withModifiers)(e=>p(`custom`),[`prevent`]),[`enter`])},null,40,k),[[e.vModelText,o.value]])])):(0,e.createCommentVNode)(``,!0)],44,C)):(0,e.createCommentVNode)(``,!0)]))}}),j=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},M=j(A,[[`__scopeId`,`data-v-c30da7a7`]]),ee=[`aria-label`],te={class:`ai-preview__header`},ne={class:`ai-preview__title`},re=[`aria-label`],ie={key:0,class:`ai-preview__loading`},ae={key:1,class:`ai-preview__error`},oe={key:2,class:`ai-preview__content`},se={key:0,class:`ai-preview__diff`},ce={class:`ai-preview__diff-label`},le={class:`ai-preview__diff-text ai-preview__diff-text--old`},ue={class:`ai-preview__diff-label`},de={class:`ai-preview__diff-text ai-preview__diff-text--new`},fe={key:1,class:`ai-preview__result`},pe={key:3,class:`ai-preview__footer`},me=j((0,e.defineComponent)({__name:`AIResponsePreview`,props:{isVisible:{type:Boolean},originalText:{},responseText:{},action:{},isLoading:{type:Boolean},error:{default:void 0},allowEdit:{type:Boolean,default:!0},showDiff:{type:Boolean,default:!0},showRetry:{type:Boolean,default:!0},labels:{default:()=>({})}},emits:[`accept`,`reject`,`retry`],setup(t,{emit:r}){let i=t,a=r,o=(0,e.ref)(!1),s=(0,e.ref)(``),c=(0,e.computed)(()=>({loading:i.labels?.loading??n.aiPreview.loading,original:i.labels?.original??n.aiPreview.original,suggested:i.labels?.suggested??n.aiPreview.suggested,edit:i.labels?.edit??n.aiPreview.edit,discard:i.labels?.discard??n.aiPreview.discard,accept:i.labels?.accept??n.aiPreview.accept,retry:i.labels?.retry??n.aiPreview.retry,close:i.labels?.close??n.aiPreview.close})),l=(0,e.computed)(()=>i.labels?.actionTitles?.[i.action]||(n.aiPreview.labels[i.action]??n.aiPreview.defaultTitle));(0,e.watch)(()=>i.responseText,e=>{s.value=e,o.value=!1});function u(){a(`accept`,o.value?s.value:i.responseText)}return(n,r)=>t.isVisible?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`ai-preview`,role:`region`,"aria-label":l.value,tabindex:`-1`,onKeydown:r[5]||=(0,e.withKeys)((0,e.withModifiers)(e=>a(`reject`),[`stop`]),[`esc`])},[(0,e.createElementVNode)(`div`,te,[(0,e.createElementVNode)(`span`,ne,(0,e.toDisplayString)(l.value),1),(0,e.createElementVNode)(`button`,{class:`ai-preview__close`,"aria-label":c.value.close,onClick:r[0]||=e=>a(`reject`)},` ✕ `,8,re)]),t.isLoading?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ie,[r[6]||=(0,e.createElementVNode)(`span`,{class:`ai-preview__spinner`},null,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(c.value.loading),1)])):t.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ae,[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.error),1),t.showRetry?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`ai-preview__retry`,onMousedown:r[1]||=(0,e.withModifiers)(e=>a(`retry`),[`prevent`])},(0,e.toDisplayString)(c.value.retry),33)):(0,e.createCommentVNode)(``,!0)])):((0,e.openBlock)(),(0,e.createElementBlock)(`div`,oe,[t.showDiff?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,se,[(0,e.createElementVNode)(`div`,ce,(0,e.toDisplayString)(c.value.original),1),(0,e.createElementVNode)(`div`,le,(0,e.toDisplayString)(t.originalText),1),(0,e.createElementVNode)(`div`,ue,(0,e.toDisplayString)(c.value.suggested),1),(0,e.createElementVNode)(`div`,de,(0,e.toDisplayString)(t.responseText),1)])):((0,e.openBlock)(),(0,e.createElementBlock)(`div`,fe,(0,e.toDisplayString)(t.responseText),1)),t.allowEdit&&o.value?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`textarea`,{key:2,"onUpdate:modelValue":r[2]||=e=>s.value=e,class:`ai-preview__textarea`,rows:`4`},null,512)),[[e.vModelText,s.value]]):(0,e.createCommentVNode)(``,!0)])),!t.isLoading&&!t.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,pe,[t.allowEdit&&!o.value?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`ai-preview__btn`,onMousedown:r[3]||=(0,e.withModifiers)(e=>o.value=!0,[`prevent`])},(0,e.toDisplayString)(c.value.edit),33)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`button`,{class:`ai-preview__btn`,onMousedown:r[4]||=(0,e.withModifiers)(e=>a(`reject`),[`prevent`])},(0,e.toDisplayString)(c.value.discard),33),(0,e.createElementVNode)(`button`,{class:`ai-preview__btn ai-preview__btn--primary`,onMousedown:(0,e.withModifiers)(u,[`prevent`])},(0,e.toDisplayString)(c.value.accept),33)])):(0,e.createCommentVNode)(``,!0)],40,ee)):(0,e.createCommentVNode)(``,!0)}}),[[`__scopeId`,`data-v-1226b741`]]),N=[`single`,`words`,`double`,`thick`,`dotted`,`dottedHeavy`,`dash`,`dashedHeavy`,`dashLong`,`dashLongHeavy`,`dotDash`,`dashDotHeavy`,`dotDotDash`,`dashDotDotHeavy`,`wave`,`wavyHeavy`,`wavyDouble`,`none`],P=[`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`red`,`white`,`yellow`,`none`],F=[{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 — 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,t)=>({success:!0,data:t.getContentAsText({fromIndex:e.fromIndex,toIndex:e.toIndex,includeTrackedChanges:!1,includeCommentAnchors:!1})})},{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,t)=>{let n=t.getSelection();return n?{success:!0,data:n}:{success:!1,error:`No selection (editor not focused).`}}},{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,t)=>{let n=t.getPage(e.pageNumber);if(!n){let n=t.getTotalPages();return n===0?{success:!1,error:`No pages rendered (headless mode or empty document).`}:{success:!1,error:`Page ${e.pageNumber} does not exist (document has ${n} page${n===1?``:`s`}).`}}return{success:!0,data:n.text||`(empty page)`}}},{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 — 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,t)=>{let n=t.getPages({from:e.from,to:e.to});if(n.length===0){let n=t.getTotalPages();return n===0?{success:!1,error:`No pages rendered (headless mode or empty document).`}:{success:!1,error:`No pages in range ${e.from}–${e.to} (document has ${n} page${n===1?``:`s`}).`}}return{success:!0,data:n.map(e=>`--- Page ${e.pageNumber} ---\n${e.text||`(empty page)`}`).join(`
|
|
10
10
|
|
|
11
11
|
`)}}},{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,t)=>{let n=t.findText(e.query,{caseSensitive:e.caseSensitive,limit:e.limit});return n.length===0?{success:!0,data:`No matches.`}:{success:!0,data:n}}},{name:`read_comments`,displayName:`Reading comments`,description:`List all comments in the document with their paragraph anchors.`,inputSchema:{type:`object`,properties:{}},handler:(e,t)=>{let n=t.getComments();return n.length===0?{success:!0,data:`No comments.`}:{success:!0,data:n.map(e=>`[Comment #${e.id}] ${e.author}: "${e.text}"`+(e.anchoredText?` (anchored to: "${e.anchoredText}")`:``)+(e.replies.length>0?`
|
|
12
12
|
`+e.replies.map(e=>` Reply by ${e.author}: "${e.text}"`).join(`
|
|
13
13
|
`):``)).join(`
|
|
14
14
|
`)}}},{name:`read_changes`,displayName:`Reading changes`,description:`List tracked changes (insertions / deletions) currently in the document.`,inputSchema:{type:`object`,properties:{}},handler:(e,t)=>{let n=t.getChanges();return n.length===0?{success:!0,data:`No tracked changes.`}:{success:!0,data:n.map(e=>`[Change #${e.id}] ${e.type} by ${e.author}: "${e.text}"`).join(`
|
|
15
|
-
`)}}},{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,t)=>{let n=t.addComment({paraId:e.paraId,text:e.text,search:e.search});return n===null?{success:!1,error:"Could not add comment. The paraId may not exist, or `search` is missing / ambiguous."}:{success:!0,data:`Comment ${n} added on ${e.paraId}.`}}},{name:`suggest_change`,displayName:`Suggesting change`,description:"Suggest a tracked change. Three modes: (1) replacement — `search` non-empty, `replaceWith` non-empty; (2) deletion — `search` non-empty, `replaceWith` empty; (3) insertion at paragraph end — `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,t)=>t.proposeChange({paraId:e.paraId,search:e.search,replaceWith:e.replaceWith})?e.search?e.replaceWith?{success:!0,data:`Replacement proposed: "${e.search}" → "${e.replaceWith}" on ${e.paraId}.`}:{success:!0,data:`Deletion proposed: "${e.search}" on ${e.paraId}.`}:{success:!0,data:`Insertion proposed on ${e.paraId}.`}:{success:!1,error:`Could not propose change. Possible causes: paraId not found; search missing or ambiguous; or the target overlaps an existing tracked change.`}},{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 — 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 → single underline; false → 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:[...
|
|
16
|
-
`)),o.push(a)}i.push(e),a.push(o)}return{type:`table`,index:t,rows:i,cellParaIds:a}}function
|
|
15
|
+
`)}}},{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,t)=>{let n=t.addComment({paraId:e.paraId,text:e.text,search:e.search});return n===null?{success:!1,error:"Could not add comment. The paraId may not exist, or `search` is missing / ambiguous."}:{success:!0,data:`Comment ${n} added on ${e.paraId}.`}}},{name:`suggest_change`,displayName:`Suggesting change`,description:"Suggest a tracked change. Three modes: (1) replacement — `search` non-empty, `replaceWith` non-empty; (2) deletion — `search` non-empty, `replaceWith` empty; (3) insertion at paragraph end — `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,t)=>t.proposeChange({paraId:e.paraId,search:e.search,replaceWith:e.replaceWith})?e.search?e.replaceWith?{success:!0,data:`Replacement proposed: "${e.search}" → "${e.replaceWith}" on ${e.paraId}.`}:{success:!0,data:`Deletion proposed: "${e.search}" on ${e.paraId}.`}:{success:!0,data:`Insertion proposed on ${e.paraId}.`}:{success:!1,error:`Could not propose change. Possible causes: paraId not found; search missing or ambiguous; or the target overlaps an existing tracked change.`}},{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 — 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 → single underline; false → 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:[...P],description:`Highlight color — must be one of the Word-supported names: `+P.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,t)=>{if(!e.marks||Object.keys(e.marks).length===0)return{success:!1,error:`No marks provided. Specify at least one of bold/italic/etc.`};let n=typeof e.marks.underline==`object`&&e.marks.underline!==null?e.marks.underline.style:void 0;if(n&&!N.includes(n))return{success:!1,error:`Invalid underline.style "${n}". Must be one of: ${N.join(`, `)}.`};let r=typeof e.marks.highlight==`string`?e.marks.highlight:void 0;if(r&&!P.includes(r))return{success:!1,error:`Invalid highlight "${r}". Must be one of: ${P.join(`, `)}. Hex values are not supported by Word's highlight attribute.`};let i=r===`none`?{...e.marks,highlight:``}:e.marks;return t.applyFormatting({paraId:e.paraId,search:e.search,marks:i})?{success:!0,data:`Formatting applied to ${e.search?`"${e.search}" in ${e.paraId}`:e.paraId}.`}:{success:!1,error:"Could not apply formatting. The paraId may not exist, or `search` is missing / ambiguous."}}},{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 — 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,t)=>t.setParagraphStyle({paraId:e.paraId,styleId:e.styleId})?{success:!0,data:`Style "${e.styleId}" applied to ${e.paraId}.`}:{success:!1,error:`Could not set style. paraId "${e.paraId}" not found, or styleId "${e.styleId}" is not defined.`}},{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,t)=>{let n=t.replyTo(e.commentId,{text:e.text});return n===null?{success:!1,error:`Comment #${e.commentId} not found.`}:{success:!0,data:`Reply ${n} 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,t)=>(t.resolveComment(e.commentId),{success:!0,data:`Comment ${e.commentId} resolved.`})},{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,t)=>t.scrollTo(e.paraId)?{success:!0,data:`Scrolled to ${e.paraId}.`}:{success:!1,error:`paraId ${e.paraId} not found.`}}];function I(e,t,n){let r=F.find(t=>t.name===e);if(!r)return{success:!1,error:`Unknown tool: ${e}`};try{return r.handler(t,n)}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}function L(e){let t=F.find(t=>t.name===e);if(t?.displayName)return t.displayName;let n=e.replace(/_/g,` `);return n.charAt(0).toUpperCase()+n.slice(1)}function R(){return F.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.inputSchema}}))}function z(e){return e.type===`insertion`||e.type===`deletion`||e.type===`moveFrom`||e.type===`moveTo`}function B(e){let n=[];for(let r of e)r.type===`run`?n.push((0,t.getRunText)(r)):r.type===`hyperlink`&&n.push((0,t.getHyperlinkText)(r));return n.join(``)}function V(e,t,n){let r=0;for(let i of e)if(i.type===`paragraph`){if(n(i,r)===!1)return;r++}else if(i.type===`table`){for(let e of i.rows)for(let t of e.cells)for(let e of t.content)if(e.type===`paragraph`){if(n(e,r)===!1)return;r++}}else t&&r++}function H(e,t){V(e.content,!0,t)}function U(e,t){V(e.content,!1,t)}function W(e,t={}){let{fromIndex:n,toIndex:r,includeTrackedChanges:i=!0,includeCommentAnchors:a=!0}=t,o=[],s=0;for(let t of e.content)if(t.type===`paragraph`)G(s,n,r)&&o.push(he(t,s,i,a)),s++;else if(t.type===`table`){G(s,n,r)&&o.push(ge(t,s,i,a));for(let e of t.rows)for(let t of e.cells)for(let e of t.content)e.type===`paragraph`&&s++}else s++;return o}function G(e,t,n){return(t===void 0||e>=t)&&(n===void 0||e<=n)}function he(e,n,r,i){let a=K(e,r,i),o=e.formatting?.styleId,s=e.paraId;return(0,t.isHeadingStyle)(o)?{type:`heading`,index:n,paraId:s,level:(0,t.parseHeadingLevel)(o)??1,text:a}:e.listRendering?{type:`list-item`,index:n,paraId:s,text:a,listLevel:e.listRendering.level??0,listType:e.listRendering.isBullet?`bullet`:`number`}:{type:`paragraph`,index:n,paraId:s,text:a}}function ge(e,t,n,r){let i=[],a=[];for(let t of e.rows){let e=[],o=[];for(let i of t.cells){let t=[],a;for(let e of i.content)e.type===`paragraph`&&(a===void 0&&(a=e.paraId),t.push(K(e,n,r)));e.push(t.join(`
|
|
16
|
+
`)),o.push(a)}i.push(e),a.push(o)}return{type:`table`,index:t,rows:i,cellParaIds:a}}function _e(e){let t=[],n=e=>e.paraId?e.paraId:String(e.index);for(let r of e)switch(r.type){case`heading`:t.push(`[${n(r)}] (h${r.level}) ${r.text}`);break;case`paragraph`:t.push(`[${n(r)}] ${r.text}`);break;case`list-item`:{let e=` `.repeat(r.listLevel),i=r.listType===`bullet`?`•`:`-`;t.push(`[${n(r)}] ${e}${i} ${r.text}`);break}case`table`:{let e=r.index;for(let n=0;n<r.rows.length;n++)for(let i=0;i<r.rows[n].length;i++){let a=r.rows[n][i].split(`
|
|
17
17
|
`),o=r.cellParaIds?.[n]?.[i];for(let r=0;r<a.length;r++){let s=r===0&&o?o:String(e);t.push(`[${s}] (table, row ${n+1}, col ${i+1}) ${a[r]}`),e++}}break}}return t.join(`
|
|
18
|
-
`)}function
|
|
19
|
-
`)}function
|
|
20
|
-
`)}function $(e){let t=e.getEditorRef();if(t){let e=t.getDocument();if(e?.package?.document)return e.package.document}return e.getDocument()?.package?.document??null}function
|
|
18
|
+
`)}function K(e,n,r){let i=[],a=new Set;for(let o of e.content){if(o.type===`commentRangeStart`&&r){a.add(o.id),i.push(`[comment:${o.id}]`);continue}if(o.type===`commentRangeEnd`&&r){a.has(o.id)&&(a.delete(o.id),i.push(`[/comment]`));continue}if(o.type===`run`)i.push((0,t.getRunText)(o));else if(o.type===`hyperlink`)i.push((0,t.getHyperlinkText)(o));else if(z(o)){let e=B(o.content);o.type===`insertion`||o.type===`moveTo`?n&&i.push(`[+${e}+]{by:${o.info.author}}`):n?i.push(`[-${e}-]{by:${o.info.author}}`):i.push(e)}}return i.join(``)}function ve(e){let n=[],r=0;for(let i=0;i<e.content.length;i++){let a=e.content[i];if(a.type===`run`){let e=(0,t.getRunText)(a);n.push({contentIndex:i,run:a,text:e,startPos:r}),r+=e.length}else if(a.type===`hyperlink`)for(let e=0;e<a.children.length;e++){let o=a.children[e];if(o.type===`run`){let e=(0,t.getRunText)(o);n.push({contentIndex:i,run:o,text:e,startPos:r}),r+=e.length}}else if(z(a)){if(a.type===`insertion`||a.type===`moveTo`)continue;for(let e=0;e<a.content.length;e++){let o=a.content[e];if(o.type===`run`){let e=(0,t.getRunText)(o);n.push({contentIndex:i,run:o,text:e,startPos:r}),r+=e.length}else if(o.type===`hyperlink`){for(let e of o.children)if(e.type===`run`){let a=(0,t.getRunText)(e);n.push({contentIndex:i,run:e,text:a,startPos:r}),r+=a.length}}}}}return n}function q(e){return ve(e).map(e=>e.text).join(``)}function J(e,t,n){let r=new Map,i=(e,t,n)=>{let i=null;for(let a of e.content)if(z(a)){i===null&&(i=q(e));let o=B(a.content),s=a.info.id,c=`${n.noteType??`body`}:${n.noteId??``}:${s}`,l=r.get(c);l&&l.paragraphIndex===t?l.text+=o:r.set(c,{id:s,type:a.type,author:a.info.author,date:a.info.date??null,text:o,context:i,paragraphIndex:t,...n.noteId===void 0?{}:{noteId:n.noteId},...n.noteType===void 0?{}:{noteType:n.noteType}})}};if(H(e,(e,t)=>i(e,t,{})),t?.includeFootnotes&&n?.footnotes)for(let e of n.footnotes)U(e,(t,n)=>i(t,n,{noteId:e.id,noteType:`footnote`}));if(t?.includeEndnotes&&n?.endnotes)for(let e of n.endnotes)U(e,(t,n)=>i(t,n,{noteId:e.id,noteType:`endnote`}));return Array.from(r.values()).filter(e=>!(t?.author&&e.author!==t.author||t?.type&&e.type!==t.type))}function Y(e,t){let n=e.comments??[];if(n.length===0)return[];let r=Z(e),i=[],a=new Map;for(let e of n)if(e.parentId!==void 0){let t=a.get(e.parentId)??[];t.push(e),a.set(e.parentId,t)}else i.push(e);return i.map(e=>{let t=r.get(e.id),n=(a.get(e.id)??[]).map(e=>({id:e.id,author:e.author,date:e.date??null,text:X(e)}));return{id:e.id,author:e.author,date:e.date??null,text:X(e),anchoredText:t?.text??``,paragraphIndex:t?.paragraphIndex??-1,replies:n,done:e.done??!1}}).filter(e=>!(t?.author&&e.author!==t.author||t?.done!==void 0&&e.done!==t.done))}function X(e){return e.content.map(e=>q(e)).join(`
|
|
19
|
+
`)}function Z(e){let n=new Map,r=new Map;return H(e,(e,i)=>{for(let a of e.content)if(a.type===`commentRangeStart`)r.set(a.id,{paragraphIndex:i,parts:[]});else if(a.type===`commentRangeEnd`){let e=r.get(a.id);e&&(n.set(a.id,{text:e.parts.join(``),paragraphIndex:e.paragraphIndex}),r.delete(a.id))}else if(a.type===`run`){let e=(0,t.getRunText)(a);for(let t of r.values())t.parts.push(e)}else if(a.type===`hyperlink`){let e=a.children.filter(e=>e.type===`run`).map(t.getRunText).join(``);for(let t of r.values())t.parts.push(e)}else if(z(a)){if(a.type===`insertion`||a.type===`moveTo`)continue;let e=B(a.content);for(let t of r.values())t.parts.push(e)}}),n}function Q(e){return!e||e.length===0?``:e.map(e=>{let t=e;return t?.content?t.content.map(e=>e.content?.map(e=>e.text||``).join(``)||``).join(``):``}).join(`
|
|
20
|
+
`)}function $(e){let t=e.getEditorRef();if(t){let e=t.getDocument();if(e?.package?.document)return e.package.document}return e.getDocument()?.package?.document??null}function ye(e,t=`AI`){function n(e){return e??t}return{getContentAsText(t){let n=$(e);return n?_e(W(n,t)):``},getContent(t){let n=$(e);return n?W(n,t):[]},getComments(t){let n=$(e);if(!n)return[];let r=Y(n,t);if(r.length>0)return r;let i=e.getComments();if(i.length===0)return[];let a=new Map,o=[];for(let e of i)if(e.parentId){let t=a.get(e.parentId);t?t.push(e):a.set(e.parentId,[e])}else o.push(e);let s=[];for(let e of o){if(t?.author&&e.author!==t.author||t?.done!==void 0&&(e.done??!1)!==t.done)continue;let n=a.get(e.id)??[];s.push({id:e.id,author:e.author,date:e.date??null,text:Q(e.content),anchoredText:``,paragraphIndex:-1,replies:n.map(e=>({id:e.id,author:e.author,date:e.date??null,text:Q(e.content)})),done:e.done??!1})}return s},getChanges(t){let n=$(e);return n?J(n,t):[]},findText(t,n){return e.findInDocument(t,n)},getSelection(){return e.getSelectionInfo()},addComment(t){return e.addComment({paraId:t.paraId,text:t.text,author:n(t.author),search:t.search})},replyTo(t,r){return e.replyToComment(t,r.text,n(r.author))},resolveComment(t){e.resolveComment(t)},proposeChange(t){return e.proposeChange({paraId:t.paraId,search:t.search,replaceWith:t.replaceWith,author:n(t.author)})},applyFormatting(t){return e.applyFormatting({paraId:t.paraId,search:t.search,marks:t.marks})},setParagraphStyle(t){return e.setParagraphStyle({paraId:t.paraId,styleId:t.styleId})},getPage(t){return e.getPageContent(t)},getPages(t){let n=e.getTotalPages(),r=Math.max(1,Math.min(t.from,n)),i=Math.max(r,Math.min(t.to,n)),a=[];for(let t=r;t<=i;t++){let n=e.getPageContent(t);n&&a.push(n)}return a},getTotalPages(){return e.getTotalPages()},getCurrentPage(){return e.getCurrentPage()},scrollTo(t){return e.scrollToParaId(t)},onContentChange(t){return e.onContentChange(()=>{let n=$(e),r=n?Y(n):[],i=n?J(n):[];try{t({commentCount:r.length,changeCount:i.length,comments:r,changes:i})}catch(e){console.error(`onContentChange listener threw:`,e)}})},onSelectionChange(t){return e.onSelectionChange(()=>{try{t(e.getSelectionInfo())}catch(e){console.error(`onSelectionChange listener threw:`,e)}})}}}var be=R();function xe(t){let{editorRef:n,author:r=`AI`}=t,i=(0,e.computed)(()=>n.value?ye(n.value,(0,e.unref)(r)):null);function a(e,t){let n=i.value;return n?I(e,t,n):{success:!1,error:`Editor not ready`}}return{executeToolCall:a,toolSchemas:be}}exports.AIContextMenu=M,exports.AIResponsePreview=me,exports.AgentChatLog=_,exports.AgentComposer=b,exports.AgentPanel=s,exports.AgentSuggestionChip=S,exports.AgentTimeline=p,exports.getToolDisplayName=L,exports.useAgentBridge=xe;
|
package/dist/vue.mjs
CHANGED
|
@@ -1586,34 +1586,40 @@ function G(e) {
|
|
|
1586
1586
|
for (let n of e) n.type === "run" ? t.push(E(n)) : n.type === "hyperlink" && t.push(T(n));
|
|
1587
1587
|
return t.join("");
|
|
1588
1588
|
}
|
|
1589
|
-
function K(e, t) {
|
|
1590
|
-
let
|
|
1591
|
-
for (let
|
|
1592
|
-
if (
|
|
1593
|
-
|
|
1594
|
-
} else if (
|
|
1595
|
-
for (let e of
|
|
1596
|
-
if (
|
|
1597
|
-
|
|
1589
|
+
function K(e, t, n) {
|
|
1590
|
+
let r = 0;
|
|
1591
|
+
for (let i of e) if (i.type === "paragraph") {
|
|
1592
|
+
if (n(i, r) === !1) return;
|
|
1593
|
+
r++;
|
|
1594
|
+
} else if (i.type === "table") {
|
|
1595
|
+
for (let e of i.rows) for (let t of e.cells) for (let e of t.content) if (e.type === "paragraph") {
|
|
1596
|
+
if (n(e, r) === !1) return;
|
|
1597
|
+
r++;
|
|
1598
1598
|
}
|
|
1599
|
-
} else
|
|
1599
|
+
} else t && r++;
|
|
1600
|
+
}
|
|
1601
|
+
function q(e, t) {
|
|
1602
|
+
K(e.content, !0, t);
|
|
1603
|
+
}
|
|
1604
|
+
function J(e, t) {
|
|
1605
|
+
K(e.content, !1, t);
|
|
1600
1606
|
}
|
|
1601
1607
|
//#endregion
|
|
1602
1608
|
//#region src/content.ts
|
|
1603
|
-
function
|
|
1609
|
+
function Y(e, t = {}) {
|
|
1604
1610
|
let { fromIndex: n, toIndex: r, includeTrackedChanges: i = !0, includeCommentAnchors: a = !0 } = t, o = [], s = 0;
|
|
1605
|
-
for (let t of e.content) if (t.type === "paragraph")
|
|
1611
|
+
for (let t of e.content) if (t.type === "paragraph") X(s, n, r) && o.push(Le(t, s, i, a)), s++;
|
|
1606
1612
|
else if (t.type === "table") {
|
|
1607
|
-
|
|
1613
|
+
X(s, n, r) && o.push(Re(t, s, i, a));
|
|
1608
1614
|
for (let e of t.rows) for (let t of e.cells) for (let e of t.content) e.type === "paragraph" && s++;
|
|
1609
1615
|
} else s++;
|
|
1610
1616
|
return o;
|
|
1611
1617
|
}
|
|
1612
|
-
function
|
|
1618
|
+
function X(e, t, n) {
|
|
1613
1619
|
return (t === void 0 || e >= t) && (n === void 0 || e <= n);
|
|
1614
1620
|
}
|
|
1615
1621
|
function Le(e, t, n, r) {
|
|
1616
|
-
let i =
|
|
1622
|
+
let i = Z(e, n, r), a = e.formatting?.styleId, o = e.paraId;
|
|
1617
1623
|
return D(a) ? {
|
|
1618
1624
|
type: "heading",
|
|
1619
1625
|
index: t,
|
|
@@ -1640,7 +1646,7 @@ function Re(e, t, n, r) {
|
|
|
1640
1646
|
let e = [], o = [];
|
|
1641
1647
|
for (let i of t.cells) {
|
|
1642
1648
|
let t = [], a;
|
|
1643
|
-
for (let e of i.content) e.type === "paragraph" && (a === void 0 && (a = e.paraId), t.push(
|
|
1649
|
+
for (let e of i.content) e.type === "paragraph" && (a === void 0 && (a = e.paraId), t.push(Z(e, n, r)));
|
|
1644
1650
|
e.push(t.join("\n")), o.push(a);
|
|
1645
1651
|
}
|
|
1646
1652
|
i.push(e), a.push(o);
|
|
@@ -1680,7 +1686,7 @@ function ze(e) {
|
|
|
1680
1686
|
}
|
|
1681
1687
|
return t.join("\n");
|
|
1682
1688
|
}
|
|
1683
|
-
function
|
|
1689
|
+
function Z(e, t, n) {
|
|
1684
1690
|
let r = [], i = /* @__PURE__ */ new Set();
|
|
1685
1691
|
for (let a of e.content) {
|
|
1686
1692
|
if (a.type === "commentRangeStart" && n) {
|
|
@@ -1754,34 +1760,44 @@ function Be(e) {
|
|
|
1754
1760
|
}
|
|
1755
1761
|
return t;
|
|
1756
1762
|
}
|
|
1757
|
-
function
|
|
1763
|
+
function Q(e) {
|
|
1758
1764
|
return Be(e).map((e) => e.text).join("");
|
|
1759
1765
|
}
|
|
1760
1766
|
//#endregion
|
|
1761
1767
|
//#region src/discovery.ts
|
|
1762
|
-
function
|
|
1763
|
-
let
|
|
1764
|
-
|
|
1765
|
-
let
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1768
|
+
function Ve(e, t, n) {
|
|
1769
|
+
let r = /* @__PURE__ */ new Map(), i = (e, t, n) => {
|
|
1770
|
+
let i = null;
|
|
1771
|
+
for (let a of e.content) if (W(a)) {
|
|
1772
|
+
i === null && (i = Q(e));
|
|
1773
|
+
let o = G(a.content), s = a.info.id, c = `${n.noteType ?? "body"}:${n.noteId ?? ""}:${s}`, l = r.get(c);
|
|
1774
|
+
l && l.paragraphIndex === t ? l.text += o : r.set(c, {
|
|
1775
|
+
id: s,
|
|
1776
|
+
type: a.type,
|
|
1777
|
+
author: a.info.author,
|
|
1778
|
+
date: a.info.date ?? null,
|
|
1779
|
+
text: o,
|
|
1780
|
+
context: i,
|
|
1781
|
+
paragraphIndex: t,
|
|
1782
|
+
...n.noteId === void 0 ? {} : { noteId: n.noteId },
|
|
1783
|
+
...n.noteType === void 0 ? {} : { noteType: n.noteType }
|
|
1777
1784
|
});
|
|
1778
1785
|
}
|
|
1779
|
-
}
|
|
1786
|
+
};
|
|
1787
|
+
if (q(e, (e, t) => i(e, t, {})), t?.includeFootnotes && n?.footnotes) for (let e of n.footnotes) J(e, (t, n) => i(t, n, {
|
|
1788
|
+
noteId: e.id,
|
|
1789
|
+
noteType: "footnote"
|
|
1790
|
+
}));
|
|
1791
|
+
if (t?.includeEndnotes && n?.endnotes) for (let e of n.endnotes) J(e, (t, n) => i(t, n, {
|
|
1792
|
+
noteId: e.id,
|
|
1793
|
+
noteType: "endnote"
|
|
1794
|
+
}));
|
|
1795
|
+
return Array.from(r.values()).filter((e) => !(t?.author && e.author !== t.author || t?.type && e.type !== t.type));
|
|
1780
1796
|
}
|
|
1781
|
-
function
|
|
1797
|
+
function He(e, t) {
|
|
1782
1798
|
let n = e.comments ?? [];
|
|
1783
1799
|
if (n.length === 0) return [];
|
|
1784
|
-
let r =
|
|
1800
|
+
let r = We(e), i = [], a = /* @__PURE__ */ new Map();
|
|
1785
1801
|
for (let e of n) if (e.parentId !== void 0) {
|
|
1786
1802
|
let t = a.get(e.parentId) ?? [];
|
|
1787
1803
|
t.push(e), a.set(e.parentId, t);
|
|
@@ -1791,13 +1807,13 @@ function Q(e, t) {
|
|
|
1791
1807
|
id: e.id,
|
|
1792
1808
|
author: e.author,
|
|
1793
1809
|
date: e.date ?? null,
|
|
1794
|
-
text:
|
|
1810
|
+
text: Ue(e)
|
|
1795
1811
|
}));
|
|
1796
1812
|
return {
|
|
1797
1813
|
id: e.id,
|
|
1798
1814
|
author: e.author,
|
|
1799
1815
|
date: e.date ?? null,
|
|
1800
|
-
text:
|
|
1816
|
+
text: Ue(e),
|
|
1801
1817
|
anchoredText: t?.text ?? "",
|
|
1802
1818
|
paragraphIndex: t?.paragraphIndex ?? -1,
|
|
1803
1819
|
replies: n,
|
|
@@ -1805,12 +1821,12 @@ function Q(e, t) {
|
|
|
1805
1821
|
};
|
|
1806
1822
|
}).filter((e) => !(t?.author && e.author !== t.author || t?.done !== void 0 && e.done !== t.done));
|
|
1807
1823
|
}
|
|
1808
|
-
function
|
|
1809
|
-
return e.content.map((e) =>
|
|
1824
|
+
function Ue(e) {
|
|
1825
|
+
return e.content.map((e) => Q(e)).join("\n");
|
|
1810
1826
|
}
|
|
1811
|
-
function
|
|
1827
|
+
function We(e) {
|
|
1812
1828
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
1813
|
-
return
|
|
1829
|
+
return q(e, (e, r) => {
|
|
1814
1830
|
for (let i of e.content) if (i.type === "commentRangeStart") n.set(i.id, {
|
|
1815
1831
|
paragraphIndex: r,
|
|
1816
1832
|
parts: []
|
|
@@ -1836,7 +1852,7 @@ function He(e) {
|
|
|
1836
1852
|
}
|
|
1837
1853
|
//#endregion
|
|
1838
1854
|
//#region src/bridge.ts
|
|
1839
|
-
function
|
|
1855
|
+
function Ge(e) {
|
|
1840
1856
|
return !e || e.length === 0 ? "" : e.map((e) => {
|
|
1841
1857
|
let t = e;
|
|
1842
1858
|
return t?.content ? t.content.map((e) => e.content?.map((e) => e.text || "").join("") || "").join("") : "";
|
|
@@ -1850,23 +1866,23 @@ function $(e) {
|
|
|
1850
1866
|
}
|
|
1851
1867
|
return e.getDocument()?.package?.document ?? null;
|
|
1852
1868
|
}
|
|
1853
|
-
function
|
|
1869
|
+
function Ke(e, t = "AI") {
|
|
1854
1870
|
function n(e) {
|
|
1855
1871
|
return e ?? t;
|
|
1856
1872
|
}
|
|
1857
1873
|
return {
|
|
1858
1874
|
getContentAsText(t) {
|
|
1859
1875
|
let n = $(e);
|
|
1860
|
-
return n ? ze(
|
|
1876
|
+
return n ? ze(Y(n, t)) : "";
|
|
1861
1877
|
},
|
|
1862
1878
|
getContent(t) {
|
|
1863
1879
|
let n = $(e);
|
|
1864
|
-
return n ?
|
|
1880
|
+
return n ? Y(n, t) : [];
|
|
1865
1881
|
},
|
|
1866
1882
|
getComments(t) {
|
|
1867
1883
|
let n = $(e);
|
|
1868
1884
|
if (!n) return [];
|
|
1869
|
-
let r =
|
|
1885
|
+
let r = He(n, t);
|
|
1870
1886
|
if (r.length > 0) return r;
|
|
1871
1887
|
let i = e.getComments();
|
|
1872
1888
|
if (i.length === 0) return [];
|
|
@@ -1883,14 +1899,14 @@ function We(e, t = "AI") {
|
|
|
1883
1899
|
id: e.id,
|
|
1884
1900
|
author: e.author,
|
|
1885
1901
|
date: e.date ?? null,
|
|
1886
|
-
text:
|
|
1902
|
+
text: Ge(e.content),
|
|
1887
1903
|
anchoredText: "",
|
|
1888
1904
|
paragraphIndex: -1,
|
|
1889
1905
|
replies: n.map((e) => ({
|
|
1890
1906
|
id: e.id,
|
|
1891
1907
|
author: e.author,
|
|
1892
1908
|
date: e.date ?? null,
|
|
1893
|
-
text:
|
|
1909
|
+
text: Ge(e.content)
|
|
1894
1910
|
})),
|
|
1895
1911
|
done: e.done ?? !1
|
|
1896
1912
|
});
|
|
@@ -1899,7 +1915,7 @@ function We(e, t = "AI") {
|
|
|
1899
1915
|
},
|
|
1900
1916
|
getChanges(t) {
|
|
1901
1917
|
let n = $(e);
|
|
1902
|
-
return n ?
|
|
1918
|
+
return n ? Ve(n, t) : [];
|
|
1903
1919
|
},
|
|
1904
1920
|
findText(t, n) {
|
|
1905
1921
|
return e.findInDocument(t, n);
|
|
@@ -1964,7 +1980,7 @@ function We(e, t = "AI") {
|
|
|
1964
1980
|
},
|
|
1965
1981
|
onContentChange(t) {
|
|
1966
1982
|
return e.onContentChange(() => {
|
|
1967
|
-
let n = $(e), r = n ?
|
|
1983
|
+
let n = $(e), r = n ? He(n) : [], i = n ? Ve(n) : [];
|
|
1968
1984
|
try {
|
|
1969
1985
|
t({
|
|
1970
1986
|
commentCount: r.length,
|
|
@@ -1990,9 +2006,9 @@ function We(e, t = "AI") {
|
|
|
1990
2006
|
}
|
|
1991
2007
|
//#endregion
|
|
1992
2008
|
//#region src/vue/composables/useAgentBridge.ts
|
|
1993
|
-
var
|
|
1994
|
-
function
|
|
1995
|
-
let { editorRef: t, author: r = "AI" } = e, i = n(() => t.value ?
|
|
2009
|
+
var qe = Ie();
|
|
2010
|
+
function Je(e) {
|
|
2011
|
+
let { editorRef: t, author: r = "AI" } = e, i = n(() => t.value ? Ke(t.value, y(r)) : null);
|
|
1996
2012
|
function a(e, t) {
|
|
1997
2013
|
let n = i.value;
|
|
1998
2014
|
return n ? Pe(e, t, n) : {
|
|
@@ -2002,8 +2018,8 @@ function Ke(e) {
|
|
|
2002
2018
|
}
|
|
2003
2019
|
return {
|
|
2004
2020
|
executeToolCall: a,
|
|
2005
|
-
toolSchemas:
|
|
2021
|
+
toolSchemas: qe
|
|
2006
2022
|
};
|
|
2007
2023
|
}
|
|
2008
2024
|
//#endregion
|
|
2009
|
-
export { ve as AIContextMenu, Ne as AIResponsePreview, ie as AgentChatLog, se as AgentComposer, M as AgentPanel, le as AgentSuggestionChip, R as AgentTimeline, Fe as getToolDisplayName,
|
|
2025
|
+
export { ve as AIContextMenu, Ne as AIResponsePreview, ie as AgentChatLog, se as AgentComposer, M as AgentPanel, le as AgentSuggestionChip, R as AgentTimeline, Fe as getToolDisplayName, Je as useAgentBridge };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eigenpal/docx-editor-agents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Agent SDK and chat UI for the DOCX editor — framework-agnostic bridge, MCP server, AI SDK adapters, plus React UI (and Vue UI in 1.x)",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css"
|
package/dist/chunk-6KT5LOQB.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {d,e,k as k$1,l,b,i,h,c,j,g as g$1,a}from'./chunk-MK47WH2X.mjs';import {w as w$1}from'./chunk-L7LXQOTH.mjs';function g(o,e){let{paragraphIndex:t,author:n="AI",text:s,search:a}=e,r=b(o,t),i$1=(o.comments??[]).map(m=>m.id),p=i$1.length>0?Math.max(...i$1)+1:1,c={id:p,author:n,date:new Date().toISOString(),content:[{type:"paragraph",content:[{type:"run",content:[{type:"text",text:s}]}],formatting:{}}]};if(o.comments||(o.comments=[]),o.comments.push(c),a){let m=i(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 y(o,e,t){let n=o.comments??[];if(!n.find(p=>p.id===e))throw new h(e);let a=n.map(p=>p.id),r=Math.max(...a)+1,i={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 n.push(i),r}function E(o,e){let t=o.comments??[],n=t.find(r=>r.id===e);if(!n)throw new h(e);let s=n.parentId!==void 0,a=new Set([e]);if(!s)for(let r of t)r.parentId===e&&a.add(r.id);o.comments=t.filter(r=>!a.has(r.id)),!s&&c(o,r=>{for(let i=r.content.length-1;i>=0;i--){let p=r.content[i];(p.type==="commentRangeStart"||p.type==="commentRangeEnd")&&p.id===e&&r.content.splice(i,1);}});}function C(o,e){if(!W(o,e,"accept"))throw new g$1(e)}function I(o,e){if(!W(o,e,"reject"))throw new g$1(e)}function k(o){return M(o,"accept")}function F(o){return M(o,"reject")}function M(o,e){let t=0;return c(o,n=>{for(let s=n.content.length-1;s>=0;s--){let a$1=n.content[s];a(a$1)&&(G(n,s,a$1,e),t++);}}),t}function W(o,e,t){let n=false;return c(o,s=>{for(let a$1=s.content.length-1;a$1>=0;a$1--){let r=s.content[a$1];a(r)&&r.info.id===e&&(G(s,a$1,r,t),n=true);}if(n)return false}),n}function G(o,e,t,n){if(t.type==="insertion"&&n==="accept"||t.type==="deletion"&&n==="reject"||t.type==="moveTo"&&n==="accept"||t.type==="moveFrom"&&n==="reject"){let a=t.content;o.content.splice(e,1,...a);}else o.content.splice(e,1);}function x(o,e){let{paragraphIndex:t,search:n,author:s="AI",replaceWith:a}=e,r=b(o,t),{startIndex:i,endIndex:p}=j(r,n,t),c=new Date().toISOString(),m=w(o),h=r.content.slice(i,p+1),R={type:"deletion",info:{id:m,author:s,date:c},content:h},v={type:"insertion",info:{id:m+1,author:s,date:c},content:[{type:"run",content:[{type:"text",text:a}]}]};r.content.splice(i,p-i+1,R,v);}function H(o,e){let{paragraphIndex:t,author:n="AI",insertText:s,position:a="after",search:r}=e,i=b(o,t),p=new Date().toISOString(),m={type:"insertion",info:{id:w(o),author:n,date:p},content:[{type:"run",content:[{type:"text",text:s}]}]};if(r){let{startIndex:h,endIndex:R}=j(i,r,t),v=a==="after"?R+1:h;i.content.splice(v,0,m);}else a==="before"?i.content.unshift(m):i.content.push(m);}function L(o,e){let{paragraphIndex:t,search:n,author:s="AI"}=e,a=b(o,t),{startIndex:r,endIndex:i}=j(a,n,t),p=new Date().toISOString(),c=w(o),m=a.content.slice(r,i+1),h={type:"deletion",info:{id:c,author:s,date:p},content:m};a.content.splice(r,i-r+1,h);}var S=new WeakMap;function w(o){let e=S.get(o);e===void 0&&(e=0,c(o,n=>{for(let s of n.content)a(s)&&(e=Math.max(e,s.info.id));}));let t=e+1;return S.set(o,t+1),t}function N(o,e,t="AI"){let n=[],s=0,a=0,r=0,i=0,p=0;for(let c of e.accept??[])try{C(o,c),s++;}catch(m){n.push({operation:"accept",id:c,error:m.message});}for(let c of e.reject??[])try{I(o,c),a++;}catch(m){n.push({operation:"reject",id:c,error:m.message});}for(let c of e.comments??[])try{g(o,{...c,author:c.author??t}),r++;}catch(m){n.push({operation:"comment",search:c.search,error:m.message});}for(let c of e.replies??[])try{y(o,c.commentId,{author:c.author??t,text:c.text}),i++;}catch(m){n.push({operation:"reply",id:c.commentId,error:m.message});}for(let c of e.proposals??[])try{x(o,{...c,author:c.author??t}),p++;}catch(m){n.push({operation:"proposal",search:c.search,error:m.message});}return {accepted:s,rejected:a,commentsAdded:r,repliesAdded:i,proposalsAdded:p,errors:n}}var U=class o{constructor(e,t="AI",n){let s=n??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 n=await w$1(e,{preloadFonts:false});return new o(n,t,e)}get body(){return this.doc.package.document}resolveAuthor(e){return e??this.author}getContent(e){return d(this.body,e)}getContentAsText(e$1){return e(d(this.body,e$1))}getChanges(e){return k$1(this.body,e)}getComments(e){return l(this.body,e)}addComment(e,t){let n=typeof e=="number"?{paragraphIndex:e,text:t,author:this.author}:{...e,author:this.resolveAuthor(e.author)};return g(this.body,n)}replyTo(e,t){let n=typeof t=="string"?{text:t,author:this.author}:{...t,author:this.resolveAuthor(t.author)};return y(this.body,e,n)}removeComment(e){E(this.body,e);}replace(e,t,n){let s=typeof e=="number"?{paragraphIndex:e,search:t,replaceWith:n,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){C(this.body,e);}rejectChange(e){I(this.body,e);}acceptAll(){return k(this.body)}rejectAll(){return F(this.body)}applyReview(e){return N(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-6C4JSKYY.mjs');return e(this.doc)}};export{U as a};
|