@usex/mikrotik-mcp 3.57.0 → 3.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +84 -64
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -15
- package/dist/shared/{cli-0ctwspf1.js → cli-2dyvnv9v.js} +1 -1
- package/dist/shared/{cli-thhk9f7n.js → cli-jq168zrj.js} +829 -597
- package/dist/shared/{library-jve65pzw.js → library-0zd2tej9.js} +1 -1
- package/dist/shared/{library-ymtf9zyk.js → library-21t1cncr.js} +828 -597
- package/dist/ui/aaa.html +1 -1
- package/dist/ui/connected-devices.html +1 -1
- package/dist/ui/dashboard.html +1 -1
- package/dist/ui/firewall-audit.html +1 -1
- package/dist/ui/firewall.html +1 -1
- package/dist/ui/interfaces.html +1 -1
- package/dist/ui/observability.html +1 -1
- package/dist/ui/records.html +1 -1
- package/package.json +1 -1
- package/schemas/README.md +5 -5
- package/schemas/config.schema.json +47 -10
- package/schemas/tool-catalog.json +2941 -736
- package/schemas/tools/check_server_pulse.json +12 -0
- package/schemas/tools/config_check_drift.json +5 -1
- package/schemas/tools/config_reconcile.json +3 -1
- package/schemas/tools/config_set_baseline.json +4 -1
- package/schemas/tools/correlate_events.json +4 -1
- package/schemas/tools/diagnose.json +3 -1
- package/schemas/tools/get_filter_rule.json +1 -1
- package/schemas/tools/memory_add_observations.json +7 -2
- package/schemas/tools/memory_create_entities.json +7 -2
- package/schemas/tools/memory_create_relations.json +8 -2
- package/schemas/tools/memory_delete_entities.json +3 -1
- package/schemas/tools/memory_delete_observations.json +7 -2
- package/schemas/tools/memory_delete_relations.json +8 -2
- package/schemas/tools/memory_open_nodes.json +3 -1
- package/schemas/tools/memory_search_nodes.json +3 -1
- package/schemas/tools/suggest_fix.json +3 -1
- package/schemas/tools/trace_path.json +5 -1
package/dist/ui/interfaces.html
CHANGED
|
@@ -116,7 +116,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
116
116
|
- omitted: host decides border`)}),I({method:V(`ui/request-display-mode`),params:I({mode:mv.describe(`The display mode being requested.`)})});var Av=I({mode:mv.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),jv=R([V(`model`),V(`app`)]).describe(`Tool visibility scope - who can access the tool.`);I({resourceUri:j().optional(),visibility:F(jv).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
117
117
|
- "model": Tool visible to and callable by the agent
|
|
118
118
|
- "app": Tool callable by the app from this server only`),csp:Jf().optional(),permissions:Jf().optional()}),I({mimeTypes:F(j()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),I({method:V(`ui/download-file`),params:I({contents:F(R([r_,i_])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),I({method:V(`ui/message`),params:I({role:V(`user`).describe(`Message role, currently only "user" is supported.`),content:F(a_).describe(`Message content blocks (text, image, etc.).`)})}),I({method:V(`ui/notifications/sandbox-resource-ready`),params:I({html:j().describe(`HTML content to load into the inner iframe.`),sandbox:j().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:yv.optional().describe(`CSP configuration from resource metadata.`),permissions:bv.optional().describe(`Sandbox permissions from resource metadata.`)})});var Mv=I({method:V(`ui/notifications/tool-result`),params:m_.describe(`Standard MCP tool execution result.`)}),Nv=I({toolInfo:I({id:Ph.optional().describe(`JSON-RPC id of the tools/call request.`),tool:d_.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:pv.optional().describe(`Current color theme preference.`),styles:Tv.optional().describe(`Style configuration for theming the app.`),displayMode:mv.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:F(mv).optional().describe(`Display modes the host supports.`),containerDimensions:R([I({height:M().describe(`Fixed container height in pixels.`)}),I({maxHeight:R([M(),Gf()]).optional().describe(`Maximum container height in pixels.`)})]).and(R([I({width:M().describe(`Fixed container width in pixels.`)}),I({maxWidth:R([M(),Gf()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
119
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Rv(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Av,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e===!1||e==null||r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function Wv(e,t,n={}){let r=$(`button`,{class:`btn${n.class?` ${n.class}`:``}`,...n.title?{title:n.title}:{}});return r.textContent=e,n.disabled&&(r.disabled=!0),r.addEventListener(`click`,t),r}function Gv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},Bv(zv())}var Kv=`show_interfaces`,qv=document.getElementById(`app`),Jv=null,Yv=``,Xv=!1;function Zv(e){return(e.flags??``).includes(`R`)||e.running===`true`}function Qv(e){return(e.flags??``).includes(`X`)||e.disabled===`true`}function $v(e,t){return!!t&&$(`div`,{class:`contents`},$(`span`,{},e),$(`b`,{},t))}function ey(e){let t=Qv(e),n=t?`dot is-down`:Zv(e)?`dot is-up`:`dot`,r=$(`div`,{class:`if-card__meta`},$v(`MTU`,e.mtu??e[`actual-mtu`]),$v(`MAC`,e[`mac-address`]),$v(`comment`,e.comment));return $(`div`,{class:`card if-card${t?` is-disabled`:``}`},$(`div`,{class:`if-card__top`},$(`span`,{class:n}),$(`span`,{class:`if-card__name`},e.name??`?`),$(`span`,{class:`badge`},e.type??`—`)),r)}function ty(e){let t=Yv.trim().toLowerCase();return t?e.rows.filter(e=>Object.values(e).some(e=>e.toLowerCase().includes(t))):e.rows}function ny(){if(!Jv){qv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for interfaces…`));return}let e=Jv,t=ty(e),n=e.rows.filter(Zv).length,r=e.rows.filter(Qv).length,i=$(`input`,{class:`search`,type:`search`,placeholder:`Search ${e.rows.length} interface(s)…`,value:Yv});i.addEventListener(`input`,()=>{Yv=i.value,ny()});let a=$(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},`Interfaces`),$(`p`,{class:`hd__sub`},`${n} running · ${r} disabled · ${e.rows.length} total`)),$(`span`,{class:`hd__spacer`}),$(`span`,{class:`pill`},`device `,$(`b`,{},e.device))),o=$(`div`,{class:`toolbar`},$(`div`,{class:`grow`},i),Wv(Xv?`Refreshing…`:`↻ Refresh`,ay,{disabled:Xv})),s=t.length?$(`section`,{class:`if-grid`},...t.map(ey)):$(`div`,{class:`empty`},`No interfaces match the search.`),c=$(`footer`,{class:`foot`},$(`span`,{class:`grow`}),$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`));qv.replaceChildren(a,o,s,c)}var ry=new Uv({name:`mikrotik-interfaces`,version:`1.0.0`});function iy(e){e&&typeof e==`object`&&e.__mikrotikView===`interfaces`&&(Jv=e,ny())}async function ay(){if(!Xv){Xv=!0,ny();try{iy((await ry.callServerTool({name:Kv,arguments:{}})).structuredContent)}catch(e){console.error(`[interfaces] refresh failed`,e)}finally{Xv=!1,ny()}}}ry.ontoolresult=e=>iy(e.structuredContent),ry.ontoolinput=()=>{Jv||ny()},Gv(ry),ry.onteardown=async()=>({}),ny(),ry.connect().catch(e=>console.error(`[interfaces] connect failed`,e));
|
|
119
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Rv(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Av,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e===!1||e==null||r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function Wv(e,t,n={}){let r=$(`button`,{class:`btn${n.class?` ${n.class}`:``}`,...n.title?{title:n.title}:{}});return r.textContent=e,n.disabled&&(r.disabled=!0),r.addEventListener(`click`,t),r}function Gv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},Bv(zv())}var Kv=1e4;async function qv(e,t,n){try{return await e.connect(void 0,{timeout:Kv}),console.warn(`[${t}] connected`,{host:e.getHostVersion(),caps:e.getHostCapabilities()}),!0}catch(e){console.error(`[${t}] connect failed`,e);let r=e instanceof Error&&/timed?\s*out/i.test(e.message)?`The MCP App host did not respond — make sure your client supports MCP Apps (ext-apps).`:`Connection failed: ${e instanceof Error?e.message:String(e)}`;return n.replaceChildren($(`div`,{class:`skeleton`},r)),!1}}var Jv=`show_interfaces`,Yv=document.getElementById(`app`),Xv=null,Zv=``,Qv=!1;function $v(e){return(e.flags??``).includes(`R`)||e.running===`true`}function ey(e){return(e.flags??``).includes(`X`)||e.disabled===`true`}function ty(e,t){return!!t&&$(`div`,{class:`contents`},$(`span`,{},e),$(`b`,{},t))}function ny(e){let t=ey(e),n=t?`dot is-down`:$v(e)?`dot is-up`:`dot`,r=$(`div`,{class:`if-card__meta`},ty(`MTU`,e.mtu??e[`actual-mtu`]),ty(`MAC`,e[`mac-address`]),ty(`comment`,e.comment));return $(`div`,{class:`card if-card${t?` is-disabled`:``}`},$(`div`,{class:`if-card__top`},$(`span`,{class:n}),$(`span`,{class:`if-card__name`},e.name??`?`),$(`span`,{class:`badge`},e.type??`—`)),r)}function ry(e){let t=Zv.trim().toLowerCase();return t?e.rows.filter(e=>Object.values(e).some(e=>e.toLowerCase().includes(t))):e.rows}function iy(){if(!Xv){Yv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for interfaces…`));return}let e=Xv,t=ry(e),n=e.rows.filter($v).length,r=e.rows.filter(ey).length,i=$(`input`,{class:`search`,type:`search`,placeholder:`Search ${e.rows.length} interface(s)…`,value:Zv});i.addEventListener(`input`,()=>{Zv=i.value,iy()});let a=$(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},`Interfaces`),$(`p`,{class:`hd__sub`},`${n} running · ${r} disabled · ${e.rows.length} total`)),$(`span`,{class:`hd__spacer`}),$(`span`,{class:`pill`},`device `,$(`b`,{},e.device))),o=$(`div`,{class:`toolbar`},$(`div`,{class:`grow`},i),Wv(Qv?`Refreshing…`:`↻ Refresh`,sy,{disabled:Qv})),s=t.length?$(`section`,{class:`if-grid`},...t.map(ny)):$(`div`,{class:`empty`},`No interfaces match the search.`),c=$(`footer`,{class:`foot`},$(`span`,{class:`grow`}),$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`));Yv.replaceChildren(a,o,s,c)}var ay=new Uv({name:`mikrotik-interfaces`,version:`1.0.0`});function oy(e){e&&typeof e==`object`&&e.__mikrotikView===`interfaces`&&(Xv=e,iy())}async function sy(){if(!Qv){Qv=!0,iy();try{oy((await ay.callServerTool({name:Jv,arguments:{}})).structuredContent)}catch(e){console.error(`[interfaces] refresh failed`,e)}finally{Qv=!1,iy()}}}ay.ontoolresult=e=>{console.warn(`[interfaces] ontoolresult`,e),oy(e.structuredContent)},ay.ontoolinput=()=>{Xv||iy()},Gv(ay),ay.onteardown=async()=>({}),iy(),qv(ay,`interfaces`,Yv);
|
|
120
120
|
</script>
|
|
121
121
|
<style>
|
|
122
122
|
:root{--mt-bg:var(--color-background-primary,#0b0d10);--mt-surface:var(--color-background-secondary,#14171c);--mt-surface-2:var(--color-background-tertiary,#1b1f26);--mt-border:var(--color-border-primary,#262b33);--mt-text:var(--color-text-primary,#e8eaed);--mt-text-dim:var(--color-text-secondary,#9aa3af);--mt-text-faint:var(--color-text-tertiary,#6b7280);--mt-accent:var(--color-accent-primary,#6ea8fe);--mt-good:#34d399;--mt-warn:#fbbf24;--mt-bad:#f87171;--mt-radius:var(--border-radius-md,14px);--mt-radius-sm:var(--border-radius-sm,9px);--mt-mono:var(--font-mono,ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace);--mt-sans:var(--font-sans,system-ui, -apple-system, "Segoe UI", sans-serif);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}}*{box-sizing:border-box}body{background:var(--mt-bg);color:var(--mt-text);font-family:var(--mt-sans);-webkit-font-smoothing:antialiased;margin:0;padding:16px;font-size:13px;line-height:1.5}.app{gap:14px;max-width:960px;margin:0 auto;display:grid}.hd{flex-wrap:wrap;align-items:center;gap:12px;display:flex}.hd__dot{background:var(--mt-good);width:9px;height:9px;box-shadow:0 0 0 4px color-mix(in srgb, var(--mt-good) 22%, transparent);border-radius:50%}.hd__title{letter-spacing:-.01em;margin:0;font-size:17px;font-weight:650}.hd__sub{color:var(--mt-text-dim);font-family:var(--mt-mono);margin:0;font-size:12px}.hd__spacer{flex:1}.pill{border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text-dim);font-family:var(--mt-mono);border-radius:999px;align-items:center;gap:6px;padding:3px 9px;font-size:11px;display:inline-flex}.pill b{color:var(--mt-text);font-weight:600}.grid{grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;display:grid}.card{background:linear-gradient(180deg, var(--mt-surface), var(--mt-surface-2));border:1px solid var(--mt-border);border-radius:var(--mt-radius);padding:14px}.card__label{color:var(--mt-text-dim);text-transform:uppercase;letter-spacing:.06em;margin:0 0 8px;font-size:11px}.card__value{font-family:var(--mt-mono);letter-spacing:-.01em;font-size:20px;font-weight:600}.toolbar{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.toolbar .grow{flex:1;min-width:140px}.search{appearance:none;border:1px solid var(--mt-border);background:var(--mt-surface);width:100%;color:var(--mt-text);font:inherit;border-radius:var(--mt-radius-sm);padding:7px 11px;font-size:13px}.search:focus{border-color:var(--mt-accent);outline:none}.search::placeholder{color:var(--mt-text-faint)}.btn{appearance:none;border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text);font:inherit;border-radius:var(--mt-radius-sm);cursor:pointer;white-space:nowrap;padding:6px 11px;font-size:12px;transition:border-color .15s,background .15s}.btn:hover{border-color:var(--mt-accent);background:var(--mt-surface-2)}.btn:disabled{opacity:.5;cursor:default}.btn.is-active{border-color:var(--mt-accent);color:var(--mt-accent)}.chip{border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text-dim);font-family:var(--mt-mono);border-radius:999px;align-items:center;gap:4px;padding:1px 7px;font-size:11px;display:inline-flex}.chip.is-good{color:var(--mt-good);border-color:color-mix(in srgb, var(--mt-good) 45%, var(--mt-border))}.chip.is-warn{color:var(--mt-warn);border-color:color-mix(in srgb, var(--mt-warn) 45%, var(--mt-border))}.chip.is-bad{color:var(--mt-bad);border-color:color-mix(in srgb, var(--mt-bad) 45%, var(--mt-border))}.tablewrap{border:1px solid var(--mt-border);border-radius:var(--mt-radius);max-height:70vh;overflow:auto}table.tbl{border-collapse:collapse;width:100%;font-size:12px}table.tbl th,table.tbl td{text-align:left;border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);white-space:nowrap;font-family:var(--mt-mono);padding:7px 12px}table.tbl thead th{z-index:1;background:var(--mt-surface-2);color:var(--mt-text-dim);cursor:pointer;-webkit-user-select:none;user-select:none;font-weight:600;position:sticky;top:0}table.tbl thead th:hover{color:var(--mt-text)}table.tbl thead th .arrow{color:var(--mt-accent);margin-left:4px}table.tbl tbody tr{cursor:pointer}table.tbl tbody tr:hover{background:color-mix(in srgb, var(--mt-accent) 8%, transparent)}table.tbl tbody tr.is-disabled td,table.tbl td.col-num{color:var(--mt-text-faint)}.kv__body{border:1px solid var(--mt-border);border-radius:var(--mt-radius);grid-template-columns:minmax(120px,.4fr) 1fr;display:grid;overflow:hidden}.kv__body>div{border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);overflow-wrap:anywhere;min-width:0;font-size:12px;font-family:var(--mt-mono);padding:7px 14px}.kv__k{color:var(--mt-text-dim);background:color-mix(in srgb, var(--mt-surface) 60%, transparent)}.kv__v{color:var(--mt-text)}.drawer{border:1px solid var(--mt-accent);border-radius:var(--mt-radius);background:var(--mt-surface);gap:10px;padding:12px;display:grid}.drawer__hd{align-items:center;gap:8px;display:flex}.drawer__hd b{font-family:var(--mt-mono)}pre.raw{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);color:var(--mt-text);font-family:var(--mt-mono);white-space:pre;max-height:70vh;margin:0;padding:14px;font-size:12px;overflow:auto}.foot{color:var(--mt-text-faint);font-size:11px;font-family:var(--mt-mono);flex-wrap:wrap;align-items:center;gap:10px;display:flex}.foot .grow{flex:1}.skeleton,.empty{color:var(--mt-text-faint);text-align:center;padding:40px 0}.if-grid{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px;display:grid}.if-card{gap:8px;display:grid}.if-card__top{align-items:center;gap:8px;display:flex}.if-card__name{font-family:var(--mt-mono);overflow-wrap:anywhere;font-size:14px;font-weight:650}.if-card.is-disabled{opacity:.6}.dot{background:var(--mt-text-faint);border-radius:50%;flex:none;width:9px;height:9px}.dot.is-up{background:var(--mt-good);box-shadow:0 0 0 4px color-mix(in srgb, var(--mt-good) 22%, transparent)}.dot.is-down{background:var(--mt-bad);box-shadow:0 0 0 4px color-mix(in srgb, var(--mt-bad) 18%, transparent)}.if-card__meta{font-family:var(--mt-mono);color:var(--mt-text-dim);grid-template-columns:auto 1fr;gap:2px 10px;font-size:11px;display:grid}.if-card__meta b{color:var(--mt-text);overflow-wrap:anywhere;font-weight:500}.if-card__meta .contents{display:contents}.badge{border:1px solid var(--mt-border);background:var(--mt-surface-2);color:var(--mt-text-dim);font-family:var(--mt-mono);text-transform:uppercase;letter-spacing:.04em;border-radius:999px;margin-left:auto;padding:1px 7px;font-size:10px}
|
|
@@ -77,7 +77,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
77
77
|
`)}),(0,J.jsxs)(`div`,{className:`cfg-ta-wrap`,children:[(0,J.jsxs)(`pre`,{className:`cfg-hl`,"aria-hidden":`true`,ref:O,children:[MY(r),`
|
|
78
78
|
`]}),(0,J.jsx)(`textarea`,{ref:E,className:`cfg-ta`,spellCheck:!1,wrap:`off`,value:r,onChange:e=>{i(e.target.value),j(e.currentTarget)},onKeyDown:N,onClick:()=>f(null),onScroll:e=>{let t=e.currentTarget;O.current&&(O.current.scrollTop=t.scrollTop,O.current.scrollLeft=t.scrollLeft),k.current&&(k.current.scrollTop=t.scrollTop)}}),d&&(0,J.jsx)(`div`,{className:`cfg-ac`,style:{left:d.x,top:d.y},children:d.items.map((e,t)=>(0,J.jsx)(`div`,{className:`cfg-ac-item${t===d.index?` is-sel`:``}`,onMouseDown:t=>{t.preventDefault(),M(e)},children:e},e))})]})]}),Object.keys(p).length>0&&(0,J.jsx)(`div`,{className:`cfg-chips`,children:Object.entries(p).map(([e,t])=>(0,J.jsxs)(`span`,{className:`cfg-chip ${t.ok?`is-ok`:`is-bad`}`,children:[t.ok?`●`:`○`,` `,e,`: `,t.label]},e))}),(l||s.length>0)&&(0,J.jsx)(`div`,{className:`cfg-errors`,children:l?(0,J.jsxs)(`div`,{className:`cfg-err`,children:[`JSON: `,l]}):s.slice(0,12).map((e,t)=>(0,J.jsxs)(`div`,{className:`cfg-err`,children:[(0,J.jsx)(`code`,{children:e.path}),` — `,e.message]},t))}),h&&(0,J.jsxs)(`div`,{className:`cfg-preview`,children:[(0,J.jsxs)(`div`,{className:`cfg-preview__hd`,children:[(0,J.jsx)(`strong`,{children:`Diff vs current`}),(0,J.jsx)(`span`,{className:`muted`,children:h.summary?.changed?`+${h.summary.added} / -${h.summary.removed}`:`no changes`}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`button`,{className:`topo-btn`,onClick:()=>g(null),children:`✕`})]}),(0,J.jsx)(`pre`,{className:`cfg-diff`,children:(h.unified||`(identical)`).split(`
|
|
79
79
|
`).map((e,t)=>(0,J.jsx)(`div`,{className:e.startsWith(`+`)?`d-add`:e.startsWith(`-`)?`d-del`:e.startsWith(`@@`)?`d-hunk`:``,children:e||` `},t))})]})]})}function WY({x:e,y:t,text:n,className:r,textClassName:i,padX:a=9,fontSize:o=9}){let s=(0,v.useRef)(null),[c,l]=(0,v.useState)(()=>n.length*o*.62);(0,v.useLayoutEffect)(()=>{let e=s.current?.getComputedTextLength();e&&e>0&&l(e)},[n,o]);let u=Math.round(c+a*2);return(0,J.jsxs)(`g`,{transform:`translate(${e.toFixed(1)},${t.toFixed(1)})`,children:[(0,J.jsx)(`rect`,{className:r,x:-u/2,y:-9,rx:9,width:u,height:18}),(0,J.jsx)(`text`,{ref:s,className:i,x:0,y:3.5,textAnchor:`middle`,fontSize:o,children:n})]})}function GY(e){return e.reachable===!0?{label:`online`,color:`#d4d4d8`}:e.reachable===!1?{label:`offline`,color:`#f87171`}:{label:`checking…`,color:`#71717a`}}function KY(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(t,31)+e.charCodeAt(n)>>>0;return`hsl(${t%360} 70% 62%)`}function qY(e,t,n,r){let i=1-r;return{x:i*i*e.x+2*i*r*t.x+r*r*n.x,y:i*i*e.y+2*i*r*t.y+r*r*n.y}}function JY(e,t,n,r){let i=1-r,a=2*i*(t.x-e.x)+2*r*(n.x-t.x),o=2*i*(t.y-e.y)+2*r*(n.y-t.y);return Math.atan2(o,a)*180/Math.PI}var YY=`#e4e4e7`,XY=`#d4d4d8`,ZY=`#f59e0b`;function QY(e){return e.jumpVia?e.jumpVia:e.jumpHost?`${e.jumpHost.host}:${e.jumpHost.port}`:null}var $Y=18,eX=e=>e.length>$Y?`${e.slice(0,$Y-1)}…`:e,tX=e=>Math.max(23,Math.min(70,e.length*3.1+12));function nX({payload:e,pulses:t}){let n=e.devices,r=Math.max(1,n.length),i=n.map(e=>{let t=eX(e.name);return{d:e,label:t,r:tX(t)}}),a=Math.max(23,...i.map(e=>e.r)),o=r>1?(a+18)/Math.sin(Math.PI/r):0,s=Math.max(110+a,o,120),c=a+60,l=Math.max(700,Math.round((s+a+40)*2)),u=Math.round((s+c)*2),d=l/2,f=u/2,p={x:d,y:f},m=i.map((e,t)=>{let n=t/r*Math.PI*2-Math.PI/2+(r%2==0?Math.PI/r:0);return{...e,i:t,x:d+s*Math.cos(n),y:f+s*Math.sin(n)}});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{className:`conn`,viewBox:`0 0 ${l} ${u}`,width:`100%`,height:u,preserveAspectRatio:`xMidYMid meet`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsxs)(`radialGradient`,{id:`conn-hub`,cx:`0.5`,cy:`0.34`,r:`0.75`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:`#fafafa`}),(0,J.jsx)(`stop`,{offset:`0.6`,stopColor:`#d4d4d8`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#a1a1aa`})]}),(0,J.jsxs)(`radialGradient`,{id:`conn-orb`,cx:`0.5`,cy:`0.32`,r:`0.85`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:`#27272a`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#18181b`})]}),(0,J.jsxs)(`radialGradient`,{id:`conn-burst`,cx:`0.5`,cy:`0.5`,r:`0.5`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:`#fafafa`}),(0,J.jsx)(`stop`,{offset:`0.5`,stopColor:`#e4e4e7`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#a1a1aa`,stopOpacity:`0`})]}),(0,J.jsxs)(`linearGradient`,{id:`conn-tunnel-grad`,x1:`0`,y1:`0`,x2:`1`,y2:`0`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:ZY,stopOpacity:`0.15`}),(0,J.jsx)(`stop`,{offset:`0.5`,stopColor:ZY,stopOpacity:`0.95`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:ZY,stopOpacity:`0.15`})]}),(0,J.jsxs)(`filter`,{id:`conn-tunnel-glow`,x:`-40%`,y:`-40%`,width:`180%`,height:`180%`,children:[(0,J.jsx)(`feGaussianBlur`,{stdDeviation:`3`,result:`b`}),(0,J.jsxs)(`feMerge`,{children:[(0,J.jsx)(`feMergeNode`,{in:`b`}),(0,J.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]})]}),[.5,.78,1].map((e,t)=>(0,J.jsx)(`circle`,{className:`conn-grid`,cx:d,cy:f,r:s*e},`g-${t}`)),[0,1,2].map(e=>(0,J.jsx)(`circle`,{className:`conn-sonar`,cx:d,cy:f,style:{animationDelay:`${e*1.1}s`}},`s-${e}`)),m.map(({d:e,i:n,x:r,y:i})=>{let a=GY(e.status),o=e.status.reachable===!0,s=e.status.reachable==null,c={x:r,y:i},l=(d+r)/2,u=(f+i)/2,m=r-d,h=i-f,g=Math.hypot(m,h)||1,_=-h/g,v=m/g,y={x:l+_*16,y:u+v*16},b={x:l-_*16,y:u-v*16},x=`M${d},${f} Q${y.x.toFixed(1)},${y.y.toFixed(1)} ${r.toFixed(1)},${i.toFixed(1)}`,S=`M${d},${f} Q${b.x.toFixed(1)},${b.y.toFixed(1)} ${r.toFixed(1)},${i.toFixed(1)}`,C=`M${d},${f} Q${l.toFixed(1)},${u.toFixed(1)} ${r.toFixed(1)},${i.toFixed(1)}`,w=qY(p,y,c,.52),T=JY(p,y,c,.52),E=qY(p,b,c,.48),D=JY(p,b,c,.48)+180,O=t[e.name]??0;return(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`path`,{id:`conn-cmd-${n}`,className:`conn-link`,d:x,stroke:o?YY:a.color,strokeOpacity:o?.5:.32,strokeDasharray:s?`2 8`:o?void 0:`6 7`}),(0,J.jsx)(`path`,{id:`conn-res-${n}`,className:`conn-link`,d:S,stroke:o?XY:a.color,strokeOpacity:o?.5:.18,strokeDasharray:o?void 0:`6 7`}),o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{className:`conn-flow`,d:x,stroke:`#e4e4e7`}),(0,J.jsx)(`circle`,{className:`conn-packet`,r:3.2,fill:`#e4e4e7`,children:(0,J.jsx)(`animateMotion`,{dur:`2.6s`,repeatCount:`indefinite`,calcMode:`linear`,children:(0,J.jsx)(`mpath`,{href:`#conn-cmd-${n}`})})}),(0,J.jsx)(`rect`,{className:`conn-packet`,x:-2.6,y:-2.6,width:5.2,height:5.2,fill:`#d4d4d8`,transform:`rotate(45)`,children:(0,J.jsx)(`animateMotion`,{dur:`2.6s`,begin:`0.9s`,repeatCount:`indefinite`,calcMode:`linear`,keyPoints:`1;0`,keyTimes:`0;1`,children:(0,J.jsx)(`mpath`,{href:`#conn-res-${n}`})})}),(0,J.jsx)(`path`,{className:`conn-chevron`,d:`M-4,-3 L4,0 L-4,3`,stroke:`#e4e4e7`,transform:`translate(${w.x.toFixed(1)},${w.y.toFixed(1)}) rotate(${T.toFixed(1)})`}),(0,J.jsx)(`path`,{className:`conn-chevron`,d:`M-4,-3 L4,0 L-4,3`,stroke:`#d4d4d8`,transform:`translate(${E.x.toFixed(1)},${E.y.toFixed(1)}) rotate(${D.toFixed(1)})`})]}),O>0&&(0,J.jsx)(`g`,{children:(0,J.jsxs)(`circle`,{r:6,fill:`url(#conn-burst)`,children:[(0,J.jsx)(`animateMotion`,{dur:`1.1s`,repeatCount:`1`,calcMode:`linear`,keyPoints:`0;1;0`,keyTimes:`0;0.5;1`,path:C}),(0,J.jsx)(`animate`,{attributeName:`opacity`,values:`0;1;1;0`,keyTimes:`0;0.1;0.85;1`,dur:`1.1s`,repeatCount:`1`,fill:`freeze`})]})},`burst-${e.name}-${O}`)]},`l-${e.name}`)}),m.map(e=>{let t=e.d.jumpVia,n=t?m.find(e=>e.d.name===t):void 0,r=!n&&e.d.jumpHost?e.d.jumpHost:void 0;if(!n&&!r)return null;let i={x:e.x,y:e.y},a=Math.hypot(e.x-d,e.y-f)||1,o=(e.x-d)/a,s=(e.y-f)/a,c=n?{x:n.x,y:n.y}:{x:e.x+o*(e.r+46),y:e.y+s*(e.r+46)},l=(c.x+i.x)/2,u=(c.y+i.y)/2,p=Math.hypot(l-d,u-f)||1,h=n?50:16,g={x:l+(l-d)/p*h,y:u+(u-f)/p*h},_=`M${c.x.toFixed(1)},${c.y.toFixed(1)} Q${g.x.toFixed(1)},${g.y.toFixed(1)} ${i.x.toFixed(1)},${i.y.toFixed(1)}`,v=QY(e.d)??``,y=qY(c,g,i,.5),b=`conn-tunnel-${e.i}`;return(0,J.jsxs)(`g`,{className:`conn-tunnel-g`,children:[(0,J.jsx)(`path`,{className:`conn-tunnel-halo`,d:_,stroke:ZY}),(0,J.jsx)(`path`,{id:b,className:`conn-tunnel`,d:_,stroke:`url(#conn-tunnel-grad)`,filter:`url(#conn-tunnel-glow)`}),r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`circle`,{className:`conn-tunnel-sat`,cx:c.x,cy:c.y,r:11,fill:`#1c1917`,stroke:`#f59e0b`}),(0,J.jsx)(`text`,{x:c.x,y:c.y+3.5,textAnchor:`middle`,fontSize:11,children:`🛡️`})]}),(0,J.jsxs)(`text`,{className:`conn-tunnel-lock`,fontSize:13,textAnchor:`middle`,children:[`🔒`,(0,J.jsx)(`animateMotion`,{dur:`2.4s`,repeatCount:`indefinite`,calcMode:`linear`,rotate:`auto`,children:(0,J.jsx)(`mpath`,{href:`#${b}`})})]}),(0,J.jsx)(WY,{x:y.x,y:y.y,text:`⤳ via ${v}`,className:`conn-tunnel-badge`,textClassName:`conn-tunnel-badge-tx`})]},`jump-${e.d.name}`)}),(0,J.jsx)(`circle`,{className:`conn-hub-glow`,cx:d,cy:f,r:42}),(0,J.jsx)(`circle`,{className:`conn-hub-ring`,cx:d,cy:f,r:37}),(0,J.jsx)(`circle`,{cx:d,cy:f,r:29,fill:`url(#conn-hub)`,stroke:`#71717a`,strokeWidth:1.5}),(0,J.jsx)(`text`,{x:d,y:f-4,textAnchor:`middle`,fill:`#09090b`,fontSize:12,fontWeight:700,children:`LLM`}),(0,J.jsx)(`text`,{x:d,y:f+8,textAnchor:`middle`,fill:`#3f3f46`,fontSize:8,fontWeight:600,children:`⇄ MCP`}),(0,J.jsx)(`text`,{x:d,y:f+18,textAnchor:`middle`,fill:`#3f3f46`,fontSize:7.5,fontWeight:600,children:`server`}),m.map(({d:e,x:t,y:n,r,label:i})=>{let a=GY(e.status),o=e.status.reachable===!0,s=o?`${e.status.latencyMs??`?`} ms`:a.label,c=KY(e.name);return(0,J.jsxs)(`g`,{className:`conn-node`,opacity:e.disabled?.35:1,children:[o&&(0,J.jsx)(`circle`,{className:`conn-node-halo`,cx:t,cy:n,r:r+1,stroke:c}),e.pool?.pooled&&(0,J.jsx)(`circle`,{cx:t,cy:n,r:r+5,fill:`none`,stroke:e.pool.inflight>0?`#3b82f6`:`#22c55e`,strokeWidth:1.5,strokeDasharray:e.pool.inflight>0?void 0:`4 4`,opacity:.5,className:e.pool.inflight>0?`conn-blink`:void 0}),(0,J.jsx)(`circle`,{cx:t,cy:n,r,fill:`url(#conn-orb)`}),(0,J.jsx)(`circle`,{cx:t,cy:n,r,fill:c,opacity:.16}),(0,J.jsx)(`circle`,{cx:t,cy:n,r,fill:`none`,stroke:c,strokeWidth:2.5}),(0,J.jsx)(`circle`,{className:o?`conn-blink`:void 0,cx:t+r*.7,cy:n-r*.7,r:4.5,fill:a.color,stroke:`#0a121b`,strokeWidth:1.5}),(0,J.jsx)(`text`,{x:t,y:n+3.5,textAnchor:`middle`,fill:`#fafafa`,fontSize:10,fontWeight:600,children:i}),(0,J.jsx)(`text`,{x:t,y:n+r+14,textAnchor:`middle`,fill:`#a1a1aa`,fontSize:9,children:e.address??e.host}),(0,J.jsx)(`text`,{x:t,y:n+r+26,textAnchor:`middle`,fill:a.color,fontSize:9,fontWeight:600,children:s})]},`n-${e.name}`)})]}),(0,J.jsxs)(`div`,{className:`conn-legend`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{style:{background:YY}}),` command · LLM → device`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{style:{background:XY}}),` response · device → LLM`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{style:{background:`#e4e4e7`}}),` live call (round-trip)`]}),e.devices.some(e=>QY(e))&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{style:{background:`#f59e0b`}}),` 🔒 SSH jump tunnel (ProxyJump)`]}),e.devices.some(e=>e.pool?.pooled)&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{style:{background:`#22c55e`}}),` pooled SSH connection`]})]})]})}function rX({d:e,onToggle:t}){let n=GY(e.status),r=e.status.reachable===!0?`${n.label} · ${e.status.latencyMs??`?`}ms${e.status.version?` · v${e.status.version}`:``}`:e.status.reachable===!1?`${n.label}${e.status.error?` · ${e.status.error}`:``}`:n.label,i=KY(e.name);return(0,J.jsxs)(`div`,{className:`card dev-card`,style:{borderLeft:`3px solid ${i}`},"data-disabled":e.disabled?`1`:void 0,children:[(0,J.jsxs)(`div`,{className:`dev-card__top`,children:[(0,J.jsx)(`span`,{className:`dot`,style:{background:i},title:`device colour`}),(0,J.jsx)(`span`,{className:`dev-card__name`,children:e.name}),e.isDefault&&(0,J.jsx)(Nc,{type:`accent`,children:`default`}),e.disabled&&(0,J.jsx)(Nc,{type:`warning`,children:`disabled`}),(0,J.jsx)(`span`,{className:`dot dot--status`,style:{background:n.color},title:n.label}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsxs)(`label`,{className:`dev-toggle`,title:e.disabled?`Enable device`:`Disable device`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:!e.disabled,onChange:()=>t?.(e.name,!e.disabled)}),(0,J.jsx)(`span`,{className:`dev-toggle__slider`})]}),(0,J.jsx)(`span`,{className:`chip`,children:e.authMode})]}),(0,J.jsxs)(`div`,{className:`dev-card__meta`,children:[(0,J.jsx)(`span`,{children:e.mac?`mac`:`host`}),(0,J.jsx)(`b`,{children:e.address??`${e.host}:${e.port}`}),(0,J.jsx)(`span`,{children:`user`}),(0,J.jsx)(`b`,{children:e.username}),(0,J.jsx)(`span`,{children:`status`}),(0,J.jsx)(`b`,{style:{color:n.color},children:r}),(0,J.jsx)(`span`,{children:`activity`}),(0,J.jsxs)(`b`,{children:[e.activity.calls,` calls · `,e.activity.errors,` err`,e.activity.avgMs?` · ${Sc(e.activity.avgMs)} avg`:``]}),e.pool&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`pool`}),(0,J.jsx)(`b`,{style:{color:e.pool.dead?`#ef4444`:e.pool.inflight>0?`#3b82f6`:e.pool.pooled?`#22c55e`:`#52525b`},children:e.pool.pooled?e.pool.inflight>0?`${e.pool.inflight} inflight`:`connected`:`—`})]}),e.description&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`note`}),(0,J.jsx)(`b`,{children:e.description})]})]}),QY(e)&&(0,J.jsxs)(`div`,{className:`jump-route`,title:`Reached over SSH through the bastion ${QY(e)} (ProxyJump) — no port exposed on ${e.name}.`,children:[(0,J.jsxs)(`span`,{className:`jump-route__hop jump-route__hop--bastion`,children:[`🛡️ `,QY(e),e.jumpVia?(0,J.jsx)(`i`,{className:`jump-route__tag`,children:`jump`}):null]}),(0,J.jsx)(`span`,{className:`jump-route__wire jump-route__wire--enc`,children:(0,J.jsx)(`span`,{className:`jump-route__lock`,"aria-hidden":!0,children:`🔒`})}),(0,J.jsxs)(`span`,{className:`jump-route__hop jump-route__hop--dest`,style:{borderColor:i},title:e.name,children:[`📡 `,e.name]})]})]})}function iX({event:e,onClose:t}){let[n,r]=(0,v.useState)(IY);return(0,J.jsx)(`div`,{className:`overlay`,onClick:e=>e.target===e.currentTarget&&t(),children:(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(`div`,{className:`sheet__hd`,children:[(0,J.jsx)(`span`,{className:`risk risk-${e.risk}`,children:e.risk}),(0,J.jsxs)(`h3`,{className:`sheet__tool`,children:[e.tool,(0,J.jsx)(xc,{text:e.tool,className:`iconbtn`,icon:!0,title:`Copy tool name`})]}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(jc,{type:`secondary`,size:`sm`,onClick:t,children:`✕ Close`})]}),(0,J.jsxs)(`div`,{className:`kv__body`,children:[(0,J.jsx)(`div`,{className:`kv__k`,children:`title`}),(0,J.jsx)(`div`,{className:`kv__v`,children:e.title}),e.reason&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`kv__k kv__k--reason`,children:`reason`}),(0,J.jsx)(`div`,{className:`kv__v kv__v--reason`,children:e.reason})]}),(0,J.jsx)(`div`,{className:`kv__k`,children:`time`}),(0,J.jsx)(`div`,{className:`kv__v`,children:new Date(e.ts).toLocaleString(void 0,{hour12:!1})}),(0,J.jsx)(`div`,{className:`kv__k`,children:`device`}),(0,J.jsx)(`div`,{className:`kv__v`,children:e.device??`—`}),(0,J.jsx)(`div`,{className:`kv__k`,children:`transport`}),(0,J.jsx)(`div`,{className:`kv__v`,children:e.transport??`—`}),(0,J.jsx)(`div`,{className:`kv__k`,children:`duration`}),(0,J.jsx)(`div`,{className:`kv__v`,children:Sc(e.durationMs)}),(0,J.jsx)(`div`,{className:`kv__k`,children:`status`}),(0,J.jsx)(`div`,{className:`kv__v`,children:(0,J.jsx)(`span`,{className:e.isError?`status-err`:`status-ok`,children:e.isError?`error`:`ok`})}),(0,J.jsx)(`div`,{className:`kv__k`,children:`output size`}),(0,J.jsxs)(`div`,{className:`kv__v`,children:[Cc(e.outputBytes),e.truncated?` (truncated)`:``]}),(0,J.jsx)(`div`,{className:`kv__k`,children:`structured`}),(0,J.jsx)(`div`,{className:`kv__v`,children:e.hasStructured?`yes (renders an MCP App view)`:`no`})]}),e.error&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h2`,{className:`muted`,children:`ERROR`}),(0,J.jsx)(`pre`,{className:`body`,style:{color:`var(--mt-bad)`},children:e.error})]}),(0,J.jsxs)(`div`,{className:`sheet__hd`,children:[(0,J.jsx)(`h2`,{className:`muted`,style:{margin:0},children:`INPUT`}),(0,J.jsx)(`span`,{style:{flex:1}}),e.input&&(0,J.jsx)(jc,{type:`secondary`,size:`sm`,ghost:!0,onClick:()=>r(e=>{let t=!e;return LY(t),t}),title:n?`Showing pretty-printed JSON — click for raw`:`Showing raw JSON — click to pretty-print`,children:n?`✦ Pretty`:`{ } Raw`}),(0,J.jsx)(xc,{text:e.input,title:`Copy input JSON`})]}),e.input?(0,J.jsx)(zY,{value:RY(e.input,n)}):(0,J.jsx)(`pre`,{className:`body`,children:`—`}),(0,J.jsxs)(`div`,{className:`sheet__hd`,children:[(0,J.jsx)(`h2`,{className:`muted`,style:{margin:0},children:`OUTPUT`}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(xc,{text:e.output,title:`Copy output`})]}),(0,J.jsx)(`pre`,{className:`body ros`,children:e.output?PY(e.output):`—`})]})})}var aX=e=>e==null?`?`:Cc(e);function oX({d:e}){let t=e.status,n=e.history??[];return t.reachable===!0||n.length>0?(0,J.jsxs)(`div`,{className:`card health-card`,children:[(0,J.jsxs)(`div`,{className:`health-card__hd`,children:[(0,J.jsx)(Pc,{color:GY(t).color}),(0,J.jsx)(`span`,{className:`dev-card__name`,children:e.name}),e.isDefault&&(0,J.jsx)(Nc,{type:`accent`,children:`default`}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(Nc,{type:t.version?`success`:`default`,children:t.version?`v${t.version}`:`—`})]}),(0,J.jsxs)(`div`,{className:`health-card__sub muted`,children:[t.boardName??`router`,t.architecture?` · ${t.architecture}`:``,t.cpuCount?` · ${t.cpuCount} cpu`:``,t.uptime?` · up ${t.uptime}`:``]}),(0,J.jsxs)(`div`,{className:`health-card__gauges`,children:[(0,J.jsx)(pY,{value:t.cpuLoad,label:`CPU`,color:Dc.cpu}),(0,J.jsx)(pY,{value:t.memUsedPct,label:`MEM`,color:Dc.mem}),(0,J.jsx)(pY,{value:t.hddUsedPct,label:`DISK`,color:Dc.disk})]}),(0,J.jsxs)(`div`,{className:`health-card__charts`,children:[(0,J.jsxs)(`div`,{className:`health-chart`,children:[(0,J.jsx)(`span`,{className:`health-chart__k`,children:`CPU load`}),(0,J.jsx)(fY,{id:`${e.name}-cpu`,values:n.map(e=>e.cpuLoad),color:Dc.cpu,maxValue:100,unit:`%`})]}),(0,J.jsxs)(`div`,{className:`health-chart`,children:[(0,J.jsx)(`span`,{className:`health-chart__k`,children:`Memory used`}),(0,J.jsx)(fY,{id:`${e.name}-mem`,values:n.map(e=>e.memUsedPct),color:Dc.mem,maxValue:100,unit:`%`})]}),(0,J.jsxs)(`div`,{className:`health-chart`,children:[(0,J.jsx)(`span`,{className:`health-chart__k`,children:`Probe latency`}),(0,J.jsx)(fY,{id:`${e.name}-lat`,values:n.map(e=>e.latencyMs),color:Dc.latency,unit:`ms`})]})]}),(0,J.jsxs)(`div`,{className:`health-card__foot muted`,children:[`RAM `,aX(t.totalMemory&&t.freeMemory?t.totalMemory-t.freeMemory:void 0),` /`,` `,aX(t.totalMemory),` · free disk `,aX(t.freeHdd)]})]}):(0,J.jsxs)(`div`,{className:`card health-card health-card--na`,children:[(0,J.jsxs)(`div`,{className:`health-card__hd`,children:[(0,J.jsx)(Pc,{color:GY(t).color}),(0,J.jsx)(`span`,{className:`dev-card__name`,children:e.name}),e.isDefault&&(0,J.jsx)(Nc,{type:`accent`,children:`default`})]}),(0,J.jsx)(`p`,{className:`muted`,style:{margin:0},children:t.reachable===!1?`Offline — ${t.error??`unreachable`}`:e.mac?`Waiting for the first MAC-Telnet probe (these run every few minutes to avoid contending with tool calls)…`:`Waiting for the first health probe…`})]})}function sX(e,t){let n=(0,v.useRef)(e),r=(0,v.useRef)(t);n.current=e,r.current=t,(0,v.useEffect)(()=>{let e=!1,t=null,i=null,a=()=>{e||(i=new EventSource(fc(`/api/sse`)),i.addEventListener(`hello`,()=>r.current(`sse`)),i.addEventListener(`tool`,e=>{try{n.current(JSON.parse(e.data))}catch{}}),i.onerror=()=>{i&&i.readyState===EventSource.CONNECTING&&r.current(`off`)})},o=()=>{if(e)return;let i=location.protocol===`https:`?`wss`:`ws`;t=new WebSocket(fc(`${i}://${location.host}/api/stream`));let s=!1;t.onopen=()=>{s=!0,r.current(`ws`)},t.onerror=()=>t?.close(),t.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`event`&&t.event&&n.current(t.event)}catch{}},t.onclose=()=>{e||(r.current(`off`),s?setTimeout(o,2e3):a())}};return o(),()=>{e=!0,t?.close(),i?.close()}},[])}function cX(e){(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;document.documentElement.classList.add(`js-motion`);let n=new WeakSet,r=e=>{n.has(e)||(n.add(e),zi.set(e,{opacity:0,y:26}),K.create({trigger:e,start:`top 90%`,once:!0,onEnter:()=>zi.to(e,{opacity:1,y:0,duration:.7,ease:`power3.out`})}))},i=e=>{for(let t of e.querySelectorAll(`.reveal`))r(t)};i(t);let a=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof Element&&(e.matches(`.reveal`)&&r(e),i(e))});a.observe(t,{childList:!0,subtree:!0});let o=setInterval(()=>K.refresh(),1200),s=setTimeout(()=>clearInterval(o),7e3);return()=>{a.disconnect(),clearInterval(o),clearTimeout(s);for(let e of K.getAll())e.kill();document.documentElement.classList.remove(`js-motion`)}},[e])}function lX(e){return new Date(e).toLocaleString()}function uX(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}var dX={"in-sync":`#22c55e`,drifted:`#f59e0b`,unknown:`#a1a1a1`,"no-baseline":`#6b7280`},fX={"in-sync":`In Sync`,drifted:`Drifted`,unknown:`Unknown`,"no-baseline":`No Baseline`};function pX({device:e,onDone:t}){let[n,r]=(0,v.useState)([]),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``);(0,v.useEffect)(()=>{q(`/api/drift/history/${encodeURIComponent(e)}?limit=20`).then(e=>{r(e.snapshots),e.snapshots.length>0&&a(e.snapshots[0].id)})},[e]);let f=async()=>{if(!i)return;l(!0),d(``);let n=await pc(`/api/drift/baseline`,{device:e,snapshotId:i,label:o||void 0});l(!1),n.ok?t():d(n.error??`Failed`)};return n.length===0?(0,J.jsx)(`div`,{style:{padding:8},children:(0,J.jsx)(`span`,{className:`muted`,children:`No snapshots for this device. Capture one with capture_config_snapshot first.`})}):(0,J.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,flexWrap:`wrap`,padding:8},children:[(0,J.jsx)(`select`,{className:`input`,value:i,onChange:e=>a(e.target.value),style:{flex:1,minWidth:200},children:n.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.id,` — `,lX(e.ts),` — `,e.lines,` lines`,e.label?` "${e.label}"`:``]},e.id))}),(0,J.jsx)(`input`,{className:`input`,placeholder:`Label (optional)`,value:o,onChange:e=>s(e.target.value),style:{width:160}}),(0,J.jsx)(`button`,{className:`btn btn--sm`,onClick:()=>void f(),disabled:c||!i,children:c?`Setting...`:`Set as Baseline`}),u&&(0,J.jsx)(`span`,{style:{color:`#ef4444`,fontSize:12},children:u})]})}function mX({unified:e}){return e?(0,J.jsx)(`pre`,{style:{fontSize:11,lineHeight:1.5,overflow:`auto`,maxHeight:500,margin:0,padding:12,background:`var(--mt-surface-2, #111)`,borderRadius:6},children:e.split(`
|
|
80
|
-
`).map((e,t)=>{let n=`var(--mt-text-dim, #aaa)`,r=`transparent`;return e.startsWith(`+`)?(n=`#22c55e`,r=`rgba(34,197,94,0.08)`):e.startsWith(`-`)?(n=`#ef4444`,r=`rgba(239,68,68,0.08)`):e.startsWith(`@@`)?n=`#3b82f6`:e.startsWith(`/`)&&(n=`#f59e0b`),(0,J.jsx)(`div`,{style:{color:n,background:r,padding:`0 4px`},children:e||`\xA0`},t)})}):(0,J.jsx)(`span`,{className:`muted`,children:`No differences.`})}function hX({sections:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.added+e.removed),1);return(0,J.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:e.slice(0,15).map(e=>(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,J.jsx)(`span`,{style:{width:220,fontSize:11,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:`var(--mt-text, #eee)`},title:e.path,children:e.path}),(0,J.jsxs)(`div`,{style:{flex:1,height:14,background:`var(--mt-surface-2, #222)`,borderRadius:3,overflow:`hidden`,display:`flex`},children:[(0,J.jsx)(`div`,{style:{width:`${e.added/t*100}%`,background:`#22c55e`,height:`100%`}}),(0,J.jsx)(`div`,{style:{width:`${e.removed/t*100}%`,background:`#ef4444`,height:`100%`}})]}),(0,J.jsxs)(`span`,{style:{fontSize:11,color:`var(--mt-text-dim, #aaa)`,minWidth:60},children:[`+`,e.added,` -`,e.removed]})]},e.path))})}function gX({attributions:e}){return e.length===0?(0,J.jsx)(`span`,{className:`muted`,children:`No config-related log entries found.`}):(0,J.jsx)(`div`,{style:{maxHeight:250,overflowY:`auto`},children:(0,J.jsxs)(`table`,{className:`tbl`,style:{fontSize:11},children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Time`}),(0,J.jsx)(`th`,{children:`User`}),(0,J.jsx)(`th`,{children:`Action`}),(0,J.jsx)(`th`,{children:`Section`}),(0,J.jsx)(`th`,{children:`Log`})]})}),(0,J.jsx)(`tbody`,{children:e.map((e,t)=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{style:{whiteSpace:`nowrap`},children:e.timestamp??`—`}),(0,J.jsx)(`td`,{children:e.user??`—`}),(0,J.jsx)(`td`,{children:(0,J.jsx)(`span`,{style:{padding:`1px 6px`,borderRadius:4,background:`var(--mt-surface-2, #222)`,fontSize:10},children:e.action??`?`})}),(0,J.jsx)(`td`,{style:{maxWidth:160,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.section,children:e.section}),(0,J.jsx)(`td`,{style:{maxWidth:300,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:`var(--mt-text-dim, #aaa)`},title:e.logLine,children:e.logLine})]},t))})]})})}function _X({device:e,onClose:t,onChanged:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=(0,v.useCallback)(async()=>{o(!0),c(``);try{let t=await q(`/api/drift/check/${encodeURIComponent(e)}`);`error`in t?c(t.error):i(t)}catch(e){c(e instanceof Error?e.message:String(e))}o(!1)},[e]),u=async()=>{(await pc(`/api/drift/baseline`,{device:e,snapshotId:r?.baselineId,label:`promoted`})).error||n()},d=async()=>{await mc(`/api/drift/baseline/${encodeURIComponent(e)}`,{}),n()};return(0,J.jsxs)(_c,{title:`${e} — Drift Detail`,className:`reveal`,extra:(0,J.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,J.jsx)(`button`,{className:`btn btn--sm`,onClick:()=>void l(),disabled:a,children:a?`Checking...`:`Check Now`}),(0,J.jsx)(`button`,{className:`btn btn--sm btn--danger`,onClick:()=>void d(),children:`Remove Baseline`}),(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:t,children:`Close`})]}),children:[s&&(0,J.jsx)(`div`,{style:{color:`#ef4444`},children:s}),r&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{style:{display:`flex`,gap:24,alignItems:`center`,padding:`12px 0`,borderBottom:`1px solid var(--mt-border, #333)`,marginBottom:12},children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{style:{display:`inline-block`,width:10,height:10,borderRadius:`50%`,background:r.identical?`#22c55e`:`#f59e0b`,marginRight:6}}),(0,J.jsx)(`strong`,{children:r.identical?`In Sync`:`Drifted`})]}),!r.identical&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{children:[`Score: `,(0,J.jsx)(`strong`,{children:r.score}),`/100`]}),(0,J.jsxs)(`div`,{style:{color:`#22c55e`},children:[`+`,r.summary.added]}),(0,J.jsxs)(`div`,{style:{color:`#ef4444`},children:[`-`,r.summary.removed]}),(0,J.jsxs)(`div`,{className:`muted`,children:[r.summary.unchanged,` unchanged`]}),(0,J.jsx)(`button`,{className:`btn btn--sm`,onClick:()=>void u(),children:`Promote as Baseline`})]}),(0,J.jsxs)(`div`,{className:`muted`,style:{marginLeft:`auto`},children:[`Checked: `,lX(r.capturedAt)]})]}),r.sections.length>0&&(0,J.jsxs)(`div`,{style:{marginBottom:16},children:[(0,J.jsx)(`h4`,{style:{margin:`0 0 8px`,fontSize:13},children:`Sections with drift`}),(0,J.jsx)(hX,{sections:r.sections})]}),r.attributions.length>0&&(0,J.jsxs)(`div`,{style:{marginBottom:16},children:[(0,J.jsx)(`h4`,{style:{margin:`0 0 8px`,fontSize:13},children:`Change attribution`}),(0,J.jsx)(gX,{attributions:r.attributions})]}),!r.identical&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{style:{margin:`0 0 8px`,fontSize:13},children:`Unified diff`}),(0,J.jsx)(mX,{unified:r.unified})]})]}),!r&&!a&&!s&&(0,J.jsx)(`p`,{className:`muted`,style:{textAlign:`center`},children:`Click "Check Now" to run a live drift check against the golden baseline.`})]})}function vX(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)([]),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),u=(0,v.useCallback)(async()=>{try{let[e,n]=await Promise.all([q(`/api/drift/status`),q(`/api/drift/baselines`)]);t(e.devices),r(n.baselines),l(``)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);if((0,v.useEffect)(()=>{u();let e=setInterval(()=>void u(),15e3);return()=>clearInterval(e)},[u]),c&&e.length===0)return(0,J.jsx)(_c,{className:`reveal`,children:(0,J.jsx)(`p`,{style:{color:`#ef4444`},children:c})});let d=e.filter(e=>e.status!==`no-baseline`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`cards reveal`,children:[(0,J.jsx)(vc,{k:`Devices`,v:String(e.length)}),(0,J.jsx)(vc,{k:`With Baseline`,v:String(d.length)}),(0,J.jsx)(vc,{k:`In Sync`,v:String(e.filter(e=>e.status===`in-sync`).length)}),(0,J.jsx)(vc,{k:`Drifted`,v:String(e.filter(e=>e.status===`drifted`).length)})]}),(0,J.jsx)(_c,{title:`Fleet Drift Overview`,className:`reveal`,children:(0,J.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(240px, 1fr))`,gap:12},children:e.map(e=>(0,J.jsxs)(`div`,{onClick:()=>{e.status!==`no-baseline`&&a(e.device)},style:{padding:16,borderRadius:`var(--mt-radius, 8px)`,border:`1px solid ${i===e.device?`var(--mt-accent, #3b82f6)`:`var(--mt-border, #333)`}`,background:`var(--mt-surface-2, #111)`,cursor:e.status===`no-baseline`?`default`:`pointer`,transition:`border-color 0.2s`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,marginBottom:8},children:[(0,J.jsx)(`strong`,{style:{fontSize:14},children:e.device}),(0,J.jsx)(`span`,{style:{padding:`2px 8px`,borderRadius:10,fontSize:11,background:`${dX[e.status]}22`,color:dX[e.status],fontWeight:600},children:fX[e.status]})]}),e.baseline&&(0,J.jsxs)(`div`,{style:{fontSize:11,color:`var(--mt-text-dim, #aaa)`},children:[(0,J.jsxs)(`div`,{children:[`Baseline: `,uX(e.baseline.setAt)]}),e.baseline.label&&(0,J.jsxs)(`div`,{children:[`Label: `,e.baseline.label]})]}),e.status===`no-baseline`&&(0,J.jsx)(`button`,{className:`btn btn--xs`,style:{marginTop:8},onClick:t=>{t.stopPropagation(),s(e.device)},children:`Set Baseline`})]},e.device))})}),o&&(0,J.jsx)(_c,{title:`Set baseline for ${o}`,className:`reveal`,extra:(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:()=>s(null),children:`Cancel`}),children:(0,J.jsx)(pX,{device:o,onDone:()=>{s(null),u()}})}),i&&(0,J.jsx)(_X,{device:i,onClose:()=>a(null),onChanged:()=>{a(null),u()}}),n.length>0&&(0,J.jsx)(_c,{title:`Baseline Manager`,className:`reveal`,children:(0,J.jsx)(`div`,{style:{overflowX:`auto`},children:(0,J.jsxs)(`table`,{className:`tbl`,style:{fontSize:12},children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Device`}),(0,J.jsx)(`th`,{children:`Snapshot ID`}),(0,J.jsx)(`th`,{children:`Set At`}),(0,J.jsx)(`th`,{children:`Set By`}),(0,J.jsx)(`th`,{children:`Label`}),(0,J.jsx)(`th`,{children:`Size`}),(0,J.jsx)(`th`,{children:`SHA`}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:n.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsx)(`strong`,{children:e.device})}),(0,J.jsx)(`td`,{style:{fontFamily:`monospace`,fontSize:11},children:e.snapshotId}),(0,J.jsx)(`td`,{title:lX(e.setAt),children:uX(e.setAt)}),(0,J.jsx)(`td`,{children:e.setBy}),(0,J.jsx)(`td`,{children:e.label??`—`}),(0,J.jsx)(`td`,{children:e.snapshot?`${e.snapshot.lines} lines / ${e.snapshot.bytes} bytes`:`deleted`}),(0,J.jsx)(`td`,{style:{fontFamily:`monospace`,fontSize:10},children:e.snapshot?.sha?.slice(0,8)??`—`}),(0,J.jsx)(`td`,{children:(0,J.jsx)(`button`,{className:`btn btn--xs btn--danger`,onClick:()=>{mc(`/api/drift/baseline/${encodeURIComponent(e.device)}`,{}).then(()=>void u())},children:`Remove`})})]},e.device))})]})})}),e.length===0&&!c&&(0,J.jsx)(_c,{className:`reveal`,children:(0,J.jsx)(`p`,{className:`muted`,style:{textAlign:`center`},children:`No devices configured. Add devices to start using Drift Guard.`})})]})}function yX(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)&2147483647;return t%360}var bX=[`#3291ff`,`#34d399`,`#a78bfa`,`#f59e0b`,`#ef4444`,`#2dd4bf`,`#f472b6`,`#60a5fa`,`#facc15`,`#fb923c`];function xX(e){return bX[Math.abs(yX(e))%bX.length]}var SX={create_entity:`Created entity`,delete_entity:`Deleted entity`,create_relation:`Created relation`,delete_relation:`Deleted relation`,add_observation:`Added observations`,delete_observation:`Deleted observations`};function CX(e,t,n,r){let i=n/2,a=r/2,o=e.map((t,o)=>{let s=2*Math.PI*o/Math.max(e.length,1),c=Math.min(n,r)*.3;return{id:t.name,label:t.name,type:t.entityType,x:i+c*Math.cos(s),y:a+c*Math.sin(s),vx:0,vy:0,obsCount:t.observations.length}}),s=t.map(e=>({source:e.from,target:e.to,label:e.relationType})),c=new Map(o.map(e=>[e.id,e])),l=.005,u=.85;for(let e=0;e<200;e++){for(let e=0;e<o.length;e++)for(let t=e+1;t<o.length;t++){let n=o[e],r=o[t],i=n.x-r.x,a=n.y-r.y,s=Math.sqrt(i*i+a*a)||1,c=3e3/(s*s);i=i/s*c,a=a/s*c,n.vx+=i,n.vy+=a,r.vx-=i,r.vy-=a}for(let e of s){let t=c.get(e.source),n=c.get(e.target);if(!t||!n)continue;let r=n.x-t.x,i=n.y-t.y,a=r*l,o=i*l;t.vx+=a,t.vy+=o,n.vx-=a,n.vy-=o}for(let e of o)e.vx+=(i-e.x)*.001,e.vy+=(a-e.y)*.001;for(let e of o){e.vx*=u,e.vy*=u,e.x+=e.vx,e.y+=e.vy;let t=Math.max(40,e.label.length*2.7+16);e.x=Math.max(t,Math.min(n-t,e.x)),e.y=Math.max(30,Math.min(r-30,e.y))}}return{nodes:o,edges:s}}function wX({graph:e}){let t=(0,v.useRef)(null),[n,r]=(0,v.useState)(null),i=(0,v.useMemo)(()=>CX(e.entities,e.relations,700,460),[e.entities,e.relations]),a=(0,v.useMemo)(()=>new Map(i.nodes.map(e=>[e.id,e])),[i.nodes]);return e.entities.length===0?(0,J.jsx)(`div`,{style:{height:460,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--mt-text-faint)`},children:(0,J.jsx)(`p`,{children:`No entities yet — create some via the MCP tools.`})}):(0,J.jsxs)(`svg`,{ref:t,viewBox:`0 0 700 460`,style:{width:`100%`,height:`auto`,maxHeight:460,display:`block`},children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:`mem-arrow`,viewBox:`0 0 10 6`,refX:`10`,refY:`3`,markerWidth:`8`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,J.jsx)(`path`,{d:`M0 0 L10 3 L0 6Z`,fill:`#666`})})}),i.edges.map((e,t)=>{let r=a.get(e.source),i=a.get(e.target);if(!r||!i)return null;let o=n!=null&&(e.source===n||e.target===n),s=n!=null&&!o,c=i.x-r.x,l=i.y-r.y,u=Math.sqrt(c*c+l*l)||1,d=e=>{let t=e.label.length*5.4,n=13+Math.min(e.obsCount,6);return Math.max(n,t/2+12)},f=d(r)+4,p=d(i)+4,m=r.x+c/u*f,h=r.y+l/u*f,g=i.x-c/u*p,_=i.y-l/u*p,v=(m+g)/2,y=(h+_)/2;return(0,J.jsxs)(`g`,{opacity:s?.15:1,children:[(0,J.jsx)(`line`,{x1:m,y1:h,x2:g,y2:_,stroke:o?`#e4e4e7`:`#444`,strokeWidth:o?1.8:1,markerEnd:`url(#mem-arrow)`}),(0,J.jsx)(`text`,{x:v,y:y-5,textAnchor:`middle`,fill:`#888`,fontSize:`8`,style:{pointerEvents:`none`},children:e.label})]},t)}),i.nodes.map(e=>{let t=e.id===n,i=n!=null&&!t,a=xX(e.type),o=e.label,s=o.length*5.4,c=13+Math.min(e.obsCount,6),l=Math.max(c,s/2+12),u=c;return(0,J.jsxs)(`g`,{opacity:i?.25:1,style:{cursor:`pointer`},onClick:()=>r(t?null:e.id),children:[(0,J.jsx)(`rect`,{x:e.x-l,y:e.y-c,width:l*2,height:c*2,rx:u,ry:u,fill:a,fillOpacity:.15,stroke:t?`#fff`:a,strokeWidth:t?2:1.2}),(0,J.jsx)(`text`,{x:e.x,y:e.y+1,textAnchor:`middle`,dominantBaseline:`central`,fill:`#e8eaed`,fontSize:`9`,fontWeight:t?600:400,style:{pointerEvents:`none`},children:o}),(0,J.jsx)(`text`,{x:e.x,y:e.y+c+11,textAnchor:`middle`,fill:`#888`,fontSize:`7`,style:{pointerEvents:`none`},children:e.type})]},e.id)})]})}function TX({entity:e,relations:t,onClose:n,onDelete:r}){let i=t.filter(t=>t.to===e.name),a=t.filter(t=>t.from===e.name);return(0,J.jsxs)(`div`,{className:`panel`,style:{border:`1px solid var(--mt-border)`},children:[(0,J.jsxs)(`div`,{className:`sheet__hd`,style:{marginBottom:8},children:[(0,J.jsxs)(`h3`,{style:{margin:0},children:[(0,J.jsx)(`span`,{style:{display:`inline-block`,width:10,height:10,borderRadius:`50%`,backgroundColor:xX(e.entityType),marginRight:8}}),e.name]}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`button`,{className:`btn btn--danger btn--xs`,onClick:r,title:`Delete entity`,children:`Delete`}),(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:n,style:{marginLeft:6},children:`Close`})]}),(0,J.jsxs)(`p`,{className:`muted`,style:{margin:`0 0 8px`,fontSize:12},children:[`Type: `,(0,J.jsx)(`strong`,{children:e.entityType}),` · Created:`,` `,new Date(e.createdAt).toLocaleString(),` · Updated:`,` `,new Date(e.updatedAt).toLocaleString()]}),e.observations.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`h4`,{style:{margin:`12px 0 6px`,fontSize:12,color:`#9aa3af`},children:[`Observations (`,e.observations.length,`)`]}),(0,J.jsx)(`ul`,{style:{margin:0,paddingLeft:18,fontSize:13},children:e.observations.map((e,t)=>(0,J.jsx)(`li`,{style:{marginBottom:2},children:e},t))})]}),(a.length>0||i.length>0)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h4`,{style:{margin:`12px 0 6px`,fontSize:12,color:`#9aa3af`},children:`Relations`}),(0,J.jsxs)(`div`,{style:{fontSize:13},children:[a.map((e,t)=>(0,J.jsxs)(`div`,{children:[`→ `,(0,J.jsx)(`strong`,{children:e.relationType}),` → `,e.to]},`o${t}`)),i.map((e,t)=>(0,J.jsxs)(`div`,{children:[`← `,(0,J.jsx)(`strong`,{children:e.relationType}),` ← `,e.from]},`i${t}`))]})]})]})}function EX({activity:e}){return e.length===0?(0,J.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:`No activity yet.`}):(0,J.jsx)(`div`,{style:{maxHeight:280,overflowY:`auto`},children:(0,J.jsxs)(`table`,{className:`tbl`,style:{fontSize:12},children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Time`}),(0,J.jsx)(`th`,{children:`Action`}),(0,J.jsx)(`th`,{children:`Subject`})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{className:`muted`,style:{whiteSpace:`nowrap`},children:wc(e.ts)}),(0,J.jsx)(`td`,{children:SX[e.action]??e.action}),(0,J.jsx)(`td`,{style:{maxWidth:260,overflow:`hidden`,textOverflow:`ellipsis`},children:e.subject})]},e.id))})]})})}function DX({config:e,onSaved:t}){let[n,r]=(0,v.useState)(e.dbPath),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);(0,v.useEffect)(()=>{r(e.dbPath)},[e.dbPath]);let c=(0,v.useCallback)(async()=>{a(!0),s(``);try{let e=await pc(`/api/memory/config`,{dbPath:n});e.ok?(s(`Saved`),t()):s(e.error??`Failed`)}catch(e){s(String(e))}finally{a(!1)}},[n,t]);return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{style:{fontSize:12,color:`#9aa3af`,display:`block`,marginBottom:4},children:`Database path`}),(0,J.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,J.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),className:`input`,style:{flex:1,fontSize:13}}),(0,J.jsx)(`button`,{className:`btn btn--sm`,onClick:c,disabled:i||n===e.dbPath,children:i?`Saving…`:`Save`})]}),o&&(0,J.jsx)(`p`,{style:{fontSize:12,marginTop:4,color:o===`Saved`?`#34d399`:`#ef4444`},children:o}),e.stats&&(0,J.jsxs)(`div`,{className:`cards`,style:{marginTop:12},children:[(0,J.jsx)(vc,{k:`Entities`,v:String(e.stats.entities)}),(0,J.jsx)(vc,{k:`Relations`,v:String(e.stats.relations)}),(0,J.jsx)(vc,{k:`Observations`,v:String(e.stats.observations)})]})]})}function OX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),m=(0,v.useCallback)(async()=>{try{let[e,n,i,o]=await Promise.all([q(`/api/memory/graph`),q(`/api/memory/stats`),q(`/api/memory/config`),q(`/api/memory/activity?limit=50`)]);t(e),r(n),a(i),s(o),p(``)}catch(e){p(String(e))}},[]);(0,v.useEffect)(()=>{m();let e=setInterval(()=>void m(),1e4);return()=>clearInterval(e)},[m]);let h=(0,v.useCallback)(async()=>{if(!u.trim()){m();return}try{let e=await q(`/api/memory/search?q=${encodeURIComponent(u)}`);t(e)}catch(e){p(String(e))}},[u,m]),g=(0,v.useCallback)(async e=>{await mc(`/api/memory/entities`,{names:[e]}),l(null),m()},[m]);return f&&!e?(0,J.jsx)(_c,{title:`Knowledge Graph`,children:(0,J.jsx)(`p`,{style:{color:`#ef4444`},children:f})}):(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsxs)(`div`,{className:`cards reveal`,children:[(0,J.jsx)(vc,{k:`Entities`,v:String(n.entities)}),(0,J.jsx)(vc,{k:`Relations`,v:String(n.relations)}),(0,J.jsx)(vc,{k:`Observations`,v:String(n.observations)}),(0,J.jsx)(vc,{k:`Entity types`,v:String(n.entityTypes.length)}),(0,J.jsx)(vc,{k:`Relation types`,v:String(n.relationTypes.length)})]}),(0,J.jsx)(_c,{title:`Knowledge Graph`,className:`reveal`,extra:(0,J.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,J.jsx)(`input`,{type:`text`,placeholder:`Search entities…`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>e.key===`Enter`&&h(),className:`input`,style:{width:200,fontSize:12}}),(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:h,children:`Search`}),u&&(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:()=>{d(``),m()},children:`Clear`})]}),children:e&&(0,J.jsx)(wX,{graph:e})}),(0,J.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16},className:`reveal`,children:[(0,J.jsx)(_c,{title:`Entities`,children:e&&e.entities.length>0?(0,J.jsx)(`div`,{style:{maxHeight:360,overflowY:`auto`},children:(0,J.jsxs)(`table`,{className:`tbl`,style:{fontSize:12},children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Name`}),(0,J.jsx)(`th`,{children:`Type`}),(0,J.jsx)(`th`,{children:`Obs`}),(0,J.jsx)(`th`,{children:`Created`})]})}),(0,J.jsx)(`tbody`,{children:e.entities.map(e=>(0,J.jsxs)(`tr`,{style:{cursor:`pointer`,background:c?.name===e.name?`rgba(255,255,255,0.05)`:void 0},onClick:()=>l(e),children:[(0,J.jsxs)(`td`,{children:[(0,J.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,backgroundColor:xX(e.entityType),marginRight:6}}),e.name]}),(0,J.jsx)(`td`,{className:`muted`,children:e.entityType}),(0,J.jsx)(`td`,{children:e.observations.length}),(0,J.jsx)(`td`,{className:`muted`,children:wc(e.createdAt)})]},e.name))})]})}):(0,J.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:e?`No entities.`:`Loading…`})}),c&&e?(0,J.jsx)(TX,{entity:c,relations:e.relations,onClose:()=>l(null),onDelete:()=>g(c.name)}):(0,J.jsx)(_c,{title:`Activity Log`,children:(0,J.jsx)(EX,{activity:o})})]}),n&&(n.entityTypes.length>0||n.relationTypes.length>0)&&(0,J.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16},className:`reveal`,children:[n.entityTypes.length>0&&(0,J.jsx)(_c,{title:`Entity Types`,children:(0,J.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:n.entityTypes.map(e=>(0,J.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,padding:`2px 10px`,borderRadius:12,background:`${xX(e.type)}22`,border:`1px solid ${xX(e.type)}44`,fontSize:12},children:[(0,J.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,backgroundColor:xX(e.type)}}),e.type,(0,J.jsxs)(`span`,{className:`muted`,children:[`(`,e.count,`)`]})]},e.type))})}),n.relationTypes.length>0&&(0,J.jsx)(_c,{title:`Relation Types`,children:(0,J.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:n.relationTypes.map(e=>(0,J.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,padding:`2px 10px`,borderRadius:12,background:`rgba(255,255,255,0.05)`,border:`1px solid var(--mt-border)`,fontSize:12},children:[e.type,(0,J.jsxs)(`span`,{className:`muted`,children:[`(`,e.count,`)`]})]},e.type))})})]}),i&&(0,J.jsx)(_c,{title:`Memory Configuration`,className:`reveal`,children:(0,J.jsx)(DX,{config:i,onSaved:m})})]})}function kX({m:e,busy:t,onToggle:n}){return(0,J.jsxs)(`label`,{className:`mod-row`,"data-on":e.enabled?`1`:void 0,title:e.description,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:t,onChange:()=>n(e.slug,!e.enabled)}),(0,J.jsxs)(`span`,{className:`mod-row__main`,children:[(0,J.jsxs)(`span`,{className:`mod-row__name`,children:[e.label,(0,J.jsx)(`code`,{className:`mod-row__slug`,children:e.slug})]}),(0,J.jsx)(`span`,{className:`mod-row__desc muted`,children:e.description})]}),(0,J.jsxs)(`span`,{className:`mod-row__count muted`,children:[e.toolCount,` tool`,e.toolCount===1?``:`s`]})]})}function AX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(new Set),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),c=(0,v.useCallback)(()=>{q(`/api/modules`).then(t).catch(()=>a(`could not load modules`))},[]);(0,v.useEffect)(()=>c(),[c]);let l=e=>t(t=>t?{...t,...e}:e),u=(0,v.useCallback)(async(e,n)=>{r(t=>new Set(t).add(e)),t(t=>t&&{...t,modules:t.modules.map(t=>t.slug===e?{...t,enabled:n}:t)});let i=await pc(`/api/modules/toggle`,{slug:e,enabled:n}).catch(()=>({error:`request failed`}));if(r(t=>{let n=new Set(t);return n.delete(e),n}),i.error||i.ok===!1){a(i.error??`toggle failed`),c();return}l(i);let o=i.persisted?`saved to config`:`applied live (not saved)`,s=i.warning?` ⚠ ${i.warning}`:``;a(`${e} ${n?`enabled`:`disabled`} — ${o}. Reconnect the MCP client (or restart the server) for the tool list to update.${s}`)},[c]),d=(0,v.useCallback)(async(e,t)=>{for(let n of e)await u(n,t)},[u]),f=(0,v.useMemo)(()=>{if(!e)return[];let t=o.trim().toLowerCase(),n=e=>!t||e.slug.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||e.group.toLowerCase().includes(t)||e.description.toLowerCase().includes(t),r=new Map;for(let t of e.modules){if(!n(t))continue;let e=r.get(t.group)??[];e.push(t),r.set(t.group,e)}return[...r.entries()].map(([e,t])=>({group:e,modules:t}))},[e,o]);if(!e)return(0,J.jsx)(`div`,{className:`muted`,children:`loading modules…`});let p=f.reduce((e,t)=>e+t.modules.length,0);return(0,J.jsx)(`section`,{className:`view`,children:(0,J.jsxs)(_c,{title:`Tool modules`,className:`reveal`,extra:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`muted`,children:[e.enabledModules,`/`,e.total,` modules · `,e.enabledTools,`/`,e.totalTools,` `,`tools exposed`]}),(0,J.jsx)(`button`,{className:`btn`,onClick:c,style:{marginLeft:10},children:`↻ Refresh`})]}),children:[(0,J.jsxs)(`div`,{className:`legend`,style:{margin:`0 0 10px`},children:[(0,J.jsxs)(`span`,{children:[`writes to: `,(0,J.jsx)(`code`,{children:e.source?.path??`config file`})]}),(0,J.jsx)(`span`,{children:e.hasAllowList?`allow-list active`:`all modules on by default`})]}),(0,J.jsxs)(`p`,{className:`muted`,style:{margin:`0 0 12px`,fontSize:12},children:[`Toggle a module to expose or hide all of its tools. Disabling adds it to`,` `,(0,J.jsx)(`code`,{children:`tools.disabledModules`}),` in your config file; enabling removes it (or adds it to`,` `,(0,J.jsx)(`code`,{children:`tools.enabledModules`}),` when an allow-list is in force). Trimming the surface below ~150–200 tools makes every remaining tool reliably findable by the MCP client. The client must reconnect for changes to take effect.`]}),(0,J.jsxs)(`div`,{className:`mod-toolbar`,children:[(0,J.jsx)(`input`,{className:`input`,placeholder:`Filter modules by name, slug, group or description…`,value:o,onChange:e=>s(e.target.value)}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`button`,{className:`btn`,onClick:()=>void d(e.modules.filter(e=>!e.enabled).map(e=>e.slug),!0),children:`Enable all`}),` `,(0,J.jsx)(`button`,{className:`btn`,onClick:()=>void d(e.modules.filter(e=>e.enabled).map(e=>e.slug),!1),children:`Disable all`})]}),i&&(0,J.jsx)(`div`,{className:`cfg-msg`,style:{marginTop:12},children:i}),p===0?(0,J.jsxs)(`div`,{className:`muted`,style:{padding:12},children:[`No modules match “`,o,`”.`]}):(0,J.jsx)(`div`,{className:`mod-groups`,children:f.map(({group:e,modules:t})=>{let r=t.filter(e=>e.enabled).length,i=t.map(e=>e.slug);return(0,J.jsxs)(`div`,{className:`mod-group`,children:[(0,J.jsxs)(`div`,{className:`mod-group__hd`,children:[(0,J.jsx)(`h3`,{className:`mod-group__title`,children:e}),(0,J.jsxs)(`span`,{className:`muted`,children:[r,`/`,t.length,` on`]}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>void d(i.filter(e=>{let n=t.find(t=>t.slug===e);return n?!n.enabled:!1}),!0),children:`Enable group`}),` `,(0,J.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>void d(i.filter(e=>{let n=t.find(t=>t.slug===e);return n?n.enabled:!1}),!1),children:`Disable group`})]}),(0,J.jsx)(`div`,{className:`mod-list`,children:t.map(e=>(0,J.jsx)(kX,{m:e,busy:n.has(e.slug),onToggle:(e,t)=>void u(e,t)},e.slug))})]},e)})})]})})}var jX={TCP:`#e4e4e7`,UDP:`#d4d4d8`,ICMP:`#a1a1aa`,ICMPv6:`#a1a1aa`,ARP:`#e4e4e7`,IPv6:`#a1a1aa`},MX=e=>e&&jX[e]||`#71717a`;function NX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=()=>void q(`/api/capture/packets?limit=150`).then(t).catch(()=>{});e();let n=setInterval(e,1500);return()=>clearInterval(n)},[]);let i=e?.stats,a=e?.packets??[],o=async()=>{r(!0),await pc(`/api/capture/stop`,{}).catch(()=>{}),r(!1)};if(!i||!i.running&&i.packets===0)return(0,J.jsxs)(`div`,{className:`cap-idle muted`,children:[`No capture running. Start one with the `,(0,J.jsx)(`code`,{children:`start_packet_capture`}),` tool — point the device's TZSP stream at this host — and decoded packets stream in here live.`]});let s=Math.max(1,...Object.values(i.protocols));return(0,J.jsxs)(`div`,{className:`cap`,children:[(0,J.jsxs)(`div`,{className:`cap-bar`,children:[(0,J.jsx)(`span`,{className:`cap-dot${i.running?` is-on`:``}`}),(0,J.jsx)(`b`,{children:i.running?`capturing`:`stopped`}),(0,J.jsxs)(`span`,{className:`muted`,children:[`UDP `,i.port]}),(0,J.jsxs)(`span`,{className:`muted`,children:[Tc(i.packets),` pkts · `,Cc(i.bytes)]}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`a`,{className:`btn`,href:fc(`/api/capture/pcap`),download:`capture.pcap`,children:`⤓ pcap`}),(0,J.jsx)(`button`,{className:`btn btn-danger`,onClick:()=>void o(),disabled:n||!i.running,children:`■ Stop`})]}),(0,J.jsxs)(`div`,{className:`cap-cols`,children:[(0,J.jsxs)(`div`,{className:`cap-side`,children:[(0,J.jsx)(`div`,{className:`cap-h`,children:`Protocols`}),Object.entries(i.protocols).map(([e,t])=>(0,J.jsxs)(`div`,{className:`cap-pbar`,children:[(0,J.jsx)(`span`,{className:`cap-plabel`,style:{color:MX(e)},children:e}),(0,J.jsx)(`span`,{className:`cap-ptrack`,children:(0,J.jsx)(`i`,{style:{width:`${t/s*100}%`,background:MX(e)}})}),(0,J.jsx)(`span`,{className:`cap-pn`,children:t})]},e)),(0,J.jsx)(`div`,{className:`cap-h`,style:{marginTop:12},children:`Top talkers`}),i.topTalkers.length===0&&(0,J.jsx)(`div`,{className:`muted`,children:`—`}),i.topTalkers.map(e=>(0,J.jsxs)(`div`,{className:`cap-talker`,children:[(0,J.jsx)(`span`,{children:e.addr}),(0,J.jsx)(`b`,{children:e.count})]},e.addr))]}),(0,J.jsx)(`div`,{className:`cap-list`,children:a.length===0?(0,J.jsx)(`div`,{className:`muted`,style:{padding:10},children:`waiting for packets…`}):a.map((e,t)=>(0,J.jsxs)(`div`,{className:`cap-row`,children:[(0,J.jsx)(`span`,{className:`cap-tt`,children:wc(e.ts)}),(0,J.jsx)(`span`,{className:`cap-proto`,style:{color:MX(e.protocol)},children:e.protocol??e.ethType}),(0,J.jsx)(`span`,{className:`cap-len`,children:e.len}),(0,J.jsx)(`span`,{className:`cap-info`,children:e.info})]},t))})]})]})}function PX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(()=>{q(`/api/s3/list`).then(t).catch(()=>t({configured:!1,objects:[]}))},[]);(0,v.useEffect)(()=>c(),[c]);let l=e=>{q(`/api/s3/presign?key=${encodeURIComponent(e)}`).then(e=>{e.url?window.open(e.url,`_blank`,`noopener`):s(`could not generate download link`)}).catch(()=>s(`could not generate download link`))},u=async e=>{a(e);let t=await pc(`/api/s3/delete`,{key:e}).catch(()=>({error:`request failed`}));a(null),r(null),t.ok?(s(`Deleted ${e}`),c()):s(t.error??`delete failed`)};return e?e.configured?(0,J.jsx)(`section`,{className:`view`,children:(0,J.jsxs)(_c,{title:`S3 backups`,className:`reveal`,extra:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`muted`,children:[e.target,` · `,e.objects.length,` object`,e.objects.length===1?``:`s`,e.truncated?` (truncated)`:``]}),(0,J.jsx)(`button`,{className:`btn`,onClick:c,style:{marginLeft:10},children:`↻ Refresh`})]}),children:[o&&(0,J.jsx)(`div`,{className:`cfg-msg`,children:o}),e.objects.length===0?(0,J.jsxs)(`div`,{className:`muted`,style:{padding:12},children:[`No objects in the bucket. Upload one with the `,(0,J.jsx)(`code`,{children:`upload_backup_to_s3`}),` tool.`]}):(0,J.jsx)(`div`,{className:`feedwrap`,children:(0,J.jsxs)(`table`,{className:`feed`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`key`}),(0,J.jsx)(`th`,{className:`num`,children:`size`}),(0,J.jsx)(`th`,{children:`modified`}),(0,J.jsx)(`th`,{style:{width:200},children:`actions`})]})}),(0,J.jsx)(`tbody`,{children:e.objects.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:e.key}),(0,J.jsx)(`td`,{className:`num`,children:Cc(e.size)}),(0,J.jsx)(`td`,{children:e.lastModified?new Date(e.lastModified).toLocaleString(void 0,{hour12:!1}):`—`}),(0,J.jsxs)(`td`,{onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`button`,{className:`btn`,onClick:()=>l(e.key),children:`⤓ Download`}),` `,n===e.key?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{className:`btn btn-danger`,disabled:i===e.key,onClick:()=>void u(e.key),children:`✓ Confirm`}),` `,(0,J.jsx)(`button`,{className:`btn`,onClick:()=>r(null),children:`Cancel`})]}):(0,J.jsx)(`button`,{className:`btn`,onClick:()=>r(e.key),children:`🗑 Delete`})]})]},e.key))})]})})]})}):(0,J.jsxs)(`div`,{className:`feed-empty`,children:[(0,J.jsx)(`div`,{className:`feed-empty__icon`,children:`☁️`}),(0,J.jsx)(`p`,{className:`feed-empty__title`,children:`S3 is not configured`}),(0,J.jsxs)(`p`,{className:`feed-empty__sub`,children:[`Add an `,(0,J.jsx)(`code`,{children:`s3`}),` block (bucket + credentials) to your config to manage backup objects here.`]})]}):(0,J.jsx)(`div`,{className:`muted`,children:`loading S3 objects…`})}function FX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),u=(0,v.useCallback)(()=>{q(`/api/snapshots`).then(e=>t(e.snapshots)).catch(()=>t([]))},[]);(0,v.useEffect)(()=>u(),[u]);let d=e=>{q(`/api/snapshot/${encodeURIComponent(e)}`).then(s).catch(()=>{})},f=()=>{!n||!i||pc(`/api/snapshots/diff`,{from:n,to:i}).then(l).catch(()=>{})};if(!e)return(0,J.jsx)(`div`,{className:`muted`,children:`loading snapshots…`});if(e.length===0)return(0,J.jsxs)(`div`,{className:`feed-empty`,children:[(0,J.jsx)(`div`,{className:`feed-empty__icon`,children:`🕰️`}),(0,J.jsx)(`p`,{className:`feed-empty__title`,children:`No config snapshots yet`}),(0,J.jsxs)(`p`,{className:`feed-empty__sub`,children:[`Capture one with the `,(0,J.jsx)(`code`,{children:`capture_config_snapshot`}),` tool — then time-travel diff any two here.`]})]});let p=e.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.device,` · `,e.label??e.id,` · `,wc(e.ts)]},e.id));return(0,J.jsxs)(`section`,{className:`view`,children:[(0,J.jsxs)(_c,{title:`Config snapshots`,className:`reveal`,extra:(0,J.jsx)(`button`,{className:`btn`,onClick:u,children:`↻ Refresh`}),children:[(0,J.jsxs)(`div`,{className:`toolbar`,style:{marginBottom:12},children:[(0,J.jsxs)(`select`,{className:`btn`,value:n,onChange:e=>r(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`diff from…`}),p]}),(0,J.jsxs)(`select`,{className:`btn`,value:i,onChange:e=>a(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`to…`}),p]}),(0,J.jsx)(`button`,{className:`btn is-active`,onClick:f,disabled:!n||!i,children:`Diff →`}),(0,J.jsxs)(`span`,{className:`muted`,children:[e.length,` snapshots`]})]}),(0,J.jsx)(`div`,{className:`feedwrap`,children:(0,J.jsxs)(`table`,{className:`feed`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`captured`}),(0,J.jsx)(`th`,{children:`device`}),(0,J.jsx)(`th`,{children:`label`}),(0,J.jsx)(`th`,{children:`version`}),(0,J.jsx)(`th`,{className:`num`,children:`lines`}),(0,J.jsx)(`th`,{className:`num`,children:`size`}),(0,J.jsx)(`th`,{children:`output`})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsxs)(`tr`,{className:o?.id===e.id?`is-selected`:void 0,onClick:()=>d(e.id),children:[(0,J.jsx)(`td`,{children:wc(e.ts)}),(0,J.jsx)(`td`,{children:e.device}),(0,J.jsx)(`td`,{children:e.label??`—`}),(0,J.jsx)(`td`,{children:e.rosVersion??`—`}),(0,J.jsx)(`td`,{className:`num`,children:e.lines}),(0,J.jsx)(`td`,{className:`num`,children:Cc(e.bytes)}),(0,J.jsx)(`td`,{className:`preview`,children:`view export →`})]},e.id))})]})})]}),c&&(0,J.jsx)(_c,{title:`Time-travel diff`,className:`reveal`,extra:(0,J.jsx)(`span`,{className:`muted`,children:c.summary.changed?`+${c.summary.added} / -${c.summary.removed}`:`identical`}),children:(0,J.jsx)(`pre`,{className:`cfg-diff`,children:(c.unified||`(identical)`).split(`
|
|
80
|
+
`).map((e,t)=>{let n=`var(--mt-text-dim, #aaa)`,r=`transparent`;return e.startsWith(`+`)?(n=`#22c55e`,r=`rgba(34,197,94,0.08)`):e.startsWith(`-`)?(n=`#ef4444`,r=`rgba(239,68,68,0.08)`):e.startsWith(`@@`)?n=`#3b82f6`:e.startsWith(`/`)&&(n=`#f59e0b`),(0,J.jsx)(`div`,{style:{color:n,background:r,padding:`0 4px`},children:e||`\xA0`},t)})}):(0,J.jsx)(`span`,{className:`muted`,children:`No differences.`})}function hX({sections:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.added+e.removed),1);return(0,J.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:e.slice(0,15).map(e=>(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,J.jsx)(`span`,{style:{width:220,fontSize:11,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:`var(--mt-text, #eee)`},title:e.path,children:e.path}),(0,J.jsxs)(`div`,{style:{flex:1,height:14,background:`var(--mt-surface-2, #222)`,borderRadius:3,overflow:`hidden`,display:`flex`},children:[(0,J.jsx)(`div`,{style:{width:`${e.added/t*100}%`,background:`#22c55e`,height:`100%`}}),(0,J.jsx)(`div`,{style:{width:`${e.removed/t*100}%`,background:`#ef4444`,height:`100%`}})]}),(0,J.jsxs)(`span`,{style:{fontSize:11,color:`var(--mt-text-dim, #aaa)`,minWidth:60},children:[`+`,e.added,` -`,e.removed]})]},e.path))})}function gX({attributions:e}){return e.length===0?(0,J.jsx)(`span`,{className:`muted`,children:`No config-related log entries found.`}):(0,J.jsx)(`div`,{style:{maxHeight:250,overflowY:`auto`},children:(0,J.jsxs)(`table`,{className:`tbl`,style:{fontSize:11},children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Time`}),(0,J.jsx)(`th`,{children:`User`}),(0,J.jsx)(`th`,{children:`Action`}),(0,J.jsx)(`th`,{children:`Section`}),(0,J.jsx)(`th`,{children:`Log`})]})}),(0,J.jsx)(`tbody`,{children:e.map((e,t)=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{style:{whiteSpace:`nowrap`},children:e.timestamp??`—`}),(0,J.jsx)(`td`,{children:e.user??`—`}),(0,J.jsx)(`td`,{children:(0,J.jsx)(`span`,{style:{padding:`1px 6px`,borderRadius:4,background:`var(--mt-surface-2, #222)`,fontSize:10},children:e.action??`?`})}),(0,J.jsx)(`td`,{style:{maxWidth:160,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.section,children:e.section}),(0,J.jsx)(`td`,{style:{maxWidth:300,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:`var(--mt-text-dim, #aaa)`},title:e.logLine,children:e.logLine})]},t))})]})})}function _X({device:e,onClose:t,onChanged:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=(0,v.useCallback)(async()=>{o(!0),c(``);try{let t=await q(`/api/drift/check/${encodeURIComponent(e)}`);`error`in t?c(t.error):i(t)}catch(e){c(e instanceof Error?e.message:String(e))}o(!1)},[e]),u=async()=>{(await pc(`/api/drift/baseline`,{device:e,snapshotId:r?.baselineId,label:`promoted`})).error||n()},d=async()=>{await mc(`/api/drift/baseline/${encodeURIComponent(e)}`,{}),n()};return(0,J.jsxs)(_c,{title:`${e} — Drift Detail`,className:`reveal`,extra:(0,J.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,J.jsx)(`button`,{className:`btn btn--sm`,onClick:()=>void l(),disabled:a,children:a?`Checking...`:`Check Now`}),(0,J.jsx)(`button`,{className:`btn btn--sm btn--danger`,onClick:()=>void d(),children:`Remove Baseline`}),(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:t,children:`Close`})]}),children:[s&&(0,J.jsx)(`div`,{style:{color:`#ef4444`},children:s}),r&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{style:{display:`flex`,gap:24,alignItems:`center`,padding:`12px 0`,borderBottom:`1px solid var(--mt-border, #333)`,marginBottom:12},children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{style:{display:`inline-block`,width:10,height:10,borderRadius:`50%`,background:r.identical?`#22c55e`:`#f59e0b`,marginRight:6}}),(0,J.jsx)(`strong`,{children:r.identical?`In Sync`:`Drifted`})]}),!r.identical&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{children:[`Score: `,(0,J.jsx)(`strong`,{children:r.score}),`/100`]}),(0,J.jsxs)(`div`,{style:{color:`#22c55e`},children:[`+`,r.summary.added]}),(0,J.jsxs)(`div`,{style:{color:`#ef4444`},children:[`-`,r.summary.removed]}),(0,J.jsxs)(`div`,{className:`muted`,children:[r.summary.unchanged,` unchanged`]}),(0,J.jsx)(`button`,{className:`btn btn--sm`,onClick:()=>void u(),children:`Promote as Baseline`})]}),(0,J.jsxs)(`div`,{className:`muted`,style:{marginLeft:`auto`},children:[`Checked: `,lX(r.capturedAt)]})]}),r.sections.length>0&&(0,J.jsxs)(`div`,{style:{marginBottom:16},children:[(0,J.jsx)(`h4`,{style:{margin:`0 0 8px`,fontSize:13},children:`Sections with drift`}),(0,J.jsx)(hX,{sections:r.sections})]}),r.attributions.length>0&&(0,J.jsxs)(`div`,{style:{marginBottom:16},children:[(0,J.jsx)(`h4`,{style:{margin:`0 0 8px`,fontSize:13},children:`Change attribution`}),(0,J.jsx)(gX,{attributions:r.attributions})]}),!r.identical&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{style:{margin:`0 0 8px`,fontSize:13},children:`Unified diff`}),(0,J.jsx)(mX,{unified:r.unified})]})]}),!r&&!a&&!s&&(0,J.jsx)(`p`,{className:`muted`,style:{textAlign:`center`},children:`Click "Check Now" to run a live drift check against the golden baseline.`})]})}function vX(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)([]),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),u=(0,v.useCallback)(async()=>{try{let[e,n]=await Promise.all([q(`/api/drift/status`),q(`/api/drift/baselines`)]);t(e.devices),r(n.baselines),l(``)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);if((0,v.useEffect)(()=>{u();let e=setInterval(()=>void u(),15e3);return()=>clearInterval(e)},[u]),c&&e.length===0)return(0,J.jsx)(_c,{className:`reveal`,children:(0,J.jsx)(`p`,{style:{color:`#ef4444`},children:c})});let d=e.filter(e=>e.status!==`no-baseline`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`cards reveal`,children:[(0,J.jsx)(vc,{k:`Devices`,v:String(e.length)}),(0,J.jsx)(vc,{k:`With Baseline`,v:String(d.length)}),(0,J.jsx)(vc,{k:`In Sync`,v:String(e.filter(e=>e.status===`in-sync`).length)}),(0,J.jsx)(vc,{k:`Drifted`,v:String(e.filter(e=>e.status===`drifted`).length)})]}),(0,J.jsx)(_c,{title:`Fleet Drift Overview`,className:`reveal`,children:(0,J.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(240px, 1fr))`,gap:12},children:e.map(e=>(0,J.jsxs)(`div`,{onClick:()=>{e.status!==`no-baseline`&&a(e.device)},style:{padding:16,borderRadius:`var(--mt-radius, 8px)`,border:`1px solid ${i===e.device?`var(--mt-accent, #3b82f6)`:`var(--mt-border, #333)`}`,background:`var(--mt-surface-2, #111)`,cursor:e.status===`no-baseline`?`default`:`pointer`,transition:`border-color 0.2s`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,marginBottom:8},children:[(0,J.jsx)(`strong`,{style:{fontSize:14},children:e.device}),(0,J.jsx)(`span`,{style:{padding:`2px 8px`,borderRadius:10,fontSize:11,background:`${dX[e.status]}22`,color:dX[e.status],fontWeight:600},children:fX[e.status]})]}),e.baseline&&(0,J.jsxs)(`div`,{style:{fontSize:11,color:`var(--mt-text-dim, #aaa)`},children:[(0,J.jsxs)(`div`,{children:[`Baseline: `,uX(e.baseline.setAt)]}),e.baseline.label&&(0,J.jsxs)(`div`,{children:[`Label: `,e.baseline.label]})]}),e.status===`no-baseline`&&(0,J.jsx)(`button`,{className:`btn btn--xs`,style:{marginTop:8},onClick:t=>{t.stopPropagation(),s(e.device)},children:`Set Baseline`})]},e.device))})}),o&&(0,J.jsx)(_c,{title:`Set baseline for ${o}`,className:`reveal`,extra:(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:()=>s(null),children:`Cancel`}),children:(0,J.jsx)(pX,{device:o,onDone:()=>{s(null),u()}})}),i&&(0,J.jsx)(_X,{device:i,onClose:()=>a(null),onChanged:()=>{a(null),u()}}),n.length>0&&(0,J.jsx)(_c,{title:`Baseline Manager`,className:`reveal`,children:(0,J.jsx)(`div`,{style:{overflowX:`auto`},children:(0,J.jsxs)(`table`,{className:`tbl`,style:{fontSize:12},children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Device`}),(0,J.jsx)(`th`,{children:`Snapshot ID`}),(0,J.jsx)(`th`,{children:`Set At`}),(0,J.jsx)(`th`,{children:`Set By`}),(0,J.jsx)(`th`,{children:`Label`}),(0,J.jsx)(`th`,{children:`Size`}),(0,J.jsx)(`th`,{children:`SHA`}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:n.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsx)(`strong`,{children:e.device})}),(0,J.jsx)(`td`,{style:{fontFamily:`monospace`,fontSize:11},children:e.snapshotId}),(0,J.jsx)(`td`,{title:lX(e.setAt),children:uX(e.setAt)}),(0,J.jsx)(`td`,{children:e.setBy}),(0,J.jsx)(`td`,{children:e.label??`—`}),(0,J.jsx)(`td`,{children:e.snapshot?`${e.snapshot.lines} lines / ${e.snapshot.bytes} bytes`:`deleted`}),(0,J.jsx)(`td`,{style:{fontFamily:`monospace`,fontSize:10},children:e.snapshot?.sha?.slice(0,8)??`—`}),(0,J.jsx)(`td`,{children:(0,J.jsx)(`button`,{className:`btn btn--xs btn--danger`,onClick:()=>{mc(`/api/drift/baseline/${encodeURIComponent(e.device)}`,{}).then(()=>void u())},children:`Remove`})})]},e.device))})]})})}),e.length===0&&!c&&(0,J.jsx)(_c,{className:`reveal`,children:(0,J.jsx)(`p`,{className:`muted`,style:{textAlign:`center`},children:`No devices configured. Add devices to start using Drift Guard.`})})]})}function yX(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)&2147483647;return t%360}var bX=[`#3291ff`,`#34d399`,`#a78bfa`,`#f59e0b`,`#ef4444`,`#2dd4bf`,`#f472b6`,`#60a5fa`,`#facc15`,`#fb923c`];function xX(e){return bX[Math.abs(yX(e))%bX.length]}var SX={create_entity:`Created entity`,delete_entity:`Deleted entity`,create_relation:`Created relation`,delete_relation:`Deleted relation`,add_observation:`Added observations`,delete_observation:`Deleted observations`};function CX(e,t,n,r){let i=n/2,a=r/2,o=e.map((t,o)=>{let s=2*Math.PI*o/Math.max(e.length,1),c=Math.min(n,r)*.3;return{id:t.name,label:t.name,type:t.entityType,x:i+c*Math.cos(s),y:a+c*Math.sin(s),vx:0,vy:0,obsCount:t.observations.length}}),s=t.map(e=>({source:e.from,target:e.to,label:e.relationType})),c=new Map(o.map(e=>[e.id,e])),l=.005,u=.85;for(let e=0;e<200;e++){for(let e=0;e<o.length;e++)for(let t=e+1;t<o.length;t++){let n=o[e],r=o[t],i=n.x-r.x,a=n.y-r.y,s=Math.sqrt(i*i+a*a)||1,c=3e3/(s*s);i=i/s*c,a=a/s*c,n.vx+=i,n.vy+=a,r.vx-=i,r.vy-=a}for(let e of s){let t=c.get(e.source),n=c.get(e.target);if(!t||!n)continue;let r=n.x-t.x,i=n.y-t.y,a=r*l,o=i*l;t.vx+=a,t.vy+=o,n.vx-=a,n.vy-=o}for(let e of o)e.vx+=(i-e.x)*.001,e.vy+=(a-e.y)*.001;for(let e of o){e.vx*=u,e.vy*=u,e.x+=e.vx,e.y+=e.vy;let t=Math.max(40,e.label.length*2.7+16);e.x=Math.max(t,Math.min(n-t,e.x)),e.y=Math.max(30,Math.min(r-30,e.y))}}return{nodes:o,edges:s}}function wX({graph:e}){let t=(0,v.useRef)(null),[n,r]=(0,v.useState)(null),i=(0,v.useMemo)(()=>CX(e.entities,e.relations,700,460),[e.entities,e.relations]),a=(0,v.useMemo)(()=>new Map(i.nodes.map(e=>[e.id,e])),[i.nodes]);return e.entities.length===0?(0,J.jsx)(`div`,{style:{height:460,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--mt-text-faint)`},children:(0,J.jsx)(`p`,{children:`No entities yet — create some via the MCP tools.`})}):(0,J.jsxs)(`svg`,{ref:t,viewBox:`0 0 700 460`,style:{width:`100%`,height:`auto`,maxHeight:460,display:`block`},children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:`mem-arrow`,viewBox:`0 0 10 6`,refX:`10`,refY:`3`,markerWidth:`8`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,J.jsx)(`path`,{d:`M0 0 L10 3 L0 6Z`,fill:`#666`})})}),i.edges.map((e,t)=>{let r=a.get(e.source),i=a.get(e.target);if(!r||!i)return null;let o=n!=null&&(e.source===n||e.target===n),s=n!=null&&!o,c=i.x-r.x,l=i.y-r.y,u=Math.sqrt(c*c+l*l)||1,d=e=>{let t=e.label.length*5.4,n=13+Math.min(e.obsCount,6);return Math.max(n,t/2+12)},f=d(r)+4,p=d(i)+4,m=r.x+c/u*f,h=r.y+l/u*f,g=i.x-c/u*p,_=i.y-l/u*p,v=(m+g)/2,y=(h+_)/2;return(0,J.jsxs)(`g`,{opacity:s?.15:1,children:[(0,J.jsx)(`line`,{x1:m,y1:h,x2:g,y2:_,stroke:o?`#e4e4e7`:`#444`,strokeWidth:o?1.8:1,markerEnd:`url(#mem-arrow)`}),(0,J.jsx)(`text`,{x:v,y:y-5,textAnchor:`middle`,fill:`#888`,fontSize:`8`,style:{pointerEvents:`none`},children:e.label})]},t)}),i.nodes.map(e=>{let t=e.id===n,i=n!=null&&!t,a=xX(e.type),o=e.label,s=o.length*5.4,c=13+Math.min(e.obsCount,6),l=Math.max(c,s/2+12),u=c;return(0,J.jsxs)(`g`,{opacity:i?.25:1,style:{cursor:`pointer`},onClick:()=>r(t?null:e.id),children:[(0,J.jsx)(`rect`,{x:e.x-l,y:e.y-c,width:l*2,height:c*2,rx:u,ry:u,fill:a,fillOpacity:.15,stroke:t?`#fff`:a,strokeWidth:t?2:1.2}),(0,J.jsx)(`text`,{x:e.x,y:e.y+1,textAnchor:`middle`,dominantBaseline:`central`,fill:`#e8eaed`,fontSize:`9`,fontWeight:t?600:400,style:{pointerEvents:`none`},children:o}),(0,J.jsx)(`text`,{x:e.x,y:e.y+c+11,textAnchor:`middle`,fill:`#888`,fontSize:`7`,style:{pointerEvents:`none`},children:e.type})]},e.id)})]})}function TX({entity:e,relations:t,onClose:n,onDelete:r}){let i=t.filter(t=>t.to===e.name),a=t.filter(t=>t.from===e.name);return(0,J.jsxs)(`div`,{className:`panel`,style:{border:`1px solid var(--mt-border)`},children:[(0,J.jsxs)(`div`,{className:`sheet__hd`,style:{marginBottom:8},children:[(0,J.jsxs)(`h3`,{style:{margin:0},children:[(0,J.jsx)(`span`,{style:{display:`inline-block`,width:10,height:10,borderRadius:`50%`,backgroundColor:xX(e.entityType),marginRight:8}}),e.name]}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`button`,{className:`btn btn--danger btn--xs`,onClick:r,title:`Delete entity`,children:`Delete`}),(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:n,style:{marginLeft:6},children:`Close`})]}),(0,J.jsxs)(`p`,{className:`muted`,style:{margin:`0 0 8px`,fontSize:12},children:[`Type: `,(0,J.jsx)(`strong`,{children:e.entityType}),` · Created:`,` `,new Date(e.createdAt).toLocaleString(),` · Updated:`,` `,new Date(e.updatedAt).toLocaleString()]}),e.observations.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`h4`,{style:{margin:`12px 0 6px`,fontSize:12,color:`#9aa3af`},children:[`Observations (`,e.observations.length,`)`]}),(0,J.jsx)(`ul`,{style:{margin:0,paddingLeft:18,fontSize:13},children:e.observations.map((e,t)=>(0,J.jsx)(`li`,{style:{marginBottom:2},children:e},t))})]}),(a.length>0||i.length>0)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h4`,{style:{margin:`12px 0 6px`,fontSize:12,color:`#9aa3af`},children:`Relations`}),(0,J.jsxs)(`div`,{style:{fontSize:13},children:[a.map((e,t)=>(0,J.jsxs)(`div`,{children:[`→ `,(0,J.jsx)(`strong`,{children:e.relationType}),` → `,e.to]},`o${t}`)),i.map((e,t)=>(0,J.jsxs)(`div`,{children:[`← `,(0,J.jsx)(`strong`,{children:e.relationType}),` ← `,e.from]},`i${t}`))]})]})]})}function EX({activity:e}){return e.length===0?(0,J.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:`No activity yet.`}):(0,J.jsx)(`div`,{style:{maxHeight:280,overflowY:`auto`},children:(0,J.jsxs)(`table`,{className:`tbl`,style:{fontSize:12},children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Time`}),(0,J.jsx)(`th`,{children:`Action`}),(0,J.jsx)(`th`,{children:`Subject`})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{className:`muted`,style:{whiteSpace:`nowrap`},children:wc(e.ts)}),(0,J.jsx)(`td`,{children:SX[e.action]??e.action}),(0,J.jsx)(`td`,{style:{maxWidth:260,overflow:`hidden`,textOverflow:`ellipsis`},children:e.subject})]},e.id))})]})})}function DX({config:e,onSaved:t}){let[n,r]=(0,v.useState)(e.dbPath),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);(0,v.useEffect)(()=>{r(e.dbPath)},[e.dbPath]);let c=(0,v.useCallback)(async()=>{a(!0),s(``);try{let e=await pc(`/api/memory/config`,{dbPath:n});e.ok?(s(`Saved`),t()):s(e.error??`Failed`)}catch(e){s(String(e))}finally{a(!1)}},[n,t]);return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{style:{fontSize:12,color:`#9aa3af`,display:`block`,marginBottom:4},children:`Database path`}),(0,J.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,J.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),className:`input`,style:{flex:1,fontSize:13}}),(0,J.jsx)(`button`,{className:`btn btn--sm`,onClick:c,disabled:i||n===e.dbPath,children:i?`Saving…`:`Save`})]}),o&&(0,J.jsx)(`p`,{style:{fontSize:12,marginTop:4,color:o===`Saved`?`#34d399`:`#ef4444`},children:o}),e.stats&&(0,J.jsxs)(`div`,{className:`cards`,style:{marginTop:12},children:[(0,J.jsx)(vc,{k:`Entities`,v:String(e.stats.entities)}),(0,J.jsx)(vc,{k:`Relations`,v:String(e.stats.relations)}),(0,J.jsx)(vc,{k:`Observations`,v:String(e.stats.observations)})]})]})}function OX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),m=(0,v.useCallback)(async()=>{try{let[e,n,i,o]=await Promise.all([q(`/api/memory/graph`),q(`/api/memory/stats`),q(`/api/memory/config`),q(`/api/memory/activity?limit=50`)]);t(e),r(n),a(i),s(o),p(``)}catch(e){p(String(e))}},[]);(0,v.useEffect)(()=>{m();let e=setInterval(()=>void m(),1e4);return()=>clearInterval(e)},[m]);let h=(0,v.useCallback)(async()=>{if(!u.trim()){m();return}try{let e=await q(`/api/memory/search?q=${encodeURIComponent(u)}`);t(e)}catch(e){p(String(e))}},[u,m]),g=(0,v.useCallback)(async e=>{await mc(`/api/memory/entities`,{names:[e]}),l(null),m()},[m]);return f&&!e?(0,J.jsx)(_c,{title:`Knowledge Graph`,children:(0,J.jsx)(`p`,{style:{color:`#ef4444`},children:f})}):(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsxs)(`div`,{className:`cards reveal`,children:[(0,J.jsx)(vc,{k:`Entities`,v:String(n.entities)}),(0,J.jsx)(vc,{k:`Relations`,v:String(n.relations)}),(0,J.jsx)(vc,{k:`Observations`,v:String(n.observations)}),(0,J.jsx)(vc,{k:`Entity types`,v:String(n.entityTypes.length)}),(0,J.jsx)(vc,{k:`Relation types`,v:String(n.relationTypes.length)})]}),(0,J.jsx)(_c,{title:`Knowledge Graph`,className:`reveal`,extra:(0,J.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,J.jsx)(`input`,{type:`text`,placeholder:`Search entities…`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>e.key===`Enter`&&h(),className:`input`,style:{width:200,fontSize:12}}),(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:h,children:`Search`}),u&&(0,J.jsx)(`button`,{className:`btn btn--xs`,onClick:()=>{d(``),m()},children:`Clear`})]}),children:e&&(0,J.jsx)(wX,{graph:e})}),(0,J.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16},className:`reveal`,children:[(0,J.jsx)(_c,{title:`Entities`,children:e&&e.entities.length>0?(0,J.jsx)(`div`,{style:{maxHeight:360,overflowY:`auto`},children:(0,J.jsxs)(`table`,{className:`tbl`,style:{fontSize:12},children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Name`}),(0,J.jsx)(`th`,{children:`Type`}),(0,J.jsx)(`th`,{children:`Obs`}),(0,J.jsx)(`th`,{children:`Created`})]})}),(0,J.jsx)(`tbody`,{children:e.entities.map(e=>(0,J.jsxs)(`tr`,{style:{cursor:`pointer`,background:c?.name===e.name?`rgba(255,255,255,0.05)`:void 0},onClick:()=>l(e),children:[(0,J.jsxs)(`td`,{children:[(0,J.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,backgroundColor:xX(e.entityType),marginRight:6}}),e.name]}),(0,J.jsx)(`td`,{className:`muted`,children:e.entityType}),(0,J.jsx)(`td`,{children:e.observations.length}),(0,J.jsx)(`td`,{className:`muted`,children:wc(e.createdAt)})]},e.name))})]})}):(0,J.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:e?`No entities.`:`Loading…`})}),c&&e?(0,J.jsx)(TX,{entity:c,relations:e.relations,onClose:()=>l(null),onDelete:()=>g(c.name)}):(0,J.jsx)(_c,{title:`Activity Log`,children:(0,J.jsx)(EX,{activity:o})})]}),n&&(n.entityTypes.length>0||n.relationTypes.length>0)&&(0,J.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16},className:`reveal`,children:[n.entityTypes.length>0&&(0,J.jsx)(_c,{title:`Entity Types`,children:(0,J.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:n.entityTypes.map(e=>(0,J.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,padding:`2px 10px`,borderRadius:12,background:`${xX(e.type)}22`,border:`1px solid ${xX(e.type)}44`,fontSize:12},children:[(0,J.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,backgroundColor:xX(e.type)}}),e.type,(0,J.jsxs)(`span`,{className:`muted`,children:[`(`,e.count,`)`]})]},e.type))})}),n.relationTypes.length>0&&(0,J.jsx)(_c,{title:`Relation Types`,children:(0,J.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:n.relationTypes.map(e=>(0,J.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,padding:`2px 10px`,borderRadius:12,background:`rgba(255,255,255,0.05)`,border:`1px solid var(--mt-border)`,fontSize:12},children:[e.type,(0,J.jsxs)(`span`,{className:`muted`,children:[`(`,e.count,`)`]})]},e.type))})})]}),i&&(0,J.jsx)(_c,{title:`Memory Configuration`,className:`reveal`,children:(0,J.jsx)(DX,{config:i,onSaved:m})})]})}function kX({m:e,busy:t,onToggle:n}){return(0,J.jsxs)(`label`,{className:`mod-row`,"data-on":e.enabled?`1`:void 0,title:e.description,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:t,onChange:()=>n(e.slug,!e.enabled)}),(0,J.jsxs)(`span`,{className:`mod-row__main`,children:[(0,J.jsxs)(`span`,{className:`mod-row__name`,children:[e.label,(0,J.jsx)(`code`,{className:`mod-row__slug`,children:e.slug})]}),(0,J.jsx)(`span`,{className:`mod-row__desc muted`,children:e.description})]}),(0,J.jsxs)(`span`,{className:`mod-row__count muted`,children:[e.toolCount,` tool`,e.toolCount===1?``:`s`]})]})}function AX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(new Set),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),f=(0,v.useCallback)(()=>{q(`/api/modules`).then(e=>{t(e),e.appViews!==void 0&&l(e.appViews)}).catch(()=>a(`could not load modules`))},[]);(0,v.useEffect)(()=>f(),[f]);let p=e=>t(t=>t?{...t,...e}:e),m=(0,v.useCallback)(async(e,n)=>{r(t=>new Set(t).add(e)),t(t=>t&&{...t,modules:t.modules.map(t=>t.slug===e?{...t,enabled:n}:t)});let i=await pc(`/api/modules/toggle`,{slug:e,enabled:n}).catch(()=>({error:`request failed`}));if(r(t=>{let n=new Set(t);return n.delete(e),n}),i.error||i.ok===!1){a(i.error??`toggle failed`),f();return}p(i);let o=i.persisted?`saved to config`:`applied live (not saved)`,s=i.warning?` ⚠ ${i.warning}`:``;a(`${e} ${n?`enabled`:`disabled`} — ${o}. Reconnect the MCP client (or restart the server) for the tool list to update.${s}`)},[f]),h=(0,v.useCallback)(async(e,t)=>{for(let n of e)await m(n,t)},[m]),g=(0,v.useCallback)(async e=>{d(!0),l(e);let t=await pc(`/api/modules/app-views`,{enabled:e}).catch(()=>({error:`request failed`}));if(d(!1),`error`in t&&t.error){a(t.error),l(!e);return}`appViews`in t&&t.appViews!==void 0&&l(t.appViews);let n=`persisted`in t&&t.persisted?`saved to config`:`applied live (not saved)`,r=`warning`in t&&t.warning?` — ${t.warning}`:``;a(`App views ${e?`enabled`:`disabled`} — ${n}. Restart the server for the change to take effect.${r}`)},[]),_=(0,v.useMemo)(()=>{if(!e)return[];let t=o.trim().toLowerCase(),n=e=>!t||e.slug.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||e.group.toLowerCase().includes(t)||e.description.toLowerCase().includes(t),r=new Map;for(let t of e.modules){if(!n(t))continue;let e=r.get(t.group)??[];e.push(t),r.set(t.group,e)}return[...r.entries()].map(([e,t])=>({group:e,modules:t}))},[e,o]);if(!e)return(0,J.jsx)(`div`,{className:`muted`,children:`loading modules…`});let y=_.reduce((e,t)=>e+t.modules.length,0);return(0,J.jsx)(`section`,{className:`view`,children:(0,J.jsxs)(_c,{title:`Tool modules`,className:`reveal`,extra:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`muted`,children:[e.enabledModules,`/`,e.total,` modules · `,e.enabledTools,`/`,e.totalTools,` `,`tools exposed`]}),(0,J.jsx)(`button`,{className:`btn`,onClick:f,style:{marginLeft:10},children:`↻ Refresh`})]}),children:[(0,J.jsxs)(`label`,{className:`mod-row`,"data-on":c?`1`:void 0,title:`Emit MCP App view metadata (_meta.ui) on read tools`,style:{marginBottom:10,border:`1px solid var(--border)`,borderRadius:8,padding:`8px 12px`},children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:c,disabled:u,onChange:()=>void g(!c)}),(0,J.jsxs)(`span`,{className:`mod-row__main`,children:[(0,J.jsx)(`span`,{className:`mod-row__name`,children:`MCP App Views`}),(0,J.jsxs)(`span`,{className:`mod-row__desc muted`,children:[`When on, read tools emit interactive table/detail widgets via `,(0,J.jsx)(`code`,{children:`_meta.ui`}),`. Disable to keep the LLM context lean. Requires server restart.`]})]})]}),(0,J.jsxs)(`div`,{className:`legend`,style:{margin:`0 0 10px`},children:[(0,J.jsxs)(`span`,{children:[`writes to: `,(0,J.jsx)(`code`,{children:e.source?.path??`config file`})]}),(0,J.jsx)(`span`,{children:e.hasAllowList?`allow-list active`:`all modules on by default`})]}),(0,J.jsxs)(`p`,{className:`muted`,style:{margin:`0 0 12px`,fontSize:12},children:[`Toggle a module to expose or hide all of its tools. Disabling adds it to`,` `,(0,J.jsx)(`code`,{children:`tools.disabledModules`}),` in your config file; enabling removes it (or adds it to`,` `,(0,J.jsx)(`code`,{children:`tools.enabledModules`}),` when an allow-list is in force). Trimming the surface below ~150–200 tools makes every remaining tool reliably findable by the MCP client. The client must reconnect for changes to take effect.`]}),(0,J.jsxs)(`div`,{className:`mod-toolbar`,children:[(0,J.jsx)(`input`,{className:`input`,placeholder:`Filter modules by name, slug, group or description…`,value:o,onChange:e=>s(e.target.value)}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`button`,{className:`btn`,onClick:()=>void h(e.modules.filter(e=>!e.enabled).map(e=>e.slug),!0),children:`Enable all`}),` `,(0,J.jsx)(`button`,{className:`btn`,onClick:()=>void h(e.modules.filter(e=>e.enabled).map(e=>e.slug),!1),children:`Disable all`})]}),i&&(0,J.jsx)(`div`,{className:`cfg-msg`,style:{marginTop:12},children:i}),y===0?(0,J.jsxs)(`div`,{className:`muted`,style:{padding:12},children:[`No modules match “`,o,`”.`]}):(0,J.jsx)(`div`,{className:`mod-groups`,children:_.map(({group:e,modules:t})=>{let r=t.filter(e=>e.enabled).length,i=t.map(e=>e.slug);return(0,J.jsxs)(`div`,{className:`mod-group`,children:[(0,J.jsxs)(`div`,{className:`mod-group__hd`,children:[(0,J.jsx)(`h3`,{className:`mod-group__title`,children:e}),(0,J.jsxs)(`span`,{className:`muted`,children:[r,`/`,t.length,` on`]}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>void h(i.filter(e=>{let n=t.find(t=>t.slug===e);return n?!n.enabled:!1}),!0),children:`Enable group`}),` `,(0,J.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>void h(i.filter(e=>{let n=t.find(t=>t.slug===e);return n?n.enabled:!1}),!1),children:`Disable group`})]}),(0,J.jsx)(`div`,{className:`mod-list`,children:t.map(e=>(0,J.jsx)(kX,{m:e,busy:n.has(e.slug),onToggle:(e,t)=>void m(e,t)},e.slug))})]},e)})})]})})}var jX={TCP:`#e4e4e7`,UDP:`#d4d4d8`,ICMP:`#a1a1aa`,ICMPv6:`#a1a1aa`,ARP:`#e4e4e7`,IPv6:`#a1a1aa`},MX=e=>e&&jX[e]||`#71717a`;function NX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=()=>void q(`/api/capture/packets?limit=150`).then(t).catch(()=>{});e();let n=setInterval(e,1500);return()=>clearInterval(n)},[]);let i=e?.stats,a=e?.packets??[],o=async()=>{r(!0),await pc(`/api/capture/stop`,{}).catch(()=>{}),r(!1)};if(!i||!i.running&&i.packets===0)return(0,J.jsxs)(`div`,{className:`cap-idle muted`,children:[`No capture running. Start one with the `,(0,J.jsx)(`code`,{children:`start_packet_capture`}),` tool — point the device's TZSP stream at this host — and decoded packets stream in here live.`]});let s=Math.max(1,...Object.values(i.protocols));return(0,J.jsxs)(`div`,{className:`cap`,children:[(0,J.jsxs)(`div`,{className:`cap-bar`,children:[(0,J.jsx)(`span`,{className:`cap-dot${i.running?` is-on`:``}`}),(0,J.jsx)(`b`,{children:i.running?`capturing`:`stopped`}),(0,J.jsxs)(`span`,{className:`muted`,children:[`UDP `,i.port]}),(0,J.jsxs)(`span`,{className:`muted`,children:[Tc(i.packets),` pkts · `,Cc(i.bytes)]}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`a`,{className:`btn`,href:fc(`/api/capture/pcap`),download:`capture.pcap`,children:`⤓ pcap`}),(0,J.jsx)(`button`,{className:`btn btn-danger`,onClick:()=>void o(),disabled:n||!i.running,children:`■ Stop`})]}),(0,J.jsxs)(`div`,{className:`cap-cols`,children:[(0,J.jsxs)(`div`,{className:`cap-side`,children:[(0,J.jsx)(`div`,{className:`cap-h`,children:`Protocols`}),Object.entries(i.protocols).map(([e,t])=>(0,J.jsxs)(`div`,{className:`cap-pbar`,children:[(0,J.jsx)(`span`,{className:`cap-plabel`,style:{color:MX(e)},children:e}),(0,J.jsx)(`span`,{className:`cap-ptrack`,children:(0,J.jsx)(`i`,{style:{width:`${t/s*100}%`,background:MX(e)}})}),(0,J.jsx)(`span`,{className:`cap-pn`,children:t})]},e)),(0,J.jsx)(`div`,{className:`cap-h`,style:{marginTop:12},children:`Top talkers`}),i.topTalkers.length===0&&(0,J.jsx)(`div`,{className:`muted`,children:`—`}),i.topTalkers.map(e=>(0,J.jsxs)(`div`,{className:`cap-talker`,children:[(0,J.jsx)(`span`,{children:e.addr}),(0,J.jsx)(`b`,{children:e.count})]},e.addr))]}),(0,J.jsx)(`div`,{className:`cap-list`,children:a.length===0?(0,J.jsx)(`div`,{className:`muted`,style:{padding:10},children:`waiting for packets…`}):a.map((e,t)=>(0,J.jsxs)(`div`,{className:`cap-row`,children:[(0,J.jsx)(`span`,{className:`cap-tt`,children:wc(e.ts)}),(0,J.jsx)(`span`,{className:`cap-proto`,style:{color:MX(e.protocol)},children:e.protocol??e.ethType}),(0,J.jsx)(`span`,{className:`cap-len`,children:e.len}),(0,J.jsx)(`span`,{className:`cap-info`,children:e.info})]},t))})]})]})}function PX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(()=>{q(`/api/s3/list`).then(t).catch(()=>t({configured:!1,objects:[]}))},[]);(0,v.useEffect)(()=>c(),[c]);let l=e=>{q(`/api/s3/presign?key=${encodeURIComponent(e)}`).then(e=>{e.url?window.open(e.url,`_blank`,`noopener`):s(`could not generate download link`)}).catch(()=>s(`could not generate download link`))},u=async e=>{a(e);let t=await pc(`/api/s3/delete`,{key:e}).catch(()=>({error:`request failed`}));a(null),r(null),t.ok?(s(`Deleted ${e}`),c()):s(t.error??`delete failed`)};return e?e.configured?(0,J.jsx)(`section`,{className:`view`,children:(0,J.jsxs)(_c,{title:`S3 backups`,className:`reveal`,extra:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`muted`,children:[e.target,` · `,e.objects.length,` object`,e.objects.length===1?``:`s`,e.truncated?` (truncated)`:``]}),(0,J.jsx)(`button`,{className:`btn`,onClick:c,style:{marginLeft:10},children:`↻ Refresh`})]}),children:[o&&(0,J.jsx)(`div`,{className:`cfg-msg`,children:o}),e.objects.length===0?(0,J.jsxs)(`div`,{className:`muted`,style:{padding:12},children:[`No objects in the bucket. Upload one with the `,(0,J.jsx)(`code`,{children:`upload_backup_to_s3`}),` tool.`]}):(0,J.jsx)(`div`,{className:`feedwrap`,children:(0,J.jsxs)(`table`,{className:`feed`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`key`}),(0,J.jsx)(`th`,{className:`num`,children:`size`}),(0,J.jsx)(`th`,{children:`modified`}),(0,J.jsx)(`th`,{style:{width:200},children:`actions`})]})}),(0,J.jsx)(`tbody`,{children:e.objects.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:e.key}),(0,J.jsx)(`td`,{className:`num`,children:Cc(e.size)}),(0,J.jsx)(`td`,{children:e.lastModified?new Date(e.lastModified).toLocaleString(void 0,{hour12:!1}):`—`}),(0,J.jsxs)(`td`,{onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`button`,{className:`btn`,onClick:()=>l(e.key),children:`⤓ Download`}),` `,n===e.key?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{className:`btn btn-danger`,disabled:i===e.key,onClick:()=>void u(e.key),children:`✓ Confirm`}),` `,(0,J.jsx)(`button`,{className:`btn`,onClick:()=>r(null),children:`Cancel`})]}):(0,J.jsx)(`button`,{className:`btn`,onClick:()=>r(e.key),children:`🗑 Delete`})]})]},e.key))})]})})]})}):(0,J.jsxs)(`div`,{className:`feed-empty`,children:[(0,J.jsx)(`div`,{className:`feed-empty__icon`,children:`☁️`}),(0,J.jsx)(`p`,{className:`feed-empty__title`,children:`S3 is not configured`}),(0,J.jsxs)(`p`,{className:`feed-empty__sub`,children:[`Add an `,(0,J.jsx)(`code`,{children:`s3`}),` block (bucket + credentials) to your config to manage backup objects here.`]})]}):(0,J.jsx)(`div`,{className:`muted`,children:`loading S3 objects…`})}function FX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),u=(0,v.useCallback)(()=>{q(`/api/snapshots`).then(e=>t(e.snapshots)).catch(()=>t([]))},[]);(0,v.useEffect)(()=>u(),[u]);let d=e=>{q(`/api/snapshot/${encodeURIComponent(e)}`).then(s).catch(()=>{})},f=()=>{!n||!i||pc(`/api/snapshots/diff`,{from:n,to:i}).then(l).catch(()=>{})};if(!e)return(0,J.jsx)(`div`,{className:`muted`,children:`loading snapshots…`});if(e.length===0)return(0,J.jsxs)(`div`,{className:`feed-empty`,children:[(0,J.jsx)(`div`,{className:`feed-empty__icon`,children:`🕰️`}),(0,J.jsx)(`p`,{className:`feed-empty__title`,children:`No config snapshots yet`}),(0,J.jsxs)(`p`,{className:`feed-empty__sub`,children:[`Capture one with the `,(0,J.jsx)(`code`,{children:`capture_config_snapshot`}),` tool — then time-travel diff any two here.`]})]});let p=e.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.device,` · `,e.label??e.id,` · `,wc(e.ts)]},e.id));return(0,J.jsxs)(`section`,{className:`view`,children:[(0,J.jsxs)(_c,{title:`Config snapshots`,className:`reveal`,extra:(0,J.jsx)(`button`,{className:`btn`,onClick:u,children:`↻ Refresh`}),children:[(0,J.jsxs)(`div`,{className:`toolbar`,style:{marginBottom:12},children:[(0,J.jsxs)(`select`,{className:`btn`,value:n,onChange:e=>r(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`diff from…`}),p]}),(0,J.jsxs)(`select`,{className:`btn`,value:i,onChange:e=>a(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`to…`}),p]}),(0,J.jsx)(`button`,{className:`btn is-active`,onClick:f,disabled:!n||!i,children:`Diff →`}),(0,J.jsxs)(`span`,{className:`muted`,children:[e.length,` snapshots`]})]}),(0,J.jsx)(`div`,{className:`feedwrap`,children:(0,J.jsxs)(`table`,{className:`feed`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`captured`}),(0,J.jsx)(`th`,{children:`device`}),(0,J.jsx)(`th`,{children:`label`}),(0,J.jsx)(`th`,{children:`version`}),(0,J.jsx)(`th`,{className:`num`,children:`lines`}),(0,J.jsx)(`th`,{className:`num`,children:`size`}),(0,J.jsx)(`th`,{children:`output`})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsxs)(`tr`,{className:o?.id===e.id?`is-selected`:void 0,onClick:()=>d(e.id),children:[(0,J.jsx)(`td`,{children:wc(e.ts)}),(0,J.jsx)(`td`,{children:e.device}),(0,J.jsx)(`td`,{children:e.label??`—`}),(0,J.jsx)(`td`,{children:e.rosVersion??`—`}),(0,J.jsx)(`td`,{className:`num`,children:e.lines}),(0,J.jsx)(`td`,{className:`num`,children:Cc(e.bytes)}),(0,J.jsx)(`td`,{className:`preview`,children:`view export →`})]},e.id))})]})})]}),c&&(0,J.jsx)(_c,{title:`Time-travel diff`,className:`reveal`,extra:(0,J.jsx)(`span`,{className:`muted`,children:c.summary.changed?`+${c.summary.added} / -${c.summary.removed}`:`identical`}),children:(0,J.jsx)(`pre`,{className:`cfg-diff`,children:(c.unified||`(identical)`).split(`
|
|
81
81
|
`).map((e,t)=>(0,J.jsx)(`div`,{className:e.startsWith(`+`)?`d-add`:e.startsWith(`-`)?`d-del`:e.startsWith(`@@`)?`d-hunk`:``,children:e||` `},t))})}),o&&(0,J.jsx)(_c,{title:`Snapshot · ${o.label??o.id}`,className:`reveal`,extra:(0,J.jsx)(jc,{type:`secondary`,size:`sm`,onClick:()=>s(null),children:`✕ Close`}),children:(0,J.jsx)(`pre`,{className:`body`,style:{maxHeight:460},children:o.body||`(empty)`})})]})}function IX(e){return e==null?`#3f3f46`:e>=85?`#f87171`:e>=60?`#a1a1aa`:`#d4d4d8`}function LX({topo:e,onOnboard:t}){let[n,r]=(0,v.useState)(null),i=e.nodes.filter(e=>e.kind===`device`),a=e.nodes.filter(e=>e.kind===`neighbor`),o=Math.max(1,i.length),s=i.length<=1?0:Math.min(150,76+o*8),c=s+(i.length<=1?180:140),l=Math.max(360,Math.round((c+78)*2)),u=l/2,d=new Map,f=new Map;i.forEach((e,t)=>{if(i.length===1){d.set(e.id,{x:380,y:u}),f.set(e.id,-Math.PI/2);return}let n=t/o*Math.PI*2-Math.PI/2;f.set(e.id,n),d.set(e.id,{x:380+s*Math.cos(n),y:u+s*Math.sin(n)})});let p=new Map,m=new Set(a.map(e=>e.id));for(let t of e.edges)m.has(t.to)&&!p.has(t.to)&&p.set(t.to,t.from);let h=new Map;for(let e of a){let t=p.get(e.id)??i[0]?.id??``;h.set(t,[...h.get(t)??[],e.id])}if(i.length<=1)a.forEach((e,t)=>{let n=t/Math.max(1,a.length)*Math.PI*2-Math.PI/2;d.set(e.id,{x:380+c*Math.cos(n),y:u+c*Math.sin(n)})});else for(let[e,t]of h){let n=f.get(e)??-Math.PI/2,r=Math.min(Math.PI/2.2,.32*t.length);t.forEach((e,i)=>{let a=t.length===1?n:n-r/2+r*i/(t.length-1);d.set(e,{x:380+c*Math.cos(a),y:u+c*Math.sin(a)})})}let g=new Map(e.nodes.map(e=>[e.id,e])),_=n?g.get(n):null;return(0,J.jsxs)(`div`,{className:`topo`,children:[(0,J.jsxs)(`svg`,{viewBox:`0 0 760 ${l}`,width:`100%`,height:Math.min(l,540),preserveAspectRatio:`xMidYMid meet`,children:[e.edges.map((e,t)=>{let n=d.get(e.from),r=d.get(e.to);return!n||!r?null:(0,J.jsx)(`line`,{className:`topo-edge${m.has(e.to)?` is-dashed`:``}`,x1:n.x,y1:n.y,x2:r.x,y2:r.y,children:(0,J.jsxs)(`title`,{children:[e.from,` → `,e.to,e.interface?` (${e.interface})`:``]})},`e-${t}`)}),e.nodes.map(e=>{let t=d.get(e.id);if(!t)return null;let i=e.kind===`device`,a=i?132:108,o=i?50:38,s=t.x-a/2,c=t.y-o/2,l=e.reachable===!0?`#d4d4d8`:e.reachable===!1?`#f87171`:i?`#71717a`:`#e4e4e7`,u=n===e.id;return(0,J.jsxs)(`g`,{className:`topo-node${i?` is-device`:` is-neighbor`}${e.onboardable?` is-onboard`:``}${u?` is-picked`:``}`,transform:`translate(${s},${c})`,onClick:()=>r(t=>t===e.id?null:e.id),children:[(0,J.jsx)(`rect`,{width:a,height:o,rx:9,style:{stroke:l}}),(0,J.jsx)(`text`,{className:`topo-label`,x:9,y:16,children:(e.label||e.id).slice(0,16)}),i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`text`,{className:`topo-sub`,x:9,y:30,children:(e.board||e.ip||``).slice(0,18)}),(0,J.jsx)(`rect`,{className:`topo-bar-bg`,x:9,y:37,width:a-18,height:4,rx:2}),(0,J.jsx)(`rect`,{x:9,y:37,width:(a-18)*Math.min(100,e.cpuLoad??0)/100,height:4,rx:2,style:{fill:IX(e.cpuLoad)}}),(0,J.jsx)(`rect`,{className:`topo-bar-bg`,x:9,y:43,width:a-18,height:4,rx:2}),(0,J.jsx)(`rect`,{x:9,y:43,width:(a-18)*Math.min(100,e.memUsedPct??0)/100,height:4,rx:2,style:{fill:IX(e.memUsedPct)}})]}):(0,J.jsx)(`text`,{className:`topo-sub`,x:9,y:29,children:e.onboardable?`+ onboard`:e.ip||e.mac||``})]},e.id)})]}),(0,J.jsxs)(`div`,{className:`topo-foot`,children:[(0,J.jsxs)(`span`,{className:`legend`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{className:`dot`,style:{background:`#d4d4d8`}}),` online`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{className:`dot`,style:{background:`#f87171`}}),` offline`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{className:`dot`,style:{background:`#e4e4e7`}}),` neighbour`]}),(0,J.jsxs)(`span`,{className:`muted`,children:[e.stats.devices,` devices · `,e.stats.neighbors,` discovered ·`,` `,e.stats.onboardable,` onboardable`]})]}),_&&(0,J.jsxs)(`div`,{className:`topo-pop`,children:[(0,J.jsxs)(`div`,{className:`topo-pop__hd`,children:[(0,J.jsx)(`strong`,{children:_.label}),(0,J.jsx)(`span`,{className:`muted`,children:[_.board,_.version,_.mac].filter(Boolean).join(` · `)||`no details advertised`}),(0,J.jsx)(`span`,{style:{flex:1}}),(0,J.jsx)(`button`,{className:`topo-btn`,onClick:()=>r(null),children:`✕`})]}),_.suggestedConfig?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`muted`,style:{margin:`2px 0 6px`},children:`Not managed yet — add this to your device config to onboard it:`}),(0,J.jsx)(`pre`,{className:`topo-stub`,children:JSON.stringify({[_.suggestedConfig.name]:RX(_.suggestedConfig)},null,2)}),(0,J.jsx)(xc,{className:`topo-btn`,title:`Copy config stub`,label:`Copy config stub`,text:JSON.stringify({[_.suggestedConfig.name]:RX(_.suggestedConfig)},null,2)}),t&&(0,J.jsx)(`button`,{className:`topo-btn cfg-save`,onClick:()=>t(_.suggestedConfig.name,RX(_.suggestedConfig)),children:`Add to config →`})]}):(0,J.jsxs)(`div`,{className:`muted`,children:[`Managed device`,_.ip?` · ${_.ip}`:``,_.uptime?` · up ${_.uptime}`:``]})]})]})]})}function RX(e){let t={port:e.port,username:e.username};return e.host&&(t.host=e.host),e.mac&&(t.mac=e.mac),t}function zX(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function BX(e){return!e||!e.pooled?`#52525b`:e.dead?`#ef4444`:e.inflight>0?`#3b82f6`:`#22c55e`}function VX(e){return!e||!e.pooled?`no connection`:e.dead?`reconnecting`:e.inflight>0?`${e.inflight} inflight`:`ready`}function HX({device:e}){let t=e.pool,n=!t||!t.pooled?`disconnected`:t.dead?`dead`:t.inflight>0?`busy`:`idle`,r=BX(t),i=!t||!t.pooled?0:t.inflight>0?Math.min(8+t.inflight*15,100):100;return(0,J.jsxs)(`div`,{className:`pool-card pool-card--${n}`,children:[(0,J.jsxs)(`div`,{className:`pool-card__hd`,children:[(0,J.jsx)(`span`,{className:`pool-card__dot`,style:{background:r}}),(0,J.jsx)(`span`,{className:`pool-card__name`,children:e.name}),(0,J.jsx)(`span`,{className:`pool-card__badge`,style:{color:r},children:VX(t)})]}),(0,J.jsxs)(`div`,{className:`pool-pipe`,children:[(0,J.jsx)(`div`,{className:`pool-pipe__fill${n===`busy`?` pool-pipe__fill--pulse`:``}`,style:{width:`${i}%`,background:r}}),t&&t.pooled&&t.inflight>0&&(0,J.jsxs)(`span`,{className:`pool-pipe__label`,children:[t.inflight,` ch`]})]})]})}function UX({k:e,v:t,sub:n}){return(0,J.jsxs)(`div`,{className:`stat`,style:{minWidth:100},children:[(0,J.jsx)(`p`,{className:`k`,children:e}),(0,J.jsxs)(`div`,{className:`v`,children:[t,n!=null&&(0,J.jsxs)(`small`,{children:[` `,n]})]})]})}function WX({devices:e,poolPayload:t}){let n=e.filter(e=>e.pool!==null&&e.pool!==void 0);if(!(t?.enabled??n.length>0)&&n.length===0)return(0,J.jsxs)(`details`,{className:`pool-panel`,open:!0,children:[(0,J.jsx)(`summary`,{style:{cursor:`pointer`,fontWeight:600,marginBottom:8},children:`SSH Connection Pool`}),(0,J.jsxs)(`p`,{className:`pool-disabled`,children:[`Connection pooling is disabled. Enable it with `,(0,J.jsx)(`code`,{children:`--ssh-keep-alive true`}),` or`,` `,(0,J.jsx)(`code`,{children:`MIKROTIK_SSH__KEEP_ALIVE=true`}),` to keep persistent SSH connections across tool calls.`]})]});let r=t?.aggregate,i=t?.config;return(0,J.jsxs)(`details`,{className:`pool-panel`,open:!0,children:[(0,J.jsx)(`summary`,{style:{cursor:`pointer`,fontWeight:600,marginBottom:8},children:`SSH Connection Pool`}),r&&(0,J.jsxs)(`div`,{className:`pool-stats`,children:[(0,J.jsx)(UX,{k:`Connections`,v:String(r.totalConnections)}),(0,J.jsx)(UX,{k:`Inflight`,v:String(r.totalInflight),sub:`channels`}),(0,J.jsx)(UX,{k:`Idle`,v:String(r.totalIdle)}),(0,J.jsx)(UX,{k:`Busy`,v:String(r.totalBusy)}),i&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(UX,{k:`Keepalive`,v:zX(i.keepAliveInterval)}),(0,J.jsx)(UX,{k:`Idle timeout`,v:zX(i.idleTimeout)})]})]}),n.length>0&&(0,J.jsx)(`div`,{className:`pool-grid`,children:n.map(e=>(0,J.jsx)(HX,{device:e},e.name))})]})}var GX=`mt-whats-new-dismissed`,KX=`mt-whats-new-seen-version`;function qX(e){try{return localStorage.getItem(GX)===e}catch{return!1}}function JX(e){try{localStorage.setItem(GX,e)}catch{}}function YX(e){try{let t=localStorage.getItem(KX);return localStorage.setItem(KX,e),t!==null&&t!==e}catch{return!1}}function XX(e){let t=e.replace(/\r\n?/g,`
|
|
82
82
|
`);t=t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);let n=[];t=t.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,r)=>(n.push(`<pre><code>${r.trim()}</code></pre>`),`%%CB${n.length-1}%%`));let r=[];t=t.replace(/`([^`]+)`/g,(e,t)=>(r.push(`<code>${t}</code>`),`%%IC${r.length-1}%%`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,`<img src="$2" alt="$1" style="max-width:100%;border-radius:6px;margin:6px 0"/>`),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,`<a href="$2" target="_blank" rel="noopener">$1</a>`),t=t.replace(/(?<!=["'])(https?:\/\/[^\s<>")\]]+)/g,`<a href="$1" target="_blank" rel="noopener">$1</a>`),t=t.replace(/\*\*\*(.+?)\*\*\*/g,`<strong><em>$1</em></strong>`),t=t.replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,`<em>$1</em>`),t=t.replace(/~~(.+?)~~/g,`<del>$1</del>`),t=t.replace(/^#### (.+)$/gm,`<h5>$1</h5>`),t=t.replace(/^### (.+)$/gm,`<h4>$1</h4>`),t=t.replace(/^## (.+)$/gm,`<h3>$1</h3>`),t=t.replace(/^# (.+)$/gm,`<h2>$1</h2>`),t=t.replace(/^> (.+)$/gm,`<blockquote>$1</blockquote>`),t=t.replace(/<\/blockquote>\n<blockquote>/g,`
|
|
83
83
|
`),t=t.replace(/^---$/gm,`<hr/>`),t=t.replace(/((?:^\|.+\|\n?)+)/gm,e=>{let t=e.trim().split(`
|
package/dist/ui/records.html
CHANGED
|
@@ -117,7 +117,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
117
117
|
- "model": Tool visible to and callable by the agent
|
|
118
118
|
- "app": Tool callable by the app from this server only`),csp:Jf().optional(),permissions:Jf().optional()}),I({mimeTypes:F(j()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),I({method:V(`ui/download-file`),params:I({contents:F(R([r_,i_])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),I({method:V(`ui/message`),params:I({role:V(`user`).describe(`Message role, currently only "user" is supported.`),content:F(a_).describe(`Message content blocks (text, image, etc.).`)})}),I({method:V(`ui/notifications/sandbox-resource-ready`),params:I({html:j().describe(`HTML content to load into the inner iframe.`),sandbox:j().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:yv.optional().describe(`CSP configuration from resource metadata.`),permissions:bv.optional().describe(`Sandbox permissions from resource metadata.`)})});var Mv=I({method:V(`ui/notifications/tool-result`),params:m_.describe(`Standard MCP tool execution result.`)}),Nv=I({toolInfo:I({id:Ph.optional().describe(`JSON-RPC id of the tools/call request.`),tool:d_.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:pv.optional().describe(`Current color theme preference.`),styles:Tv.optional().describe(`Style configuration for theming the app.`),displayMode:mv.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:F(mv).optional().describe(`Display modes the host supports.`),containerDimensions:R([I({height:M().describe(`Fixed container height in pixels.`)}),I({maxHeight:R([M(),Gf()]).optional().describe(`Maximum container height in pixels.`)})]).and(R([I({width:M().describe(`Fixed container width in pixels.`)}),I({maxWidth:R([M(),Gf()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
119
119
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:j().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:j().optional().describe(`User's timezone in IANA format.`),userAgent:j().optional().describe(`Host application identifier.`),platform:R([V(`web`),V(`desktop`),V(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:I({touch:N().optional().describe(`Whether the device supports touch input.`),hover:N().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:I({top:M().describe(`Top safe area inset in pixels.`),right:M().describe(`Right safe area inset in pixels.`),bottom:M().describe(`Bottom safe area inset in pixels.`),left:M().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Pv=I({method:V(`ui/notifications/host-context-changed`),params:Nv.describe(`Partial context update containing only changed fields.`)});I({method:V(`ui/update-model-context`),params:I({content:F(a_).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:z(j(),P().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),I({method:V(`ui/initialize`),params:I({appInfo:Yh.describe(`App identification (name and version).`),appCapabilities:kv.describe(`Features and capabilities this app provides.`),protocolVersion:j().describe(`Protocol version this app supports.`)})});var Fv=I({protocolVersion:j().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Yh.describe(`Host application identification and version.`),hostCapabilities:Ov.describe(`Features and capabilities provided by the host.`),hostContext:Nv.describe(`Rich context about the host environment.`)}).passthrough(),Iv={target:`draft-2020-12`};async function Lv(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](Iv);if(n.vendor===`zod`){let{z:n}=await lv(async()=>{let{z:e}=await Promise.resolve().then(()=>(Ch(),xh));return{z:e}},void 0,import.meta.url);return n.toJSONSchema(e,{io:t})}throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Rv(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function zv(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Bv(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function Vv(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Hv(e){if(document.getElementById(`__mcp-host-fonts`))return;let t=document.createElement(`style`);t.id=`__mcp-host-fonts`,t.textContent=e,document.head.appendChild(t)}var Uv=class e extends uv{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:xv,toolinputpartial:Sv,toolresult:Mv,toolcancelled:Cv,hostcontextchanged:Pv};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,n.allowUnsafeEval||a({jitless:!0}),this.setRequestHandler(ag,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._capabilities=av(this._capabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._capabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Rv(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Rv(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Lv(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Lv(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(Ev,(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(g_,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(f_,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},m_,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},zg,t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},Ng,t)}async createSamplingMessage(e,t){this._assertInitialized(`createSamplingMessage`);let n=e.tools?M_:j_;return await this.request({method:`sampling/createMessage`,params:e},n,t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},vv,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},Wh,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},gv,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},_v,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Av,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new fv(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:dv}},Fv,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function $(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n.flat())e===!1||e==null||r.append(e instanceof Node?e:document.createTextNode(String(e)));return r}function Wv(e,t,n={}){let r=$(`button`,{class:`btn${n.class?` ${n.class}`:``}`,...n.title?{title:n.title}:{}});return r.textContent=e,n.disabled&&(r.disabled=!0),r.addEventListener(`click`,t),r}async function Gv(e){try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.append(t),t.select();try{document.execCommand(`copy`)}finally{t.remove()}}}function Kv(e,t,n=`text/plain`){let r=new Blob([t],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=$(`a`,{href:i,download:e});document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function qv(e,t){let n=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e;return`${e.map(n).join(`,`)}\n${t.map(t=>e.map(e=>n(t[e]??``)).join(`,`)).join(`
|
|
120
|
-
`)}\n`}function Jv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},Bv(zv())}var Yv=document.getElementById(`app`),
|
|
120
|
+
`)}\n`}function Jv(e){e.onhostcontextchanged=e=>{if(e.theme&&Bv(e.theme),e.styles?.variables&&Vv(e.styles.variables),e.styles?.css?.fonts&&Hv(e.styles.css.fonts),e.safeAreaInsets){let{top:t,right:n,bottom:r,left:i}=e.safeAreaInsets;document.body.style.padding=`${t+16}px ${n+16}px ${r+16}px ${i+16}px`}},Bv(zv())}var Yv=1e4;async function Xv(e,t,n){try{return await e.connect(void 0,{timeout:Yv}),console.warn(`[${t}] connected`,{host:e.getHostVersion(),caps:e.getHostCapabilities()}),!0}catch(e){console.error(`[${t}] connect failed`,e);let r=e instanceof Error&&/timed?\s*out/i.test(e.message)?`The MCP App host did not respond — make sure your client supports MCP Apps (ext-apps).`:`Connection failed: ${e instanceof Error?e.message:String(e)}`;return n.replaceChildren($(`div`,{class:`skeleton`},r)),!1}}var Zv=document.getElementById(`app`),Qv=null,$v=``,ey=null,ty=1,ny=new Set,ry=null,iy=!1,ay=0,oy=null,sy={};function cy(e){let t=[`#`,`flags`].filter(t=>e.columns.includes(t));return[...t,...e.columns.filter(e=>!t.includes(e))]}function ly(e){let t=$v.trim().toLowerCase(),n=e.rows;if(t&&(n=n.filter(e=>Object.values(e).some(e=>e.toLowerCase().includes(t)))),ny.size&&(n=n.filter(e=>{let t=e.flags??``;return[...ny].every(e=>t.includes(e))})),ey){let e=ey;n=[...n].sort((t,n)=>{let r=t[e]??``,i=n[e]??``,a=Number(r),o=Number(i);return(r!==``&&i!==``&&!Number.isNaN(a)&&!Number.isNaN(o)?a-o:r.localeCompare(i))*ty})}return n}function uy(e){let t=new Set;for(let n of e.rows)for(let e of n.flags??``)t.add(e);return[...t].sort()}function dy(e){return Object.entries(e).filter(([e])=>e!==`#`&&e!==`flags`).map(([e,t])=>/\s/.test(t)?`${e}="${t}"`:`${e}=${t}`).join(` `)}function fy(e){let t=uy(e);return t.length?$(`div`,{class:`toolbar`},...t.map(t=>{let n=e.flags[t]??t,r=ny.has(t);return Wv(`${t} · ${n}`,()=>{r?ny.delete(t):ny.add(t),xy()},{class:r?`is-active`:``,title:`Filter rows flagged "${n}"`})})):!1}function py(e){let t=$(`th`,e===`#`?{class:`col-num`}:{},e);return ey===e&&t.append($(`span`,{class:`arrow`},ty===1?`▲`:`▼`)),t.addEventListener(`click`,()=>{ey===e?ty=ty===1?-1:1:(ey=e,ty=1),xy()}),t}function my(e,t){let n=cy(e),r=$(`thead`,{},$(`tr`,{},...n.map(py))),i=$(`tbody`);return t.forEach(t=>{let r=$(`tr`,(t.flags??``).includes(`X`)?{class:`is-disabled`}:{});for(let e of n)r.append($(`td`,e===`#`?{class:`col-num`}:{},t[e]??`—`));r.addEventListener(`click`,()=>{ry=e.rows.indexOf(t),xy()}),i.append(r)}),$(`div`,{class:`tablewrap`},$(`table`,{class:`tbl`},r,i))}function hy(e){let t=$(`div`,{class:`kv__body`});for(let[n,r]of Object.entries(e))t.append($(`div`,{class:`kv__k`},n),$(`div`,{class:`kv__v`},r||`—`));return t}function gy(e){if(ry==null||!e.rows[ry])return!1;let t=e.rows[ry],n=t.name??t[`#`]??`record`;return $(`div`,{class:`drawer`},$(`div`,{class:`drawer__hd`},$(`span`,{},`Row `),$(`b`,{},String(n)),$(`span`,{class:`hd__spacer`}),Wv(`Copy as CLI`,()=>void Gv(dy(t)),{title:`Copy key=value pairs`}),Wv(`Close`,()=>{ry=null,xy()})),hy(t))}function _y(e,t){let n=$(`input`,{class:`search`,type:`search`,placeholder:`Search ${e.count} row${e.count===1?``:`s`}…`,value:$v});n.addEventListener(`input`,()=>{$v=n.value,ry=null,yy()});let r=$(`select`,{class:`btn`,title:`Auto-refresh interval`});for(let[e,t]of[[`Auto: off`,`0`],[`Auto: 5s`,`5000`],[`Auto: 15s`,`15000`],[`Auto: 60s`,`60000`]]){let n=$(`option`,{value:t},e);Number(t)===ay&&(n.selected=!0),r.append(n)}r.addEventListener(`change`,()=>Ty(Number(r.value)));let i=()=>ly(e),a=cy(e);return $(`div`,{class:`toolbar`},$(`div`,{class:`grow`},n),Wv(iy?`Refreshing…`:`↻ Refresh`,wy,{disabled:iy}),r,Wv(`CSV`,()=>Kv(`${e.tool}.csv`,qv(a,i()),`text/csv`),{title:`Export visible rows as CSV`}),Wv(`JSON`,()=>Kv(`${e.tool}.json`,JSON.stringify(i(),null,2),`application/json`),{title:`Export visible rows as JSON`}),Wv(`Copy`,()=>void Gv(JSON.stringify(i(),null,2)),{title:`Copy visible rows as JSON`}),$(`span`,{class:`pill count-pill`},`showing `,$(`b`,{},`${t}/${e.count}`)))}function vy(e){return $(`header`,{class:`hd`},$(`span`,{class:`hd__dot`}),$(`div`,{},$(`h1`,{class:`hd__title`},e.title),$(`p`,{class:`hd__sub`},e.tool)),$(`span`,{class:`hd__spacer`}))}function yy(){if(!Qv)return;let e=document.getElementById(`results`);if(!e){xy();return}e.replaceChildren(by(Qv));let t=document.querySelector(`.count-pill b`);t&&(t.textContent=`${ly(Qv).length}/${Qv.count}`)}function by(e){let t=ly(e);return e.rows.length===0?e.raw?$(`pre`,{class:`raw`},e.raw):$(`div`,{class:`empty`},`No records returned.`):e.kind===`record`&&e.rows.length===1?hy(e.rows[0]):t.length===0?$(`div`,{class:`empty`},`No rows match the current filter.`):my(e,t)}function xy(){if(!Qv){Zv.replaceChildren($(`div`,{class:`skeleton`},`Waiting for data…`));return}let e=Qv,t=ly(e).length,n=e.kind===`list`&&e.rows.length>0,r=[vy(e),n&&_y(e,t),n&&fy(e),$(`div`,{id:`results`},by(e)),gy(e),$(`footer`,{class:`foot`},$(`span`,{},`format: ${e.format}`),$(`span`,{class:`grow`}),$(`span`,{},`updated ${new Date(e.generatedAt).toLocaleTimeString()}`))];Zv.replaceChildren(...r.filter(Boolean))}var Sy=new Uv({name:`mikrotik-records`,version:`1.0.0`});function Cy(e){e&&typeof e==`object`&&e.__mikrotikView===`records`&&(Qv=e,ry=null,xy())}async function wy(){if(!(iy||!Qv)){iy=!0,xy();try{Cy((await Sy.callServerTool({name:Qv.tool,arguments:sy})).structuredContent)}catch(e){console.error(`[records] refresh failed`,e)}finally{iy=!1,xy()}}}function Ty(e){ay=e,oy&&=(clearInterval(oy),null),e>0&&(oy=setInterval(()=>void wy(),e)),xy()}Sy.ontoolresult=e=>{console.warn(`[records] ontoolresult`,e),Cy(e.structuredContent)},Sy.ontoolinput=e=>{e&&typeof e==`object`&&`arguments`in e&&(sy=e.arguments??{}),Qv||xy()},Jv(Sy),Sy.onteardown=async()=>(oy&&clearInterval(oy),{}),xy(),Xv(Sy,`records`,Zv);
|
|
121
121
|
</script>
|
|
122
122
|
<style>
|
|
123
123
|
:root{--mt-bg:var(--color-background-primary,#0b0d10);--mt-surface:var(--color-background-secondary,#14171c);--mt-surface-2:var(--color-background-tertiary,#1b1f26);--mt-border:var(--color-border-primary,#262b33);--mt-text:var(--color-text-primary,#e8eaed);--mt-text-dim:var(--color-text-secondary,#9aa3af);--mt-text-faint:var(--color-text-tertiary,#6b7280);--mt-accent:var(--color-accent-primary,#6ea8fe);--mt-good:#34d399;--mt-warn:#fbbf24;--mt-bad:#f87171;--mt-radius:var(--border-radius-md,14px);--mt-radius-sm:var(--border-radius-sm,9px);--mt-mono:var(--font-mono,ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace);--mt-sans:var(--font-sans,system-ui, -apple-system, "Segoe UI", sans-serif);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}}*{box-sizing:border-box}body{background:var(--mt-bg);color:var(--mt-text);font-family:var(--mt-sans);-webkit-font-smoothing:antialiased;margin:0;padding:16px;font-size:13px;line-height:1.5}.app{gap:14px;max-width:960px;margin:0 auto;display:grid}.hd{flex-wrap:wrap;align-items:center;gap:12px;display:flex}.hd__dot{background:var(--mt-good);width:9px;height:9px;box-shadow:0 0 0 4px color-mix(in srgb, var(--mt-good) 22%, transparent);border-radius:50%}.hd__title{letter-spacing:-.01em;margin:0;font-size:17px;font-weight:650}.hd__sub{color:var(--mt-text-dim);font-family:var(--mt-mono);margin:0;font-size:12px}.hd__spacer{flex:1}.pill{border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text-dim);font-family:var(--mt-mono);border-radius:999px;align-items:center;gap:6px;padding:3px 9px;font-size:11px;display:inline-flex}.pill b{color:var(--mt-text);font-weight:600}.grid{grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;display:grid}.card{background:linear-gradient(180deg, var(--mt-surface), var(--mt-surface-2));border:1px solid var(--mt-border);border-radius:var(--mt-radius);padding:14px}.card__label{color:var(--mt-text-dim);text-transform:uppercase;letter-spacing:.06em;margin:0 0 8px;font-size:11px}.card__value{font-family:var(--mt-mono);letter-spacing:-.01em;font-size:20px;font-weight:600}.toolbar{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.toolbar .grow{flex:1;min-width:140px}.search{appearance:none;border:1px solid var(--mt-border);background:var(--mt-surface);width:100%;color:var(--mt-text);font:inherit;border-radius:var(--mt-radius-sm);padding:7px 11px;font-size:13px}.search:focus{border-color:var(--mt-accent);outline:none}.search::placeholder{color:var(--mt-text-faint)}.btn{appearance:none;border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text);font:inherit;border-radius:var(--mt-radius-sm);cursor:pointer;white-space:nowrap;padding:6px 11px;font-size:12px;transition:border-color .15s,background .15s}.btn:hover{border-color:var(--mt-accent);background:var(--mt-surface-2)}.btn:disabled{opacity:.5;cursor:default}.btn.is-active{border-color:var(--mt-accent);color:var(--mt-accent)}.chip{border:1px solid var(--mt-border);background:var(--mt-surface);color:var(--mt-text-dim);font-family:var(--mt-mono);border-radius:999px;align-items:center;gap:4px;padding:1px 7px;font-size:11px;display:inline-flex}.chip.is-good{color:var(--mt-good);border-color:color-mix(in srgb, var(--mt-good) 45%, var(--mt-border))}.chip.is-warn{color:var(--mt-warn);border-color:color-mix(in srgb, var(--mt-warn) 45%, var(--mt-border))}.chip.is-bad{color:var(--mt-bad);border-color:color-mix(in srgb, var(--mt-bad) 45%, var(--mt-border))}.tablewrap{border:1px solid var(--mt-border);border-radius:var(--mt-radius);max-height:70vh;overflow:auto}table.tbl{border-collapse:collapse;width:100%;font-size:12px}table.tbl th,table.tbl td{text-align:left;border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);white-space:nowrap;font-family:var(--mt-mono);padding:7px 12px}table.tbl thead th{z-index:1;background:var(--mt-surface-2);color:var(--mt-text-dim);cursor:pointer;-webkit-user-select:none;user-select:none;font-weight:600;position:sticky;top:0}table.tbl thead th:hover{color:var(--mt-text)}table.tbl thead th .arrow{color:var(--mt-accent);margin-left:4px}table.tbl tbody tr{cursor:pointer}table.tbl tbody tr:hover{background:color-mix(in srgb, var(--mt-accent) 8%, transparent)}table.tbl tbody tr.is-disabled td,table.tbl td.col-num{color:var(--mt-text-faint)}.kv__body{border:1px solid var(--mt-border);border-radius:var(--mt-radius);grid-template-columns:minmax(120px,.4fr) 1fr;display:grid;overflow:hidden}.kv__body>div{border-bottom:1px solid color-mix(in srgb, var(--mt-border) 55%, transparent);overflow-wrap:anywhere;min-width:0;font-size:12px;font-family:var(--mt-mono);padding:7px 14px}.kv__k{color:var(--mt-text-dim);background:color-mix(in srgb, var(--mt-surface) 60%, transparent)}.kv__v{color:var(--mt-text)}.drawer{border:1px solid var(--mt-accent);border-radius:var(--mt-radius);background:var(--mt-surface);gap:10px;padding:12px;display:grid}.drawer__hd{align-items:center;gap:8px;display:flex}.drawer__hd b{font-family:var(--mt-mono)}pre.raw{border:1px solid var(--mt-border);border-radius:var(--mt-radius);background:var(--mt-surface);color:var(--mt-text);font-family:var(--mt-mono);white-space:pre;max-height:70vh;margin:0;padding:14px;font-size:12px;overflow:auto}.foot{color:var(--mt-text-faint);font-size:11px;font-family:var(--mt-mono);flex-wrap:wrap;align-items:center;gap:10px;display:flex}.foot .grow{flex:1}.skeleton,.empty{color:var(--mt-text-faint);text-align:center;padding:40px 0}.count-pill b{color:var(--mt-accent)}table.tbl td.col-num,table.tbl th.col-num{width:1%}
|
package/package.json
CHANGED
package/schemas/README.md
CHANGED
|
@@ -4,11 +4,11 @@ Machine-readable JSON Schemas for `@usex/mikrotik-mcp`, **generated** from the
|
|
|
4
4
|
TypeScript source by `scripts/gen-schemas.ts` (`bun run gen:schemas`). Do not
|
|
5
5
|
edit by hand — regenerate instead.
|
|
6
6
|
|
|
7
|
-
| File
|
|
8
|
-
|
|
9
|
-
| `config.schema.json` | The runtime configuration object (env vars / CLI flags).
|
|
10
|
-
| `tool-catalog.json`
|
|
11
|
-
| `tools/<name>.json`
|
|
7
|
+
| File | Contents |
|
|
8
|
+
|------|----------|
|
|
9
|
+
| `config.schema.json` | The runtime configuration object (env vars / CLI flags). |
|
|
10
|
+
| `tool-catalog.json` | Every one of the 794 tools: `name`, `risk`, `title`, `description`, and input JSON Schema. |
|
|
11
|
+
| `tools/<name>.json` | The input JSON Schema for a single tool. |
|
|
12
12
|
|
|
13
13
|
`risk` is derived from the MCP tool annotations:
|
|
14
14
|
`read` · `write` · `write-idempotent` · `destructive` · `dangerous`.
|
|
@@ -90,7 +90,11 @@
|
|
|
90
90
|
"maximum": 9007199254740991
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
|
-
"required": [
|
|
93
|
+
"required": [
|
|
94
|
+
"host",
|
|
95
|
+
"port",
|
|
96
|
+
"username"
|
|
97
|
+
],
|
|
94
98
|
"additionalProperties": false
|
|
95
99
|
},
|
|
96
100
|
"mac": {
|
|
@@ -109,9 +113,18 @@
|
|
|
109
113
|
},
|
|
110
114
|
"description": {
|
|
111
115
|
"type": "string"
|
|
116
|
+
},
|
|
117
|
+
"disabled": {
|
|
118
|
+
"type": "boolean"
|
|
112
119
|
}
|
|
113
120
|
},
|
|
114
|
-
"required": [
|
|
121
|
+
"required": [
|
|
122
|
+
"host",
|
|
123
|
+
"username",
|
|
124
|
+
"password",
|
|
125
|
+
"port",
|
|
126
|
+
"timeoutMs"
|
|
127
|
+
],
|
|
115
128
|
"additionalProperties": false
|
|
116
129
|
}
|
|
117
130
|
},
|
|
@@ -128,14 +141,18 @@
|
|
|
128
141
|
"allowedOrigins": "",
|
|
129
142
|
"corsOrigins": "",
|
|
130
143
|
"toolPageSize": 0,
|
|
131
|
-
"appViews":
|
|
144
|
+
"appViews": false
|
|
132
145
|
},
|
|
133
146
|
"type": "object",
|
|
134
147
|
"properties": {
|
|
135
148
|
"transport": {
|
|
136
149
|
"default": "stdio",
|
|
137
150
|
"type": "string",
|
|
138
|
-
"enum": [
|
|
151
|
+
"enum": [
|
|
152
|
+
"stdio",
|
|
153
|
+
"sse",
|
|
154
|
+
"streamable-http"
|
|
155
|
+
]
|
|
139
156
|
},
|
|
140
157
|
"host": {
|
|
141
158
|
"default": "0.0.0.0",
|
|
@@ -166,7 +183,7 @@
|
|
|
166
183
|
"maximum": 9007199254740991
|
|
167
184
|
},
|
|
168
185
|
"appViews": {
|
|
169
|
-
"default":
|
|
186
|
+
"default": false,
|
|
170
187
|
"type": "boolean"
|
|
171
188
|
}
|
|
172
189
|
},
|
|
@@ -214,7 +231,10 @@
|
|
|
214
231
|
"maximum": 9007199254740991
|
|
215
232
|
}
|
|
216
233
|
},
|
|
217
|
-
"required": [
|
|
234
|
+
"required": [
|
|
235
|
+
"prefix",
|
|
236
|
+
"presignExpiresIn"
|
|
237
|
+
],
|
|
218
238
|
"additionalProperties": false
|
|
219
239
|
},
|
|
220
240
|
"dashboard": {
|
|
@@ -309,7 +329,11 @@
|
|
|
309
329
|
"maximum": 9007199254740991
|
|
310
330
|
}
|
|
311
331
|
},
|
|
312
|
-
"required": [
|
|
332
|
+
"required": [
|
|
333
|
+
"keepAlive",
|
|
334
|
+
"keepAliveInterval",
|
|
335
|
+
"idleTimeout"
|
|
336
|
+
],
|
|
313
337
|
"additionalProperties": false
|
|
314
338
|
},
|
|
315
339
|
"readOnly": {
|
|
@@ -354,7 +378,12 @@
|
|
|
354
378
|
}
|
|
355
379
|
}
|
|
356
380
|
},
|
|
357
|
-
"required": [
|
|
381
|
+
"required": [
|
|
382
|
+
"enabledModules",
|
|
383
|
+
"disabledModules",
|
|
384
|
+
"enabledGroups",
|
|
385
|
+
"disabledGroups"
|
|
386
|
+
],
|
|
358
387
|
"additionalProperties": false
|
|
359
388
|
},
|
|
360
389
|
"memory": {
|
|
@@ -373,11 +402,18 @@
|
|
|
373
402
|
"type": "string"
|
|
374
403
|
}
|
|
375
404
|
},
|
|
376
|
-
"required": [
|
|
405
|
+
"required": [
|
|
406
|
+
"enabled",
|
|
407
|
+
"dbPath"
|
|
408
|
+
],
|
|
377
409
|
"additionalProperties": false
|
|
378
410
|
},
|
|
379
411
|
"backupDir": {
|
|
380
412
|
"type": "string"
|
|
413
|
+
},
|
|
414
|
+
"disableUpdateCheck": {
|
|
415
|
+
"default": false,
|
|
416
|
+
"type": "boolean"
|
|
381
417
|
}
|
|
382
418
|
},
|
|
383
419
|
"required": [
|
|
@@ -388,7 +424,8 @@
|
|
|
388
424
|
"ssh",
|
|
389
425
|
"readOnly",
|
|
390
426
|
"tools",
|
|
391
|
-
"memory"
|
|
427
|
+
"memory",
|
|
428
|
+
"disableUpdateCheck"
|
|
392
429
|
],
|
|
393
430
|
"additionalProperties": false
|
|
394
431
|
}
|