@vpxa/aikit 0.1.315 → 0.1.317

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.
@@ -0,0 +1 @@
1
+ import{fileURLToPath as e}from"node:url";import{serializeError as t}from"../../core/dist/index.js";import{resolve as n}from"node:path";function r(t){return t.startsWith(`file://`)?e(t):t}function i(e){let t=n(e);return process.platform===`win32`?t.toLowerCase():t}function a(e){let t=new Map;for(let n of e){let e=r(n.uri);t.set(i(e),e)}return[...t.values()].sort((e,t)=>i(e).localeCompare(i(t)))}function o({config:e,roots:t}){let n=a(t);if(n.length===0)return null;let r=e.sources?.[0]?.path;if(r){let e=i(r),t=n.find(t=>i(t)===e);if(t)return t}return n[0]}function s({config:e,log:t,reconfigureForWorkspace:n,roots:r}){let s=a(r);if(s.length===0)return!1;let c=o({config:e,roots:s.map(e=>({uri:e}))});if(!c)return!1;let l=e.sources?.[0]?.path;return t.debug(`MCP roots resolved`,{rootPath:c,rootCount:s.length,selectedBy:l&&i(l)===i(c)?`configured-source`:`stable-sorted-root`}),n(e,c),e.allRoots=s,!0}async function c({config:e,indexMode:n,log:r,rootsChangedNotificationSchema:i,reconfigureForWorkspace:a,runInitialIndex:o,server:c,startInit:l,timeoutMs:u=5e3,getCwd:d=()=>process.env.AIKIT_WORKSPACE_ROOT??process.cwd(),version:f=`0.0.0`}){let p=!1,m=!1,h,g=c.server,_=e=>{let n=t(e),r=`${String(e)} ${String(n.message??``)}`.toLowerCase();return r.includes(`method not found`)||r.includes(`not supported`)||r.includes(`unsupported`)||r.includes(`unknown method`)||r.includes(`roots/list`)||r.includes(`timed out`)},v=()=>{p||(p=!0,l())},y=()=>{m||n!==`auto`||(m=!0,(async()=>{try{await o()}catch(e){r.error(`Initial index failed`,{version:f,...t(e)})}})())},b=t=>t.length===0||(h&&=(clearTimeout(h),void 0),!s({config:e,log:r,reconfigureForWorkspace:a,roots:t}))?!1:(v(),y(),!0);try{if(b((await g.listRoots()).roots))return;r.debug(`No MCP roots yet; waiting for roots/list_changed notification`)}catch(n){if(_(n)){r.warn(`MCP roots/list not supported by client; using cwd fallback`,{version:f,cwd:d(),...t(n)}),s({config:e,log:r,reconfigureForWorkspace:a,roots:[{uri:d()}]})&&(v(),y());return}r.warn(`MCP roots/list failed; waiting for roots/list_changed notification`,{version:f,cwd:d(),...t(n)})}g.setNotificationHandler(i,async()=>{try{b((await g.listRoots()).roots)}catch(e){r.warn(`roots/list retry failed after notification`,{version:f,...t(e)})}}),h=setTimeout(()=>{let t=d();r.debug(`Timed out waiting for roots/list_changed; falling back to cwd workspace`,{cwd:t}),s({config:e,log:r,reconfigureForWorkspace:a,roots:[{uri:t}]})&&(v(),y())},u)}export{c as n,o as r,s as t};
@@ -1 +0,0 @@
1
- import{fileURLToPath as e}from"node:url";import{serializeError as t}from"../../core/dist/index.js";import{resolve as n}from"node:path";function r(t){return t.startsWith(`file://`)?e(t):t}function i(e){let t=n(e);return process.platform===`win32`?t.toLowerCase():t}function a(e){let t=new Map;for(let n of e){let e=r(n.uri);t.set(i(e),e)}return[...t.values()].sort((e,t)=>i(e).localeCompare(i(t)))}function o({config:e,roots:t}){let n=a(t);if(n.length===0)return null;let r=e.sources?.[0]?.path;if(r){let e=i(r),t=n.find(t=>i(t)===e);if(t)return t}return n[0]}function s({config:e,log:t,reconfigureForWorkspace:n,roots:r}){let s=a(r);if(s.length===0)return!1;let c=o({config:e,roots:s.map(e=>({uri:e}))});if(!c)return!1;let l=e.sources?.[0]?.path;return t.debug(`MCP roots resolved`,{rootPath:c,rootCount:s.length,selectedBy:l&&i(l)===i(c)?`configured-source`:`stable-sorted-root`}),n(e,c),e.allRoots=s,!0}async function c({config:e,indexMode:n,log:r,rootsChangedNotificationSchema:i,reconfigureForWorkspace:a,runInitialIndex:o,server:c,startInit:l,timeoutMs:u=5e3,getCwd:d=()=>process.cwd(),version:f=`0.0.0`}){let p=!1,m=!1,h,g=c.server,_=e=>{let n=t(e),r=`${String(e)} ${String(n.message??``)}`.toLowerCase();return r.includes(`method not found`)||r.includes(`not supported`)||r.includes(`unsupported`)||r.includes(`unknown method`)||r.includes(`roots/list`)||r.includes(`timed out`)},v=()=>{p||(p=!0,l())},y=()=>{m||n!==`auto`||(m=!0,(async()=>{try{await o()}catch(e){r.error(`Initial index failed`,{version:f,...t(e)})}})())},b=t=>t.length===0||(h&&=(clearTimeout(h),void 0),!s({config:e,log:r,reconfigureForWorkspace:a,roots:t}))?!1:(v(),y(),!0);try{if(b((await g.listRoots()).roots))return;r.debug(`No MCP roots yet; waiting for roots/list_changed notification`)}catch(n){if(_(n)){r.warn(`MCP roots/list not supported by client; using cwd fallback`,{version:f,cwd:d(),...t(n)}),s({config:e,log:r,reconfigureForWorkspace:a,roots:[{uri:d()}]})&&(v(),y());return}r.warn(`MCP roots/list failed; waiting for roots/list_changed notification`,{version:f,cwd:d(),...t(n)})}g.setNotificationHandler(i,async()=>{try{b((await g.listRoots()).roots)}catch(e){r.warn(`roots/list retry failed after notification`,{version:f,...t(e)})}}),h=setTimeout(()=>{let t=d();r.debug(`Timed out waiting for roots/list_changed; falling back to cwd workspace`,{cwd:t}),s({config:e,log:r,reconfigureForWorkspace:a,roots:[{uri:t}]})&&(v(),y())},u)}export{c as n,o as r,s as t};