@vpxa/aikit 0.1.319 → 0.1.321
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/package.json +1 -1
- package/packages/browser/dist/index.js +1 -1
- package/packages/present/dist/annotation-layer.js +28 -12
- package/packages/server/dist/bin.js +1 -1
- package/packages/server/dist/index.js +1 -1
- package/packages/server/dist/{server-DyYCi71H.js → server-D2GsXYBu.js} +155 -155
- package/packages/server/dist/{server-BYY6wi6v.js → server-Rjjmacb7.js} +155 -155
- package/packages/server/dist/{server-http-BTLSMqqO.js → server-http-Bbb9mzxV.js} +1 -1
- package/packages/server/dist/{server-http-BwK7mqRs.js → server-http-OJ2BorHy.js} +1 -1
- package/packages/server/dist/{server-stdio-ksLTYwSm.js → server-stdio-CcuCPyku.js} +1 -1
- package/packages/server/dist/{server-stdio-BOx_iUYc.js → server-stdio-DqqC5gDB.js} +1 -1
package/package.json
CHANGED
|
@@ -7,5 +7,5 @@ import{execFile as e,execFileSync as t,execSync as n}from"node:child_process";im
|
|
|
7
7
|
})`:`fetch(${JSON.stringify(e)}, ${o}).then(async r => {
|
|
8
8
|
const text = await r.text();
|
|
9
9
|
return JSON.stringify({ status: r.status, statusText: r.statusText, body: text.slice(0, 100000) });
|
|
10
|
-
})`}function we(e){return async({pageId:t,url:n,type:r,selector:i,timeoutMs:a})=>{let o=E(e),s=o.resolvePageId(t);if(n){let t=D(n,e);if(!t.allowed)return N(`Navigation blocked: ${t.reason}`,{blocked:!0,pageId:s,reason:t.reason});await o.tabExec(s,`goto`,n)}else if(!r)return N(`Navigation requires url or type`,{error:`Navigation requires url or type`,pageId:s});else if(r===`back`)await o.tabExec(s,`back`);else if(r===`forward`)await o.tabExec(s,`forward`);else if(r===`reload`)await o.tabExec(s,`reload`);else if(r===`waitFor`){if(!i)throw Error(`browser_navigate(waitFor) requires selector`);let e=a?[i,String(a)]:[i];await o.tabExec(s,`wait`,...e)}let c=await o.tabExec(s,`get`,`text`).catch(()=>({stdout:n??``})),l=await o.tabExec(s,`get`,`attr`,`title`).catch(()=>({stdout:``})),u=c.stdout.trim()||n||``,d=l.stdout.trim()||u;return o.tabs.updateTabInfo(s,u,d),o.resetIdleTimer(),N(`${d||u}\n${u}`,{pageId:s,url:u,title:d})}}function Te(e){return async({pageId:t,subAction:n,filter:r,includeBody:i,bufferSize:a})=>{let o=E(e),s=o.resolvePageId(t);switch(n){case`enable`:{let e=[`--enable`];return r?.resourceTypes&&e.push(`--filter`,r.resourceTypes.join(`,`)),i&&e.push(`--include-body`),a&&e.push(`--buffer-size`,String(a)),await o.tabExec(s,`network`,...e),o.resetIdleTimer(),N(`Network capture enabled`,{enabled:!0,filter:r})}case`get`:{let e=await o.tabExec(s,`network`,`requests`,`--json`);o.resetIdleTimer();let t=[];try{t=JSON.parse(e.stdout)}catch{t=[{raw:e.stdout}]}return N(`Captured ${t.length} network requests`,{entries:t,count:t.length})}case`clear`:return await o.tabExec(s,`network`,`clear`),o.resetIdleTimer(),N(`Network capture cleared`,{cleared:!0});case`export-har`:{let e=await o.tabExec(s,`network`,`har`);return o.resetIdleTimer(),N(e.stdout,{har:e.stdout})}default:return N(`Unknown network sub-action`,{error:`Unknown network sub-action`})}}}function Ee(e){return async({url:t,mode:n,label:r,waitUntil:i,forceNew:a,autoDialog:o})=>{let s=D(t,e);if(!s.allowed)return N(`Navigation blocked: ${s.reason}`,{blocked:!0,reason:s.reason});let c=E(e);await c.launch(n);let l=await c.exec(`open`,t);c.tabs.register(`t0`,t,r??l.stdout.trim(),r),c.resetIdleTimer();let u=[];return i===`networkidle`&&u.push(`--wait-until`,`networkidle`),i===`domcontentloaded`&&u.push(`--wait-until`,`domcontentloaded`),u.length>0&&await c.tabExec(`t0`,`wait`,...u).catch(()=>{}),N(`Opened ${t}\nTab: t0`,{pageId:`t0`,url:t,tabId:`t0`,label:r})}}function De(e){return async({pageId:t,mode:n,selector:r})=>{let i=E(e),a=i.resolvePageId(t);switch(n??`snapshot`){case`snapshot`:{let e=[`-i`,`--json`];r&&e.push(`-s`,r);let t=await i.tabExec(a,`snapshot`,...e);return i.tabs.setSnapshot(a,t.stdout),i.resetIdleTimer(),N(t.stdout,{pageId:a,mode:`snapshot`,content:t.stdout})}case`dom`:{let e=await i.tabExec(a,`get`,`html`);return i.resetIdleTimer(),N(e.stdout,{pageId:a,mode:`dom`,content:e.stdout})}case`markdown`:{let e=await i.tabExec(a,`snapshot`,`-c`);return i.resetIdleTimer(),N(e.stdout,{pageId:a,mode:`markdown`,content:e.stdout})}case`text`:{let e=await i.tabExec(a,`get`,`text`);return i.resetIdleTimer(),N(e.stdout,{pageId:a,mode:`text`,content:e.stdout})}default:return N(`Unknown read mode`,{error:`Unknown read mode`,pageId:a})}}}function Oe(e){return async({pageId:t,ref:n,selector:r,fullPage:i,clip:a,format:o,quality:s})=>{let c=E(e),l=c.resolvePageId(t);if(
|
|
10
|
+
})`}function we(e){return async({pageId:t,url:n,type:r,selector:i,timeoutMs:a})=>{let o=E(e),s=o.resolvePageId(t);if(n){let t=D(n,e);if(!t.allowed)return N(`Navigation blocked: ${t.reason}`,{blocked:!0,pageId:s,reason:t.reason});await o.tabExec(s,`goto`,n)}else if(!r)return N(`Navigation requires url or type`,{error:`Navigation requires url or type`,pageId:s});else if(r===`back`)await o.tabExec(s,`back`);else if(r===`forward`)await o.tabExec(s,`forward`);else if(r===`reload`)await o.tabExec(s,`reload`);else if(r===`waitFor`){if(!i)throw Error(`browser_navigate(waitFor) requires selector`);let e=a?[i,String(a)]:[i];await o.tabExec(s,`wait`,...e)}let c=await o.tabExec(s,`get`,`text`).catch(()=>({stdout:n??``})),l=await o.tabExec(s,`get`,`attr`,`title`).catch(()=>({stdout:``})),u=c.stdout.trim()||n||``,d=l.stdout.trim()||u;return o.tabs.updateTabInfo(s,u,d),o.resetIdleTimer(),N(`${d||u}\n${u}`,{pageId:s,url:u,title:d})}}function Te(e){return async({pageId:t,subAction:n,filter:r,includeBody:i,bufferSize:a})=>{let o=E(e),s=o.resolvePageId(t);switch(n){case`enable`:{let e=[`--enable`];return r?.resourceTypes&&e.push(`--filter`,r.resourceTypes.join(`,`)),i&&e.push(`--include-body`),a&&e.push(`--buffer-size`,String(a)),await o.tabExec(s,`network`,...e),o.resetIdleTimer(),N(`Network capture enabled`,{enabled:!0,filter:r})}case`get`:{let e=await o.tabExec(s,`network`,`requests`,`--json`);o.resetIdleTimer();let t=[];try{t=JSON.parse(e.stdout)}catch{t=[{raw:e.stdout}]}return N(`Captured ${t.length} network requests`,{entries:t,count:t.length})}case`clear`:return await o.tabExec(s,`network`,`clear`),o.resetIdleTimer(),N(`Network capture cleared`,{cleared:!0});case`export-har`:{let e=await o.tabExec(s,`network`,`har`);return o.resetIdleTimer(),N(e.stdout,{har:e.stdout})}default:return N(`Unknown network sub-action`,{error:`Unknown network sub-action`})}}}function Ee(e){return async({url:t,mode:n,label:r,waitUntil:i,forceNew:a,autoDialog:o})=>{let s=D(t,e);if(!s.allowed)return N(`Navigation blocked: ${s.reason}`,{blocked:!0,reason:s.reason});let c=E(e);await c.launch(n);let l=await c.exec(`open`,t);c.tabs.register(`t0`,t,r??l.stdout.trim(),r),c.resetIdleTimer();let u=[];return i===`networkidle`&&u.push(`--wait-until`,`networkidle`),i===`domcontentloaded`&&u.push(`--wait-until`,`domcontentloaded`),u.length>0&&await c.tabExec(`t0`,`wait`,...u).catch(()=>{}),N(`Opened ${t}\nTab: t0`,{pageId:`t0`,url:t,tabId:`t0`,label:r})}}function De(e){return async({pageId:t,mode:n,selector:r})=>{let i=E(e),a=i.resolvePageId(t);switch(n??`snapshot`){case`snapshot`:{let e=[`-i`,`--json`];r&&e.push(`-s`,r);let t=await i.tabExec(a,`snapshot`,...e);return i.tabs.setSnapshot(a,t.stdout),i.resetIdleTimer(),N(t.stdout,{pageId:a,mode:`snapshot`,content:t.stdout})}case`dom`:{let e=await i.tabExec(a,`get`,`html`);return i.resetIdleTimer(),N(e.stdout,{pageId:a,mode:`dom`,content:e.stdout})}case`markdown`:{let e=await i.tabExec(a,`snapshot`,`-c`);return i.resetIdleTimer(),N(e.stdout,{pageId:a,mode:`markdown`,content:e.stdout})}case`text`:{let e=await i.tabExec(a,`get`,`text`);return i.resetIdleTimer(),N(e.stdout,{pageId:a,mode:`text`,content:e.stdout})}default:return N(`Unknown read mode`,{error:`Unknown read mode`,pageId:a})}}}function Oe(e){return async({pageId:t,ref:n,selector:r,fullPage:i,clip:a,format:o,quality:s})=>{let c=E(e),l=c.resolvePageId(t),u=r??n;if(u){let e=await c.tabExec(l,`screenshot`,`--element`,u);return c.resetIdleTimer(),N(`Screenshot captured for element ${u}`,{element:u,pageId:l,screenshot:e.stdout})}let d=await c.screenshot(l,{fullPage:i,format:o,quality:s});return c.resetIdleTimer(),N(`Screenshot captured (${d.bytes} bytes)`,{pageId:l,base64:d.base64,mimeType:d.mimeType,bytes:d.bytes})}}function ke(e){return async({sessionAction:t,pageId:n,confirm:r,cookies:i,name:a,storageType:o,storageKey:s,storageValue:c})=>{let l=E(e),u=n?l.resolvePageId(n):void 0;switch(t){case`list`:{let e=l.tabs.listPages().map(e=>({pageId:e.pageId,url:e.url,title:e.title,label:e.label,createdAt:e.createdAt.toISOString()}));return N(`Open tabs: ${e.length}\n${e.map(e=>` ${e.pageId}: ${e.title||e.url}`).join(`
|
|
11
11
|
`)}`,{pages:e})}case`close`:return u?(await l.tabExec(u,`close`).catch(()=>{}),await l.tabs.removeTab(u),l.resetIdleTimer(),N(`Closed tab ${u}`,{closed:u})):N(`close requires pageId`,{error:`pageId required`});case`cookies`:{if(!r)return N(`Cookie export requires explicit confirmation. Set confirm: true to proceed.`,{confirmRequired:!0});let e=await l.tabExec(u??`t0`,`cookies`),t=[];try{t=JSON.parse(e.stdout)}catch{t=[{raw:e.stdout}]}return N(`Exported ${t.length} cookies`,{cookies:t,count:t.length})}case`set-cookie`:{if(!i||i.length===0)return N(`set-cookie requires cookies array`,{error:`cookies array required`});let e=i.map(e=>`${e.name}=${e.value}${e.domain?`; domain=${e.domain}`:``}${e.path?`; path=${e.path}`:``}`).join(` `);return await l.tabExec(u??`t0`,`cookies`,`set`,e),l.resetIdleTimer(),N(`Set ${i.length} cookies`,{count:i.length})}case`delete-cookie`:return a?(await l.tabExec(u??`t0`,`cookies`,`clear`,a),l.resetIdleTimer(),N(`Deleted cookie ${a}`,{deleted:a})):N(`delete-cookie requires name`,{error:`name required`});case`clear-cookies`:return await l.tabExec(u??`t0`,`cookies`,`clear`),l.resetIdleTimer(),N(`Cookies cleared`,{cleared:!0});case`get-storage`:{if(!o||!s)return N(`get-storage requires storageType and storageKey`,{error:`storageType and storageKey required`});let e=await l.tabExec(u??`t0`,`storage`,o===`localStorage`?`local`:`session`,`get`,s);return l.resetIdleTimer(),N(e.stdout,{value:e.stdout})}case`set-storage`:return!o||!s||c===void 0?N(`set-storage requires storageType, storageKey, and storageValue`,{error:`storageType, storageKey, storageValue required`}):(await l.tabExec(u??`t0`,`storage`,o===`localStorage`?`local`:`session`,`set`,s,c),l.resetIdleTimer(),N(`Storage key ${s} set`,{key:s}));case`clear-storage`:return o?(await l.tabExec(u??`t0`,`storage`,o===`localStorage`?`local`:`session`,`clear`),l.resetIdleTimer(),N(`Storage cleared`,{cleared:!0})):N(`clear-storage requires storageType`,{error:`storageType required`});default:return N(`Unknown session action`,{error:`Unknown session action`})}}}const F=[`open`,`batch`,`read`,`act`,`navigate`,`network`,`console`,`fetch`,`eval`,`diff`,`screenshot`,`dialog`,`session`],I=[`ui`,`headless`],L=[`load`,`domcontentloaded`,`networkidle`],R=[`click`,`type`,`press`,`hover`,`drag`,`select`,`scroll`,`upload`],z=[`back`,`forward`,`reload`,`waitFor`],B=[`enable`,`get`,`clear`,`export-har`],V=[`enable`,`get`,`clear`],H=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`HEAD`,`OPTIONS`],U=[`list`,`close`,`cookies`,`set-cookie`,`delete-cookie`,`clear-cookies`,`get-storage`,`set-storage`,`clear-storage`],Ae={action:f.enum(F).describe(`Browser action to perform`),pageId:f.string().optional().describe(`Tracked browser page identifier`),label:f.string().optional().describe(`Human-readable label for the page (used as alternative to pageId)`),url:f.string().url().optional().describe(`URL to open or navigate to`),mode:f.enum(I).optional().describe(`Browser launch mode (open only)`),forceNew:f.boolean().optional().describe(`Reserved for future tab reuse`),autoDialog:f.boolean().optional().describe(`Auto-accept alert/beforeunload dialogs (default: true). Set false to handle all dialogs manually.`),waitUntil:f.enum(L).optional().describe(`Navigation readiness event`),kind:f.enum(R).optional().describe(`Interaction kind (act only)`),ref:f.string().optional().describe(`Target ref alias`),selector:f.string().optional().describe(`CSS selector for targeting`),element:f.string().optional().describe(`Human-readable element label. Prefer selector for precision.`),text:f.string().optional().describe(`Text to type`),key:f.string().optional().describe(`Key to press`),value:f.string().optional().describe(`Option value or drag target`),fromRef:f.string().optional().describe(`Drag source ref`),fromSelector:f.string().optional().describe(`Drag source selector`),toRef:f.string().optional().describe(`Drag target ref`),toSelector:f.string().optional().describe(`Drag target selector`),type:f.enum(z).optional().describe(`Navigation type`),subAction:f.enum(B).optional().describe(`Network sub-action: enable, get, clear, or export-har`),code:f.string().optional().describe(`JavaScript expression or IIFE evaluated in page context.`),timeoutMs:f.number().min(1).max(6e4).optional().describe(`Timeout in milliseconds`),filter:f.object({resourceTypes:f.array(f.string()).optional(),urlPattern:f.string().optional(),excludeUrls:f.array(f.string()).optional()}).optional().describe(`Network capture filter for resource types and URL patterns`),showSensitive:f.boolean().optional().describe(`Include sensitive headers instead of redacting them`),includeBody:f.boolean().optional().describe(`Include truncated request bodies in captured entries`),bufferSize:f.number().int().min(1).max(1e4).optional().describe(`Buffer capacity (1-10000, default varies by action)`),consoleSubAction:f.enum(V).optional().describe(`Console sub-action: enable, get, or clear`),level:f.string().optional().describe(`Filter console entries by level (log/info/warn/error/debug)`),fetchUrl:f.string().optional().describe(`URL for fetch action (http/https only). Uses page cookies/session.`),fetchMethod:f.enum(H).optional().describe(`HTTP method for fetch action (default: GET)`),fetchHeaders:f.record(f.string(),f.string()).optional().describe(`Custom headers for fetch action`),fetchBody:f.string().optional().describe(`Request body for fetch action (POST/PUT/PATCH)`),includeResponseHeaders:f.boolean().optional().describe(`Include response headers in fetch output (default: true)`),fullPage:f.boolean().optional().describe(`Capture full page`),redactPasswords:f.boolean().optional().describe(`Mask password fields`),readMode:f.enum([`snapshot`,`dom`,`markdown`,`text`]).optional().describe(`Extraction mode for read action: snapshot (ARIA tree), dom (HTML), markdown (clean MD), text (plain text)`),clip:f.object({x:f.number(),y:f.number(),width:f.number(),height:f.number()}).optional().describe(`Capture a specific page region { x, y, width, height }`),format:f.enum([`png`,`jpeg`]).optional().describe(`Screenshot image format (default: png)`),quality:f.number().min(0).max(100).optional().describe(`JPEG quality 0-100 (only for jpeg format)`),cookies:f.array(f.object({name:f.string(),value:f.string(),url:f.string().optional(),domain:f.string().optional(),path:f.string().optional(),expires:f.number().optional(),httpOnly:f.boolean().optional(),secure:f.boolean().optional(),sameSite:f.enum([`Lax`,`None`,`Strict`]).optional()})).optional().describe(`Cookies to set (for session set-cookie action)`),name:f.string().optional().describe(`Cookie name for delete-cookie action`),storageType:f.enum([`localStorage`,`sessionStorage`]).optional().describe(`Storage type for get/set/clear-storage actions`),storageKey:f.string().optional().describe(`Storage key to get or set`),storageValue:f.string().optional().describe(`Value to set in storage`),accept:f.boolean().optional().describe(`Accept or dismiss dialog`),promptText:f.string().optional().describe(`Text for prompt dialog`),sessionAction:f.enum(U).optional().describe(`Session sub-action (session only)`),confirm:f.boolean().optional().describe(`Explicit confirmation for cookie export`),steps:f.array(f.record(f.string(),f.unknown())).optional().describe(`Array of action steps for batch execution. Each step is an object with action + action-specific params.`)};function W(e,t){return typeof e==`string`&&t.includes(e)}function G(e,t,n){let r=e[t];if(typeof r!=`string`)throw Error(`${n} requires ${t}`);return r}function je(e,t,n){let r=e[t];if(typeof r!=`boolean`)throw Error(`${n} requires ${t}`);return r}function K(e,t){let n=e[t];return typeof n==`string`?n:void 0}function q(e,t){let n=e[t];return typeof n==`boolean`?n:void 0}function J(e,t){let n=e[t];return typeof n==`number`?n:void 0}function Y(e,t){let n=e[t];return typeof n==`object`&&n?n:void 0}function Me(e,t){let n=e.steps;if(!Array.isArray(n)||n.length===0)throw Error(`${t} requires non-empty steps`);return n.map((e,n)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`${t} step ${n+1} must be an object`);return e})}function X(e,t,n,r){let i=e[t];if(!W(i,n))throw Error(`${r} requires ${t}`);return i}function Z(e,t,n,r){let i=e[t];if(i!==void 0){if(!W(i,n))throw Error(`${r} received invalid ${t}`);return i}}function Ne(e,t){let n=K(e,`pageId`);if(n)return E(t).resolvePageId(n)}function Q(e,t,n){let r=K(e,`pageId`);if(!r)throw Error(`${n} requires pageId`);return E(t).resolvePageId(r)}async function $(e,t,n){let r=X(e,`action`,F,`browser`);switch(r){case`open`:return t.openHandler({url:G(e,`url`,`browser(open)`),mode:Z(e,`mode`,I,`browser(open)`),forceNew:q(e,`forceNew`),label:K(e,`label`),autoDialog:q(e,`autoDialog`),waitUntil:Z(e,`waitUntil`,L,`browser(open)`)});case`batch`:{let r=Me(e,`browser(batch)`),i=[],a=0;for(let e=0;e<r.length;e+=1){let o=r[e],s=K(o,`action`)??`unknown`;try{let r=await $(o,t,n);a+=1,i.push({index:e,action:s,ok:!0,result:r})}catch(t){i.push({index:e,action:s,ok:!1,error:t instanceof Error?t.message:String(t)})}}return N(`Batch completed: ${a}/${r.length} steps succeeded`,{total:r.length,succeeded:a,steps:i})}case`read`:return t.readHandler({pageId:Q(e,n,`browser(read)`),mode:Z(e,`readMode`,[`snapshot`,`dom`,`markdown`,`text`],`browser(read)`),selector:K(e,`selector`)});case`act`:return t.actHandler({pageId:Q(e,n,`browser(act)`),kind:X(e,`kind`,R,`browser(act)`),ref:K(e,`ref`),selector:K(e,`selector`),element:K(e,`element`),text:K(e,`text`),key:K(e,`key`),value:K(e,`value`),fromRef:K(e,`fromRef`),fromSelector:K(e,`fromSelector`),toRef:K(e,`toRef`),toSelector:K(e,`toSelector`)});case`navigate`:return t.navigateHandler({pageId:Q(e,n,`browser(navigate)`),url:K(e,`url`),type:Z(e,`type`,z,`browser(navigate)`),selector:K(e,`selector`),timeoutMs:J(e,`timeoutMs`)});case`network`:return t.networkHandler({pageId:Q(e,n,`browser(network)`),subAction:X(e,`subAction`,B,`browser(network)`),filter:Y(e,`filter`),showSensitive:q(e,`showSensitive`),includeBody:q(e,`includeBody`),bufferSize:J(e,`bufferSize`)});case`console`:return t.consoleHandler({pageId:Q(e,n,`browser(console)`),subAction:X(e,`consoleSubAction`,V,`browser(console)`),level:K(e,`level`),bufferSize:J(e,`bufferSize`)});case`fetch`:return t.fetchHandler({pageId:Q(e,n,`browser(fetch)`),url:G(e,`fetchUrl`,`browser(fetch)`),method:Z(e,`fetchMethod`,H,`browser(fetch)`),headers:Y(e,`fetchHeaders`),body:K(e,`fetchBody`),timeoutMs:J(e,`timeoutMs`),includeHeaders:q(e,`includeResponseHeaders`)});case`eval`:return t.evalHandler({pageId:Q(e,n,`browser(eval)`),code:G(e,`code`,`browser(eval)`),timeoutMs:J(e,`timeoutMs`)});case`diff`:return t.diffHandler({pageId:Q(e,n,`browser(diff)`)});case`screenshot`:{let r=Y(e,`clip`);return t.screenshotHandler({pageId:Q(e,n,`browser(screenshot)`),ref:K(e,`ref`),selector:K(e,`selector`),fullPage:q(e,`fullPage`),redactPasswords:q(e,`redactPasswords`),clip:r,format:Z(e,`format`,[`png`,`jpeg`],`browser(screenshot)`),quality:J(e,`quality`)})}case`dialog`:return t.dialogHandler({pageId:Q(e,n,`browser(dialog)`),accept:je(e,`accept`,`browser(dialog)`),promptText:K(e,`promptText`)});case`session`:return t.sessionHandler({sessionAction:X(e,`sessionAction`,U,`browser(session)`),pageId:K(e,`pageId`)&&Ne(e,n),confirm:q(e,`confirm`),cookies:Y(e,`cookies`),name:K(e,`name`),storageType:Z(e,`storageType`,[`localStorage`,`sessionStorage`],`browser(session)`),storageKey:K(e,`storageKey`),storageValue:K(e,`storageValue`)});default:return N(`Unknown action: ${r}`,{error:`Unknown action: ${r}`})}}function Pe(e,t){let n=ge(t),r={openHandler:Ee(n),readHandler:De(n),actHandler:_e(n),navigateHandler:we(n),networkHandler:Te(n),consoleHandler:ve(n),fetchHandler:Se(n),evalHandler:xe(n),diffHandler:be(n),screenshotHandler:Oe(n),dialogHandler:ye(n),sessionHandler:ke(n)};e.tool(`browser`,`Unified browser automation tool using agent-browser (Chrome DevTools Protocol). Provides open, read, act, navigate, screenshot, eval, dialog, network, console, fetch, diff, session actions.`,Ae,async e=>{try{let t=await $(e,r,n);return{content:t.content,structuredContent:t.structuredContent}}catch(e){return{content:[{type:`text`,text:`Browser error: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}export{de as BrowserEngine,w as DEFAULT_BROWSER_CONFIG,ue as SessionRegistry,C as TabRegistry,x as autoSelectMode,fe as closeEngine,b as ensureAgentBrowserInstalled,oe as getAgentBrowserVersion,S as getDaemonArgs,h as getDefaultBrowsersPath,E as getEngine,le as getLaunchArgs,se as isBrowserReady,D as isUrlAllowed,Pe as registerBrowserTools,g as resolveBrowsersPath,pe as validateEvalResult};
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
<button class="cp-btn cp-btn--remove" aria-label="Remove selection without comment">Remove</button>
|
|
106
106
|
<button class="cp-btn cp-btn--comment" aria-label="Submit comment">Comment</button>
|
|
107
107
|
</div>
|
|
108
|
-
`,this.textarea=this.el.querySelector(".cp-textarea");let n=this.el.querySelector(".cp-btn--comment"),a=this.el.querySelector(".cp-btn--remove"),
|
|
108
|
+
`,this.textarea=this.el.querySelector(".cp-textarea");let n=this.el.querySelector(".cp-btn--comment"),a=this.el.querySelector(".cp-btn--remove"),i=this.el.querySelector(".cp-btn--cancel");this.backdrop.addEventListener("click",()=>this.handleCancel()),n.addEventListener("click",()=>this.handleComment()),a.addEventListener("click",()=>this.handleRemove()),i.addEventListener("click",()=>this.handleCancel()),this.textarea.addEventListener("keydown",o=>this.handleKeyDown(o)),document.body.appendChild(this.backdrop),document.body.appendChild(this.el),this.positionNearSelection(),this.textarea.focus(),this.el.addEventListener("keydown",o=>{if(o.key!=="Tab")return;let r=this.el.querySelectorAll('button, textarea, [tabindex]:not([tabindex="-1"])');if(r.length===0)return;let s=r[0],p=r[r.length-1];o.shiftKey&&document.activeElement===s?(o.preventDefault(),p.focus()):!o.shiftKey&&document.activeElement===p&&(o.preventDefault(),s.focus())})}destroy(){this.backdrop.remove(),this.el.remove()}escapeText(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}positionNearSelection(){let t=this.result.range.getBoundingClientRect(),e=window.scrollX,n=window.scrollY,a=this.el.offsetWidth||320,i=this.el.offsetHeight||260,o=8,r=t.left+e+t.width/2-a/2;r=Math.max(o,r),r=Math.min(r,window.innerWidth+e-a-o);let s=window.innerHeight+n,p=t.bottom+n+o,c;p+i<=s?c=p:(c=t.top+n-i-o,c=Math.max(o,c)),this.el.style.left=`${r}px`,this.el.style.top=`${c}px`}handleComment(){let t=this.textarea.value.trim();this.options.onSubmit(this.result,t)}handleRemove(){let t=this.textarea.value.trim();this.options.onRemove(this.result,t)}handleCancel(){this.options.onDismiss()}handleKeyDown(t){t.key==="Escape"?(t.preventDefault(),this.handleCancel()):(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),this.handleComment())}};var x=class{constructor(t){d(this,"store");this.store=t}exportMarkdown(){let e=[...this.store.getState().annotations].sort((o,r)=>o.createdAt-r.createdAt);if(e.length===0)return"No feedback provided.";let n=e.filter(o=>o.type==="COMMENT"),a=e.filter(o=>o.type==="DELETION"),i=["## Reviewer Feedback",""];if(n.length>0){i.push("### Comments","");for(let o of n){let r=o.originalText.length>80?`${o.originalText.slice(0,80)}\u2026`:o.originalText;i.push(`- **${o.comment}**`),i.push(` > "${r}"`),i.push("")}}if(a.length>0){i.push("### Deletions","");for(let o of a){let r=o.originalText.length>80?`${o.originalText.slice(0,80)}\u2026`:o.originalText;i.push("- Remove this"),i.push(` > "${r}"`),i.push("")}}return i.join(`
|
|
109
109
|
`).trimEnd()}exportJSON(){let e=[...this.store.getState().annotations].sort((n,a)=>n.createdAt-a.createdAt);return JSON.stringify(e,null,2)}submitFeedback(t){let e=this.exportMarkdown(),n=this.exportJSON(),a=e==="No feedback provided."?e:`${e}
|
|
110
110
|
|
|
111
111
|
\`\`\`json
|
|
112
112
|
${n}
|
|
113
|
-
\`\`\``;t("annotations",a)}getTotalCount(){let t=this.store.getState(),e=t.annotations.filter(a=>a.type==="COMMENT").length,n=t.annotations.filter(a=>a.type==="DELETION").length;return{comments:e,deletions:n,total:t.annotations.length}}};var
|
|
113
|
+
\`\`\``;t("annotations",a)}getTotalCount(){let t=this.store.getState(),e=t.annotations.filter(a=>a.type==="COMMENT").length,n=t.annotations.filter(a=>a.type==="DELETION").length;return{comments:e,deletions:n,total:t.annotations.length}}};var w="aikit-annotation-highlight";function B(){if(document.getElementById(w))return;let l=document.createElement("style");l.id=w,l.textContent=`
|
|
114
114
|
mark.hl-COMMENT {
|
|
115
115
|
background: var(--dt-annotation-comment-bg, rgba(88, 166, 255, 0.15));
|
|
116
116
|
border-bottom: 2px solid var(--dt-annotation-comment, #58a6ff);
|
|
@@ -151,7 +151,7 @@ ${n}
|
|
|
151
151
|
50% { transform: scale(1.05); }
|
|
152
152
|
100% { transform: scale(1); }
|
|
153
153
|
}
|
|
154
|
-
`,document.head.appendChild(l)}var y=class{constructor(t,e){d(this,"container");d(this,"store");d(this,"unsubscribe",null);this.container=t,this.store=e}start(){B(),this.unsubscribe=this.store.subscribe(t=>{switch(t.type){case"annotation-added":this.createHighlight(t.annotation);break;case"annotation-removed":this.removeHighlight(t.id);break;case"selection-changed":this.updateSelection(t.id),t.id!==null&&this.scrollToAnnotation(t.id);break}})}stop(){this.unsubscribe?.(),this.unsubscribe=null,this.clearAll()}findTextNodeRange(t,e,n){let a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null),
|
|
154
|
+
`,document.head.appendChild(l)}var y=class{constructor(t,e){d(this,"container");d(this,"store");d(this,"unsubscribe",null);this.container=t,this.store=e}start(){B(),this.unsubscribe=this.store.subscribe(t=>{switch(t.type){case"annotation-added":this.createHighlight(t.annotation);break;case"annotation-removed":this.removeHighlight(t.id);break;case"selection-changed":this.updateSelection(t.id),t.id!==null&&this.scrollToAnnotation(t.id);break}})}stop(){this.unsubscribe?.(),this.unsubscribe=null,this.clearAll()}findTextNodeRange(t,e,n){let a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null),i=0,o=null,r=0,s=null,p=0,c=a.nextNode();for(;c;){let f=(c.textContent||"").length,m=i+f;if(o===null&&m>e&&(o=c,r=e-i),m>=n){s=c,p=n-i;break}i=m,c=a.nextNode()}if(!o||!s)return null;let u=document.createRange();return u.setStart(o,Math.min(r,(o.textContent||"").length)),u.setEnd(s,Math.min(p,(s.textContent||"").length)),u}createHighlight(t){let e=this.container.querySelector(`[data-block-id="${t.blockId}"]`);if(!e){console.warn(`[HighlightManager] Block not found for annotation ${t.id}: ${t.blockId}`);return}let n=this.findTextNodeRange(e,t.startOffset,t.endOffset);if(!n){console.warn(`[HighlightManager] Could not resolve text range for annotation ${t.id}`);return}let a=document.createElement("mark");a.className=`hl-${t.type}`,a.dataset.annotationId=t.id,a.addEventListener("click",()=>{this.store.select(t.id)});try{n.surroundContents(a)}catch{try{if(n.endContainer.nodeType===Node.TEXT_NODE&&n.endContainer.splitText(n.endOffset),n.startContainer.nodeType===Node.TEXT_NODE){let i=n.startContainer;n.startOffset>0&&i.splitText(n.startOffset);let o=document.createRange();o.setStart(i.nextSibling||i,0),o.setEnd(n.endContainer.nodeType===Node.TEXT_NODE&&n.endContainer.previousSibling||n.endContainer,n.endOffset),o.surroundContents(a)}else throw new Error("Non-text range")}catch{let i=n.extractContents();a.append(i),n.insertNode(a)}}}removeHighlight(t){let e=this.container.querySelector(`mark[data-annotation-id="${t}"]`);if(!e)return;let n=e.parentNode;if(n){for(;e.firstChild;)n.insertBefore(e.firstChild,e);n.removeChild(e),n.nodeType===Node.ELEMENT_NODE&&n.normalize()}}updateSelection(t){let e=this.container.querySelectorAll("mark[data-annotation-id]");for(let n of e)n.classList.toggle("hl-selected",n.dataset.annotationId===t)}scrollToAnnotation(t){let e=this.container.querySelector(`mark[data-annotation-id="${t}"]`);e&&(e.scrollIntoView({behavior:"smooth",block:"center"}),e.classList.add("annotation-pulse"),setTimeout(()=>{e.classList.remove("annotation-pulse")},600))}clearAll(){let t=this.container.querySelectorAll("mark[data-annotation-id]");for(let e of t){let n=e.parentNode;if(n){for(;e.firstChild;)n.insertBefore(e.firstChild,e);n.removeChild(e),n.nodeType===Node.ELEMENT_NODE&&n.normalize()}}}};var I=new Set(["button","input","textarea","select"]),E=class{constructor(t){d(this,"options");d(this,"boundHandleMouseUp");this.options=t,this.boundHandleMouseUp=this.handleMouseUp.bind(this),this.options.container.addEventListener("mouseup",this.boundHandleMouseUp,{passive:!0})}destroy(){this.options.container.removeEventListener("mouseup",this.boundHandleMouseUp)}handleMouseUp(t){if(this.options.mode()==="selection")return;let e=t.target;if(!e||this.isExcludedElement(e))return;let n=this.getSelectionRange();if(!n)return;let a=this.findBlockId(n.startContainer);if(!a)return;let i=this.findBlockContainer(n.startContainer),o=this.findBlockContainer(n.endContainer);if(i!==o)return;let r=this.computeBlockOffset(n.startContainer,n.startOffset),s=this.computeBlockOffset(n.endContainer,n.endOffset);if(r===null||s===null)return;let p={blockId:a,startOffset:r,endOffset:s,text:n.toString(),range:n};this.options.onSelection(p),this.clearSelection()}getSelectionRange(){let t=window.getSelection();return!t||t.isCollapsed||t.rangeCount===0?null:t.getRangeAt(0)}findBlockId(t){let e=t;for(;e;){if(e instanceof HTMLElement&&e.hasAttribute("data-block-id"))return e.getAttribute("data-block-id");e=e.parentNode}return null}computeBlockOffset(t,e){let n=this.findBlockContainer(t);if(!n)return null;let a=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null),i=0,o=a.nextNode();for(;o;){if(o===t)return i+e;i+=(o.textContent||"").length,o=a.nextNode()}return null}findBlockContainer(t){let e=t;for(;e;){if(e instanceof HTMLElement&&e.hasAttribute("data-block-id"))return e;e=e.parentNode}return null}clearSelection(){let t=window.getSelection();t&&t.removeAllRanges()}isExcludedElement(t){let e=t;for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e?I.has(e.tagName.toLowerCase()):!1}};var z="aikit-annotation-sidebar",D=`
|
|
155
155
|
.as-sidebar {
|
|
156
156
|
width: var(--dt-annotation-sidebar-width, 300px);
|
|
157
157
|
background: var(--dt-bg-secondary);
|
|
@@ -333,7 +333,7 @@ ${n}
|
|
|
333
333
|
font-size: var(--dt-font-size-sm);
|
|
334
334
|
padding: var(--dt-space-6) var(--dt-space-2);
|
|
335
335
|
}
|
|
336
|
-
`,R='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"/></svg>',k=class{constructor(t){d(this,"el");d(this,"store");d(this,"exporter");d(this,"unsubscribe",null);d(this,"listEl");d(this,"modeToggleBtn");this.store=t.store,this.exporter=t.exporter,this.el=this.render(),this.listEl=this.el.querySelector(".as-list"),this.modeToggleBtn=this.el.querySelector(".as-mode-toggle"),this.unsubscribe=this.store.subscribe(n=>{switch(n.type){case"annotation-added":case"annotation-removed":case"annotation-updated":this.renderList(),this.updateHeader();break;case"selection-changed":this.updateCardSelection(n.id);break;case"sidebar-toggled":this.updateVisibility();break;case"mode-changed":this.updateModeToggle();break}}),(t.mountTarget??document.body).appendChild(this.el),this.updateVisibility(),this.updateModeToggle()}destroy(){this.unsubscribe?.(),this.el.remove()}render(){b(
|
|
336
|
+
`,R='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"/></svg>',k=class{constructor(t){d(this,"el");d(this,"store");d(this,"exporter");d(this,"unsubscribe",null);d(this,"listEl");d(this,"modeToggleBtn");this.store=t.store,this.exporter=t.exporter,this.el=this.render(),this.listEl=this.el.querySelector(".as-list"),this.modeToggleBtn=this.el.querySelector(".as-mode-toggle"),this.unsubscribe=this.store.subscribe(n=>{switch(n.type){case"annotation-added":case"annotation-removed":case"annotation-updated":this.renderList(),this.updateHeader();break;case"selection-changed":this.updateCardSelection(n.id);break;case"sidebar-toggled":this.updateVisibility();break;case"mode-changed":this.updateModeToggle();break}}),(t.mountTarget??document.body).appendChild(this.el),this.updateVisibility(),this.updateModeToggle()}destroy(){this.unsubscribe?.(),this.el.remove()}render(){b(z,D);let t=document.createElement("div");t.className="as-sidebar",t.setAttribute("role","complementary"),t.setAttribute("aria-label","Annotations");let e=this.exporter.getTotalCount();return t.innerHTML=`
|
|
337
337
|
<div class="as-header">
|
|
338
338
|
<span class="as-header-title">Annotations</span>
|
|
339
339
|
<span class="as-count-badge" aria-live="polite">${e.total}</span>
|
|
@@ -342,12 +342,12 @@ ${n}
|
|
|
342
342
|
<button class="as-close-btn" aria-label="Close sidebar">×</button>
|
|
343
343
|
</div>
|
|
344
344
|
<div class="as-list" role="list" aria-label="Annotation list"></div>
|
|
345
|
-
`,t.querySelector(".as-close-btn").addEventListener("click",
|
|
345
|
+
`,t.querySelector(".as-close-btn").addEventListener("click",i=>{i.stopPropagation(),this.store.toggleSidebar(!1)}),t.querySelector(".as-mode-toggle").addEventListener("click",i=>{i.stopPropagation();let o=this.store.getState().mode==="feedback"?"selection":"feedback";this.store.setMode(o)}),t}renderList(){let e=this.store.getState().annotations;if(this.listEl.innerHTML="",e.length===0){let a=document.createElement("div");a.className="as-empty",a.textContent="No annotations yet. Select text in Feedback mode.",this.listEl.appendChild(a);return}let n=[...e].sort((a,i)=>i.createdAt-a.createdAt);for(let a of n)this.listEl.appendChild(this.renderAnnotationItem(a))}renderAnnotationItem(t){let e=document.createElement("div");e.className=`as-card as-card--${t.type}`,e.dataset.annotationId=t.id,this.store.getState().selectedId===t.id&&e.classList.add("as-card--selected");let a=t.originalText.length>60?`${t.originalText.slice(0,60)}\u2026`:t.originalText;return e.innerHTML=`
|
|
346
346
|
<div class="as-card-excerpt">${g(a)}</div>
|
|
347
347
|
${t.comment?`<div class="as-card-comment">${g(t.comment)}</div>`:""}
|
|
348
348
|
<div class="as-card-comment-detail">${t.comment?g(t.comment):'<em style="color:var(--dt-text-tertiary)">No comment \u2014 marked text only</em>'}</div>
|
|
349
349
|
<button class="as-delete-btn" aria-label="Delete annotation">×</button>
|
|
350
|
-
`,e.addEventListener("click",()=>{this.store.select(t.id);let o=e.querySelector(".as-card-comment-detail");if(o){o.classList.toggle("as-card-comment-detail--open");let
|
|
350
|
+
`,e.addEventListener("click",()=>{this.store.select(t.id);let o=e.querySelector(".as-card-comment-detail");if(o){o.classList.toggle("as-card-comment-detail--open");let r=this.listEl.querySelectorAll(".as-card-comment-detail--open");for(let s of r)s!==o&&s.classList.remove("as-card-comment-detail--open")}}),e.querySelector(".as-delete-btn").addEventListener("click",o=>{o.stopPropagation(),this.handleDelete(t.id)}),e}handleDelete(t){this.store.remove(t)}updateVisibility(){let t=this.store.getState();this.el.style.display=t.isSidebarOpen?"flex":"none"}updateHeader(){let t=this.el.querySelector(".as-count-badge");if(t){let e=this.exporter.getTotalCount();t.textContent=String(e.total)}}updateModeToggle(){let t=this.store.getState().mode==="feedback";this.modeToggleBtn.classList.toggle("as-mode-toggle--active",t),this.modeToggleBtn.setAttribute("aria-pressed",String(t)),this.modeToggleBtn.setAttribute("aria-label",t?"Disable annotation mode":"Enable annotation mode")}updateCardSelection(t){let e=this.el.querySelectorAll(".as-card");for(let n of e){let a=n.dataset.annotationId;n.classList.toggle("as-card--selected",a!==void 0&&a===t)}}};var T=class{constructor(){d(this,"annotations",[]);d(this,"selectedId",null);d(this,"mode","selection");d(this,"isSidebarOpen",!1);d(this,"subscribers",new Set);d(this,"idCounter",0)}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}notify(t){for(let e of this.subscribers)e(t)}generateId(){return this.idCounter+=1,`ann-${this.idCounter}`}openSidebar(){this.isSidebarOpen=!0,this.notify({type:"sidebar-toggled",open:!0})}add(t,e,n,a,i,o,r,s,p){let c={id:this.generateId(),type:t,blockId:e,startOffset:n,endOffset:a,originalText:i,comment:o,section:r,contextBefore:s,contextAfter:p,createdAt:Date.now()};return this.annotations.push(c),this.annotations.length===1&&(this.isSidebarOpen=!0,this.notify({type:"sidebar-toggled",open:!0})),this.notify({type:"annotation-added",annotation:c}),c}update(t,e){let n=this.annotations.find(a=>a.id===t);n&&(Object.assign(n,e),this.notify({type:"annotation-updated",id:t,changes:e}))}remove(t){let e=this.annotations.findIndex(n=>n.id===t);e!==-1&&(this.annotations.splice(e,1),this.notify({type:"annotation-removed",id:t}))}select(t){this.selectedId=t,this.notify({type:"selection-changed",id:t})}setMode(t){t!==this.mode&&(this.mode=t,this.notify({type:"mode-changed",mode:t}))}toggleSidebar(t){this.isSidebarOpen=t!==void 0?t:!this.isSidebarOpen,this.notify({type:"sidebar-toggled",open:this.isSidebarOpen})}getState(){return{annotations:[...this.annotations],selectedId:this.selectedId,mode:this.mode,isSidebarOpen:this.isSidebarOpen}}destroy(){this.subscribers.clear(),this.annotations=[],this.selectedId=null,this.mode="selection",this.isSidebarOpen=!1,this.idCounter=0}};var M=25,$="aikit-annotation-guide",q=`
|
|
351
351
|
.as-guide {
|
|
352
352
|
margin: 0 0 var(--dt-space-3) 0;
|
|
353
353
|
padding: var(--dt-space-2) var(--dt-space-3);
|
|
@@ -364,7 +364,7 @@ ${n}
|
|
|
364
364
|
.as-guide--visible {
|
|
365
365
|
display: block;
|
|
366
366
|
}
|
|
367
|
-
`;function _(l){let{range:t}=l,e,n=t.startContainer;for(;n;){if(n instanceof HTMLElement&&n.tagName.toLowerCase().match(/^h[1-6]$/)){e=n.textContent?.trim()||void 0;break}n=n.parentNode}let a,
|
|
367
|
+
`;function _(l){let{range:t}=l,e,n=t.startContainer;for(;n;){if(n instanceof HTMLElement&&n.tagName.toLowerCase().match(/^h[1-6]$/)){e=n.textContent?.trim()||void 0;break}n=n.parentNode}let a,i;try{if(t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset>0){let o=t.startContainer.textContent||"",r=Math.max(0,t.startOffset-M);a=o.slice(r,t.startOffset)}if(t.endContainer.nodeType===Node.TEXT_NODE&&t.endOffset<(t.endContainer.textContent?.length||0)){let o=t.endContainer.textContent||"",r=Math.min(o.length,t.endOffset+M);i=o.slice(t.endOffset,r)}}catch{}return{section:e,contextBefore:a,contextAfter:i}}function L(l){let{container:t,mountTarget:e}=l,n=null,a=new T;a.setMode("feedback");let i=new x(a);b($,q);let o=document.createElement("div");o.className="as-guide",o.textContent="\u27B3 Ready. Select text to annotate or disable Feedback in the sidebar.",t.prepend(o);let r=()=>{let u=a.getState();o.classList.toggle("as-guide--visible",u.mode==="feedback"&&u.annotations.length===0)};r(),a.subscribe(()=>r());let s=new y(t,a);s.start();let p=new E({container:t,mode:()=>a.getState().mode,onSelection:u=>{let f=_(u);n?.destroy();let m=new v(u,{onSubmit:(h,S)=>{a.add("COMMENT",h.blockId,h.startOffset,h.endOffset,h.text,S||void 0,f.section,f.contextBefore,f.contextAfter),m.destroy(),n===m&&(n=null)},onRemove:(h,S)=>{a.add("DELETION",h.blockId,h.startOffset,h.endOffset,h.text,S||void 0,f.section,f.contextBefore,f.contextAfter),m.destroy(),n===m&&(n=null)},onDismiss:()=>{m.destroy(),n===m&&(n=null)}});n=m}}),c=new k({store:a,exporter:i,mountTarget:e});return a.openSidebar(),{destroy(){n?.destroy(),n=null,o.remove(),p.destroy(),s.stop(),c.destroy(),a.destroy()},getStore(){return a},getExporter(){return i}}}document.addEventListener("DOMContentLoaded",()=>{let l=document.querySelector(".content")||document.querySelector("main"),t=l||document.body;if(!l)return;let e=t.parentElement;e?.classList.contains("shell-layout")||(e=document.createElement("div"),e.className="shell-layout",t.parentNode?.insertBefore(e,t),e.appendChild(t));let n="aikit-shell-layout";if(!document.getElementById(n)){let o=document.createElement("style");o.id=n,o.textContent=`
|
|
368
368
|
.shell-layout {
|
|
369
369
|
flex: 1;
|
|
370
370
|
display: flex;
|
|
@@ -415,24 +415,40 @@ ${n}
|
|
|
415
415
|
border: none;
|
|
416
416
|
background: none;
|
|
417
417
|
}
|
|
418
|
-
/*
|
|
418
|
+
/* Compact controls in action bar \u2014 single-line inline layout */
|
|
419
419
|
.action-bar .present-action-btn {
|
|
420
420
|
padding: 0.375rem 0.75rem;
|
|
421
421
|
font-size: var(--dt-font-size-sm);
|
|
422
422
|
min-height: 2rem;
|
|
423
423
|
}
|
|
424
|
+
.action-bar .present-action-field {
|
|
425
|
+
display: inline-flex;
|
|
426
|
+
flex-direction: row;
|
|
427
|
+
align-items: center;
|
|
428
|
+
gap: 0.375rem;
|
|
429
|
+
min-width: 0;
|
|
430
|
+
}
|
|
431
|
+
.action-bar .present-action-field span {
|
|
432
|
+
font-size: var(--dt-font-size-xs);
|
|
433
|
+
white-space: nowrap;
|
|
434
|
+
color: var(--dt-text-secondary, #6b6a65);
|
|
435
|
+
}
|
|
424
436
|
.action-bar .present-action-field select {
|
|
425
437
|
font-size: var(--dt-font-size-sm);
|
|
426
438
|
min-height: 2rem;
|
|
427
439
|
padding: 0 0.5rem;
|
|
440
|
+
max-width: 10rem;
|
|
428
441
|
}
|
|
429
|
-
.action-bar .present-action-field
|
|
430
|
-
|
|
442
|
+
.action-bar .present-action-field select[multiple] {
|
|
443
|
+
max-width: 6rem;
|
|
444
|
+
max-height: 3rem;
|
|
445
|
+
padding: 0.125rem 0.25rem;
|
|
431
446
|
}
|
|
432
447
|
.action-bar .present-text-input {
|
|
433
448
|
font-size: var(--dt-font-size-sm);
|
|
434
449
|
min-height: 2rem;
|
|
435
450
|
padding: 0 0.5rem;
|
|
436
|
-
min-width:
|
|
451
|
+
min-width: 120px;
|
|
452
|
+
max-width: 200px;
|
|
437
453
|
}
|
|
438
|
-
`,document.head.appendChild(o)}let a=
|
|
454
|
+
`,document.head.appendChild(o)}let a=L({container:t,mountTarget:e});a.getStore().subscribe(o=>{o.type==="sidebar-toggled"&&document.documentElement.setAttribute("data-annotation-sidebar",o.open?"open":"")}),a.getStore().getState().isSidebarOpen&&document.documentElement.setAttribute("data-annotation-sidebar","open"),window.__annotationLayer=a;let i=document.querySelectorAll(".bk-actions");if(i.length>0){let o=document.createElement("div");o.className="action-bar";let r=!1;for(let s of i)if(!s.querySelector('input[type="text"], input:not([type]), textarea')){for(;s.firstChild;)o.appendChild(s.firstChild);s.remove(),r=!0}if(r){let s=document.querySelector("main")||document.querySelector(".content");s&&(s.appendChild(o),s.style.paddingBottom="0")}}});})();
|
|
@@ -5,4 +5,4 @@ import{fileURLToPath as e,pathToFileURL as t}from"node:url";import{parseArgs as
|
|
|
5
5
|
`).length,fileHash:this.hash(e.content),indexedAt:t,origin:`curated`,tags:e.frontmatter.tags,category:e.frontmatter.category,version:e.frontmatter.version}});try{return await this.store.upsert(i,r),e.length}catch(t){R.error(`Failed to upsert curated batch`,{batchSize:e.length,...a(t)});for(let t of e)n.push(`${t.relativePath}: upsert failed`);return 0}}catch(r){if(e.length===1)return R.error(`Failed to embed curated item`,{relativePath:e[0].relativePath,...a(r)}),n.push(`${e[0].relativePath}: reindex failed`),0;R.warn(`Curated embed batch failed, retrying with smaller chunks`,{batchSize:e.length,...a(r)});let i=Math.ceil(e.length/2),o=e.slice(0,i),s=e.slice(i);return await this.embedAndUpsertBatch(o,t,n)+await this.embedAndUpsertBatch(s,t,n)}}gitCommitKnowledge(e,t,n){try{if(!p(this.curatedDir))return;let r=this.knowledgeRefForPath(e);if(!r)return;m(r,`entry.md`,t,n,this.curatedDir)}catch{}}gitDeleteKnowledgeRef(e){try{if(!p(this.curatedDir))return;let t=this.knowledgeRefForPath(e);if(!t)return;h([`update-ref`,`-d`,t],this.curatedDir)}catch{}}knowledgeRefForPath(e){let t=e.replace(/\.md$/,``).split(`/`).map(e=>g(e)).join(`/`);return t.split(`/`).every(e=>f.test(e))?`${L}/${t}`:null}async indexCuratedFile(e,t,n){let r=await this.embedder.embed(t),i=`.ai/curated/${e}`,a=new Date().toISOString(),o={id:this.hashId(i,0),content:t,sourcePath:i,contentType:`curated-knowledge`,headingPath:n.title,chunkIndex:0,totalChunks:1,startLine:1,endLine:t.split(`
|
|
6
6
|
`).length,fileHash:this.hash(t),indexedAt:a,origin:`curated`,tags:n.tags,category:n.category,version:n.version};await this.store.upsert([o],[r])}async indexCuratedFileBestEffort(e,t,n,i){if(r.instance().isDegraded(`embedder`)){R.debug(`Skipping vector indexing — embedder degraded`,{relativePath:e,operation:i,subsystem:`embedder`});return}try{await this.indexCuratedFile(e,t,n)}catch(t){R.warn(`Curated file persisted but vector indexing deferred`,{relativePath:e,operation:i,...a(t)})}}async discoverCategories(){return this.adapter.listDirectories()}guardPath(e){let t=e.replace(/^\.ai\/curated\//,``);if(t.endsWith(`.md`)||(t+=`.md`),t.includes(`..`)||c(t))throw Error(`Invalid path: ${t}. Must be relative within .ai/curated/ directory.`);let n=t.split(`/`)[0];return this.validateCategoryName(n),t}validateCategoryName(e){if(!/^[a-z][a-z0-9-]*$/.test(e))throw Error(`Invalid category name: "${e}". Must be lowercase kebab-case (e.g., "decisions", "api-contracts").`)}validateContentSize(e){if(Buffer.byteLength(e,`utf-8`)>I)throw Error(`Content exceeds maximum size of ${I/1024}KB`)}slugify(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,80)}normalizeTags(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))]}sameTags(e,t){if(e.length!==t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}ensureCategoryPath(e,t){if(!e.startsWith(`${t}/`))throw Error(`Curated path "${e}" must stay within category "${t}"`)}async uniqueRelativePath(e,t){let n=`${e}/${t}.md`;if(!await this.adapter.exists(n))return n;for(let n=2;n<=100;n++){let r=`${e}/${t}-${n}.md`;if(!await this.adapter.exists(r))return r}throw Error(`Too many entries with slug "${t}" in category "${e}"`)}hash(e){return d(`sha256`).update(e).digest(`hex`).slice(0,16)}hashId(e,t){return this.hash(`${e}::${t}`)}serializeFile(e,t){return`${[`---`,`title: "${t.title.replace(/"/g,`\\"`)}"`,`category: ${t.category}`,`tags: [${t.tags.map(e=>`"${e}"`).join(`, `)}]`,`created: ${t.created}`,`updated: ${t.updated}`,`version: ${t.version}`,`origin: ${t.origin}`,`changelog:`,...t.changelog.map(e=>` - version: ${e.version}\n date: ${e.date}\n reason: "${e.reason.replace(/"/g,`\\"`)}"`),`---`].join(`
|
|
7
7
|
`)}\n\n${e}\n`}parseFile(e){let t=e.match(/^---\n([\s\S]*?)\n---\n\n?([\s\S]*)$/);if(!t)return{frontmatter:{title:`Untitled`,category:`notes`,tags:[],created:``,updated:``,version:1,origin:`curated`,changelog:[]},content:e};let n=t[1],r=t[2].trim(),i={},a=[],o=n.split(`
|
|
8
|
-
`),s=!1,c={};for(let e of o){if(/^changelog:\s*$/.test(e)){s=!0;continue}if(s){let t=e.match(/^\s+-\s+version:\s*(\d+)$/);if(t){c.version!=null&&a.push(c),c={version:parseInt(t[1],10)};continue}let n=e.match(/^\s+date:\s*(.+)$/);if(n){c.date=n[1].trim();continue}let r=e.match(/^\s+reason:\s*"?(.*?)"?\s*$/);if(r){c.reason=r[1];continue}/^\w/.test(e)&&(s=!1,c.version!=null&&a.push(c),c={});continue}let t=e.match(/^(\w+):\s*(.*)$/);if(t){let e=t[1],n=t[2];typeof n==`string`&&n.startsWith(`[`)&&n.endsWith(`]`)?n=n.slice(1,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``)).filter(e=>e.length>0):typeof n==`string`&&/^\d+$/.test(n)?n=parseInt(n,10):typeof n==`string`&&n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1)),i[e]=n}}return c.version!=null&&a.push(c),{frontmatter:{title:i.title??`Untitled`,category:i.category??`notes`,tags:i.tags??[],created:i.created??``,updated:i.updated??``,version:i.version??1,origin:`curated`,changelog:a},content:r}}};const B=i(`server`);function V(e,t){return t?{version:e,...a(t)}:{version:e}}function H(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function U(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===t(e).href}catch{return!1}}function W(){return U()?n({allowPositionals:!0,options:{transport:{type:`string`,default:H()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:H(),port:process.env.AIKIT_PORT??`3210`}}async function G(){let e=C(),t=W();if(process.on(`unhandledRejection`,t=>{B.error(`Unhandled rejection`,V(e,t))}),process.on(`uncaughtException`,t=>{B.error(`Uncaught exception — exiting`,V(e,t)),process.exit(1)}),B.info(`Starting MCP AI Kit server`,{version:e}),t.transport===`http`){let{startHttpMode:n}=await import(`./server-http-
|
|
8
|
+
`),s=!1,c={};for(let e of o){if(/^changelog:\s*$/.test(e)){s=!0;continue}if(s){let t=e.match(/^\s+-\s+version:\s*(\d+)$/);if(t){c.version!=null&&a.push(c),c={version:parseInt(t[1],10)};continue}let n=e.match(/^\s+date:\s*(.+)$/);if(n){c.date=n[1].trim();continue}let r=e.match(/^\s+reason:\s*"?(.*?)"?\s*$/);if(r){c.reason=r[1];continue}/^\w/.test(e)&&(s=!1,c.version!=null&&a.push(c),c={});continue}let t=e.match(/^(\w+):\s*(.*)$/);if(t){let e=t[1],n=t[2];typeof n==`string`&&n.startsWith(`[`)&&n.endsWith(`]`)?n=n.slice(1,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``)).filter(e=>e.length>0):typeof n==`string`&&/^\d+$/.test(n)?n=parseInt(n,10):typeof n==`string`&&n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1)),i[e]=n}}return c.version!=null&&a.push(c),{frontmatter:{title:i.title??`Untitled`,category:i.category??`notes`,tags:i.tags??[],created:i.created??``,updated:i.updated??``,version:i.version??1,origin:`curated`,changelog:a},content:r}}};const B=i(`server`);function V(e,t){return t?{version:e,...a(t)}:{version:e}}function H(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function U(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===t(e).href}catch{return!1}}function W(){return U()?n({allowPositionals:!0,options:{transport:{type:`string`,default:H()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:H(),port:process.env.AIKIT_PORT??`3210`}}async function G(){let e=C(),t=W();if(process.on(`unhandledRejection`,t=>{B.error(`Unhandled rejection`,V(e,t))}),process.on(`uncaughtException`,t=>{B.error(`Uncaught exception — exiting`,V(e,t)),process.exit(1)}),B.info(`Starting MCP AI Kit server`,{version:e}),t.transport===`http`){let{startHttpMode:n}=await import(`./server-http-Bbb9mzxV.js`);await n(e,t.port)}else{let{startStdioMode:t}=await import(`./server-stdio-DqqC5gDB.js`);await t(e)}}G();export{w as a,O as i,F as n,T as o,P as r,D as s,z as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./server-utils-De-aZNQa.js";import{n as a,r as o,t as s}from"./workspace-bootstrap-DupGrGox.js";import{t as c}from"./curated-manager-BrgM_znO.js";import{pathToFileURL as l}from"node:url";import{parseArgs as u}from"node:util";import{createLogger as d,serializeError as f}from"../../core/dist/index.js";const p=d(`server`);function m(e,t){return t?{version:e,...f(t)}:{version:e}}function h(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function g(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===l(e).href}catch{return!1}}function _(){return g()?u({allowPositionals:!0,options:{transport:{type:`string`,default:h()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:h(),port:process.env.AIKIT_PORT??`3210`}}async function v(){let e=t(),n=_();if(process.on(`unhandledRejection`,t=>{p.error(`Unhandled rejection`,m(e,t))}),process.on(`uncaughtException`,t=>{p.error(`Uncaught exception — exiting`,m(e,t)),process.exit(1)}),p.info(`Starting MCP AI Kit server`,{version:e}),n.transport===`http`){let{startHttpMode:t}=await import(`./server-http-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./server-utils-De-aZNQa.js";import{n as a,r as o,t as s}from"./workspace-bootstrap-DupGrGox.js";import{t as c}from"./curated-manager-BrgM_znO.js";import{pathToFileURL as l}from"node:url";import{parseArgs as u}from"node:util";import{createLogger as d,serializeError as f}from"../../core/dist/index.js";const p=d(`server`);function m(e,t){return t?{version:e,...f(t)}:{version:e}}function h(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function g(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===l(e).href}catch{return!1}}function _(){return g()?u({allowPositionals:!0,options:{transport:{type:`string`,default:h()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:h(),port:process.env.AIKIT_PORT??`3210`}}async function v(){let e=t(),n=_();if(process.on(`unhandledRejection`,t=>{p.error(`Unhandled rejection`,m(e,t))}),process.on(`uncaughtException`,t=>{p.error(`Uncaught exception — exiting`,m(e,t)),process.exit(1)}),p.info(`Starting MCP AI Kit server`,{version:e}),n.transport===`http`){let{startHttpMode:t}=await import(`./server-http-OJ2BorHy.js`);await t(e,n.port)}else{let{startStdioMode:t}=await import(`./server-stdio-CcuCPyku.js`);await t(e)}}export{c as CuratedKnowledgeManager,s as applyWorkspaceRoots,a as bootstrapWorkspaceRoots,i as createSlidingWindowRateLimiter,n as getSessionIdHeader,v as main,r as readPositiveIntEnv,t as readVersion,e as resolveCorsOrigin,o as selectWorkspaceRoot};
|