minecodex 2.0.16 → 2.0.18

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.
@@ -222,7 +222,7 @@ function updatePluginCard(card, feature) {
222
222
  const dot = card.querySelector(".plugin-state .status-dot");
223
223
  const stateLabel = card.querySelector(".plugin-state-label");
224
224
  card.dataset.featureId = feature.id;
225
- image.src = `${feature.iconUrl}?v=resource-1`;
225
+ image.src = feature.iconUrl.startsWith("data:") ? feature.iconUrl : `${feature.iconUrl}?v=resource-1`;
226
226
  name.textContent = feature.label;
227
227
  description.textContent = feature.description;
228
228
  input.checked = Boolean(feature.enabled);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecodex",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
4
4
  "description": "Lightweight, local-first plugins for the Codex desktop app.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- var vz=Object.defineProperty;var Rn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var zt=(e,t)=>{for(var n in t)vz(e,n,{get:t[n],enumerable:!0})};function G$(e){return{minecodexVersion:e?.version??null,codexBuild:e?.renderer?.codexBuild??e?.runtime?.codex?.version??null,buildSource:e?.renderer?.buildSource??null,verification:"runtime-observation-only",targets:(e?.renderer?.targets??[]).map(t=>({targetId:t.targetId,checkedAt:t.checkedAt,reason:t.reason??null,tokens:t.tokens,capabilities:t.capabilities,plugins:(t.plugins??[]).map(n=>({featureId:n.featureId,installation:n.installation,state:n.state,reason:n.reason,checks:n.checks,tokens:n.tokens}))})),services:(e?.features??[]).map(t=>({featureId:t.id,state:t.state,failureCode:t.failure?.code??null}))}}var W$=Rn(()=>{});async function sn(e,t={}){let n=window.minecodexMcpApp;if(!n)return fetch(e,t);let o=t.method??"GET",r=await n.callServerTool({name:o==="GET"?"minecodex_read":"minecodex_write",arguments:{route:e,method:o,locale:new Headers(t.headers).get("Accept-Language")??document.documentElement.lang,...t.body?{body:JSON.parse(t.body)}:{}}});if(r.isError)throw new Error(r.content?.find(s=>s.type==="text")?.text??"MineCodex request failed");let{status:i,body:a}=r.structuredContent;return new Response(JSON.stringify(a),{status:i,headers:{"Content-Type":"application/json"}})}var Vv=Rn(()=>{});var ET={};function kT(){D.languageToggle.setAttribute("aria-label",At==="zh-CN"?"\u8BED\u8A00":"Language");for(let e of D.languageButtons)e.setAttribute("aria-pressed",String(e.dataset.languageChoice===At));D.runtimeLabel.textContent=Y.connecting,D.restartTitle.textContent=Y.restartTitle,D.restartCopy.textContent=Y.restartCopy,D.restartButton.querySelector(".button-label").textContent=Y.restart,D.pluginsHeading.textContent=Y.plugins,D.errorTitle.textContent=Y.loadError,D.errorCopy.textContent=Y.loadErrorCopy,D.retryButton.textContent=Y.retry,D.versionLabel.textContent=Y.version,D.diagnosticsButton.textContent=Y.copyDiagnostics,D.updateButton.querySelector(".button-label").textContent=Y.checkUpdates}function xT(e){let t=e.state??(e.failure?"failed":e.healthy?"healthy":e.injected?"injected":e.applied?"launching":e.enabled?"restart-required":"stopped"),n=Y.states[t]??Y.states.stopped,o={healthy:"is-active",injected:"is-active",configured:"is-warning",failed:"is-failed",launching:"is-warning","restart-required":"is-warning",saved:"is-warning",stopped:"is-stopped"}[t]??"is-warning";return{label:e.failure?.message&&t==="failed"?`${n}: ${Y.failureDetail}`:n,className:o}}function qe(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function IT(e){let t=qe("article","plugin-card");t.dataset.featureId=e.id;let n=qe("div","plugin-icon");n.setAttribute("aria-hidden","true");let o=qe("img");o.alt="",o.width=24,o.height=24,n.append(o);let r=qe("div","plugin-copy"),i=qe("div","plugin-title-line"),a=qe("h3","plugin-name");i.append(a);let s=qe("p","plugin-description");r.append(i,s);let l=qe("div","plugin-topline"),c=qe("label","switch"),d=qe("input");d.type="checkbox",d.name=`feature-${e.id}`,d.setAttribute("role","switch"),d.setAttribute("aria-describedby",`description-${e.id} state-${e.id}`),s.id=`description-${e.id}`;let p=qe("span","switch-track");p.setAttribute("aria-hidden","true"),c.append(d,p);let h=qe("span","plugin-state"),f=qe("span","status-dot");f.setAttribute("aria-hidden","true");let v=qe("span","plugin-state-label");return v.id=`state-${e.id}`,h.append(f,v),l.append(n,c),t.append(l,r,h),t}function Ud(e,t){for(let c of D.languageButtons)c.disabled=at.size>0;let n=xT(t),o=e.querySelector('input[type="checkbox"]'),r=e.querySelector(".plugin-icon img"),i=e.querySelector(".plugin-name"),a=e.querySelector(".plugin-description"),s=e.querySelector(".plugin-state .status-dot"),l=e.querySelector(".plugin-state-label");e.dataset.featureId=t.id,r.src=`${t.iconUrl}?v=resource-1`,i.textContent=t.label,a.textContent=t.description,o.checked=!!t.enabled,o.disabled=at.has(t.id),o.setAttribute("aria-label",t.label),s.className=`status-dot ${n.className}`,l.textContent=n.label}function Q$(e){return[...D.pluginList.querySelectorAll("[data-feature-id]")].find(t=>t.dataset.featureId===e)??null}function RT(e){e=e.filter(n=>n.id!=="unread-inbox");for(let n of[...D.pluginList.children])n.dataset.featureId||n.remove();let t=new Set(e.map(({id:n})=>n));for(let n of e){let o=Q$(n.id);o||(o=IT(n)),D.pluginList.append(o),Ud(o,n)}for(let n of[...D.pluginList.querySelectorAll("[data-feature-id]")])n.dataset.featureId&&!t.has(n.dataset.featureId)&&n.remove();D.pluginList.setAttribute("aria-busy","false")}function ez(){let e=!!ze?.runtime?.running,t=ze?.renderer,n=!!(t?.discovered&&t.runtimeSessionId&&t.runtimeSessionId===ze?.runtime?.runtimeSessionId&&t.active&&Number(t.injectedTargets)>0),o=e&&n;D.runtimeLabel.closest(".overview").hidden=o,D.runtimeDot.className=`status-dot ${o?"is-active":"is-warning"}`,D.runtimeLabel.textContent=o?Y.runtimeActive:e?Y.runtimeNotInjected:Y.runtimeStopped,D.versionValue.textContent=ze?.version??"\u2014",D.restartNotice.hidden=!ze?.pendingRestart}function PT(){ez(),RT(ze?.features??[])}function TT(e){let t=document.activeElement,n=t?.closest?.("[data-feature-id]");return!n||n.dataset.featureId!==e?null:{featureId:e,input:t.matches?.('input[type="checkbox"]')}}function X$(e){if(!e?.input)return;Q$(e.featureId)?.querySelector('input[type="checkbox"]')?.focus()}function Dd(e){clearTimeout(Y$),D.toast.textContent=e,D.toast.hidden=!1,Y$=setTimeout(()=>{D.toast.hidden=!0},4200)}function Zv(e,t){ze.features=ze.features.map(n=>n.id===e?{...n,...t}:n)}async function Md(){D.loadError.hidden=!0;try{let e=await sn("/api/status",{headers:{"Accept-Language":At}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();at.size&&ze&&(t.features=t.features.map(n=>at.has(n.id)?ze.features.find(o=>o.id===n.id)??n:n)),ze=t,D.pluginList.hidden=!1,PT()}catch{D.pluginList.hidden=!0,D.loadError.hidden=!1,D.runtimeDot.className="status-dot is-warning",D.runtimeLabel.textContent=Y.runtimeStopped,D.runtimeLabel.closest(".overview").hidden=!0}}function qd(){let e=window.minecodexHostTheme?window.minecodexHostTheme==="dark":tz.matches,t=Tc==="dark"||Tc!=="light"&&e;document.documentElement.dataset.theme=t?"dark":"light",D.themeToggle.setAttribute("aria-label",At==="zh-CN"?"\u5916\u89C2":"Appearance");for(let n of D.themeButtons)n.setAttribute("aria-label",n.dataset.themeChoice==="light"?Y.lightAppearance:Y.darkAppearance),n.setAttribute("aria-pressed",String(n.dataset.themeChoice===(t?"dark":"light")))}var Fv,At,Y,D,ze,Y$,at,tz,Tc,rz=Rn(()=>{W$();Vv();try{Fv=localStorage.getItem("minecodex-language")}catch{}At=["en","zh-CN"].includes(Fv)?Fv:navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en";document.documentElement.lang=At;Y={en:{connecting:"Connecting\u2026",runtimeActive:"Active in Codex",runtimeStopped:"Runtime unavailable",runtimeNotInjected:"Runtime running \u2014 restart Codex to apply plugins",plugins:"Your extensions",restartTitle:"Restart Codex to apply changes",restartCopy:"Your plugin choices are saved. Restart when you are ready.",restart:"Restart Codex",restarting:"Restarting\u2026",saved:"Saved",saving:"Saving\u2026",states:{saved:"Saved \u2014 restart Codex to apply",configured:"Configured \u2014 starting in Codex\u2026",launching:"Launching in Codex\u2026",injected:"Active in Codex",healthy:"Active in Codex",checking:"Checking compatibility\u2026",partial:"Available in some windows",degraded:"Appearance needs an update",unavailable:"Temporarily unavailable \u2014 check for updates","not-applicable":"Not needed on this page",failed:"Couldn\u2019t start \u2014 try again",stopped:"Stopped","restart-required":"Restart required \u2014 restart Codex"},loadError:"Couldn\u2019t load MineCodex",loadErrorCopy:"Check that the background service is running.",retry:"Try again",version:"Version",darkAppearance:"Dark appearance",lightAppearance:"Light appearance",updateFailed:"Couldn\u2019t check for updates. Please try again.",copyDiagnostics:"Copy diagnostics",diagnosticsCopied:"Diagnostics copied",diagnosticsFailed:"Couldn\u2019t copy diagnostics. Please try again.",checkUpdates:"Check for updates",checkingUpdates:"Checking\u2026",current:"You\u2019re up to date.",updateAvailable:e=>`MineCodex ${e} is available. Run mcx update in Terminal.`,changeFailed:"The plugin setting could not be saved.",restartFailed:"MineCodex could not restart Codex. Please try again or copy diagnostics.",failureDetail:"This extension could not be confirmed. Copy diagnostics to help investigate."},"zh-CN":{connecting:"\u6B63\u5728\u8FDE\u63A5\u2026",runtimeActive:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",runtimeStopped:"\u8FD0\u884C\u670D\u52A1\u4E0D\u53EF\u7528",runtimeNotInjected:"\u8FD0\u884C\u670D\u52A1\u5DF2\u542F\u52A8\u2014\u2014\u91CD\u542F Codex \u4EE5\u5E94\u7528\u63D2\u4EF6",plugins:"\u529F\u80FD\u6269\u5C55",restartTitle:"\u91CD\u542F Codex \u4EE5\u5E94\u7528\u66F4\u6539",restartCopy:"\u63D2\u4EF6\u9009\u62E9\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u53EF\u4EE5\u5728\u51C6\u5907\u597D\u540E\u7EDF\u4E00\u91CD\u542F\u3002",restart:"\u91CD\u542F Codex",restarting:"\u6B63\u5728\u91CD\u542F\u2026",saved:"\u5DF2\u4FDD\u5B58",saving:"\u6B63\u5728\u4FDD\u5B58\u2026",states:{saved:"\u5DF2\u4FDD\u5B58\u2014\u2014\u91CD\u542F Codex \u540E\u5E94\u7528",configured:"\u5DF2\u914D\u7F6E\u2014\u2014\u6B63\u5728 Codex \u4E2D\u542F\u52A8\u2026",launching:"\u6B63\u5728 Codex \u4E2D\u542F\u52A8\u2026",injected:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",healthy:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",checking:"\u6B63\u5728\u81EA\u68C0\u2026",partial:"\u90E8\u5206\u7A97\u53E3\u53EF\u7528",degraded:"\u5916\u89C2\u9002\u914D\u9700\u8981\u66F4\u65B0",unavailable:"\u6682\u4E0D\u53EF\u7528\u2014\u2014\u8BF7\u68C0\u67E5\u66F4\u65B0","not-applicable":"\u5F53\u524D\u9875\u9762\u4E0D\u9002\u7528",failed:"\u6682\u65F6\u65E0\u6CD5\u542F\u52A8\u2014\u2014\u8BF7\u91CD\u8BD5",stopped:"\u5DF2\u505C\u6B62","restart-required":"\u9700\u8981\u91CD\u542F\u2014\u2014\u8BF7\u91CD\u542F Codex"},loadError:"\u65E0\u6CD5\u52A0\u8F7D MineCodex",loadErrorCopy:"\u8BF7\u68C0\u67E5\u540E\u53F0\u670D\u52A1\u662F\u5426\u6B63\u5728\u8FD0\u884C\u3002",retry:"\u91CD\u8BD5",version:"\u7248\u672C",darkAppearance:"\u6DF1\u8272\u5916\u89C2",lightAppearance:"\u6D45\u8272\u5916\u89C2",updateFailed:"\u6682\u65F6\u65E0\u6CD5\u68C0\u67E5\u66F4\u65B0\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",copyDiagnostics:"\u590D\u5236\u8BCA\u65AD\u4FE1\u606F",diagnosticsCopied:"\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",diagnosticsFailed:"\u6682\u65F6\u65E0\u6CD5\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\uFF0C\u8BF7\u91CD\u8BD5\u3002",checkUpdates:"\u68C0\u67E5\u66F4\u65B0",checkingUpdates:"\u6B63\u5728\u68C0\u67E5\u2026",current:"\u5F53\u524D\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002",updateAvailable:e=>`\u53D1\u73B0 MineCodex ${e}\uFF0C\u8BF7\u5728\u7EC8\u7AEF\u8FD0\u884C mcx update\u3002`,changeFailed:"\u63D2\u4EF6\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002",restartFailed:"MineCodex \u65E0\u6CD5\u91CD\u542F Codex\u3002\u8BF7\u91CD\u8BD5\u6216\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u534F\u52A9\u6392\u67E5\u3002",failureDetail:"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u8FD9\u9879\u529F\u80FD\u7684\u72B6\u6001\uFF0C\u53EF\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u534F\u52A9\u6392\u67E5\u3002"}}[At],D={runtimeDot:document.querySelector("#runtime-dot"),runtimeLabel:document.querySelector("#runtime-label"),restartNotice:document.querySelector("#restart-notice"),restartTitle:document.querySelector("#restart-title"),restartCopy:document.querySelector("#restart-copy"),restartButton:document.querySelector("#restart-button"),pluginsHeading:document.querySelector("#plugins-heading"),saveState:document.querySelector("#save-state"),pluginList:document.querySelector("#plugin-list"),loadError:document.querySelector("#load-error"),errorTitle:document.querySelector("#error-title"),errorCopy:document.querySelector("#error-copy"),retryButton:document.querySelector("#retry-button"),versionLabel:document.querySelector("#version-label"),versionValue:document.querySelector("#version-value"),languageToggle:document.querySelector(".language-toggle"),languageButtons:[...document.querySelectorAll("[data-language-choice]")],themeToggle:document.querySelector(".theme-toggle"),themeButtons:[...document.querySelectorAll("[data-theme-choice]")],updateResult:document.querySelector("#update-result"),updateButton:document.querySelector("#update-button"),diagnosticsButton:document.querySelector("#diagnostics-button"),toast:document.querySelector("#toast")},ze=null,Y$=null,at=new Set;D.pluginList.addEventListener("change",async e=>{let t=e.target.closest('input[type="checkbox"]'),n=t?.closest("[data-feature-id]");if(!t||!n||!ze)return;let o=n.dataset.featureId,r={...ze.features.find(a=>a.id===o)},i=TT(o);at.add(o),Zv(o,{enabled:t.checked,state:"saved"}),Ud(n,ze.features.find(a=>a.id===o)),D.saveState.textContent=Y.saving;try{let a=await sn(`/api/features/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json","Accept-Language":At},body:JSON.stringify({enabled:t.checked})});if(!a.ok)throw new Error(`HTTP ${a.status}`);let s=await a.json(),l=s.features?.find(d=>d.id===o);l&&Zv(o,l),ze.pendingRestart=s.pendingRestart,at.delete(o);let c=l??ze.features.find(d=>d.id===o);c&&Ud(n,c),ez(),X$(i),D.saveState.textContent=at.size?Y.saving:Y.saved}catch{at.delete(o),Zv(o,r),Ud(n,r),D.saveState.textContent=at.size?Y.saving:"",X$(i),Dd(Y.changeFailed)}});D.restartButton.addEventListener("click",async()=>{D.restartButton.disabled=!0,D.restartButton.querySelector(".button-label").textContent=Y.restarting;try{let e=await sn("/api/restart",{method:"POST",headers:{"Content-Type":"application/json","Accept-Language":At},body:"{}"});if(!e.ok)throw new Error(`HTTP ${e.status}`);await Md()}catch{Dd(Y.restartFailed)}finally{D.restartButton.disabled=!1,D.restartButton.querySelector(".button-label").textContent=Y.restart}});D.retryButton.addEventListener("click",()=>{D.pluginList.hidden=!1,Md()});D.diagnosticsButton.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(JSON.stringify(G$(ze),null,2)),Dd(Y.diagnosticsCopied)}catch{Dd(Y.diagnosticsFailed)}});setInterval(()=>{!document.hidden&&!at.size&&Md()},5e3);D.updateButton.addEventListener("click",async()=>{D.updateButton.disabled=!0,D.updateButton.querySelector(".button-label").textContent=Y.checkingUpdates,D.updateResult.hidden=!0;try{let e=await sn("/api/update");if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();D.updateResult.textContent=t.available?Y.updateAvailable(t.latest):Y.current,D.updateResult.hidden=!1}catch{D.updateResult.textContent=Y.updateFailed,D.updateResult.hidden=!1}finally{D.updateButton.disabled=!1,D.updateButton.querySelector(".button-label").textContent=Y.checkUpdates}});tz=matchMedia("(prefers-color-scheme: dark)"),Tc=null;try{Tc=localStorage.getItem("minecodex-appearance")}catch{}D.themeToggle.addEventListener("click",e=>{let t=e.target.closest("[data-theme-choice]");if(t){Tc=t.dataset.themeChoice;try{localStorage.setItem("minecodex-appearance",Tc)}catch{}qd()}});D.languageToggle.addEventListener("click",e=>{let t=e.target.closest("[data-language-choice]");if(!t||at.size||D.restartButton.disabled)return;let n=t.dataset.languageChoice;if(n!==At){try{localStorage.setItem("minecodex-language",n)}catch{return}location.reload()}});tz.addEventListener("change",qd);window.addEventListener("minecodex-host-theme",qd);document.addEventListener("keydown",()=>{document.documentElement.dataset.input="keyboard"});document.addEventListener("pointerdown",()=>{document.documentElement.dataset.input="pointer"});kT();qd();Md()});function nz(e){let t="data-minecodex-tooltip",n=document.createElement("div");n.id="minecodex-feature-tooltip",n.setAttribute("role","tooltip"),n.hidden=!0;let o=document.createElement("style");o.setAttribute("data-minecodex-ui-styles","tooltip"),o.textContent=`
1
+ var vz=Object.defineProperty;var Rn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var zt=(e,t)=>{for(var n in t)vz(e,n,{get:t[n],enumerable:!0})};function G$(e){return{minecodexVersion:e?.version??null,codexBuild:e?.renderer?.codexBuild??e?.runtime?.codex?.version??null,buildSource:e?.renderer?.buildSource??null,verification:"runtime-observation-only",targets:(e?.renderer?.targets??[]).map(t=>({targetId:t.targetId,checkedAt:t.checkedAt,reason:t.reason??null,tokens:t.tokens,capabilities:t.capabilities,plugins:(t.plugins??[]).map(n=>({featureId:n.featureId,installation:n.installation,state:n.state,reason:n.reason,checks:n.checks,tokens:n.tokens}))})),services:(e?.features??[]).map(t=>({featureId:t.id,state:t.state,failureCode:t.failure?.code??null}))}}var W$=Rn(()=>{});async function sn(e,t={}){let n=window.minecodexMcpApp;if(!n)return fetch(e,t);let o=t.method??"GET",r=await n.callServerTool({name:o==="GET"?"minecodex_read":"minecodex_write",arguments:{route:e,method:o,locale:new Headers(t.headers).get("Accept-Language")??document.documentElement.lang,...t.body?{body:JSON.parse(t.body)}:{}}});if(r.isError)throw new Error(r.content?.find(s=>s.type==="text")?.text??"MineCodex request failed");let{status:i,body:a}=r.structuredContent;return new Response(JSON.stringify(a),{status:i,headers:{"Content-Type":"application/json"}})}var Vv=Rn(()=>{});var ET={};function kT(){D.languageToggle.setAttribute("aria-label",At==="zh-CN"?"\u8BED\u8A00":"Language");for(let e of D.languageButtons)e.setAttribute("aria-pressed",String(e.dataset.languageChoice===At));D.runtimeLabel.textContent=Y.connecting,D.restartTitle.textContent=Y.restartTitle,D.restartCopy.textContent=Y.restartCopy,D.restartButton.querySelector(".button-label").textContent=Y.restart,D.pluginsHeading.textContent=Y.plugins,D.errorTitle.textContent=Y.loadError,D.errorCopy.textContent=Y.loadErrorCopy,D.retryButton.textContent=Y.retry,D.versionLabel.textContent=Y.version,D.diagnosticsButton.textContent=Y.copyDiagnostics,D.updateButton.querySelector(".button-label").textContent=Y.checkUpdates}function xT(e){let t=e.state??(e.failure?"failed":e.healthy?"healthy":e.injected?"injected":e.applied?"launching":e.enabled?"restart-required":"stopped"),n=Y.states[t]??Y.states.stopped,o={healthy:"is-active",injected:"is-active",configured:"is-warning",failed:"is-failed",launching:"is-warning","restart-required":"is-warning",saved:"is-warning",stopped:"is-stopped"}[t]??"is-warning";return{label:e.failure?.message&&t==="failed"?`${n}: ${Y.failureDetail}`:n,className:o}}function qe(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function IT(e){let t=qe("article","plugin-card");t.dataset.featureId=e.id;let n=qe("div","plugin-icon");n.setAttribute("aria-hidden","true");let o=qe("img");o.alt="",o.width=24,o.height=24,n.append(o);let r=qe("div","plugin-copy"),i=qe("div","plugin-title-line"),a=qe("h3","plugin-name");i.append(a);let s=qe("p","plugin-description");r.append(i,s);let l=qe("div","plugin-topline"),c=qe("label","switch"),d=qe("input");d.type="checkbox",d.name=`feature-${e.id}`,d.setAttribute("role","switch"),d.setAttribute("aria-describedby",`description-${e.id} state-${e.id}`),s.id=`description-${e.id}`;let p=qe("span","switch-track");p.setAttribute("aria-hidden","true"),c.append(d,p);let h=qe("span","plugin-state"),f=qe("span","status-dot");f.setAttribute("aria-hidden","true");let v=qe("span","plugin-state-label");return v.id=`state-${e.id}`,h.append(f,v),l.append(n,c),t.append(l,r,h),t}function Ud(e,t){for(let c of D.languageButtons)c.disabled=at.size>0;let n=xT(t),o=e.querySelector('input[type="checkbox"]'),r=e.querySelector(".plugin-icon img"),i=e.querySelector(".plugin-name"),a=e.querySelector(".plugin-description"),s=e.querySelector(".plugin-state .status-dot"),l=e.querySelector(".plugin-state-label");e.dataset.featureId=t.id,r.src=t.iconUrl.startsWith("data:")?t.iconUrl:`${t.iconUrl}?v=resource-1`,i.textContent=t.label,a.textContent=t.description,o.checked=!!t.enabled,o.disabled=at.has(t.id),o.setAttribute("aria-label",t.label),s.className=`status-dot ${n.className}`,l.textContent=n.label}function Q$(e){return[...D.pluginList.querySelectorAll("[data-feature-id]")].find(t=>t.dataset.featureId===e)??null}function RT(e){e=e.filter(n=>n.id!=="unread-inbox");for(let n of[...D.pluginList.children])n.dataset.featureId||n.remove();let t=new Set(e.map(({id:n})=>n));for(let n of e){let o=Q$(n.id);o||(o=IT(n)),D.pluginList.append(o),Ud(o,n)}for(let n of[...D.pluginList.querySelectorAll("[data-feature-id]")])n.dataset.featureId&&!t.has(n.dataset.featureId)&&n.remove();D.pluginList.setAttribute("aria-busy","false")}function ez(){let e=!!ze?.runtime?.running,t=ze?.renderer,n=!!(t?.discovered&&t.runtimeSessionId&&t.runtimeSessionId===ze?.runtime?.runtimeSessionId&&t.active&&Number(t.injectedTargets)>0),o=e&&n;D.runtimeLabel.closest(".overview").hidden=o,D.runtimeDot.className=`status-dot ${o?"is-active":"is-warning"}`,D.runtimeLabel.textContent=o?Y.runtimeActive:e?Y.runtimeNotInjected:Y.runtimeStopped,D.versionValue.textContent=ze?.version??"\u2014",D.restartNotice.hidden=!ze?.pendingRestart}function PT(){ez(),RT(ze?.features??[])}function TT(e){let t=document.activeElement,n=t?.closest?.("[data-feature-id]");return!n||n.dataset.featureId!==e?null:{featureId:e,input:t.matches?.('input[type="checkbox"]')}}function X$(e){if(!e?.input)return;Q$(e.featureId)?.querySelector('input[type="checkbox"]')?.focus()}function Dd(e){clearTimeout(Y$),D.toast.textContent=e,D.toast.hidden=!1,Y$=setTimeout(()=>{D.toast.hidden=!0},4200)}function Zv(e,t){ze.features=ze.features.map(n=>n.id===e?{...n,...t}:n)}async function Md(){D.loadError.hidden=!0;try{let e=await sn("/api/status",{headers:{"Accept-Language":At}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();at.size&&ze&&(t.features=t.features.map(n=>at.has(n.id)?ze.features.find(o=>o.id===n.id)??n:n)),ze=t,D.pluginList.hidden=!1,PT()}catch{D.pluginList.hidden=!0,D.loadError.hidden=!1,D.runtimeDot.className="status-dot is-warning",D.runtimeLabel.textContent=Y.runtimeStopped,D.runtimeLabel.closest(".overview").hidden=!0}}function qd(){let e=window.minecodexHostTheme?window.minecodexHostTheme==="dark":tz.matches,t=Tc==="dark"||Tc!=="light"&&e;document.documentElement.dataset.theme=t?"dark":"light",D.themeToggle.setAttribute("aria-label",At==="zh-CN"?"\u5916\u89C2":"Appearance");for(let n of D.themeButtons)n.setAttribute("aria-label",n.dataset.themeChoice==="light"?Y.lightAppearance:Y.darkAppearance),n.setAttribute("aria-pressed",String(n.dataset.themeChoice===(t?"dark":"light")))}var Fv,At,Y,D,ze,Y$,at,tz,Tc,rz=Rn(()=>{W$();Vv();try{Fv=localStorage.getItem("minecodex-language")}catch{}At=["en","zh-CN"].includes(Fv)?Fv:navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en";document.documentElement.lang=At;Y={en:{connecting:"Connecting\u2026",runtimeActive:"Active in Codex",runtimeStopped:"Runtime unavailable",runtimeNotInjected:"Runtime running \u2014 restart Codex to apply plugins",plugins:"Your extensions",restartTitle:"Restart Codex to apply changes",restartCopy:"Your plugin choices are saved. Restart when you are ready.",restart:"Restart Codex",restarting:"Restarting\u2026",saved:"Saved",saving:"Saving\u2026",states:{saved:"Saved \u2014 restart Codex to apply",configured:"Configured \u2014 starting in Codex\u2026",launching:"Launching in Codex\u2026",injected:"Active in Codex",healthy:"Active in Codex",checking:"Checking compatibility\u2026",partial:"Available in some windows",degraded:"Appearance needs an update",unavailable:"Temporarily unavailable \u2014 check for updates","not-applicable":"Not needed on this page",failed:"Couldn\u2019t start \u2014 try again",stopped:"Stopped","restart-required":"Restart required \u2014 restart Codex"},loadError:"Couldn\u2019t load MineCodex",loadErrorCopy:"Check that the background service is running.",retry:"Try again",version:"Version",darkAppearance:"Dark appearance",lightAppearance:"Light appearance",updateFailed:"Couldn\u2019t check for updates. Please try again.",copyDiagnostics:"Copy diagnostics",diagnosticsCopied:"Diagnostics copied",diagnosticsFailed:"Couldn\u2019t copy diagnostics. Please try again.",checkUpdates:"Check for updates",checkingUpdates:"Checking\u2026",current:"You\u2019re up to date.",updateAvailable:e=>`MineCodex ${e} is available. Run mcx update in Terminal.`,changeFailed:"The plugin setting could not be saved.",restartFailed:"MineCodex could not restart Codex. Please try again or copy diagnostics.",failureDetail:"This extension could not be confirmed. Copy diagnostics to help investigate."},"zh-CN":{connecting:"\u6B63\u5728\u8FDE\u63A5\u2026",runtimeActive:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",runtimeStopped:"\u8FD0\u884C\u670D\u52A1\u4E0D\u53EF\u7528",runtimeNotInjected:"\u8FD0\u884C\u670D\u52A1\u5DF2\u542F\u52A8\u2014\u2014\u91CD\u542F Codex \u4EE5\u5E94\u7528\u63D2\u4EF6",plugins:"\u529F\u80FD\u6269\u5C55",restartTitle:"\u91CD\u542F Codex \u4EE5\u5E94\u7528\u66F4\u6539",restartCopy:"\u63D2\u4EF6\u9009\u62E9\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u53EF\u4EE5\u5728\u51C6\u5907\u597D\u540E\u7EDF\u4E00\u91CD\u542F\u3002",restart:"\u91CD\u542F Codex",restarting:"\u6B63\u5728\u91CD\u542F\u2026",saved:"\u5DF2\u4FDD\u5B58",saving:"\u6B63\u5728\u4FDD\u5B58\u2026",states:{saved:"\u5DF2\u4FDD\u5B58\u2014\u2014\u91CD\u542F Codex \u540E\u5E94\u7528",configured:"\u5DF2\u914D\u7F6E\u2014\u2014\u6B63\u5728 Codex \u4E2D\u542F\u52A8\u2026",launching:"\u6B63\u5728 Codex \u4E2D\u542F\u52A8\u2026",injected:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",healthy:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",checking:"\u6B63\u5728\u81EA\u68C0\u2026",partial:"\u90E8\u5206\u7A97\u53E3\u53EF\u7528",degraded:"\u5916\u89C2\u9002\u914D\u9700\u8981\u66F4\u65B0",unavailable:"\u6682\u4E0D\u53EF\u7528\u2014\u2014\u8BF7\u68C0\u67E5\u66F4\u65B0","not-applicable":"\u5F53\u524D\u9875\u9762\u4E0D\u9002\u7528",failed:"\u6682\u65F6\u65E0\u6CD5\u542F\u52A8\u2014\u2014\u8BF7\u91CD\u8BD5",stopped:"\u5DF2\u505C\u6B62","restart-required":"\u9700\u8981\u91CD\u542F\u2014\u2014\u8BF7\u91CD\u542F Codex"},loadError:"\u65E0\u6CD5\u52A0\u8F7D MineCodex",loadErrorCopy:"\u8BF7\u68C0\u67E5\u540E\u53F0\u670D\u52A1\u662F\u5426\u6B63\u5728\u8FD0\u884C\u3002",retry:"\u91CD\u8BD5",version:"\u7248\u672C",darkAppearance:"\u6DF1\u8272\u5916\u89C2",lightAppearance:"\u6D45\u8272\u5916\u89C2",updateFailed:"\u6682\u65F6\u65E0\u6CD5\u68C0\u67E5\u66F4\u65B0\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",copyDiagnostics:"\u590D\u5236\u8BCA\u65AD\u4FE1\u606F",diagnosticsCopied:"\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",diagnosticsFailed:"\u6682\u65F6\u65E0\u6CD5\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\uFF0C\u8BF7\u91CD\u8BD5\u3002",checkUpdates:"\u68C0\u67E5\u66F4\u65B0",checkingUpdates:"\u6B63\u5728\u68C0\u67E5\u2026",current:"\u5F53\u524D\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002",updateAvailable:e=>`\u53D1\u73B0 MineCodex ${e}\uFF0C\u8BF7\u5728\u7EC8\u7AEF\u8FD0\u884C mcx update\u3002`,changeFailed:"\u63D2\u4EF6\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002",restartFailed:"MineCodex \u65E0\u6CD5\u91CD\u542F Codex\u3002\u8BF7\u91CD\u8BD5\u6216\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u534F\u52A9\u6392\u67E5\u3002",failureDetail:"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u8FD9\u9879\u529F\u80FD\u7684\u72B6\u6001\uFF0C\u53EF\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u534F\u52A9\u6392\u67E5\u3002"}}[At],D={runtimeDot:document.querySelector("#runtime-dot"),runtimeLabel:document.querySelector("#runtime-label"),restartNotice:document.querySelector("#restart-notice"),restartTitle:document.querySelector("#restart-title"),restartCopy:document.querySelector("#restart-copy"),restartButton:document.querySelector("#restart-button"),pluginsHeading:document.querySelector("#plugins-heading"),saveState:document.querySelector("#save-state"),pluginList:document.querySelector("#plugin-list"),loadError:document.querySelector("#load-error"),errorTitle:document.querySelector("#error-title"),errorCopy:document.querySelector("#error-copy"),retryButton:document.querySelector("#retry-button"),versionLabel:document.querySelector("#version-label"),versionValue:document.querySelector("#version-value"),languageToggle:document.querySelector(".language-toggle"),languageButtons:[...document.querySelectorAll("[data-language-choice]")],themeToggle:document.querySelector(".theme-toggle"),themeButtons:[...document.querySelectorAll("[data-theme-choice]")],updateResult:document.querySelector("#update-result"),updateButton:document.querySelector("#update-button"),diagnosticsButton:document.querySelector("#diagnostics-button"),toast:document.querySelector("#toast")},ze=null,Y$=null,at=new Set;D.pluginList.addEventListener("change",async e=>{let t=e.target.closest('input[type="checkbox"]'),n=t?.closest("[data-feature-id]");if(!t||!n||!ze)return;let o=n.dataset.featureId,r={...ze.features.find(a=>a.id===o)},i=TT(o);at.add(o),Zv(o,{enabled:t.checked,state:"saved"}),Ud(n,ze.features.find(a=>a.id===o)),D.saveState.textContent=Y.saving;try{let a=await sn(`/api/features/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json","Accept-Language":At},body:JSON.stringify({enabled:t.checked})});if(!a.ok)throw new Error(`HTTP ${a.status}`);let s=await a.json(),l=s.features?.find(d=>d.id===o);l&&Zv(o,l),ze.pendingRestart=s.pendingRestart,at.delete(o);let c=l??ze.features.find(d=>d.id===o);c&&Ud(n,c),ez(),X$(i),D.saveState.textContent=at.size?Y.saving:Y.saved}catch{at.delete(o),Zv(o,r),Ud(n,r),D.saveState.textContent=at.size?Y.saving:"",X$(i),Dd(Y.changeFailed)}});D.restartButton.addEventListener("click",async()=>{D.restartButton.disabled=!0,D.restartButton.querySelector(".button-label").textContent=Y.restarting;try{let e=await sn("/api/restart",{method:"POST",headers:{"Content-Type":"application/json","Accept-Language":At},body:"{}"});if(!e.ok)throw new Error(`HTTP ${e.status}`);await Md()}catch{Dd(Y.restartFailed)}finally{D.restartButton.disabled=!1,D.restartButton.querySelector(".button-label").textContent=Y.restart}});D.retryButton.addEventListener("click",()=>{D.pluginList.hidden=!1,Md()});D.diagnosticsButton.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(JSON.stringify(G$(ze),null,2)),Dd(Y.diagnosticsCopied)}catch{Dd(Y.diagnosticsFailed)}});setInterval(()=>{!document.hidden&&!at.size&&Md()},5e3);D.updateButton.addEventListener("click",async()=>{D.updateButton.disabled=!0,D.updateButton.querySelector(".button-label").textContent=Y.checkingUpdates,D.updateResult.hidden=!0;try{let e=await sn("/api/update");if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();D.updateResult.textContent=t.available?Y.updateAvailable(t.latest):Y.current,D.updateResult.hidden=!1}catch{D.updateResult.textContent=Y.updateFailed,D.updateResult.hidden=!1}finally{D.updateButton.disabled=!1,D.updateButton.querySelector(".button-label").textContent=Y.checkUpdates}});tz=matchMedia("(prefers-color-scheme: dark)"),Tc=null;try{Tc=localStorage.getItem("minecodex-appearance")}catch{}D.themeToggle.addEventListener("click",e=>{let t=e.target.closest("[data-theme-choice]");if(t){Tc=t.dataset.themeChoice;try{localStorage.setItem("minecodex-appearance",Tc)}catch{}qd()}});D.languageToggle.addEventListener("click",e=>{let t=e.target.closest("[data-language-choice]");if(!t||at.size||D.restartButton.disabled)return;let n=t.dataset.languageChoice;if(n!==At){try{localStorage.setItem("minecodex-language",n)}catch{return}location.reload()}});tz.addEventListener("change",qd);window.addEventListener("minecodex-host-theme",qd);document.addEventListener("keydown",()=>{document.documentElement.dataset.input="keyboard"});document.addEventListener("pointerdown",()=>{document.documentElement.dataset.input="pointer"});kT();qd();Md()});function nz(e){let t="data-minecodex-tooltip",n=document.createElement("div");n.id="minecodex-feature-tooltip",n.setAttribute("role","tooltip"),n.hidden=!0;let o=document.createElement("style");o.setAttribute("data-minecodex-ui-styles","tooltip"),o.textContent=`
2
2
  [data-mcx-ui-tooltip] { position:fixed;z-index:2147483001;pointer-events:none;box-sizing:border-box;
3
3
  padding:calc(var(--mcx-spacing) * 1.25) calc(var(--mcx-spacing) * 3);border:1px solid var(--mcx-color-border-tooltip);border-radius:var(--mcx-radius-2xl);corner-shape:var(--mcx-codex-corner-shape);
4
4
  background:var(--mcx-color-background-tooltip);color:var(--mcx-color-text-tooltip);box-shadow:var(--mcx-shadow-tooltip);
@@ -104,7 +104,7 @@ Boolean requesting whether a visible border and background is provided by the ho
104
104
  - omitted: host decides border`)}),zj=m.object({method:m.literal("ui/request-display-mode"),params:m.object({mode:Pc.describe("The display mode being requested.")})}),ST=m.object({mode:Pc.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),_T=m.union([m.literal("model"),m.literal("app")]).describe("Tool visibility scope - who can access the tool."),wj=m.object({resourceUri:m.string().optional(),visibility:m.array(_T).optional().describe(`Who can access this tool. Default: ["model", "app"]
105
105
  - "model": Tool visible to and callable by the agent
106
106
  - "app": Tool callable by the app from this server only`),csp:m.never().optional(),permissions:m.never().optional()}),kj=m.object({mimeTypes:m.array(m.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),xj=m.object({method:m.literal("ui/download-file"),params:m.object({contents:m.array(m.union([en,tn])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Ij=m.object({method:m.literal("ui/message"),params:m.object({role:m.literal("user").describe('Message role, currently only "user" is supported.'),content:m.array(_t).describe("Message content blocks (text, image, etc.).")})}),Rj=m.object({method:m.literal("ui/notifications/sandbox-resource-ready"),params:m.object({html:m.string().describe("HTML content to load into the inner iframe."),sandbox:m.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:qv.optional().describe("CSP configuration from resource metadata."),permissions:Lv.optional().describe("Sandbox permissions from resource metadata.")})}),bT=m.object({method:m.literal("ui/notifications/tool-result"),params:cr.describe("Standard MCP tool execution result.")}),K$=m.object({toolInfo:m.object({id:ot.optional().describe("JSON-RPC id of the tools/call request."),tool:sr.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:nT.optional().describe("Current color theme preference."),styles:pT.optional().describe("Style configuration for theming the app."),displayMode:Pc.optional().describe("How the UI is currently displayed."),availableDisplayModes:m.array(Pc).optional().describe("Display modes the host supports."),containerDimensions:m.union([m.object({height:m.number().describe("Fixed container height in pixels.")}),m.object({maxHeight:m.union([m.number(),m.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(m.union([m.object({width:m.number().describe("Fixed container width in pixels.")}),m.object({maxWidth:m.union([m.number(),m.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
107
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:m.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:m.string().optional().describe("User's timezone in IANA format."),userAgent:m.string().optional().describe("Host application identifier."),platform:m.union([m.literal("web"),m.literal("desktop"),m.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:m.object({touch:m.boolean().optional().describe("Whether the device supports touch input."),hover:m.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:m.object({top:m.number().describe("Top safe area inset in pixels."),right:m.number().describe("Right safe area inset in pixels."),bottom:m.number().describe("Bottom safe area inset in pixels."),left:m.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),yT=m.object({method:m.literal("ui/notifications/host-context-changed"),params:K$.describe("Partial context update containing only changed fields.")}),Pj=m.object({method:m.literal("ui/update-model-context"),params:m.object({content:m.array(_t).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:m.record(m.string(),m.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Tj=m.object({method:m.literal("ui/initialize"),params:m.object({appInfo:vt.describe("App identification (name and version)."),appCapabilities:vT.describe("Features and capabilities this app provides."),protocolVersion:m.string().describe("Protocol version this app supports.")})}),$T=m.object({protocolVersion:m.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:vt.describe("Host application identification and version."),hostCapabilities:gT.describe("Features and capabilities provided by the host."),hostContext:K$.describe("Rich context about the host environment.")}).passthrough(),zT={target:"draft-2020-12"};async function J$(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](zT);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 B$(e,t,n=""){let o=await e["~standard"].validate(t);if(o.issues){let r=o.issues.map(i=>{let a=i.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(n+r)}return o.value}function wT(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Ad=class e extends Av{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Uv;_methods=new Dv;setRequestHandler=(...t)=>{let[n,...o]=F$("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...o)};setNotificationHandler=(...t)=>{let[n,...o]=F$("notification",t)??t;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...o)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...n)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...n)};_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() 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(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:lT,toolinputpartial:uT,toolresult:bT,toolcancelled:dT,hostcontextchanged:yT};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(t,n){n&&this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.setHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.addEventListener(t,n)}removeEventListener(t,n){this._events.removeEventListener(t,n)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let n=this.eventSchemas[t];if(!n)throw Error(`Unknown event: ${String(t)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},o=>{let r=o;t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r}),this._events.dispatch(t,r)}),this._registeredEvents.add(t)}getEventHandler(t){return this._events.getHandler(t)}warnIfRequestHandlerReplaced(t,n,o){n&&o&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,n={},o={autoResize:!0}){super(o),this._appInfo=t,this._appCapabilities=n,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval&&m.config({jitless:!0}),this.replaceRequestHandler("ping",r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(t){return t}registerAppCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=wT(this._appCapabilities,t)}registerTool(t,n,o){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=n.inputSchema!==void 0,s={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(l){Object.assign(this,l),i()},remove(){r._registeredTools[t]===s&&(delete r._registeredTools[t],i())},handler:async(l,c)=>{if(!s.enabled)throw Error(`Tool ${t} is disabled`);let d;if(a){let p=s.inputSchema,h=p?await B$(p,l??{},`Invalid input for tool ${t}: `):l??{};d=await o(h,c)}else d=await o(c);return s.outputSchema&&!d.isError&&(d.structuredContent=await B$(s.outputSchema,d.structuredContent,`Invalid output for tool ${t}: `)),d}};return this._registeredTools[t]=s,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let o=this._registeredTools[t.name];if(!o)throw Error(`Tool ${t.name} not found`);return o.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let i={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await J$(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(i.outputSchema=await J$(r.outputSchema,"output")),r.annotations&&(i.annotations=r.annotations),r._meta&&(i._meta=r._meta),i}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler("ui/resource-teardown",{params:fT.shape.params,result:hT},(n,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",(n,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler("tools/list",(n,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,o)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;default:return}}assertNotificationCapability(t){}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},n)}async createSamplingMessage(t,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:t},n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},cT,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},ar,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},aT,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},sT,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},ST,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,o=0,r=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let l=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let c=Math.ceil(window.innerWidth);(c!==n||l!==o)&&(n=c,o=l,this.sendSizeChanged({width:c,height:l}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(t=new Mv(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(t);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:tT}},$T,n);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}};var Oc=new Ad({name:"MineCodex",version:"0.1.0"});Oc.ontoolresult=()=>{};await Oc.connect();window.minecodexMcpApp=Oc;function hz(e){Object.hasOwn(e??{},"theme")&&(window.minecodexHostTheme=e?.theme,window.dispatchEvent(new Event("minecodex-host-theme")))}Oc.addEventListener("hostcontextchanged",hz);hz(Oc.getHostContext());await Promise.resolve().then(()=>(rz(),ET));await Promise.resolve().then(()=>(sz(),UT));await Promise.resolve().then(()=>(fz(),DT));
107
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:m.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:m.string().optional().describe("User's timezone in IANA format."),userAgent:m.string().optional().describe("Host application identifier."),platform:m.union([m.literal("web"),m.literal("desktop"),m.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:m.object({touch:m.boolean().optional().describe("Whether the device supports touch input."),hover:m.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:m.object({top:m.number().describe("Top safe area inset in pixels."),right:m.number().describe("Right safe area inset in pixels."),bottom:m.number().describe("Bottom safe area inset in pixels."),left:m.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),yT=m.object({method:m.literal("ui/notifications/host-context-changed"),params:K$.describe("Partial context update containing only changed fields.")}),Pj=m.object({method:m.literal("ui/update-model-context"),params:m.object({content:m.array(_t).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:m.record(m.string(),m.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Tj=m.object({method:m.literal("ui/initialize"),params:m.object({appInfo:vt.describe("App identification (name and version)."),appCapabilities:vT.describe("Features and capabilities this app provides."),protocolVersion:m.string().describe("Protocol version this app supports.")})}),$T=m.object({protocolVersion:m.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:vt.describe("Host application identification and version."),hostCapabilities:gT.describe("Features and capabilities provided by the host."),hostContext:K$.describe("Rich context about the host environment.")}).passthrough(),zT={target:"draft-2020-12"};async function J$(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](zT);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 B$(e,t,n=""){let o=await e["~standard"].validate(t);if(o.issues){let r=o.issues.map(i=>{let a=i.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(n+r)}return o.value}function wT(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Ad=class e extends Av{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Uv;_methods=new Dv;setRequestHandler=(...t)=>{let[n,...o]=F$("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...o)};setNotificationHandler=(...t)=>{let[n,...o]=F$("notification",t)??t;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...o)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...n)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...n)};_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() 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(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:lT,toolinputpartial:uT,toolresult:bT,toolcancelled:dT,hostcontextchanged:yT};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(t,n){n&&this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.setHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.addEventListener(t,n)}removeEventListener(t,n){this._events.removeEventListener(t,n)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let n=this.eventSchemas[t];if(!n)throw Error(`Unknown event: ${String(t)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},o=>{let r=o;t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r}),this._events.dispatch(t,r)}),this._registeredEvents.add(t)}getEventHandler(t){return this._events.getHandler(t)}warnIfRequestHandlerReplaced(t,n,o){n&&o&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,n={},o={autoResize:!0}){super(o),this._appInfo=t,this._appCapabilities=n,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval&&m.config({jitless:!0}),this.replaceRequestHandler("ping",r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(t){return t}registerAppCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=wT(this._appCapabilities,t)}registerTool(t,n,o){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=n.inputSchema!==void 0,s={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(l){Object.assign(this,l),i()},remove(){r._registeredTools[t]===s&&(delete r._registeredTools[t],i())},handler:async(l,c)=>{if(!s.enabled)throw Error(`Tool ${t} is disabled`);let d;if(a){let p=s.inputSchema,h=p?await B$(p,l??{},`Invalid input for tool ${t}: `):l??{};d=await o(h,c)}else d=await o(c);return s.outputSchema&&!d.isError&&(d.structuredContent=await B$(s.outputSchema,d.structuredContent,`Invalid output for tool ${t}: `)),d}};return this._registeredTools[t]=s,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let o=this._registeredTools[t.name];if(!o)throw Error(`Tool ${t.name} not found`);return o.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let i={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await J$(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(i.outputSchema=await J$(r.outputSchema,"output")),r.annotations&&(i.annotations=r.annotations),r._meta&&(i._meta=r._meta),i}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler("ui/resource-teardown",{params:fT.shape.params,result:hT},(n,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",(n,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler("tools/list",(n,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,o)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;default:return}}assertNotificationCapability(t){}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},n)}async createSamplingMessage(t,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:t},n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},cT,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},ar,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},aT,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},sT,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},ST,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,o=0,r=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let l=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let c=Math.ceil(window.innerWidth);(c!==n||l!==o)&&(n=c,o=l,this.sendSizeChanged({width:c,height:l}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(t=new Mv(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(t);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:tT}},$T,n);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}};var Oc=new Ad({name:"MineCodex",version:"2.0.18"});Oc.ontoolresult=()=>{};await Oc.connect();window.minecodexMcpApp=Oc;function hz(e){Object.hasOwn(e??{},"theme")&&(window.minecodexHostTheme=e?.theme,window.dispatchEvent(new Event("minecodex-host-theme")))}Oc.addEventListener("hostcontextchanged",hz);hz(Oc.getHostContext());await Promise.resolve().then(()=>(rz(),ET));await Promise.resolve().then(()=>(sz(),UT));await Promise.resolve().then(()=>(fz(),DT));
108
108
  /*! Bundled license information:
109
109
 
110
110
  @modelcontextprotocol/client/dist/src-WCy6ifGf.mjs:
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "minecodex",
3
- "version": "0.1.0",
4
3
  "description": "Manage local MineCodex enhancements without changing their runtime.",
5
4
  "author": { "name": "Vontean" },
6
5
  "mcpServers": "./.mcp.json",
@@ -1,6 +1,6 @@
1
1
  import { App } from "@modelcontextprotocol/ext-apps";
2
2
 
3
- const app = new App({ name: "MineCodex", version: "0.1.0" });
3
+ const app = new App({ name: "MineCodex", version: __MCX_RELEASE_VERSION__ });
4
4
  app.ontoolresult = () => {};
5
5
  await app.connect();
6
6
  window.minecodexMcpApp = app;
@@ -2,6 +2,7 @@ import { mkdir, readFile, writeFile, copyFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { execFile } from "node:child_process";
4
4
  import { promisify } from "node:util";
5
+ import { RELEASE_VERSION } from "./version.mjs";
5
6
  const execute = promisify(execFile);
6
7
 
7
8
  export async function installPlugin({ paths, execFileImpl = execute, codex = "codex", node = process.execPath }) {
@@ -11,6 +12,7 @@ export async function installPlugin({ paths, execFileImpl = execute, codex = "co
11
12
  await mkdir(path.join(plugin, "assets"), { recursive: true });
12
13
  await mkdir(path.join(root, ".agents/plugins"), { recursive: true });
13
14
  const manifest = JSON.parse(await readFile(path.join(paths.packageRoot, "packages/plugin/plugin.json"), "utf8"));
15
+ manifest.version = RELEASE_VERSION;
14
16
  await writeFile(path.join(plugin, ".codex-plugin/plugin.json"), JSON.stringify(manifest, null, 2) + "\n");
15
17
  await copyFile(path.join(paths.packageRoot, "assets/brand/minecodex-icon.svg"), path.join(plugin, "assets/icon.svg"));
16
18
  await writeFile(path.join(plugin, ".mcp.json"), JSON.stringify({ mcpServers: { minecodex: {
@@ -9,12 +9,13 @@ import { resolvePaths } from "../../cli/src/paths.mjs";
9
9
  import { createControlClient } from "./control-client.mjs";
10
10
  import { createPromptsClient } from "./prompts-client.mjs";
11
11
  import { createAppHtml, createPromptsHtml } from "./ui-resource.mjs";
12
+ import { RELEASE_VERSION, CONTROL_RESOURCE_URI } from "./version.mjs";
12
13
 
13
- export const APP_URI = "ui://minecodex/control-panel.html";
14
+ export const APP_URI = CONTROL_RESOURCE_URI;
14
15
  export const PROMPTS_URI = "ui://minecodex/prompts.html";
15
16
  export function createPluginServer({ promptsClient, paths = resolvePaths(), client = createControlClient({ paths, port: Number(process.env.MINECODEX_CONTROL_PORT ?? 47830) }) } = {}) {
16
17
  const icons = [{ src: `data:image/svg+xml;base64,${readFileSync(path.join(paths.packageRoot, "assets/brand/minecodex-icon.svg")).toString("base64")}`, mimeType: "image/svg+xml" }];
17
- const server = new McpServer({ name: "minecodex", version: "0.1.0", icons });
18
+ const server = new McpServer({ name: "minecodex", version: RELEASE_VERSION, icons });
18
19
  const promptIcons = [{src:`data:image/svg+xml;base64,${readFileSync(path.join(paths.packageRoot,"features/notes/assets/icons/prompt-entry.svg")).toString("base64")}`,mimeType:"image/svg+xml",sizes:["20x20"]}];
19
20
  const tools = [];
20
21
  // 使用公开 tools/list 协议补齐 SDK 高层注册尚未转发的工具图标。
@@ -61,11 +62,19 @@ export function createPluginServer({ promptsClient, paths = resolvePaths(), clie
61
62
  _meta:{ui:{csp:{connectDomains:[],resourceDomains:["data:","blob:"]}}},
62
63
  }]}));
63
64
  let html;
64
- registerAppResource(server, "control-panel", APP_URI, {}, async () => ({ contents: [{
65
- uri: APP_URI, mimeType: RESOURCE_MIME_TYPE, text: html ??= await createAppHtml(paths.packageRoot),
65
+ const controlResource = async uri => ({ contents: [{
66
+ uri, mimeType: RESOURCE_MIME_TYPE, text: html ??= await createAppHtml(paths.packageRoot),
66
67
  _meta: { ui: { csp: { connectDomains: [], resourceDomains: ["data:", "blob:"] } } },
67
- }] }));
68
+ }] });
69
+ registerAppResource(server, "control-panel", APP_URI, {}, () => controlResource(APP_URI));
70
+ // 已打开的 Codex 入口仍可能保存旧 URI;通知重新发现,期间共用当前资源。
71
+ const previousUri = "ui://minecodex/control-panel.html";
72
+ registerAppResource(server, "control-panel-upgrade", previousUri, {}, async () => {
73
+ server.sendToolListChanged();
74
+ return controlResource(previousUri);
75
+ });
68
76
  server.server.setRequestHandler(ListToolsRequestSchema, async () => ({tools}));
77
+ server.server.oninitialized = () => server.sendToolListChanged();
69
78
  return server;
70
79
  }
71
80
  export async function servePlugin(options) {
@@ -11,8 +11,9 @@ export async function createAppHtml(packageRoot) {
11
11
  }
12
12
  const script = await readFile(path.join(packageRoot, "packages/plugin/assets/app.js"), "utf8");
13
13
  html = html.replace(/\s*<link[^>]+>/g, "").replace(/\s*<script[\s\S]*?<\/script>/g, "");
14
- return html.replace("</head>", `<style>${css}</style></head>`)
15
- .replace("</body>", `<script type="module">${script.replaceAll("</script", "<\\/script")}</script></body>`);
14
+ // 回调保留资源中的 $&、$` 等字面量,避免被 replace 当成替换指令。
15
+ return html.replace("</head>", () => `<style>${css}</style></head>`)
16
+ .replace("</body>", () => `<script type="module">${script.replaceAll("</script", "<\\/script")}</script></body>`);
16
17
  }
17
18
 
18
19
  export async function createPromptsHtml(packageRoot) {
@@ -0,0 +1,6 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ export const RELEASE_VERSION = JSON.parse(readFileSync(new URL("../../../package.json", import.meta.url), "utf8")).version;
4
+
5
+ // Codex 保留 App 沙箱;发布时改变资源身份,不能只替换同一 URI 的 HTML。
6
+ export const CONTROL_RESOURCE_URI = `ui://minecodex/${RELEASE_VERSION}/control-panel.html`;