minecodex 2.0.20 → 2.0.22
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/features/markdown-reading/src/adapters/codex/reading-runtime.mjs +20 -2
- package/features/markdown-reading/src/adapters/codex/rich-text.mjs +10 -14
- package/features/markdown-reading/src/adapters/codex/table-actions.mjs +5 -5
- package/features/markdown-reading/src/adapters/codex/tables.mjs +12 -14
- package/features/markdown-reading/src/injection-source.mjs +2 -0
- package/features/model-slider/src/frontend/install.mjs +5 -8
- package/package.json +1 -1
- package/packages/plugin/assets/app.js +1 -1
- package/packages/plugin/assets/prompts.js +1 -1
- package/packages/plugin/src/server.mjs +1 -1
|
@@ -6,6 +6,23 @@ import { installMarkdownToc } from './toc.mjs';
|
|
|
6
6
|
import { loadNativeMarkdownTableActions, installMarkdownTableActions } from './table-actions.mjs';
|
|
7
7
|
import { loadNativeMarkdownRichText, installMarkdownRichText } from './rich-text.mjs';
|
|
8
8
|
|
|
9
|
+
// 每个 Preview 共用换行状态,虚拟滚动重挂载的块也读取当前值。
|
|
10
|
+
export function createMarkdownWrapState() {
|
|
11
|
+
let enabled = false;
|
|
12
|
+
const listeners = new Set();
|
|
13
|
+
return {
|
|
14
|
+
get: () => enabled,
|
|
15
|
+
toggle() {
|
|
16
|
+
enabled = !enabled;
|
|
17
|
+
for (const listener of listeners) listener();
|
|
18
|
+
},
|
|
19
|
+
subscribe(listener) {
|
|
20
|
+
listeners.add(listener);
|
|
21
|
+
return () => listeners.delete(listener);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
9
26
|
// 原生能力加载与会话寿命归 Adapter;入口只持有检查结果和释放动作。
|
|
10
27
|
export function createMarkdownReadingRuntime(
|
|
11
28
|
codex,
|
|
@@ -37,6 +54,7 @@ export function createMarkdownReadingRuntime(
|
|
|
37
54
|
}
|
|
38
55
|
function attach({ editor, content, scroller }) {
|
|
39
56
|
const view = content.cmTile?.view;
|
|
57
|
+
const wrapState = createMarkdownWrapState();
|
|
40
58
|
const states = new Map([
|
|
41
59
|
['markdown-reading-layout', 'loading'],
|
|
42
60
|
['markdown-reading-links', 'loading'],
|
|
@@ -71,7 +89,7 @@ export function createMarkdownReadingRuntime(
|
|
|
71
89
|
await stage('markdown-reading-rich-text', 'native-rich-text-unavailable', async () => {
|
|
72
90
|
const rich = await load('loadNativeMarkdownRichText', actions);
|
|
73
91
|
if (!current()) return;
|
|
74
|
-
cleanups.push(capabilities.installMarkdownRichText(view, api, rich, codex));
|
|
92
|
+
cleanups.push(capabilities.installMarkdownRichText(view, api, rich, codex, wrapState));
|
|
75
93
|
report('markdown-reading-rich-text', true);
|
|
76
94
|
});
|
|
77
95
|
}
|
|
@@ -102,7 +120,7 @@ export function createMarkdownReadingRuntime(
|
|
|
102
120
|
const api = await capabilities.loadMarkdownListAPI(view);
|
|
103
121
|
if (!current()) return;
|
|
104
122
|
cleanups.push(capabilities.installMarkdownLists(view, api));
|
|
105
|
-
const tables = capabilities.installMarkdownTables(view, api);
|
|
123
|
+
const tables = capabilities.installMarkdownTables(view, api, wrapState);
|
|
106
124
|
cleanups.push(tables);
|
|
107
125
|
report('markdown-reading-layout', true);
|
|
108
126
|
await Promise.all([installLinks(api), installToc(api, tables)]);
|
|
@@ -38,7 +38,7 @@ export async function loadNativeMarkdownRichText(native) {
|
|
|
38
38
|
return { ...native, CodeSnippet: sharedBinding(codeName), katex };
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export function installMarkdownRichText(view, api, native, codex) {
|
|
41
|
+
export function installMarkdownRichText(view, api, native, codex, wrapState) {
|
|
42
42
|
const { Decoration, StateField, StateEffect, Compartment, WidgetType, Prec } = api;
|
|
43
43
|
const {
|
|
44
44
|
React,
|
|
@@ -55,8 +55,7 @@ export function installMarkdownRichText(view, api, native, codex) {
|
|
|
55
55
|
} = native;
|
|
56
56
|
const h = React.createElement,
|
|
57
57
|
roots = new Set(),
|
|
58
|
-
footnoteReturns = new Map()
|
|
59
|
-
codeStates = new Map();
|
|
58
|
+
footnoteReturns = new Map();
|
|
60
59
|
const withProviders = captureMarkdownProviders(view.dom, codex);
|
|
61
60
|
const mount = (element, tree) => {
|
|
62
61
|
const root = ReactDOM.createRoot(element);
|
|
@@ -64,11 +63,9 @@ export function installMarkdownRichText(view, api, native, codex) {
|
|
|
64
63
|
root.render(withProviders(React, tree));
|
|
65
64
|
return root;
|
|
66
65
|
};
|
|
67
|
-
function Code({ content, language
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
),
|
|
71
|
-
[overflow, setOverflow] = React.useState(false),
|
|
66
|
+
function Code({ content, language }) {
|
|
67
|
+
const wrap = React.useSyncExternalStore(wrapState.subscribe, wrapState.get);
|
|
68
|
+
const [overflow, setOverflow] = React.useState(false),
|
|
72
69
|
ref = React.useRef(null);
|
|
73
70
|
React.useLayoutEffect(() => {
|
|
74
71
|
const element = ref.current?.querySelector('code')?.parentElement;
|
|
@@ -84,7 +81,9 @@ export function installMarkdownRichText(view, api, native, codex) {
|
|
|
84
81
|
check();
|
|
85
82
|
return () => observer.disconnect();
|
|
86
83
|
}, [wrap, content]);
|
|
87
|
-
const label =
|
|
84
|
+
const label = document.documentElement.lang.startsWith('zh')
|
|
85
|
+
? wrap ? '关闭文档换行' : '开启文档换行'
|
|
86
|
+
: wrap ? 'Disable document word wrap' : 'Enable document word wrap';
|
|
88
87
|
return h(
|
|
89
88
|
'div',
|
|
90
89
|
{ ref, className: 'mcx-reading-code-block group/app-widget' },
|
|
@@ -112,10 +111,7 @@ export function installMarkdownRichText(view, api, native, codex) {
|
|
|
112
111
|
color: 'blockAction',
|
|
113
112
|
radius: 'full',
|
|
114
113
|
size: 'inputIcon',
|
|
115
|
-
onClick: () =>
|
|
116
|
-
codeStates.set(id, { source: content, wrap: !wrap });
|
|
117
|
-
setWrap(!wrap);
|
|
118
|
-
},
|
|
114
|
+
onClick: () => wrapState.toggle(),
|
|
119
115
|
},
|
|
120
116
|
h(wrap ? wrapIcons.disable : wrapIcons.enable),
|
|
121
117
|
),
|
|
@@ -159,7 +155,7 @@ export function installMarkdownRichText(view, api, native, codex) {
|
|
|
159
155
|
else if (this.kind === 'code')
|
|
160
156
|
element._mcxRoot = mount(
|
|
161
157
|
element,
|
|
162
|
-
h(Code, { content: this.source, language: this.options.language
|
|
158
|
+
h(Code, { content: this.source, language: this.options.language }),
|
|
163
159
|
);
|
|
164
160
|
else if (this.kind === 'math')
|
|
165
161
|
element.innerHTML = katex.renderToString(this.source, {
|
|
@@ -136,11 +136,11 @@ export function installMarkdownTableActions(view, native, codex, controller) {
|
|
|
136
136
|
const tokens = React.useMemo(() => (open ? lexer(item.source, undefined) : []), [open, item.source]);
|
|
137
137
|
const wrap = chinese
|
|
138
138
|
? item.fit
|
|
139
|
-
? '
|
|
140
|
-
: '
|
|
139
|
+
? '关闭文档换行'
|
|
140
|
+
: '开启文档换行'
|
|
141
141
|
: item.fit
|
|
142
|
-
? '
|
|
143
|
-
: '
|
|
142
|
+
? 'Disable document word wrap'
|
|
143
|
+
: 'Enable document word wrap';
|
|
144
144
|
const copy = chinese ? '复制表格' : 'Copy table';
|
|
145
145
|
const expand = chinese ? '展开表格' : 'Expand table';
|
|
146
146
|
const preview = chinese ? '表格预览' : 'Table preview';
|
|
@@ -186,7 +186,7 @@ export function installMarkdownTableActions(view, native, codex, controller) {
|
|
|
186
186
|
color: 'blockAction',
|
|
187
187
|
radius: 'full',
|
|
188
188
|
size: 'inputIcon',
|
|
189
|
-
onClick: () => controller.toggle(
|
|
189
|
+
onClick: () => controller.toggle(),
|
|
190
190
|
},
|
|
191
191
|
h(item.fit ? wrapIcons.disable : wrapIcons.enable),
|
|
192
192
|
),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// 保留原生逐行表格及选区;每张表的行共享横向位置,不移动正文节点。
|
|
2
|
-
export function installMarkdownTables(view, api) {
|
|
2
|
+
export function installMarkdownTables(view, api, wrapState) {
|
|
3
3
|
const { Decoration, ViewPlugin, StateEffect, Compartment, WidgetType } = api;
|
|
4
4
|
class EmptyCell extends WidgetType {
|
|
5
5
|
eq() {
|
|
@@ -82,7 +82,6 @@ export function installMarkdownTables(view, api) {
|
|
|
82
82
|
view.dom.append(layoutStyle);
|
|
83
83
|
let measuredDoc = null;
|
|
84
84
|
const tables = new Map();
|
|
85
|
-
const fitted = new Set();
|
|
86
85
|
let hovered = null;
|
|
87
86
|
function inline(state, node, target) {
|
|
88
87
|
let cursor = node.from;
|
|
@@ -155,9 +154,9 @@ export function installMarkdownTables(view, api) {
|
|
|
155
154
|
const inset = (scroller.clientWidth - available) / 2;
|
|
156
155
|
const breakout = Math.max(0, parseFloat(padding.paddingLeft) - inset);
|
|
157
156
|
for (const [id, table] of tables) {
|
|
158
|
-
table.style.inlineSize =
|
|
157
|
+
table.style.inlineSize = wrapState.get() ? '100%' : 'max-content';
|
|
159
158
|
for (const cell of table.querySelectorAll('td,th'))
|
|
160
|
-
cell.style.overflowWrap =
|
|
159
|
+
cell.style.overflowWrap = wrapState.get() ? 'anywhere' : 'break-word';
|
|
161
160
|
}
|
|
162
161
|
const widths = new Map(
|
|
163
162
|
[...tables].map(([id, table]) => [
|
|
@@ -173,7 +172,7 @@ export function installMarkdownTables(view, api) {
|
|
|
173
172
|
);
|
|
174
173
|
columns.forEach((width, index) =>
|
|
175
174
|
rules.push(
|
|
176
|
-
`${selector} > .cm-markdown-table-cell:nth-child(${index + 1} of .cm-markdown-table-cell){width:${width}px;overflow-wrap:${
|
|
175
|
+
`${selector} > .cm-markdown-table-cell:nth-child(${index + 1} of .cm-markdown-table-cell){width:${width}px;overflow-wrap:${wrapState.get() ? 'anywhere' : 'break-word'}}`,
|
|
177
176
|
),
|
|
178
177
|
);
|
|
179
178
|
}
|
|
@@ -322,7 +321,7 @@ export function installMarkdownTables(view, api) {
|
|
|
322
321
|
const headerInset = parseFloat(getComputedStyle(rows[0]).paddingTop);
|
|
323
322
|
items.push({
|
|
324
323
|
id,
|
|
325
|
-
fit:
|
|
324
|
+
fit: wrapState.get(),
|
|
326
325
|
overflow: (scrollLimits.get(id) ?? 0) > 0,
|
|
327
326
|
visible: hovered === id,
|
|
328
327
|
left: (first.left - frameRect.left) / scale,
|
|
@@ -435,7 +434,6 @@ export function installMarkdownTables(view, api) {
|
|
|
435
434
|
update(update) {
|
|
436
435
|
if (update.docChanged) {
|
|
437
436
|
offsets.clear();
|
|
438
|
-
fitted.clear();
|
|
439
437
|
geometryRows = [];
|
|
440
438
|
}
|
|
441
439
|
if (update.docChanged || update.startState.tree !== update.state.tree) measuredDoc = null;
|
|
@@ -456,16 +454,16 @@ export function installMarkdownTables(view, api) {
|
|
|
456
454
|
const controller = {
|
|
457
455
|
schedule,
|
|
458
456
|
renderActions: null,
|
|
459
|
-
toggle(
|
|
460
|
-
if (fitted.has(id)) fitted.delete(id);
|
|
461
|
-
else fitted.add(id);
|
|
462
|
-
offsets.delete(id);
|
|
463
|
-
schedule();
|
|
464
|
-
view.requestMeasure();
|
|
465
|
-
},
|
|
457
|
+
toggle: () => wrapState.toggle(),
|
|
466
458
|
};
|
|
459
|
+
const unsubscribeWrap = wrapState.subscribe(() => {
|
|
460
|
+
offsets.clear();
|
|
461
|
+
schedule();
|
|
462
|
+
view.requestMeasure();
|
|
463
|
+
});
|
|
467
464
|
schedule();
|
|
468
465
|
const dispose = () => {
|
|
466
|
+
unsubscribeWrap();
|
|
469
467
|
view.dom.removeEventListener('pointerover', onHover);
|
|
470
468
|
view.dom.removeEventListener('pointerout', onHover);
|
|
471
469
|
view.dom.removeEventListener('focusin', schedule);
|
|
@@ -3,6 +3,7 @@ import { collectMarkdownFootnotes } from './domain/footnotes.mjs';
|
|
|
3
3
|
import { captureMarkdownProviders } from './adapters/codex/providers.mjs';
|
|
4
4
|
import {
|
|
5
5
|
createMarkdownReadingRuntime,
|
|
6
|
+
createMarkdownWrapState,
|
|
6
7
|
installMarkdownMetadataScroll,
|
|
7
8
|
} from './adapters/codex/reading-runtime.mjs';
|
|
8
9
|
import { loadNativeMarkdownRichText, installMarkdownRichText } from './adapters/codex/rich-text.mjs';
|
|
@@ -23,6 +24,7 @@ export async function createPageScriptSource() {
|
|
|
23
24
|
collectMarkdownFootnotes,
|
|
24
25
|
captureMarkdownProviders,
|
|
25
26
|
createMarkdownReadingRuntime,
|
|
27
|
+
createMarkdownWrapState,
|
|
26
28
|
createMarkdownPreviewAdapter,
|
|
27
29
|
installMarkdownMetadataScroll,
|
|
28
30
|
loadMarkdownListAPI,
|
|
@@ -1331,18 +1331,14 @@ export function installModelSlider(signal, { feature, ui, createIcon, requestRef
|
|
|
1331
1331
|
particles.setAttribute("aria-hidden", "true");
|
|
1332
1332
|
particles.setAttribute("data-animation-active", "true");
|
|
1333
1333
|
const travelDuration = 1.9;
|
|
1334
|
-
const stagger = travelDuration / 14;
|
|
1335
1334
|
const valueMax = Number(rail.getAttribute("aria-valuemax") ?? 0);
|
|
1336
1335
|
const valueNow = Number(rail.getAttribute("aria-valuenow") ?? 0);
|
|
1337
|
-
const initialStartPercent = valueMax > 0 ? (valueNow / valueMax) * 100 : 0;
|
|
1338
|
-
const remainingTravel = 1 - Math.min(Math.max(initialStartPercent, 0), 100) / 100;
|
|
1339
1336
|
particles.append(...Array.from({ length: 14 }, (_, index) => {
|
|
1340
|
-
const speed = 1 + (nativeParticleSeed(index, 21) - 0.5) * 0.4;
|
|
1341
|
-
const duration = travelDuration / speed;
|
|
1342
1337
|
const path = document.createElement("span");
|
|
1343
1338
|
path.className = pathClass;
|
|
1344
|
-
|
|
1345
|
-
path.style.
|
|
1339
|
+
// 等速、等间距铺满完整路径;档位只裁剪可见范围,不压缩运动或聚集粒子。
|
|
1340
|
+
path.style.animationDelay = `${-((index + 0.5) / 14) * travelDuration}s`;
|
|
1341
|
+
path.style.animationDuration = `${travelDuration}s`;
|
|
1346
1342
|
path.style.top = `${12 + nativeParticleSeed(index, 23) * 76}%`;
|
|
1347
1343
|
const particle = document.createElement("span");
|
|
1348
1344
|
particle.className = particleClass;
|
|
@@ -1354,6 +1350,8 @@ export function installModelSlider(signal, { feature, ui, createIcon, requestRef
|
|
|
1354
1350
|
clip.append(particles);
|
|
1355
1351
|
const tickRail = Array.from(track.children).find((element) => String(element.className).includes("_TickRail_"));
|
|
1356
1352
|
track.insertBefore(clip, tickRail ?? null);
|
|
1353
|
+
// 重建粒子层后按当前档位恢复裁剪,避免重开面板时覆盖整条滑轨。
|
|
1354
|
+
setGenericSliderVisual(rail, valueNow, valueMax + 1);
|
|
1357
1355
|
if (entering) {
|
|
1358
1356
|
// 首帧沿用关闭 Fast 时的星点,再渐显流动粒子。
|
|
1359
1357
|
clip.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 240, easing: "ease-out" });
|
|
@@ -1381,7 +1379,6 @@ export function installModelSlider(signal, { feature, ui, createIcon, requestRef
|
|
|
1381
1379
|
rail.setAttribute("data-fast-mode", String(enabled));
|
|
1382
1380
|
rail.setAttribute("data-fast-mode-dot-transition", animate ? (enabled ? "entering" : "exiting") : (enabled ? "active" : "inactive"));
|
|
1383
1381
|
syncNativeFastParticles(rail, enabled, animate && enabled);
|
|
1384
|
-
setGenericSliderVisual(rail, Number(rail.getAttribute("aria-valuenow") ?? 0), Number(rail.getAttribute("aria-valuemax") ?? 0) + 1);
|
|
1385
1382
|
if (animate && enabled) {
|
|
1386
1383
|
shell.setAttribute("data-codex-model-slider-fast-transitioning", "");
|
|
1387
1384
|
setTimeout(() => {
|
package/package.json
CHANGED
|
@@ -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:Tc.describe("The display mode being requested.")})}),ST=m.object({mode:Tc.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:Tc.optional().describe("How the UI is currently displayed."),availableDisplayModes:m.array(Tc).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:"2.0.20"});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.21"});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:
|
|
@@ -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:"2.0.
|
|
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.21"});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:
|
|
@@ -46,7 +46,7 @@ export function createPluginServer({ promptsClient, paths = resolvePaths(), clie
|
|
|
46
46
|
registerAppTool(server,"minecodex_prompts_open",{
|
|
47
47
|
title:"Prompt",description:"Manage MineCodex prompts, categories and usage.",inputSchema:{},
|
|
48
48
|
annotations:{readOnlyHint:true,openWorldHint:false},
|
|
49
|
-
_meta:{ui:promptsUi,"openai/ui":{entrypoints:[{type:"global"}]}},
|
|
49
|
+
_meta:{ui:promptsUi,"openai/ui":{entrypoints:[{type:"global"},{type:"thread"}]}},
|
|
50
50
|
},async()=>({content:[],structuredContent:{view:"prompts"}}));
|
|
51
51
|
for (const write of [false,true]) registerAppTool(server,write ? "minecodex_prompts_write" : "minecodex_prompts_read",{
|
|
52
52
|
description:write ? "Apply an explicit Prompts edit or record successful usage." : "Read MineCodex Prompts.",
|