minecodex 2.0.40 → 2.0.42
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/README.md +3 -1
- package/apps/dashboard/assets/preview-content.js +5 -2
- package/features/composer-expand/assets/maximize-2.svg +16 -0
- package/features/composer-expand/codex-feature.json +24 -0
- package/features/composer-expand/src/entry.mjs +1 -0
- package/features/composer-expand/src/injection-source.mjs +7 -0
- package/features/composer-expand/src/install.mjs +91 -0
- package/features/composer-expand/src/native.mjs +79 -0
- package/features/composer-expand/vendor/lucide-LICENSE +15 -0
- package/features/hide-upsell-banner/src/hide-upsell-banner.mjs +2 -0
- package/features/images/codex-feature.json +1 -1
- package/features/images/src/adapters/codex/native-image-modules.mjs +10 -1
- package/features/quick-chat/codex-feature.json +4 -5
- package/features/quick-chat/src/adapters/codex/shortcut.mjs +15 -7
- package/features/quick-chat/src/adapters/codex/sidebar.mjs +35 -0
- package/features/quick-chat/src/frontend/entry.mjs +6 -8
- package/features/quick-chat/src/frontend/sidebar.mjs +63 -0
- package/features/quick-chat/src/injection-source.mjs +6 -5
- package/features/session-status/src/adapters/codex/context-usage.mjs +11 -6
- package/features/sidebar-focus/src/adapters/codex/renderer.mjs +11 -5
- package/features/sidebar-focus/src/sidebar-focus.mjs +5 -3
- package/features/sites/src/adapters/codex/renderer.mjs +1 -1
- package/features/sites/src/frontend/entry.mjs +1 -0
- package/package.json +6 -2
- package/packages/cli/src/config.mjs +3 -2
- package/packages/cli/src/control-server.mjs +1 -1
- package/packages/cli/src/paths.mjs +2 -1
- package/packages/cli/src/platform.mjs +43 -12
- package/packages/codex-adapter/src/markdown/markdown-native.mjs +7 -4
- package/packages/codex-adapter/src/markdown/toc-native.mjs +5 -4
- package/packages/plugin/assets/app.js +2 -2
- package/packages/plugin/assets/prompts.js +1 -1
- package/features/quick-chat/assets/pin.svg +0 -1
- package/features/quick-chat/src/adapters/codex/pin.mjs +0 -29
- package/features/quick-chat/src/adapters/codex/presence.mjs +0 -74
- package/features/quick-chat/src/frontend/exit.mjs +0 -14
- package/features/quick-chat/src/frontend/pin.mjs +0 -54
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
export function createFocusAdapter(codex) {
|
|
2
2
|
const sectionSelector="[data-app-action-sidebar-section]", projectSelector="[data-app-action-sidebar-project-row]";
|
|
3
3
|
const props = (element,predicate) => codex.props(element,predicate,30) ?? {};
|
|
4
|
+
const visible = element => element.checkVisibility({visibilityProperty:true});
|
|
5
|
+
function activity() {
|
|
6
|
+
return [...document.querySelectorAll('#app-shell-sidebar button[aria-pressed]')]
|
|
7
|
+
.find(element => visible(element) && /activity|活动|动态/i.test(element.getAttribute("aria-label") || ""));
|
|
8
|
+
}
|
|
4
9
|
function branches() {
|
|
5
|
-
return [...document.querySelectorAll("#app-shell-sidebar " + sectionSelector)].map(element => {
|
|
10
|
+
return [...document.querySelectorAll("#app-shell-sidebar " + sectionSelector)].filter(visible).map(element => {
|
|
6
11
|
const native = props(element, p => !!p.sectionKey);
|
|
7
12
|
const data = props(element, p => Array.isArray(p.section?.threadKeys)).section;
|
|
8
13
|
return { element, key:"section:" + native.sectionKey, data, expanded:element.dataset.appActionSidebarSectionCollapsed === "false",
|
|
9
14
|
toggle:() => native.onCollapsedChange?.(element.dataset.appActionSidebarSectionCollapsed === "false") };
|
|
10
|
-
}).concat([...document.querySelectorAll("#app-shell-sidebar " + projectSelector)].map(element => ({
|
|
15
|
+
}).concat([...document.querySelectorAll("#app-shell-sidebar " + projectSelector)].filter(visible).map(element => ({
|
|
11
16
|
element, key:"project:" + element.dataset.appActionSidebarProjectId,
|
|
12
17
|
data:props(element, p => !!p.group?.projectId).group,
|
|
13
18
|
expanded:element.getAttribute("aria-expanded") === "true",
|
|
@@ -15,14 +20,15 @@ function branches() {
|
|
|
15
20
|
})));
|
|
16
21
|
}
|
|
17
22
|
function target(items) {
|
|
18
|
-
|
|
23
|
+
// 两种模式的侧栏同时挂载,只在当前分支中读取原生选中身份。
|
|
24
|
+
const selected = items.map(b => b.element.querySelector?.('[data-app-action-sidebar-thread-selected="true"], [data-sidebar-chatgpt-conversation-key]:has([aria-current="page"])')).find(Boolean);
|
|
19
25
|
const id = codex.currentThreadId();
|
|
20
|
-
const key = selected?.dataset.appActionSidebarThreadId || (id ? "local:" + id : null);
|
|
26
|
+
const key = selected?.dataset.appActionSidebarThreadId || selected?.dataset.sidebarChatgptConversationKey || (id ? "local:" + id : null);
|
|
21
27
|
const activeProject = items.map(b => props(b.element, p => p.activeProjectId != null).activeProjectId).find(Boolean);
|
|
22
28
|
const project = items.find(b => b.key.startsWith("project:") && (b.data?.threadKeys?.includes(key) || b.data?.projectId === activeProject));
|
|
23
29
|
const section = items.find(b => b.key.startsWith("section:") && (b.data?.threadKeys?.includes(key) || (activeProject && b.data?.itemKeys?.includes("codex:project:" + activeProject))))
|
|
24
30
|
|| items.find(b => b.key.startsWith("section:") && (selected && b.element.contains(selected) || project && b.element.contains(project.element)));
|
|
25
31
|
return section ? { section, project } : null;
|
|
26
32
|
}
|
|
27
|
-
return {branches,target,isBranchToggle:element=>!!element.closest("[data-app-action-sidebar-section-toggle], " + projectSelector)};
|
|
33
|
+
return {activity,branches,target,isBranchToggle:element=>!!element.closest("[data-app-action-sidebar-section-toggle], " + projectSelector)};
|
|
28
34
|
}
|
|
@@ -4,7 +4,7 @@ const EXPAND_GLYPH = "<svg aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/200
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const states = new Map();
|
|
7
|
-
let active = false, restoring = false, button, timer = null, disposed = false;
|
|
7
|
+
let active = false, restoring = false, button, currentBell, timer = null, disposed = false;
|
|
8
8
|
const text = (en, cn) => (document.documentElement.lang || navigator.language).startsWith("zh") ? cn : en;
|
|
9
9
|
|
|
10
10
|
|
|
@@ -15,8 +15,10 @@ function remember(items) {
|
|
|
15
15
|
function reconcile() {
|
|
16
16
|
if (disposed) return;
|
|
17
17
|
const sidebar = document.querySelector("#app-shell-sidebar");
|
|
18
|
-
const bell =
|
|
18
|
+
const bell = nativeFocus.activity();
|
|
19
19
|
if (!bell) { button?.remove(); button = null; return; }
|
|
20
|
+
if (currentBell !== bell) { button?.remove(); button = null; }
|
|
21
|
+
currentBell = bell;
|
|
20
22
|
if (!button?.isConnected) {
|
|
21
23
|
button = bell.cloneNode(false);
|
|
22
24
|
button.removeAttribute("id");
|
|
@@ -93,7 +95,7 @@ const observer = new MutationObserver(records => {
|
|
|
93
95
|
)) schedule();
|
|
94
96
|
});
|
|
95
97
|
observer.observe(document.documentElement, { subtree:true, childList:true, attributes:true, attributeFilter:[
|
|
96
|
-
"aria-expanded", "aria-pressed", "data-app-action-sidebar-thread-selected",
|
|
98
|
+
"aria-expanded", "aria-pressed", "aria-current", "style", "class", "data-app-action-sidebar-thread-selected",
|
|
97
99
|
"data-app-action-sidebar-section-collapsed", "data-above-composer-conversation-id", "lang"
|
|
98
100
|
] });
|
|
99
101
|
reconcile();
|
|
@@ -34,7 +34,7 @@ function pageInfo() {
|
|
|
34
34
|
const ownershipTabs=[...page.querySelectorAll('[role="tablist"]')].find(node=>!node.closest(`[${owned}]`)&&nativeProps(node,p=>p.tabs?.some(tab=>tab.key==="owned")&&p.tabs?.some(tab=>tab.key==="shared")));
|
|
35
35
|
const ownership=ownershipTabs&&nativeProps(ownershipTabs,p=>p.tabs?.some(tab=>tab.key==="owned")&&p.tabs?.some(tab=>tab.key==="shared"));
|
|
36
36
|
const shared = ownership ? ownership.selectedKey === "shared" : native ? !!native.shared : [...page.querySelectorAll("button[aria-pressed=true]")].some(b => /Shared with you|与你共享|與你共用/.test(b.textContent));
|
|
37
|
-
const create = [...(plus ? page : page.firstElementChild).querySelectorAll("button")].find(b => visible(b) && (plus ? /^(Create Site
|
|
37
|
+
const create = [...(plus ? page : page.firstElementChild).querySelectorAll("button")].find(b => visible(b) && (plus ? /^(Create Site|创建站点|创建新站点|建立網站)$/ : /^(New|新建|新增)$/).test(b.textContent.trim()) && !b.hasAttribute(owned));
|
|
38
38
|
codex.report("sites-page",true);
|
|
39
39
|
return { page, input, content, list, grid, shared, create, plus, ownershipTabs:plus?(ownershipTabs??null):null, accountKey:account.read().key, empty: list ? null : [...content.children].findLast(e => !e.hasAttribute(owned)) };
|
|
40
40
|
}
|
|
@@ -36,6 +36,7 @@ function setButtonDisabled(button, disabled) {
|
|
|
36
36
|
button.disabled = disabled; button.setAttribute("aria-disabled", String(disabled)); button.toggleAttribute("data-disabled", disabled);
|
|
37
37
|
}
|
|
38
38
|
function notice(message) {
|
|
39
|
+
if (disposed || signal.aborted) return;
|
|
39
40
|
document.querySelector(`[${owned}=notice]`)?.remove();
|
|
40
41
|
const n = element("div", "", message); n.setAttribute(owned, "notice"); n.setAttribute("role", "status"); document.body.append(n);
|
|
41
42
|
setTimeout(() => n.remove(), 7000);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minecodex",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.42",
|
|
4
4
|
"description": "Lightweight, local-first plugins for the Codex desktop app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
"README.md",
|
|
45
45
|
"features/usage-meter/src",
|
|
46
46
|
"features/usage-meter/codex-feature.json",
|
|
47
|
+
"features/composer-expand/src",
|
|
48
|
+
"features/composer-expand/assets",
|
|
49
|
+
"features/composer-expand/vendor/lucide-LICENSE",
|
|
50
|
+
"features/composer-expand/codex-feature.json",
|
|
47
51
|
"features/quick-chat/src",
|
|
48
52
|
"features/quick-chat/assets",
|
|
49
53
|
"features/quick-chat/vendor/lucide-LICENSE",
|
|
@@ -90,7 +94,7 @@
|
|
|
90
94
|
},
|
|
91
95
|
"scripts": {
|
|
92
96
|
"start": "node packages/cli/bin/mcx.mjs serve",
|
|
93
|
-
"test": "node --test packages/cli/test/*.test.mjs packages/runtime-host/test/*.test.mjs features/model-slider/test/*.test.mjs features/notes/test/*.test.mjs features/images/test/*.test.mjs features/hide-upsell-banner/test/*.test.mjs features/session-status/test/*.test.mjs features/usage-meter/test/*.test.mjs apps/dashboard/test/*.test.mjs features/unread-inbox/test/*.test.mjs features/quick-chat/test/*.test.mjs features/sidebar-focus/test/*.test.mjs features/sites/test/*.test.mjs packages/ui/test/*.test.mjs packages/codex-adapter/test/*.test.mjs features/markdown-reading/test/*.test.mjs features/file-navigation/test/*.test.mjs packages/plugin/test/*.test.mjs features/mermaid-diagrams/test/*.test.mjs",
|
|
97
|
+
"test": "node --test packages/cli/test/*.test.mjs packages/runtime-host/test/*.test.mjs features/model-slider/test/*.test.mjs features/notes/test/*.test.mjs features/images/test/*.test.mjs features/hide-upsell-banner/test/*.test.mjs features/session-status/test/*.test.mjs features/usage-meter/test/*.test.mjs apps/dashboard/test/*.test.mjs features/unread-inbox/test/*.test.mjs features/quick-chat/test/*.test.mjs features/composer-expand/test/*.test.mjs features/sidebar-focus/test/*.test.mjs features/sites/test/*.test.mjs packages/ui/test/*.test.mjs packages/codex-adapter/test/*.test.mjs features/markdown-reading/test/*.test.mjs features/file-navigation/test/*.test.mjs packages/plugin/test/*.test.mjs features/mermaid-diagrams/test/*.test.mjs",
|
|
94
98
|
"test:cli": "node --test packages/cli/test/*.test.mjs",
|
|
95
99
|
"test:runtime": "node --test packages/runtime-host/test/*.test.mjs",
|
|
96
100
|
"check": "node scripts/check-syntax.mjs",
|
|
@@ -2,7 +2,7 @@ import { randomBytes } from "node:crypto";
|
|
|
2
2
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
|
-
export const FEATURE_IDS = Object.freeze(["model-slider", "notes", "images", "hide-upsell-banner", "session-status", "usage-meter", "sidebar-focus", "sites", "markdown-reading", "mermaid-diagrams", "file-navigation", "quick-chat"]);
|
|
5
|
+
export const FEATURE_IDS = Object.freeze(["model-slider", "notes", "images", "hide-upsell-banner", "session-status", "usage-meter", "sidebar-focus", "sites", "markdown-reading", "mermaid-diagrams", "file-navigation", "quick-chat", "composer-expand"]);
|
|
6
6
|
export const DEFAULT_CONFIG = Object.freeze({
|
|
7
7
|
schemaVersion: 1,
|
|
8
8
|
features: Object.freeze({
|
|
@@ -18,6 +18,7 @@ export const DEFAULT_CONFIG = Object.freeze({
|
|
|
18
18
|
"mermaid-diagrams": false,
|
|
19
19
|
"file-navigation": true,
|
|
20
20
|
"quick-chat": true,
|
|
21
|
+
"composer-expand": true,
|
|
21
22
|
}),
|
|
22
23
|
});
|
|
23
24
|
|
|
@@ -43,7 +44,7 @@ export function normalizeConfig(value = {}) {
|
|
|
43
44
|
};
|
|
44
45
|
// 暂停的 Task 通知不继承旧配置,也不再提供开启入口。
|
|
45
46
|
delete features["unread-inbox"];
|
|
46
|
-
//
|
|
47
|
+
// 清理已退役的独立 Quick Chat 修复开关。
|
|
47
48
|
delete features["quick-chat-repair"];
|
|
48
49
|
return {
|
|
49
50
|
...value,
|
|
@@ -14,7 +14,7 @@ import { createDataTransfer, MAX_TRANSFER_BYTES } from "./data-transfer/service.
|
|
|
14
14
|
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
15
15
|
const packageMetadata = JSON.parse(await readFile(path.join(packageRoot, "package.json"), "utf8"));
|
|
16
16
|
const MAX_BODY_BYTES = 64 * 1024;
|
|
17
|
-
const DASHBOARD_FEATURE_ORDER = ["model-slider", "notes", "usage-meter", "session-status", "markdown-reading", "mermaid-diagrams", "file-navigation", "images", "sites", "quick-chat", "sidebar-focus", "hide-upsell-banner"];
|
|
17
|
+
const DASHBOARD_FEATURE_ORDER = ["model-slider", "notes", "usage-meter", "session-status", "markdown-reading", "mermaid-diagrams", "file-navigation", "images", "sites", "quick-chat", "composer-expand", "sidebar-focus", "hide-upsell-banner"];
|
|
18
18
|
const CONTENT_TYPES = new Map([
|
|
19
19
|
[".css", "text/css; charset=utf-8"],
|
|
20
20
|
[".html", "text/html; charset=utf-8"],
|
|
@@ -25,9 +25,10 @@ export function resolvePaths({ homeDir = os.homedir(), platform = process.platfo
|
|
|
25
25
|
supportDir,
|
|
26
26
|
logsDir,
|
|
27
27
|
serviceDir,
|
|
28
|
-
// Windows
|
|
28
|
+
// Windows 通过隐藏启动器等待 cmd 服务,保留计划任务的退出状态。
|
|
29
29
|
serviceBundleSource: null,
|
|
30
30
|
serviceAppPath: winPath.join(serviceDir, "MineCodexService.cmd"),
|
|
31
|
+
serviceLauncherPath: winPath.join(serviceDir, "MineCodexService-hidden.vbs"),
|
|
31
32
|
serviceManagerPath: null,
|
|
32
33
|
serviceRuntimeConfigPath: winPath.join(supportDir, "service-runtime.json"),
|
|
33
34
|
configPath: winPath.join(supportDir, "config.json"),
|
|
@@ -217,6 +217,20 @@ export function buildWindowsServiceCommand({ nodePath, cliPath, paths }) {
|
|
|
217
217
|
].join("\r\n");
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
export function buildWindowsServiceLauncher(paths) {
|
|
221
|
+
const serviceCmd = String(paths.serviceAppPath).replaceAll('"', '""');
|
|
222
|
+
return [
|
|
223
|
+
"Option Explicit",
|
|
224
|
+
"Dim shell, command, exitCode",
|
|
225
|
+
'Set shell = CreateObject("WScript.Shell")',
|
|
226
|
+
"' 隐藏窗口并等待服务退出,向计划任务传递真实退出码。",
|
|
227
|
+
'command = Chr(34) & shell.ExpandEnvironmentStrings("%ComSpec%") & Chr(34) & " /d /s /c " & Chr(34) & Chr(34) & "' + serviceCmd + '" & Chr(34) & Chr(34)',
|
|
228
|
+
"exitCode = shell.Run(command, 0, True)",
|
|
229
|
+
"WScript.Quit exitCode",
|
|
230
|
+
"",
|
|
231
|
+
].join("\r\n");
|
|
232
|
+
}
|
|
233
|
+
|
|
220
234
|
// cmd 的引号转义是内部双引号翻倍,与 JSON 转义规则不同,不能混用。
|
|
221
235
|
function cmdQuote(value) {
|
|
222
236
|
return '"' + String(value).replaceAll('"', '""') + '"';
|
|
@@ -907,6 +921,8 @@ export class WindowsPlatformAdapter {
|
|
|
907
921
|
|
|
908
922
|
async writeServiceCommand(paths, content) {
|
|
909
923
|
await this.fileSystem.writeFile(paths.serviceAppPath, content, { mode: 0o700 });
|
|
924
|
+
// WSH 用 UTF-16 BOM 识别中文路径,避免依赖系统 ANSI 代码页。
|
|
925
|
+
await this.fileSystem.writeFile(paths.serviceLauncherPath, Buffer.from("\uFEFF" + buildWindowsServiceLauncher(paths), "utf16le"), { mode: 0o700 });
|
|
910
926
|
}
|
|
911
927
|
|
|
912
928
|
async snapshotServiceState(paths) {
|
|
@@ -956,8 +972,9 @@ export class WindowsPlatformAdapter {
|
|
|
956
972
|
async registerServiceTask(paths) {
|
|
957
973
|
// ExecutionTimeLimit 0 表示不限时:服务是常驻进程,不能被默认 72h 限制回收。
|
|
958
974
|
const script = [
|
|
959
|
-
"$
|
|
960
|
-
|
|
975
|
+
"$launcher = '" + String(paths.serviceLauncherPath).replaceAll("'", "''") + "';",
|
|
976
|
+
"$serviceDir = '" + String(paths.serviceDir).replaceAll("'", "''") + "';",
|
|
977
|
+
'$action = New-ScheduledTaskAction -Execute (Join-Path $env:SystemRoot \'System32\\wscript.exe\') -Argument (\'//B //Nologo "\' + $launcher + \'"\') -WorkingDirectory $serviceDir;',
|
|
961
978
|
"$trigger = New-ScheduledTaskTrigger -AtLogOn;",
|
|
962
979
|
"$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -ExecutionTimeLimit ([TimeSpan]::Zero) -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1);",
|
|
963
980
|
"Register-ScheduledTask -TaskName '" + WINDOWS_SERVICE_TASK_NAME + "' -Action $action -Trigger $trigger -Settings $settings -Force | Out-Null;",
|
|
@@ -1179,18 +1196,32 @@ export class WindowsPlatformAdapter {
|
|
|
1179
1196
|
|
|
1180
1197
|
async openNativeCodex({ cdpPort } = {}) {
|
|
1181
1198
|
const installation = await this.codex();
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1199
|
+
const withCdp = Number.isInteger(cdpPort) && cdpPort > 0 && cdpPort <= 65_535;
|
|
1200
|
+
const existingPids = new Set(withCdp ? (await this.listCodexProcesses()).map(({ pid }) => pid) : []);
|
|
1201
|
+
const appId = `${installation.packageFamilyName}!App`.replaceAll("'", "''");
|
|
1202
|
+
const args = withCdp
|
|
1203
|
+
? `--remote-debugging-address=127.0.0.1 --remote-debugging-port=${cdpPort} --remote-allow-origins=http://127.0.0.1:${cdpPort}`
|
|
1204
|
+
: "";
|
|
1205
|
+
// 通过已注册应用入口激活,保留任务栏身份及扩展所需参数。
|
|
1188
1206
|
await this.powershell([
|
|
1189
|
-
"
|
|
1190
|
-
"
|
|
1191
|
-
"
|
|
1192
|
-
"
|
|
1207
|
+
"Add-Type -TypeDefinition @'",
|
|
1208
|
+
"using System;",
|
|
1209
|
+
"using System.Runtime.InteropServices;",
|
|
1210
|
+
"public static class MineCodexRegisteredLaunch {",
|
|
1211
|
+
" [ComImport, Guid(\"2E941141-7F97-4756-BA1D-9DECDE894A3D\"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]",
|
|
1212
|
+
" interface Activation {",
|
|
1213
|
+
" [PreserveSig] int ActivateApplication([MarshalAs(UnmanagedType.LPWStr)] string id, [MarshalAs(UnmanagedType.LPWStr)] string args, uint options, out uint pid);",
|
|
1214
|
+
" }",
|
|
1215
|
+
" public static uint Launch(string id, string args) {",
|
|
1216
|
+
" object manager = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(\"45BA127D-10A8-46EA-8AB7-56EA9078943C\")));",
|
|
1217
|
+
" try { uint pid; Marshal.ThrowExceptionForHR(((Activation)manager).ActivateApplication(id, args, 0, out pid)); return pid; }",
|
|
1218
|
+
" finally { Marshal.ReleaseComObject(manager); }",
|
|
1219
|
+
" }",
|
|
1220
|
+
"}",
|
|
1221
|
+
"'@",
|
|
1222
|
+
`[MineCodexRegisteredLaunch]::Launch('${appId}', '${args}') | Out-Null`,
|
|
1193
1223
|
].join("\n"));
|
|
1224
|
+
if (!withCdp) return null;
|
|
1194
1225
|
return this.waitForNativeCodex({ cdpPort, excludedPids: existingPids });
|
|
1195
1226
|
}
|
|
1196
1227
|
|
|
@@ -13,16 +13,19 @@ export async function loadNativeMarkdownRenderer(source, url, module) {
|
|
|
13
13
|
].find((m) => m[2].includes(`${init}()`) && binding(m[1]));
|
|
14
14
|
if (!initializer || !binding(markdownName)) throw new Error('native-rich-markdown-contract-unavailable');
|
|
15
15
|
binding(initializer[1])();
|
|
16
|
-
let lexer, sharedUrl;
|
|
17
16
|
const lexerName = source.match(/tokens:([\w$]+)\(e,void 0\)/)?.[1];
|
|
18
|
-
|
|
17
|
+
let lexer = lexerName ? binding(lexerName) : undefined, sharedUrl;
|
|
18
|
+
// lexer 可在入口模块本地导出;代码组件仍从独立的共享模块加载。
|
|
19
|
+
for (const m of source.matchAll(/import\{([^}]+)\}from["']([^"']+)["']/g)) {
|
|
20
|
+
const importUrl = new URL(m[2], url).href;
|
|
21
|
+
if (/\/app-shared-[^/]+\.(?:js|mjs)$/.test(importUrl)) sharedUrl = importUrl;
|
|
19
22
|
for (const entry of m[1].split(',')) {
|
|
20
23
|
const parts = entry.trim().split(/\s+as\s+/);
|
|
21
24
|
if (parts.at(-1) === lexerName) {
|
|
22
|
-
|
|
23
|
-
lexer = (await import(sharedUrl))[parts[0]];
|
|
25
|
+
lexer = (await import(importUrl))[parts[0]];
|
|
24
26
|
}
|
|
25
27
|
}
|
|
28
|
+
}
|
|
26
29
|
if (!sharedUrl || typeof lexer !== 'function') throw new Error('native-markdown-lexer-unavailable');
|
|
27
30
|
return { Markdown: binding(markdownName), lexer, sharedUrl };
|
|
28
31
|
}
|
|
@@ -69,7 +69,7 @@ export async function loadNativeMarkdownToc() {
|
|
|
69
69
|
)?.[1];
|
|
70
70
|
const Tooltip = await binding(tooltipLocal);
|
|
71
71
|
const layoutUrl = [...imports.values()].find((item) =>
|
|
72
|
-
|
|
72
|
+
/\/floating-navigation-rail-(?:layout-)?[\w-]+\.js(?:$|\?)/.test(item.url),
|
|
73
73
|
)?.url;
|
|
74
74
|
if (!layoutUrl) throw new Error('native-page-toc-layout-unavailable');
|
|
75
75
|
const layout = await import(layoutUrl);
|
|
@@ -84,7 +84,7 @@ export async function loadNativeMarkdownToc() {
|
|
|
84
84
|
mainImports.set(parts.at(-1), { name: parts[0], url: new URL(match[2], mainUrl).href });
|
|
85
85
|
}
|
|
86
86
|
const ReactDOM = (await binding(rootFactory, mainImports))();
|
|
87
|
-
const css = initial.match(/["']\.\/((?:floating-navigation-rail
|
|
87
|
+
const css = initial.match(/["']\.\/((?:floating-navigation-rail(?:-layout)?)-[\w-]+\.css)["']/)?.[1];
|
|
88
88
|
if (!css) throw new Error('native-page-toc-styles-unavailable');
|
|
89
89
|
const cssUrl = new URL(css, initialUrl).href;
|
|
90
90
|
if (![...document.querySelectorAll('link[rel="stylesheet"]')].some((n) => n.href === cssUrl)) {
|
|
@@ -114,9 +114,10 @@ export async function loadNativeMarkdownToc() {
|
|
|
114
114
|
const classes = {
|
|
115
115
|
rail: requireClass(railBody, /ref:[\w$]+,className:`([^`]+)`,"data-floating-navigation-rail-list"/),
|
|
116
116
|
railButton: requireClass(railBody, /className:`([^`]+)`,"aria-current"/),
|
|
117
|
-
menu: requireClass(listBody, /ref:[\w$]+,className:`([^`]+)`,children:/),
|
|
117
|
+
menu: requireClass(listBody, /ref:[\w$]+,className:`([^`]+)`,(?:variant:`viewer`,)?children:/),
|
|
118
118
|
menuButton: requireClass(listBody, /className:[\w$]+\(`([^`]+)`/),
|
|
119
|
-
|
|
119
|
+
// 按 TOC 调用角色找导航样式,避免绑定随布局变化的 top utility。
|
|
120
|
+
nav: requireClass(bodyMatching(/skipDelayKey:`page-table-of-contents`/), /jsx\)\(`nav`,\{"aria-label":[\w$]+,className:`([^`]+)`/),
|
|
120
121
|
};
|
|
121
122
|
const indentName = listBody.match(/`block`,([\w$]+)\[e\.level\]/)?.[1];
|
|
122
123
|
const indentValue = indentName && source.match(new RegExp(`\\b${indentName}=(\\[[^\\]]+\\])`))?.[1];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var uz=Object.defineProperty;var Nr=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var At=(e,t)=>{for(var n in t)uz(e,n,{get:t[n],enumerable:!0})};function q$(e,t){return ST[e]?.[t==="zh-CN"?0:1]??(t==="zh-CN"?["Codex \u4E2D\u5BF9\u5E94\u529F\u80FD\u7684\u4F4D\u7F6E\u3002","\u8BF7\u53C2\u8003\u529F\u80FD\u8BF4\u660E\u3002","\u6548\u679C\u53D6\u51B3\u4E8E\u5F53\u524D\u7248\u672C\u4E0E\u9002\u7528\u9875\u9762\u3002"]:["The feature\u2019s location in Codex.","Refer to the feature description.","Availability depends on the version and current page."])}var ST,V$=Nr(()=>{ST={"model-slider":[["\u8F93\u5165\u6846\u7684\u6A21\u578B\u9009\u62E9\u533A\u57DF\u3002","\u6A21\u578B\u4E0E\u601D\u8003\u6863\u4F4D\u5206\u6563\uFF0C\u5207\u6362\u4E0D\u591F\u76F4\u63A5\u3002","\u6253\u5F00\u6A21\u578B\u7A97\u53E3\uFF0C\u9009\u62E9\u6A21\u578B\u4E0E\u601D\u8003\u6863\u4F4D\uFF1B\u6536\u85CF\u5E38\u7528\u6A21\u578B\u4EE5\u4FBF\u518D\u6B21\u9009\u62E9\u3002"],["The model selector beside the composer.","Switching models and reasoning levels takes extra steps.","Open the model panel, choose a model and reasoning level, and save favorites for quick access."]],notes:[["\u5B98\u65B9 Prompt \u9875\u9762\u4E0E\u8F93\u5165\u6846\u65C1\u7684 Quick Prompts\u3002","\u5E38\u7528\u63D0\u793A\u8BCD\u9700\u8981\u53CD\u590D\u67E5\u627E\u548C\u590D\u5236\u3002","\u6309\u5206\u7C7B\u7BA1\u7406\u63D0\u793A\u8BCD\uFF0C\u4ECE Quick Prompts \u586B\u5165\u5F53\u524D\u8F93\u5165\u6846\uFF1B\u586B\u5165\u540E\u7531\u4F60\u68C0\u67E5\u5E76\u53D1\u9001\u3002"],["The Prompt page and Quick Prompts beside the composer.","Reusable prompts are hard to find and copy repeatedly.","Organize prompts by category and insert one into the current composer. Review it before sending."]],"usage-meter":[["Codex \u4FA7\u680F\u7684\u989D\u5EA6\u73AF\u3002","\u67E5\u770B\u5269\u4F59\u989D\u5EA6\u9700\u8981\u6253\u5F00\u8D26\u53F7\u83DC\u5355\u3002","\u7528\u989D\u5EA6\u73AF\u67E5\u770B\u4F7F\u7528\u6BD4\u4F8B\uFF0C\u70B9\u51FB\u6253\u5F00\u7528\u91CF\u8BE6\u60C5\u3002"],["The usage ring in the Codex sidebar.","Checking remaining usage requires opening the account menu.","Read usage at a glance, then click for usage details."]],"session-status":[["\u5F53\u524D\u4F1A\u8BDD\u7684\u72B6\u6001\u533A\u57DF\u3002","\u4F1A\u8BDD\u7528\u91CF\u4E0E\u751F\u6210\u901F\u5EA6\u4E0D\u5BB9\u6613\u96C6\u4E2D\u67E5\u770B\u3002","\u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\u7684\u7528\u91CF\u3001\u4E0A\u4E0B\u6587\u548C\u751F\u6210\u6307\u6807\uFF1B\u53EF\u7528\u9879\u76EE\u53D6\u51B3\u4E8E\u4F1A\u8BDD\u4E0E\u63D0\u4F9B\u65B9\u3002"],["The current conversation\u2019s status area.","Usage and generation metrics are spread across the interface.","Read session usage, context and generation metrics when supported by the session and provider."]],"markdown-reading":[["Codex \u7684 Markdown \u6587\u4EF6\u9884\u89C8\u3002","\u957F\u6587\u9605\u8BFB\u3001\u811A\u6CE8\u8DF3\u8F6C\u548C\u8868\u683C\u67E5\u770B\u4E0D\u591F\u65B9\u4FBF\u3002","\u5728\u6587\u4EF6\u9884\u89C8\u4E2D\u9605\u8BFB\u589E\u5F3A\u6392\u7248\uFF0C\u4F7F\u7528\u76EE\u5F55\u3001\u811A\u6CE8\u548C\u8868\u683C\u64CD\u4F5C\u3002"],["Markdown file previews in Codex.","Long documents, footnotes and tables take extra effort to read.","Read enhanced formatting and use the outline, footnote navigation and table actions."]],"mermaid-diagrams":[["Markdown \u6587\u4EF6\u9884\u89C8\u4E2D\u7684 Mermaid \u56FE\u8868\u3002","\u5B9E\u9A8C\u6027\u56FE\u8868\u6837\u5F0F\u4E0E\u4EA4\u4E92\u4ECD\u5728\u5B8C\u5584\uFF0C\u9ED8\u8BA4\u5173\u95ED\u3002","\u6309\u9700\u5F00\u542F\u56FE\u8868\u589E\u5F3A\uFF0C\u4F7F\u7528\u7F29\u653E\u548C PNG \u4E0B\u8F7D\uFF1B\u5173\u95ED\u540E\u4F7F\u7528 Codex \u539F\u751F\u56FE\u8868\u3002"],["Mermaid diagrams in Markdown file previews.","Enhanced diagram styles and interactions are experimental and off by default.","Opt in to diagram zoom and PNG download. Turn it off to use native Codex diagrams."]],"file-navigation":[["Codex \u6587\u4EF6\u9884\u89C8\u4E0A\u65B9\u7684\u8DEF\u5F84\u533A\u57DF\u3002","\u6D4F\u89C8\u76F8\u90BB\u76EE\u5F55\u548C\u6587\u4EF6\u9700\u8981\u989D\u5916\u8DF3\u8F6C\u3002","\u70B9\u51FB\u8DEF\u5F84\u5C55\u5F00\u5206\u5217\u76EE\u5F55\uFF0C\u9010\u7EA7\u6D4F\u89C8\u5E76\u6253\u5F00\u53E6\u4E00\u4E2A\u6587\u4EF6\u3002"],["The path above a file preview in Codex.","Browsing nearby files and folders takes extra navigation.","Open the path to browse cascading folder columns and choose another file."]],images:[["Codex Library \u7684\u56FE\u7247\u96C6\u5408\u4E0E\u56FE\u7247\u67E5\u770B\u5668\u3002","\u67E5\u627E\u56FE\u7247\u53CA\u5176\u63D0\u793A\u8BCD\u9700\u8981\u6765\u56DE\u5207\u6362\u3002","\u6D4F\u89C8\u56FE\u7247\u96C6\u5408\uFF0C\u6253\u5F00\u56FE\u7247\u67E5\u770B\u5927\u56FE\u53CA\u53EF\u8FFD\u6EAF\u7684\u63D0\u793A\u8BCD\u4FE1\u606F\u3002"],["Image collections in Codex Library and the image viewer.","Finding images and their prompts requires switching views.","Browse collections, open an image, and inspect available prompt provenance."]],sites:[["Codex \u4E2D\u7684 Sites \u9875\u9762\u3002","\u672C\u5730\u9879\u76EE\u4E0E\u5E38\u7528\u7F51\u5740\u5206\u6563\u5728\u4E0D\u540C\u4F4D\u7F6E\u3002","\u6536\u85CF\u7F51\u5740\u3001\u53D1\u73B0\u6B63\u5728\u8FD0\u884C\u7684\u672C\u5730\u7AD9\u70B9\uFF0C\u5E76\u4ECE Sites \u6253\u5F00\u3002"],["The Sites page in Codex.","Local projects and saved links are scattered.","Save URLs, discover running local sites, and open them from Sites."]],"quick-chat":[["Codex \u7684\u6D6E\u52A8 Quick Chat \u7A97\u53E3\u3002","\u4E34\u65F6\u63D0\u95EE\u65F6\u9700\u8981\u5207\u6362\u4E3B\u7A97\u53E3\uFF0C\u5386\u53F2\u4E0D\u6613\u7EE7\u7EED\u3002","\u901A\u8FC7\u5FEB\u6377\u952E\u6253\u5F00 Quick Chat\uFF0C\u53D1\u9001\u540E\u5C55\u5F00\uFF0C\u6062\u590D\u6700\u5C0F\u5316\u8F93\u5165\u6846\u5E76\u56FA\u5B9A\u804A\u5929\u3002"],["The floating Quick Chat window.","Quick questions and continuing recent chats require window switching.","Open Quick Chat with a shortcut, expand after sending, restore a minimized composer and pin the chat."]],"sidebar-focus":[["Codex \u5DE6\u4FA7\u680F\u7684\u5206\u7EC4\u6807\u9898\u3002","\u591A\u4E2A\u4FA7\u680F\u5206\u7EC4\u5C55\u5F00\u65F6\uFF0C\u5F53\u524D\u5206\u7EC4\u4E0D\u5BB9\u6613\u805A\u7126\u3002","\u70B9\u51FB\u5F53\u524D\u5206\u7EC4\uFF0C\u4E00\u952E\u6536\u8D77\u5176\u4ED6\u5206\u7EC4\uFF1B\u518D\u6B21\u70B9\u51FB\u6062\u590D\u5148\u524D\u7684\u5C55\u5F00\u72B6\u6001\u3002"],["Group headings in the Codex sidebar.","Several expanded groups make the current group harder to focus on.","Click a group to collapse other groups. Click again to restore their previous expanded state."]],"hide-upsell-banner":[["Codex \u7684\u989D\u5EA6\u63A8\u5E7F\u63D0\u793A\u533A\u57DF\u3002","\u63A8\u5E7F\u63D0\u793A\u5360\u7528\u65E5\u5E38\u64CD\u4F5C\u7A7A\u95F4\u3002","\u9690\u85CF\u989D\u5EA6\u63A8\u5E7F\u63D0\u793A\uFF0C\u4FDD\u7559\u771F\u5B9E\u989D\u5EA6\u4E0E\u8FD0\u884C\u9519\u8BEF\u53CD\u9988\u3002"],["Usage promotion banners in Codex.","Promotions take space during everyday tasks.","Hide usage promotions while retaining real usage and error feedback."]]}});function Z$(e,t){let n=t==="zh-CN",o=(A,K)=>n?A:K,r=new AbortController,i=(A,K,Q,re={})=>A.addEventListener(K,Q,{...re,signal:r.signal}),a=matchMedia("(hover: hover) and (pointer: fine)"),s=matchMedia("(prefers-reduced-motion: reduce)"),l=null,c=null,d=null,m,h,f,v=!1,y=0,k=!1,T=null,R,N=null,Z=!1,X=null,M=()=>R??=window.minecodexPreviewMedia!==void 0?Promise.resolve(window.minecodexPreviewMedia):fetch("/assets/previews/manifest.json").then(A=>A.ok?A.json():{}).then(A=>A&&typeof A=="object"?A:{}).catch(()=>({})),B=(A,K,Q)=>{let re=document.createElement(A);return re.className=K,Q&&(re.textContent=Q),re};async function De(A,K,Q,re){if(!window.minecodexMcpApp)return`/assets/previews/${Q}`;let be=(await window.minecodexMcpApp.readServerResource({uri:`resource://minecodex/previews/${A}/${K}`},{signal:re})).contents?.[0];if(!be?.blob)throw new Error("Preview resource unavailable");return`data:${be.mimeType};base64,${be.blob}`}function ie({restore:A=!1}={}){clearTimeout(m),clearTimeout(h),clearTimeout(f),y++,T?.abort(),T=null;let K=c,Q=l,re=d;c=null,l=null,d=null,v=!1,re&&(re.pause(),re.removeAttribute("src"),re.load());let le=Q?.querySelector(".preview-entry");le?.setAttribute("aria-expanded","false"),le?.removeAttribute("aria-controls"),Q?.classList.remove("is-previewing"),e.classList.remove("has-preview"),K?.remove(),A&&le?.isConnected&&(k=!0,le.focus({preventScroll:!0}),k=!1)}function fe(){if(!l||!c)return;let A=l.getBoundingClientRect(),K=Math.min(360,innerWidth-32);c.style.width=`${K}px`,c.style.maxHeight=`${Math.max(120,innerHeight-32)}px`;let Q=c.getBoundingClientRect().height,re,le;if(innerWidth-A.right>=K+24)re=A.right+8;else if(A.left>=K+24)re=A.left-K-8;else{re=Math.max(16,Math.min(A.left,innerWidth-K-16));let be=innerHeight-A.bottom-24,Oe=A.top-24;be>=Math.min(Q,180)?(c.style.maxHeight=`${be}px`,le=A.bottom+8):Oe>=Math.min(Q,180)?(c.style.maxHeight=`${Oe}px`,le=Math.max(16,A.top-Q-8)):(le=Math.max(16,A.top+l.querySelector(".plugin-topline").getBoundingClientRect().height+32),c.style.maxHeight=`${Math.max(100,innerHeight-le-16)}px`)}le??=Math.max(16,Math.min(A.top,innerHeight-Q-16)),Object.assign(c.style,{left:`${re}px`,top:`${le}px`,visibility:"visible"})}function et(){!v&&!N&&!Z&&(h=setTimeout(()=>ie(),100))}async function Nt(A,K,Q,re){let le=(await M())?.[A];if(re!==y||!c||!le)return;T=new AbortController;let be=T.signal,Oe,at,He=!1;Q.textContent=o("\u6B63\u5728\u52A0\u8F7D\u9884\u89C8\u2026","Loading preview\u2026");let pt=await Promise.all(["poster","video"].map(async jt=>{if(!le[jt])return null;try{return await De(A,jt,le[jt],be)}catch{return He=!0,null}}));if(re!==y)return;[Oe,at]=pt,Q.textContent=He?o("\u8D44\u6E90\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Preview unavailable \xB7 See description"):o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon");let ue=null;if(Oe&&(ue=B("img","preview-poster"),ue.alt=o("\u529F\u80FD\u9759\u6001\u9884\u89C8","Static feature preview"),ue.addEventListener("load",fe,{once:!0}),ue.addEventListener("error",()=>{ue.remove(),He=!0,d||(Q.textContent=o("\u8D44\u6E90\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Preview unavailable \xB7 See description")),fe()},{once:!0}),ue.src=Oe,K.append(ue),Q.textContent=o("\u9759\u6001\u9884\u89C8","Static preview")),!at){fe();return}if(s.matches){fe();return}let ne=B("video","preview-video");d=ne,ne.muted=!0,ne.playsInline=!0,ne.preload="metadata",ne.hidden=!0;let zt=()=>{c.classList.remove("is-media-only"),ue&&(ue.hidden=!1)},zr=()=>{re===y&&(clearTimeout(f),ne.pause(),ne.removeAttribute("src"),ne.load(),ne.remove(),d=null,zt(),Q.textContent=ue?.isConnected?o("\u89C6\u9891\u6682\u4E0D\u53EF\u7528 \xB7 \u9759\u6001\u9884\u89C8","Video unavailable \xB7 Static preview"):o("\u89C6\u9891\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Video unavailable \xB7 See description"),fe())};ne.addEventListener("error",zr,{once:!0}),ne.addEventListener("loadeddata",()=>{re===y&&fe()}),ne.addEventListener("play",()=>{re===y&&(ne.hidden=!1,ue&&(ue.hidden=!0),c.classList.add("is-media-only"),fe())});let Wt=async()=>{if(re===y)try{await ne.play()}catch{re===y&&d===ne&&ne.isConnected&&(ne.hidden=!0,zt(),Q.textContent=ue?.isConnected?o("\u9759\u6001\u9884\u89C8","Static preview"):o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon"),fe())}};ne.addEventListener("ended",()=>{clearTimeout(f),f=setTimeout(()=>{re!==y||d!==ne||(ne.currentTime=0,Wt())},2e3)}),K.append(ne),Q.textContent=o("\u6B63\u5728\u52A0\u8F7D\u6F14\u793A\u2026","Loading demo\u2026"),ne.src=at,Wt(),fe()}function mt(A,K=!1){if(clearTimeout(m),clearTimeout(h),A===l){v||=K;return}ie(),Z=!1,l=A,v=K,c=B("section","feature-preview"),c.id="feature-preview",c.setAttribute("role","region");let Q=B("h3","preview-title",A.querySelector(".plugin-name").textContent);Q.id="feature-preview-title",c.setAttribute("aria-labelledby",Q.id);let re=B("button","button quiet preview-close",o("\u5173\u95ED","Close"));re.type="button",re.addEventListener("click",()=>ie({restore:v||c.contains(document.activeElement)}));let le=B("div","preview-heading");le.append(Q,re),c.append(le);let be=B("div","preview-media");c.append(be);let Oe=B("dl","preview-details"),at=[o("\u51FA\u73B0\u4F4D\u7F6E","Location"),o("\u89E3\u51B3\u95EE\u9898","Problem"),o("\u64CD\u4F5C\u4E0E\u6548\u679C","Action and result")];q$(A.dataset.featureId,t).forEach((ue,ne)=>{Oe.append(B("dt","",at[ne]),B("dd","",ue))});let He=B("p","preview-resource-state",o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon"));c.append(Oe,He),c.addEventListener("pointerenter",()=>{Z=!0,clearTimeout(h)}),c.addEventListener("pointerleave",()=>{Z=!1,et()}),c.addEventListener("focusin",()=>{clearTimeout(h)}),c.addEventListener("focusout",ue=>{!c?.contains(ue.relatedTarget)&&!l?.contains(ue.relatedTarget)&&ie()}),document.querySelector(".dashboard-surface").append(c),A.classList.add("is-previewing"),e.classList.add("has-preview");let pt=A.querySelector(".preview-entry");pt.setAttribute("aria-expanded","true"),pt.setAttribute("aria-controls",c.id),fe(),Nt(A.dataset.featureId,be,He,y)}function Gt(A){let K=B("button","preview-entry");K.type="button",K.setAttribute("aria-expanded","false"),K.setAttribute("aria-label",`${o("\u67E5\u770B\u6548\u679C","See how it works")} \xB7 ${A.querySelector(".plugin-name").textContent||A.dataset.featureId}`),A.append(K),i(A,"pointerenter",()=>{a.matches&&(N=A,X=A,clearTimeout(m),clearTimeout(h),m=setTimeout(()=>{X=null,mt(A)},200))}),i(A,"pointerleave",()=>{N===A&&(N=null),X===A&&(clearTimeout(m),X=null),et()}),i(K,"focus",()=>{k||mt(A)}),i(K,"click",()=>mt(A,!0)),i(A,"focusout",Q=>{!A.contains(Q.relatedTarget)&&!c?.contains(Q.relatedTarget)&&document.documentElement.dataset.input==="keyboard"&&ie()})}i(document,"keydown",A=>{if(A.key==="Escape"&&l){A.preventDefault();let K=v||c.contains(document.activeElement);ie({restore:K})}}),i(document,"pointerdown",A=>{l&&!l.contains(A.target)&&!c.contains(A.target)&&ie()}),i(window,"scroll",A=>{c?.contains(A.target)||ie()},{capture:!0}),i(window,"resize",()=>ie()),i(document,"visibilitychange",()=>{document.hidden&&ie()}),i(window,"blur",()=>ie()),i(document.querySelector("#data-dialog"),"toggle",()=>ie()),i(document.querySelector("#language-menu"),"toggle",()=>ie()),i(window,"pagehide",()=>{ie(),r.abort()});function $t(A){ie(),t=A,n=t==="zh-CN";for(let K of e.querySelectorAll(".plugin-card"))K.querySelector(".preview-entry")?.setAttribute("aria-label",`${o("\u67E5\u770B\u6548\u679C","See how it works")} \xB7 ${K.querySelector(".plugin-name").textContent}`)}return{attach:Gt,close:ie,setLocale:$t}}var F$=Nr(()=>{V$()});function H$(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 J$=Nr(()=>{});async function gn(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 jv=Nr(()=>{});var kT={};function W$(){document.querySelector("#brand-slogan").textContent=$e==="zh-CN"?"\u8BA9 Codex \u66F4\u987A\u624B\u3002":"Make Codex work better for you.",document.querySelector("#brand-description").textContent=$e==="zh-CN"?"\u6309\u9700\u5F00\u542F\u4EA4\u4E92\u589E\u5F3A\uFF0C\u8BA9\u65E5\u5E38\u4F7F\u7528\u66F4\u9AD8\u6548\u3002":"Enable the enhancements you need for a smoother daily workflow.";let e=document.querySelector("#language-button"),t=$e==="zh-CN"?"\u8BED\u8A00 \xB7 \u4E2D\u6587":"Language \xB7 English";e.setAttribute("aria-label",t),e.setAttribute("data-minecodex-tooltip",t),q.languageToggle.setAttribute("aria-label",$e==="zh-CN"?"\u8BED\u8A00":"Language"),document.querySelector("#language-menu").setAttribute("aria-label",$e==="zh-CN"?"\u8BED\u8A00":"Language");for(let n of q.languageButtons)n.setAttribute("aria-pressed",String(n.dataset.languageChoice===$e));q.restartTitle.textContent=oe.restartTitle,q.restartCopy.textContent=oe.restartCopy,q.restartButton.querySelector(".button-label").textContent=oe.restart,q.pluginsHeading.textContent=oe.plugins,q.errorTitle.textContent=oe.loadError,q.errorCopy.textContent=oe.loadErrorCopy,q.retryButton.textContent=oe.retry,q.versionLabel.textContent=oe.version,q.diagnosticsButton.textContent=oe.copyDiagnostics,q.updateButton.querySelector(".button-label").textContent=oe.checkUpdates}function bT(e){let t=e.state??(e.failure?"failed":e.healthy?"healthy":e.injected?"injected":e.applied?"launching":e.enabled?"restart-required":"stopped"),n=oe.states[t]??oe.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}: ${oe.failureDetail}`:n,className:o}}function Xe(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function yT(e){let t=Xe("article","plugin-card");t.dataset.featureId=e.id;let n=Xe("div","plugin-icon");n.setAttribute("aria-hidden","true");let o=Xe("img");o.alt="",o.width=24,o.height=24,n.append(o);let r=Xe("div","plugin-copy"),i=Xe("div","plugin-title-line"),a=Xe("h3","plugin-name");i.append(a);let s=Xe("p","plugin-description");r.append(i,s);let l=Xe("div","plugin-topline"),c=Xe("label","switch"),d=Xe("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 m=Xe("span","switch-track");m.setAttribute("aria-hidden","true"),c.append(d,m);let h=Xe("span","plugin-state"),f=Xe("span","status-dot");f.setAttribute("aria-hidden","true");let v=Xe("span","plugin-state-label");return v.id=`state-${e.id}`,h.append(f,v),l.append(n,c),t.append(l,r,h),Vi.attach(t),t}function Ud(e,t){for(let d of q.languageButtons)d.disabled=yt.size>0;let n=bT(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=yt.has(t.id),o.setAttribute("aria-label",t.label),s.className=`status-dot ${n.className}`,l.textContent=n.label,e.querySelector(".preview-entry")?.setAttribute("aria-label",`${$e==="zh-CN"?"\u67E5\u770B\u6548\u679C":"See how it works"} \xB7 ${t.label}`)}function Y$(e){return[...q.pluginList.querySelectorAll("[data-feature-id]")].find(t=>t.dataset.featureId===e)??null}function _T(e){e=e.filter(n=>n.id!=="unread-inbox");for(let n of[...q.pluginList.children])n.dataset.featureId||n.remove();let t=new Set(e.map(({id:n})=>n));for(let[n,o]of e.entries()){let r=Y$(o.id);r||(r=yT(o));let i=q.pluginList.children[n];i!==r&&q.pluginList.insertBefore(r,i??null),Ud(r,o)}for(let n of[...q.pluginList.querySelectorAll("[data-feature-id]")])n.dataset.featureId&&!t.has(n.dataset.featureId)&&(n.classList.contains("is-previewing")&&Vi.close(),n.remove());q.pluginList.setAttribute("aria-busy","false")}function X$(){q.versionValue.textContent=Qe?.version??"\u2014",q.restartNotice.hidden=!Qe?.pendingRestart}function $T(){X$(),_T(Qe?.features??[])}function zT(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 K$(e){if(!e?.input)return;Y$(e.featureId)?.querySelector('input[type="checkbox"]')?.focus()}function Dd(e){clearTimeout(B$),q.toast.textContent=e,q.toast.hidden=!1,B$=setTimeout(()=>{q.toast.hidden=!0},4200)}function Av(e,t){Qe.features=Qe.features.map(n=>n.id===e?{...n,...t}:n)}async function Tc(){q.loadError.hidden=!0;try{let e=await gn("/api/status",{headers:{"Accept-Language":$e}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();yt.size&&Qe&&(t.features=t.features.map(n=>yt.has(n.id)?Qe.features.find(o=>o.id===n.id)??n:n)),Qe=t,q.pluginList.hidden=!1,$T()}catch{Vi.close(),q.pluginList.hidden=!0,q.loadError.hidden=!1}}function Fi(){let e=window.minecodexHostTheme?window.minecodexHostTheme==="dark":Q$.matches,t=Zi==="dark"||Zi!=="light"&&e;document.documentElement.dataset.theme=t?"dark":"light",q.themeToggle.setAttribute("aria-label",$e==="zh-CN"?"\u5916\u89C2":"Appearance");for(let n of q.themeButtons){n.dataset.themeChoice=t?"dark":"light",n.querySelector(".ui-icon").className=`ui-icon ${t?"moon":"sun"}-icon`;let o=t?oe.darkAppearance:oe.lightAppearance,r=t?oe.lightAppearance:oe.darkAppearance,i=$e==="zh-CN"?`${o} \xB7 \u5207\u6362\u4E3A${r}`:`${o} \xB7 Switch to ${r.toLowerCase()}`;n.setAttribute("aria-label",i),n.setAttribute("data-minecodex-tooltip",i)}}async function wT(e){if(Uv)return;if(Vi.close(),Zi=document.documentElement.dataset.theme==="dark"?"light":"dark",!window.minecodexMcpApp)try{localStorage.setItem("minecodex-appearance",Zi)}catch{}if(!document.startViewTransition||matchMedia("(prefers-reduced-motion: reduce)").matches){Fi();return}let t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,r=Math.hypot(Math.max(n,innerWidth-n),Math.max(o,innerHeight-o)),i=document.startViewTransition(Fi);Uv=i;try{await i.ready,document.documentElement.animate({clipPath:[`circle(0px at ${n}px ${o}px)`,`circle(${r}px at ${n}px ${o}px)`]},{duration:420,easing:"cubic-bezier(0.23, 1, 0.32, 1)",pseudoElement:"::view-transition-new(root)"}),await i.finished}catch{i.skipTransition()}finally{Uv=null}}var Mv,$e,G$,oe,q,Qe,B$,yt,Vi,Q$,Zi,Uv,Dv,ez=Nr(()=>{F$();J$();jv();try{Mv=localStorage.getItem("minecodex-language")}catch{}$e=["en","zh-CN"].includes(Mv)?Mv:navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en";document.documentElement.lang=$e;G$={en:{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":{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"}},oe=G$[$e],q={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")},Qe=null,B$=null,yt=new Set,Vi=Z$(q.pluginList,$e);q.pluginList.addEventListener("change",async e=>{let t=e.target.closest('input[type="checkbox"]'),n=t?.closest("[data-feature-id]");if(!t||!n||!Qe)return;let o=n.dataset.featureId,r={...Qe.features.find(a=>a.id===o)},i=zT(o);yt.add(o),Av(o,{enabled:t.checked,state:"saved"}),Ud(n,Qe.features.find(a=>a.id===o)),q.saveState.textContent=oe.saving;try{let a=await gn(`/api/features/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json","Accept-Language":$e},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&&Av(o,l),Qe.pendingRestart=s.pendingRestart,yt.delete(o);let c=l??Qe.features.find(d=>d.id===o);c&&Ud(n,c),X$(),K$(i),q.saveState.textContent=yt.size?oe.saving:oe.saved}catch{yt.delete(o),Av(o,r),Ud(n,r),q.saveState.textContent=yt.size?oe.saving:"",K$(i),Dd(oe.changeFailed)}});q.restartButton.addEventListener("click",async()=>{q.restartButton.disabled=!0,q.restartButton.querySelector(".button-label").textContent=oe.restarting;try{let e=await gn("/api/restart",{method:"POST",headers:{"Content-Type":"application/json","Accept-Language":$e},body:"{}"});if(!e.ok)throw new Error(`HTTP ${e.status}`);await Tc()}catch{Dd(oe.restartFailed)}finally{q.restartButton.disabled=!1,q.restartButton.querySelector(".button-label").textContent=oe.restart}});q.retryButton.addEventListener("click",()=>{q.pluginList.hidden=!1,Tc()});q.diagnosticsButton.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(JSON.stringify(H$(Qe),null,2)),Dd(oe.diagnosticsCopied)}catch{Dd(oe.diagnosticsFailed)}});setInterval(()=>{!document.hidden&&!yt.size&&Tc()},5e3);q.updateButton.addEventListener("click",async()=>{q.updateButton.disabled=!0,q.updateButton.querySelector(".button-label").textContent=oe.checkingUpdates,q.updateResult.hidden=!0;try{let e=await gn("/api/update");if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();q.updateResult.textContent=t.available?oe.updateAvailable(t.latest):oe.current,q.updateResult.hidden=!1}catch{q.updateResult.textContent=oe.updateFailed,q.updateResult.hidden=!1}finally{q.updateButton.disabled=!1,q.updateButton.querySelector(".button-label").textContent=oe.checkUpdates}});Q$=matchMedia("(prefers-color-scheme: dark)"),Zi=null;if(!window.minecodexMcpApp)try{Zi=localStorage.getItem("minecodex-appearance")}catch{}Uv=null;q.themeToggle.addEventListener("click",e=>{let t=e.target.closest("[data-theme-choice]");t&&wT(t)});q.languageToggle.addEventListener("click",e=>{let t=e.target.closest("[data-language-choice]");if(!t||yt.size||q.restartButton.disabled)return;let n=t.dataset.languageChoice;if(n!==$e){try{localStorage.setItem("minecodex-language",n)}catch{return}if(Vi.close(),!window.minecodexMcpApp){location.reload();return}$e=n,oe=G$[$e],document.documentElement.lang=$e,Vi.setLocale($e),document.querySelector("#language-menu").hidePopover(),W$(),Fi(),q.updateResult.hidden=!0,q.toast.hidden=!0,window.dispatchEvent(new Event("minecodex-language")),Tc()}});Q$.addEventListener("change",Fi);window.addEventListener("minecodex-host-theme",()=>{Zi=null,Fi()});document.addEventListener("keydown",()=>{document.documentElement.dataset.input="keyboard"});document.addEventListener("pointerdown",()=>{document.documentElement.dataset.input="pointer"});W$();Fi();Tc();Dv=document.querySelector("#language-menu");Dv.addEventListener("toggle",e=>{if(document.querySelector("#language-button").setAttribute("aria-expanded",String(e.newState==="open")),e.newState!=="open")return;let t=document.querySelector("#language-button").getBoundingClientRect();Dv.style.left=`${Math.max(8,Math.min(t.right-140,innerWidth-148))}px`,Dv.style.top=`${t.bottom+8}px`})});function tz(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 uz=Object.defineProperty;var Nr=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var At=(e,t)=>{for(var n in t)uz(e,n,{get:t[n],enumerable:!0})};function q$(e,t){return ST[e]?.[t==="zh-CN"?0:1]??(t==="zh-CN"?["Codex \u4E2D\u5BF9\u5E94\u529F\u80FD\u7684\u4F4D\u7F6E\u3002","\u8BF7\u53C2\u8003\u529F\u80FD\u8BF4\u660E\u3002","\u6548\u679C\u53D6\u51B3\u4E8E\u5F53\u524D\u7248\u672C\u4E0E\u9002\u7528\u9875\u9762\u3002"]:["The feature\u2019s location in Codex.","Refer to the feature description.","Availability depends on the version and current page."])}var ST,V$=Nr(()=>{ST={"model-slider":[["\u8F93\u5165\u6846\u7684\u6A21\u578B\u9009\u62E9\u533A\u57DF\u3002","\u6A21\u578B\u4E0E\u601D\u8003\u6863\u4F4D\u5206\u6563\uFF0C\u5207\u6362\u4E0D\u591F\u76F4\u63A5\u3002","\u6253\u5F00\u6A21\u578B\u7A97\u53E3\uFF0C\u9009\u62E9\u6A21\u578B\u4E0E\u601D\u8003\u6863\u4F4D\uFF1B\u6536\u85CF\u5E38\u7528\u6A21\u578B\u4EE5\u4FBF\u518D\u6B21\u9009\u62E9\u3002"],["The model selector beside the composer.","Switching models and reasoning levels takes extra steps.","Open the model panel, choose a model and reasoning level, and save favorites for quick access."]],notes:[["\u5B98\u65B9 Prompt \u9875\u9762\u4E0E\u8F93\u5165\u6846\u65C1\u7684 Quick Prompts\u3002","\u5E38\u7528\u63D0\u793A\u8BCD\u9700\u8981\u53CD\u590D\u67E5\u627E\u548C\u590D\u5236\u3002","\u6309\u5206\u7C7B\u7BA1\u7406\u63D0\u793A\u8BCD\uFF0C\u4ECE Quick Prompts \u586B\u5165\u5F53\u524D\u8F93\u5165\u6846\uFF1B\u586B\u5165\u540E\u7531\u4F60\u68C0\u67E5\u5E76\u53D1\u9001\u3002"],["The Prompt page and Quick Prompts beside the composer.","Reusable prompts are hard to find and copy repeatedly.","Organize prompts by category and insert one into the current composer. Review it before sending."]],"usage-meter":[["Codex \u4FA7\u680F\u7684\u989D\u5EA6\u73AF\u3002","\u67E5\u770B\u5269\u4F59\u989D\u5EA6\u9700\u8981\u6253\u5F00\u8D26\u53F7\u83DC\u5355\u3002","\u7528\u989D\u5EA6\u73AF\u67E5\u770B\u4F7F\u7528\u6BD4\u4F8B\uFF0C\u70B9\u51FB\u6253\u5F00\u7528\u91CF\u8BE6\u60C5\u3002"],["The usage ring in the Codex sidebar.","Checking remaining usage requires opening the account menu.","Read usage at a glance, then click for usage details."]],"session-status":[["\u5F53\u524D\u4F1A\u8BDD\u7684\u72B6\u6001\u533A\u57DF\u3002","\u4F1A\u8BDD\u7528\u91CF\u4E0E\u751F\u6210\u901F\u5EA6\u4E0D\u5BB9\u6613\u96C6\u4E2D\u67E5\u770B\u3002","\u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\u7684\u7528\u91CF\u3001\u4E0A\u4E0B\u6587\u548C\u751F\u6210\u6307\u6807\uFF1B\u53EF\u7528\u9879\u76EE\u53D6\u51B3\u4E8E\u4F1A\u8BDD\u4E0E\u63D0\u4F9B\u65B9\u3002"],["The current conversation\u2019s status area.","Usage and generation metrics are spread across the interface.","Read session usage, context and generation metrics when supported by the session and provider."]],"markdown-reading":[["Codex \u7684 Markdown \u6587\u4EF6\u9884\u89C8\u3002","\u957F\u6587\u9605\u8BFB\u3001\u811A\u6CE8\u8DF3\u8F6C\u548C\u8868\u683C\u67E5\u770B\u4E0D\u591F\u65B9\u4FBF\u3002","\u5728\u6587\u4EF6\u9884\u89C8\u4E2D\u9605\u8BFB\u589E\u5F3A\u6392\u7248\uFF0C\u4F7F\u7528\u76EE\u5F55\u3001\u811A\u6CE8\u548C\u8868\u683C\u64CD\u4F5C\u3002"],["Markdown file previews in Codex.","Long documents, footnotes and tables take extra effort to read.","Read enhanced formatting and use the outline, footnote navigation and table actions."]],"mermaid-diagrams":[["Markdown \u6587\u4EF6\u9884\u89C8\u4E2D\u7684 Mermaid \u56FE\u8868\u3002","\u5B9E\u9A8C\u6027\u56FE\u8868\u6837\u5F0F\u4E0E\u4EA4\u4E92\u4ECD\u5728\u5B8C\u5584\uFF0C\u9ED8\u8BA4\u5173\u95ED\u3002","\u6309\u9700\u5F00\u542F\u56FE\u8868\u589E\u5F3A\uFF0C\u4F7F\u7528\u7F29\u653E\u548C PNG \u4E0B\u8F7D\uFF1B\u5173\u95ED\u540E\u4F7F\u7528 Codex \u539F\u751F\u56FE\u8868\u3002"],["Mermaid diagrams in Markdown file previews.","Enhanced diagram styles and interactions are experimental and off by default.","Opt in to diagram zoom and PNG download. Turn it off to use native Codex diagrams."]],"file-navigation":[["Codex \u6587\u4EF6\u9884\u89C8\u4E0A\u65B9\u7684\u8DEF\u5F84\u533A\u57DF\u3002","\u6D4F\u89C8\u76F8\u90BB\u76EE\u5F55\u548C\u6587\u4EF6\u9700\u8981\u989D\u5916\u8DF3\u8F6C\u3002","\u70B9\u51FB\u8DEF\u5F84\u5C55\u5F00\u5206\u5217\u76EE\u5F55\uFF0C\u9010\u7EA7\u6D4F\u89C8\u5E76\u6253\u5F00\u53E6\u4E00\u4E2A\u6587\u4EF6\u3002"],["The path above a file preview in Codex.","Browsing nearby files and folders takes extra navigation.","Open the path to browse cascading folder columns and choose another file."]],images:[["Codex Library \u7684\u56FE\u7247\u96C6\u5408\u4E0E\u56FE\u7247\u67E5\u770B\u5668\u3002","\u67E5\u627E\u56FE\u7247\u53CA\u5176\u63D0\u793A\u8BCD\u9700\u8981\u6765\u56DE\u5207\u6362\u3002","\u6D4F\u89C8\u56FE\u7247\u96C6\u5408\uFF0C\u6253\u5F00\u56FE\u7247\u67E5\u770B\u5927\u56FE\u53CA\u53EF\u8FFD\u6EAF\u7684\u63D0\u793A\u8BCD\u4FE1\u606F\u3002"],["Image collections in Codex Library and the image viewer.","Finding images and their prompts requires switching views.","Browse collections, open an image, and inspect available prompt provenance."]],sites:[["Codex \u4E2D\u7684 Sites \u9875\u9762\u3002","\u672C\u5730\u9879\u76EE\u4E0E\u5E38\u7528\u7F51\u5740\u5206\u6563\u5728\u4E0D\u540C\u4F4D\u7F6E\u3002","\u6536\u85CF\u7F51\u5740\u3001\u53D1\u73B0\u6B63\u5728\u8FD0\u884C\u7684\u672C\u5730\u7AD9\u70B9\uFF0C\u5E76\u4ECE Sites \u6253\u5F00\u3002"],["The Sites page in Codex.","Local projects and saved links are scattered.","Save URLs, discover running local sites, and open them from Sites."]],"composer-expand":[["Work \u4E0E Codex \u7684\u8F93\u5165\u6846\u53F3\u4E0A\u89D2\u3002","\u957F\u6307\u4EE4\u53D7\u8F93\u5165\u6846\u9AD8\u5EA6\u9650\u5236\uFF0C\u7F16\u8F91\u65F6\u9700\u8981\u53CD\u590D\u6EDA\u52A8\u3002","\u8F93\u5165\u591A\u884C\u6587\u5B57\u540E\u70B9\u51FB\u5C55\u5F00\uFF1B\u7F16\u8F91\u5B8C\u6210\u540E\u6536\u8D77\uFF0C\u8349\u7A3F\u4FDD\u6301\u4E0D\u53D8\u3002"],["The upper-right corner of the Work and Codex composer.","Long drafts need repeated scrolling in a compact editor.","Enter a multiline draft and click Expand. Collapse when finished; your draft stays in place."]],"quick-chat":[["Codex \u7684\u6D6E\u52A8 Quick Chat \u7A97\u53E3\u3002","\u4E34\u65F6\u63D0\u95EE\u65F6\u9700\u8981\u5207\u6362\u4E3B\u7A97\u53E3\uFF0C\u5386\u53F2\u4E0D\u6613\u7EE7\u7EED\u3002","\u4ECE\u4FA7\u680F\u6216\u5FEB\u6377\u952E\u6253\u5F00 Quick Chat\uFF0C\u53D1\u9001\u540E\u5C55\u5F00\uFF0C\u6062\u590D\u6700\u5C0F\u5316\u8F93\u5165\u6846\u5E76\u67E5\u770B\u5386\u53F2\u3002"],["The floating Quick Chat window.","Quick questions and continuing recent chats require window switching.","Open Quick Chat from the sidebar or shortcut, expand after sending, restore a minimized composer and browse history."]],"sidebar-focus":[["Codex \u5DE6\u4FA7\u680F\u7684\u5206\u7EC4\u6807\u9898\u3002","\u591A\u4E2A\u4FA7\u680F\u5206\u7EC4\u5C55\u5F00\u65F6\uFF0C\u5F53\u524D\u5206\u7EC4\u4E0D\u5BB9\u6613\u805A\u7126\u3002","\u70B9\u51FB\u5F53\u524D\u5206\u7EC4\uFF0C\u4E00\u952E\u6536\u8D77\u5176\u4ED6\u5206\u7EC4\uFF1B\u518D\u6B21\u70B9\u51FB\u6062\u590D\u5148\u524D\u7684\u5C55\u5F00\u72B6\u6001\u3002"],["Group headings in the Codex sidebar.","Several expanded groups make the current group harder to focus on.","Click a group to collapse other groups. Click again to restore their previous expanded state."]],"hide-upsell-banner":[["Codex \u7684\u989D\u5EA6\u63A8\u5E7F\u63D0\u793A\u533A\u57DF\u3002","\u63A8\u5E7F\u63D0\u793A\u5360\u7528\u65E5\u5E38\u64CD\u4F5C\u7A7A\u95F4\u3002","\u9690\u85CF\u989D\u5EA6\u63A8\u5E7F\u63D0\u793A\uFF0C\u4FDD\u7559\u771F\u5B9E\u989D\u5EA6\u4E0E\u8FD0\u884C\u9519\u8BEF\u53CD\u9988\u3002"],["Usage promotion banners in Codex.","Promotions take space during everyday tasks.","Hide usage promotions while retaining real usage and error feedback."]]}});function Z$(e,t){let n=t==="zh-CN",o=(A,K)=>n?A:K,r=new AbortController,i=(A,K,Q,re={})=>A.addEventListener(K,Q,{...re,signal:r.signal}),a=matchMedia("(hover: hover) and (pointer: fine)"),s=matchMedia("(prefers-reduced-motion: reduce)"),l=null,c=null,d=null,m,h,f,v=!1,y=0,k=!1,T=null,R,N=null,Z=!1,X=null,M=()=>R??=window.minecodexPreviewMedia!==void 0?Promise.resolve(window.minecodexPreviewMedia):fetch("/assets/previews/manifest.json").then(A=>A.ok?A.json():{}).then(A=>A&&typeof A=="object"?A:{}).catch(()=>({})),B=(A,K,Q)=>{let re=document.createElement(A);return re.className=K,Q&&(re.textContent=Q),re};async function De(A,K,Q,re){if(!window.minecodexMcpApp)return`/assets/previews/${Q}`;let be=(await window.minecodexMcpApp.readServerResource({uri:`resource://minecodex/previews/${A}/${K}`},{signal:re})).contents?.[0];if(!be?.blob)throw new Error("Preview resource unavailable");return`data:${be.mimeType};base64,${be.blob}`}function ie({restore:A=!1}={}){clearTimeout(m),clearTimeout(h),clearTimeout(f),y++,T?.abort(),T=null;let K=c,Q=l,re=d;c=null,l=null,d=null,v=!1,re&&(re.pause(),re.removeAttribute("src"),re.load());let le=Q?.querySelector(".preview-entry");le?.setAttribute("aria-expanded","false"),le?.removeAttribute("aria-controls"),Q?.classList.remove("is-previewing"),e.classList.remove("has-preview"),K?.remove(),A&&le?.isConnected&&(k=!0,le.focus({preventScroll:!0}),k=!1)}function fe(){if(!l||!c)return;let A=l.getBoundingClientRect(),K=Math.min(360,innerWidth-32);c.style.width=`${K}px`,c.style.maxHeight=`${Math.max(120,innerHeight-32)}px`;let Q=c.getBoundingClientRect().height,re,le;if(innerWidth-A.right>=K+24)re=A.right+8;else if(A.left>=K+24)re=A.left-K-8;else{re=Math.max(16,Math.min(A.left,innerWidth-K-16));let be=innerHeight-A.bottom-24,Oe=A.top-24;be>=Math.min(Q,180)?(c.style.maxHeight=`${be}px`,le=A.bottom+8):Oe>=Math.min(Q,180)?(c.style.maxHeight=`${Oe}px`,le=Math.max(16,A.top-Q-8)):(le=Math.max(16,A.top+l.querySelector(".plugin-topline").getBoundingClientRect().height+32),c.style.maxHeight=`${Math.max(100,innerHeight-le-16)}px`)}le??=Math.max(16,Math.min(A.top,innerHeight-Q-16)),Object.assign(c.style,{left:`${re}px`,top:`${le}px`,visibility:"visible"})}function et(){!v&&!N&&!Z&&(h=setTimeout(()=>ie(),100))}async function Nt(A,K,Q,re){let le=(await M())?.[A];if(re!==y||!c||!le)return;T=new AbortController;let be=T.signal,Oe,at,He=!1;Q.textContent=o("\u6B63\u5728\u52A0\u8F7D\u9884\u89C8\u2026","Loading preview\u2026");let pt=await Promise.all(["poster","video"].map(async jt=>{if(!le[jt])return null;try{return await De(A,jt,le[jt],be)}catch{return He=!0,null}}));if(re!==y)return;[Oe,at]=pt,Q.textContent=He?o("\u8D44\u6E90\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Preview unavailable \xB7 See description"):o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon");let ue=null;if(Oe&&(ue=B("img","preview-poster"),ue.alt=o("\u529F\u80FD\u9759\u6001\u9884\u89C8","Static feature preview"),ue.addEventListener("load",fe,{once:!0}),ue.addEventListener("error",()=>{ue.remove(),He=!0,d||(Q.textContent=o("\u8D44\u6E90\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Preview unavailable \xB7 See description")),fe()},{once:!0}),ue.src=Oe,K.append(ue),Q.textContent=o("\u9759\u6001\u9884\u89C8","Static preview")),!at){fe();return}if(s.matches){fe();return}let ne=B("video","preview-video");d=ne,ne.muted=!0,ne.playsInline=!0,ne.preload="metadata",ne.hidden=!0;let zt=()=>{c.classList.remove("is-media-only"),ue&&(ue.hidden=!1)},zr=()=>{re===y&&(clearTimeout(f),ne.pause(),ne.removeAttribute("src"),ne.load(),ne.remove(),d=null,zt(),Q.textContent=ue?.isConnected?o("\u89C6\u9891\u6682\u4E0D\u53EF\u7528 \xB7 \u9759\u6001\u9884\u89C8","Video unavailable \xB7 Static preview"):o("\u89C6\u9891\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Video unavailable \xB7 See description"),fe())};ne.addEventListener("error",zr,{once:!0}),ne.addEventListener("loadeddata",()=>{re===y&&fe()}),ne.addEventListener("play",()=>{re===y&&(ne.hidden=!1,ue&&(ue.hidden=!0),c.classList.add("is-media-only"),fe())});let Wt=async()=>{if(re===y)try{await ne.play()}catch{re===y&&d===ne&&ne.isConnected&&(ne.hidden=!0,zt(),Q.textContent=ue?.isConnected?o("\u9759\u6001\u9884\u89C8","Static preview"):o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon"),fe())}};ne.addEventListener("ended",()=>{clearTimeout(f),f=setTimeout(()=>{re!==y||d!==ne||(ne.currentTime=0,Wt())},2e3)}),K.append(ne),Q.textContent=o("\u6B63\u5728\u52A0\u8F7D\u6F14\u793A\u2026","Loading demo\u2026"),ne.src=at,Wt(),fe()}function mt(A,K=!1){if(clearTimeout(m),clearTimeout(h),A===l){v||=K;return}ie(),Z=!1,l=A,v=K,c=B("section","feature-preview"),c.id="feature-preview",c.setAttribute("role","region");let Q=B("h3","preview-title",A.querySelector(".plugin-name").textContent);Q.id="feature-preview-title",c.setAttribute("aria-labelledby",Q.id);let re=B("button","button quiet preview-close",o("\u5173\u95ED","Close"));re.type="button",re.addEventListener("click",()=>ie({restore:v||c.contains(document.activeElement)}));let le=B("div","preview-heading");le.append(Q,re),c.append(le);let be=B("div","preview-media");c.append(be);let Oe=B("dl","preview-details"),at=[o("\u51FA\u73B0\u4F4D\u7F6E","Location"),o("\u89E3\u51B3\u95EE\u9898","Problem"),o("\u64CD\u4F5C\u4E0E\u6548\u679C","Action and result")];q$(A.dataset.featureId,t).forEach((ue,ne)=>{Oe.append(B("dt","",at[ne]),B("dd","",ue))});let He=B("p","preview-resource-state",o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon"));c.append(Oe,He),c.addEventListener("pointerenter",()=>{Z=!0,clearTimeout(h)}),c.addEventListener("pointerleave",()=>{Z=!1,et()}),c.addEventListener("focusin",()=>{clearTimeout(h)}),c.addEventListener("focusout",ue=>{!c?.contains(ue.relatedTarget)&&!l?.contains(ue.relatedTarget)&&ie()}),document.querySelector(".dashboard-surface").append(c),A.classList.add("is-previewing"),e.classList.add("has-preview");let pt=A.querySelector(".preview-entry");pt.setAttribute("aria-expanded","true"),pt.setAttribute("aria-controls",c.id),fe(),Nt(A.dataset.featureId,be,He,y)}function Gt(A){let K=B("button","preview-entry");K.type="button",K.setAttribute("aria-expanded","false"),K.setAttribute("aria-label",`${o("\u67E5\u770B\u6548\u679C","See how it works")} \xB7 ${A.querySelector(".plugin-name").textContent||A.dataset.featureId}`),A.append(K),i(A,"pointerenter",()=>{a.matches&&(N=A,X=A,clearTimeout(m),clearTimeout(h),m=setTimeout(()=>{X=null,mt(A)},200))}),i(A,"pointerleave",()=>{N===A&&(N=null),X===A&&(clearTimeout(m),X=null),et()}),i(K,"focus",()=>{k||mt(A)}),i(K,"click",()=>mt(A,!0)),i(A,"focusout",Q=>{!A.contains(Q.relatedTarget)&&!c?.contains(Q.relatedTarget)&&document.documentElement.dataset.input==="keyboard"&&ie()})}i(document,"keydown",A=>{if(A.key==="Escape"&&l){A.preventDefault();let K=v||c.contains(document.activeElement);ie({restore:K})}}),i(document,"pointerdown",A=>{l&&!l.contains(A.target)&&!c.contains(A.target)&&ie()}),i(window,"scroll",A=>{c?.contains(A.target)||ie()},{capture:!0}),i(window,"resize",()=>ie()),i(document,"visibilitychange",()=>{document.hidden&&ie()}),i(window,"blur",()=>ie()),i(document.querySelector("#data-dialog"),"toggle",()=>ie()),i(document.querySelector("#language-menu"),"toggle",()=>ie()),i(window,"pagehide",()=>{ie(),r.abort()});function $t(A){ie(),t=A,n=t==="zh-CN";for(let K of e.querySelectorAll(".plugin-card"))K.querySelector(".preview-entry")?.setAttribute("aria-label",`${o("\u67E5\u770B\u6548\u679C","See how it works")} \xB7 ${K.querySelector(".plugin-name").textContent}`)}return{attach:Gt,close:ie,setLocale:$t}}var F$=Nr(()=>{V$()});function H$(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 J$=Nr(()=>{});async function gn(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 jv=Nr(()=>{});var kT={};function W$(){document.querySelector("#brand-slogan").textContent=$e==="zh-CN"?"\u8BA9 Codex \u66F4\u987A\u624B\u3002":"Make Codex work better for you.",document.querySelector("#brand-description").textContent=$e==="zh-CN"?"\u6309\u9700\u5F00\u542F\u4EA4\u4E92\u589E\u5F3A\uFF0C\u8BA9\u65E5\u5E38\u4F7F\u7528\u66F4\u9AD8\u6548\u3002":"Enable the enhancements you need for a smoother daily workflow.";let e=document.querySelector("#language-button"),t=$e==="zh-CN"?"\u8BED\u8A00 \xB7 \u4E2D\u6587":"Language \xB7 English";e.setAttribute("aria-label",t),e.setAttribute("data-minecodex-tooltip",t),q.languageToggle.setAttribute("aria-label",$e==="zh-CN"?"\u8BED\u8A00":"Language"),document.querySelector("#language-menu").setAttribute("aria-label",$e==="zh-CN"?"\u8BED\u8A00":"Language");for(let n of q.languageButtons)n.setAttribute("aria-pressed",String(n.dataset.languageChoice===$e));q.restartTitle.textContent=oe.restartTitle,q.restartCopy.textContent=oe.restartCopy,q.restartButton.querySelector(".button-label").textContent=oe.restart,q.pluginsHeading.textContent=oe.plugins,q.errorTitle.textContent=oe.loadError,q.errorCopy.textContent=oe.loadErrorCopy,q.retryButton.textContent=oe.retry,q.versionLabel.textContent=oe.version,q.diagnosticsButton.textContent=oe.copyDiagnostics,q.updateButton.querySelector(".button-label").textContent=oe.checkUpdates}function bT(e){let t=e.state??(e.failure?"failed":e.healthy?"healthy":e.injected?"injected":e.applied?"launching":e.enabled?"restart-required":"stopped"),n=oe.states[t]??oe.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}: ${oe.failureDetail}`:n,className:o}}function Xe(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function yT(e){let t=Xe("article","plugin-card");t.dataset.featureId=e.id;let n=Xe("div","plugin-icon");n.setAttribute("aria-hidden","true");let o=Xe("img");o.alt="",o.width=24,o.height=24,n.append(o);let r=Xe("div","plugin-copy"),i=Xe("div","plugin-title-line"),a=Xe("h3","plugin-name");i.append(a);let s=Xe("p","plugin-description");r.append(i,s);let l=Xe("div","plugin-topline"),c=Xe("label","switch"),d=Xe("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 m=Xe("span","switch-track");m.setAttribute("aria-hidden","true"),c.append(d,m);let h=Xe("span","plugin-state"),f=Xe("span","status-dot");f.setAttribute("aria-hidden","true");let v=Xe("span","plugin-state-label");return v.id=`state-${e.id}`,h.append(f,v),l.append(n,c),t.append(l,r,h),Vi.attach(t),t}function Ud(e,t){for(let d of q.languageButtons)d.disabled=yt.size>0;let n=bT(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=yt.has(t.id),o.setAttribute("aria-label",t.label),s.className=`status-dot ${n.className}`,l.textContent=n.label,e.querySelector(".preview-entry")?.setAttribute("aria-label",`${$e==="zh-CN"?"\u67E5\u770B\u6548\u679C":"See how it works"} \xB7 ${t.label}`)}function Y$(e){return[...q.pluginList.querySelectorAll("[data-feature-id]")].find(t=>t.dataset.featureId===e)??null}function _T(e){e=e.filter(n=>n.id!=="unread-inbox");for(let n of[...q.pluginList.children])n.dataset.featureId||n.remove();let t=new Set(e.map(({id:n})=>n));for(let[n,o]of e.entries()){let r=Y$(o.id);r||(r=yT(o));let i=q.pluginList.children[n];i!==r&&q.pluginList.insertBefore(r,i??null),Ud(r,o)}for(let n of[...q.pluginList.querySelectorAll("[data-feature-id]")])n.dataset.featureId&&!t.has(n.dataset.featureId)&&(n.classList.contains("is-previewing")&&Vi.close(),n.remove());q.pluginList.setAttribute("aria-busy","false")}function X$(){q.versionValue.textContent=Qe?.version??"\u2014",q.restartNotice.hidden=!Qe?.pendingRestart}function $T(){X$(),_T(Qe?.features??[])}function zT(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 K$(e){if(!e?.input)return;Y$(e.featureId)?.querySelector('input[type="checkbox"]')?.focus()}function Dd(e){clearTimeout(B$),q.toast.textContent=e,q.toast.hidden=!1,B$=setTimeout(()=>{q.toast.hidden=!0},4200)}function Av(e,t){Qe.features=Qe.features.map(n=>n.id===e?{...n,...t}:n)}async function Tc(){q.loadError.hidden=!0;try{let e=await gn("/api/status",{headers:{"Accept-Language":$e}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();yt.size&&Qe&&(t.features=t.features.map(n=>yt.has(n.id)?Qe.features.find(o=>o.id===n.id)??n:n)),Qe=t,q.pluginList.hidden=!1,$T()}catch{Vi.close(),q.pluginList.hidden=!0,q.loadError.hidden=!1}}function Fi(){let e=window.minecodexHostTheme?window.minecodexHostTheme==="dark":Q$.matches,t=Zi==="dark"||Zi!=="light"&&e;document.documentElement.dataset.theme=t?"dark":"light",q.themeToggle.setAttribute("aria-label",$e==="zh-CN"?"\u5916\u89C2":"Appearance");for(let n of q.themeButtons){n.dataset.themeChoice=t?"dark":"light",n.querySelector(".ui-icon").className=`ui-icon ${t?"moon":"sun"}-icon`;let o=t?oe.darkAppearance:oe.lightAppearance,r=t?oe.lightAppearance:oe.darkAppearance,i=$e==="zh-CN"?`${o} \xB7 \u5207\u6362\u4E3A${r}`:`${o} \xB7 Switch to ${r.toLowerCase()}`;n.setAttribute("aria-label",i),n.setAttribute("data-minecodex-tooltip",i)}}async function wT(e){if(Uv)return;if(Vi.close(),Zi=document.documentElement.dataset.theme==="dark"?"light":"dark",!window.minecodexMcpApp)try{localStorage.setItem("minecodex-appearance",Zi)}catch{}if(!document.startViewTransition||matchMedia("(prefers-reduced-motion: reduce)").matches){Fi();return}let t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,r=Math.hypot(Math.max(n,innerWidth-n),Math.max(o,innerHeight-o)),i=document.startViewTransition(Fi);Uv=i;try{await i.ready,document.documentElement.animate({clipPath:[`circle(0px at ${n}px ${o}px)`,`circle(${r}px at ${n}px ${o}px)`]},{duration:420,easing:"cubic-bezier(0.23, 1, 0.32, 1)",pseudoElement:"::view-transition-new(root)"}),await i.finished}catch{i.skipTransition()}finally{Uv=null}}var Mv,$e,G$,oe,q,Qe,B$,yt,Vi,Q$,Zi,Uv,Dv,ez=Nr(()=>{F$();J$();jv();try{Mv=localStorage.getItem("minecodex-language")}catch{}$e=["en","zh-CN"].includes(Mv)?Mv:navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en";document.documentElement.lang=$e;G$={en:{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":{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"}},oe=G$[$e],q={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")},Qe=null,B$=null,yt=new Set,Vi=Z$(q.pluginList,$e);q.pluginList.addEventListener("change",async e=>{let t=e.target.closest('input[type="checkbox"]'),n=t?.closest("[data-feature-id]");if(!t||!n||!Qe)return;let o=n.dataset.featureId,r={...Qe.features.find(a=>a.id===o)},i=zT(o);yt.add(o),Av(o,{enabled:t.checked,state:"saved"}),Ud(n,Qe.features.find(a=>a.id===o)),q.saveState.textContent=oe.saving;try{let a=await gn(`/api/features/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json","Accept-Language":$e},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&&Av(o,l),Qe.pendingRestart=s.pendingRestart,yt.delete(o);let c=l??Qe.features.find(d=>d.id===o);c&&Ud(n,c),X$(),K$(i),q.saveState.textContent=yt.size?oe.saving:oe.saved}catch{yt.delete(o),Av(o,r),Ud(n,r),q.saveState.textContent=yt.size?oe.saving:"",K$(i),Dd(oe.changeFailed)}});q.restartButton.addEventListener("click",async()=>{q.restartButton.disabled=!0,q.restartButton.querySelector(".button-label").textContent=oe.restarting;try{let e=await gn("/api/restart",{method:"POST",headers:{"Content-Type":"application/json","Accept-Language":$e},body:"{}"});if(!e.ok)throw new Error(`HTTP ${e.status}`);await Tc()}catch{Dd(oe.restartFailed)}finally{q.restartButton.disabled=!1,q.restartButton.querySelector(".button-label").textContent=oe.restart}});q.retryButton.addEventListener("click",()=>{q.pluginList.hidden=!1,Tc()});q.diagnosticsButton.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(JSON.stringify(H$(Qe),null,2)),Dd(oe.diagnosticsCopied)}catch{Dd(oe.diagnosticsFailed)}});setInterval(()=>{!document.hidden&&!yt.size&&Tc()},5e3);q.updateButton.addEventListener("click",async()=>{q.updateButton.disabled=!0,q.updateButton.querySelector(".button-label").textContent=oe.checkingUpdates,q.updateResult.hidden=!0;try{let e=await gn("/api/update");if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();q.updateResult.textContent=t.available?oe.updateAvailable(t.latest):oe.current,q.updateResult.hidden=!1}catch{q.updateResult.textContent=oe.updateFailed,q.updateResult.hidden=!1}finally{q.updateButton.disabled=!1,q.updateButton.querySelector(".button-label").textContent=oe.checkUpdates}});Q$=matchMedia("(prefers-color-scheme: dark)"),Zi=null;if(!window.minecodexMcpApp)try{Zi=localStorage.getItem("minecodex-appearance")}catch{}Uv=null;q.themeToggle.addEventListener("click",e=>{let t=e.target.closest("[data-theme-choice]");t&&wT(t)});q.languageToggle.addEventListener("click",e=>{let t=e.target.closest("[data-language-choice]");if(!t||yt.size||q.restartButton.disabled)return;let n=t.dataset.languageChoice;if(n!==$e){try{localStorage.setItem("minecodex-language",n)}catch{return}if(Vi.close(),!window.minecodexMcpApp){location.reload();return}$e=n,oe=G$[$e],document.documentElement.lang=$e,Vi.setLocale($e),document.querySelector("#language-menu").hidePopover(),W$(),Fi(),q.updateResult.hidden=!0,q.toast.hidden=!0,window.dispatchEvent(new Event("minecodex-language")),Tc()}});Q$.addEventListener("change",Fi);window.addEventListener("minecodex-host-theme",()=>{Zi=null,Fi()});document.addEventListener("keydown",()=>{document.documentElement.dataset.input="keyboard"});document.addEventListener("pointerdown",()=>{document.documentElement.dataset.input="pointer"});W$();Fi();Tc();Dv=document.querySelector("#language-menu");Dv.addEventListener("toggle",e=>{if(document.querySelector("#language-button").setAttribute("aria-expanded",String(e.newState==="open")),e.newState!=="open")return;let t=document.querySelector("#language-button").getBoundingClientRect();Dv.style.left=`${Math.max(8,Math.min(t.right-140,innerWidth-148))}px`,Dv.style.top=`${t.bottom+8}px`})});function tz(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`)}),hj=p.object({method:p.literal("ui/request-display-mode"),params:p.object({mode:Pc.describe("The display mode being requested.")})}),dT=p.object({mode:Pc.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),mT=p.union([p.literal("model"),p.literal("app")]).describe("Tool visibility scope - who can access the tool."),gj=p.object({resourceUri:p.string().optional(),visibility:p.array(mT).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:p.never().optional(),permissions:p.never().optional()}),vj=p.object({mimeTypes:p.array(p.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Sj=p.object({method:p.literal("ui/download-file"),params:p.object({contents:p.array(p.union([un,dn])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),bj=p.object({method:p.literal("ui/message"),params:p.object({role:p.literal("user").describe('Message role, currently only "user" is supported.'),content:p.array(Ct).describe("Message content blocks (text, image, etc.).")})}),yj=p.object({method:p.literal("ui/notifications/sandbox-resource-ready"),params:p.object({html:p.string().describe("HTML content to load into the inner iframe."),sandbox:p.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Ov.optional().describe("CSP configuration from resource metadata."),permissions:Nv.optional().describe("Sandbox permissions from resource metadata.")})}),pT=p.object({method:p.literal("ui/notifications/tool-result"),params:yr.describe("Standard MCP tool execution result.")}),L$=p.object({toolInfo:p.object({id:bt.optional().describe("JSON-RPC id of the tools/call request."),tool:br.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:WP.optional().describe("Current color theme preference."),styles:aT.optional().describe("Style configuration for theming the app."),displayMode:Pc.optional().describe("How the UI is currently displayed."),availableDisplayModes:p.array(Pc).optional().describe("Display modes the host supports."),containerDimensions:p.union([p.object({height:p.number().describe("Fixed container height in pixels.")}),p.object({maxHeight:p.union([p.number(),p.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(p.union([p.object({width:p.number().describe("Fixed container width in pixels.")}),p.object({maxWidth:p.union([p.number(),p.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:p.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:p.string().optional().describe("User's timezone in IANA format."),userAgent:p.string().optional().describe("Host application identifier."),platform:p.union([p.literal("web"),p.literal("desktop"),p.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p.object({touch:p.boolean().optional().describe("Whether the device supports touch input."),hover:p.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p.object({top:p.number().describe("Top safe area inset in pixels."),right:p.number().describe("Right safe area inset in pixels."),bottom:p.number().describe("Bottom safe area inset in pixels."),left:p.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fT=p.object({method:p.literal("ui/notifications/host-context-changed"),params:L$.describe("Partial context update containing only changed fields.")}),_j=p.object({method:p.literal("ui/update-model-context"),params:p.object({content:p.array(Ct).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:p.record(p.string(),p.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),$j=p.object({method:p.literal("ui/initialize"),params:p.object({appInfo:Tt.describe("App identification (name and version)."),appCapabilities:uT.describe("Features and capabilities this app provides."),protocolVersion:p.string().describe("Protocol version this app supports.")})}),hT=p.object({protocolVersion:p.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Tt.describe("Host application identification and version."),hostCapabilities:lT.describe("Features and capabilities provided by the host."),hostContext:L$.describe("Rich context about the host environment.")}).passthrough(),gT={target:"draft-2020-12"};async function D$(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](gT);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 M$(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 vT(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 Pv{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Tv;_methods=new Ev;setRequestHandler=(...t)=>{let[n,...o]=A$("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...o)};setNotificationHandler=(...t)=>{let[n,...o]=A$("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:rT,toolinputpartial:nT,toolresult:pT,toolcancelled:iT,hostcontextchanged:fT};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&&p.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=vT(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 m=s.inputSchema,h=m?await M$(m,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 M$(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 D$(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(i.outputSchema=await D$(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:sT.shape.params,result:cT},(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},tT,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},Sr,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},QP,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},eT,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},dT,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 Cv(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:KP}},hT,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.39"});Oc.ontoolresult=()=>{};await Oc.connect();window.minecodexMcpApp=Oc;function cz(e){Object.hasOwn(e??{},"theme")&&(window.minecodexHostTheme=e?.theme,window.dispatchEvent(new Event("minecodex-host-theme")))}Oc.addEventListener("hostcontextchanged",cz);cz(Oc.getHostContext());await Promise.resolve().then(()=>(ez(),kT));await Promise.resolve().then(()=>(sz(),TT));
|
|
107
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:p.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:p.string().optional().describe("User's timezone in IANA format."),userAgent:p.string().optional().describe("Host application identifier."),platform:p.union([p.literal("web"),p.literal("desktop"),p.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p.object({touch:p.boolean().optional().describe("Whether the device supports touch input."),hover:p.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p.object({top:p.number().describe("Top safe area inset in pixels."),right:p.number().describe("Right safe area inset in pixels."),bottom:p.number().describe("Bottom safe area inset in pixels."),left:p.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fT=p.object({method:p.literal("ui/notifications/host-context-changed"),params:L$.describe("Partial context update containing only changed fields.")}),_j=p.object({method:p.literal("ui/update-model-context"),params:p.object({content:p.array(Ct).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:p.record(p.string(),p.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),$j=p.object({method:p.literal("ui/initialize"),params:p.object({appInfo:Tt.describe("App identification (name and version)."),appCapabilities:uT.describe("Features and capabilities this app provides."),protocolVersion:p.string().describe("Protocol version this app supports.")})}),hT=p.object({protocolVersion:p.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Tt.describe("Host application identification and version."),hostCapabilities:lT.describe("Features and capabilities provided by the host."),hostContext:L$.describe("Rich context about the host environment.")}).passthrough(),gT={target:"draft-2020-12"};async function D$(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](gT);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 M$(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 vT(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 Pv{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Tv;_methods=new Ev;setRequestHandler=(...t)=>{let[n,...o]=A$("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...o)};setNotificationHandler=(...t)=>{let[n,...o]=A$("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:rT,toolinputpartial:nT,toolresult:pT,toolcancelled:iT,hostcontextchanged:fT};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&&p.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=vT(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 m=s.inputSchema,h=m?await M$(m,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 M$(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 D$(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(i.outputSchema=await D$(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:sT.shape.params,result:cT},(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},tT,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},Sr,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},QP,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},eT,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},dT,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 Cv(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:KP}},hT,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.42"});Oc.ontoolresult=()=>{};await Oc.connect();window.minecodexMcpApp=Oc;function cz(e){Object.hasOwn(e??{},"theme")&&(window.minecodexHostTheme=e?.theme,window.dispatchEvent(new Event("minecodex-host-theme")))}Oc.addEventListener("hostcontextchanged",cz);cz(Oc.getHostContext());await Promise.resolve().then(()=>(ez(),kT));await Promise.resolve().then(()=>(sz(),TT));
|
|
108
108
|
/*! Bundled license information:
|
|
109
109
|
|
|
110
110
|
@modelcontextprotocol/client/dist/src-WCy6ifGf.mjs:
|