mcp-apps-inspector 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ import type { DiagnosticsResponse } from '../config.js';
2
+ export declare class PreviewDiagnostics {
3
+ private events;
4
+ private cursor;
5
+ private lastProbeReadyAt;
6
+ captureRequestDetails: boolean;
7
+ add(input: unknown): boolean;
8
+ read(after: number): DiagnosticsResponse;
9
+ }
10
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function renderPreviewProbe(shellOrigin: string, captureEnabled?: boolean): string;
2
+ //# sourceMappingURL=probe.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { WorkbenchPreviewHandle, WorkbenchPreviewOptions } from '../types.js';
2
+ /** Starts the workbench local preview shell (reusing the inspector React UI) and guest static server. */
3
+ export declare function startWorkbenchPreview(options: WorkbenchPreviewOptions): Promise<WorkbenchPreviewHandle>;
4
+ //# sourceMappingURL=workbench.d.ts.map
package/dist/types.d.ts CHANGED
@@ -22,4 +22,33 @@ export interface InspectorHandle {
22
22
  appWindow: boolean;
23
23
  close(): Promise<void>;
24
24
  }
25
+ export interface WorkbenchPreviewCsp {
26
+ connectDomains?: readonly string[];
27
+ resourceDomains?: readonly string[];
28
+ frameDomains?: readonly string[];
29
+ baseUriDomains?: readonly string[];
30
+ }
31
+ export interface WorkbenchPreviewEntry {
32
+ path: string;
33
+ csp?: WorkbenchPreviewCsp;
34
+ }
35
+ export interface WorkbenchPreviewOptions {
36
+ /** Path to the workbench directory containing `web/`. */
37
+ workbenchDir: string;
38
+ /** Initial takeover HTML entry and optional CSP domains. */
39
+ initialEntry: WorkbenchPreviewEntry;
40
+ /** Port for the shell server; defaults to an ephemeral loopback port (0). */
41
+ port?: number;
42
+ /** Opens the preview window; defaults to false. */
43
+ open?: boolean;
44
+ /** Closes the server when aborted. */
45
+ signal?: AbortSignal;
46
+ log?: InspectorLogger;
47
+ }
48
+ export interface WorkbenchPreviewHandle {
49
+ /** Loopback URL with session token in the fragment, e.g. `http://127.0.0.1:54321/#token=...`. */
50
+ url: string;
51
+ setEntry(next: WorkbenchPreviewEntry): void;
52
+ close(): Promise<void>;
53
+ }
25
54
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><title>MCP Apps Inspector</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.00514652bf.js"></script><script defer src="/static/js/155.747f5232dc.js"></script><script defer src="/static/js/index.c1186260b9.js"></script><link href="/static/css/index.b3102f16b9.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1
+ <!DOCTYPE html><html><head><title>MCP Apps Inspector</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.00514652bf.js"></script><script defer src="/static/js/155.747f5232dc.js"></script><script defer src="/static/js/index.2565a9860f.js"></script><link href="/static/css/index.4d9a7b2b96.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
@@ -1 +1 @@
1
- :root{--background-page:#f7f7f7;--background-base-1:#fff;--line-subtle:#0000000f;--line-default:#0000001a;--text-100:#000;--text-80:#333;--text-60:#666;--text-40:#999;--text-30:#bababa;--text-transparent-6:#0000000f;--fill-subtle:#00000008;--support-success:#34c759;--support-success-text:#1f9d45;--support-success-bg:#34c7591f;--support-warning:#ff9500;--support-warning-bg:#ff95001f;--support-error:#ff3b30;--support-error-text:#e5352b;--support-error-bg:#ff3b301a;--theme:#1664ff;--theme-bg:#ebf2ff;--tok-key:#c41a16;--tok-string:#1a55d6;--tok-number:#1a55d6;--tok-literal:#9b2393;--font-sans:"PingFang SC", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Microsoft YaHei", sans-serif;--font-mono:"SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}#root{overflow:auto}body{font-family:var(--font-sans);color:var(--text-100);background:var(--background-page);-webkit-font-smoothing:antialiased;font-size:12px;overflow:hidden}button{font:inherit;color:inherit;cursor:pointer;background:0 0;border:0;padding:0}button:disabled{cursor:not-allowed}input,textarea,select{font:inherit;color:inherit}h2,h3{margin:0}.mono{font-family:var(--font-mono)}.layout{flex-direction:column;min-width:1080px;height:100%;display:flex}.workspace-columns{flex:1;min-height:0;display:flex}.canvas-pane{background:var(--background-page);border-right:1px solid var(--line-subtle);flex-direction:column;flex:none;min-width:360px;display:flex;position:relative;container-type:inline-size}.server-pane{background:var(--background-page);flex-direction:column;flex:1;min-width:420px;display:flex}.card{background:var(--background-base-1);border-radius:12px}.pane-topbar{background:var(--background-base-1);border-bottom:1px solid var(--line-subtle);flex:none;justify-content:space-between;align-items:center;height:36px;padding:0 8px;display:flex;position:relative}.pane-topbar-side{justify-content:flex-end;align-items:center;margin-left:auto;display:flex}.pane-topbar-tabs{position:absolute;left:50%;transform:translate(-50%)}.pane-topbar.is-devtools{justify-content:flex-start;padding:0 20px}.pane-topbar.is-devtools .tabs{gap:28px}.tab-count{color:var(--text-40);margin-left:6px;font-size:10px}[hidden]{display:none!important}.tabs{align-items:stretch;gap:24px;height:100%;display:flex}.tab{color:var(--text-40);white-space:nowrap;align-items:center;font-size:12px;font-weight:500;line-height:25px;display:flex;position:relative}.tab:hover{color:var(--text-60)}.tab.is-active{color:var(--text-100)}.tab.is-active:after{content:"";background:var(--text-100);border-radius:2px;width:32px;height:2px;position:absolute;bottom:0;left:50%;transform:translate(-50%)}.icon-btn{color:var(--text-40);border-radius:6px;justify-content:center;align-items:center;padding:8px;transition:background .15s,color .15s;display:inline-flex}.icon-btn:hover:not(:disabled){color:var(--text-80);background:var(--fill-subtle)}.icon-btn:disabled{opacity:.4}.btn{white-space:nowrap;border-radius:6px;justify-content:center;align-items:center;gap:6px;height:28px;padding:0 12px;font-size:12px;font-weight:500;transition:background .15s,opacity .15s;display:inline-flex}.btn-default{background:var(--background-base-1);border:1px solid var(--line-default);color:var(--text-100)}.btn-default:hover:not(:disabled){background:var(--fill-subtle)}.btn-primary{background:var(--text-100);color:#fff;height:32px;padding:0 16px;font-size:13px}.btn-primary:hover:not(:disabled){background:#262626}.btn:disabled{opacity:.4}.tag{white-space:nowrap;border-radius:6px;align-items:center;height:22px;padding:0 6px;font-size:11px;font-weight:500;line-height:12px;display:inline-flex}.tag-gray{background:var(--text-transparent-6);color:var(--text-60)}.tag-success{background:var(--support-success-bg);color:var(--support-success-text)}.tag-error{background:var(--support-error-bg);color:var(--support-error-text)}.tag-xs{border-radius:4px;height:16px;padding:0 5px;font-size:10px;font-weight:600}.dot{border-radius:50%;flex:none;width:6px;height:6px;display:inline-block}.dot-success{background:var(--support-success)}.dot-error{background:var(--support-error)}.dot-warning{background:var(--support-warning)}.dot-idle{background:var(--text-30)}.pill{white-space:nowrap;border-radius:12px;align-items:center;gap:6px;height:24px;padding:0 10px;font-size:12px;font-weight:500;display:inline-flex}.pill-success{background:var(--support-success-bg);color:var(--support-success-text)}.pill-warning{background:var(--support-warning-bg);color:var(--support-warning)}.pill-error{background:var(--support-error-bg);color:var(--support-error-text)}.pill-idle{background:var(--text-transparent-6);color:var(--text-60)}.search{border:1px solid var(--line-default);background:var(--background-base-1);height:32px;color:var(--text-40);border-radius:6px;align-items:center;gap:6px;padding:0 10px;display:flex}.search:focus-within{border-color:#0000004d}.search input{min-width:0;color:var(--text-100);background:0 0;border:0;outline:0;flex:1;font-size:12px}.search input::placeholder{color:var(--text-40)}.segmented{border:1px solid var(--line-default);background:var(--background-base-1);border-radius:6px;padding:2px;display:inline-flex}.segmented button{min-width:56px;height:22px;color:var(--text-60);border-radius:4px;padding:0 12px;font-size:11px;font-weight:500}.segmented button.is-active{background:var(--text-100);color:#fff}.dropdown{display:inline-flex;position:relative}.dropdown-trigger{border:1px solid var(--line-default);background:var(--background-base-1);width:100%;height:28px;color:var(--text-100);border-radius:6px;justify-content:space-between;align-items:center;gap:8px;padding:0 10px;font-size:12px;font-weight:500;display:inline-flex}.dropdown-trigger svg{color:var(--text-30);flex:none}.dropdown-trigger .is-placeholder{color:var(--text-40)}.dropdown-menu{z-index:20;background:var(--background-base-1);min-width:100%;max-height:280px;box-shadow:0 6px 24px #0000001f, 0 0 0 1px var(--line-subtle);border-radius:8px;padding:4px;position:absolute;top:calc(100% + 4px);left:0;overflow:auto}.dropdown-menu button{text-align:left;white-space:nowrap;border-radius:6px;width:100%;padding:6px 10px;font-size:12px;display:block}.dropdown-menu button:hover{background:var(--fill-subtle)}.dropdown-menu button.is-active{color:var(--theme);font-weight:500}.dropdown-empty{color:var(--text-40);padding:6px 10px}.code{background:var(--background-page);border:1px solid var(--line-subtle);font-family:var(--font-mono);border-radius:6px;font-size:12px;line-height:18px;position:relative;overflow:hidden}.code-scroll{height:100%;padding:6px 0;overflow:auto}.code-line{min-width:max-content;display:flex}.code-gutter,.code-gutter-col{text-align:right;width:36px;color:var(--text-40);-webkit-user-select:none;user-select:none;flex:none;padding-right:12px}.code-text{white-space:pre;color:var(--text-80);padding-right:12px}.tok-key{color:var(--tok-key)}.tok-string{color:var(--tok-string)}.tok-number{color:var(--tok-number)}.tok-literal{color:var(--tok-literal)}.code-editor{display:flex}.code-editor .code-gutter-col{padding-top:6px;padding-bottom:6px;overflow:hidden}.code-editor textarea{resize:none;min-width:0;font-family:inherit;font-size:inherit;line-height:inherit;color:var(--text-80);white-space:pre;background:0 0;border:0;outline:0;flex:1;padding:6px 12px 6px 0;overflow:auto}.code-editor:focus-within{border-color:#00000040}.code-editor.is-invalid{border-color:#ff3b3080}.canvas-stage{background-image:radial-gradient(#00000012 1px,#0000 1px);background-size:16px 16px;flex-direction:column;flex:1;align-items:center;min-height:0;padding:32px 20px;display:flex;position:relative;overflow:auto}.canvas-pane:-webkit-full-screen{width:100%!important}.canvas-pane:fullscreen{width:100%!important}.canvas-empty{color:var(--text-40);flex-direction:column;align-items:center;gap:12px;margin:auto;font-size:13px;display:flex}.canvas-frame-wrap{flex-direction:column;flex:1;min-height:0;display:flex}.canvas-frame-label{height:18px;color:var(--text-80);flex:none;justify-content:space-between;align-items:center;margin-bottom:12px;font-size:11px;font-weight:500;display:flex}.canvas-frame-state{color:var(--text-60);align-items:center;gap:6px;display:inline-flex}.canvas-frame{background:var(--background-base-1);border-radius:8px;flex:1;min-height:0;position:relative;overflow:hidden;box-shadow:0 4px 24px #00000014}.canvas-frame-content{transform-origin:0 0}.app-iframe{background:0 0;border:0;width:100%;height:100%;display:block}.canvas-frame-issues{color:var(--text-60);border-radius:4px;align-items:center;gap:4px;padding:0 4px;display:inline-flex}.canvas-frame-issues svg{color:var(--support-error)}.canvas-frame-issues:hover{background:var(--text-transparent-6)}.canvas-statusbar{height:44px;color:var(--text-60);flex:none;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:8px;margin:12px 12px 0;padding:0 12px;font-size:11px;display:grid}.canvas-statusbar-left{align-items:center;gap:8px;min-width:0;display:flex}.canvas-status{white-space:nowrap;flex:none;align-items:center;gap:8px;font-weight:500;display:inline-flex}.canvas-uri{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.canvas-statusbar-right{text-align:right;white-space:nowrap;align-items:center;gap:4px;display:flex}@container (width<=440px){.canvas-dimensions{display:none}}.zoom-group{border:1px solid var(--line-default);border-radius:6px;align-items:center;height:28px;display:inline-flex}.zoom-group button{width:28px;height:100%;color:var(--text-60);justify-content:center;align-items:center;display:flex}.zoom-group button:hover{color:var(--text-100)}.zoom-group .icon-btn{border-left:1px solid var(--line-default);border-radius:0 5px 5px 0;width:32px;padding:0}.zoom-group span{text-align:center;min-width:44px;color:var(--text-80);font-size:11px}.server-body{flex-direction:column;flex:1;min-height:0;padding:12px;display:flex;overflow:hidden}.connection-bar{flex:none;align-items:center;gap:12px;margin-bottom:12px;padding:10px 12px 10px 16px;display:flex}.connection-summary{flex-direction:column;flex:1;gap:3px;min-width:0;display:flex}.connection-summary strong{font-size:13px;font-weight:600;line-height:20px}.connection-summary>*{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.connection-summary>span{color:var(--text-40);font-family:var(--font-mono);font-size:11px;line-height:16px}.loading-line{vertical-align:middle;background:var(--text-transparent-6);border-radius:4px;width:112px;max-width:100%;height:1em;display:inline-block}.connection-bar .pill{flex:none}.server-error{background:var(--support-error-bg);max-height:72px;color:var(--support-error-text);word-break:break-word;border-radius:6px;flex:none;margin:0 0 12px;padding:8px 12px;overflow:auto}.inspector-panel{flex:1;min-height:0;display:flex;overflow:hidden}.inspector-panel>.debug-log{flex:1;min-width:0}.explorer{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden}.explorer-body{flex-direction:column;flex:1;min-height:0;display:flex}.explorer-loading-picker{border:1px solid var(--line-default);border-radius:6px;align-items:center;height:32px;padding:0 10px;display:flex}.explorer-loading-editor{background:var(--background-page);border-radius:6px;flex:1}.explorer-picker{border-bottom:1px solid var(--line-subtle);flex:none;padding:10px 12px;position:relative}.explorer-picker-head{align-items:center;gap:8px;display:flex}.explorer-picker-trigger{border:1px solid var(--line-default);text-align:left;border-radius:6px;flex:1;align-items:center;gap:8px;min-width:0;height:32px;padding:0 10px;display:flex}.explorer-picker-trigger>span{white-space:nowrap;text-overflow:ellipsis;flex:1;overflow:hidden}.explorer-picker-trigger>.tag{flex:none}.explorer-picker-trigger>svg{color:var(--text-60);flex:none}.explorer-picker-menu{z-index:30;background:var(--background-base-1);border:1px solid var(--line-default);border-radius:8px;flex-direction:column;gap:8px;max-height:min(360px,50vh);padding:8px;display:flex;position:absolute;top:calc(100% - 6px);left:12px;right:12px;box-shadow:0 8px 24px #0000001f}.explorer-picker-menu .search{flex:none}.explorer-items{flex-direction:column;flex:1;gap:4px;min-height:0;display:flex;overflow:auto}.explorer-empty{color:var(--text-40);padding:16px 4px}.explorer-item{text-align:left;border-radius:8px;align-items:center;gap:8px;width:100%;padding:9px 8px;transition:background .15s;display:flex}.explorer-item:hover{background:var(--fill-subtle)}.explorer-item.is-active{background:var(--theme-bg)}.explorer-item-icon{color:var(--text-60);flex:none}.explorer-item.is-active .explorer-item-icon,.explorer-item.is-active .explorer-item-title{color:var(--theme)}.explorer-item-text{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.explorer-item-title{text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:600;line-height:20px;overflow:hidden}.explorer-item-sub{color:var(--text-40);text-overflow:ellipsis;white-space:nowrap;font-size:11px;line-height:16px;overflow:hidden}.tool-ui-tag{color:var(--theme);background:var(--theme-bg);flex:none;font-size:10px}.detail{flex-direction:column;flex:1;min-width:0;min-height:0;padding:14px 16px;display:flex;overflow:auto}.detail-empty{color:var(--text-40);justify-content:center;align-items:center;font-size:13px}.detail-head{flex:none;justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.detail-head>.btn{flex:none}.detail-title{min-width:0}.detail-title-row{align-items:center;gap:8px;display:flex}.detail-title-row h3{text-overflow:ellipsis;white-space:nowrap;font-size:15px;font-weight:600;line-height:26px;overflow:hidden}.detail-desc{color:var(--text-40);margin:2px 0 0;font-size:12px;line-height:18px}.detail-fields{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:8px;display:grid}.field{flex-direction:column;gap:4px;min-width:0;display:flex}.field.is-wide{grid-column:1/-1}.field-label{color:var(--text-60);font-size:12px;line-height:16px}.field-box{border:1px solid var(--line-subtle);background:var(--background-page);height:32px;color:var(--text-80);border-radius:6px;justify-content:space-between;align-items:center;gap:8px;padding:0 4px 0 14px;font-size:12px;display:flex}.field-box-text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.section-head{justify-content:space-between;align-items:center;margin:8px 0 4px;display:flex}.section-title{font-size:13px;font-weight:600}.tool-detail{overflow:auto}.tool-overview{flex:0 0 72px;min-width:0;height:72px}.tool-overview>.detail-head{height:46px}.tool-overview .detail-title-row{height:26px}.tool-overview .detail-desc{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.tool-loading-action{background:var(--text-transparent-6);border-radius:6px;width:78px;height:32px}.tool-loading-splitter{flex:none;height:12px}.tool-metadata{color:var(--text-60);flex:none;margin-top:8px;font-size:12px;line-height:18px;position:relative}.tool-metadata summary{cursor:pointer;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.tool-metadata-body{z-index:20;border:1px solid var(--line-default);background:var(--background-base-1);border-radius:8px;max-height:180px;padding:8px 12px;position:absolute;top:calc(100% + 6px);left:0;right:0;overflow:auto;box-shadow:0 8px 24px #0000001f}.tool-metadata p{white-space:pre-wrap;overflow-wrap:anywhere;margin:8px 0;line-height:18px}.resource-link{max-width:100%;color:var(--theme);text-align:left;overflow-wrap:anywhere;align-items:center;gap:6px;display:flex}.resource-link svg{flex:none}.tool-workspace{flex-direction:column;flex:1;min-height:320px;margin-top:8px;display:flex}.tool-input{flex-direction:column;flex:none;min-height:140px;display:flex}.tool-input .section-head{flex:none;min-height:28px;margin:0 0 8px}.args-editor{flex:1;min-height:0}.tool-form-scroll{flex:1;min-height:0;overflow:auto}.tool-form-scroll .args-form,.tool-form-scroll .args-form-empty{min-height:100%}.tool-output{flex-direction:column;flex:1;min-height:150px;display:flex}.tool-output .result-head{flex:none;margin-top:0}.result-summary{flex-wrap:wrap;flex:none;justify-content:space-between;align-items:center;gap:4px;margin-top:8px;display:flex}.result-summary .synced-note{margin-top:0}.tool-output .result-code,.tool-output .result-placeholder{min-height:0}.args-error{color:var(--support-error-text);margin-top:6px;font-size:11px}.args-form,.args-form-empty{border:1px solid var(--line-subtle);background:var(--background-page);border-radius:6px;padding:10px 12px}.args-form{flex-direction:column;gap:10px;display:flex}.args-form-empty{color:var(--text-40)}.form-row{flex-direction:column;gap:4px;display:flex}.form-label{color:var(--text-80);align-items:center;gap:6px;font-size:12px;font-weight:500;display:flex}.form-label em{color:var(--support-error);font-style:normal}.form-type{color:var(--text-40);font-size:11px;font-weight:400}.form-input{border:1px solid var(--line-default);background:var(--background-base-1);border-radius:6px;outline:0;height:30px;padding:0 10px;font-size:12px}textarea.form-input{resize:vertical;height:auto;padding:6px 10px}.form-input:focus{border-color:#0000004d}.form-input.is-invalid{border-color:#ff3b3099}.form-help{color:var(--text-40);font-size:11px}.result-head{border-bottom:1px solid var(--line-subtle);height:32px;margin-bottom:0}.result-head .tabs{gap:0}.result-head .tab{color:var(--text-60);padding:0 10px;font-size:13px}.result-head .tab.is-active{color:var(--text-100);font-weight:600}.result-head .tab.is-active:after{width:100%}.result-status{align-items:center;gap:6px;font-size:12px;font-weight:500;display:inline-flex}.result-status.is-success{color:var(--support-success-text)}.result-status.is-success svg{color:var(--support-success)}.result-status.is-error{color:var(--support-error-text)}.result-status.is-running{color:var(--text-40)}.result-code{flex:1 1 0;min-height:48px;margin-top:6px}.result-code.is-tall{min-height:160px}.result-placeholder{background:var(--background-page);min-height:48px;color:var(--text-40);border-radius:6px;flex:1 1 0;justify-content:center;align-items:center;margin-top:6px;display:flex}.synced-note{color:var(--text-60);align-items:center;gap:8px;margin-top:6px;font-size:11px;display:flex}.debug-log{flex-direction:column;height:100%;padding:10px 12px 12px;display:flex}.debug-log-body{flex-direction:column;flex:1;min-height:0;margin-top:8px;display:flex}.debug-log-actions{flex-wrap:wrap;flex:none;align-items:center;gap:8px;width:100%;display:flex}.debug-log-search{width:100%;height:28px}.debug-log-order{width:100px;margin-right:auto}.debug-log-order .dropdown-trigger{height:28px}.debug-log-actions .btn{min-width:64px;height:28px}.log-table{border-top:1px solid var(--line-subtle);flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.log-rows{flex:1;min-height:0;overflow:auto}.log-row{border-bottom:1px solid var(--line-subtle);text-align:left;width:100%;color:var(--text-80);flex-direction:column;gap:5px;padding:9px 8px;font-size:12px;display:flex}.log-row-main,.log-row-meta{justify-content:space-between;align-items:center;gap:8px;display:flex}.log-row-main .log-cell-main{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.log-row-main .tag{flex:none}.log-row-meta{color:var(--text-40);font-size:10px}.log-cell-main.is-error{color:var(--support-error-text)}.log-dir{color:var(--theme);margin-right:4px;font-weight:600}.log-kind{color:var(--text-40);margin-left:6px;font-size:10px}button.log-row:hover{background:var(--fill-subtle)}button.log-row.is-active{background:var(--theme-bg)}.log-empty{color:var(--text-40);padding:16px 4px}.log-detail-pane{flex:none;width:100%;min-width:0;min-height:0}.log-detail{border:1px solid var(--line-subtle);border-radius:6px;flex-direction:column;height:100%;display:flex;overflow:hidden}.log-detail-head{border-bottom:1px solid var(--line-subtle);flex:none;align-items:center;gap:4px;height:30px;padding:0 4px;display:flex}.log-detail-head .icon-btn{padding:4px}.log-detail-head .tabs{gap:0}.log-detail-title{flex:none;align-items:center;gap:8px;min-width:0;padding:8px 12px 4px;font-size:12px;font-weight:600;display:flex}.log-detail-title>span:last-child{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kv-view{flex:1;min-height:0;padding:4px 12px 12px;overflow:auto}.kv-section+.kv-section{border-top:1px solid var(--line-subtle);margin-top:4px}.kv-section h4{color:var(--text-100);margin:0;padding:8px 0 4px;font-size:12px;font-weight:600}.kv-row{grid-template-columns:minmax(96px,32%) 1fr;gap:12px;padding:2px 0;font-size:12px;line-height:18px;display:grid}.kv-key{color:var(--text-60);word-break:break-all}.kv-value{color:var(--text-100);font-family:var(--font-mono);word-break:break-all;font-size:11.5px}.kv-empty{color:var(--text-40);padding:2px 0}.log-detail-head .tab{color:var(--text-60);padding:0 14px;font-size:11px}.log-detail-head .tab.is-active{color:var(--text-100);font-weight:600}.log-detail-head .tab.is-active:after{width:100%}.log-detail-code{background:var(--background-base-1);border:0;border-radius:0;flex:1;min-height:0}.log-detail-code .code-scroll{padding:6px 0}.splitter{z-index:5;touch-action:none;flex:none;position:relative}.splitter:after{content:"";background:0 0;border-radius:1px;transition:background .15s;position:absolute}.splitter:hover:after,.splitter.is-dragging:after{background:var(--theme)}.splitter-x{cursor:col-resize}.splitter-x:after{width:2px;top:0;bottom:0;left:50%;transform:translate(-50%)}.splitter-y{cursor:row-resize;height:9px}.splitter-y:after{height:2px;top:50%;left:0;right:0;transform:translateY(-50%)}.splitter-edge{width:8px;position:absolute;top:0;bottom:0;right:-4px}.splitter-y.splitter-gap{height:12px}.splitter-y.splitter-gap:after{left:40%;right:40%}body.is-resizing-x,body.is-resizing-x *{-webkit-user-select:none;user-select:none;cursor:col-resize!important}body.is-resizing-y,body.is-resizing-y *{-webkit-user-select:none;user-select:none;cursor:row-resize!important}body.is-resizing-x iframe,body.is-resizing-y iframe{pointer-events:none}.requests-pane{border-left:1px solid var(--line-subtle);flex-direction:column;flex:none;min-width:300px;display:flex;position:relative}.requests-topbar{padding:0 16px;font-size:12px;font-weight:500}.requests-protocol{color:var(--text-40);font-size:10px;font-weight:400}.requests-body{flex:1;min-height:0;padding:12px;display:flex}.splitter-edge.is-leading{left:-4px;right:auto}.console-dock{flex:none;min-height:0}.console-drawer{background:var(--background-base-1);border-top:1px solid var(--line-default);flex-direction:column;min-height:180px;display:flex;position:relative}.console-resize{z-index:20;position:absolute;top:-5px;left:0;right:0}.console-drawer-head{border-bottom:1px solid var(--line-subtle);flex:none;justify-content:space-between;align-items:center;height:32px;padding:0 12px 0 16px;font-size:12px;font-weight:500;display:flex}.workspace-statusbar{border-top:1px solid var(--line-subtle);background:var(--background-base-1);height:30px;color:var(--text-60);justify-content:space-between;align-items:center;padding:0 10px 0 16px;font-size:11px;display:flex}.workspace-connection{align-items:center;gap:8px;display:flex}.workspace-transport{color:var(--text-40);margin-left:8px}.console-indicators{align-items:center;gap:4px;height:100%;display:flex}.console-indicator{height:24px;color:var(--text-80);border-radius:4px;align-items:center;gap:4px;padding:0 5px;font-size:12px;display:flex}.console-indicator:hover,.console-toggle:hover{background:var(--fill-subtle)}.console-indicator.is-error svg{color:var(--support-error)}.console-indicator.is-warn svg{color:var(--support-warning)}.console-indicator.is-info svg{color:var(--theme)}.console-toggle{border-left:1px solid var(--line-default);align-items:center;gap:8px;height:24px;margin-left:4px;padding:0 8px;font-size:11px;display:flex}.console-toggle svg{transform:rotate(180deg)}.console-toggle.is-active svg{transform:none}.dialog-mask{z-index:100;background:#00000040;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.dialog{background:var(--background-base-1);border-radius:12px;width:480px;box-shadow:0 12px 48px #0000002e}.dialog-head{border-bottom:1px solid var(--line-subtle);justify-content:space-between;align-items:center;padding:12px 12px 12px 20px;display:flex}.dialog-head h2{font-size:15px;font-weight:600}.dialog-body{flex-direction:column;gap:16px;padding:20px;display:flex}.dialog-body .form-input{height:34px}.dialog-body textarea.form-input{height:auto}.endpoint-input{position:relative}.endpoint-input .form-input{width:100%;padding-right:34px}.endpoint-clear{position:absolute;top:3px;right:3px}.endpoint-hint{align-items:center;gap:6px;height:20px;display:flex}.endpoint-hint kbd{border:1px solid var(--line-default);border-radius:4px;flex:none;padding:0 4px;line-height:16px}.endpoint-hint span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.dialog-foot{justify-content:flex-end;gap:12px;padding:0 20px 20px;display:flex}.dialog-foot .btn{height:32px}.console-panel{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.console-toolbar{border-bottom:1px solid var(--line-subtle);flex-wrap:wrap;flex:none;align-items:center;gap:8px;padding:8px 16px;display:flex}.console-toolbar .search{flex:0 360px;min-width:120px}.console-toolbar .dropdown{width:110px}.console-list{flex:1;min-height:0;overflow:auto}.console-empty{color:var(--text-40);text-align:center;padding:32px 20px;line-height:20px}.console-entry{border-bottom:1px solid var(--line-subtle);font-family:var(--font-mono);align-items:flex-start;gap:8px;padding:4px 16px;font-size:11px;display:flex}.console-entry time{color:var(--text-40);flex:none;line-height:20px}.console-entry-level{width:34px;color:var(--text-60);flex:none;line-height:20px}.console-entry.is-error{background:var(--support-error-bg)}.console-entry.is-error .console-entry-level{color:var(--support-error-text)}.console-entry.is-warn{background:var(--support-warning-bg)}.console-entry.is-debug{color:var(--text-60)}.console-entry-source{flex:none;align-items:center;width:52px;height:20px;display:flex}.console-entry-context{text-overflow:ellipsis;white-space:nowrap;max-width:144px;color:var(--text-40);flex:0 auto;line-height:20px;overflow:hidden}.console-source-host{color:var(--theme);background:var(--theme-bg)}.console-source-iframe{color:var(--support-success-text);background:var(--support-success-bg)}.console-entry pre{min-width:0;font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;flex:1;margin:0;line-height:20px}.console-footnote{border-top:1px solid var(--line-subtle);color:var(--text-40);flex:none;padding:5px 16px;font-size:11px}
1
+ :root{--background-page:#f7f7f7;--background-base-1:#fff;--line-subtle:#0000000f;--line-default:#0000001a;--text-100:#000;--text-80:#333;--text-60:#666;--text-40:#999;--text-30:#bababa;--text-transparent-6:#0000000f;--fill-subtle:#00000008;--support-success:#34c759;--support-success-text:#1f9d45;--support-success-bg:#34c7591f;--support-warning:#ff9500;--support-warning-bg:#ff95001f;--support-error:#ff3b30;--support-error-text:#e5352b;--support-error-bg:#ff3b301a;--theme:#1664ff;--theme-bg:#ebf2ff;--tok-key:#c41a16;--tok-string:#1a55d6;--tok-number:#1a55d6;--tok-literal:#9b2393;--font-sans:"PingFang SC", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Microsoft YaHei", sans-serif;--font-mono:"SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}#root{overflow:auto}body{font-family:var(--font-sans);color:var(--text-100);background:var(--background-page);-webkit-font-smoothing:antialiased;font-size:12px;overflow:hidden}button{font:inherit;color:inherit;cursor:pointer;background:0 0;border:0;padding:0}button:disabled{cursor:not-allowed}input,textarea,select{font:inherit;color:inherit}h2,h3{margin:0}.mono{font-family:var(--font-mono)}.layout{flex-direction:column;min-width:1080px;height:100%;display:flex}.workspace-columns{flex:1;min-height:0;display:flex}.canvas-pane{background:var(--background-page);border-right:1px solid var(--line-subtle);flex-direction:column;flex:none;min-width:360px;display:flex;position:relative;container-type:inline-size}.server-pane{background:var(--background-page);flex-direction:column;flex:1;min-width:420px;display:flex}.card{background:var(--background-base-1);border-radius:12px}.pane-topbar{background:var(--background-base-1);border-bottom:1px solid var(--line-subtle);flex:none;justify-content:space-between;align-items:center;height:36px;padding:0 8px;display:flex;position:relative}.pane-topbar-side{justify-content:flex-end;align-items:center;margin-left:auto;display:flex}.pane-topbar-tabs{position:absolute;left:50%;transform:translate(-50%)}.pane-topbar.is-devtools{justify-content:flex-start;padding:0 20px}.pane-topbar.is-devtools .tabs{gap:28px}.tab-count{color:var(--text-40);margin-left:6px;font-size:10px}[hidden]{display:none!important}.tabs{align-items:stretch;gap:24px;height:100%;display:flex}.tab{color:var(--text-40);white-space:nowrap;align-items:center;font-size:12px;font-weight:500;line-height:25px;display:flex;position:relative}.tab:hover{color:var(--text-60)}.tab.is-active{color:var(--text-100)}.tab.is-active:after{content:"";background:var(--text-100);border-radius:2px;width:32px;height:2px;position:absolute;bottom:0;left:50%;transform:translate(-50%)}.icon-btn{color:var(--text-40);border-radius:6px;justify-content:center;align-items:center;padding:8px;transition:background .15s,color .15s;display:inline-flex}.icon-btn:hover:not(:disabled){color:var(--text-80);background:var(--fill-subtle)}.icon-btn:disabled{opacity:.4}.btn{white-space:nowrap;border-radius:6px;justify-content:center;align-items:center;gap:6px;height:28px;padding:0 12px;font-size:12px;font-weight:500;transition:background .15s,opacity .15s;display:inline-flex}.btn-default{background:var(--background-base-1);border:1px solid var(--line-default);color:var(--text-100)}.btn-default:hover:not(:disabled){background:var(--fill-subtle)}.btn-primary{background:var(--text-100);color:#fff;height:32px;padding:0 16px;font-size:13px}.btn-primary:hover:not(:disabled){background:#262626}.btn:disabled{opacity:.4}.tag{white-space:nowrap;border-radius:6px;align-items:center;height:22px;padding:0 6px;font-size:11px;font-weight:500;line-height:12px;display:inline-flex}.tag-gray{background:var(--text-transparent-6);color:var(--text-60)}.tag-success{background:var(--support-success-bg);color:var(--support-success-text)}.tag-error{background:var(--support-error-bg);color:var(--support-error-text)}.tag-xs{border-radius:4px;height:16px;padding:0 5px;font-size:10px;font-weight:600}.dot{border-radius:50%;flex:none;width:6px;height:6px;display:inline-block}.dot-success{background:var(--support-success)}.dot-error{background:var(--support-error)}.dot-warning{background:var(--support-warning)}.dot-idle{background:var(--text-30)}.pill{white-space:nowrap;border-radius:12px;align-items:center;gap:6px;height:24px;padding:0 10px;font-size:12px;font-weight:500;display:inline-flex}.pill-success{background:var(--support-success-bg);color:var(--support-success-text)}.pill-warning{background:var(--support-warning-bg);color:var(--support-warning)}.pill-error{background:var(--support-error-bg);color:var(--support-error-text)}.pill-idle{background:var(--text-transparent-6);color:var(--text-60)}.search{border:1px solid var(--line-default);background:var(--background-base-1);height:32px;color:var(--text-40);border-radius:6px;align-items:center;gap:6px;padding:0 10px;display:flex}.search:focus-within{border-color:#0000004d}.search input{min-width:0;color:var(--text-100);background:0 0;border:0;outline:0;flex:1;font-size:12px}.search input::placeholder{color:var(--text-40)}.segmented{border:1px solid var(--line-default);background:var(--background-base-1);border-radius:6px;padding:2px;display:inline-flex}.segmented button{min-width:56px;height:22px;color:var(--text-60);border-radius:4px;padding:0 12px;font-size:11px;font-weight:500}.segmented button.is-active{background:var(--text-100);color:#fff}.dropdown{display:inline-flex;position:relative}.dropdown-trigger{border:1px solid var(--line-default);background:var(--background-base-1);width:100%;height:28px;color:var(--text-100);border-radius:6px;justify-content:space-between;align-items:center;gap:8px;padding:0 10px;font-size:12px;font-weight:500;display:inline-flex}.dropdown-trigger svg{color:var(--text-30);flex:none}.dropdown-trigger .is-placeholder{color:var(--text-40)}.dropdown-menu{z-index:20;background:var(--background-base-1);min-width:100%;max-height:280px;box-shadow:0 6px 24px #0000001f, 0 0 0 1px var(--line-subtle);border-radius:8px;padding:4px;position:absolute;top:calc(100% + 4px);left:0;overflow:auto}.dropdown-menu button{text-align:left;white-space:nowrap;border-radius:6px;width:100%;padding:6px 10px;font-size:12px;display:block}.dropdown-menu button:hover{background:var(--fill-subtle)}.dropdown-menu button.is-active{color:var(--theme);font-weight:500}.dropdown-empty{color:var(--text-40);padding:6px 10px}.code{background:var(--background-page);border:1px solid var(--line-subtle);font-family:var(--font-mono);border-radius:6px;font-size:12px;line-height:18px;position:relative;overflow:hidden}.code-scroll{height:100%;padding:6px 0;overflow:auto}.code-line{min-width:max-content;display:flex}.code-gutter,.code-gutter-col{text-align:right;width:36px;color:var(--text-40);-webkit-user-select:none;user-select:none;flex:none;padding-right:12px}.code-text{white-space:pre;color:var(--text-80);padding-right:12px}.tok-key{color:var(--tok-key)}.tok-string{color:var(--tok-string)}.tok-number{color:var(--tok-number)}.tok-literal{color:var(--tok-literal)}.code-editor{display:flex}.code-editor .code-gutter-col{padding-top:6px;padding-bottom:6px;overflow:hidden}.code-editor textarea{resize:none;min-width:0;font-family:inherit;font-size:inherit;line-height:inherit;color:var(--text-80);white-space:pre;background:0 0;border:0;outline:0;flex:1;padding:6px 12px 6px 0;overflow:auto}.code-editor:focus-within{border-color:#00000040}.code-editor.is-invalid{border-color:#ff3b3080}.canvas-stage{background-image:radial-gradient(#00000012 1px,#0000 1px);background-size:16px 16px;flex-direction:column;flex:1;align-items:center;min-height:0;padding:32px 20px;display:flex;position:relative;overflow:auto}.canvas-pane:-webkit-full-screen{width:100%!important}.canvas-pane:fullscreen{width:100%!important}.canvas-empty{color:var(--text-40);flex-direction:column;align-items:center;gap:12px;margin:auto;font-size:13px;display:flex}.canvas-frame-wrap{flex-direction:column;flex:1;min-height:0;display:flex}.canvas-frame-label{height:18px;color:var(--text-80);flex:none;justify-content:space-between;align-items:center;margin-bottom:12px;font-size:11px;font-weight:500;display:flex}.canvas-frame-state{color:var(--text-60);align-items:center;gap:6px;display:inline-flex}.canvas-frame{background:var(--background-base-1);border-radius:8px;flex:1;min-height:0;position:relative;overflow:hidden;box-shadow:0 4px 24px #00000014}.canvas-frame-content{transform-origin:0 0}.app-iframe{background:0 0;border:0;width:100%;height:100%;display:block}.canvas-frame-issues{color:var(--text-60);border-radius:4px;align-items:center;gap:4px;padding:0 4px;display:inline-flex}.canvas-frame-issues svg{color:var(--support-error)}.canvas-frame-issues:hover{background:var(--text-transparent-6)}.canvas-statusbar{height:44px;color:var(--text-60);flex:none;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:8px;margin:12px 12px 0;padding:0 12px;font-size:11px;display:grid}.canvas-statusbar-left{align-items:center;gap:8px;min-width:0;display:flex}.canvas-status{white-space:nowrap;flex:none;align-items:center;gap:8px;font-weight:500;display:inline-flex}.canvas-uri{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.canvas-statusbar-right{text-align:right;white-space:nowrap;align-items:center;gap:4px;display:flex}@container (width<=440px){.canvas-dimensions{display:none}}.zoom-group{border:1px solid var(--line-default);border-radius:6px;align-items:center;height:28px;display:inline-flex}.zoom-group button{width:28px;height:100%;color:var(--text-60);justify-content:center;align-items:center;display:flex}.zoom-group button:hover{color:var(--text-100)}.zoom-group .icon-btn{border-left:1px solid var(--line-default);border-radius:0 5px 5px 0;width:32px;padding:0}.zoom-group span{text-align:center;min-width:44px;color:var(--text-80);font-size:11px}.server-body{flex-direction:column;flex:1;min-height:0;padding:12px;display:flex;overflow:hidden}.connection-bar{flex:none;align-items:center;gap:12px;margin-bottom:12px;padding:10px 12px 10px 16px;display:flex}.connection-summary{flex-direction:column;flex:1;gap:3px;min-width:0;display:flex}.connection-summary strong{font-size:13px;font-weight:600;line-height:20px}.connection-summary>*{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.connection-summary>span{color:var(--text-40);font-family:var(--font-mono);font-size:11px;line-height:16px}.loading-line{vertical-align:middle;background:var(--text-transparent-6);border-radius:4px;width:112px;max-width:100%;height:1em;display:inline-block}.connection-bar .pill{flex:none}.server-error{background:var(--support-error-bg);max-height:72px;color:var(--support-error-text);word-break:break-word;border-radius:6px;flex:none;margin:0 0 12px;padding:8px 12px;overflow:auto}.inspector-panel{flex:1;min-height:0;display:flex;overflow:hidden}.inspector-panel>.debug-log{flex:1;min-width:0}.explorer{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden}.explorer-body{flex-direction:column;flex:1;min-height:0;display:flex}.explorer-loading-picker{border:1px solid var(--line-default);border-radius:6px;align-items:center;height:32px;padding:0 10px;display:flex}.explorer-loading-editor{background:var(--background-page);border-radius:6px;flex:1}.explorer-picker{border-bottom:1px solid var(--line-subtle);flex:none;padding:10px 12px;position:relative}.explorer-picker-head{align-items:center;gap:8px;display:flex}.explorer-picker-trigger{border:1px solid var(--line-default);text-align:left;border-radius:6px;flex:1;align-items:center;gap:8px;min-width:0;height:32px;padding:0 10px;display:flex}.explorer-picker-trigger>span{white-space:nowrap;text-overflow:ellipsis;flex:1;overflow:hidden}.explorer-picker-trigger>.tag{flex:none}.explorer-picker-trigger>svg{color:var(--text-60);flex:none}.explorer-picker-menu{z-index:30;background:var(--background-base-1);border:1px solid var(--line-default);border-radius:8px;flex-direction:column;gap:8px;max-height:min(360px,50vh);padding:8px;display:flex;position:absolute;top:calc(100% - 6px);left:12px;right:12px;box-shadow:0 8px 24px #0000001f}.explorer-picker-menu .search{flex:none}.explorer-items{flex-direction:column;flex:1;gap:4px;min-height:0;display:flex;overflow:auto}.explorer-empty{color:var(--text-40);padding:16px 4px}.explorer-item{text-align:left;border-radius:8px;align-items:center;gap:8px;width:100%;padding:9px 8px;transition:background .15s;display:flex}.explorer-item:hover{background:var(--fill-subtle)}.explorer-item.is-active{background:var(--theme-bg)}.explorer-item-icon{color:var(--text-60);flex:none}.explorer-item.is-active .explorer-item-icon,.explorer-item.is-active .explorer-item-title{color:var(--theme)}.explorer-item-text{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.explorer-item-title{text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:600;line-height:20px;overflow:hidden}.explorer-item-sub{color:var(--text-40);text-overflow:ellipsis;white-space:nowrap;font-size:11px;line-height:16px;overflow:hidden}.tool-ui-tag{color:var(--theme);background:var(--theme-bg);flex:none;font-size:10px}.detail{flex-direction:column;flex:1;min-width:0;min-height:0;padding:14px 16px;display:flex;overflow:auto}.detail-empty{color:var(--text-40);justify-content:center;align-items:center;font-size:13px}.detail-head{flex:none;justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.detail-head>.btn{flex:none}.detail-title{min-width:0}.detail-title-row{align-items:center;gap:8px;display:flex}.detail-title-row h3{text-overflow:ellipsis;white-space:nowrap;font-size:15px;font-weight:600;line-height:26px;overflow:hidden}.detail-desc{color:var(--text-40);margin:2px 0 0;font-size:12px;line-height:18px}.detail-fields{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:8px;display:grid}.field{flex-direction:column;gap:4px;min-width:0;display:flex}.field.is-wide{grid-column:1/-1}.field-label{color:var(--text-60);font-size:12px;line-height:16px}.field-box{border:1px solid var(--line-subtle);background:var(--background-page);height:32px;color:var(--text-80);border-radius:6px;justify-content:space-between;align-items:center;gap:8px;padding:0 4px 0 14px;font-size:12px;display:flex}.field-box-text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.section-head{justify-content:space-between;align-items:center;margin:8px 0 4px;display:flex}.section-title{font-size:13px;font-weight:600}.tool-detail{overflow:auto}.tool-overview{flex:0 0 72px;min-width:0;height:72px}.tool-overview>.detail-head{height:46px}.tool-overview .detail-title-row{height:26px}.tool-overview .detail-desc{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.tool-loading-action{background:var(--text-transparent-6);border-radius:6px;width:78px;height:32px}.tool-loading-splitter{flex:none;height:12px}.tool-metadata{color:var(--text-60);flex:none;margin-top:8px;font-size:12px;line-height:18px;position:relative}.tool-metadata summary{cursor:pointer;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.tool-metadata-body{z-index:20;border:1px solid var(--line-default);background:var(--background-base-1);border-radius:8px;max-height:180px;padding:8px 12px;position:absolute;top:calc(100% + 6px);left:0;right:0;overflow:auto;box-shadow:0 8px 24px #0000001f}.tool-metadata p{white-space:pre-wrap;overflow-wrap:anywhere;margin:8px 0;line-height:18px}.resource-link{max-width:100%;color:var(--theme);text-align:left;overflow-wrap:anywhere;align-items:center;gap:6px;display:flex}.resource-link svg{flex:none}.tool-workspace{flex-direction:column;flex:1;min-height:320px;margin-top:8px;display:flex}.tool-input{flex-direction:column;flex:none;min-height:140px;display:flex}.tool-input .section-head{flex:none;min-height:28px;margin:0 0 8px}.args-editor{flex:1;min-height:0}.tool-form-scroll{flex:1;min-height:0;overflow:auto}.tool-form-scroll .args-form,.tool-form-scroll .args-form-empty{min-height:100%}.tool-output{flex-direction:column;flex:1;min-height:150px;display:flex}.tool-output .result-head{flex:none;margin-top:0}.result-summary{flex-wrap:wrap;flex:none;justify-content:space-between;align-items:center;gap:4px;margin-top:8px;display:flex}.result-summary .synced-note{margin-top:0}.tool-output .result-code,.tool-output .result-placeholder{min-height:0}.args-error{color:var(--support-error-text);margin-top:6px;font-size:11px}.args-form,.args-form-empty{border:1px solid var(--line-subtle);background:var(--background-page);border-radius:6px;padding:10px 12px}.args-form{flex-direction:column;gap:10px;display:flex}.args-form-empty{color:var(--text-40)}.form-row{flex-direction:column;gap:4px;display:flex}.form-label{color:var(--text-80);align-items:center;gap:6px;font-size:12px;font-weight:500;display:flex}.form-label em{color:var(--support-error);font-style:normal}.form-type{color:var(--text-40);font-size:11px;font-weight:400}.form-input{border:1px solid var(--line-default);background:var(--background-base-1);border-radius:6px;outline:0;height:30px;padding:0 10px;font-size:12px}textarea.form-input{resize:vertical;height:auto;padding:6px 10px}.form-input:focus{border-color:#0000004d}.form-input.is-invalid{border-color:#ff3b3099}.form-help{color:var(--text-40);font-size:11px}.result-head{border-bottom:1px solid var(--line-subtle);height:32px;margin-bottom:0}.result-head .tabs{gap:0}.result-head .tab{color:var(--text-60);padding:0 10px;font-size:13px}.result-head .tab.is-active{color:var(--text-100);font-weight:600}.result-head .tab.is-active:after{width:100%}.result-status{align-items:center;gap:6px;font-size:12px;font-weight:500;display:inline-flex}.result-status.is-success{color:var(--support-success-text)}.result-status.is-success svg{color:var(--support-success)}.result-status.is-error{color:var(--support-error-text)}.result-status.is-running{color:var(--text-40)}.result-code{flex:1 1 0;min-height:48px;margin-top:6px}.result-code.is-tall{min-height:160px}.result-placeholder{background:var(--background-page);min-height:48px;color:var(--text-40);border-radius:6px;flex:1 1 0;justify-content:center;align-items:center;margin-top:6px;display:flex}.synced-note{color:var(--text-60);align-items:center;gap:8px;margin-top:6px;font-size:11px;display:flex}.debug-log{flex-direction:column;height:100%;padding:10px 12px 12px;display:flex}.debug-log-body{flex-direction:column;flex:1;min-height:0;margin-top:8px;display:flex}.debug-log-actions{flex-wrap:wrap;flex:none;align-items:center;gap:8px;width:100%;display:flex}.debug-log-search{width:100%;height:28px}.debug-log-order{width:100px;margin-right:auto}.debug-log-order .dropdown-trigger{height:28px}.debug-log-actions .btn{min-width:64px;height:28px}.log-table{border-top:1px solid var(--line-subtle);flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.log-rows{flex:1;min-height:0;overflow:auto}.log-row{border-bottom:1px solid var(--line-subtle);text-align:left;width:100%;color:var(--text-80);flex-direction:column;gap:5px;padding:9px 8px;font-size:12px;display:flex}.log-row-main,.log-row-meta{justify-content:space-between;align-items:center;gap:8px;display:flex}.log-row-main .log-cell-main{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.log-row-main .tag{flex:none}.log-row-meta{color:var(--text-40);font-size:10px}.log-cell-main.is-error{color:var(--support-error-text)}.log-dir{color:var(--theme);margin-right:4px;font-weight:600}.log-kind{color:var(--text-40);margin-left:6px;font-size:10px}button.log-row:hover{background:var(--fill-subtle)}button.log-row.is-active{background:var(--theme-bg)}.log-empty{color:var(--text-40);padding:16px 4px}.log-detail-pane{flex:none;width:100%;min-width:0;min-height:0}.log-detail{border:1px solid var(--line-subtle);border-radius:6px;flex-direction:column;height:100%;display:flex;overflow:hidden}.log-detail-head{border-bottom:1px solid var(--line-subtle);flex:none;align-items:center;gap:4px;height:30px;padding:0 4px;display:flex}.log-detail-head .icon-btn{padding:4px}.log-detail-head .tabs{gap:0}.log-detail-title{flex:none;align-items:center;gap:8px;min-width:0;padding:8px 12px 4px;font-size:12px;font-weight:600;display:flex}.log-detail-title>span:last-child{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kv-view{flex:1;min-height:0;padding:4px 12px 12px;overflow:auto}.kv-section+.kv-section{border-top:1px solid var(--line-subtle);margin-top:4px}.kv-section h4{color:var(--text-100);margin:0;padding:8px 0 4px;font-size:12px;font-weight:600}.kv-row{grid-template-columns:minmax(96px,32%) 1fr;gap:12px;padding:2px 0;font-size:12px;line-height:18px;display:grid}.kv-key{color:var(--text-60);word-break:break-all}.kv-value{color:var(--text-100);font-family:var(--font-mono);word-break:break-all;font-size:11.5px}.kv-empty{color:var(--text-40);padding:2px 0}.log-detail-head .tab{color:var(--text-60);padding:0 14px;font-size:11px}.log-detail-head .tab.is-active{color:var(--text-100);font-weight:600}.log-detail-head .tab.is-active:after{width:100%}.log-detail-code{background:var(--background-base-1);border:0;border-radius:0;flex:1;min-height:0}.log-detail-code .code-scroll{padding:6px 0}.splitter{z-index:5;touch-action:none;flex:none;position:relative}.splitter:after{content:"";background:0 0;border-radius:1px;transition:background .15s;position:absolute}.splitter:hover:after,.splitter.is-dragging:after{background:var(--theme)}.splitter-x{cursor:col-resize}.splitter-x:after{width:2px;top:0;bottom:0;left:50%;transform:translate(-50%)}.splitter-y{cursor:row-resize;height:9px}.splitter-y:after{height:2px;top:50%;left:0;right:0;transform:translateY(-50%)}.splitter-edge{width:8px;position:absolute;top:0;bottom:0;right:-4px}.splitter-y.splitter-gap{height:12px}.splitter-y.splitter-gap:after{left:40%;right:40%}body.is-resizing-x,body.is-resizing-x *{-webkit-user-select:none;user-select:none;cursor:col-resize!important}body.is-resizing-y,body.is-resizing-y *{-webkit-user-select:none;user-select:none;cursor:row-resize!important}body.is-resizing-x iframe,body.is-resizing-y iframe{pointer-events:none}.requests-pane{border-left:1px solid var(--line-subtle);flex-direction:column;flex:none;min-width:300px;display:flex;position:relative}.requests-topbar{padding:0 16px;font-size:12px;font-weight:500}.requests-protocol{color:var(--text-40);font-size:10px;font-weight:400}.requests-body{flex:1;min-height:0;padding:12px;display:flex}.splitter-edge.is-leading{left:-4px;right:auto}.console-dock{flex:none;min-height:0}.console-drawer{background:var(--background-base-1);border-top:1px solid var(--line-default);flex-direction:column;min-height:180px;display:flex;position:relative}.console-resize{z-index:20;position:absolute;top:-5px;left:0;right:0}.console-drawer-head{border-bottom:1px solid var(--line-subtle);flex:none;justify-content:space-between;align-items:center;height:32px;padding:0 12px 0 16px;font-size:12px;font-weight:500;display:flex}.workspace-statusbar{border-top:1px solid var(--line-subtle);background:var(--background-base-1);height:30px;color:var(--text-60);justify-content:space-between;align-items:center;padding:0 10px 0 16px;font-size:11px;display:flex}.workspace-connection{align-items:center;gap:8px;display:flex}.workspace-transport{color:var(--text-40);margin-left:8px}.console-indicators{align-items:center;gap:4px;height:100%;display:flex}.console-indicator{height:24px;color:var(--text-80);border-radius:4px;align-items:center;gap:4px;padding:0 5px;font-size:12px;display:flex}.console-indicator:hover,.console-toggle:hover{background:var(--fill-subtle)}.console-indicator.is-error svg{color:var(--support-error)}.console-indicator.is-warn svg{color:var(--support-warning)}.console-indicator.is-info svg{color:var(--theme)}.console-toggle{border-left:1px solid var(--line-default);align-items:center;gap:8px;height:24px;margin-left:4px;padding:0 8px;font-size:11px;display:flex}.console-toggle svg{transform:rotate(180deg)}.console-toggle.is-active svg{transform:none}.dialog-mask{z-index:100;background:#00000040;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.dialog{background:var(--background-base-1);border-radius:12px;width:480px;box-shadow:0 12px 48px #0000002e}.dialog-head{border-bottom:1px solid var(--line-subtle);justify-content:space-between;align-items:center;padding:12px 12px 12px 20px;display:flex}.dialog-head h2{font-size:15px;font-weight:600}.dialog-body{flex-direction:column;gap:16px;padding:20px;display:flex}.dialog-body .form-input{height:34px}.dialog-body textarea.form-input{height:auto}.endpoint-input{position:relative}.endpoint-input .form-input{width:100%;padding-right:34px}.endpoint-clear{position:absolute;top:3px;right:3px}.endpoint-hint{align-items:center;gap:6px;height:20px;display:flex}.endpoint-hint kbd{border:1px solid var(--line-default);border-radius:4px;flex:none;padding:0 4px;line-height:16px}.endpoint-hint span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.dialog-foot{justify-content:flex-end;gap:12px;padding:0 20px 20px;display:flex}.dialog-foot .btn{height:32px}.console-panel{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.console-toolbar{border-bottom:1px solid var(--line-subtle);flex-wrap:wrap;flex:none;align-items:center;gap:8px;padding:8px 16px;display:flex}.console-toolbar .search{flex:0 360px;min-width:120px}.console-toolbar .dropdown{width:110px}.console-list{flex:1;min-height:0;overflow:auto}.console-empty{color:var(--text-40);text-align:center;padding:32px 20px;line-height:20px}.console-entry{border-bottom:1px solid var(--line-subtle);font-family:var(--font-mono);align-items:flex-start;gap:8px;padding:4px 16px;font-size:11px;display:flex}.console-entry time{color:var(--text-40);flex:none;line-height:20px}.console-entry-level{width:34px;color:var(--text-60);flex:none;line-height:20px}.console-entry.is-error{background:var(--support-error-bg)}.console-entry.is-error .console-entry-level{color:var(--support-error-text)}.console-entry.is-warn{background:var(--support-warning-bg)}.console-entry.is-debug{color:var(--text-60)}.console-entry-source{flex:none;align-items:center;width:52px;height:20px;display:flex}.console-entry-context{text-overflow:ellipsis;white-space:nowrap;max-width:144px;color:var(--text-40);flex:0 auto;line-height:20px;overflow:hidden}.console-source-host{color:var(--theme);background:var(--theme-bg)}.console-source-iframe{color:var(--support-success-text);background:var(--support-success-bg)}.console-entry pre{min-width:0;font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;flex:1;margin:0;line-height:20px}.console-footnote{border-top:1px solid var(--line-subtle);color:var(--text-40);flex:none;padding:5px 16px;font-size:11px}.wb-layout{background:var(--background-base-1);flex-direction:column;height:100%;display:flex}.wb-header{border-bottom:1px solid var(--line-default);background:var(--background-base-1);flex:none;justify-content:space-between;align-items:center;gap:12px;height:40px;padding:0 14px;display:flex}.wb-header-title,.wb-header-actions{align-items:center;gap:8px;display:flex}.wb-header-title strong{font-size:13px;font-weight:600}.wb-notice{color:var(--support-error-text);background:var(--support-error-bg);border-bottom:1px solid var(--line-subtle);flex:none;padding:6px 14px;font-size:12px}.wb-stage{flex:1;min-height:0;display:flex}.wb-iframe{background:var(--background-base-1);border:0;width:100%;height:100%}.wb-empty-stage{color:var(--text-60);margin:auto;font-size:13px}.wb-drawer-head{padding-top:0;padding-bottom:0}.wb-network-panel{flex-direction:column;flex:1;min-height:0;display:flex}.wb-capture{color:var(--text-80);white-space:nowrap;cursor:pointer;align-items:center;gap:5px;display:inline-flex}.wb-capture input{accent-color:var(--theme);margin:0}.wb-network-split{flex:1;grid-template-columns:minmax(280px,42%) minmax(0,1fr);min-height:0;display:grid}.wb-request-list,.wb-inspector{min-width:0;overflow:auto}.wb-request-list{border-right:1px solid var(--line-default)}.wb-request-list table{border-spacing:0;table-layout:fixed;text-align:left;width:100%}.wb-request-list th{background:var(--background-page);color:var(--text-60);border-bottom:1px solid var(--line-default);font-weight:500;position:sticky;top:0}.wb-request-list th,.wb-request-list td{white-space:nowrap;text-overflow:ellipsis;border-bottom:1px solid var(--line-subtle);padding:5px 10px;overflow:hidden}.wb-col-sm{width:60px}.wb-col-md{width:72px}.wb-request-list tbody tr{cursor:pointer}.wb-request-list tbody tr:hover{background:var(--fill-subtle)}.wb-request-list tbody tr.is-selected{background:var(--theme-bg)}.wb-request-list tbody tr.is-failed .wb-status-cell{color:var(--support-error-text);font-weight:600}.wb-inspector{flex-direction:column;display:flex}.wb-detail-tabs{border-bottom:1px solid var(--line-subtle);background:var(--background-page);flex:none;padding:0 10px}.wb-detail-body{flex:1;overflow:auto}.wb-detail-group{border-bottom:1px solid var(--line-subtle)}.wb-detail-group summary{background:var(--background-page);cursor:pointer;padding:6px 12px;font-weight:600}.wb-kv{flex-direction:column;gap:4px;margin:8px 12px;display:flex}.wb-kv-row{grid-template-columns:minmax(90px,28%) minmax(0,1fr);gap:8px;display:grid}.wb-kv dt{color:var(--text-60);overflow-wrap:anywhere}.wb-kv dd{white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.wb-body-pre{white-space:pre-wrap;overflow-wrap:anywhere;margin:10px 12px;line-height:1.5}.wb-net-hint{color:var(--text-60);margin:12px}
@@ -0,0 +1,5 @@
1
+ (()=>{"use strict";var e,s,t,r,n,a={114(e,s,t){var r=t(274),n=t(474),a=t(88);let i="/__inspector/config",l="/__dbx/capture";var o=t(566);let c={phase:"reading",timedOut:!1,issueCount:0};function d(e,s){switch(s.type){case"reset":return c;case"initializing":case"ready":return{...e,phase:s.type,timedOut:!1};case"timeout":return"reading"===e.phase||"initializing"===e.phase?{...e,timedOut:!0}:e;case"error":return{...e,phase:"error",error:s.message,timedOut:!1};case"issue":return{...e,issueCount:e.issueCount+1,lastIssue:s.message}}}function u(e){let s=new WeakSet,t=120,r=(e,n)=>{if(--t<0)return"…";try{if("string"==typeof e)return e.slice(0,8e3);if(e instanceof Error)return(e.stack||`${e.name}: ${e.message}`).slice(0,8e3);if(null===e||"object"!=typeof e)return String(e);if(s.has(e))return"[Circular]";if(n>=3)return Array.isArray(e)?"[Array]":"[Object]";s.add(e);let t=Object.keys(e).slice(0,30).map(s=>{let t;try{t=r(e[s],n+1)}catch{t="[Unreadable]"}return Array.isArray(e)?t:`${s.slice(0,200)}: ${t}`}).join(", ");return Array.isArray(e)?`[${t}]`:`{${t}}`}catch{return"[Unreadable]"}};return e.slice(0,30).map(e=>r(e,0)).join(" ").slice(0,8e3)}function h(e,s,t){let r=["log","info","debug","warn","error"].map(r=>{let n=e.console[r],a=function(){for(var a=arguments.length,i=Array(a),l=0;l<a;l++)i[l]=arguments[l];n.apply(e.console,i);try{s(r,t(i))}catch{}};return e.console[r]=a,()=>{e.console[r]===a&&(e.console[r]=n)}}),n=e=>{if("message"in e)s("error",t([e.error??e.message,`${e.filename}:${e.lineno}:${e.colno}`]),"runtime");else{let r=e.target;s("error",t(["Resource failed to load",r?.getAttribute?.("src")??r?.getAttribute?.("href")??""]),"resource")}},a=e=>s("error",t(["Unhandled rejection:",e.reason]),"runtime");return e.addEventListener("error",n,!0),e.addEventListener("unhandledrejection",a),()=>{r.forEach(e=>e()),e.removeEventListener("error",n,!0),e.removeEventListener("unhandledrejection",a)}}class m{entries=[];listeners=new Set;sequence=0;getSnapshot=()=>this.entries;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));append(e,s,t,r){this.entries=[...this.entries.slice(-499),{id:++this.sequence,time:Date.now(),source:e,level:s,message:t.slice(0,8e3),context:r}],this.listeners.forEach(e=>e())}clear=()=>{this.entries=[],this.listeners.forEach(e=>e())}}let p=/^(?:\*|[a-zA-Z][a-zA-Z0-9+.-]*:(?:\/\/(?:\*\.)?[A-Za-z0-9._~%!$&'()*+,=@:-]+(?::\d+)?(?:\/[A-Za-z0-9._~%!$&'()*+,=@:/-]*)?)?|(?:\*\.)?[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?)$/,x=["connectDomains","resourceDomains","frameDomains","baseUriDomains"],v=["camera","microphone","geolocation","clipboardWrite"];function g(e,s){return e&&e.length>0?e.join(" "):s}let f={name:"DBX MCP Apps Inspector",version:"0.1.0"},j={openLinks:{},serverTools:{listChanged:!0},serverResources:{listChanged:!0},logging:{}};function b(e){let{session:s,consoleStore:t,tool:a,resourceUri:i,args:l,result:c,width:d,maxHeight:m,onStatus:b,onSize:w}=e,y=(0,n.useRef)(null),N=(0,n.useRef)(null),[C,k]=(0,n.useState)(!1),S=(0,n.useRef)({onStatus:b,onSize:w});return S.current={onStatus:b,onSize:w},(0,n.useEffect)(()=>{S.current.onStatus({type:"reset"});let e=y.current,r=s.getClient();if(!e?.contentWindow)return;if(!r)return void S.current.onStatus({type:"error",message:"MCP server is not connected"});let n=s.getSandboxUrl();if(!n)return void S.current.onStatus({type:"error",message:"Sandbox proxy is unavailable. Restart Inspector."});let l=new URL(n).origin;if(l===window.location.origin)return void S.current.onStatus({type:"error",message:"Sandbox proxy must use a separate origin."});let c=crypto.randomUUID(),b=s=>{s.source===e.contentWindow&&s.origin!==l?s.stopImmediatePropagation():e.contentWindow&&function(e,s,t,r,n,a,i){if(e.source!==s||e.origin!==t)return!1;let l=e.data;return!!l&&"object"==typeof l&&"dbx:console"===l.type&&l.channel===r&&"string"==typeof l.message&&"string"==typeof l.level&&!!["log","info","debug","warn","error"].includes(l.level)&&(n.append("iframe",l.level,l.message,a),"error"===l.level&&("resource"===l.issueKind||"runtime"===l.issueKind)&&i?.({kind:l.issueKind,message:l.message.slice(0,8e3)}),!0)}(s,e.contentWindow,l,c,t,a.name,e=>S.current.onStatus({type:"issue",message:e.message}))&&s.stopImmediatePropagation()};window.addEventListener("message",b);let w=!1,C=()=>window.setTimeout(()=>S.current.onStatus({type:"timeout"}),15e3),M=C(),E={...j},L=new o.T1(r,f,E,{hostContext:{theme:"light",platform:"web",displayMode:"inline",availableDisplayModes:["inline"],locale:navigator.language,timeZone:new Intl.DateTimeFormat().resolvedOptions().timeZone,userAgent:navigator.userAgent,containerDimensions:{width:d,maxHeight:m},toolInfo:{tool:a}}});N.current=L,L.addEventListener("initialized",()=>{w||(window.clearTimeout(M),k(!0),S.current.onStatus({type:"ready"}))}),L.addEventListener("sizechange",e=>{let{height:s}=e;!w&&"number"==typeof s&&Number.isFinite(s)&&s>0&&S.current.onSize({height:Math.ceil(s)})}),L.onopenlink=async e=>{let{url:s}=e;return/^https?:\/\//i.test(s)?(window.open(s,"_blank","noopener,noreferrer"),{isError:!1}):{isError:!0}},L.onloggingmessage=e=>{let{level:s,data:r,logger:n}=e;t.append("iframe","debug"===s?"debug":"info"===s||"notice"===s?"info":"warning"===s?"warn":"error",u([r]),n?`${a.name} \xb7 ${n}`:a.name)},L.onmessage=async()=>({}),L.onrequestdisplaymode=async()=>({mode:"inline"});let $=e=>{w||(t.append("host","error",u([e]),a.name),window.clearTimeout(M),S.current.onStatus({type:"error",message:e instanceof Error?e.message:String(e)}))};return L.addEventListener("sandboxready",()=>{(async()=>{var e,t;let r,n,a,l;if(w)return;let{html:o,meta:d}=function(e){for(let s of e.contents)if("text"in s&&"string"==typeof s.text){let t=s._meta?.ui??e._meta?.ui;return{html:s.text,meta:t}}throw Error("UI resource has no text (HTML) content")}(await s.readResource(i));if(w)return;let m=function(e){let s={};if(!e)return s;for(let t of x){let r=e[t];if(!Array.isArray(r))continue;let n=[];for(let e of r)"string"==typeof e&&p.test(e)?n.push(e):console.warn(`[mcp-app sandbox] dropping "${t}" entry (expected an origin such as https://example.com or https://*.example.com, a scheme such as data:, or *):`,e);n.length>0&&(s[t]=n)}return s}(d?.csp),f=function(e){if("object"!=typeof e||null===e)return;let s={...e},t={},r=!1;for(let e of v){let n=s[e];void 0!==n&&!1!==n&&("object"!=typeof n||null===n||Array.isArray(n)?console.warn(`[mcp-app sandbox] dropping unrecognized "${e}" permission value:`,n):(t[e]={},r=!0))}return r?t:void 0}(d?.permissions);E.sandbox={csp:m,permissions:f},S.current.onStatus({type:"initializing"}),window.clearTimeout(M),M=C();await L.sendSandboxResourceReady({html:(e=(r=JSON.stringify(c).replace(/</g,"\\u003c"),`<script>(${h.toString()})(window, function(level, message, issueKind) {
2
+ parent.postMessage({type: 'dbx:console', channel: ${r}, level, message, issueKind}, '*');
3
+ }, (${u.toString()}));<\/script>`+o),t=(a="'none'"===(n=g(m.resourceDomains,"'none'"))?"'unsafe-inline'":`'unsafe-inline' ${n}`,`default-src 'none'; connect-src ${g(m.connectDomains,"'none'")}; script-src ${a}; style-src ${a}; img-src ${n}; font-src ${n}; media-src ${n}; frame-src ${g(m.frameDomains,"'none'")}; base-uri ${g(m.baseUriDomains,"'self'")}; form-action 'none'; object-src 'none'; worker-src 'none'`),l=`<meta http-equiv="Content-Security-Policy" content="${t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}">`,`<!DOCTYPE html><html><head>${l}<meta charset="utf-8"></head><body>${e}</body></html>`),permissions:f})})().catch($)}),(async()=>{try{let t=new o.hJ(e.contentWindow,e.contentWindow);if(await L.connect(t),w)return void await L.close();s.installListChangedHandlers({tools:()=>void L.sendToolListChanged({}),resources:()=>void L.sendResourceListChanged({})}),e.src=n}catch(e){$(e)}})(),()=>{w=!0,window.clearTimeout(M),window.removeEventListener("message",b),N.current=null,s.installListChangedHandlers({}),L.teardownResource({}).catch(()=>{}).finally(()=>void L.close().catch(()=>{}))}},[]),(0,n.useEffect)(()=>{let e=N.current;C&&e&&e.sendToolInput({arguments:l})},[C]),(0,n.useEffect)(()=>{let e=N.current;C&&e&&c&&e.sendToolResult(c)},[C,c]),(0,n.useEffect)(()=>{N.current?.setHostContext({containerDimensions:{width:d,maxHeight:m}})},[d,m]),(0,r.jsx)("iframe",{ref:y,className:"app-iframe",title:a.name})}let w={errorCircle:{viewBox:"0 0 16 16",d:["M8 0.7a7.3 7.3 0 1 0 0 14.6A7.3 7.3 0 0 0 8 0.7ZM5.1 4.2 8 7.1l2.9-2.9.9.9L8.9 8l2.9 2.9-.9.9L8 8.9l-2.9 2.9-.9-.9L7.1 8 4.2 5.1Z"]},warningTriangle:{viewBox:"0 0 16 16",d:["M7.1 1.9a1.04 1.04 0 0 1 1.8 0l6.6 11.4a1.04 1.04 0 0 1-.9 1.55H1.4a1.04 1.04 0 0 1-.9-1.55ZM7.3 5.5v4.7h1.4V5.5Zm0 6v1.4h1.4v-1.4Z"]},messageBubble:{viewBox:"0 0 16 16",d:["M2 1.5h12a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H6l-4 3v-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1Zm1 2v1h10v-1Zm0 3v1h10v-1Zm0 3v1h7v-1Z"]},setting:{viewBox:"0 0 16 16",d:["M8 5.21213C6.46029 5.21213 5.21211 6.46031 5.21211 8.00001C5.21211 9.53972 6.46029 10.7879 8 10.7879C9.5397 10.7879 10.7879 9.53972 10.7879 8.00001C10.7879 6.46031 9.5397 5.21213 8 5.21213ZM8 6.54546C7.19667 6.54546 6.54545 7.19669 6.54545 8.00001C6.54545 8.80333 7.19667 9.45456 8 9.45456C8.80332 9.45456 9.45454 8.80333 9.45454 8.00001C9.45454 7.19669 8.80332 6.54546 8 6.54546Z","M5.73383 2.52841C6.22227 0.0461347 9.77827 0.0460849 10.2668 2.52826C12.3674 1.11863 14.8818 3.63306 13.472 5.73365C15.9541 6.22227 15.9541 9.77804 13.472 10.2666C14.8817 12.3672 12.3674 14.8816 10.2668 13.472C9.77821 15.9541 6.22232 15.9541 5.73384 13.4719C3.63323 14.8817 1.11873 12.3673 2.52844 10.2666C0.0461 9.77821 0.0460737 6.22209 2.52837 5.73361C1.11863 3.63296 3.6332 1.11848 5.73383 2.52841ZM7.04043 2.79433C7.24216 1.73522 8.75852 1.73522 8.96026 2.79433C9.13828 3.72897 10.2157 4.1754 11.0025 3.64031C11.8941 3.03406 12.9663 4.10629 12.3601 4.99784C11.8252 5.78443 12.2709 6.86212 13.2059 7.0402C14.265 7.24194 14.265 8.7583 13.2059 8.96003C12.271 9.1381 11.825 10.2157 12.36 11.0024C12.9662 11.894 11.894 12.9662 11.0025 12.3599C10.2156 11.8248 9.13827 12.2713 8.96026 13.2059C8.75853 14.265 7.24217 14.265 7.04043 13.2059C6.86237 12.2711 5.78481 11.8249 4.99798 12.3599C4.10643 12.9662 3.0342 11.8939 3.64046 11.0024C4.17567 10.2153 3.7288 9.13803 2.79433 8.96003C1.73522 8.7583 1.73522 7.24194 2.79433 7.0402L3.23419 6.95642C3.96115 6.81795 4.30825 5.98 3.89212 5.36804L3.64038 4.99784C3.03413 4.10629 4.10635 3.03406 4.99791 3.64032C5.78473 4.17536 6.86235 3.72923 7.04043 2.79433Z"]},refresh:{viewBox:"0 0 16 16",d:["M8.12435 1.86979C9.94864 1.86982 11.594 2.64073 12.7507 3.8724C12.7971 3.92188 12.8431 3.97182 12.888 4.02279V2.61979C12.888 2.2516 13.1865 1.95313 13.5547 1.95313C13.9229 1.95313 14.2214 2.2516 14.2214 2.61979V5.43229C14.2214 5.98458 13.7736 6.43229 13.2214 6.43229H10.4089C10.0407 6.43229 9.74219 6.13382 9.74219 5.76563C9.74219 5.39744 10.0407 5.09896 10.4089 5.09896H12.0475C11.9617 4.99106 11.8729 4.88557 11.7786 4.78516C10.8635 3.81064 9.56539 3.20316 8.12435 3.20313C5.35615 3.20313 3.11198 5.4473 3.11198 8.21549C3.11204 10.9836 5.35619 13.2279 8.12435 13.2279C10.1119 13.2278 11.8305 12.0707 12.6413 10.3906C12.8012 10.0591 13.1997 9.91971 13.5313 10.0794C13.8629 10.2394 14.0024 10.6384 13.8424 10.9701C12.8178 13.0936 10.643 14.5612 8.12435 14.5612C4.61981 14.5612 1.7787 11.72 1.77865 8.21549C1.77865 4.71092 4.61977 1.86979 8.12435 1.86979Z"]},arrowDown:{viewBox:"0 0 12 12",d:["M1.16207 4.61092C0.966809 4.41566 0.966809 4.09915 1.16207 3.90389C1.35733 3.70863 1.67384 3.70863 1.8691 3.90389L5.92916 7.96395C5.96821 8.003 6.03171 8.003 6.07076 7.96395L10.1308 3.90389C10.3261 3.70863 10.6426 3.70863 10.8379 3.90389C11.0331 4.09915 11.0331 4.41566 10.8379 4.61092L6.77779 8.67098C6.34822 9.10056 5.65171 9.10056 5.22213 8.67098L1.16207 4.61092Z"]},doneFill:{viewBox:"0 0 12 12",d:["M6 0.25C9.17564 0.25 11.75 2.82436 11.75 6C11.75 9.17564 9.17564 11.75 6 11.75C2.82436 11.75 0.25 9.17564 0.25 6C0.25 2.82436 2.82436 0.25 6 0.25ZM8.83301 3.40234C8.55737 3.21858 8.18484 3.29283 8.00098 3.56836L5.45459 7.38672L4.34326 6.09229C4.13585 5.8339 3.75842 5.79261 3.5 6C3.24161 6.20741 3.20033 6.58484 3.40771 6.84326L4.77588 8.45752C5.15678 8.93195 5.88901 8.89977 6.22656 8.39355L8.99902 4.23438C9.18278 3.95873 9.10854 3.58621 8.83301 3.40234Z"]},wrench:{viewBox:"0 0 24 24",d:["M10.3923 3.02511C12.5995 0.817931 15.8395 0.274772 18.5534 1.39132C18.8625 1.5186 19.0874 1.79206 19.153 2.11983C19.2186 2.44773 19.116 2.78669 18.8796 3.02315L15.696 6.20675L17.8171 8.32784L21.0007 5.14522L21.0944 5.06319C21.3222 4.88613 21.6171 4.81436 21.904 4.87179C22.2317 4.93742 22.5052 5.16234 22.6325 5.4714C23.7488 8.18516 23.2058 11.4245 20.9987 13.6316C18.8745 15.7555 15.7967 16.335 13.1491 15.3806L7.47528 21.8708C6.071 23.4765 3.63346 23.6068 2.06708 22.198L1.91864 22.0564C0.362199 20.4992 0.448139 17.9499 2.10517 16.5007L8.61591 10.8054C7.69704 8.17347 8.28734 5.13031 10.3923 3.02511ZM16.2204 2.85323C14.6426 2.70329 13.0131 3.23237 11.8063 4.43917C10.1237 6.12201 9.75834 8.62611 10.7155 10.6657C10.9049 11.0694 10.8041 11.5499 10.4684 11.8435L3.42157 18.0066C2.63533 18.6943 2.59465 19.9037 3.33271 20.6423L3.47626 20.7712C4.22048 21.373 5.32459 21.2916 5.96942 20.5544L12.1169 13.5232L12.236 13.4069C12.533 13.1637 12.9498 13.1098 13.3044 13.281C15.354 14.2706 17.8871 13.9148 19.5847 12.2175C20.7916 11.0106 21.3198 9.38121 21.1696 7.80343L19.2311 9.7419C18.4501 10.523 17.1841 10.523 16.403 9.7419L14.2819 7.62081C13.5009 6.83976 13.5009 5.57373 14.2819 4.79268L16.2204 2.85323Z"]},close:{viewBox:"0 0 16 16",d:["M12.9868 3.01216C13.2471 3.27245 13.247 3.6946 12.9868 3.95497L8.9453 7.99643L12.9891 12.0402C13.2494 12.3006 13.2494 12.7227 12.9891 12.983C12.7287 13.2431 12.3065 13.2433 12.0463 12.983L8.00249 8.93924L3.95688 12.9848C3.69654 13.2452 3.27443 13.2452 3.01408 12.9848C2.75388 12.7245 2.75378 12.3023 3.01408 12.042L7.05968 7.99643L3.01638 3.95312C2.7561 3.69285 2.75624 3.27068 3.01638 3.01032C3.27673 2.74997 3.69884 2.74997 3.95919 3.01032L8.00249 7.05362L12.044 3.01216C12.3043 2.75202 12.7265 2.75202 12.9868 3.01216Z"]},play:{viewBox:"0 0 16 16",d:["M4.5 2.9C4.5 2.13 5.33 1.65 6 2.03L13.17 6.13C13.84 6.52 13.84 7.48 13.17 7.87L6 11.97C5.33 12.35 4.5 11.87 4.5 11.1V2.9Z"]}},y={search:["M7.33 12.67A5.33 5.33 0 1 0 7.33 2a5.33 5.33 0 0 0 0 10.67Z","M14 14l-2.9-2.9"],file:["M9.33 1.33H4a1.33 1.33 0 0 0-1.33 1.34v10.66A1.33 1.33 0 0 0 4 14.67h8a1.33 1.33 0 0 0 1.33-1.34V5.33l-4-4Z","M9.33 1.33v4h4"],external:["M12 8.67v4A1.33 1.33 0 0 1 10.67 14H3.33A1.33 1.33 0 0 1 2 12.67V5.33A1.33 1.33 0 0 1 3.33 4h4","M10 2h4v4","M6.67 9.33 14 2"],fullscreen:["M2.67 6V2.67H6","M10 2.67h3.33V6","M13.33 10v3.33H10","M6 13.33H2.67V10"],fit:["M2.67 5.33V2.67h2.66","M10.67 2.67h2.66v2.66","M13.33 10.67v2.66h-2.66","M5.33 13.33H2.67v-2.66","M5.33 6.67a1.33 1.33 0 0 1 1.34-1.34h2.66a1.33 1.33 0 0 1 1.34 1.34v2.66a1.33 1.33 0 0 1-1.34 1.34H6.67a1.33 1.33 0 0 1-1.34-1.34V6.67Z"],minus:["M3.33 8h9.34"],plus:["M8 3.33v9.34","M3.33 8h9.34"]};function N(e){let{name:s,size:t=16,className:n}=e,a=w[s];return a?(0,r.jsx)("svg",{width:t,height:t,viewBox:a.viewBox,fill:"currentColor",className:n,"aria-hidden":!0,children:a.d.map(e=>(0,r.jsx)("path",{d:e,fillRule:"evenodd",clipRule:"evenodd"},e))}):(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.33,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:y[s].map(e=>(0,r.jsx)("path",{d:e},e))})}function C(e,s){let t=`dbx-mcp-inspector:size:${e}`,[r,a]=(0,n.useState)(()=>{let e=Number(localStorage.getItem(t));return Number.isFinite(e)&&e>0?e:s});return[r,(0,n.useCallback)(e=>{a(e),localStorage.setItem(t,String(Math.round(e)))},[t])]}function k(e){let{axis:s,value:t,onChange:a,bounds:i,invert:l,className:o=""}=e,[c,d]=(0,n.useState)(!1);return(0,r.jsx)("div",{role:"separator","aria-orientation":"x"===s?"vertical":"horizontal",className:`splitter splitter-${s} ${c?"is-dragging":""} ${o}`,onPointerDown:e=>{if(0!==e.button)return;e.preventDefault();let r=e.currentTarget;r.setPointerCapture(e.pointerId);let n="x"===s?e.clientX:e.clientY,[o,c]=i();d(!0),document.body.classList.add("x"===s?"is-resizing-x":"is-resizing-y");let u=e=>{let r=("x"===s?e.clientX:e.clientY)-n;a(Math.min(c,Math.max(o,t+(l?-r:r))))},h=()=>{d(!1),document.body.classList.remove("is-resizing-x","is-resizing-y"),r.removeEventListener("pointermove",u),r.removeEventListener("pointerup",h),r.removeEventListener("pointercancel",h)};r.addEventListener("pointermove",u),r.addEventListener("pointerup",h),r.addEventListener("pointercancel",h)}})}function S(e){let{items:s,value:t,onChange:n,className:a=""}=e;return(0,r.jsx)("div",{className:`tabs ${a}`,role:"tablist",children:s.map(e=>(0,r.jsx)("button",{role:"tab","aria-selected":e.value===t,className:`tab ${e.value===t?"is-active":""}`,onClick:()=>n(e.value),children:e.label},e.value))})}function M(e){let{children:s,tone:t="gray",className:n=""}=e;return(0,r.jsx)("span",{className:`tag tag-${t} ${n}`,children:s})}function E(e){let{tone:s}=e;return(0,r.jsx)("span",{className:`dot dot-${s}`})}function L(e){let{icon:s,title:t,onClick:n,disabled:a,size:i=16}=e;return(0,r.jsx)("button",{className:"icon-btn",title:t,"aria-label":t,onClick:n,disabled:a,children:(0,r.jsx)(N,{name:s,size:i})})}function $(e){let{children:s,variant:t="default",onClick:n,disabled:a,icon:i,className:l=""}=e;return(0,r.jsxs)("button",{className:`btn btn-${t} ${l}`,onClick:n,disabled:a,children:[i&&(0,r.jsx)(N,{name:i,size:14}),s]})}function R(e){let{value:s,onChange:t,placeholder:n,className:a=""}=e;return(0,r.jsxs)("label",{className:`search ${a}`,children:[(0,r.jsx)(N,{name:"search",size:14}),(0,r.jsx)("input",{value:s,placeholder:n,onChange:e=>t(e.target.value)})]})}function T(e){let{items:s,value:t,onChange:n}=e;return(0,r.jsx)("div",{className:"segmented",children:s.map(e=>(0,r.jsx)("button",{className:e.value===t?"is-active":"",onClick:()=>n(e.value),children:e.label},e.value))})}function O(e){let{value:s,options:t,onChange:a,placeholder:i="—",className:l=""}=e,[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!o)return;let e=e=>{d.current?.contains(e.target)||c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]);let u=t.find(e=>e.value===s);return(0,r.jsxs)("div",{className:`dropdown ${l}`,ref:d,children:[(0,r.jsxs)("button",{className:"dropdown-trigger",onClick:()=>c(e=>!e),children:[(0,r.jsx)("span",{className:u?"":"is-placeholder",children:u?.label??i}),(0,r.jsx)(N,{name:"arrowDown",size:12})]}),o&&(0,r.jsxs)("div",{className:"dropdown-menu",role:"listbox",children:[0===t.length&&(0,r.jsx)("div",{className:"dropdown-empty",children:"暂无选项"}),t.map(e=>(0,r.jsx)("button",{role:"option","aria-selected":e.value===s,className:e.value===s?"is-active":"",onClick:()=>{a(e.value),c(!1)},children:e.label},e.value))]})]})}function U(e){return new Date(e).toLocaleTimeString("zh-CN",{hour12:!1})}let I=[.5,.75,.9,1,1.1,1.25,1.5,2];function q(e){let{width:s,onResize:t,resizeBounds:a,session:i,consoleStore:l,connectionStatus:o,hasUiTools:u,app:h,run:m,frameNonce:p,onReload:x,onOpenConsole:v}=e,[g,f]=(0,n.useState)(1),[j,w]=(0,n.useReducer)(d,c),[y,C]=(0,n.useState)(),[M,$]=function(){let e=(0,n.useRef)(null),[s,t]=(0,n.useState)({width:0,height:0});return(0,n.useEffect)(()=>{if(!e.current)return;let s=new ResizeObserver(e=>{let[s]=e;return t({width:s.contentRect.width,height:s.contentRect.height})});return s.observe(e.current),()=>s.disconnect()},[]),[e,s]}(),R=(0,n.useRef)(null),T=Math.max(320,Math.floor($.width/g)),O=JSON.stringify([h?.tool.name,h?.resourceUri,m?.runId,p]),U=Math.max(0,($.height-30)/g),q=y?.key===O?y.height:void 0,z={width:T,height:Math.min(q??U,U)},A=e=>{let s=I.findIndex(e=>e>=g-.001);f(I[Math.min(I.length-1,Math.max(0,s+e))])},P="connected"===o&&h&&m,H="error"===j.phase?{tone:"error",label:"加载失败",title:j.error}:j.timedOut?{tone:"warning",label:"reading"===j.phase?"等待读取":"等待初始化",title:"reading"===j.phase?"读取 UI 页面已超过 15 秒":"等待页面完成 MCP 初始化已超过 15 秒"}:{tone:"ready"===j.phase?"success":"warning",label:"ready"===j.phase?"已就绪":"加载中",title:"ready"===j.phase?"页面已完成 MCP 初始化":"reading"===j.phase?"正在读取 UI 页面":"等待页面完成 MCP 初始化"},D=j.issueCount+Number("error"===j.phase),B=`${D} 条页面错误,点击查看 Console`;return(0,r.jsxs)("section",{className:"canvas-pane",ref:R,style:{width:s},children:[(0,r.jsx)(k,{axis:"x",className:"splitter-edge",value:s,onChange:t,bounds:a}),(0,r.jsxs)("header",{className:"pane-topbar",children:[(0,r.jsx)(S,{className:"pane-topbar-tabs",items:[{value:"canvas",label:"画布"}],value:"canvas",onChange:()=>{}}),(0,r.jsx)("div",{className:"pane-topbar-side",children:(0,r.jsx)(L,{icon:"refresh",title:"重新加载画布",onClick:x,disabled:!P})})]}),(0,r.jsxs)("div",{className:"canvas-statusbar card","aria-label":"预览控制",children:[(0,r.jsx)("div",{className:"canvas-statusbar-left",children:P?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"canvas-status",title:H.title,children:[(0,r.jsx)(E,{tone:H.tone}),H.label]}),(0,r.jsx)("span",{className:"canvas-uri",title:h.resourceUri,children:h.resourceUri})]}):(0,r.jsxs)("span",{className:"canvas-status",children:[(0,r.jsx)(E,{tone:"idle"}),"未渲染"]})}),(0,r.jsxs)("div",{className:"zoom-group",role:"group","aria-label":"画布缩放",children:[(0,r.jsx)("button",{title:"缩小",onClick:()=>A(-1),children:(0,r.jsx)(N,{name:"minus",size:14})}),(0,r.jsxs)("span",{children:[Math.round(100*g),"%"]}),(0,r.jsx)("button",{title:"放大",onClick:()=>A(1),children:(0,r.jsx)(N,{name:"plus",size:14})}),(0,r.jsx)(L,{icon:"fit",title:"适应画布",onClick:()=>{if(!q)return f(1);let e=($.height-30)/q;f([...I].reverse().find(s=>s<=Math.min(1,e))??I[0])}})]}),(0,r.jsxs)("div",{className:"canvas-statusbar-right",children:[(0,r.jsx)("span",{className:"canvas-dimensions",children:P&&z.height>0?`${z.width} \xd7 ${Math.ceil(z.height)}`:"—"}),(0,r.jsx)(L,{icon:"fullscreen",title:"全屏",onClick:()=>{document.fullscreenElement?document.exitFullscreen():R.current?.requestFullscreen()}})]})]}),(0,r.jsx)("div",{className:"canvas-stage",ref:M,children:"error"===o?(0,r.jsx)("div",{className:"canvas-empty",children:"连接失败,请检查连接设置"}):"disconnected"===o?(0,r.jsx)("div",{className:"canvas-empty",children:"未连接到 MCP Server"}):h&&m?(0,r.jsxs)("div",{className:"canvas-frame-wrap",style:{width:T*g},children:[(0,r.jsxs)("div",{className:"canvas-frame-label",children:[(0,r.jsx)("span",{children:h.tool.name}),(0,r.jsxs)("span",{className:"canvas-frame-state",children:[(0,r.jsxs)("span",{className:"canvas-frame-state",title:H.title,children:[(0,r.jsx)(E,{tone:H.tone}),H.label]}),D>0&&(0,r.jsxs)("button",{className:"canvas-frame-issues",title:`${B}
4
+ ${j.error??j.lastIssue??""}`,"aria-label":B,"aria-controls":"console-drawer",onClick:v,children:[(0,r.jsx)(N,{name:"errorCircle",size:12}),(0,r.jsx)("span",{children:D})]})]})]}),(0,r.jsx)("div",{className:"canvas-frame",children:(0,r.jsx)("div",{className:"canvas-frame-content",style:{transform:`scale(${g})`,width:T,height:z.height},children:(0,r.jsx)(b,{session:i,consoleStore:l,tool:h.tool,resourceUri:h.resourceUri,args:m.args,result:m.result,width:T,maxHeight:U,onStatus:w,onSize:e=>C({key:O,height:e.height})},O)})})]}):(0,r.jsx)("div",{className:"canvas-empty",children:"connected"!==o||u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"尚未预览"}),(0,r.jsx)("span",{children:"在 Tools 中运行带 UI 的 Tool,此处将展示 UI"})]}):"当前 Server 没有带 UI 的 Tool"})})]})}var z=t(306);let A="x-mcp-target",P="Streamable HTTP";function H(e){return"starting"===e||"connecting"===e}let D="dbx-mcp-inspector:connection";async function B(){try{let e=await fetch(i,{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}let Z={200:"OK",201:"Created",202:"Accepted",204:"No Content",400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",500:"Internal Server Error",502:"Bad Gateway"};function J(e){return e.error?"Failed":void 0===e.status?"Pending":`${e.status} ${e.statusText||Z[e.status]||""}`.trim()}function F(e){let s={};return e.forEach((e,t)=>{t!==A&&(s[t]=e)}),s}class _{state;listeners=new Set;client=null;sandboxUrl=null;nextId=1;forwarders={};constructor(){this.state={config:{endpoint:"",headers:{}},status:"starting",tools:[],resources:[],network:[],log:[]}}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getState=()=>this.state;getClient=()=>this.client;getSandboxUrl=()=>this.sandboxUrl;set(e){for(let s of(this.state={...this.state,...e},this.listeners))s()}updateNetwork(e,s){this.set({network:this.state.network.map(t=>t.id===e?{...t,...s}:t)})}pushNetwork(e){this.set({network:[...this.state.network,e].slice(-500)})}pushLog(e){let s={id:this.nextId++,time:Date.now(),...e};this.set({log:[...this.state.log,s].slice(-500)})}updateLatestLog(e,s){let t=this.state.log;for(let r=t.length-1;r>=0;r--)if(e(t[r]))return this.set({log:t.map((e,t)=>t===r?{...e,...s}:e)}),!0;return!1}recordMessage=(e,s)=>{if(void 0===s.method){let t="in"===e?"out":"in";if(this.updateLatestLog(e=>e.direction===t&&"request"===e.kind&&e.rpcId===s.id&&!e.response,{response:s,respondedAt:Date.now()}))return}this.pushLog({direction:e,kind:void 0!==s.id&&void 0!==s.method?"request":"notification",label:s.method?"tools/call"===s.method&&s.params?.name?`${s.method} \xb7 ${s.params.name}`:s.method:void 0!==s.id?`response #${String(s.id)}`:"message",method:s.method,rpcId:s.id,request:s})};clearLogs(){this.set({network:[],log:[]})}trackedFetch=async(e,s)=>{let t,r="string"==typeof e?e:e instanceof URL?e.href:e.url,n=(s?.method??"GET").toUpperCase(),a=new Headers(s?.headers);a.set(A,r);let i="string"==typeof s?.body?s.body:void 0,l=this.nextId++,o=performance.now();this.pushNetwork({id:l,startedAt:Date.now(),method:n,url:r,requestHeaders:F(a),requestBody:i,responseBody:"",streaming:!0});let[c]=function(e){if(!e)return[];try{let s=JSON.parse(e);return Array.isArray(s)?s:[s]}catch{return[]}}(i);c&&this.updateLatestLog(e=>void 0===e.httpId&&e.rpcId===c.id&&(void 0!==c.method?"out"===e.direction&&e.method===c.method:"in"===e.direction&&"request"===e.kind),{httpId:l})||this.pushLog({direction:"out",kind:"http",label:"GET"===n?"GET stream (SSE)":"DELETE"===n?"session/terminate":n,httpId:l});try{t=await fetch("/__mcp_proxy",{...s,method:n,headers:a})}catch(e){throw this.updateNetwork(l,{streaming:!1,error:e instanceof Error?e.message:String(e),durationMs:Math.round(performance.now()-o)}),e}let d=t.headers.get("content-type")?.includes("text/event-stream");this.updateNetwork(l,{status:t.status,statusText:t.statusText,responseHeaders:F(t.headers),..."GET"===n?{durationMs:Math.round(performance.now()-o)}:{}});let u=t.clone();return(async()=>{let e="";try{let s=u.body?.getReader(),t=new TextDecoder;for(;s;){let{done:r,value:n}=await s.read();if(r)break;e+=t.decode(n,{stream:!0}),d&&this.updateNetwork(l,{responseBody:e})}}catch{}this.updateNetwork(l,{responseBody:e,streaming:!1,..."GET"===n?{}:{durationMs:Math.round(performance.now()-o)}})})(),t};async start(){let e=await B();if(this.sandboxUrl=e?.sandboxUrl??null,"starting"!==this.state.status)return!0;let s=e?.endpoint?{endpoint:e.endpoint,headers:e.headers}:function(){try{let e=localStorage.getItem(D);if(!e)return null;let{endpoint:s,headers:t}=JSON.parse(e);if("string"!=typeof s)return null;return{endpoint:s,headers:t&&"object"==typeof t?t:{}}}catch{return null}}();return s?.endpoint?(await this.connect(s),!0):(this.set({status:"disconnected"}),!1)}async connect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state.config;localStorage.setItem(D,JSON.stringify(e)),this.set({config:e,status:"connecting",error:void 0,latencyMs:void 0,serverInfo:void 0,tools:[],resources:[]});let s=new z.Kj({name:"dbx-mcp-apps-inspector",version:"0.1.0"},{capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:[o.fU]}}}}),t=this.client;this.client=s,s.onclose=()=>{this.client===s&&"connected"===this.state.status&&(this.client=null,this.set({status:"disconnected"}))};let r=performance.now();try{var n;let a;if(await t?.close().catch(()=>{}),this.client!==s)return;let i=new z.jS(new URL(e.endpoint),{fetch:this.trackedFetch,requestInit:{headers:e.headers}});if(await s.connect((n=this.recordMessage,i.onmessage=(e,s)=>{n("in",e),a?.(e,s)},new Proxy(i,{get(e,s,t){if("onmessage"===s)return a;if("send"===s)return(s,t)=>(n("out",s),e.send(s,t));let r=Reflect.get(e,s,t);return"function"==typeof r?r.bind(e):r},set:(e,s,t)=>"onmessage"===s?(a=t,!0):Reflect.set(e,s,t)}))),this.client!==s)return void await s.close();let l=Math.round(performance.now()-r),[o,c]=await Promise.all([this.readTools(s),this.readResources(s)]);if(this.client!==s)return;this.installListChangedHandlers(),this.set({status:"connected",latencyMs:l,serverInfo:s.getServerVersion(),tools:o,resources:c})}catch(e){this.client===s&&(this.client=null,this.set({status:"error",error:e instanceof Error?e.message:String(e)})),await s.close().catch(()=>{})}}async disconnect(){let e=this.client;if(this.client=null,e)try{await e.close()}catch{}"disconnected"!==this.state.status&&this.set({status:"disconnected"})}installListChangedHandlers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.forwarders;this.forwarders=e;let s=this.client;s&&(s.setNotificationHandler("notifications/tools/list_changed",()=>{this.refreshTools(),this.forwarders.tools?.()}),s.setNotificationHandler("notifications/resources/list_changed",()=>{this.refreshResources(),this.forwarders.resources?.()}))}async refreshLists(){await Promise.all([this.refreshTools(),this.refreshResources()])}async readTools(e){let s;if(!e.getServerCapabilities()?.tools)return[];let t=[];do{let r=await e.listTools(s?{cursor:s}:void 0);t.push(...r.tools),s=r.nextCursor}while(s)return t}async refreshTools(){let e=this.client;if(e)try{let s=await this.readTools(e);this.client===e&&this.set({tools:s})}catch(e){console.error("[inspector] tools/list failed",e)}}async readResources(e){let s;if(!e.getServerCapabilities()?.resources)return[];let t=[];do{let r=await e.listResources(s?{cursor:s}:void 0);t.push(...r.resources),s=r.nextCursor}while(s)return t}async refreshResources(){let e=this.client;if(e)try{let s=await this.readResources(e);this.client===e&&this.set({resources:s})}catch(e){console.error("[inspector] resources/list failed",e)}}requireClient(){if(!this.client)throw Error("MCP server is not connected");return this.client}callTool(e,s){return this.requireClient().callTool({name:e,arguments:s})}readResource(e){return this.requireClient().readResource({uri:e})}}function W(e){let{store:s,active:t,filters:a,onFiltersChange:i}=e,l=(0,n.useSyncExternalStore)(s.subscribe,s.getSnapshot),{query:o,source:c,level:d}=a,u=(0,n.useRef)(null),h=(0,n.useRef)(!0);(0,n.useEffect)(()=>{let e=u.current;t&&e&&h.current&&(e.scrollTop=e.scrollHeight)},[t,l,o,c,d]);let m=l.filter(e=>("all"===c||e.source===c)&&("all"===d||("messages"===d?"warn"!==e.level&&"error"!==e.level:e.level===d))&&`${e.message} ${e.context??""}`.toLowerCase().includes(o.toLowerCase()));return(0,r.jsxs)("div",{className:"console-panel",children:[(0,r.jsxs)("div",{className:"console-toolbar",children:[(0,r.jsx)(R,{value:o,onChange:e=>i({...a,query:e}),placeholder:"搜索日志…"}),(0,r.jsx)(O,{value:c,onChange:e=>i({...a,source:e}),options:[{value:"all",label:"全部来源"},{value:"host",label:"宿主页面"},{value:"iframe",label:"iframe"}]}),(0,r.jsx)(O,{value:d,onChange:e=>i({...a,level:e}),options:[{value:"all",label:"全部级别"},{value:"messages",label:"普通日志"},...["error","warn","info","log","debug"].map(e=>({value:e,label:e}))]}),(0,r.jsx)($,{onClick:s.clear,children:"清空"})]}),(0,r.jsxs)("div",{className:"console-list","aria-label":"Console 日志",ref:u,onScroll:e=>{let s=e.currentTarget;h.current=s.scrollHeight-s.scrollTop-s.clientHeight<24},children:[0===m.length&&(0,r.jsx)("div",{className:"console-empty",children:l.length?"没有匹配的日志":"等待日志… 宿主页面和 UI iframe 的日志、错误会显示在这里。"}),m.map(e=>(0,r.jsxs)("div",{className:`console-entry is-${e.level}`,children:[(0,r.jsx)("time",{children:new Date(e.time).toLocaleTimeString("en-GB",{hour12:!1})}),(0,r.jsx)("span",{className:"console-entry-level",children:e.level}),(0,r.jsx)("div",{className:"console-entry-source",children:(0,r.jsx)(M,{className:`tag-xs console-source-${e.source}`,children:"host"===e.source?"宿主":"iframe"})}),(0,r.jsx)("pre",{children:e.message}),e.context&&(0,r.jsx)("span",{className:"console-entry-context",title:e.context,children:e.context})]},e.id))]}),(0,r.jsxs)("div",{className:"console-footnote",children:[m.length," / ",l.length," 条 · 保留最近 500 条 · 宿主指 Inspector 页面"]})]})}function V(e){let{store:s,state:t,viewportHeight:a,openRequest:i}=e,l=(0,n.useSyncExternalStore)(s.subscribe,s.getSnapshot),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)({query:"",source:"all",level:"all"}),[h,m]=C("console-drawer",280),p=(0,n.useRef)(null),x=(0,n.useRef)(null);(0,n.useEffect)(()=>{i&&(u(i),c(!0),x.current?.querySelector("input")?.focus())},[i]),(0,n.useEffect)(()=>{if(!o)return;x.current?.querySelector("input")?.focus();let e=e=>{"Escape"===e.key&&!e.defaultPrevented&&x.current?.contains(e.target)&&(c(!1),p.current?.focus())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o]);let v=Math.max(180,a-400),g=Math.min(v,Math.max(180,h)),f=l.filter(e=>"error"===e.level).length,j=l.filter(e=>"warn"===e.level).length,b=l.length-f-j,w=e=>{u({query:"",source:"all",level:e}),c(!0)};return(0,r.jsxs)("div",{className:"console-dock",children:[(0,r.jsxs)("section",{id:"console-drawer",className:"console-drawer",hidden:!o,style:{height:g},"aria-label":"Console",ref:x,children:[(0,r.jsx)(k,{axis:"y",invert:!0,className:"console-resize",value:g,onChange:m,bounds:()=>[180,v]}),(0,r.jsxs)("div",{className:"console-drawer-head",children:[(0,r.jsx)("span",{children:"Console"}),(0,r.jsx)(L,{icon:"close",title:"收起 Console",onClick:()=>{c(!1),p.current?.focus()}})]}),(0,r.jsx)(W,{store:s,active:o,filters:d,onFiltersChange:u})]}),(0,r.jsxs)("footer",{className:"workspace-statusbar",children:[(0,r.jsxs)("span",{className:"workspace-connection",children:[(0,r.jsx)(E,{tone:"connected"===t.status?"success":"error"===t.status?"error":"idle"}),"connected"===t.status?"Server connected":H(t.status)?"Connecting…":"error"===t.status?"Connection failed":"Server disconnected",(0,r.jsxs)("span",{className:"workspace-transport",children:[P," · ",t.network.length," requests"]})]}),(0,r.jsxs)("div",{className:"console-indicators","aria-label":"Console 日志统计",children:[f>0&&(0,r.jsxs)("button",{className:"console-indicator is-error",title:`${f} 条错误,点击查看`,"aria-label":`查看 ${f} 条错误`,"aria-controls":"console-drawer","aria-expanded":o,onClick:()=>w("error"),children:[(0,r.jsx)(N,{name:"errorCircle",size:14}),(0,r.jsx)("span",{children:f})]}),j>0&&(0,r.jsxs)("button",{className:"console-indicator is-warn",title:`${j} 条警告,点击查看`,"aria-label":`查看 ${j} 条警告`,"aria-controls":"console-drawer","aria-expanded":o,onClick:()=>w("warn"),children:[(0,r.jsx)(N,{name:"warningTriangle",size:14}),(0,r.jsx)("span",{children:j})]}),(0,r.jsxs)("button",{className:"console-indicator is-info",title:`${b} 条普通日志,点击查看`,"aria-label":`查看 ${b} 条普通日志`,"aria-controls":"console-drawer","aria-expanded":o,onClick:()=>w(b?"messages":"all"),children:[(0,r.jsx)(N,{name:"messageBubble",size:14}),(0,r.jsx)("span",{children:b})]}),(0,r.jsxs)("button",{ref:p,className:`console-toggle ${o?"is-active":""}`,"aria-expanded":o,"aria-controls":"console-drawer",onClick:()=>c(e=>!e),children:["Console ",(0,r.jsx)(N,{name:"arrowDown",size:12})]})]})]})]})}let K=/("(?:\\.|[^"\\])*")(\s*:)?|\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b|\b(true|false|null)\b/g;function G(e){let{code:s,language:t="json",className:n=""}=e,a=s.split("\n");return(0,r.jsx)("div",{className:`code ${n}`,children:(0,r.jsx)("div",{className:"code-scroll",children:a.map((e,s)=>(0,r.jsxs)("div",{className:"code-line",children:[(0,r.jsx)("span",{className:"code-gutter",children:s+1}),(0,r.jsx)("span",{className:"code-text",children:"json"===t?function(e){let s=[],t=0;for(let n of e.matchAll(K)){let a=n.index??0;a>t&&s.push(e.slice(t,a));let[i,l,o,c,d]=n;void 0!==l?(s.push((0,r.jsx)("span",{className:o?"tok-key":"tok-string",children:l},a)),o&&s.push(o)):void 0!==c?s.push((0,r.jsx)("span",{className:"tok-number",children:c},a)):void 0!==d?s.push((0,r.jsx)("span",{className:"tok-literal",children:d},a)):s.push(i),t=a+i.length}return t<e.length&&s.push(e.slice(t)),s}(e):e})]},s))})})}function X(e){let{value:s,onChange:t,invalid:a,className:i=""}=e,l=(0,n.useRef)(null),o=s.split("\n").length;return(0,r.jsxs)("div",{className:`code code-editor ${a?"is-invalid":""} ${i}`,children:[(0,r.jsx)("div",{className:"code-gutter-col",ref:l,children:Array.from({length:o},(e,s)=>(0,r.jsx)("div",{children:s+1},s))}),(0,r.jsx)("textarea",{spellCheck:!1,value:s,onChange:e=>t(e.target.value),onScroll:e=>{l.current&&(l.current.scrollTop=e.currentTarget.scrollTop)}})]})}function Y(e){if(!e)return{code:"",json:!1};try{return{code:JSON.stringify(JSON.parse(e),null,2),json:!0}}catch{return{code:e,json:!1}}}function Q(e){return{code:JSON.stringify(e,null,2),json:!0}}function ee(e,s){return"request"===e.kind?void 0!==e.respondedAt?`${e.respondedAt-e.time} ms`:"…":s?.durationMs!==void 0?`${s.durationMs} ms`:s?.streaming?"…":"—"}function es(e){let{title:s,rows:t}=e;return(0,r.jsxs)("section",{className:"kv-section",children:[(0,r.jsx)("h4",{children:s}),0===t.length?(0,r.jsx)("div",{className:"kv-empty",children:"—"}):t.map(e=>{let[s,t]=e;return(0,r.jsxs)("div",{className:"kv-row",children:[(0,r.jsx)("span",{className:"kv-key",children:s}),(0,r.jsx)("span",{className:"kv-value",children:t})]},s)})]})}function et(e){let{entry:s,http:t}=e;return t?(0,r.jsxs)("div",{className:"kv-view",children:[(0,r.jsx)(es,{title:"General",rows:[["Request URL",t.url],["Request Method",t.method],["Status Code",t.error?`Failed \xb7 ${t.error}`:J(t)],..."http"!==s.kind?[["JSON-RPC",`${s.method??s.label} → ${function(e){if("notification"===e.kind)return"Notification(无响应)";let s=e.response?.error;return s?`Error ${s.code??""} \xb7 ${s.message??""}`.trim():e.response?"Result":"Pending"}(s)}`]]:[],["Duration",ee(s,t)]]}),(0,r.jsx)(es,{title:"Response Headers",rows:Object.entries(t.responseHeaders??{})}),(0,r.jsx)(es,{title:"Request Headers",rows:Object.entries(t.requestHeaders)})]}):(0,r.jsx)("div",{className:"kv-view",children:(0,r.jsx)(es,{title:"General",rows:[["来源","Server → Client(经 SSE 流推送)"],["JSON-RPC",s.method??s.label],...void 0!==s.rpcId?[["ID",String(s.rpcId)]]:[],["时间",U(s.time)]]})})}function er(e){let{entry:s,http:t,tab:n,onTab:a,onClose:i}=e,l="headers"===n?null:function(e,s,t){if("request"===t){if(e.request)return Q(e.request);let t=Y(s?.requestBody);return t.code?t:{code:"(无请求体)",json:!1}}if(e.response)return Q(e.response);if("http"===e.kind&&s){if(s.error)return{code:s.error,json:!1};let e=s.responseHeaders?.["content-type"]?.includes("text/event-stream")?function(e){let s=e.split(/\n\n+/).map(e=>e.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trim()).join("\n")).filter(Boolean);if(0===s.length)return{code:e,json:!1};let t=s.map(e=>Y(e));return{code:t.map(e=>e.code).join("\n"),json:t.every(e=>e.json)}}(s.responseBody):Y(s.responseBody);return e.code?e:{code:s.streaming?"(接收中…)":"(无响应体)",json:!1}}return s?.error?{code:s.error,json:!1}:"notification"===e.kind?{code:"(通知没有响应)",json:!1}:{code:"(等待响应…)",json:!1}}(s,t,n);return(0,r.jsxs)("div",{className:"log-detail",children:[(0,r.jsxs)("div",{className:"log-detail-head",children:[(0,r.jsx)(L,{icon:"close",size:14,title:"关闭",onClick:i}),(0,r.jsx)(S,{value:n,onChange:a,items:[{value:"headers",label:"Headers"},{value:"request",label:"Request"},{value:"response",label:"Response"}]})]}),(0,r.jsxs)("div",{className:"log-detail-title",children:[(0,r.jsx)(M,{className:"tag-xs",children:t?t.method:"SSE"}),(0,r.jsx)("span",{title:s.label,children:s.label})]}),l?(0,r.jsx)(G,{className:"log-detail-code",code:l.code,language:l.json?"json":"text"}):(0,r.jsx)(et,{entry:s,http:t})]})}function en(e){let{session:s,state:t}=e,[a,i]=(0,n.useState)(""),[l,o]=(0,n.useState)("desc"),[c,d]=(0,n.useState)(null),[u,h]=(0,n.useState)("response"),[m,p]=C("request-detail-height",320),[x,v]=(0,n.useState)(600),g=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=g.current;if(!e)return;let s=new ResizeObserver(e=>{let[s]=e;return v(s.contentRect.height)});return s.observe(e),()=>s.disconnect()},[]);let f=Math.max(120,x-130),j=Math.min(f,Math.max(120,m)),b=(0,n.useMemo)(()=>new Map(t.network.map(e=>[e.id,e])),[t.network]),w=a.trim().toLowerCase(),y=(0,n.useMemo)(()=>{let e=w?t.log.filter(e=>e.label.toLowerCase().includes(w)||JSON.stringify([e.request,e.response]).toLowerCase().includes(w)):t.log;return"desc"===l?[...e].reverse():e},[t.log,w,l]),N=y.find(e=>e.id===c),S=void 0!==N;return(0,n.useEffect)(()=>{if(!S)return;let e=e=>{"Escape"===e.key&&!e.defaultPrevented&&g.current?.contains(e.target)&&!document.querySelector(".dialog")&&d(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[S]),(0,r.jsxs)("div",{className:"debug-log",children:[(0,r.jsxs)("div",{className:"debug-log-actions",children:[(0,r.jsx)(R,{className:"debug-log-search",value:a,onChange:i,placeholder:"搜索请求..."}),(0,r.jsx)(O,{className:"debug-log-order",value:l,onChange:o,options:[{value:"desc",label:"最新优先"},{value:"asc",label:"最早优先"}]}),(0,r.jsx)($,{onClick:()=>{var e,s;let r,n;return e=`mcp-debug-log-${Date.now()}.json`,s=t.log.map(e=>({...e,http:void 0!==e.httpId?b.get(e.httpId):void 0})),r=URL.createObjectURL(new Blob([JSON.stringify(s,null,2)],{type:"application/json"})),void((n=document.createElement("a")).href=r,n.download=e,n.click(),URL.revokeObjectURL(r))},children:"导出"}),(0,r.jsx)($,{onClick:()=>s.clearLogs(),children:"清空"})]}),(0,r.jsxs)("div",{className:"debug-log-body",ref:g,children:[(0,r.jsx)("div",{className:"log-table",children:(0,r.jsxs)("div",{className:"log-rows",children:[0===y.length&&(0,r.jsx)("div",{className:"log-empty",children:w?"无匹配结果":"暂无请求"}),y.map(e=>{let s,t=void 0!==e.httpId?b.get(e.httpId):void 0,n=(s=e.response?.error)?{label:`Error ${s.code??""}`.trim(),tone:"error"}:"http"===e.kind&&t?.method==="GET"&&405===t.status?{label:"405 未开启推送流",tone:"gray"}:t?.error||(t?.status??0)>=400?{label:J(t),tone:"error"}:"request"!==e.kind||e.response?t?.status!==void 0?{label:J(t),tone:"success"}:e.response?{label:"OK",tone:"success"}:{label:"in"===e.direction?"SSE":"Sent",tone:"gray"}:{label:"Pending",tone:"gray"},a=(0,r.jsxs)("span",{className:`log-cell-main ${"error"===n.tone?"is-error":""}`,children:["in"===e.direction&&(0,r.jsx)("span",{className:"log-dir",title:"服务端发起",children:"←"}),e.label,"notification"===e.kind&&(0,r.jsx)("span",{className:"log-kind",children:"notify"})]});return(0,r.jsxs)("button",{className:`log-row ${e.id===N?.id?"is-active":""}`,onClick:()=>d(e.id),title:`${U(e.time)} \xb7 ${n.label} \xb7 ${ee(e,t)}`,"aria-pressed":e.id===N?.id,children:[(0,r.jsxs)("span",{className:"log-row-main",children:[a,(0,r.jsx)(M,{className:"tag-xs",tone:n.tone,children:n.label})]}),(0,r.jsxs)("span",{className:"log-row-meta",children:[(0,r.jsxs)("span",{children:[U(e.time)," · ",t?t.method:"SSE"]}),(0,r.jsx)("span",{children:ee(e,t)})]})]},e.id)})]})}),N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k,{axis:"y",invert:!0,className:"splitter-gap",value:j,onChange:p,bounds:()=>[120,f]}),(0,r.jsx)("div",{className:"log-detail-pane",style:{height:j},children:(0,r.jsx)(er,{entry:N,http:void 0!==N.httpId?b.get(N.httpId):void 0,tab:u,onTab:h,onClose:()=>d(null)})})]})]})]})}function ea(e){let{width:s,onResize:t,resizeBounds:n,session:a,state:i}=e;return(0,r.jsxs)("aside",{className:"requests-pane",style:{width:s},"aria-label":"请求记录",children:[(0,r.jsx)(k,{axis:"x",invert:!0,className:"splitter-edge is-leading",value:s,onChange:t,bounds:n}),(0,r.jsxs)("header",{className:"pane-topbar requests-topbar",children:[(0,r.jsxs)("span",{children:["请求记录 ",(0,r.jsx)("span",{className:"tab-count",children:i.log.length})]}),(0,r.jsx)("span",{className:"requests-protocol",children:"HTTP / JSON-RPC"})]}),(0,r.jsx)("div",{className:"requests-body",children:(0,r.jsx)("div",{className:"card inspector-panel",children:(0,r.jsx)(en,{session:a,state:i})})})]})}function ei(e){return Object.entries(e.properties??{})}function el(e){return Array.isArray(e.type)?e.type.find(e=>"null"!==e):e.type}function eo(e){let{value:s,onChange:t}=e,[a,i]=(0,n.useState)(()=>void 0===s?"":JSON.stringify(s)),[l,o]=(0,n.useState)(!1);return(0,r.jsx)("input",{className:`form-input mono ${l?"is-invalid":""}`,value:a,placeholder:"JSON",onChange:e=>{if(i(e.target.value),""===e.target.value.trim())return o(!1),t(void 0);try{t(JSON.parse(e.target.value)),o(!1)}catch{o(!0)}}})}function ec(e){let{schema:s,value:t,onChange:n}=e,a=ei(s),i=new Set(s.required??[]);if(0===a.length)return(0,r.jsx)("div",{className:"args-form-empty",children:"该工具无需输入参数"});let l=(e,s)=>{let r={...t};void 0===s?delete r[e]:r[e]=s,n(r)};return(0,r.jsx)("div",{className:"args-form",children:a.map(e=>{let s,[n,a]=e,o=el(a),c=t[n];return s=a.enum?(0,r.jsxs)("select",{className:"form-input",value:void 0===c?"":JSON.stringify(c),onChange:e=>l(n,""===e.target.value?void 0:JSON.parse(e.target.value)),children:[(0,r.jsx)("option",{value:"",children:"—"}),a.enum.map(e=>(0,r.jsx)("option",{value:JSON.stringify(e),children:String(e)},JSON.stringify(e)))]}):"boolean"===o?(0,r.jsx)("input",{type:"checkbox",checked:!0===c,onChange:e=>l(n,e.target.checked)}):"number"===o||"integer"===o?(0,r.jsx)("input",{className:"form-input",type:"number",value:"number"==typeof c?c:"",onChange:e=>l(n,""===e.target.value?void 0:Number(e.target.value))}):"string"===o||void 0===o?(0,r.jsx)("input",{className:"form-input",value:"string"==typeof c?c:"",onChange:e=>l(n,e.target.value)}):(0,r.jsx)(eo,{value:c,onChange:e=>l(n,e)}),(0,r.jsxs)("label",{className:"form-row",children:[(0,r.jsxs)("span",{className:"form-label",children:[n,i.has(n)&&(0,r.jsx)("em",{children:"*"}),o&&(0,r.jsx)("span",{className:"form-type",children:o})]}),s,a.description&&(0,r.jsx)("span",{className:"form-help",children:a.description})]},n)})})}function ed(e){let{title:s,icon:t,placeholder:a,items:i,selected:l,onSelect:o,onRefresh:c,connected:d}=e,[u,h]=(0,n.useState)(""),[m,p]=(0,n.useState)(!1),x=(0,n.useRef)(null),v=(0,n.useRef)(null),g=(0,n.useId)();(0,n.useEffect)(()=>{if(!m)return;x.current?.querySelector("input")?.focus();let e=e=>{x.current?.contains(e.target)||p(!1)},s=e=>{"Escape"===e.key&&x.current?.contains(e.target)&&(p(!1),v.current?.focus())};return document.addEventListener("mousedown",e),window.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("keydown",s)}},[m]);let f=u.trim().toLowerCase(),j=f?i.filter(e=>e.title.toLowerCase().includes(f)||e.subtitle?.toLowerCase().includes(f)):i,b=i.find(e=>e.key===l);return(0,r.jsxs)("div",{className:"explorer-picker",ref:x,children:[(0,r.jsxs)("div",{className:"explorer-picker-head",children:[(0,r.jsxs)("button",{className:"explorer-picker-trigger",ref:v,"aria-expanded":m,"aria-controls":g,"aria-label":`选择 ${s}`,onClick:()=>p(e=>!e),children:[(0,r.jsx)(N,{name:t,size:16}),(0,r.jsx)("span",{title:b?.title,children:b?.title??`选择 ${s}`}),b?.hasUi&&(0,r.jsx)(M,{className:"tool-ui-tag",children:"UI"}),(0,r.jsx)(N,{name:"arrowDown",size:12})]}),(0,r.jsx)(L,{icon:"refresh",title:"刷新列表",disabled:!d,onClick:c})]}),m&&(0,r.jsxs)("div",{className:"explorer-picker-menu",id:g,children:[(0,r.jsx)(R,{value:u,onChange:h,placeholder:a}),(0,r.jsxs)("div",{className:"explorer-items",children:[0===j.length&&(0,r.jsx)("div",{className:"explorer-empty",children:f?"无匹配结果":"暂无数据"}),j.map(e=>(0,r.jsxs)("button",{className:`explorer-item ${e.key===l?"is-active":""}`,"aria-pressed":e.key===l,onClick:()=>{o(e.key),p(!1),v.current?.focus()},children:[(0,r.jsx)(N,{name:t,size:18,className:"explorer-item-icon"}),(0,r.jsxs)("span",{className:"explorer-item-text",children:[(0,r.jsx)("span",{className:"explorer-item-title",children:e.title}),e.subtitle&&(0,r.jsx)("span",{className:"explorer-item-sub",children:e.subtitle})]}),e.hasUi&&(0,r.jsx)(M,{className:"tool-ui-tag",children:"UI"})]},e.key))]})]})]})}function eu(e){return JSON.stringify(e,null,2)??"undefined"}function eh(e){let{status:s,durationMs:t}=e;if("running"===s)return(0,r.jsx)("span",{className:"result-status is-running",children:"调用中…"});let n=void 0!==t?` \xb7 ${t} ms`:"";return"success"===s?(0,r.jsxs)("span",{className:"result-status is-success",children:[(0,r.jsx)(N,{name:"doneFill",size:14}),"Success",n]}):(0,r.jsxs)("span",{className:"result-status is-error",children:[(0,r.jsx)(E,{tone:"error"}),"Error",n]})}function em(e){let{tool:s,resourceUri:t,run:a,synced:i,connected:l,inputShare:o,onInputShare:c,argsText:d,onArgsText:u,onRun:h,onOpenResource:m}=e,[p,x]=(0,n.useState)("json"),[v,g]=(0,n.useState)("result"),f=(0,n.useRef)(null),[j,b]=(0,n.useState)(500);(0,n.useLayoutEffect)(()=>{let e=f.current;if(!e)return;b(e.getBoundingClientRect().height);let s=new ResizeObserver(e=>{let[s]=e;s.contentRect.height>0&&b(s.contentRect.height)});return s.observe(e),()=>s.disconnect()},[]);let w=Math.max(140,Math.min(j-170,j*o/100)),y=function(e){try{let s=JSON.parse(""===e.trim()?"{}":e);if(null===s||"object"!=typeof s||Array.isArray(s))return{ok:!1,error:"参数必须是 JSON 对象"};return{ok:!0,value:s}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}(d),C=a?.error?a.error:a?.result?eu("raw"===v?a.result:a.result.structuredContent??a.result):"";return(0,r.jsxs)("div",{className:"detail tool-detail",children:[(0,r.jsxs)("div",{className:"tool-overview",children:[(0,r.jsxs)("div",{className:"detail-head",children:[(0,r.jsxs)("div",{className:"detail-title",children:[(0,r.jsxs)("div",{className:"detail-title-row",children:[(0,r.jsx)("h3",{title:s.name,children:s.name}),t&&(0,r.jsx)(M,{className:"tool-ui-tag",children:"UI"})]}),t&&(0,r.jsx)("p",{className:"detail-desc",children:"运行后自动更新左侧预览"})]}),(0,r.jsx)($,{variant:"primary",icon:"play",disabled:!l||!y.ok||a?.status==="running",onClick:()=>y.ok&&h(y.value),children:a?.status==="running"?"运行中…":"运行"})]}),(s.description||s.title||t)&&(0,r.jsxs)("details",{className:"tool-metadata",children:[(0,r.jsx)("summary",{children:s.description??s.title??"工具说明与 UI 资源"}),(0,r.jsxs)("div",{className:"tool-metadata-body",children:[(s.description||s.title)&&(0,r.jsx)("p",{children:s.description??s.title}),t&&(0,r.jsxs)("button",{className:"resource-link mono",title:t,onClick:()=>m(t),children:[(0,r.jsx)(N,{name:"external",size:14})," ",t]})]})]})]}),(0,r.jsxs)("div",{className:"tool-workspace",ref:f,children:[(0,r.jsxs)("div",{className:"tool-input",style:{height:w},children:[(0,r.jsxs)("div",{className:"section-head",children:[(0,r.jsx)("span",{className:"section-title",children:"输入参数"}),(0,r.jsx)(T,{value:p,onChange:x,items:[{value:"form",label:"表单"},{value:"json",label:"JSON"}]})]}),"json"===p?(0,r.jsx)(X,{className:"args-editor",value:d,onChange:u,invalid:!y.ok}):y.ok?(0,r.jsx)("div",{className:"tool-form-scroll",children:(0,r.jsx)(ec,{schema:s.inputSchema,value:y.value,onChange:e=>u(eu(e))})}):(0,r.jsx)("div",{className:"args-error",children:"JSON 格式有误,请先在 JSON 模式下修正"}),!y.ok&&"json"===p&&(0,r.jsx)("div",{className:"args-error",children:y.error})]}),(0,r.jsx)(k,{axis:"y",className:"splitter-gap",value:w,onChange:e=>c(e/j*100),bounds:()=>[140,Math.max(140,j-170)]}),(0,r.jsxs)("div",{className:"tool-output",children:[(0,r.jsx)("div",{className:"section-head result-head",children:(0,r.jsx)(S,{value:v,onChange:g,items:[{value:"result",label:"调用结果"},{value:"raw",label:"完整响应"},{value:"schema",label:"Schema"}]})}),a&&"schema"!==v&&(0,r.jsxs)("div",{className:"result-summary",children:[(0,r.jsx)(eh,{status:a.status,durationMs:a.durationMs}),i&&(0,r.jsxs)("span",{className:"synced-note",children:[(0,r.jsx)(E,{tone:"success"}),"预览位于左侧"]})]}),"schema"===v?(0,r.jsx)(G,{className:"result-code",code:eu({inputSchema:s.inputSchema,...s.outputSchema?{outputSchema:s.outputSchema}:{}})}):a&&"running"!==a.status?(0,r.jsx)(G,{className:"result-code",code:C,language:a.error?"text":"json"}):(0,r.jsx)("div",{className:"result-placeholder",children:a?"调用中…":"运行 Tool 后,调用结果显示在这里"})]})]})]})}function ep(e){let{resource:s,read:t,onRead:n,connected:a}=e,i=t?.error?t.error:t?.result?t.result.contents.map(e=>"text"in e?e.text:`[blob ${e.mimeType??""}, ${e.blob.length} bytes base64]`).join("\n\n"):"",l=/^\s*[[{]/.test(i);return(0,r.jsxs)("div",{className:"detail",children:[(0,r.jsxs)("div",{className:"detail-head",children:[(0,r.jsxs)("div",{className:"detail-title",children:[(0,r.jsxs)("div",{className:"detail-title-row",children:[(0,r.jsx)("h3",{children:s.name}),s.mimeType&&(0,r.jsx)(M,{children:s.mimeType})]}),s.description&&(0,r.jsx)("p",{className:"detail-desc",children:s.description})]}),(0,r.jsx)($,{variant:"primary",icon:"play",onClick:n,disabled:!a||t?.status==="running",children:"读取"})]}),(0,r.jsx)("div",{className:"detail-fields",children:(0,r.jsxs)("div",{className:"field is-wide",children:[(0,r.jsx)("span",{className:"field-label",children:"URI"}),(0,r.jsx)("span",{className:"field-box mono",children:(0,r.jsx)("span",{className:"field-box-text",children:s.uri})})]})}),(0,r.jsxs)("div",{className:"section-head result-head",children:[(0,r.jsx)(S,{value:"content",onChange:()=>{},items:[{value:"content",label:"读取结果"}]}),t&&(0,r.jsx)(eh,{status:t.status,durationMs:t.durationMs})]}),t&&"running"!==t.status?(0,r.jsx)(G,{className:"result-code is-tall",code:i,language:l&&!t.error?"json":"text"}):(0,r.jsx)("div",{className:"result-placeholder",children:t?"读取中…":"点击「读取」查看资源内容"})]})}function ex(e){let{session:s,state:t,apps:a,runs:i,previewApp:l,onRun:o,tab:c,onTabChange:d}=e,[u,h]=(0,n.useState)(null);(0,n.useEffect)(()=>h(null),[t.config]);let[m,p]=(0,n.useState)(null),[x,v]=(0,n.useState)({}),[g,f]=(0,n.useState)({}),[j,b]=C("tool-input-share",45),w=(0,n.useMemo)(()=>new Map(a.map(e=>[e.tool.name,e])),[a]),y="connected"===t.status,N=t.tools.find(e=>e.name===u)??t.tools[0],k=(0,n.useMemo)(()=>{let e=new Map(t.resources.map(e=>[e.uri,e]));for(let s of a)e.has(s.resourceUri)||e.set(s.resourceUri,{uri:s.resourceUri,name:s.tool.name});return[...e.values()]},[t.resources,a]),S=k.find(e=>e.uri===m)??k[0],M=async e=>{f(s=>({...s,[e]:{status:"running"}}));let t=performance.now(),r=s=>f(r=>({...r,[e]:{...s,durationMs:Math.round(performance.now()-t)}}));try{r({status:"success",result:await s.readResource(e)})}catch(e){r({status:"error",error:e instanceof Error?e.message:String(e)})}},E=()=>void s.refreshLists(),L=N?w.get(N.name):void 0,$=N?i[N.name]:void 0;return H(t.status)?(0,r.jsxs)("div",{className:"card explorer","aria-busy":"true","aria-label":"正在加载工具和资源",children:[(0,r.jsx)("div",{className:"explorer-picker","aria-hidden":"true",children:(0,r.jsx)("div",{className:"explorer-loading-picker",children:(0,r.jsx)("span",{className:"loading-line"})})}),(0,r.jsxs)("div",{className:"detail tool-detail","aria-hidden":"true",children:[(0,r.jsxs)("div",{className:"tool-overview",children:[(0,r.jsxs)("div",{className:"detail-head",children:[(0,r.jsxs)("div",{className:"detail-title",children:[(0,r.jsx)("div",{className:"detail-title-row",children:(0,r.jsx)("span",{className:"loading-line"})}),(0,r.jsx)("p",{className:"detail-desc",children:(0,r.jsx)("span",{className:"loading-line"})})]}),(0,r.jsx)("span",{className:"tool-loading-action"})]}),(0,r.jsx)("div",{className:"tool-metadata",children:(0,r.jsx)("span",{className:"loading-line"})})]}),(0,r.jsxs)("div",{className:"tool-workspace",children:[(0,r.jsxs)("div",{className:"tool-input",style:{height:`clamp(140px, ${j}%, calc(100% - 170px))`},children:[(0,r.jsx)("div",{className:"section-head",children:(0,r.jsx)("span",{className:"loading-line"})}),(0,r.jsx)("div",{className:"explorer-loading-editor"})]}),(0,r.jsx)("div",{className:"tool-loading-splitter"}),(0,r.jsxs)("div",{className:"tool-output",children:[(0,r.jsx)("div",{className:"section-head result-head",children:(0,r.jsx)("span",{className:"loading-line"})}),(0,r.jsx)("div",{className:"explorer-loading-editor"})]})]})]})]}):(0,r.jsxs)("div",{className:"card explorer",children:[(0,r.jsxs)("div",{className:"explorer-body",hidden:"tools"!==c,children:[(0,r.jsx)(ed,{title:"Tools",icon:"wrench",placeholder:"搜索 Tools…",items:t.tools.map(e=>({key:e.name,title:e.name,subtitle:e.description??e.title,hasUi:w.has(e.name)})),selected:N?.name??null,onSelect:h,onRefresh:E,connected:y}),N?(0,r.jsx)(em,{tool:N,resourceUri:L?.resourceUri,run:$,connected:y,inputShare:j,onInputShare:b,synced:y&&!!L&&l===N.name&&$?.status==="success",argsText:x[N.name]??function(e){let s=new Set(e.inputSchema.required??[]),t={};for(let[r,n]of ei(e.inputSchema))if(void 0!==n.default)t[r]=n.default;else if(s.has(r)){let e=el(n);t[r]=n.enum?.[0]??("number"===e||"integer"===e?0:"boolean"!==e&&("array"===e?[]:"object"===e?{}:""))}return 0===Object.keys(t).length?"{\n}":JSON.stringify(t,null,2)}(N),onArgsText:e=>v(s=>({...s,[N.name]:e})),onRun:e=>o(N,e,!!L),onOpenResource:e=>{p(e),d("resources")}},N.name):(0,r.jsx)(ev,{connected:y,what:"Tool"})]}),(0,r.jsxs)("div",{className:"explorer-body",hidden:"resources"!==c,children:[(0,r.jsx)(ed,{title:"Resources",icon:"file",placeholder:"搜索 Resources…",items:k.map(e=>({key:e.uri,title:e.name,subtitle:e.uri})),selected:S?.uri??null,onSelect:p,onRefresh:E,connected:y}),S?(0,r.jsx)(ep,{resource:S,read:g[S.uri],connected:y,onRead:()=>void M(S.uri)},S.uri):(0,r.jsx)(ev,{connected:y,what:"Resource"})]})]})}function ev(e){let{connected:s,what:t}=e;return(0,r.jsx)("div",{className:"detail detail-empty",children:s?`当前 Server 没有可用的 ${t}`:"连接 MCP Server 后在此调试"})}function eg(e){let{state:s}=e;switch(s.status){case"connected":return(0,r.jsxs)("span",{className:"pill pill-success",children:[(0,r.jsx)(E,{tone:"success"}),"Connected",void 0!==s.latencyMs?` \xb7 ${s.latencyMs} ms`:""]});case"starting":case"connecting":return(0,r.jsxs)("span",{className:"pill pill-warning",children:[(0,r.jsx)(E,{tone:"warning"}),"Connecting…"]});case"error":return(0,r.jsxs)("span",{className:"pill pill-error",title:s.error,children:[(0,r.jsx)(E,{tone:"error"}),"Connection failed"]});default:return(0,r.jsxs)("span",{className:"pill pill-idle",children:[(0,r.jsx)(E,{tone:"idle"}),"Disconnected"]})}}function ef(e){let{session:s,state:t,apps:a,runs:i,previewApp:l,onRun:o,onOpenSettings:c}=e,[d,u]=(0,n.useState)("tools"),h=H(t.status),m=new Set([...t.resources.map(e=>e.uri),...a.map(e=>e.resourceUri)]).size;return(0,r.jsxs)("section",{className:"server-pane",children:[(0,r.jsx)("header",{className:"pane-topbar is-devtools",children:(0,r.jsx)(S,{value:d,onChange:u,items:[{value:"tools",label:(0,r.jsxs)(r.Fragment,{children:["Tools ",(0,r.jsx)("span",{className:"tab-count",children:h?"—":t.tools.length})]})},{value:"resources",label:(0,r.jsxs)(r.Fragment,{children:["Resources ",(0,r.jsx)("span",{className:"tab-count",children:h?"—":m})]})}]})}),(0,r.jsxs)("div",{className:"server-body",children:[(0,r.jsxs)("div",{className:"card connection-bar",children:[(0,r.jsxs)("div",{className:"connection-summary",children:[(0,r.jsx)("strong",{title:t.serverInfo?.name,children:h?(0,r.jsx)("span",{className:"loading-line","aria-hidden":"true"}):t.serverInfo?.name??"MCP Server"}),(0,r.jsx)("span",{title:`${t.config.endpoint} \xb7 ${P}${t.serverInfo?.version?` \xb7 v${t.serverInfo.version}`:""}`,children:"starting"===t.status?(0,r.jsx)("span",{className:"loading-line","aria-hidden":"true"}):t.config.endpoint||"配置连接以开始调试"})]}),(0,r.jsx)(eg,{state:t}),(0,r.jsx)(L,{icon:"refresh",title:"重新连接",disabled:h,onClick:()=>void s.connect()}),(0,r.jsx)(L,{icon:"setting",title:"连接设置",onClick:c})]}),"error"===t.status&&(0,r.jsx)("div",{className:"server-error",role:"alert",children:t.error}),(0,r.jsx)("div",{className:"inspector-panel",role:"tabpanel","aria-label":"resources"===d?"Resources":"Tools",children:(0,r.jsx)(ex,{session:s,state:t,apps:a,runs:i,previewApp:l,tab:d,onTabChange:u,onRun:o},JSON.stringify(t.config))})]})]})}let ej="http://localhost:8088/api/mcp";function eb(e){let{config:s,onSave:t,onClose:a}=e,[i,l]=(0,n.useState)(s.endpoint),[o,c]=(0,n.useState)(Object.entries(s.headers).map(e=>{let[s,t]=e;return`${s}: ${t}`}).join("\n")),d=(0,n.useRef)(null),u=(0,n.useId)(),h=function(e,s){let t=e.trim();for(let e of[s.trim(),ej])if(/^https?:\/\//.test(e)){if(e===t)return null;if(e.startsWith(t)||!t.includes("://")&&e.replace(/^https?:\/\//,"").startsWith(t))return e}return null}(i,s.endpoint);(0,n.useEffect)(()=>{let e=e=>"Escape"===e.key&&a();return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]);let m=!0;try{let e=new URL(i);m="http:"===e.protocol||"https:"===e.protocol}catch{m=!1}let p=()=>m&&t({endpoint:i.trim(),headers:function(e){let s={};for(let t of e.split("\n")){let e=t.indexOf(":");e>0&&(s[t.slice(0,e).trim()]=t.slice(e+1).trim())}return s}(o)});return(0,r.jsx)("div",{className:"dialog-mask",onMouseDown:e=>e.target===e.currentTarget&&a(),children:(0,r.jsxs)("div",{className:"dialog",role:"dialog","aria-label":"连接设置",children:[(0,r.jsxs)("div",{className:"dialog-head",children:[(0,r.jsx)("h2",{children:"连接设置"}),(0,r.jsx)(L,{icon:"close",title:"关闭",onClick:a})]}),(0,r.jsxs)("div",{className:"dialog-body",children:[(0,r.jsxs)("div",{className:"form-row",children:[(0,r.jsxs)("label",{className:"form-label",htmlFor:u,children:["Endpoint",(0,r.jsx)("span",{className:"form-type",children:P})]}),(0,r.jsxs)("div",{className:"endpoint-input",children:[(0,r.jsx)("input",{id:u,ref:d,className:`form-input mono ${i.trim()&&!m?"is-invalid":""}`,value:i,autoFocus:!0,autoComplete:"off",spellCheck:!1,"aria-describedby":`${u}-hint`,onChange:e=>l(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||("Tab"!==e.key||e.shiftKey||e.ctrlKey||e.altKey||e.metaKey||!h||e.currentTarget.selectionStart!==i.length||e.currentTarget.selectionEnd!==i.length?"Enter"===e.key&&p():(e.preventDefault(),l(h)))},placeholder:s.endpoint||ej}),i&&(0,r.jsx)("button",{type:"button",className:"icon-btn endpoint-clear",title:"清空 Endpoint","aria-label":"清空 Endpoint",onClick:()=>{l(""),d.current?.focus()},children:(0,r.jsx)(N,{name:"close",size:12})})]}),(0,r.jsx)("div",{className:"form-help endpoint-hint",id:`${u}-hint`,children:h?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("kbd",{children:"Tab"}),(0,r.jsxs)("span",{title:h,children:["补全为 ",h]})]}):"支持 http:// 和 https:// 地址"})]}),(0,r.jsxs)("label",{className:"form-row",children:[(0,r.jsx)("span",{className:"form-label",children:"Headers"}),(0,r.jsx)("textarea",{className:"form-input mono",rows:3,value:o,onChange:e=>c(e.target.value),placeholder:"Authorization: Bearer <token>"}),(0,r.jsx)("span",{className:"form-help",children:"每行一个,格式为 Name: Value"})]})]}),(0,r.jsxs)("div",{className:"dialog-foot",children:[(0,r.jsx)($,{onClick:a,children:"取消"}),(0,r.jsx)($,{variant:"primary",onClick:p,disabled:!m,children:"保存并连接"})]})]})})}function ew(){let e=(0,n.useMemo)(()=>new _,[]),s=(0,n.useMemo)(()=>new m,[]),[t,a]=(0,n.useState)();(0,n.useEffect)(()=>h(window,(e,t)=>{queueMicrotask(()=>s.append("host",e,t))},u),[s]);let i=(0,n.useSyncExternalStore)(e.subscribe,e.getState),l=(0,n.useMemo)(()=>(function(e){let s=[];for(let t of e)try{let e=(0,o.Bv)(t);e&&s.push({tool:t,resourceUri:e})}catch(e){console.warn(`[inspector] ignoring malformed UI resource on tool ${t.name}`,e)}return s})(i.tools),[i.tools]);(0,n.useEffect)(()=>{"error"===i.status&&i.error&&s.append("host","error",i.error,"MCP connection")},[s,i.status,i.error]);let[c,d]=(0,n.useState)({}),[p,x]=(0,n.useState)(null),[v,g]=(0,n.useState)(0),[f,j]=(0,n.useState)(!1),[b,w]=(0,n.useState)({width:window.innerWidth,height:window.innerHeight});(0,n.useEffect)(()=>{let e=()=>w({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let[y,N]=C("canvas-three-column",Math.round(.3*window.innerWidth)),[k,S]=C("requests-column",Math.round(.26*window.innerWidth)),M=Math.max(1080,b.width),E=Math.max(360,Math.min(y,M-420-300)),L=Math.max(300,Math.min(k,M-E-420));(0,n.useEffect)(()=>(e.start().then(e=>{e||j(!0)}),()=>void e.disconnect()),[e]);let $=(0,n.useCallback)(async(t,r,n)=>{let a=Date.now();d(e=>({...e,[t.name]:{runId:a,args:r,status:"running"}})),n&&x(t.name);let i=performance.now(),l=e=>d(s=>s[t.name]?.runId===a?{...s,[t.name]:{...s[t.name],durationMs:Math.round(performance.now()-i),...e}}:s);try{let s=await e.callTool(t.name,r);l({result:s,status:s.isError?"error":"success"})}catch(e){s.append("host","error",u([e]),t.name),l({status:"error",error:e instanceof Error?e.message:String(e)})}},[e,s]),R=l.find(e=>e.tool.name===p)??null;return(0,r.jsxs)("div",{className:"layout",children:[(0,r.jsxs)("div",{className:"workspace-columns",children:[(0,r.jsx)(q,{width:E,onResize:N,resizeBounds:()=>[360,M-420-L],session:e,consoleStore:s,connectionStatus:i.status,hasUiTools:l.length>0,app:R,run:R?c[R.tool.name]:void 0,frameNonce:v,onReload:()=>g(e=>e+1),onOpenConsole:()=>a({query:R?.tool.name??"",source:"all",level:"error"})}),(0,r.jsx)(ef,{session:e,state:i,apps:l,runs:c,previewApp:p,onRun:$,onOpenSettings:()=>j(!0)}),(0,r.jsx)(ea,{width:L,onResize:S,resizeBounds:()=>[300,M-E-420],session:e,state:i})]}),(0,r.jsx)(V,{store:s,state:i,viewportHeight:b.height,openRequest:t}),f&&(0,r.jsx)(eb,{config:i.config,onClose:()=>j(!1),onSave:s=>{j(!1),d({}),x(null),e.connect(s)}})]})}function ey(e){let{title:s,pairs:t,empty:n}=e;return(0,r.jsxs)("details",{className:"wb-detail-group",open:!0,children:[(0,r.jsx)("summary",{children:s}),t&&t.length>0?(0,r.jsx)("dl",{className:"wb-kv",children:t.map((e,s)=>{let[t,n]=e;return(0,r.jsxs)("div",{className:"wb-kv-row",children:[(0,r.jsx)("dt",{children:t}),(0,r.jsx)("dd",{className:"mono",children:n})]},`${t}-${s}`)})}):(0,r.jsx)("p",{className:"wb-net-hint",children:n})]})}function eN(e){let{config:s}=e,[t,a]=(0,n.useState)(s),o=(0,n.useMemo)(()=>new URL(t.guestUrl).origin,[t.guestUrl]),c=(0,n.useMemo)(()=>new URLSearchParams(window.location.hash.slice(1)).get("token"),[]),d=(0,n.useMemo)(()=>c?{Authorization:`Bearer ${c}`}:void 0,[c]),u=(0,n.useRef)(null),h=(0,n.useMemo)(()=>new m,[]),p=(0,n.useSyncExternalStore)(h.subscribe,h.getSnapshot),[x,v]=(0,n.useState)(0),[g,f]=(0,n.useState)(!c),[j,b]=(0,n.useState)("logs"),[w,y]=C("wb-debug-drawer",300),[T,U]=(0,n.useState)(window.innerHeight),[I,q]=(0,n.useState)({query:"",source:"all",level:"all"}),[z,A]=(0,n.useState)([]),[P,H]=(0,n.useState)(null),[D,B]=(0,n.useState)("headers"),[Z,J]=(0,n.useState)(""),[F,_]=(0,n.useState)(""),[V,K]=(0,n.useState)(""),[G,X]=(0,n.useState)(s.captureEnabled),[Y,Q]=(0,n.useState)(!1),[ee,es]=(0,n.useState)(c?"":"请打开 dbx dev 输出的完整预览链接。"),[et,er]=(0,n.useState)(!1),en=(0,n.useRef)(0),ea=(0,n.useRef)(!1),ei=(0,n.useRef)(0),el=(0,n.useRef)(s.captureEnabled);el.current=G,(0,n.useEffect)(()=>{document.title="工作台本地预览";let e=()=>U(window.innerHeight);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let eo=(0,n.useCallback)(e=>{u.current?.contentWindow?.postMessage({type:"dbx:capture-request-details",enabled:e},o)},[o]),ec=(0,n.useCallback)(e=>{if(0===e.length)return;let s=[];for(let t of e)if("network"===t.kind||"resource"===t.kind)s.push(t);else{let e="console"===t.kind?t.level??"log":"error",s="error"===t.kind?"脚本":"unhandledrejection"===t.kind?"Promise":t.path;h.append("iframe",e,function(e,s){let t=[e.path,e.line,e.column].filter(Boolean).join(":"),r=e.message||t||e.kind,n=[r];return t&&t!==r&&t!==s&&n.push(`(${t})`),e.stack&&n.push(`
5
+ ${e.stack}`),n.join(" ")}(t,s),s)}s.length>0&&A(e=>[...e,...s].slice(-500))},[h]);(0,n.useEffect)(()=>{if(!d)return;let e=e=>{let s=u.current?.contentWindow;if(!s||e.source!==s||e.origin!==o)return;let t=e.data;if(!t||"object"!=typeof t)return;let r="dbx:probe-ready"===t.type;if(r||"dbx:preview-event"===t.type){if(!r&&(!t.event||"object"!=typeof t.event||Array.isArray(t.event)))return;r&&(er(!0),eo(el.current));let e=r?{kind:"preview-ready"}:el.current?t.event:{...t.event,requestDetails:void 0};fetch("/__dbx/events",{method:"POST",headers:{...d,"Content-Type":"application/json"},body:JSON.stringify(e)}).then(e=>{if(!e.ok)throw Error();es(e=>e.startsWith("日志上报失败")?"":e)}).catch(()=>es("日志上报失败,请检查本地调试服务。"));return}if("2.0"!==t.jsonrpc||"string"!=typeof t.id&&"number"!=typeof t.id||"string"!=typeof t.method)return;let n={jsonrpc:"2.0",id:t.id};"ui/initialize"===t.method?n.result={protocolVersion:"2026-01-26",hostInfo:{name:"dbx-preview",version:"1"},hostCapabilities:{},hostContext:{displayMode:"fullscreen",platform:"web",locale:navigator.language}}:(n.error={code:-32601,message:"此宿主能力请在豆包工作开发版中验证。"},h.append("host","warn",`本地预览暂不支持宿主方法:${t.method}`,"JSON-RPC")),s.postMessage(n,o)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[d,h,o,eo]),(0,n.useEffect)(()=>{if(!d)return;let e=!0,s=async()=>{if(!e)return;if(!ea.current){ea.current=!0;try{let s=await fetch(`/__dbx/diagnostics?after=${en.current}`,{headers:d});if(!s.ok)throw Error();let t=await s.json();if(!e)return;t.lastProbeReadyAt&&er(!0),t.events.length>0&&ec(t.events),en.current=t.nextCursor,es(e=>e.startsWith("无法读取日志")?"":e)}catch{e&&es("无法读取日志,请确认 dbx dev 正在运行并使用本次预览链接。")}finally{ea.current=!1}}let s=ei.current;try{let t=await fetch(l,{headers:d});if(!t.ok)return;let{enabled:r}=await t.json();e&&"boolean"==typeof r&&s===ei.current&&X(e=>(e!==r&&eo(r),r))}catch{}};s();let t=window.setInterval(()=>void s(),1e3);return()=>{e=!1,window.clearInterval(t)}},[d,ec,eo]);let ed=async e=>{if(d){Q(!0),ei.current++;try{let s=await fetch(l,{method:"PUT",headers:{...d,"Content-Type":"application/json"},body:JSON.stringify({enabled:e})});if(!s.ok)throw Error();let t=await s.json();X(t.enabled),eo(t.enabled),es("")}catch{es("请求详情开关更新失败,请重试")}finally{Q(!1)}}},eu=(0,n.useMemo)(()=>{let e=new Set;for(let s of z)e.add(s.method?.toUpperCase()||"—");return[...e].sort()},[z]),eh=(0,n.useMemo)(()=>{let e=Z.trim().toLowerCase();return z.filter(s=>{let t=s.method?.toUpperCase()||"—";return(!F||t===F)&&(!V||(s.status?`${Math.floor(s.status/100)}xx`:"不透明响应"===s.message?"opaque":"failed")===V)&&(!e||`${s.requestDetails?.url??""} ${s.path??""} ${s.message??""}`.toLowerCase().includes(e))})},[z,Z,F,V]),em=(0,n.useMemo)(()=>eh.find(e=>e.seq===P)??null,[eh,P]),ep=p.filter(e=>"error"===e.level).length,ex=p.filter(e=>"warn"===e.level).length,ev=p.length-ep-ex,eg=Math.max(180,T-220),ef=Math.min(eg,Math.max(180,w)),ej=e=>{q({query:"",source:"all",level:e}),b("logs"),f(!0)},eb=(0,n.useCallback)(async()=>{try{let e=await fetch(i,{cache:"no-store"});if(e.ok){let s=await e.json();"workbench"===s.mode&&"string"==typeof s.guestUrl&&"string"==typeof s.entryPath&&a(e=>e.guestUrl===s.guestUrl&&e.entryPath===s.entryPath?e:{mode:"workbench",guestUrl:s.guestUrl,entryPath:s.entryPath,captureEnabled:"boolean"==typeof s.captureEnabled?s.captureEnabled:e.captureEnabled})}}catch{}v(e=>e+1)},[]);return(0,r.jsxs)("div",{className:"wb-layout",children:[(0,r.jsxs)("header",{className:"wb-header",children:[(0,r.jsxs)("div",{className:"wb-header-title",children:[(0,r.jsx)("strong",{children:"工作台本地预览"}),(0,r.jsx)(M,{className:"mono",children:t.entryPath})]}),(0,r.jsx)("div",{className:"wb-header-actions",children:(0,r.jsx)(L,{icon:"refresh",title:"刷新预览页",onClick:()=>void eb()})})]}),ee&&(0,r.jsx)("div",{className:"wb-notice",role:"status",children:ee}),(0,r.jsx)("main",{className:"wb-stage",children:c?(0,r.jsx)("iframe",{ref:u,className:"wb-iframe",title:"工作台首页",src:t.guestUrl,sandbox:"allow-scripts allow-same-origin allow-forms",referrerPolicy:"no-referrer"},x):(0,r.jsx)("div",{className:"wb-empty-stage",children:"请打开 dbx dev 终端输出的完整本地预览链接(含 #token=)。"})}),(0,r.jsxs)("div",{className:"console-dock",children:[(0,r.jsxs)("section",{className:"console-drawer",hidden:!g,style:{height:ef},"aria-label":"调试面板",children:[(0,r.jsx)(k,{axis:"y",invert:!0,className:"console-resize",value:ef,onChange:y,bounds:()=>[180,eg]}),(0,r.jsxs)("div",{className:"console-drawer-head wb-drawer-head",children:[(0,r.jsx)(S,{value:j,onChange:b,items:[{value:"logs",label:`日志 (${p.length})`},{value:"network",label:`网络 (${z.length})`}]}),(0,r.jsx)(L,{icon:"close",title:"收起调试面板",onClick:()=>f(!1)})]}),"logs"===j?(0,r.jsx)(W,{store:h,active:g&&"logs"===j,filters:I,onFiltersChange:q}):(0,r.jsxs)("div",{className:"wb-network-panel",children:[(0,r.jsxs)("div",{className:"console-toolbar",children:[(0,r.jsx)(R,{value:Z,onChange:J,placeholder:"搜索请求 URL 或资源名称"}),(0,r.jsx)(O,{value:F,onChange:_,options:[{value:"",label:"所有方法"},...eu.map(e=>({value:e,label:"—"===e?"未记录方法":e}))]}),(0,r.jsx)(O,{value:V,onChange:K,options:[{value:"",label:"所有状态"},{value:"1xx",label:"1xx"},{value:"2xx",label:"2xx"},{value:"3xx",label:"3xx"},{value:"4xx",label:"4xx"},{value:"5xx",label:"5xx"},{value:"failed",label:"无响应(失败)"},{value:"opaque",label:"不透明响应"}]}),(0,r.jsxs)("label",{className:"wb-capture",title:"开启后记录新请求的详情,本地静态资源可查看常用标头",children:[(0,r.jsx)("input",{type:"checkbox",checked:G,disabled:Y||!d,onChange:e=>void ed(e.target.checked)}),"记录请求详情"]}),(0,r.jsx)($,{onClick:()=>{A([]),H(null)},children:"清空"})]}),0===eh.length?(0,r.jsx)("div",{className:"console-empty",children:z.length?"没有匹配的网络请求":"暂无网络请求"}):(0,r.jsxs)("div",{className:"wb-network-split",children:[(0,r.jsx)("div",{className:"wb-request-list",children:(0,r.jsxs)("table",{"aria-label":"网络请求",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"名称"}),(0,r.jsx)("th",{className:"wb-col-sm",children:"方法"}),(0,r.jsx)("th",{className:"wb-col-sm",children:"状态"}),(0,r.jsx)("th",{className:"wb-col-md",children:"耗时"})]})}),(0,r.jsx)("tbody",{children:eh.map(e=>{let s=e.path?.split("/").pop()||e.path||e.message||"资源",t=e.seq===P,n=(e.status??0)>=400||!e.status&&"不透明响应"!==e.message;return(0,r.jsxs)("tr",{className:`${t?"is-selected":""} ${n?"is-failed":""}`,onClick:()=>H(e.seq),children:[(0,r.jsx)("td",{title:e.requestDetails?.url||e.path||"",children:s}),(0,r.jsx)("td",{className:"mono",children:e.method||"—"}),(0,r.jsx)("td",{className:"mono wb-status-cell",children:e.status||"—"}),(0,r.jsx)("td",{className:"mono",children:Number.isFinite(e.durationMs)?`${e.durationMs} ms`:"—"})]},e.seq)})})]})}),(0,r.jsx)("div",{className:"wb-inspector",children:em?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"wb-detail-tabs",children:(0,r.jsx)(S,{value:D,onChange:B,items:[{value:"headers",label:"标头"},{value:"payload",label:"载荷"},{value:"response",label:"响应"}]})}),(0,r.jsx)("div",{className:"wb-detail-body",children:(()=>{let e=em.requestDetails,s="resource"!==em.kind||em.method?"未记录此项。开启「记录请求详情」后重新发起请求。":"浏览器未提供该资源的 HTTP 明细。";if("headers"===D){let t=[[e?.url?"请求 URL":"资源路径",e?.url||em.path||"未知"]];return em.method&&t.push(["请求方法",em.method]),em.status&&t.push(["状态码",String(em.status)]),em.message&&t.push(["说明",em.message]),Number.isFinite(em.durationMs)&&t.push(["耗时",`${em.durationMs} ms`]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ey,{title:"常规",pairs:t,empty:""}),"resource"!==em.kind||e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ey,{title:"请求标头",pairs:e?.headers,empty:e?"没有显式设置的请求头":s}),(0,r.jsx)(ey,{title:"响应标头",pairs:e?.responseHeaders,empty:e?"没有页面可读取的响应头":s})]}):(0,r.jsx)("p",{className:"wb-net-hint",children:s})]})}let t="payload"===D?e?.body:e?.responseBody,n=t?(0,r.jsx)("pre",{className:"wb-body-pre mono",children:t}):(0,r.jsx)("p",{className:"wb-net-hint",children:""===t?"payload"===D?"无请求体":"无响应体":e&&"resource"===em.kind?"未采集静态资源正文":e?"未取得正文":s});return"payload"===D?(0,r.jsxs)(r.Fragment,{children:["resource"!==em.kind&&(0,r.jsx)(ey,{title:"查询参数",pairs:e?.query,empty:e?"无查询参数":s}),(0,r.jsxs)("details",{className:"wb-detail-group",open:!0,children:[(0,r.jsx)("summary",{children:"请求体"}),n]})]}):n})()})]}):(0,r.jsx)("p",{className:"wb-net-hint",children:"选择请求以查看详情"})})]})]})]}),(0,r.jsxs)("footer",{className:"workspace-statusbar",children:[(0,r.jsxs)("span",{className:"workspace-connection",children:[(0,r.jsx)(E,{tone:et?"success":c?"idle":"error"}),et?"预览探针已就绪":c?"等待页面加载…":"缺少预览令牌",(0,r.jsxs)("span",{className:"workspace-transport",children:[z.length," requests",G?" · 详情采集已开启":""]})]}),(0,r.jsxs)("div",{className:"console-indicators","aria-label":"日志统计",children:[ep>0&&(0,r.jsxs)("button",{className:"console-indicator is-error",title:`${ep} 条错误,点击查看`,onClick:()=>ej("error"),children:[(0,r.jsx)(N,{name:"errorCircle",size:14}),(0,r.jsx)("span",{children:ep})]}),ex>0&&(0,r.jsxs)("button",{className:"console-indicator is-warn",title:`${ex} 条警告,点击查看`,onClick:()=>ej("warn"),children:[(0,r.jsx)(N,{name:"warningTriangle",size:14}),(0,r.jsx)("span",{children:ex})]}),(0,r.jsxs)("button",{className:"console-indicator is-info",title:`${ev} 条普通日志,点击查看`,onClick:()=>ej(ev?"messages":"all"),children:[(0,r.jsx)(N,{name:"messageBubble",size:14}),(0,r.jsx)("span",{children:ev})]}),(0,r.jsxs)("button",{className:`console-toggle ${g?"is-active":""}`,"aria-expanded":g,onClick:()=>f(e=>!e),children:["调试 ",(0,r.jsx)(N,{name:"arrowDown",size:12})]})]})]})]})]})}(0,a.H)(document.getElementById("root")).render((0,r.jsx)(function(){let[e,s]=(0,n.useState)(null);return((0,n.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await fetch(i,{cache:"no-store"}),r=t.ok?await t.json():"mcp";e&&s(r)}catch{e&&s("mcp")}})(),()=>{e=!1}},[]),null===e)?null:"mcp"!==e&&"workbench"===e.mode?(0,r.jsx)(eN,{config:e}):(0,r.jsx)(ew,{})},{}))}},i={};function l(e){var s=i[e];if(void 0!==s)return s.exports;var t=i[e]={exports:{}};return a[e](t,t.exports,l),t.exports}l.m=a,l.d=(e,s,t)=>{var r=(s,t)=>{for(var r in s)l.o(s,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,[t]:s[r]})};r(s,"get"),r(t,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((s,t)=>(l.f[t](e,s),s),[])),l.u=e=>"static/js/async/"+e+".86106314b5.js",l.miniCssF=e=>""+e+".css",l.o=(e,s)=>Object.prototype.hasOwnProperty.call(e,s),e={},l.l=function(s,t,r,n){if(e[s])return void e[s].push(t);if(void 0!==r)for(var a,i,o=document.getElementsByTagName("script"),c=0;c<o.length;c++){var d=o[c];if(d.getAttribute("src")==s||d.getAttribute("data-rspack")=="mcp-apps-inspector:"+r){a=d;break}}a||(i=!0,(a=document.createElement("script")).timeout=120,l.nc&&a.setAttribute("nonce",l.nc),a.setAttribute("data-rspack","mcp-apps-inspector:"+r),a.src=s),e[s]=[t];var u=function(t,r){a.onerror=a.onload=null,clearTimeout(h);var n=e[s];if(delete e[s],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach(function(e){return e(r)}),t)return t(r)},h=setTimeout(u.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=u.bind(null,a.onerror),a.onload=u.bind(null,a.onload),i&&document.head.appendChild(a)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s=[],l.O=(e,t,r,n)=>{if(t){n=n||0;for(var a=s.length;a>0&&s[a-1][2]>n;a--)s[a]=s[a-1];s[a]=[t,r,n];return}for(var i=1/0,a=0;a<s.length;a++){for(var[t,r,n]=s[a],o=!0,c=0;c<t.length;c++)(!1&n||i>=n)&&Object.keys(l.O).every(e=>l.O[e](t[c]))?t.splice(c--,1):(o=!1,n<i&&(i=n));if(o){s.splice(a--,1);var d=r();void 0!==d&&(e=d)}}return e},l.p="/",t={410:0},l.f.j=function(e,s){var r=l.o(t,e)?t[e]:void 0;if(0!==r)if(r)s.push(r[2]);else{var n=new Promise((s,n)=>r=t[e]=[s,n]);s.push(r[2]=n);var a=l.p+l.u(e),i=Error();l.l(a,function(s){if(l.o(t,e)&&(0!==(r=t[e])&&(t[e]=void 0),r)){var n=s&&("load"===s.type?"missing":s.type),a=s&&s.target&&s.target.src;i.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",i.name="ChunkLoadError",i.type=n,i.request=a,r[1](i)}},"chunk-"+e,e)}},l.O.j=e=>0===t[e],r=(e,s)=>{var r,n,[a,i,o]=s,c=0;if(a.some(e=>0!==t[e])){for(r in i)l.o(i,r)&&(l.m[r]=i[r]);if(o)var d=o(l)}for(e&&e(s);c<a.length;c++)n=a[c],l.o(t,n)&&t[n]&&t[n][0](),t[n]=0;return l.O(d)},(n=self.rspackChunkmcp_apps_inspector=self.rspackChunkmcp_apps_inspector||[]).forEach(r.bind(null,0)),n.push=r.bind(null,n.push.bind(n));var o=l.O(void 0,["783","155"],()=>l(114));o=l.O(o)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-apps-inspector",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Local inspector for MCP servers and MCP Apps",
5
5
  "type": "module",
6
6
  "exports": {