@kafca/agentdock 0.1.40 → 0.1.42
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 +9 -0
- package/dist/renderer/assets/{Badge-CmP99fZV.js → Badge-D-WU4kUV.js} +1 -1
- package/dist/renderer/assets/{Chat-BHxpB0Vz.js → Chat-BGkC5tAe.js} +1 -1
- package/dist/renderer/assets/{ChatMarkdown-Cnhe-XvR.js → ChatMarkdown-CfbC1jRd.js} +1 -1
- package/dist/renderer/assets/{Config-CreR5RZX.js → Config-qQb4bX5D.js} +1 -1
- package/dist/renderer/assets/{CronList-OHg6JWsr.js → CronList-CKhggzYk.js} +1 -1
- package/dist/renderer/assets/{Dashboard-C083Q4zC.js → Dashboard-xn6cUy_n.js} +2 -2
- package/dist/renderer/assets/{EmptyState-Br-H8kqG.js → EmptyState-BdKBBUpr.js} +1 -1
- package/dist/renderer/assets/{KnowledgeDetail-DKhVUY4_.js → KnowledgeDetail-Duk8IQP3.js} +1 -1
- package/dist/renderer/assets/{KnowledgeHome-BM3TMxhj.js → KnowledgeHome-BfjX_4Sv.js} +1 -1
- package/dist/renderer/assets/{Logs-debYolKz.js → Logs-Bfq61QMn.js} +1 -1
- package/dist/renderer/assets/{Modal-BIetew5T.js → Modal-B3vlBmBr.js} +1 -1
- package/dist/renderer/assets/{Page-183Y5-ef.js → Page-CPsLOP3z.js} +1 -1
- package/dist/renderer/assets/{ProjectDetail-CB6-zRBY.js → ProjectDetail-D-g46wyF.js} +1 -1
- package/dist/renderer/assets/{ProjectList-BEUflZUB.js → ProjectList-BrQEKDQ8.js} +1 -1
- package/dist/renderer/assets/{Select-CNIQBVMx.js → Select-C4CFMQmF.js} +1 -1
- package/dist/renderer/assets/{SessionChat-CLpfIftJ.js → SessionChat-06Jny5_G.js} +1 -1
- package/dist/renderer/assets/{SessionList-BUwfQcGl.js → SessionList-DPWIUbOg.js} +1 -1
- package/dist/renderer/assets/{ThreadChat-B9EcRcki.js → ThreadChat-BjtU-j9q.js} +1 -1
- package/dist/renderer/assets/{Workspace-D82il8Vz.js → Workspace-BcNmHuJx.js} +1 -1
- package/dist/renderer/assets/{arrow-left-T9D9J6Ln.js → arrow-left-DPzSmidS.js} +1 -1
- package/dist/renderer/assets/{book-open-Bfdr9s70.js → book-open-B0xhoRqZ.js} +1 -1
- package/dist/renderer/assets/{check-CPJsC_C4.js → check-BTJTyd0C.js} +1 -1
- package/dist/renderer/assets/{chevron-down-BDoIQdna.js → chevron-down-B6jJXlhi.js} +1 -1
- package/dist/renderer/assets/{circle-CRGTgPlR.js → circle-qRhJR9qR.js} +1 -1
- package/dist/renderer/assets/{desktop-DJ_OjjxL.js → desktop-DXmXjjUR.js} +1 -1
- package/dist/renderer/assets/{funnel-BISvzz6U.js → funnel-CbYKGTn8.js} +1 -1
- package/dist/renderer/assets/{heart-EllaLuEV.js → heart-DjwWJfkz.js} +1 -1
- package/dist/renderer/assets/{index-YUnN4zTb.js → index-BWmHJRhe.js} +2 -2
- package/dist/renderer/assets/{index-Db87Dhd_.js → index-CyZs_2NJ.js} +1 -1
- package/dist/renderer/assets/{pencil-w4F5pFB6.js → pencil-1dfAivmj.js} +1 -1
- package/dist/renderer/assets/{play-CNY6DepD.js → play-CB3w1G6S.js} +1 -1
- package/dist/renderer/assets/{plug-DnMzECJy.js → plug-Bvep5o3r.js} +1 -1
- package/dist/renderer/assets/{plus-D33HMCG5.js → plus-DJVg9m09.js} +1 -1
- package/dist/renderer/assets/projects-xnW0fTtq.js +1 -0
- package/dist/renderer/assets/{save-B0PXgtN_.js → save-xjJn3qf2.js} +1 -1
- package/dist/renderer/assets/{search-zNtpxpxG.js → search-BK3UrQxM.js} +1 -1
- package/dist/renderer/assets/{server-DIsU-ww0.js → server-Dyd2eXJu.js} +1 -1
- package/dist/renderer/assets/{session-utils-CxQ3KCei.js → session-utils-eXC0020s.js} +1 -1
- package/dist/renderer/assets/{sessions-DFDVZGz-.js → sessions-WLYpkyUt.js} +1 -1
- package/dist/renderer/assets/{shield-check-5hrgmi9Y.js → shield-check-C0N6aWzF.js} +1 -1
- package/dist/renderer/assets/{trash-2-DWftp5eL.js → trash-2-BGMTNJA6.js} +1 -1
- package/dist/renderer/assets/{user-CKjiW1bV.js → user-BcGMLyhu.js} +1 -1
- package/dist/renderer/assets/{wifi-off-DyBtTbdO.js → wifi-off-FhcQx0HK.js} +1 -1
- package/dist/renderer/index.html +1 -1
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-backend.js +27 -39
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-progress.js +25 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-session-coordinator.js +13 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-store.js +7 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-turn-coordinator.js +31 -8
- package/dist-electron/services/local-ai-core/src/acp/local-core-slash-commands.js +28 -0
- package/dist-electron/services/local-ai-core/src/channel/lark/local-core-lark-gateway.js +21 -11
- package/dist-electron/services/local-ai-core/src/channel/lark/post.js +7 -16
- package/dist-electron/services/local-ai-core/src/channel/lark/rendering/markdown.js +94 -0
- package/dist-electron/services/local-ai-core/src/channel/lark/rendering/messages.js +51 -0
- package/dist-electron/services/local-ai-core/src/channel/lark/runtime-state.js +14 -0
- package/dist-electron/services/local-ai-core/src/router/workspace-router.js +40 -4
- package/dist-electron/services/local-ai-core/src/thread/thread-command-service.js +134 -0
- package/dist-electron/tests/electron/plugin-kernel.test.js +26 -0
- package/dist-electron/tests/integration/lark-rendering.test.js +123 -0
- package/dist-electron/tests/integration/local-core-refactor.test.js +335 -4
- package/package.json +1 -1
- package/dist/renderer/assets/projects-DcYpVq_W.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{G as Te,aK as Ae,r as c,j as x,aL as pe,aM as Ne,aA as te}from"./index-YUnN4zTb.js";var ye=Ae();const De=Te(ye);function X(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Jt(e,t){const n=c.createContext(t),r=i=>{const{children:s,...a}=i,h=c.useMemo(()=>a,Object.values(a));return x.jsx(n.Provider,{value:h,children:s})};r.displayName=e+"Provider";function o(i){const s=c.useContext(n);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function en(e,t=[]){let n=[];function r(i,s){const a=c.createContext(s),h=n.length;n=[...n,s];const l=d=>{var p;const{scope:v,children:y,...w}=d,u=((p=v==null?void 0:v[e])==null?void 0:p[h])||a,m=c.useMemo(()=>w,Object.values(w));return x.jsx(u.Provider,{value:m,children:y})};l.displayName=i+"Provider";function f(d,v){var u;const y=((u=v==null?void 0:v[e])==null?void 0:u[h])||a,w=c.useContext(y);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[l,f]}const o=()=>{const i=n.map(s=>c.createContext(s));return function(a){const h=(a==null?void 0:a[e])||i;return c.useMemo(()=>({[`__scope${e}`]:{...a,[e]:h}}),[a,h])}};return o.scopeName=e,[r,ke(o,...t)]}function ke(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:h,scopeName:l})=>{const d=h(i)[`__scope${l}`];return{...a,...d}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}var ne=globalThis!=null&&globalThis.document?c.useLayoutEffect:()=>{},Me=pe[" useId ".trim().toString()]||(()=>{}),Fe=0;function tn(e){const[t,n]=c.useState(Me());return ne(()=>{n(r=>r??String(Fe++))},[e]),e||(t?`radix-${t}`:"")}var Ie=pe[" useInsertionEffect ".trim().toString()]||ne;function nn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,s]=We({defaultProp:t,onChange:n}),a=e!==void 0,h=a?e:o;{const f=c.useRef(e!==void 0);c.useEffect(()=>{const d=f.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,r])}const l=c.useCallback(f=>{var d;if(a){const v=Be(f)?f(e):f;v!==e&&((d=s.current)==null||d.call(s,v))}else i(f)},[a,e,i,s]);return[h,l]}function We({defaultProp:e,onChange:t}){const[n,r]=c.useState(e),o=c.useRef(n),i=c.useRef(t);return Ie(()=>{i.current=t},[t]),c.useEffect(()=>{var s;o.current!==n&&((s=i.current)==null||s.call(i,n),o.current=n)},[n,o]),[n,r,i]}function Be(e){return typeof e=="function"}function _e(e){const t=je(e),n=c.forwardRef((r,o)=>{const{children:i,...s}=r,a=c.Children.toArray(i),h=a.find($e);if(h){const l=h.props.children,f=a.map(d=>d===h?c.Children.count(l)>1?c.Children.only(null):c.isValidElement(l)?l.props.children:null:d);return x.jsx(t,{...s,ref:o,children:c.isValidElement(l)?c.cloneElement(l,void 0,f):null})}return x.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function je(e){const t=c.forwardRef((n,r)=>{const{children:o,...i}=n;if(c.isValidElement(o)){const s=Ke(o),a=Ve(i,o.props);return o.type!==c.Fragment&&(a.ref=r?Ne(r,s):s),c.cloneElement(o,a)}return c.Children.count(o)>1?c.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ue=Symbol("radix.slottable");function $e(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ue}function Ve(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const h=i(...a);return o(...a),h}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Ke(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],V=Xe.reduce((e,t)=>{const n=_e(`Primitive.${t}`),r=c.forwardRef((o,i)=>{const{asChild:s,...a}=o,h=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),x.jsx(h,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ye(e,t){e&&ye.flushSync(()=>e.dispatchEvent(t))}function F(e){const t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function He(e,t=globalThis==null?void 0:globalThis.document){const n=F(e);c.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var ze="DismissableLayer",J="dismissableLayer.update",Ge="dismissableLayer.pointerDownOutside",Ze="dismissableLayer.focusOutside",oe,Ee=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),qe=c.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...h}=e,l=c.useContext(Ee),[f,d]=c.useState(null),v=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=c.useState({}),w=te(t,E=>d(E)),u=Array.from(l.layers),[m]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),p=u.indexOf(m),g=f?u.indexOf(f):-1,b=l.layersWithOutsidePointerEventsDisabled.size>0,S=g>=p,C=et(E=>{const L=E.target,T=[...l.branches].some(M=>M.contains(L));!S||T||(o==null||o(E),s==null||s(E),E.defaultPrevented||a==null||a())},v),P=tt(E=>{const L=E.target;[...l.branches].some(M=>M.contains(L))||(i==null||i(E),s==null||s(E),E.defaultPrevented||a==null||a())},v);return He(E=>{g===l.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},v),c.useEffect(()=>{if(f)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(oe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(f)),l.layers.add(f),ae(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=oe)}},[f,v,n,l]),c.useEffect(()=>()=>{f&&(l.layers.delete(f),l.layersWithOutsidePointerEventsDisabled.delete(f),ae())},[f,l]),c.useEffect(()=>{const E=()=>y({});return document.addEventListener(J,E),()=>document.removeEventListener(J,E)},[]),x.jsx(V.div,{...h,ref:w,style:{pointerEvents:b?S?"auto":"none":void 0,...e.style},onFocusCapture:X(e.onFocusCapture,P.onFocusCapture),onBlurCapture:X(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:X(e.onPointerDownCapture,C.onPointerDownCapture)})});qe.displayName=ze;var Qe="DismissableLayerBranch",Je=c.forwardRef((e,t)=>{const n=c.useContext(Ee),r=c.useRef(null),o=te(t,r);return c.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),x.jsx(V.div,{...e,ref:o})});Je.displayName=Qe;function et(e,t=globalThis==null?void 0:globalThis.document){const n=F(e),r=c.useRef(!1),o=c.useRef(()=>{});return c.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let h=function(){ge(Ge,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=h,t.addEventListener("click",o.current,{once:!0})):h()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function tt(e,t=globalThis==null?void 0:globalThis.document){const n=F(e),r=c.useRef(!1);return c.useEffect(()=>{const o=i=>{i.target&&!r.current&&ge(Ze,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ae(){const e=new CustomEvent(J);document.dispatchEvent(e)}function ge(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ye(o,i):o.dispatchEvent(i)}var Y="focusScope.autoFocusOnMount",H="focusScope.autoFocusOnUnmount",ce={bubbles:!1,cancelable:!0},nt="FocusScope",rt=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,h]=c.useState(null),l=F(o),f=F(i),d=c.useRef(null),v=te(t,u=>h(u)),y=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let u=function(b){if(y.paused||!a)return;const S=b.target;a.contains(S)?d.current=S:O(d.current,{select:!0})},m=function(b){if(y.paused||!a)return;const S=b.relatedTarget;S!==null&&(a.contains(S)||O(d.current,{select:!0}))},p=function(b){if(document.activeElement===document.body)for(const C of b)C.removedNodes.length>0&&O(a)};document.addEventListener("focusin",u),document.addEventListener("focusout",m);const g=new MutationObserver(p);return a&&g.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",u),document.removeEventListener("focusout",m),g.disconnect()}}},[r,a,y.paused]),c.useEffect(()=>{if(a){se.add(y);const u=document.activeElement;if(!a.contains(u)){const p=new CustomEvent(Y,ce);a.addEventListener(Y,l),a.dispatchEvent(p),p.defaultPrevented||(ot(ut(be(a)),{select:!0}),document.activeElement===u&&O(a))}return()=>{a.removeEventListener(Y,l),setTimeout(()=>{const p=new CustomEvent(H,ce);a.addEventListener(H,f),a.dispatchEvent(p),p.defaultPrevented||O(u??document.body,{select:!0}),a.removeEventListener(H,f),se.remove(y)},0)}}},[a,l,f,y]);const w=c.useCallback(u=>{if(!n&&!r||y.paused)return;const m=u.key==="Tab"&&!u.altKey&&!u.ctrlKey&&!u.metaKey,p=document.activeElement;if(m&&p){const g=u.currentTarget,[b,S]=at(g);b&&S?!u.shiftKey&&p===S?(u.preventDefault(),n&&O(b,{select:!0})):u.shiftKey&&p===b&&(u.preventDefault(),n&&O(S,{select:!0})):p===g&&u.preventDefault()}},[n,r,y.paused]);return x.jsx(V.div,{tabIndex:-1,...s,ref:v,onKeyDown:w})});rt.displayName=nt;function ot(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(O(r,{select:t}),document.activeElement!==n)return}function at(e){const t=be(e),n=ie(t,e),r=ie(t.reverse(),e);return[n,r]}function be(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ie(e,t){for(const n of e)if(!ct(n,{upTo:t}))return n}function ct(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function it(e){return e instanceof HTMLInputElement&&"select"in e}function O(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&it(e)&&t&&e.select()}}var se=st();function st(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ue(e,t),e.unshift(t)},remove(t){var n;e=ue(e,t),(n=e[0])==null||n.resume()}}}function ue(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ut(e){return e.filter(t=>t.tagName!=="A")}var lt="Portal",ft=c.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=c.useState(!1);ne(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?De.createPortal(x.jsx(V.div,{...r,ref:t}),s):null});ft.displayName=lt;var z=0;function rn(){c.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??le()),document.body.insertAdjacentElement("beforeend",e[1]??le()),z++,()=>{z===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),z--}},[])}function le(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var R=function(){return R=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},R.apply(this,arguments)};function Se(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function dt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var U="right-scroll-bar-position",$="width-before-scroll-bar",vt="with-scroll-bars-hidden",ht="--removed-body-scroll-bar-size";function G(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mt(e,t){var n=c.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var pt=typeof window<"u"?c.useLayoutEffect:c.useEffect,fe=new WeakMap;function yt(e,t){var n=mt(null,function(r){return e.forEach(function(o){return G(o,r)})});return pt(function(){var r=fe.get(n);if(r){var o=new Set(r),i=new Set(e),s=n.current;o.forEach(function(a){i.has(a)||G(a,null)}),i.forEach(function(a){o.has(a)||G(a,s)})}fe.set(n,e)},[e]),n}function Et(e){return e}function gt(e,t){t===void 0&&(t=Et);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var s=t(i,r);return n.push(s),function(){n=n.filter(function(a){return a!==s})}},assignSyncMedium:function(i){for(r=!0;n.length;){var s=n;n=[],s.forEach(i)}n={push:function(a){return i(a)},filter:function(){return n}}},assignMedium:function(i){r=!0;var s=[];if(n.length){var a=n;n=[],a.forEach(i),s=n}var h=function(){var f=s;s=[],f.forEach(i)},l=function(){return Promise.resolve().then(h)};l(),n={push:function(f){s.push(f),l()},filter:function(f){return s=s.filter(f),n}}}};return o}function bt(e){e===void 0&&(e={});var t=gt(null);return t.options=R({async:!0,ssr:!1},e),t}var we=function(e){var t=e.sideCar,n=Se(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return c.createElement(r,R({},n))};we.isSideCarExport=!0;function St(e,t){return e.useMedium(t),we}var Ce=bt(),Z=function(){},K=c.forwardRef(function(e,t){var n=c.useRef(null),r=c.useState({onScrollCapture:Z,onWheelCapture:Z,onTouchMoveCapture:Z}),o=r[0],i=r[1],s=e.forwardProps,a=e.children,h=e.className,l=e.removeScrollBar,f=e.enabled,d=e.shards,v=e.sideCar,y=e.noRelative,w=e.noIsolation,u=e.inert,m=e.allowPinchZoom,p=e.as,g=p===void 0?"div":p,b=e.gapMode,S=Se(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=v,P=yt([n,t]),E=R(R({},S),o);return c.createElement(c.Fragment,null,f&&c.createElement(C,{sideCar:Ce,removeScrollBar:l,shards:d,noRelative:y,noIsolation:w,inert:u,setCallbacks:i,allowPinchZoom:!!m,lockRef:n,gapMode:b}),s?c.cloneElement(c.Children.only(a),R(R({},E),{ref:P})):c.createElement(g,R({},E,{className:h,ref:P}),a))});K.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};K.classNames={fullWidth:$,zeroRight:U};var wt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ct(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=wt();return t&&e.setAttribute("nonce",t),e}function Pt(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Rt(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var xt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ct())&&(Pt(t,n),Rt(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ot=function(){var e=xt();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Pe=function(){var e=Ot(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Lt={left:0,top:0,right:0,gap:0},q=function(e){return parseInt(e||"",10)||0},Tt=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[q(n),q(r),q(o)]},At=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Lt;var t=Tt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Nt=Pe(),k="data-scroll-locked",Dt=function(e,t,n,r){var o=e.left,i=e.top,s=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
1
|
+
import{G as Te,aK as Ae,r as c,j as x,aL as pe,aM as Ne,aA as te}from"./index-BWmHJRhe.js";var ye=Ae();const De=Te(ye);function X(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Jt(e,t){const n=c.createContext(t),r=i=>{const{children:s,...a}=i,h=c.useMemo(()=>a,Object.values(a));return x.jsx(n.Provider,{value:h,children:s})};r.displayName=e+"Provider";function o(i){const s=c.useContext(n);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function en(e,t=[]){let n=[];function r(i,s){const a=c.createContext(s),h=n.length;n=[...n,s];const l=d=>{var p;const{scope:v,children:y,...w}=d,u=((p=v==null?void 0:v[e])==null?void 0:p[h])||a,m=c.useMemo(()=>w,Object.values(w));return x.jsx(u.Provider,{value:m,children:y})};l.displayName=i+"Provider";function f(d,v){var u;const y=((u=v==null?void 0:v[e])==null?void 0:u[h])||a,w=c.useContext(y);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[l,f]}const o=()=>{const i=n.map(s=>c.createContext(s));return function(a){const h=(a==null?void 0:a[e])||i;return c.useMemo(()=>({[`__scope${e}`]:{...a,[e]:h}}),[a,h])}};return o.scopeName=e,[r,ke(o,...t)]}function ke(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:h,scopeName:l})=>{const d=h(i)[`__scope${l}`];return{...a,...d}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}var ne=globalThis!=null&&globalThis.document?c.useLayoutEffect:()=>{},Me=pe[" useId ".trim().toString()]||(()=>{}),Fe=0;function tn(e){const[t,n]=c.useState(Me());return ne(()=>{n(r=>r??String(Fe++))},[e]),e||(t?`radix-${t}`:"")}var Ie=pe[" useInsertionEffect ".trim().toString()]||ne;function nn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,s]=We({defaultProp:t,onChange:n}),a=e!==void 0,h=a?e:o;{const f=c.useRef(e!==void 0);c.useEffect(()=>{const d=f.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,r])}const l=c.useCallback(f=>{var d;if(a){const v=Be(f)?f(e):f;v!==e&&((d=s.current)==null||d.call(s,v))}else i(f)},[a,e,i,s]);return[h,l]}function We({defaultProp:e,onChange:t}){const[n,r]=c.useState(e),o=c.useRef(n),i=c.useRef(t);return Ie(()=>{i.current=t},[t]),c.useEffect(()=>{var s;o.current!==n&&((s=i.current)==null||s.call(i,n),o.current=n)},[n,o]),[n,r,i]}function Be(e){return typeof e=="function"}function _e(e){const t=je(e),n=c.forwardRef((r,o)=>{const{children:i,...s}=r,a=c.Children.toArray(i),h=a.find($e);if(h){const l=h.props.children,f=a.map(d=>d===h?c.Children.count(l)>1?c.Children.only(null):c.isValidElement(l)?l.props.children:null:d);return x.jsx(t,{...s,ref:o,children:c.isValidElement(l)?c.cloneElement(l,void 0,f):null})}return x.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function je(e){const t=c.forwardRef((n,r)=>{const{children:o,...i}=n;if(c.isValidElement(o)){const s=Ke(o),a=Ve(i,o.props);return o.type!==c.Fragment&&(a.ref=r?Ne(r,s):s),c.cloneElement(o,a)}return c.Children.count(o)>1?c.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ue=Symbol("radix.slottable");function $e(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ue}function Ve(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const h=i(...a);return o(...a),h}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Ke(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],V=Xe.reduce((e,t)=>{const n=_e(`Primitive.${t}`),r=c.forwardRef((o,i)=>{const{asChild:s,...a}=o,h=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),x.jsx(h,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ye(e,t){e&&ye.flushSync(()=>e.dispatchEvent(t))}function F(e){const t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function He(e,t=globalThis==null?void 0:globalThis.document){const n=F(e);c.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var ze="DismissableLayer",J="dismissableLayer.update",Ge="dismissableLayer.pointerDownOutside",Ze="dismissableLayer.focusOutside",oe,Ee=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),qe=c.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...h}=e,l=c.useContext(Ee),[f,d]=c.useState(null),v=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=c.useState({}),w=te(t,E=>d(E)),u=Array.from(l.layers),[m]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),p=u.indexOf(m),g=f?u.indexOf(f):-1,b=l.layersWithOutsidePointerEventsDisabled.size>0,S=g>=p,C=et(E=>{const L=E.target,T=[...l.branches].some(M=>M.contains(L));!S||T||(o==null||o(E),s==null||s(E),E.defaultPrevented||a==null||a())},v),P=tt(E=>{const L=E.target;[...l.branches].some(M=>M.contains(L))||(i==null||i(E),s==null||s(E),E.defaultPrevented||a==null||a())},v);return He(E=>{g===l.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},v),c.useEffect(()=>{if(f)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(oe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(f)),l.layers.add(f),ae(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=oe)}},[f,v,n,l]),c.useEffect(()=>()=>{f&&(l.layers.delete(f),l.layersWithOutsidePointerEventsDisabled.delete(f),ae())},[f,l]),c.useEffect(()=>{const E=()=>y({});return document.addEventListener(J,E),()=>document.removeEventListener(J,E)},[]),x.jsx(V.div,{...h,ref:w,style:{pointerEvents:b?S?"auto":"none":void 0,...e.style},onFocusCapture:X(e.onFocusCapture,P.onFocusCapture),onBlurCapture:X(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:X(e.onPointerDownCapture,C.onPointerDownCapture)})});qe.displayName=ze;var Qe="DismissableLayerBranch",Je=c.forwardRef((e,t)=>{const n=c.useContext(Ee),r=c.useRef(null),o=te(t,r);return c.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),x.jsx(V.div,{...e,ref:o})});Je.displayName=Qe;function et(e,t=globalThis==null?void 0:globalThis.document){const n=F(e),r=c.useRef(!1),o=c.useRef(()=>{});return c.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let h=function(){ge(Ge,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=h,t.addEventListener("click",o.current,{once:!0})):h()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function tt(e,t=globalThis==null?void 0:globalThis.document){const n=F(e),r=c.useRef(!1);return c.useEffect(()=>{const o=i=>{i.target&&!r.current&&ge(Ze,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ae(){const e=new CustomEvent(J);document.dispatchEvent(e)}function ge(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ye(o,i):o.dispatchEvent(i)}var Y="focusScope.autoFocusOnMount",H="focusScope.autoFocusOnUnmount",ce={bubbles:!1,cancelable:!0},nt="FocusScope",rt=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,h]=c.useState(null),l=F(o),f=F(i),d=c.useRef(null),v=te(t,u=>h(u)),y=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let u=function(b){if(y.paused||!a)return;const S=b.target;a.contains(S)?d.current=S:O(d.current,{select:!0})},m=function(b){if(y.paused||!a)return;const S=b.relatedTarget;S!==null&&(a.contains(S)||O(d.current,{select:!0}))},p=function(b){if(document.activeElement===document.body)for(const C of b)C.removedNodes.length>0&&O(a)};document.addEventListener("focusin",u),document.addEventListener("focusout",m);const g=new MutationObserver(p);return a&&g.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",u),document.removeEventListener("focusout",m),g.disconnect()}}},[r,a,y.paused]),c.useEffect(()=>{if(a){se.add(y);const u=document.activeElement;if(!a.contains(u)){const p=new CustomEvent(Y,ce);a.addEventListener(Y,l),a.dispatchEvent(p),p.defaultPrevented||(ot(ut(be(a)),{select:!0}),document.activeElement===u&&O(a))}return()=>{a.removeEventListener(Y,l),setTimeout(()=>{const p=new CustomEvent(H,ce);a.addEventListener(H,f),a.dispatchEvent(p),p.defaultPrevented||O(u??document.body,{select:!0}),a.removeEventListener(H,f),se.remove(y)},0)}}},[a,l,f,y]);const w=c.useCallback(u=>{if(!n&&!r||y.paused)return;const m=u.key==="Tab"&&!u.altKey&&!u.ctrlKey&&!u.metaKey,p=document.activeElement;if(m&&p){const g=u.currentTarget,[b,S]=at(g);b&&S?!u.shiftKey&&p===S?(u.preventDefault(),n&&O(b,{select:!0})):u.shiftKey&&p===b&&(u.preventDefault(),n&&O(S,{select:!0})):p===g&&u.preventDefault()}},[n,r,y.paused]);return x.jsx(V.div,{tabIndex:-1,...s,ref:v,onKeyDown:w})});rt.displayName=nt;function ot(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(O(r,{select:t}),document.activeElement!==n)return}function at(e){const t=be(e),n=ie(t,e),r=ie(t.reverse(),e);return[n,r]}function be(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ie(e,t){for(const n of e)if(!ct(n,{upTo:t}))return n}function ct(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function it(e){return e instanceof HTMLInputElement&&"select"in e}function O(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&it(e)&&t&&e.select()}}var se=st();function st(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ue(e,t),e.unshift(t)},remove(t){var n;e=ue(e,t),(n=e[0])==null||n.resume()}}}function ue(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ut(e){return e.filter(t=>t.tagName!=="A")}var lt="Portal",ft=c.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=c.useState(!1);ne(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?De.createPortal(x.jsx(V.div,{...r,ref:t}),s):null});ft.displayName=lt;var z=0;function rn(){c.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??le()),document.body.insertAdjacentElement("beforeend",e[1]??le()),z++,()=>{z===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),z--}},[])}function le(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var R=function(){return R=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},R.apply(this,arguments)};function Se(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function dt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var U="right-scroll-bar-position",$="width-before-scroll-bar",vt="with-scroll-bars-hidden",ht="--removed-body-scroll-bar-size";function G(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mt(e,t){var n=c.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var pt=typeof window<"u"?c.useLayoutEffect:c.useEffect,fe=new WeakMap;function yt(e,t){var n=mt(null,function(r){return e.forEach(function(o){return G(o,r)})});return pt(function(){var r=fe.get(n);if(r){var o=new Set(r),i=new Set(e),s=n.current;o.forEach(function(a){i.has(a)||G(a,null)}),i.forEach(function(a){o.has(a)||G(a,s)})}fe.set(n,e)},[e]),n}function Et(e){return e}function gt(e,t){t===void 0&&(t=Et);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var s=t(i,r);return n.push(s),function(){n=n.filter(function(a){return a!==s})}},assignSyncMedium:function(i){for(r=!0;n.length;){var s=n;n=[],s.forEach(i)}n={push:function(a){return i(a)},filter:function(){return n}}},assignMedium:function(i){r=!0;var s=[];if(n.length){var a=n;n=[],a.forEach(i),s=n}var h=function(){var f=s;s=[],f.forEach(i)},l=function(){return Promise.resolve().then(h)};l(),n={push:function(f){s.push(f),l()},filter:function(f){return s=s.filter(f),n}}}};return o}function bt(e){e===void 0&&(e={});var t=gt(null);return t.options=R({async:!0,ssr:!1},e),t}var we=function(e){var t=e.sideCar,n=Se(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return c.createElement(r,R({},n))};we.isSideCarExport=!0;function St(e,t){return e.useMedium(t),we}var Ce=bt(),Z=function(){},K=c.forwardRef(function(e,t){var n=c.useRef(null),r=c.useState({onScrollCapture:Z,onWheelCapture:Z,onTouchMoveCapture:Z}),o=r[0],i=r[1],s=e.forwardProps,a=e.children,h=e.className,l=e.removeScrollBar,f=e.enabled,d=e.shards,v=e.sideCar,y=e.noRelative,w=e.noIsolation,u=e.inert,m=e.allowPinchZoom,p=e.as,g=p===void 0?"div":p,b=e.gapMode,S=Se(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=v,P=yt([n,t]),E=R(R({},S),o);return c.createElement(c.Fragment,null,f&&c.createElement(C,{sideCar:Ce,removeScrollBar:l,shards:d,noRelative:y,noIsolation:w,inert:u,setCallbacks:i,allowPinchZoom:!!m,lockRef:n,gapMode:b}),s?c.cloneElement(c.Children.only(a),R(R({},E),{ref:P})):c.createElement(g,R({},E,{className:h,ref:P}),a))});K.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};K.classNames={fullWidth:$,zeroRight:U};var wt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ct(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=wt();return t&&e.setAttribute("nonce",t),e}function Pt(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Rt(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var xt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ct())&&(Pt(t,n),Rt(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ot=function(){var e=xt();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Pe=function(){var e=Ot(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Lt={left:0,top:0,right:0,gap:0},q=function(e){return parseInt(e||"",10)||0},Tt=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[q(n),q(r),q(o)]},At=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Lt;var t=Tt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Nt=Pe(),k="data-scroll-locked",Dt=function(e,t,n,r){var o=e.left,i=e.top,s=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
2
2
|
.`.concat(vt,` {
|
|
3
3
|
overflow: hidden `).concat(r,`;
|
|
4
4
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as t}from"./index-BWmHJRhe.js";const e=()=>t.get("/projects"),r=o=>t.get(`/projects/${o}`);export{r as g,e as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as o}from"./index-
|
|
1
|
+
import{z as o}from"./index-BWmHJRhe.js";const i=s=>o.get(`/projects/${s}/sessions`),c=(s,e,t)=>o.get(`/projects/${s}/sessions/${e}`,{history_limit:String(t)}),r=(s,e,t)=>o.patch(`/projects/${s}/sessions/${e}`,t),a=(s,e)=>o.delete(`/projects/${s}/sessions/${e}`),p=(s,e)=>o.post(`/projects/${s}/sessions/switch`,e),$=(s,e)=>o.post(`/projects/${s}/send`,e);export{$ as a,a as d,c as g,i as l,r,p as s};
|
package/dist/renderer/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>AgentDock</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-BWmHJRhe.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-CaQZSRbg.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body class="bg-[#f5f5f7] dark:bg-[#151516]">
|
|
@@ -13,6 +13,7 @@ const local_core_slash_commands_js_1 = require("./local-core-slash-commands.js")
|
|
|
13
13
|
const local_core_acp_progress_js_1 = require("./local-core-acp-progress.js");
|
|
14
14
|
const index_js_1 = require("../agents/index.js");
|
|
15
15
|
const scheduled_job_route_js_1 = require("../scheduler/scheduled-job-route.js");
|
|
16
|
+
const thread_command_service_js_1 = require("../thread/thread-command-service.js");
|
|
16
17
|
const ACP_PROMPT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
17
18
|
class LocalCoreAcpBackend {
|
|
18
19
|
options;
|
|
@@ -20,6 +21,7 @@ class LocalCoreAcpBackend {
|
|
|
20
21
|
turnCoordinator;
|
|
21
22
|
sessionCoordinator;
|
|
22
23
|
responseProcessor;
|
|
24
|
+
commandService;
|
|
23
25
|
constructor(options) {
|
|
24
26
|
this.options = options;
|
|
25
27
|
this.transport = new local_core_acp_transport_js_1.LocalCoreAcpTransport({
|
|
@@ -87,6 +89,19 @@ class LocalCoreAcpBackend {
|
|
|
87
89
|
emitBridge: (event) => this.emitBridgeEvent(event),
|
|
88
90
|
log: options.log,
|
|
89
91
|
});
|
|
92
|
+
this.commandService = new thread_command_service_js_1.ThreadCommandService({
|
|
93
|
+
getThreadRow: (threadId) => this.options.store.getThreadRow(threadId),
|
|
94
|
+
updateThreadAgentMode: (threadId, mode) => this.options.store.updateThreadAgentMode(threadId, mode),
|
|
95
|
+
updateThreadAgentType: (threadId, agentType) => this.options.store.updateThreadAgentType(threadId, agentType),
|
|
96
|
+
getLatestRunForThread: (threadId) => this.options.store.getLatestRunForThread(threadId),
|
|
97
|
+
createAuditEvent: (input) => {
|
|
98
|
+
this.options.store.createAuditEvent(input);
|
|
99
|
+
},
|
|
100
|
+
getAgentTypes: options.getAgentTypes,
|
|
101
|
+
setThreadMode: (threadId, mode) => this.sessionCoordinator.setThreadMode(threadId, mode),
|
|
102
|
+
closeThreadSession: (threadId) => this.sessionCoordinator.closeThreadSession(threadId),
|
|
103
|
+
log: options.log,
|
|
104
|
+
});
|
|
90
105
|
this.responseProcessor = new local_core_acp_response_processor_js_1.LocalCoreAcpResponseProcessor({
|
|
91
106
|
getScheduledDeliveryBinding: (threadId) => {
|
|
92
107
|
const binding = this.options.store.getPlatformThreadBindingByThreadId(threadId);
|
|
@@ -149,16 +164,21 @@ class LocalCoreAcpBackend {
|
|
|
149
164
|
source: 'user',
|
|
150
165
|
},
|
|
151
166
|
});
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
167
|
+
const commandResult = await this.commandService.execute({
|
|
168
|
+
threadId,
|
|
169
|
+
workspaceId: row.workspace_id,
|
|
170
|
+
content,
|
|
171
|
+
defaultAgentType: config.agentType,
|
|
172
|
+
});
|
|
173
|
+
if (commandResult.handled) {
|
|
174
|
+
this.options.store.appendMessage(threadId, 'assistant', commandResult.displayText, 'final');
|
|
155
175
|
this.options.eventBus.emit({
|
|
156
176
|
type: 'thread.message.accepted',
|
|
157
177
|
payload: {
|
|
158
178
|
threadId,
|
|
159
179
|
workspaceId: row.workspace_id,
|
|
160
180
|
role: 'assistant',
|
|
161
|
-
content:
|
|
181
|
+
content: commandResult.displayText,
|
|
162
182
|
kind: 'final',
|
|
163
183
|
source: 'system',
|
|
164
184
|
},
|
|
@@ -166,7 +186,7 @@ class LocalCoreAcpBackend {
|
|
|
166
186
|
this.emitBridgeEvent({
|
|
167
187
|
type: 'reply',
|
|
168
188
|
sessionKey: row.bridge_session_key,
|
|
169
|
-
content:
|
|
189
|
+
content: commandResult.displayText,
|
|
170
190
|
});
|
|
171
191
|
this.emitBridgeEvent({
|
|
172
192
|
type: 'typing_stop',
|
|
@@ -246,40 +266,6 @@ class LocalCoreAcpBackend {
|
|
|
246
266
|
});
|
|
247
267
|
return { runId: session.currentRunId };
|
|
248
268
|
}
|
|
249
|
-
async handleLocalSlashCommand(threadId, workspaceId, content) {
|
|
250
|
-
const command = (0, local_core_slash_commands_js_1.parseSlashCommand)(content);
|
|
251
|
-
if (!command || command.name !== 'mode') {
|
|
252
|
-
return '';
|
|
253
|
-
}
|
|
254
|
-
const row = this.options.store.getThreadRow(threadId);
|
|
255
|
-
const currentMode = row?.agent_mode || local_core_slash_commands_js_1.DEFAULT_AGENT_MODE;
|
|
256
|
-
const requested = command.args.join(' ').trim();
|
|
257
|
-
if (!requested) {
|
|
258
|
-
return (0, local_core_slash_commands_js_1.modeHelpText)(currentMode);
|
|
259
|
-
}
|
|
260
|
-
const mode = (0, local_core_slash_commands_js_1.normalizeAgentMode)(requested);
|
|
261
|
-
if (!mode) {
|
|
262
|
-
return `未知模式:${requested}\n\n${(0, local_core_slash_commands_js_1.modeHelpText)(currentMode)}`;
|
|
263
|
-
}
|
|
264
|
-
this.options.store.updateThreadAgentMode(threadId, mode);
|
|
265
|
-
try {
|
|
266
|
-
await this.sessionCoordinator.setThreadMode(threadId, mode);
|
|
267
|
-
}
|
|
268
|
-
catch (error) {
|
|
269
|
-
this.options.log?.(`localcore-acp mode sync failed for ${threadId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
270
|
-
}
|
|
271
|
-
this.options.store.createAuditEvent({
|
|
272
|
-
type: 'permission.changed',
|
|
273
|
-
workspaceId,
|
|
274
|
-
actor: 'local',
|
|
275
|
-
summary: `Thread agent mode changed to ${mode}.`,
|
|
276
|
-
metadata: { threadId, mode },
|
|
277
|
-
});
|
|
278
|
-
if (mode === 'bypassPermissions') {
|
|
279
|
-
return '已切换到 yolo 模式:后续工具调用会跳过权限申请。使用 `/mode default` 可恢复默认权限。';
|
|
280
|
-
}
|
|
281
|
-
return `已切换到 ${(0, local_core_slash_commands_js_1.formatAgentMode)(mode)} 模式。`;
|
|
282
|
-
}
|
|
283
269
|
async interruptRun(runId) {
|
|
284
270
|
return this.sessionCoordinator.interruptRun(runId);
|
|
285
271
|
}
|
|
@@ -324,6 +310,8 @@ class LocalCoreAcpBackend {
|
|
|
324
310
|
agentType: row.agent_type,
|
|
325
311
|
assistantText: '',
|
|
326
312
|
rawAssistantText: '',
|
|
313
|
+
assistantSequence: 1,
|
|
314
|
+
assistantMessageId: `${runId}-assistant-1`,
|
|
327
315
|
priorAssistantFinalMessages,
|
|
328
316
|
priorAssistantProgressMessages,
|
|
329
317
|
thoughtText: '',
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.applyAssistantMessageChunk = applyAssistantMessageChunk;
|
|
4
4
|
exports.applyThoughtChunk = applyThoughtChunk;
|
|
5
5
|
exports.closeThoughtSegment = closeThoughtSegment;
|
|
6
|
+
exports.closeAssistantMessageSegment = closeAssistantMessageSegment;
|
|
6
7
|
exports.registerPendingToolCall = registerPendingToolCall;
|
|
7
8
|
exports.resolveToolCallForUpdate = resolveToolCallForUpdate;
|
|
8
9
|
exports.resolveFallbackToolCall = resolveFallbackToolCall;
|
|
@@ -81,6 +82,30 @@ function closeThoughtSegment(currentTurn) {
|
|
|
81
82
|
currentTurn.thoughtMessageId = `${runId}-thought-${nextSequence}`;
|
|
82
83
|
currentTurn.thoughtPreviewHandle = `${runId}-thought-preview-${nextSequence}`;
|
|
83
84
|
}
|
|
85
|
+
function closeAssistantMessageSegment(currentTurn) {
|
|
86
|
+
const content = currentTurn.assistantText || '';
|
|
87
|
+
if (!content.trim()) {
|
|
88
|
+
resetAssistantMessageSegment(currentTurn);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const messageId = currentTurn.assistantMessageId || currentTurn.previewHandle;
|
|
92
|
+
resetAssistantMessageSegment(currentTurn);
|
|
93
|
+
return {
|
|
94
|
+
messageId,
|
|
95
|
+
content,
|
|
96
|
+
bridgeKind: 'assistant',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function resetAssistantMessageSegment(currentTurn) {
|
|
100
|
+
const runId = currentTurn.runId || 'assistant';
|
|
101
|
+
const nextSequence = (currentTurn.assistantSequence || 1) + 1;
|
|
102
|
+
currentTurn.assistantSequence = nextSequence;
|
|
103
|
+
currentTurn.assistantText = '';
|
|
104
|
+
currentTurn.rawAssistantText = '';
|
|
105
|
+
currentTurn.previewStarted = false;
|
|
106
|
+
currentTurn.assistantMessageId = `${runId}-assistant-${nextSequence}`;
|
|
107
|
+
currentTurn.previewHandle = `${runId}-assistant-preview-${nextSequence}`;
|
|
108
|
+
}
|
|
84
109
|
function mergeThoughtSegment(current, next) {
|
|
85
110
|
if (!current) {
|
|
86
111
|
return { fullText: next, segmentText: next };
|
|
@@ -29,11 +29,13 @@ class LocalCoreAcpSessionCoordinator {
|
|
|
29
29
|
async ensureSession(threadId, bridgeSessionKey, config, options = {}) {
|
|
30
30
|
const existing = this.sessions.get(threadId);
|
|
31
31
|
const permissionMode = this.resolveLaunchPermissionMode(threadId, options.permissionMode);
|
|
32
|
+
const configKey = this.buildLaunchConfigKey(config);
|
|
32
33
|
const runtimeEnvKey = this.buildRuntimeEnvKey(options.runtimeEnv);
|
|
33
34
|
if (existing
|
|
34
35
|
&& !existing.closed
|
|
35
36
|
&& existing.sessionId
|
|
36
37
|
&& existing.launchPermissionMode === permissionMode
|
|
38
|
+
&& existing.launchConfigKey === configKey
|
|
37
39
|
&& existing.launchRuntimeEnvKey === runtimeEnvKey) {
|
|
38
40
|
return existing;
|
|
39
41
|
}
|
|
@@ -51,6 +53,7 @@ class LocalCoreAcpSessionCoordinator {
|
|
|
51
53
|
runtimeEnv: this.buildAgentRuntimeEnv(threadId, String(baseEnv.PATH || ''), options.runtimeEnv),
|
|
52
54
|
});
|
|
53
55
|
session.launchPermissionMode = permissionMode;
|
|
56
|
+
session.launchConfigKey = configKey;
|
|
54
57
|
session.launchRuntimeEnvKey = runtimeEnvKey;
|
|
55
58
|
this.sessions.set(threadId, session);
|
|
56
59
|
await this.options.transport.initializeSession(session);
|
|
@@ -204,6 +207,16 @@ class LocalCoreAcpSessionCoordinator {
|
|
|
204
207
|
...runtimeEnv,
|
|
205
208
|
};
|
|
206
209
|
}
|
|
210
|
+
buildLaunchConfigKey(config) {
|
|
211
|
+
return JSON.stringify({
|
|
212
|
+
agentType: config.agentType,
|
|
213
|
+
workDir: config.workDir,
|
|
214
|
+
command: config.command,
|
|
215
|
+
args: config.args || [],
|
|
216
|
+
env: config.env || {},
|
|
217
|
+
model: config.model || '',
|
|
218
|
+
});
|
|
219
|
+
}
|
|
207
220
|
resolveLaunchPermissionMode(threadId, permissionModeOverride = '') {
|
|
208
221
|
const row = this.options.store.getThreadRow(threadId);
|
|
209
222
|
const mode = String(permissionModeOverride || row?.agent_mode || '').trim();
|
|
@@ -978,6 +978,13 @@ class LocalCoreAcpStore {
|
|
|
978
978
|
WHERE id = ?
|
|
979
979
|
`).run(mode, new Date().toISOString(), threadId);
|
|
980
980
|
}
|
|
981
|
+
updateThreadAgentType(threadId, agentType) {
|
|
982
|
+
this.db.prepare(`
|
|
983
|
+
UPDATE threads
|
|
984
|
+
SET agent_type = ?, acp_session_id = NULL, acp_supports_load = 0, updated_at = ?
|
|
985
|
+
WHERE id = ?
|
|
986
|
+
`).run(agentType, new Date().toISOString(), threadId);
|
|
987
|
+
}
|
|
981
988
|
updateThreadSession(threadId, sessionId, supportsLoad) {
|
|
982
989
|
this.db.prepare(`
|
|
983
990
|
UPDATE threads
|
|
@@ -17,6 +17,31 @@ class LocalCoreAcpTurnCoordinator {
|
|
|
17
17
|
if (currentTurn)
|
|
18
18
|
(0, local_core_acp_progress_js_1.closeThoughtSegment)(currentTurn);
|
|
19
19
|
}
|
|
20
|
+
closePendingAssistantSegment(session) {
|
|
21
|
+
const currentTurn = session.currentTurn;
|
|
22
|
+
const currentRunId = session.currentRunId;
|
|
23
|
+
if (!currentTurn || !currentRunId) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const projection = (0, local_core_acp_progress_js_1.closeAssistantMessageSegment)(currentTurn);
|
|
27
|
+
if (!projection) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (this.options.upsertMessage) {
|
|
31
|
+
this.options.upsertMessage(session.threadId, projection.messageId, 'assistant', projection.content, 'progress', undefined, projection.bridgeKind);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.options.appendMessage(session.threadId, 'assistant', projection.content, 'progress', undefined, projection.bridgeKind);
|
|
35
|
+
}
|
|
36
|
+
this.options.emitBridge({
|
|
37
|
+
type: 'reply',
|
|
38
|
+
sessionKey: session.bridgeSessionKey,
|
|
39
|
+
replyCtx: currentRunId,
|
|
40
|
+
messageId: projection.messageId,
|
|
41
|
+
bridgeKind: projection.bridgeKind,
|
|
42
|
+
content: projection.content,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
20
45
|
flushPendingToolCall(session) {
|
|
21
46
|
const currentTurn = session.currentTurn;
|
|
22
47
|
const currentRunId = session.currentRunId;
|
|
@@ -112,6 +137,7 @@ class LocalCoreAcpTurnCoordinator {
|
|
|
112
137
|
params: payload.params,
|
|
113
138
|
}) || parsedOptions;
|
|
114
139
|
const toolTitle = (0, workspace_acp_permissions_js_1.formatToolCallContent)(payload.params?.toolCall);
|
|
140
|
+
this.closePendingAssistantSegment(session);
|
|
115
141
|
this.closePendingThoughtSegment(session);
|
|
116
142
|
const effectiveAgentMode = session.launchPermissionMode || this.options.getThreadAgentMode?.(session.threadId) || local_core_slash_commands_js_1.DEFAULT_AGENT_MODE;
|
|
117
143
|
if (effectiveAgentMode === 'bypassPermissions') {
|
|
@@ -213,6 +239,7 @@ class LocalCoreAcpTurnCoordinator {
|
|
|
213
239
|
return;
|
|
214
240
|
}
|
|
215
241
|
if (isToolScopedAssistantUpdate(update) || consumeRawAssistantProgressChunk(session, String(update.content.text || ''))) {
|
|
242
|
+
this.closePendingAssistantSegment(session);
|
|
216
243
|
const content = String(update.content.text || '').trim();
|
|
217
244
|
if (content) {
|
|
218
245
|
if (this.shouldSuppressProgress(currentTurn, 'tool', content)) {
|
|
@@ -246,17 +273,10 @@ class LocalCoreAcpTurnCoordinator {
|
|
|
246
273
|
if (!projection) {
|
|
247
274
|
return;
|
|
248
275
|
}
|
|
249
|
-
this.options.emitBridge({
|
|
250
|
-
type: projection.bridgeType,
|
|
251
|
-
sessionKey: session.bridgeSessionKey,
|
|
252
|
-
replyCtx: currentRunId,
|
|
253
|
-
previewHandle: projection.previewHandle,
|
|
254
|
-
bridgeKind: projection.bridgeKind,
|
|
255
|
-
content: projection.content,
|
|
256
|
-
});
|
|
257
276
|
return;
|
|
258
277
|
}
|
|
259
278
|
case 'agent_thought_chunk': {
|
|
279
|
+
this.closePendingAssistantSegment(session);
|
|
260
280
|
if (update.content?.type !== 'text') {
|
|
261
281
|
return;
|
|
262
282
|
}
|
|
@@ -282,6 +302,7 @@ class LocalCoreAcpTurnCoordinator {
|
|
|
282
302
|
return;
|
|
283
303
|
}
|
|
284
304
|
case 'tool_call': {
|
|
305
|
+
this.closePendingAssistantSegment(session);
|
|
285
306
|
this.closePendingThoughtSegment(session);
|
|
286
307
|
const toolCall = (0, local_core_acp_progress_js_1.registerPendingToolCall)({ currentTurn, runId: currentRunId, update });
|
|
287
308
|
if (this.isKnownPriorToolInput(currentTurn, toolCall.title, toolCall.input)) {
|
|
@@ -298,6 +319,7 @@ class LocalCoreAcpTurnCoordinator {
|
|
|
298
319
|
return;
|
|
299
320
|
}
|
|
300
321
|
case 'tool_call_update': {
|
|
322
|
+
this.closePendingAssistantSegment(session);
|
|
301
323
|
this.closePendingThoughtSegment(session);
|
|
302
324
|
const title = String(update.title || 'Tool update').trim();
|
|
303
325
|
const status = String(update.status || '').trim();
|
|
@@ -366,6 +388,7 @@ class LocalCoreAcpTurnCoordinator {
|
|
|
366
388
|
return;
|
|
367
389
|
}
|
|
368
390
|
case 'plan': {
|
|
391
|
+
this.closePendingAssistantSegment(session);
|
|
369
392
|
this.closePendingThoughtSegment(session);
|
|
370
393
|
this.flushPendingToolCall(session);
|
|
371
394
|
const entries = Array.isArray(update.entries) ? update.entries : [];
|
|
@@ -5,7 +5,17 @@ exports.parseSlashCommand = parseSlashCommand;
|
|
|
5
5
|
exports.normalizeAgentMode = normalizeAgentMode;
|
|
6
6
|
exports.formatAgentMode = formatAgentMode;
|
|
7
7
|
exports.modeHelpText = modeHelpText;
|
|
8
|
+
exports.normalizeAgentCommandTarget = normalizeAgentCommandTarget;
|
|
9
|
+
exports.formatAgentList = formatAgentList;
|
|
10
|
+
exports.agentHelpText = agentHelpText;
|
|
8
11
|
exports.DEFAULT_AGENT_MODE = 'default';
|
|
12
|
+
const AGENT_ALIASES = {
|
|
13
|
+
claude: 'claudecode',
|
|
14
|
+
'claude-code': 'claudecode',
|
|
15
|
+
claude_code: 'claudecode',
|
|
16
|
+
claudecode: 'claudecode',
|
|
17
|
+
cc: 'claudecode',
|
|
18
|
+
};
|
|
9
19
|
const MODE_ALIASES = {
|
|
10
20
|
auto: 'auto',
|
|
11
21
|
default: 'default',
|
|
@@ -58,3 +68,21 @@ function modeHelpText(currentMode) {
|
|
|
58
68
|
'`/mode yolo` 会跳过工具权限申请;使用 `/mode default` 可恢复默认权限。'
|
|
59
69
|
].join('\n');
|
|
60
70
|
}
|
|
71
|
+
function normalizeAgentCommandTarget(agent) {
|
|
72
|
+
const key = String(agent || '').trim().toLowerCase();
|
|
73
|
+
return AGENT_ALIASES[key] || key;
|
|
74
|
+
}
|
|
75
|
+
function formatAgentList(agents) {
|
|
76
|
+
return [...new Set(agents.map(normalizeAgentCommandTarget).filter(Boolean))].sort();
|
|
77
|
+
}
|
|
78
|
+
function agentHelpText(input) {
|
|
79
|
+
const currentAgent = normalizeAgentCommandTarget(input.currentAgent) || 'unknown';
|
|
80
|
+
const defaultAgent = normalizeAgentCommandTarget(input.defaultAgent) || 'unknown';
|
|
81
|
+
const availableAgents = formatAgentList(input.availableAgents);
|
|
82
|
+
return [
|
|
83
|
+
`当前线程 Agent:${currentAgent}`,
|
|
84
|
+
`默认 Agent:${defaultAgent}`,
|
|
85
|
+
`可用 Agent:${availableAgents.length ? availableAgents.join(', ') : '无'}`,
|
|
86
|
+
'可用命令:`/agent list`、`/agent current`、`/agent use <agent-id>`、`/agent reset`。',
|
|
87
|
+
].join('\n');
|
|
88
|
+
}
|
|
@@ -44,7 +44,7 @@ const file_utils_js_1 = require("../shared/file-utils.js");
|
|
|
44
44
|
const cards_js_1 = require("./cards.js");
|
|
45
45
|
const config_js_1 = require("./config.js");
|
|
46
46
|
const registration_js_1 = require("./registration.js");
|
|
47
|
-
const
|
|
47
|
+
const messages_js_1 = require("./rendering/messages.js");
|
|
48
48
|
const runtime_state_js_1 = require("./runtime-state.js");
|
|
49
49
|
const PAIRING_EXPIRY_MS = 10 * 60 * 1000;
|
|
50
50
|
const LARK_MAX_UPLOAD_FILE_SIZE = 30 * 1024 * 1024;
|
|
@@ -219,7 +219,7 @@ class LocalCoreLarkGateway extends node_events_1.EventEmitter {
|
|
|
219
219
|
if (part.type === 'text') {
|
|
220
220
|
const text = String(part.text || '').trim();
|
|
221
221
|
if (text) {
|
|
222
|
-
messageIds.push(await this.
|
|
222
|
+
messageIds.push((await this.sendTextAsMessage(state, channelId, text)).messageId);
|
|
223
223
|
}
|
|
224
224
|
continue;
|
|
225
225
|
}
|
|
@@ -514,15 +514,20 @@ class LocalCoreLarkGateway extends node_events_1.EventEmitter {
|
|
|
514
514
|
continue;
|
|
515
515
|
}
|
|
516
516
|
if (!existingMessageId) {
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
517
|
+
const sendAsPlainMessage = renderedMessage.delivery === 'message' && renderedMessage.buttonRows.length === 0;
|
|
518
|
+
const sentMessage = sendAsPlainMessage
|
|
519
|
+
? await this.sendTextAsMessage(state, route.chatId, renderedMessage.text)
|
|
520
|
+
: {
|
|
521
|
+
messageId: await this.sendTextAsCard(state, route.chatId, renderedMessage.text, renderedMessage.buttonRows, sessionKey, bridgeThreadId),
|
|
522
|
+
renderKind: 'card',
|
|
523
|
+
};
|
|
524
|
+
const createdId = sentMessage.messageId;
|
|
520
525
|
if (createdId) {
|
|
521
526
|
(0, runtime_state_js_1.setLarkRenderedMessageId)(turn, renderedMessage, createdId);
|
|
522
527
|
if (renderedMessage.isFinal) {
|
|
523
528
|
this.options.store.updatePlatformThreadMessageId(route.workspaceId, route.chatId, route.platformUserId, createdId, routePlatformKey);
|
|
524
529
|
}
|
|
525
|
-
this.options.log?.(`localcore-lark sent new ${
|
|
530
|
+
this.options.log?.(`localcore-lark sent new ${sentMessage.renderKind} message ${createdId} for sessionKey=${sessionKey}`);
|
|
526
531
|
}
|
|
527
532
|
continue;
|
|
528
533
|
}
|
|
@@ -1152,20 +1157,25 @@ class LocalCoreLarkGateway extends node_events_1.EventEmitter {
|
|
|
1152
1157
|
this.options.log?.(`localcore-lark card create took ${Date.now() - startedAt}ms textBytes=${Buffer.byteLength(text || '', 'utf8')}`);
|
|
1153
1158
|
return String(response?.data?.message_id || '').trim();
|
|
1154
1159
|
}
|
|
1155
|
-
async
|
|
1160
|
+
async sendTextAsMessage(state, chatId, text) {
|
|
1156
1161
|
const startedAt = Date.now();
|
|
1162
|
+
const rendered = (0, messages_js_1.renderLarkTextMessage)(text);
|
|
1157
1163
|
const response = await state.client.im.message.create({
|
|
1158
1164
|
params: {
|
|
1159
1165
|
receive_id_type: this.resolveReceiveIdType(chatId),
|
|
1160
1166
|
},
|
|
1161
1167
|
data: {
|
|
1162
1168
|
receive_id: chatId,
|
|
1163
|
-
msg_type:
|
|
1164
|
-
content: JSON.stringify(
|
|
1169
|
+
msg_type: rendered.msgType,
|
|
1170
|
+
content: JSON.stringify(rendered.content),
|
|
1165
1171
|
},
|
|
1166
1172
|
});
|
|
1167
|
-
this.options.log?.(`localcore-lark
|
|
1168
|
-
return
|
|
1173
|
+
this.options.log?.(`localcore-lark ${rendered.renderKind} create took ${Date.now() - startedAt}ms msgType=${rendered.msgType} reason=${rendered.reason} tableCount=${rendered.tableCount} textBytes=${Buffer.byteLength(text || '', 'utf8')}`);
|
|
1174
|
+
return {
|
|
1175
|
+
messageId: String(response?.data?.message_id || '').trim(),
|
|
1176
|
+
renderKind: rendered.renderKind,
|
|
1177
|
+
msgType: rendered.msgType,
|
|
1178
|
+
};
|
|
1169
1179
|
}
|
|
1170
1180
|
resolveReceiveIdType(receiveId) {
|
|
1171
1181
|
return receiveId.startsWith('oc_') ? 'chat_id' : receiveId.startsWith('ou_') ? 'open_id' : 'user_id';
|