minecodex 2.0.18 → 2.0.20

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.
@@ -381,7 +381,7 @@ ${U.body}`.toLocaleLowerCase().includes(y)));if(!k.length){g.append(jn(!!y));ret
381
381
  [data-minecodex-quick-prompts=panel] .qp-title { max-width:55%; flex-shrink:0; }
382
382
  .qp-image-preview { position:fixed; visibility:hidden; padding:0; overflow:hidden; border-radius:var(--mcx-radius-2xl); transform-origin:left center; }
383
383
  .qp-image-preview img { display:block; width:100%; height:100%; object-fit:contain; }
384
- `;function uv(e){let t=document.documentElement;t.dataset.theme=e.theme??t.dataset.theme??"light",t.style.colorScheme=t.dataset.theme;for(let[o,r]of Object.entries(e.styles?.variables??{}))t.style.setProperty(o,r);let i={"color-surface":"--color-background-primary","color-surface-elevated-secondary":"--color-background-secondary","color-text-primary":"--color-text-primary","color-text-secondary":"--color-text-secondary","color-text-tertiary":"--color-text-tertiary","color-border":"--color-border-primary","color-border-subtle":"--color-border-secondary","color-border-primary-outline":"--color-border-primary","color-background-primary-ghost-hover":"--color-background-tertiary","color-background-primary-outline-hover":"--color-background-tertiary","color-background-primary-solid":"--color-text-primary","color-text-primary-solid":"--color-background-primary","color-background-primary-solid-hover":"--color-text-secondary","color-ring":"--color-border-info","color-text-danger":"--color-text-danger","font-sans-default":"--font-sans","text-sm":"--font-text-sm-size","text-base":"--font-text-md-size","text-xs":"--font-text-xs-size","text-heading-lg":"--font-heading-lg-size","text-heading-md":"--font-heading-md-size","radius-md":"--border-radius-md","radius-lg":"--border-radius-lg","radius-xl":"--border-radius-xl","radius-full":"--border-radius-full"};for(let[o,r]of Object.entries(i))t.style.setProperty(`--mcx-${o}`,`var(${r})`);e.locale&&(t.lang=e.locale)}function hx(e){let t=document.createElement("style");t.setAttribute("data-minecodex-ui-styles","layers"),t.textContent=`
384
+ `;function uv(e){let t=document.documentElement;t.dataset.theme=e.theme??t.dataset.theme??"light",t.style.colorScheme=t.dataset.theme;for(let[o,r]of Object.entries(e.styles?.variables??{}))t.style.setProperty(o,r);let i={"color-surface":"--color-background-primary","color-surface-elevated-secondary":"--color-background-secondary","color-text-primary":"--color-text-primary","color-text-secondary":"--color-text-secondary","color-text-tertiary":"--color-text-tertiary","color-border":"--color-border-primary","color-border-subtle":"--color-border-secondary","color-border-primary-outline":"--color-border-primary","color-background-primary-ghost-hover":"--color-background-primary-ghost-hover","color-background-primary-outline-hover":"--color-background-primary-ghost-hover","color-background-primary-solid":"--color-text-primary","color-text-primary-solid":"--color-background-primary","color-background-primary-solid-hover":"--color-text-secondary","color-ring":"--color-border-info","color-text-danger":"--color-text-danger","font-sans-default":"--font-sans","text-sm":"--font-text-sm-size","text-base":"--font-text-md-size","text-xs":"--font-text-xs-size","text-heading-lg":"--font-heading-lg-size","text-heading-md":"--font-heading-md-size","radius-md":"--border-radius-md","radius-lg":"--border-radius-lg","radius-xl":"--border-radius-xl","radius-full":"--border-radius-full"};for(let[o,r]of Object.entries(i))t.style.setProperty(`--mcx-${o}`,`var(${r})`);e.locale&&(t.lang=e.locale)}function hx(e){let t=document.createElement("style");t.setAttribute("data-minecodex-ui-styles","layers"),t.textContent=`
385
385
  [data-mcx-ui-layer=page] { position:fixed; z-index:20; }
386
386
  [data-mcx-ui-layer=notification] { position:fixed; z-index:45; }
387
387
  [data-mcx-ui-layer=floating], [data-mcx-ui-layer=modal] { position:fixed; z-index:50; }
@@ -425,7 +425,7 @@ ${U.body}`.toLocaleLowerCase().includes(y)));if(!k.length){g.append(jn(!!y));ret
425
425
  font-family:var(--mcx-font-sans-default);font-size:var(--mcx-text-sm);line-height:18px;
426
426
  font-weight:var(--mcx-tooltip-compact-font-weight);letter-spacing:var(--mcx-tracking-tooltip);user-select:none; }
427
427
  `,document.head.append(o);function r(m){return m.setAttribute("data-mcx-ui-tooltip",""),m}r(i),i.style.cssText=`zoom:var(--codex-window-zoom,1);max-width:min(320px,calc(100vw - 16px));
428
- text-align:center;overflow-wrap:anywhere;`;let n=null,a,s,c=-1/0;function l(){if(clearTimeout(a),cancelAnimationFrame(s),n){let m=(n.getAttribute("aria-describedby")||"").split(/\s+/).filter(A=>A&&A!==i.id);m.length?n.setAttribute("aria-describedby",m.join(" ")):n.removeAttribute("aria-describedby")}i.hidden||(c=Date.now()),n=null,i.hidden=!0}function d(){if(!n?.isConnected||!n.getClientRects().length||n.getAttribute("aria-expanded")==="true")return l();let m=Number.parseFloat(getComputedStyle(i).zoom)||1,A=n.getBoundingClientRect(),x=i.offsetWidth,C=i.offsetHeight,M=n.getAttribute("data-minecodex-tooltip-side")||(n.closest("[data-app-navigation-rail]")?"right":getComputedStyle(n).getPropertyValue("--side-tooltip").trim()||"top"),T=2/m,Q=(A.left+A.width/2)/m-x/2,re=M==="bottom"?A.bottom/m+T:A.top/m-C-T;M==="right"||M==="left"?(Q=M==="right"?A.right/m+T:A.left/m-x-T,re=(A.top+A.height/2)/m-C/2,Q+x>innerWidth/m-8?Q=A.left/m-x-T:Q<8&&(Q=A.right/m+T)):re<8?re=A.bottom/m+T:re+C>innerHeight/m-8&&(re=A.top/m-C-T),i.style.left=`${Math.max(8,Math.min(Q,innerWidth/m-x-8))}px`,i.style.top=`${Math.max(8,Math.min(re,innerHeight/m-C-8))}px`,s=requestAnimationFrame(d)}function f(m,A=!1){!m||m===n||(l(),!(m.getAttribute("aria-expanded")==="true"||!m.getAttribute(t))&&(n=m,a=setTimeout(()=>{if(!n?.isConnected)return l();i.isConnected||document.body.append(i);let x=getComputedStyle(n);for(let M of["--radius-2xl","--codex-corner-shape","--color-background-tooltip","--color-text-tooltip","--color-border-tooltip","--shadow-tooltip","--tooltip-compact-font-weight","--tracking-tooltip","--spacing","--text-sm","--font-sans-default"]){let T=x.getPropertyValue(M).trim();T?i.style.setProperty(M,T):i.style.removeProperty(M)}i.textContent=n.getAttribute(t),i.hidden=!1;let C=(n.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean);n.setAttribute("aria-describedby",[...new Set([...C,i.id])].join(" ")),d()},A||Date.now()-c<300?0:200)))}let h=m=>m.target instanceof Element?m.target.closest(`[${t}]`):null;return document.addEventListener("pointerover",m=>f(h(m)),{signal:e}),document.addEventListener("pointerout",m=>{n&&!n.contains(m.relatedTarget)&&l()},{signal:e}),document.addEventListener("focusin",m=>f(h(m),!0),{signal:e}),document.addEventListener("focusout",l,{signal:e}),document.addEventListener("pointerdown",l,{signal:e,capture:!0}),document.addEventListener("keydown",m=>{m.key==="Escape"&&l()},{signal:e}),window.addEventListener("blur",l,{signal:e}),e.addEventListener("abort",()=>{l(),i.remove(),o.remove()},{once:!0}),{tooltipSurface:r}}var Mo=new vd({name:"Prompt",version:"0.1.0"});Mo.ontoolresult=()=>{};await Mo.connect();uv(Mo.getHostContext());Mo.addEventListener("hostcontextchanged",uv);var bx=new AbortController,Ad=bx.signal,bi={};for(let e of[hx,gx,vx,Ax,yx])Object.assign(bi,e(Ad,bi));bi.page=e=>(bi.surface(e,"page"),bi.layer(e,"page"));bi.releasePage=()=>{};var j_=dx(Ad,{management:!0,ui:bi,resources:{icons:mx,previews:px,styles:fx},insertPrompt:e=>new Promise((t,i)=>{let o=new MessageChannel,r,n=s=>{clearTimeout(r),o.port1.close(),Ad.removeEventListener("abort",a),s?i(s):t()},a=()=>n(new Error("Prompt page closed"));Ad.addEventListener("abort",a,{once:!0}),r=setTimeout(()=>n(new Error("No available input in the focused window")),4500),o.port1.onmessage=({data:s})=>n(s.ok?null:new Error(s.error)),window.top.postMessage({type:"minecodex:insert-prompt",promptId:e,expiresAt:Date.now()+4e3},"*",[o.port2])}),requestHostAction:async(e,t)=>{let i=await Mo.callServerTool({name:t.method&&t.method!=="GET"?"minecodex_prompts_write":"minecodex_prompts_read",arguments:t});if(i.isError)throw new Error(i.content?.find(o=>o.type==="text")?.text??"Prompts request failed");return i.structuredContent.result}});Mo.onteardown=async()=>(bx.abort(),j_(),{});
428
+ text-align:center;overflow-wrap:anywhere;`;let n=null,a,s,c=-1/0;function l(){if(clearTimeout(a),cancelAnimationFrame(s),n){let m=(n.getAttribute("aria-describedby")||"").split(/\s+/).filter(A=>A&&A!==i.id);m.length?n.setAttribute("aria-describedby",m.join(" ")):n.removeAttribute("aria-describedby")}i.hidden||(c=Date.now()),n=null,i.hidden=!0}function d(){if(!n?.isConnected||!n.getClientRects().length||n.getAttribute("aria-expanded")==="true")return l();let m=Number.parseFloat(getComputedStyle(i).zoom)||1,A=n.getBoundingClientRect(),x=i.offsetWidth,C=i.offsetHeight,M=n.getAttribute("data-minecodex-tooltip-side")||(n.closest("[data-app-navigation-rail]")?"right":getComputedStyle(n).getPropertyValue("--side-tooltip").trim()||"top"),T=2/m,Q=(A.left+A.width/2)/m-x/2,re=M==="bottom"?A.bottom/m+T:A.top/m-C-T;M==="right"||M==="left"?(Q=M==="right"?A.right/m+T:A.left/m-x-T,re=(A.top+A.height/2)/m-C/2,Q+x>innerWidth/m-8?Q=A.left/m-x-T:Q<8&&(Q=A.right/m+T)):re<8?re=A.bottom/m+T:re+C>innerHeight/m-8&&(re=A.top/m-C-T),i.style.left=`${Math.max(8,Math.min(Q,innerWidth/m-x-8))}px`,i.style.top=`${Math.max(8,Math.min(re,innerHeight/m-C-8))}px`,s=requestAnimationFrame(d)}function f(m,A=!1){!m||m===n||(l(),!(m.getAttribute("aria-expanded")==="true"||!m.getAttribute(t))&&(n=m,a=setTimeout(()=>{if(!n?.isConnected)return l();i.isConnected||document.body.append(i);let x=getComputedStyle(n);for(let M of["--radius-2xl","--codex-corner-shape","--color-background-tooltip","--color-text-tooltip","--color-border-tooltip","--shadow-tooltip","--tooltip-compact-font-weight","--tracking-tooltip","--spacing","--text-sm","--font-sans-default"]){let T=x.getPropertyValue(M).trim();T?i.style.setProperty(M,T):i.style.removeProperty(M)}i.textContent=n.getAttribute(t),i.hidden=!1;let C=(n.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean);n.setAttribute("aria-describedby",[...new Set([...C,i.id])].join(" ")),d()},A||Date.now()-c<300?0:200)))}let h=m=>m.target instanceof Element?m.target.closest(`[${t}]`):null;return document.addEventListener("pointerover",m=>f(h(m)),{signal:e}),document.addEventListener("pointerout",m=>{n&&!n.contains(m.relatedTarget)&&l()},{signal:e}),document.addEventListener("focusin",m=>f(h(m),!0),{signal:e}),document.addEventListener("focusout",l,{signal:e}),document.addEventListener("pointerdown",l,{signal:e,capture:!0}),document.addEventListener("keydown",m=>{m.key==="Escape"&&l()},{signal:e}),window.addEventListener("blur",l,{signal:e}),e.addEventListener("abort",()=>{l(),i.remove(),o.remove()},{once:!0}),{tooltipSurface:r}}var Mo=new vd({name:"Prompt",version:"2.0.20"});Mo.ontoolresult=()=>{};await Mo.connect();uv(Mo.getHostContext());Mo.addEventListener("hostcontextchanged",uv);var bx=new AbortController,Ad=bx.signal,bi={};for(let e of[hx,gx,vx,Ax,yx])Object.assign(bi,e(Ad,bi));bi.page=e=>(bi.surface(e,"page"),bi.layer(e,"page"));bi.releasePage=()=>{};var j_=dx(Ad,{management:!0,ui:bi,resources:{icons:mx,previews:px,styles:fx},insertPrompt:e=>new Promise((t,i)=>{let o=new MessageChannel,r,n=s=>{clearTimeout(r),o.port1.close(),Ad.removeEventListener("abort",a),s?i(s):t()},a=()=>n(new Error("Prompt page closed"));Ad.addEventListener("abort",a,{once:!0}),r=setTimeout(()=>n(new Error("No available input in the focused window")),4500),o.port1.onmessage=({data:s})=>n(s.ok?null:new Error(s.error)),window.top.postMessage({type:"minecodex:insert-prompt",promptId:e,expiresAt:Date.now()+4e3},"*",[o.port2])}),requestHostAction:async(e,t)=>{let i=await Mo.callServerTool({name:t.method&&t.method!=="GET"?"minecodex_prompts_write":"minecodex_prompts_read",arguments:t});if(i.isError)throw new Error(i.content?.find(o=>o.type==="text")?.text??"Prompts request failed");return i.structuredContent.result}});Mo.onteardown=async()=>(bx.abort(),j_(),{});
429
429
  /*! Bundled license information:
430
430
 
431
431
  @modelcontextprotocol/client/dist/src-WCy6ifGf.mjs:
@@ -10,7 +10,7 @@ import { installDialog } from '../../ui/src/components/dialog.mjs';
10
10
  import { installButton } from '../../ui/src/components/button.mjs';
11
11
  import { installFeatureTooltips } from '../../ui/src/components/tooltip.mjs';
12
12
 
13
- const app = new App({name:'Prompt',version:'0.1.0'});
13
+ const app = new App({name:'Prompt',version:__MCX_RELEASE_VERSION__});
14
14
  app.ontoolresult = () => {};
15
15
  await app.connect();
16
16
  applyMcpTheme(app.getHostContext());
@@ -1,5 +1,5 @@
1
1
  import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
2
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { registerAppResource, registerAppTool as registerSdkAppTool, RESOURCE_MIME_TYPE } from "@modelcontextprotocol/ext-apps/server";
5
5
  import { z } from "zod";
@@ -9,10 +9,10 @@ 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
+ import { RELEASE_VERSION, CONTROL_RESOURCE_URI, PROMPT_RESOURCE_URI } from "./version.mjs";
13
13
 
14
14
  export const APP_URI = CONTROL_RESOURCE_URI;
15
- export const PROMPTS_URI = "ui://minecodex/prompts.html";
15
+ export const PROMPTS_URI = PROMPT_RESOURCE_URI;
16
16
  export function createPluginServer({ promptsClient, paths = resolvePaths(), client = createControlClient({ paths, port: Number(process.env.MINECODEX_CONTROL_PORT ?? 47830) }) } = {}) {
17
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" }];
18
18
  const server = new McpServer({ name: "minecodex", version: RELEASE_VERSION, icons });
@@ -57,10 +57,16 @@ export function createPluginServer({ promptsClient, paths = resolvePaths(), clie
57
57
  return {content:[],structuredContent:{result:await promptsClient.request(route,method,body)}};
58
58
  });
59
59
  let promptsHtml;
60
- registerAppResource(server,"prompts",PROMPTS_URI,{},async()=>({contents:[{
61
- uri:PROMPTS_URI,mimeType:RESOURCE_MIME_TYPE,text:promptsHtml ??= await createPromptsHtml(paths.packageRoot),
60
+ const promptsResource = async uri => ({contents:[{
61
+ uri,mimeType:RESOURCE_MIME_TYPE,text:promptsHtml ??= await createPromptsHtml(paths.packageRoot),
62
62
  _meta:{ui:{csp:{connectDomains:[],resourceDomains:["data:","blob:"]}}},
63
- }]}));
63
+ }]});
64
+ registerAppResource(server,"prompts",PROMPTS_URI,{},()=>promptsResource(PROMPTS_URI));
65
+ const previousPromptsUri = "ui://minecodex/prompts.html";
66
+ registerAppResource(server,"prompts-upgrade",previousPromptsUri,{},async()=>{
67
+ server.sendToolListChanged();
68
+ return promptsResource(previousPromptsUri);
69
+ });
64
70
  let html;
65
71
  const controlResource = async uri => ({ contents: [{
66
72
  uri, mimeType: RESOURCE_MIME_TYPE, text: html ??= await createAppHtml(paths.packageRoot),
@@ -73,6 +79,15 @@ export function createPluginServer({ promptsClient, paths = resolvePaths(), clie
73
79
  server.sendToolListChanged();
74
80
  return controlResource(previousUri);
75
81
  });
82
+ // 升级中宿主可能仍请求上版 URI;只提供当前页面并要求重新发现入口。
83
+ for (const [name, read] of [["control-panel", controlResource], ["prompts", promptsResource]]) {
84
+ server.registerResource(`${name}-version-upgrade`, new ResourceTemplate(`ui://minecodex/{release}/${name}.html`, {list:undefined}),
85
+ {mimeType:RESOURCE_MIME_TYPE}, async (uri, {release}) => {
86
+ if (typeof release !== "string" || !/^\d+\.\d+\.\d+$/.test(release)) throw new Error("Invalid release resource");
87
+ server.sendToolListChanged();
88
+ return read(uri.href);
89
+ });
90
+ }
76
91
  server.server.setRequestHandler(ListToolsRequestSchema, async () => ({tools}));
77
92
  server.server.oninitialized = () => server.sendToolListChanged();
78
93
  return server;
@@ -4,3 +4,4 @@ export const RELEASE_VERSION = JSON.parse(readFileSync(new URL("../../../package
4
4
 
5
5
  // Codex 保留 App 沙箱;发布时改变资源身份,不能只替换同一 URI 的 HTML。
6
6
  export const CONTROL_RESOURCE_URI = `ui://minecodex/${RELEASE_VERSION}/control-panel.html`;
7
+ export const PROMPT_RESOURCE_URI = `ui://minecodex/${RELEASE_VERSION}/prompts.html`;
@@ -1,4 +1,6 @@
1
1
  :root { --color-background-primary:light-dark(#fff,#212121); --color-background-secondary:light-dark(#f8f8f8,#303030); --color-background-tertiary:light-dark(#eee,#3c3c3c); --color-text-primary:light-dark(#202020,#eee); --color-text-secondary:light-dark(#626262,#aaa); --color-text-tertiary:light-dark(#777,#999); --color-border-primary:light-dark(#ddd,#555); --color-border-secondary:light-dark(#eee,#444); --color-border-info:#0285ff; --color-text-danger:light-dark(#ba2a2a,#ff6764); --font-sans:system-ui,sans-serif; --font-text-sm-size:13px; --font-text-md-size:14px; --font-text-xs-size:12px; --font-heading-lg-size:28px; --font-heading-md-size:20px; --border-radius-md:8px; --border-radius-lg:10px; --border-radius-xl:15px; --border-radius-full:999px;
2
2
  --mcx-spacing:4px; --mcx-radius-2xl:20px; --mcx-radius-3xl:25px; --mcx-text-sm--line-height:1.43; --mcx-font-weight-semibold:600; --mcx-font-weight-normal:400; --font-weight-medium:500; --mcx-control-size-lg:36px; --mcx-control-font-size-md:13px; --mcx-control-gutter-md:16px; --mcx-control-gutter-pill-scaling:1; --mcx-button-gap-lg:8px; --mcx-modal-container-inner-padding:20px; --mcx-shadow-lg:0 8px 24px #0002; --mcx-shadow-xl-spread:0 12px 36px #0003; --mcx-color-border-overlay:var(--mcx-color-border); --mcx-blur-sm:4px; --mcx-blur-xl:24px; --mcx-color-dialog-overlay:#0002; --mcx-color-background-danger-soft-alpha:color-mix(in oklab,var(--color-text-danger) 12%,transparent); --mcx-color-background-danger-soft-alpha-hover:color-mix(in oklab,var(--color-text-danger) 20%,transparent); --color-background-primary-soft:var(--color-background-secondary); --cursor-interaction:pointer; }
3
+ /* Codex desktop browse Tabs:浅色前景 5%,深色白色 8%;宿主同名变量优先。 */
4
+ :root { --color-background-primary-ghost-hover:light-dark(color-mix(in oklab,var(--color-text-primary) 5%,transparent),#ffffff14); }
3
5
  html,body {margin:0;min-height:100%;height:100%;color:var(--color-text-primary);background:var(--color-background-primary);font-family:var(--font-sans);}
4
6
  button,input,textarea {font:inherit;color:inherit;} button {border:0;background:transparent;padding:0;} .sr-only {position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);}
@@ -8,7 +8,7 @@ export function applyMcpTheme(context) {
8
8
  'color-surface':'--color-background-primary', 'color-surface-elevated-secondary':'--color-background-secondary',
9
9
  'color-text-primary':'--color-text-primary', 'color-text-secondary':'--color-text-secondary', 'color-text-tertiary':'--color-text-tertiary',
10
10
  'color-border':'--color-border-primary', 'color-border-subtle':'--color-border-secondary', 'color-border-primary-outline':'--color-border-primary',
11
- 'color-background-primary-ghost-hover':'--color-background-tertiary', 'color-background-primary-outline-hover':'--color-background-tertiary',
11
+ 'color-background-primary-ghost-hover':'--color-background-primary-ghost-hover', 'color-background-primary-outline-hover':'--color-background-primary-ghost-hover',
12
12
  'color-background-primary-solid':'--color-text-primary', 'color-text-primary-solid':'--color-background-primary',
13
13
  'color-background-primary-solid-hover':'--color-text-secondary', 'color-ring':'--color-border-info', 'color-text-danger':'--color-text-danger',
14
14
  'font-sans-default':'--font-sans', 'text-sm':'--font-text-sm-size', 'text-base':'--font-text-md-size', 'text-xs':'--font-text-xs-size',