@jonathanleelx/meddle 0.2.2 → 0.3.1

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.
Files changed (35) hide show
  1. package/README.md +29 -0
  2. package/bin/commands/session/create.js +20 -17
  3. package/bin/commands/start.js +16 -13
  4. package/bin/commands/supervise.js +16 -7
  5. package/bin/lib/dispatch.js +34 -0
  6. package/bin/lib/spawn-proxy.js +51 -0
  7. package/bin/main.js +34 -0
  8. package/mcp-server.js +22 -16
  9. package/package.json +2 -2
  10. package/web/dist/assets/{checkbox-D0y07vOb.js → checkbox-BWULYytd.js} +1 -1
  11. package/web/dist/assets/{code-fixer-DOrMk-4V.js → code-fixer-5eQnwT8X.js} +2 -2
  12. package/web/dist/assets/{detail-panel-CGfKk7-i.js → detail-panel-BpOhMCBc.js} +1 -1
  13. package/web/dist/assets/{global-panel-shell-COyDpKbS.js → global-panel-shell-BAYOGxQQ.js} +1 -1
  14. package/web/dist/assets/{health-panel-CgEmCIeC.js → health-panel-kmPJnyYQ.js} +1 -1
  15. package/web/dist/assets/{index-DTeCUv1G.js → index-DboWpNx1.js} +2 -2
  16. package/web/dist/assets/{mobile-proxy-panel-BCUn96iR.js → mobile-proxy-panel-DmB_Xpfw.js} +1 -1
  17. package/web/dist/assets/mock-config-iBp0BDov.js +1 -0
  18. package/web/dist/assets/{mock-editor-panel-Ctf1EX-d.js → mock-editor-panel-CXXDTlEW.js} +1 -1
  19. package/web/dist/assets/{monaco-editor-DboIGERI.js → monaco-editor-Z1BRT9kx.js} +2 -2
  20. package/web/dist/assets/{plugin-code-editor-DuaSNWGF.js → plugin-code-editor-BlDjbDTI.js} +1 -1
  21. package/web/dist/assets/{plugin-config-D7H47wsJ.js → plugin-config-CAt68TW2.js} +1 -1
  22. package/web/dist/assets/{plugin-generator-xGpWo1Fc.js → plugin-generator-DQPeKPiv.js} +1 -1
  23. package/web/dist/assets/{plugin-test-dialog-BfxPpCfE.js → plugin-test-dialog-DzxpHPhR.js} +1 -1
  24. package/web/dist/assets/{route-preview-CvoRZiwx.js → route-preview-DE5VQpeQ.js} +1 -1
  25. package/web/dist/assets/{rule-ai-assistant-panel-B0UlJVO3.js → rule-ai-assistant-panel-CzFwse2h.js} +1 -1
  26. package/web/dist/assets/rule-config-CSjkrM2g.js +15 -0
  27. package/web/dist/assets/{select-CH0aJ3Dd.js → select-DOK-k_l8.js} +1 -1
  28. package/web/dist/assets/{settings-panel-BvaGZmBw.js → settings-panel-Ccdeqa9n.js} +1 -1
  29. package/web/dist/index.html +1 -1
  30. package/dist/core/plugin-compiler.d.ts +0 -37
  31. package/dist/core/plugin-compiler.d.ts.map +0 -1
  32. package/dist/core/plugin-compiler.js +0 -172
  33. package/dist/core/plugin-compiler.js.map +0 -1
  34. package/web/dist/assets/mock-config-DNMSOrLv.js +0 -1
  35. package/web/dist/assets/rule-config-BmrlYakh.js +0 -15
package/README.md CHANGED
@@ -5,8 +5,37 @@
5
5
 
6
6
  ## 使用
7
7
 
8
+ ### 方式一:npm 安装
9
+
8
10
  全局安装 `npm install @jonathanleelx/meddle -g`,会创建一个 `meddle` 命令。
9
11
 
12
+ ### 方式二:二进制安装(无需 Node.js)
13
+
14
+ **macOS / Linux:**
15
+
16
+ ```bash
17
+ curl -fsSL https://raw.githubusercontent.com/JonathanLee-LX/meddle/main/scripts/install-binary.sh | bash
18
+ ```
19
+
20
+ **Windows (PowerShell):**
21
+
22
+ ```powershell
23
+ irm https://raw.githubusercontent.com/JonathanLee-LX/meddle/main/scripts/install-binary.ps1 | iex
24
+ ```
25
+
26
+ **支持平台:**
27
+
28
+ | 平台 | 产物 |
29
+ |---|---|
30
+ | Linux x64 | `meddle-linux-x64` |
31
+ | Linux ARM64 | `meddle-linux-arm64` |
32
+ | macOS Intel | `meddle-darwin-x64` |
33
+ | macOS Apple Silicon | `meddle-darwin-arm64` |
34
+ | Windows x64 | `meddle-windows-x64.exe` |
35
+ | Windows ARM64 | `meddle-windows-arm64.exe` |
36
+
37
+ 二进制产物随 [GitHub Release](https://github.com/JonathanLee-LX/meddle/releases) 发布,也可手动下载。安装目录默认 `~/.meddle/bin`,可通过 `MEDDLE_BIN_DIR` 环境变量自定义。
38
+
10
39
  ### 命令
11
40
 
12
41
  ```bash
@@ -30,6 +30,7 @@ const {
30
30
  } = require('../../lib/sessions')
31
31
  const { resolveMeddleHome } = require('../../lib/meddle-home')
32
32
  const { GLOBAL_DEFAULT_PORT } = require('../../lib/session-args')
33
+ const { buildProxySpawn, getReentryArgv } = require('../../lib/spawn-proxy')
33
34
 
34
35
  function parseArgs(argv) {
35
36
  const args = argv.slice(4) // after 'meddle' 'session' 'create'
@@ -88,24 +89,26 @@ async function main() {
88
89
  // via its existing startup logic. We only ensure the root exists.
89
90
 
90
91
  // 3. spawn child
91
- const indexPath = path.join(__dirname, '..', '..', '..', 'index.js')
92
- const childEnv = {
93
- ...process.env,
94
- MEDDLE_HOME: meddleHome,
95
- PORT: String(port),
96
- MEDDLE_SESSION_ID: id,
97
- // Suppress the CA trust prompt — sessions reuse the shared CA
98
- // from ~/.meddle/ca which the user already trusted when setting up
99
- // the default session. Also avoid interactive prompts blocking
100
- // a non-interactive agent spawn.
101
- MEDDLE_HEADLESS: '1',
102
- // Disable MCP file discovery for non-default sessions; the MCP
103
- // proxy-url file is only meaningful for the default session.
104
- MEDDLE_MCP: '',
105
- }
106
- const child = spawn(process.execPath, [indexPath], {
92
+ const { args: spawnArgs, options: spawnOptions } = buildProxySpawn({
93
+ baseEnv: process.env,
94
+ reentryArgv: getReentryArgv(),
95
+ extraEnv: {
96
+ MEDDLE_HOME: meddleHome,
97
+ PORT: String(port),
98
+ MEDDLE_SESSION_ID: id,
99
+ // Suppress the CA trust prompt — sessions reuse the shared CA
100
+ // from ~/.meddle/ca which the user already trusted when setting up
101
+ // the default session. Also avoid interactive prompts blocking
102
+ // a non-interactive agent spawn.
103
+ MEDDLE_HEADLESS: '1',
104
+ // Disable MCP file discovery for non-default sessions; the MCP
105
+ // proxy-url file is only meaningful for the default session.
106
+ MEDDLE_MCP: '',
107
+ },
108
+ })
109
+ const child = spawn(process.execPath, spawnArgs, {
107
110
  cwd: process.cwd(),
108
- env: childEnv,
111
+ env: spawnOptions.env,
109
112
  stdio: 'inherit',
110
113
  detached: false,
111
114
  })
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  const { spawn } = require('child_process')
6
- const path = require('path')
6
+ const { buildProxySpawn, getReentryArgv } = require('../lib/spawn-proxy')
7
7
 
8
8
  // Parse arguments
9
9
  const args = process.argv.slice(3)
@@ -13,24 +13,27 @@ const interceptHttpsFlag = args.includes('--intercept-https')
13
13
  const noInterceptHttpsFlag = args.includes('--no-intercept-https')
14
14
 
15
15
  // Start proxy
16
- const indexPath = path.join(__dirname, '..', 'index.js')
17
- const spawnEnv = { ...process.env, DEBUG: process.env.DEBUG || '' }
18
- if (openFlag) spawnEnv.MEDDLE_OPEN = '1'
19
- if (remoteFlag) spawnEnv.MEDDLE_REMOTE = '1'
20
- if (interceptHttpsFlag) spawnEnv.MEDDLE_INTERCEPT_HTTPS = '1'
21
- if (noInterceptHttpsFlag) spawnEnv.MEDDLE_INTERCEPT_HTTPS = '0'
16
+ const extraEnv = { DEBUG: process.env.DEBUG || '' }
17
+ if (openFlag) extraEnv.MEDDLE_OPEN = '1'
18
+ if (remoteFlag) extraEnv.MEDDLE_REMOTE = '1'
19
+ if (interceptHttpsFlag) extraEnv.MEDDLE_INTERCEPT_HTTPS = '1'
20
+ if (noInterceptHttpsFlag) extraEnv.MEDDLE_INTERCEPT_HTTPS = '0'
22
21
 
23
22
  const remoteTokenIndex = args.indexOf('--remote-token')
24
23
  if (remoteTokenIndex >= 0 && args[remoteTokenIndex + 1]) {
25
- spawnEnv.MEDDLE_REMOTE_TOKEN = args[remoteTokenIndex + 1]
24
+ extraEnv.MEDDLE_REMOTE_TOKEN = args[remoteTokenIndex + 1]
26
25
  }
27
26
  const inlineRemoteToken = args.find(arg => arg.startsWith('--remote-token='))
28
- if (inlineRemoteToken) spawnEnv.MEDDLE_REMOTE_TOKEN = inlineRemoteToken.slice('--remote-token='.length)
27
+ if (inlineRemoteToken) extraEnv.MEDDLE_REMOTE_TOKEN = inlineRemoteToken.slice('--remote-token='.length)
29
28
 
30
- const child = spawn(process.execPath, [indexPath], {
31
- env: spawnEnv,
32
- stdio: 'inherit',
33
- cwd: process.cwd()
29
+ const { args: spawnArgs, options: spawnOptions } = buildProxySpawn({
30
+ baseEnv: process.env,
31
+ reentryArgv: getReentryArgv(),
32
+ extraEnv,
33
+ })
34
+ const child = spawn(process.execPath, spawnArgs, {
35
+ ...spawnOptions,
36
+ cwd: process.cwd(),
34
37
  })
35
38
 
36
39
  child.on('error', (err) => {
@@ -6,6 +6,7 @@ const fs = require('fs')
6
6
  const path = require('path')
7
7
  const { spawn } = require('child_process')
8
8
  const { resolveMeddleHome } = require('../lib/meddle-home')
9
+ const { buildProxySpawn, buildCliSpawn, getReentryArgv } = require('../lib/spawn-proxy')
9
10
 
10
11
  const rawArgs = process.argv.slice(3)
11
12
  const daemonFlag = rawArgs.includes('--daemon')
@@ -20,9 +21,13 @@ if (daemonFlag) {
20
21
  }
21
22
 
22
23
  function supervise() {
23
- const indexPath = path.join(__dirname, '..', '..', 'index.js')
24
24
  const proxyArgs = stripSupervisorArgs(rawArgs)
25
- const childEnv = { ...process.env, DEBUG: process.env.DEBUG || '', MEDDLE_SUPERVISED: '1' }
25
+ const { args: spawnArgs, options: spawnOptions } = buildProxySpawn({
26
+ baseEnv: process.env,
27
+ reentryArgv: getReentryArgv(),
28
+ extraArgv: proxyArgs,
29
+ extraEnv: { DEBUG: process.env.DEBUG || '', MEDDLE_SUPERVISED: '1' },
30
+ })
26
31
 
27
32
  let child = null
28
33
  let stopping = false
@@ -37,9 +42,9 @@ function supervise() {
37
42
  process.on('SIGTERM', () => stop('SIGTERM'))
38
43
 
39
44
  const start = () => {
40
- child = spawn(process.execPath, [indexPath, ...proxyArgs], {
45
+ child = spawn(process.execPath, spawnArgs, {
41
46
  cwd: process.cwd(),
42
- env: childEnv,
47
+ env: spawnOptions.env,
43
48
  stdio: 'inherit',
44
49
  })
45
50
 
@@ -71,12 +76,16 @@ function startDaemon() {
71
76
  const meddleDir = resolveMeddleHome()
72
77
  fs.mkdirSync(meddleDir, { recursive: true })
73
78
  const logFd = fs.openSync(path.join(meddleDir, 'supervisor.log'), 'a')
74
- const binPath = path.join(__dirname, '..', 'index')
75
- const child = spawn(process.execPath, [binPath, 'supervise', ...args], {
79
+ const { args: spawnArgs, options: spawnOptions } = buildCliSpawn({
80
+ baseEnv: process.env,
81
+ reentryArgv: getReentryArgv(),
82
+ extraArgv: ['supervise', ...args],
83
+ })
84
+ const child = spawn(process.execPath, spawnArgs, {
76
85
  cwd: process.cwd(),
77
86
  detached: true,
78
87
  stdio: ['ignore', logFd, logFd],
79
- env: process.env,
88
+ env: spawnOptions.env,
80
89
  })
81
90
  child.unref()
82
91
  console.log(`Supervisor started: pid=${child.pid}, log=${path.join(meddleDir, 'supervisor.log')}`)
@@ -0,0 +1,34 @@
1
+ 'use strict'
2
+
3
+ // Single-entry env dispatch for the meddle binary.
4
+ // Pure function: no process.env / process.argv reads, no side effects.
5
+ // The binary entrypoint (bin/main.js) calls this with explicit values and then
6
+ // requires the matching module. Self-spawn children set MEDDLE_ENTRY=proxy|mcp|cli
7
+ // instead of passing a script path, so a deno-compiled binary (which has no
8
+ // index.js / mcp-server.js / bin/index.js as files on disk) can still route.
9
+
10
+ /** @typedef {'proxy' | 'mcp' | 'cli'} Entry */
11
+
12
+ const ALLOWED = ['proxy', 'mcp', 'cli']
13
+
14
+ /**
15
+ * @param {{ env: Record<string, string | undefined>, argv: string[] }} input
16
+ * @returns {{ entry: Entry, argv: string[] }}
17
+ */
18
+ function dispatch({ env, argv }) {
19
+ const raw = env && typeof env.MEDDLE_ENTRY === 'string' ? env.MEDDLE_ENTRY : ''
20
+ const normalized = raw.trim().toLowerCase()
21
+ let entry
22
+ if (normalized === '') {
23
+ entry = 'cli'
24
+ } else if (ALLOWED.includes(normalized)) {
25
+ entry = normalized
26
+ } else {
27
+ throw new Error(
28
+ `Unknown MEDDLE_ENTRY "${raw}". Allowed values: ${ALLOWED.join(', ')} (case-insensitive). Omit to default to 'cli'.`
29
+ )
30
+ }
31
+ return { entry, argv: Array.isArray(argv) ? argv.slice() : [] }
32
+ }
33
+
34
+ module.exports = { dispatch, ALLOWED }
@@ -0,0 +1,51 @@
1
+ 'use strict'
2
+
3
+ const path = require('path')
4
+
5
+ // Pure constructor for the meddle self-spawn contract, parameterised by runtime
6
+ // context (binary vs node). All six prod self-spawn sites (mcp-server x2, supervise
7
+ // x2, session/create, start) build their { args, options } through this so the
8
+ // contract lives in ONE place.
9
+ //
10
+ // Reentry model:
11
+ // binary (deno compile): process.execPath IS meddle, reads MEDDLE_ENTRY, dispatches.
12
+ // -> reentryArgv = [] (no script path)
13
+ // npm/node: process.execPath is plain `node`, needs a script path to bin/main.js,
14
+ // which then dispatches via MEDDLE_ENTRY.
15
+ // -> reentryArgv = [absPathToBinMainJs]
16
+ // Callers pass reentryArgv explicitly via getReentryArgv() so buildProxySpawn stays
17
+ // pure (no process reads) and unit-testable with injected reentryArgv.
18
+
19
+ let reentryOverride = null // test hook; undefined = detect from process
20
+
21
+ function getReentryArgv() {
22
+ if (reentryOverride !== null) return reentryOverride.slice()
23
+ // The deno-compiled meddle binary's execPath does NOT look like node, and it
24
+ // dispatches via MEDDLE_ENTRY itself, so no script path is needed. Plain `node`
25
+ // needs bin/main.js to re-enter the dispatcher.
26
+ const exe = (process.execPath || '').toLowerCase()
27
+ const looksLikeNode = /(^|[\\\/])node(\.exe)?$/i.test(exe) || /[\\\/]node-[0-9]/i.test(exe)
28
+ if (!looksLikeNode) return [] // the meddle binary
29
+ // node: re-enter via bin/main.js (this file's neighbour).
30
+ return [path.join(__dirname, '..', 'main.js')]
31
+ }
32
+
33
+ function buildSpawn({ baseEnv, extraEnv, extraArgv, entry, reentryArgv } = {}) {
34
+ const env = Object.assign({}, baseEnv || {}, extraEnv || {}, { MEDDLE_ENTRY: entry })
35
+ const reentry = Array.isArray(reentryArgv) ? reentryArgv : [] // default = binary form
36
+ const args = reentry.concat(Array.isArray(extraArgv) ? extraArgv : [])
37
+ return { args, options: { env, stdio: 'inherit' } }
38
+ }
39
+
40
+ function buildProxySpawn(opts = {}) {
41
+ return buildSpawn({ ...(opts || {}), entry: 'proxy' })
42
+ }
43
+
44
+ function buildCliSpawn(opts = {}) {
45
+ return buildSpawn({ ...(opts || {}), entry: 'cli' })
46
+ }
47
+
48
+ // Test-only hook; do not call from prod code.
49
+ function __setReentryOverrideForTest(v) { reentryOverride = v === undefined ? null : v }
50
+
51
+ module.exports = { buildProxySpawn, buildCliSpawn, getReentryArgv, __setReentryOverrideForTest }
package/bin/main.js ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ // Single injectable entrypoint for the meddle binary.
5
+ // - deno compile target: `deno compile bin/main.js` injects this; routing is via
6
+ // MEDDLE_ENTRY (proxy|mcp|cli) since the compiled binary has no index.js /
7
+ // mcp-server.js / bin/index.js as files on disk.
8
+ // - node/npm path: `meddle` still resolves to bin/index.js (see package.json "bin");
9
+ // this file is only required when MEDDLE_ENTRY is set (self-spawn children) or
10
+ // when invoked explicitly (e.g. `node bin/main.js`).
11
+ //
12
+ // Existing entry files (bin/index.js, index.js, mcp-server.js) are left runnable
13
+ // directly under node — npm path has zero regression.
14
+
15
+ const { dispatch } = require('./lib/dispatch')
16
+
17
+ const { entry, argv } = dispatch({ env: process.env, argv: process.argv.slice(2) })
18
+
19
+ if (entry === 'proxy') {
20
+ // Proxy server. process.argv must look like `node index.js [opts]` for index.js
21
+ // semantics (it reads process.argv via helpers like getFreePort etc.), so we
22
+ // splice argv into process.argv. index.js itself ignores argv for routing but
23
+ // MEDDLE_* env is the real config channel, so argv here is informational.
24
+ process.argv = [process.argv[0], 'index.js', ...argv]
25
+ require('../index.js')
26
+ } else if (entry === 'mcp') {
27
+ process.argv = [process.argv[0], 'mcp-server.js', ...argv]
28
+ require('../mcp-server.js')
29
+ } else {
30
+ // cli: bin/index.js expects argv = process.argv.slice(2) (the user command +
31
+ // flags), and strips --session itself. Forward verbatim.
32
+ process.argv = [process.argv[0], 'bin/index.js', ...argv]
33
+ require('./index.js')
34
+ }
package/mcp-server.js CHANGED
@@ -16,6 +16,7 @@ const {
16
16
  deleteSession, isPidAlive, allocatePort, generateId, sessionDir, readRegistry
17
17
  } = require('./bin/lib/sessions')
18
18
  const { GLOBAL_DEFAULT_PORT } = require('./bin/lib/session-args')
19
+ const { buildProxySpawn, getReentryArgv } = require('./bin/lib/spawn-proxy')
19
20
 
20
21
  const meddleDir = resolveMeddleHome()
21
22
  const mcpFile = path.join(meddleDir, 'mcp-proxy-url.json')
@@ -208,12 +209,15 @@ mcpServer.registerTool('start_proxy', {
208
209
  }
209
210
  proxyProcess = null
210
211
  cachedProxyUrl = null
211
- const indexPath = path.join(__dirname, 'index.js')
212
- const spawnEnv = { ...process.env, MEDDLE_MCP: '1', DEBUG: process.env.DEBUG || '' }
213
- const child = spawn(process.execPath, [indexPath], {
214
- env: spawnEnv,
212
+ const { args, options } = buildProxySpawn({
213
+ baseEnv: process.env,
214
+ reentryArgv: getReentryArgv(),
215
+ extraEnv: { MEDDLE_MCP: '1', DEBUG: process.env.DEBUG || '' },
216
+ })
217
+ const child = spawn(process.execPath, args, {
218
+ ...options,
215
219
  stdio: ['ignore', 'pipe', 'pipe'],
216
- cwd: process.cwd()
220
+ cwd: process.cwd(),
217
221
  })
218
222
  proxyProcess = child
219
223
  child.stdout?.on('data', (d) => process.stderr.write(d))
@@ -278,17 +282,19 @@ mcpServer.registerTool('create_session', {
278
282
  fs.mkdirSync(sDir, { recursive: true })
279
283
 
280
284
  // 3. spawn child
281
- const indexPath = path.join(__dirname, 'index.js')
282
- const childEnv = {
283
- ...process.env,
284
- MEDDLE_HOME: sDir,
285
- PORT: String(targetPort),
286
- MEDDLE_SESSION_ID: id,
287
- MEDDLE_HEADLESS: '1',
288
- MEDDLE_MCP: '1',
289
- }
290
- const child = spawn(process.execPath, [indexPath], {
291
- env: childEnv,
285
+ const { args, options } = buildProxySpawn({
286
+ baseEnv: process.env,
287
+ reentryArgv: getReentryArgv(),
288
+ extraEnv: {
289
+ MEDDLE_HOME: sDir,
290
+ PORT: String(targetPort),
291
+ MEDDLE_SESSION_ID: id,
292
+ MEDDLE_HEADLESS: '1',
293
+ MEDDLE_MCP: '1',
294
+ },
295
+ })
296
+ const child = spawn(process.execPath, args, {
297
+ ...options,
292
298
  stdio: ['ignore', 'ignore', 'ignore'],
293
299
  cwd: process.cwd(),
294
300
  detached: false,
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@jonathanleelx/meddle",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "A simple development proxy server with custom routing rules, mock responses, HTTPS interception, and a plugin system",
5
+ "type": "commonjs",
5
6
  "main": "index.js",
6
7
  "scripts": {
7
8
  "build": "tsc",
@@ -71,7 +72,6 @@
71
72
  "chalk": "^4.1.2",
72
73
  "chokidar": "^3.6.0",
73
74
  "debug": "^4.4.3",
74
- "esbuild": "^0.27.7",
75
75
  "express": "^5.2.1",
76
76
  "inquirer": "^8.2.7",
77
77
  "node-easy-cert": "^1.3.3",
@@ -1 +1 @@
1
- import{a as e,f as t,l as n,n as r,s as i,u as a}from"./button-BTToMaBW.js";import{a as o,o as s,r as c,t as l}from"./dist-C6eaYCUo.js";import{t as u}from"./dist-C5nMErq8.js";import{n as d,t as f}from"./dist-D5Dj17P8.js";import{mt as p}from"./index-DTeCUv1G.js";var m=n(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),h=t(a(),1),g=e(),_=`Checkbox`,[v,y]=o(_),[b,x]=v(_);function S(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:u,value:d=`on`,internal_do_not_use_render:f}=e,[p,m]=l({prop:n,defaultProp:i??!1,onChange:c,caller:_}),[v,y]=h.useState(null),[x,S]=h.useState(null),C=h.useRef(!1),w=v?!!o||!!v.closest(`form`):!0,T={checked:p,disabled:a,setChecked:m,control:v,setControl:y,name:s,form:o,value:d,hasConsumerStoppedPropagationRef:C,required:u,defaultChecked:j(i)?!1:i,isFormControl:w,bubbleInput:x,setBubbleInput:S};return(0,g.jsx)(b,{scope:t,...T,children:A(f)?f(T):r})}var C=`CheckboxTrigger`,w=h.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},a)=>{let{control:o,value:l,disabled:u,checked:d,required:f,setControl:p,setChecked:m,hasConsumerStoppedPropagationRef:_,isFormControl:v,bubbleInput:y}=x(C,e),b=i(a,p),S=h.useRef(d);return h.useEffect(()=>{let e=o?.form;if(e){let t=()=>m(S.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[o,m]),(0,g.jsx)(s.button,{type:`button`,role:`checkbox`,"aria-checked":j(d)?`mixed`:d,"aria-required":f,"data-state":M(d),"data-disabled":u?``:void 0,disabled:u,value:l,...r,ref:b,onKeyDown:c(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:c(n,e=>{m(e=>j(e)?!0:!e),y&&v&&(_.current=e.isPropagationStopped(),_.current||e.stopPropagation())})})});w.displayName=C;var T=h.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,g.jsx)(S,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(w,{...d,ref:t,__scopeCheckbox:n}),e&&(0,g.jsx)(k,{__scopeCheckbox:n})]})})});T.displayName=_;var E=`CheckboxIndicator`,D=h.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=x(E,n);return(0,g.jsx)(u,{present:r||j(a.checked)||a.checked===!0,children:(0,g.jsx)(s.span,{"data-state":M(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});D.displayName=E;var O=`CheckboxBubbleInput`,k=h.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:c,required:l,disabled:u,name:p,value:m,form:_,bubbleInput:v,setBubbleInput:y}=x(O,e),b=i(n,y),S=d(o),C=f(r);h.useEffect(()=>{let e=v;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!a.current;if(S!==o&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=j(o),n.call(e,j(o)?!1:o),e.dispatchEvent(t)}},[v,S,o,a]);let w=h.useRef(j(o)?!1:o);return(0,g.jsx)(s.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??w.current,required:l,disabled:u,name:p,value:m,form:_,...t,tabIndex:-1,ref:b,style:{...t.style,...C,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});k.displayName=O;function A(e){return typeof e==`function`}function j(e){return e===`indeterminate`}function M(e){return j(e)?`indeterminate`:e?`checked`:`unchecked`}function N({className:e,...t}){return(0,g.jsx)(T,{"data-slot":`checkbox`,className:r(`peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,g.jsx)(D,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none`,children:(0,g.jsx)(p,{className:`size-3.5`})})})}export{m as n,N as t};
1
+ import{a as e,f as t,l as n,n as r,s as i,u as a}from"./button-BTToMaBW.js";import{a as o,o as s,r as c,t as l}from"./dist-C6eaYCUo.js";import{t as u}from"./dist-C5nMErq8.js";import{n as d,t as f}from"./dist-D5Dj17P8.js";import{mt as p}from"./index-DboWpNx1.js";var m=n(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),h=t(a(),1),g=e(),_=`Checkbox`,[v,y]=o(_),[b,x]=v(_);function S(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:u,value:d=`on`,internal_do_not_use_render:f}=e,[p,m]=l({prop:n,defaultProp:i??!1,onChange:c,caller:_}),[v,y]=h.useState(null),[x,S]=h.useState(null),C=h.useRef(!1),w=v?!!o||!!v.closest(`form`):!0,T={checked:p,disabled:a,setChecked:m,control:v,setControl:y,name:s,form:o,value:d,hasConsumerStoppedPropagationRef:C,required:u,defaultChecked:j(i)?!1:i,isFormControl:w,bubbleInput:x,setBubbleInput:S};return(0,g.jsx)(b,{scope:t,...T,children:A(f)?f(T):r})}var C=`CheckboxTrigger`,w=h.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},a)=>{let{control:o,value:l,disabled:u,checked:d,required:f,setControl:p,setChecked:m,hasConsumerStoppedPropagationRef:_,isFormControl:v,bubbleInput:y}=x(C,e),b=i(a,p),S=h.useRef(d);return h.useEffect(()=>{let e=o?.form;if(e){let t=()=>m(S.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[o,m]),(0,g.jsx)(s.button,{type:`button`,role:`checkbox`,"aria-checked":j(d)?`mixed`:d,"aria-required":f,"data-state":M(d),"data-disabled":u?``:void 0,disabled:u,value:l,...r,ref:b,onKeyDown:c(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:c(n,e=>{m(e=>j(e)?!0:!e),y&&v&&(_.current=e.isPropagationStopped(),_.current||e.stopPropagation())})})});w.displayName=C;var T=h.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,g.jsx)(S,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(w,{...d,ref:t,__scopeCheckbox:n}),e&&(0,g.jsx)(k,{__scopeCheckbox:n})]})})});T.displayName=_;var E=`CheckboxIndicator`,D=h.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=x(E,n);return(0,g.jsx)(u,{present:r||j(a.checked)||a.checked===!0,children:(0,g.jsx)(s.span,{"data-state":M(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});D.displayName=E;var O=`CheckboxBubbleInput`,k=h.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:c,required:l,disabled:u,name:p,value:m,form:_,bubbleInput:v,setBubbleInput:y}=x(O,e),b=i(n,y),S=d(o),C=f(r);h.useEffect(()=>{let e=v;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!a.current;if(S!==o&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=j(o),n.call(e,j(o)?!1:o),e.dispatchEvent(t)}},[v,S,o,a]);let w=h.useRef(j(o)?!1:o);return(0,g.jsx)(s.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??w.current,required:l,disabled:u,name:p,value:m,form:_,...t,tabIndex:-1,ref:b,style:{...t.style,...C,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});k.displayName=O;function A(e){return typeof e==`function`}function j(e){return e===`indeterminate`}function M(e){return j(e)?`indeterminate`:e?`checked`:`unchecked`}function N({className:e,...t}){return(0,g.jsx)(T,{"data-slot":`checkbox`,className:r(`peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,g.jsx)(D,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none`,children:(0,g.jsx)(p,{className:`size-3.5`})})})}export{m as n,N as t};
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,r as n}from"./ai-config-store-DQXVJVn_.js";import{vt as r}from"./index-DTeCUv1G.js";import{r as i}from"./syntax-highlight-DVhPdkuV.js";function a(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.parse(t),`json`}catch{}return t.startsWith(`<!DOCTYPE`)||t.startsWith(`<html`)||/<[a-z][\s\S]*>/i.test(t)?`html`:/[a-z-]+\s*\{[\s\S]*\}/i.test(t)||/@(media|keyframes|import|font-face)/i.test(t)?`css`:/(function|const|let|var|class|import|export|=>)/i.test(t)?`javascript`:`unknown`}function o(e){let t=0,n=e.replace(/><>/g,`>
1
+ import{i as e,o as t,r as n}from"./ai-config-store-DQXVJVn_.js";import{vt as r}from"./index-DboWpNx1.js";import{r as i}from"./syntax-highlight-DVhPdkuV.js";function a(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.parse(t),`json`}catch{}return t.startsWith(`<!DOCTYPE`)||t.startsWith(`<html`)||/<[a-z][\s\S]*>/i.test(t)?`html`:/[a-z-]+\s*\{[\s\S]*\}/i.test(t)||/@(media|keyframes|import|font-face)/i.test(t)?`css`:/(function|const|let|var|class|import|export|=>)/i.test(t)?`javascript`:`unknown`}function o(e){let t=0,n=e.replace(/><>/g,`>
2
2
  <`).split(`
3
3
  `),r=[];for(let e of n){let n=e.trim();n&&(n.startsWith(`</`)&&(t=Math.max(0,t-1)),r.push(` `.repeat(t)+n),n.startsWith(`<`)&&!n.startsWith(`</`)&&!n.startsWith(`<?`)&&!n.endsWith(`/>`)&&(/<(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)\b/i.test(n)||t++))}return r.join(`
4
4
  `)}function s(e){return e.replace(/\s*{\s*/g,` {
@@ -16,5 +16,5 @@ import{i as e,o as t,r as n}from"./ai-config-store-DQXVJVn_.js";import{vt as r}f
16
16
  ${e}`,a=await fetch(n.baseUrl,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${n.apiKey}`},body:JSON.stringify({model:n.model,messages:[{role:`system`,content:r},{role:`user`,content:i}],temperature:.3,max_tokens:2e3})});if(!a.ok){let e=await a.text();throw Error(`OpenAI API错误 (${a.status}): ${e}`)}let o=(await a.json()).choices?.[0]?.message?.content?.trim();if(!o)throw Error(`OpenAI返回了空结果`);return S(o)}async function x(e,t,n){let r=`You are a code fixing assistant. Fix syntax errors in ${t.toUpperCase()} code. Return only the fixed code without explanations or markdown formatting.`,i=`Please fix the syntax errors in the following ${t.toUpperCase()} code. Return ONLY the fixed code without any explanations:
17
17
 
18
18
  ${e}`,a=await fetch(n.baseUrl,{method:`POST`,headers:{"Content-Type":`application/json`,"x-api-key":n.apiKey,"anthropic-version":`2023-06-01`},body:JSON.stringify({model:n.model,max_tokens:2e3,system:r,messages:[{role:`user`,content:i}],temperature:.3})});if(!a.ok){let e=await a.text();throw Error(`Anthropic API错误 (${a.status}): ${e}`)}let o=(await a.json()).content?.[0]?.text?.trim();if(!o)throw Error(`Anthropic返回了空结果`);return S(o)}function S(e){let t=e.replace(/^```[a-z]*\n?/i,``).replace(/\n?```$/i,``).trim(),n=t.split(`
19
- `);return n.length>0&&!n[0].trim().match(/^[{<\[a-z@]/i)&&(n.shift(),t=n.join(`
19
+ `);return n.length>0&&!n[0].trim().match(/^[{<[a-z@]/i)&&(n.shift(),t=n.join(`
20
20
  `).trim()),t}async function C(e,t,n){return n.provider===`anthropic`?x(e,t,n):b(e,t,n)}export{u as n,v as t};
@@ -1,3 +1,3 @@
1
- import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./arrow-right-B4Mrlj2-.js";import{t as o}from"./chevron-down-CPngAx4M.js";import{t as s}from"./chevron-right-V1DGIDbL.js";import{t as c}from"./circle-x-C9USji_R.js";import{n as l,t as u}from"./server-Cpj4KNwN.js";import{t as d}from"./shield-check-OqUmVLQt.js";import{t as f}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{B as p,H as m,S as h,U as g,V as _,_t as v,at as y,et as b,g as x,gt as S,h as C,m as w,ot as ee,v as T,x as E,y as D,z as O}from"./index-DTeCUv1G.js";import{n as k,t as A}from"./body-diff-view-D7dCWajG.js";import{t as j}from"./syntax-highlight-DVhPdkuV.js";var M=n(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),te=n(`flag`,[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]),N=n(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),P=t(i(),1),F=e();function I(e){return e>=200&&e<300?`bg-green-100 text-green-800`:e>=300&&e<400?`bg-blue-100 text-blue-800`:e>=400&&e<500?`bg-amber-100 text-amber-800`:e>=500?`bg-red-100 text-red-800`:``}function L({headers:e}){let t=Object.entries(e||{});return t.length===0?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无头部信息`}):(0,F.jsx)(`div`,{className:`font-mono text-xs space-y-0.5`,children:t.map(([e,t])=>(0,F.jsxs)(`div`,{className:`flex gap-2 py-0.5 hover:bg-muted/50 px-1 rounded`,children:[(0,F.jsxs)(`span`,{className:`text-purple-600 shrink-0 font-semibold`,children:[e,`:`]}),(0,F.jsx)(`span`,{className:`text-foreground/80 break-all`,children:t})]},e))})}function R({body:e}){let t=(0,P.useMemo)(()=>e?j(e):null,[e]);return e?(0,F.jsx)(`div`,{className:`font-mono text-xs bg-muted/30 rounded p-2`,children:(0,F.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:t})}):(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无内容`})}function z(e){switch(e){case`ok`:return`bg-green-100 text-green-800 border-green-200`;case`error`:return`bg-red-100 text-red-800 border-red-200`;case`skipped`:return`bg-amber-100 text-amber-800 border-amber-200`;case`short-circuited`:return`bg-blue-100 text-blue-800 border-blue-200`;default:return``}}function B(e){switch(e){case`ok`:return`通过`;case`error`:return`异常`;case`skipped`:return`跳过`;case`short-circuited`:return`已短路返回`;default:return e}}function V(e){switch(e){case`builtin`:return`内置`;case`custom`:return`自定义`;case`system`:return`系统`;default:return e}}function H(e){return e.replace(/^builtin\./,``).replace(/^custom\./,``)}function U(e,t){return`${t}-${e.hook}-${e.name}`}function W(e){return e===`onBeforeResponse`||e===`onAfterResponse`?`response`:`request`}function G(e,t){return Array.from(new Set([...Object.keys(e),...Object.keys(t)])).sort().map(n=>({key:n,before:e[n]??``,after:t[n]??``})).filter(e=>e.before!==e.after)}function K({headers:e}){let t=Object.entries(e);return t.length===0?(0,F.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`}):(0,F.jsx)(`div`,{className:`space-y-1`,children:t.map(([e,t])=>(0,F.jsxs)(`div`,{className:`break-all`,children:[(0,F.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`]}),` `,t]},e))})}function q({lines:e,className:t}){return e.length===0?(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,F.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-2 text-xs font-mono space-y-1 ${t||``}`,children:e.map((e,t)=>(0,F.jsxs)(`div`,{className:`whitespace-pre-wrap break-all px-2 py-1 rounded ${e.type===`added`?`bg-green-500/10 text-green-700 dark:text-green-300`:`bg-red-500/10 text-red-700 dark:text-red-300`}`,children:[(0,F.jsx)(`span`,{className:`mr-1`,children:e.type===`added`?`+ `:`- `}),e.text]},`${e.type}-${t}-${e.text}`))})}function J(e,t,n){let r=[];return t!==void 0&&t!==``&&r.push({type:`removed`,text:`${e} ${t}`}),n!==void 0&&n!==``&&r.push({type:`added`,text:`${e} ${n}`}),r}function Y(e,t){let n=[];return e!==void 0&&e!==``&&n.push({type:`removed`,text:e}),t!==void 0&&t!==``&&n.push({type:`added`,text:t}),n}function X(e){let t=e.replace(/\r\n/g,`
1
+ import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./arrow-right-B4Mrlj2-.js";import{t as o}from"./chevron-down-CPngAx4M.js";import{t as s}from"./chevron-right-V1DGIDbL.js";import{t as c}from"./circle-x-C9USji_R.js";import{n as l,t as u}from"./server-Cpj4KNwN.js";import{t as d}from"./shield-check-OqUmVLQt.js";import{t as f}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{B as p,H as m,S as h,U as g,V as _,_t as v,at as y,et as b,g as x,gt as S,h as C,m as w,ot as ee,v as T,x as E,y as D,z as O}from"./index-DboWpNx1.js";import{n as k,t as A}from"./body-diff-view-D7dCWajG.js";import{t as j}from"./syntax-highlight-DVhPdkuV.js";var M=n(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),te=n(`flag`,[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]),N=n(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),P=t(i(),1),F=e();function I(e){return e>=200&&e<300?`bg-green-100 text-green-800`:e>=300&&e<400?`bg-blue-100 text-blue-800`:e>=400&&e<500?`bg-amber-100 text-amber-800`:e>=500?`bg-red-100 text-red-800`:``}function L({headers:e}){let t=Object.entries(e||{});return t.length===0?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无头部信息`}):(0,F.jsx)(`div`,{className:`font-mono text-xs space-y-0.5`,children:t.map(([e,t])=>(0,F.jsxs)(`div`,{className:`flex gap-2 py-0.5 hover:bg-muted/50 px-1 rounded`,children:[(0,F.jsxs)(`span`,{className:`text-purple-600 shrink-0 font-semibold`,children:[e,`:`]}),(0,F.jsx)(`span`,{className:`text-foreground/80 break-all`,children:t})]},e))})}function R({body:e}){let t=(0,P.useMemo)(()=>e?j(e):null,[e]);return e?(0,F.jsx)(`div`,{className:`font-mono text-xs bg-muted/30 rounded p-2`,children:(0,F.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:t})}):(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无内容`})}function z(e){switch(e){case`ok`:return`bg-green-100 text-green-800 border-green-200`;case`error`:return`bg-red-100 text-red-800 border-red-200`;case`skipped`:return`bg-amber-100 text-amber-800 border-amber-200`;case`short-circuited`:return`bg-blue-100 text-blue-800 border-blue-200`;default:return``}}function B(e){switch(e){case`ok`:return`通过`;case`error`:return`异常`;case`skipped`:return`跳过`;case`short-circuited`:return`已短路返回`;default:return e}}function V(e){switch(e){case`builtin`:return`内置`;case`custom`:return`自定义`;case`system`:return`系统`;default:return e}}function H(e){return e.replace(/^builtin\./,``).replace(/^custom\./,``)}function U(e,t){return`${t}-${e.hook}-${e.name}`}function W(e){return e===`onBeforeResponse`||e===`onAfterResponse`?`response`:`request`}function G(e,t){return Array.from(new Set([...Object.keys(e),...Object.keys(t)])).sort().map(n=>({key:n,before:e[n]??``,after:t[n]??``})).filter(e=>e.before!==e.after)}function K({headers:e}){let t=Object.entries(e);return t.length===0?(0,F.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`}):(0,F.jsx)(`div`,{className:`space-y-1`,children:t.map(([e,t])=>(0,F.jsxs)(`div`,{className:`break-all`,children:[(0,F.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`]}),` `,t]},e))})}function q({lines:e,className:t}){return e.length===0?(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,F.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-2 text-xs font-mono space-y-1 ${t||``}`,children:e.map((e,t)=>(0,F.jsxs)(`div`,{className:`whitespace-pre-wrap break-all px-2 py-1 rounded ${e.type===`added`?`bg-green-500/10 text-green-700 dark:text-green-300`:`bg-red-500/10 text-red-700 dark:text-red-300`}`,children:[(0,F.jsx)(`span`,{className:`mr-1`,children:e.type===`added`?`+ `:`- `}),e.text]},`${e.type}-${t}-${e.text}`))})}function J(e,t,n){let r=[];return t!==void 0&&t!==``&&r.push({type:`removed`,text:`${e} ${t}`}),n!==void 0&&n!==``&&r.push({type:`added`,text:`${e} ${n}`}),r}function Y(e,t){let n=[];return e!==void 0&&e!==``&&n.push({type:`removed`,text:e}),t!==void 0&&t!==``&&n.push({type:`added`,text:t}),n}function X(e){let t=e.replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `);return t[t.length-1]===``&&t.pop(),t.length>0?t:[``]}function Z(e){if(!e)return!1;if(/^\(binary(?:,\s*\d+\s+bytes)?\)$/i.test(e.trim()))return!0;let t=0;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r===9||r===10||r===13||(r<32||r===65533)&&(t+=1)}return t>0&&t/Math.max(e.length,1)>.15}function Q({before:e,after:t}){let[n,i]=(0,P.useState)(!1),a=(0,P.useMemo)(()=>G(e,t),[e,t]),c=(0,P.useMemo)(()=>a.flatMap(e=>J(e.key,e.before,e.after)),[a]);return c.length===0?(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(q,{lines:c}),(0,F.jsxs)(r,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:()=>i(e=>!e),children:[n?(0,F.jsx)(o,{className:`h-3.5 w-3.5 mr-1`}):(0,F.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}),n?`收起完整头部`:`展开完整头部`]}),n&&(0,F.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 text-xs font-mono`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`变更前`}),(0,F.jsx)(K,{headers:e})]}),(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 text-xs font-mono`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`变更后`}),(0,F.jsx)(K,{headers:t})]})]})]})}function ne({before:e,after:t}){let[n,i]=(0,P.useState)(!1),a=(0,P.useMemo)(()=>k(e||``,t||``).filter(e=>e.added||e.removed),[e,t]),c=(0,P.useMemo)(()=>Z(e||``)||Z(t||``),[e,t]),l=(0,P.useMemo)(()=>c?Y(e||``,t||``):a.flatMap(e=>X(e.value).map(t=>({type:e.added?`added`:`removed`,text:t}))),[e,t,a,c]);return l.length===0?(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(q,{lines:l,className:`max-h-40 overflow-auto`}),!c&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(r,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:()=>i(e=>!e),children:[n?(0,F.jsx)(o,{className:`h-3.5 w-3.5 mr-1`}):(0,F.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}),n?`收起完整 Diff`:`展开完整 Diff`]}),n&&(0,F.jsx)(A,{original:e,modified:t,mode:`inline`,maxHeight:`220px`})]})]})}function re({stage:e}){let t=e.changes;return t?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(t.targetBefore||t.targetAfter)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Request URL Diff`}),(0,F.jsx)(q,{lines:J(`Request URL`,t.targetBefore,t.targetAfter||t.target)})]}),(t.requestHeadersBefore||t.requestHeadersAfter)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Request Header Diff`}),(0,F.jsx)(Q,{before:t.requestHeadersBefore||{},after:t.requestHeadersAfter||{}})]}),(t.responseStatusCodeBefore!==void 0||t.responseStatusCodeAfter!==void 0)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Status Diff`}),(0,F.jsx)(q,{lines:J(`Response Status`,t.responseStatusCodeBefore,t.responseStatusCodeAfter??t.responseStatusCode)})]}),(t.responseHeadersBefore||t.responseHeadersAfter)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Header Diff`}),(0,F.jsx)(Q,{before:t.responseHeadersBefore||{},after:t.responseHeadersAfter||{}})]}),(t.responseBodyBefore!==void 0||t.responseBodyAfter!==void 0)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Body Diff`}),(0,F.jsx)(ne,{before:t.responseBodyBefore||``,after:t.responseBodyAfter||t.responseBody||``})]})]}):null}function ie({stage:e,index:t,isLast:n,accentClass:i}){let[a,c]=(0,P.useState)(e.status!==`skipped`);return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border bg-background/90 p-3 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-6 px-1 text-xs`,onClick:()=>c(e=>!e),title:a?`收起`:`展开`,children:a?(0,F.jsx)(o,{className:`h-3.5 w-3.5`}):(0,F.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,F.jsxs)(`span`,{className:`font-medium text-sm`,children:[t+1,`. `,H(e.name)]}),(0,F.jsx)(O,{variant:`outline`,className:`text-xs font-normal`,children:e.hook}),(0,F.jsx)(O,{variant:`outline`,className:`text-xs font-normal`,children:V(e.type)})]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.status===`short-circuited`?`这一阶段直接生成了响应,请求不会继续往后转发。`:e.status===`error`?`这一阶段执行失败,影响了后续处理流程。`:`这一阶段执行完成,请求继续进入下一步。`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,F.jsx)(O,{className:`text-xs border ${z(e.status)}`,children:B(e.status)}),(0,F.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.duration,`ms`]})]})]}),a&&(0,F.jsxs)(F.Fragment,{children:[e.target&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`当前 Target`}),(0,F.jsx)(`div`,{className:`font-mono text-xs break-all`,children:e.target})]}),(0,F.jsx)(re,{stage:e}),e.error&&(0,F.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[`Error: `,e.error]})]})]}),!n&&(0,F.jsx)(`div`,{className:`flex justify-center py-1`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full ${i} animate-pulse`}),(0,F.jsx)(S,{className:`h-4 w-4 ${i} animate-bounce`})]})})]})}function $({title:e,description:t,stages:n,icon:r,roleLabel:i,roleIcon:a,accentClass:o}){return(0,F.jsxs)(`div`,{className:`rounded-xl border bg-card p-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`flex items-center gap-2 mb-2`,children:(0,F.jsxs)(O,{variant:`outline`,className:`text-[11px] font-normal`,children:[(0,F.jsx)(`span`,{className:`mr-1`,children:a}),i]})}),(0,F.jsxs)(`h4`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:o,children:r}),e]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t})]}),(0,F.jsxs)(O,{variant:`outline`,className:`text-xs`,children:[n.length,` 个阶段`]})]}),n.length===0?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`无阶段信息`}):(0,F.jsx)(`div`,{className:`space-y-3`,children:n.map(({stage:e,index:t},r)=>(0,F.jsx)(ie,{stage:e,index:t,isLast:r===n.length-1,accentClass:o},U(e,t)))})]})}function ae(e){let t=[...e.stages].reverse().find(e=>e.status===`short-circuited`);if(t)return{label:`提前返回响应`,description:`在 ${H(t.name)} 阶段直接生成响应`,icon:(0,F.jsx)(M,{className:`h-4 w-4 text-blue-500`})};let n=[...e.stages].reverse().find(e=>e.status===`error`);return n?{label:`处理过程中出现异常`,description:`${H(n.name)} 执行失败`,icon:(0,F.jsx)(c,{className:`h-4 w-4 text-red-500`})}:{label:`进入正常代理流程`,description:`请求经过检查后继续转发到目标服务`,icon:(0,F.jsx)(a,{className:`h-4 w-4 text-emerald-500`})}}function oe({inspection:e}){let t=ae(e),n=e.stages.map((e,t)=>({stage:e,index:t})),r=n.filter(({stage:e})=>W(e.hook)===`request`),i=n.filter(({stage:e})=>W(e.hook)===`response`);return(0,F.jsxs)(`div`,{className:`space-y-4 pt-3`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border bg-gradient-to-br from-muted/20 via-background to-muted/10 p-4 space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,F.jsx)(O,{variant:`outline`,className:`font-mono`,children:e.method}),(0,F.jsx)(`span`,{className:`font-mono text-muted-foreground truncate flex-1`,children:e.url}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,F.jsx)(l,{className:`h-3.5 w-3.5`}),(0,F.jsxs)(`span`,{className:`text-xs`,children:[e.totalDuration,`ms`]})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,F.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,F.jsx)(N,{className:`h-3.5 w-3.5`}),`请求入口`]}),(0,F.jsx)(`div`,{className:`text-sm font-medium`,children:`请求进入代理`}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`从浏览器或客户端发起,进入 Meddle 的处理流水线`})]}),(0,F.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,F.jsx)(d,{className:`h-3.5 w-3.5`}),`处理阶段`]}),(0,F.jsxs)(`div`,{className:`text-sm font-medium`,children:[e.stages.length,` 个阶段`]}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`按实际执行顺序记录插件和系统模块对请求的处理`})]}),(0,F.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[t.icon,`最终结果`]}),(0,F.jsx)(`div`,{className:`text-sm font-medium`,children:t.label}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:t.description})]})]})]}),e.stages.length===0?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`无处理阶段信息(插件模式可能未开启)`}):(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,F.jsx)(te,{className:`h-3.5 w-3.5`}),(0,F.jsx)(`span`,{children:`默认仅展示改动内容;跳过阶段默认折叠,可单独展开查看更多。`})]}),(0,F.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,F.jsx)($,{title:`请求阶段`,description:`客户端请求进入代理后,按顺序执行请求侧处理阶段`,stages:r,icon:(0,F.jsx)(N,{className:`h-4 w-4 text-blue-500`}),roleLabel:`客户端`,roleIcon:(0,F.jsx)(y,{className:`h-3 w-3 text-blue-500`}),accentClass:`text-blue-500`}),(0,F.jsx)($,{title:`响应阶段`,description:`服务器响应返回代理后,按顺序执行响应侧处理阶段`,stages:i,icon:(0,F.jsx)(v,{className:`h-4 w-4 text-emerald-500`}),roleLabel:`服务器`,roleIcon:(0,F.jsx)(u,{className:`h-3 w-3 text-emerald-500`}),accentClass:`text-emerald-500`})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,F.jsx)(`span`,{children:`请求进入`}),(0,F.jsx)(a,{className:`h-4 w-4 animate-pulse text-blue-500`}),(0,F.jsx)(`span`,{children:`请求阶段`}),(0,F.jsx)(a,{className:`h-4 w-4 animate-pulse text-violet-500`}),(0,F.jsx)(`span`,{children:`响应阶段`}),(0,F.jsx)(a,{className:`h-4 w-4 animate-pulse text-emerald-500`}),(0,F.jsx)(`span`,{children:`最终返回`})]})]})]})}function se({open:e=!1,onClose:t,embedded:n=!1,detail:i,loading:a,error:o,selectedRecord:s,onCreateMock:c,onReplay:l}){let[u,d]=(0,P.useState)(!1),y=()=>{i&&s&&c&&c({source:s.source,responseBody:i.responseBody,statusCode:i.statusCode,responseHeaders:i.responseHeaders})},[S,k]=(0,P.useState)(null),A=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(T,{className:`px-4 pt-4 pb-2`,children:(0,F.jsxs)(D,{className:`flex items-center gap-2 text-base`,children:[`请求详情`,i&&(0,F.jsxs)(O,{className:`${I(i.statusCode)} border-0`,children:[i.statusCode,` `,i.statusMessage]}),s?.clientType&&(0,F.jsxs)(O,{variant:`outline`,className:`max-w-48 text-[10px] font-mono`,title:[s.clientName,s.clientIp].filter(Boolean).join(` · `),children:[s.clientName||(s.clientType===`local`?`本机`:s.clientType===`plugin`?`插件测试`:`远程设备`),s.clientIp?` · ${s.clientIp}`:``]}),s?.applicationName&&(0,F.jsxs)(O,{variant:`outline`,className:`max-w-56 gap-1.5 text-[10px]`,title:[s.applicationIdentitySource===`local-process`?`识别方式: 本机进程`:s.applicationIdentitySource===`user-agent`?`识别方式: User-Agent 推断`:s.applicationIdentitySource===`client-reported`?`识别方式: 客户端上报`:void 0,s.applicationIdentityConfidence?`可信度: ${s.applicationIdentityConfidence===`high`?`高`:s.applicationIdentityConfidence===`medium`?`中`:`低`}`:void 0,s.applicationProcess,s.applicationPid?`PID ${s.applicationPid}`:void 0,s.applicationBundleId,s.applicationPath].filter(Boolean).join(` · `),children:[(0,F.jsx)(E,{record:s,compact:!0}),(0,F.jsx)(`span`,{className:`truncate`,children:s.applicationName}),s.applicationIdentitySource===`user-agent`&&(0,F.jsx)(`span`,{className:`shrink-0 text-[9px] text-muted-foreground`,children:`推断`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto`,children:[i&&l&&s?.id!=null&&(0,F.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:async()=>{if(s?.id!=null&&l){d(!0),k(null);try{await l(s.id)}catch(e){k(e.message||`重放失败`)}finally{d(!1)}}},disabled:u,title:`使用相同的请求参数重新发送请求`,children:[(0,F.jsx)(b,{className:`h-3.5 w-3.5 mr-1 ${u?`animate-spin`:``}`}),u?`重放中...`:`重放`]}),i&&c&&!s?.mock&&(0,F.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:y,children:[(0,F.jsx)(f,{className:`h-3.5 w-3.5 mr-1`}),`创建 Mock`]})]})]})}),(0,F.jsx)(w,{}),S&&(0,F.jsx)(`div`,{className:`mx-4 mt-2 px-3 py-2 rounded-md bg-red-50 border border-red-200 text-red-700 text-xs`,children:S}),o&&!a&&!i&&(0,F.jsx)(`div`,{className:`mx-4 mt-2 px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-amber-800 text-xs`,children:o}),a?(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,F.jsx)(ee,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):i?(0,F.jsxs)(p,{defaultValue:`request`,className:`flex-1 flex flex-col min-h-0`,children:[(0,F.jsxs)(m,{className:`mx-4 mt-2 w-fit`,children:[(0,F.jsx)(g,{value:`request`,children:`请求`}),(0,F.jsx)(g,{value:`response`,children:`响应`}),(0,F.jsxs)(g,{value:`inspect`,children:[(0,F.jsx)(v,{className:`h-3.5 w-3.5 mr-1`}),`Inspect`]})]}),(0,F.jsx)(_,{value:`request`,className:`flex-1 min-h-0 mt-0`,children:(0,F.jsx)(h,{className:`h-full px-4 pb-4`,children:(0,F.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Request Headers`}),(0,F.jsx)(L,{headers:i.requestHeaders})]}),(0,F.jsx)(w,{}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Request Body`}),(0,F.jsx)(R,{body:i.requestBody})]})]})})}),(0,F.jsx)(_,{value:`response`,className:`flex-1 min-h-0 mt-0`,children:(0,F.jsx)(h,{className:`h-full px-4 pb-4`,children:(0,F.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Response Headers`}),(0,F.jsx)(L,{headers:i.responseHeaders})]}),(0,F.jsx)(w,{}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Response Body`}),(0,F.jsx)(R,{body:i.responseBody})]})]})})}),(0,F.jsx)(_,{value:`inspect`,className:`flex-1 min-h-0 mt-0`,children:(0,F.jsx)(h,{className:`h-full px-4 pb-4`,children:i.inspection?(0,F.jsx)(oe,{inspection:i.inspection}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full py-12 text-muted-foreground`,children:[(0,F.jsx)(v,{className:`h-12 w-12 mb-4 opacity-50`}),(0,F.jsx)(`p`,{className:`text-sm`,children:`无 Inspect 信息`}),(0,F.jsx)(`p`,{className:`text-xs mt-1`,children:`需要开启插件模式(on/shadow)才能查看请求生命周期`})]})})})]}):(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm px-6 text-center`,children:s?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`div`,{children:`详情数据暂不可用`}),(0,F.jsxs)(`div`,{className:`text-xs font-mono break-all`,children:[s.method,` `,s.source]})]}):(0,F.jsx)(`div`,{children:`无法加载详情`})})]});return n?(0,F.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:A}):(0,F.jsx)(C,{open:e,onOpenChange:e=>!e&&t?.(),children:(0,F.jsx)(x,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:640,storageKey:`detail-panel`,children:A})})}export{se as DetailPanel};
@@ -1,4 +1,4 @@
1
- import{a as e,f as t,l as n,n as r,t as i,u as a}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as o}from"./circle-alert-Q8cZk9Rv.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p}from"./dist-CxdY_A67.js";import"./es2015-CfXu88Y7.js";import{i as m,o as h,r as g}from"./ai-config-store-DQXVJVn_.js";import{A as _,Q as v,dt as y,ht as b,ot as x,pt as S,t as C,z as w}from"./index-DTeCUv1G.js";var T=n(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),E=n(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),D=n(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),O=t(a(),1);function k(){let e=g(),t=m(e);return t?{...e,provider:t.provider,apiKey:t.apiKey,baseUrl:t.baseUrl,model:t.model}:e}async function A(e){let t=await e.json();if(!e.ok)throw Error(t.error||`请求失败: ${e.status}`);return t}function j(e){let t=e.split(`
1
+ import{a as e,f as t,l as n,n as r,t as i,u as a}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as o}from"./circle-alert-Q8cZk9Rv.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p}from"./dist-CxdY_A67.js";import"./es2015-CfXu88Y7.js";import{i as m,o as h,r as g}from"./ai-config-store-DQXVJVn_.js";import{A as _,Q as v,dt as y,ht as b,ot as x,pt as S,t as C,z as w}from"./index-DboWpNx1.js";var T=n(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),E=n(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),D=n(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),O=t(a(),1);function k(){let e=g(),t=m(e);return t?{...e,provider:t.provider,apiKey:t.apiKey,baseUrl:t.baseUrl,model:t.model}:e}async function A(e){let t=await e.json();if(!e.ok)throw Error(t.error||`请求失败: ${e.status}`);return t}function j(e){let t=e.split(`
2
2
  `);return{event:t.find(e=>e.startsWith(`event:`))?.slice(6).trim()||`message`,data:t.filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
3
3
  `)}}async function M(e,t={},n){let r=k();if(!h(r))throw Error(`请先在系统设置中启用并填写可用的 AI 配置。`);let i=await fetch(`/api/agent/chat-stream`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:e,aiConfig:r,...n?{conversationId:n}:{}})});if(!i.ok||!i.body)return A(i);let a=i.body.getReader(),o=new TextDecoder,s=``,c=e=>{let{event:n,data:r}=j(e);if(!r)return null;let i=JSON.parse(r);if(n===`start`)return t.onStart?.(),null;if(n===`delta`){let e=typeof i.delta==`string`?i.delta:``;return e&&t.onDelta?.(e),null}if(n===`error`)throw Error(typeof i.error==`string`?i.error:`AI 请求失败`);return n===`done`?i:null};for(;;){let{value:e,done:t}=await a.read();s+=o.decode(e||new Uint8Array,{stream:!t});let n=s.split(/\n\n/);s=n.pop()||``;for(let e of n){let t=c(e);if(t)return t}if(t)break}if(s.trim()){let e=c(s);if(e)return e}throw Error(`AI 流式响应未返回完成事件`)}async function N(e,t){return A(await fetch(`/api/agent/confirm`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({confirmationId:e,approved:t})}))}function P(e){return e.trim().toLowerCase()}function F(e,t){if(!e)return 1;let n=P(e),r=P(t);if(!n)return 1;if(!r)return 0;if(r===n)return 120;if(r.startsWith(n))return 100-Math.min(r.length-n.length,30);if(r.includes(n))return 80-Math.min(r.indexOf(n),30);let i=0,a=0;for(let e=0;e<r.length&&i<n.length;e++)n[i]===r[e]&&(i+=1,a+=4);return i===n.length?a:0}function I(e,t){let n=[t.title,t.description||``,t.section,...t.keywords||[]];return Math.max(...n.map(t=>F(e,t)))}function L(e,t){return(0,O.useMemo)(()=>{let n=e.map(e=>({command:e,score:I(t,e)})).filter(e=>e.score>0);return n.sort((e,t)=>e.command.disabled===t.command.disabled?t.score===e.score?e.command.title.localeCompare(t.command.title,`zh-Hans-CN`):t.score-e.score:e.command.disabled?1:-1),n.map(e=>e.command)},[e,t])}function R(){let e=(0,O.useContext)(C);if(!e)throw Error(`useGlobalPanel must be used inside GlobalPanelProvider`);return e}var z=e(),B={command:`w-[min(760px,calc(100vw-32px))] h-[min(760px,calc(100vh-48px))]`,md:`w-[min(760px,calc(100vw-32px))] h-[min(720px,calc(100vh-48px))]`,lg:`w-[min(1040px,calc(100vw-32px))] h-[min(780px,calc(100vh-48px))]`,xl:`w-[min(1240px,calc(100vw-32px))] h-[min(860px,calc(100vh-32px))]`,fullscreen:`w-[calc(100vw-32px)] h-[calc(100vh-32px)]`},V={md:{width:760,height:720},lg:{width:1040,height:780},xl:{width:1240,height:860},fullscreen:{width:1/0,height:1/0}};function H(){let e=typeof window>`u`?1280:window.innerWidth,t=typeof window>`u`?900:window.innerHeight,n=Math.max(320,e-32),r=Math.max(360,t-32);return{minWidth:Math.min(560,n),minHeight:Math.min(420,r),maxWidth:n,maxHeight:r}}function U(e){let t=H();return{width:Math.min(t.maxWidth,Math.max(t.minWidth,e.width)),height:Math.min(t.maxHeight,Math.max(t.minHeight,e.height))}}function W(e){let t=H(),n=V[e]||V.lg;return e===`fullscreen`?{width:t.maxWidth,height:t.maxHeight}:U(n)}function G(e){if(typeof window>`u`)return null;try{let t=window.localStorage.getItem(`global-panel-size:${e}`);if(!t)return null;let n=JSON.parse(t);return typeof n.width!=`number`||typeof n.height!=`number`?null:U({width:n.width,height:n.height})}catch{return null}}function K(e){let t=[],n=/(`[^`]+`|\*\*[^*]+\*\*)/g,r=0,i;for(;i=n.exec(e);){i.index>r&&t.push(e.slice(r,i.index));let n=i[0];n.startsWith("`")?t.push((0,z.jsx)(`code`,{className:`rounded bg-muted/70 px-1 py-0.5 font-mono text-[0.92em]`,children:n.slice(1,-1)},`${i.index}-code`)):t.push((0,z.jsx)(`strong`,{children:n.slice(2,-2)},`${i.index}-strong`)),r=i.index+n.length}return r<e.length&&t.push(e.slice(r)),t}function q(e){return/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(e)}function J(e){return e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim())}function Y({content:e}){let t=e.replace(/\r\n/g,`
4
4
  `).split(`
@@ -1 +1 @@
1
- import{a as e,f as t,l as n,n as r,t as i,u as a}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as o}from"./circle-x-C9USji_R.js";import{n as s,t as c}from"./server-Cpj4KNwN.js";import{t as l}from"./refresh-cw-CG3HaiQT.js";import{t as ee}from"./shield-check-OqUmVLQt.js";import{t as u}from"./wifi-D9M35Ajj.js";import{t as d}from"./switch-C-Xk56TK.js";import{C as f,D as p,E as m,F as h,L as g,M as _,N as te,P as v,R as y,T as b,W as x,j as S,pt as C,q as ne,w,z as T}from"./index-DTeCUv1G.js";import{n as E,r as D,t as O}from"./alert-COF-DIAE.js";import{a as k,i as A,n as j,o as M,r as N,t as P}from"./table-CT97lAYq.js";var re=n(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),F=n(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),I=n(`hard-drive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),L=n(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),R=n(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),z=t(a(),1),B=e(),V={ok:`正常`,degraded:`降级`,critical:`严重`},ie={cpu:`CPU`,rss:`RSS 内存`,connections:`连接数`,mitmServers:`MITM 服务`,eventLoopDelay:`事件循环延迟`,fds:`文件描述符`};function H(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.generatedAt==`number`&&typeof t.status==`string`&&typeof t.pid==`number`&&typeof t.uptimeSec==`number`&&!!t.memory&&!!t.cpu&&!!t.connections&&!!t.mitmServers&&Array.isArray(t.checks)}async function U(){let e=await fetch(`/api/health`,{cache:`no-store`});if(!e.ok)throw Error(`健康接口返回 ${e.status}`);let t=await e.json();if(!H(t))throw Error(`健康接口返回格式不正确`);return t}function W(e){if(!Number.isFinite(e))return`-`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=t[0];for(let e=1;e<t.length&&n>=1024;e+=1)n/=1024,r=t[e];return`${n>=10?n.toFixed(0):n.toFixed(1)} ${r}`}function G(e){if(!Number.isFinite(e)||e<0)return`-`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=Math.floor(e%60);return t>0?`${t}天 ${n}小时`:n>0?`${n}小时 ${r}分钟`:r>0?`${r}分钟 ${i}秒`:`${i}秒`}function K(e){return e?new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(new Date(e)):`-`}function q(e,t){return t===`bytes`?W(e):t===`%`?`${e.toFixed(1)}%`:t===`ms`?`${e.toFixed(1)} ms`:String(e)}function J(e,t){return t===`bytes`?W(e):t===`%`?`${e}%`:t===`ms`?`${e} ms`:String(e)}function ae(e){if(!e||typeof e!=`object`)return null;let t=e;return Array.isArray(t.keys)?{windowMs:Number(t.windowMs)||0,maxPerWindow:Number(t.maxPerWindow)||0,keys:t.keys,suppressedTotal:Number(t.suppressedTotal)||0}:null}function Y({status:e}){return(0,B.jsxs)(T,{variant:e===`critical`?`destructive`:e===`degraded`?`secondary`:`default`,children:[e===`ok`?(0,B.jsx)(C,{}):e===`degraded`?(0,B.jsx)(x,{}):(0,B.jsx)(o,{}),V[e]]})}function oe({icon:e,label:t,value:n,detail:r}){return(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsx)(g,{className:`border-b px-4 py-3`,children:(0,B.jsxs)(y,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(e,{}),t]})}),(0,B.jsxs)(v,{className:`flex flex-col gap-1 p-4`,children:[(0,B.jsx)(`div`,{className:`text-2xl font-semibold tracking-tight`,children:n}),(0,B.jsx)(`div`,{className:`min-h-4 truncate text-xs text-muted-foreground`,title:r,children:r})]})]})}function X({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 rounded-lg border bg-background p-3`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsx)(`span`,{className:`truncate text-sm font-medium`,title:t,children:t})]})}function se(){return(0,B.jsxs)(`div`,{className:`app-workspace-content`,"aria-label":`正在读取健康状态`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(S,{className:`h-7 w-40`}),(0,B.jsx)(S,{className:`h-4 w-64`})]}),(0,B.jsx)(S,{className:`h-8 w-28`})]}),(0,B.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-6`,children:Array.from({length:6}).map((e,t)=>(0,B.jsx)(S,{className:`h-32 w-full`},t))}),(0,B.jsx)(S,{className:`h-80 w-full`})]})}function Z(){let[e,t]=(0,z.useState)(null),[n,a]=(0,z.useState)(!0),[o,S]=(0,z.useState)(!1),[C,V]=(0,z.useState)(``),[H,Z]=(0,z.useState)(!0),Q=(0,z.useCallback)(async(e=!1)=>{e?S(!0):a(!0),V(``);try{t(await U())}catch(e){V(e instanceof Error?e.message:`无法读取健康状态`)}finally{a(!1),S(!1)}},[]);(0,z.useEffect)(()=>{Q()},[Q]),(0,z.useEffect)(()=>{if(!H)return;let e=window.setInterval(()=>{Q(!0)},5e3);return()=>window.clearInterval(e)},[H,Q]);let $=(0,z.useMemo)(()=>ae(e?.logs),[e]);if(n&&!e)return(0,B.jsx)(se,{});if(!e)return(0,B.jsxs)(`div`,{className:`app-workspace-content`,children:[(0,B.jsxs)(O,{variant:`destructive`,children:[(0,B.jsx)(D,{children:`加载失败`}),(0,B.jsx)(E,{children:C||`无法读取健康状态`})]}),(0,B.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void Q(),children:[(0,B.jsx)(l,{"data-icon":`inline-start`}),`重新检测`]})]});let ce=[{icon:re,label:`CPU`,value:`${e.cpu.percent.toFixed(1)}%`,detail:`${e.cpu.cores} 核 · load ${e.cpu.loadAverage.map(e=>e.toFixed(2)).join(` / `)}`},{icon:I,label:`RSS 内存`,value:W(e.memory.rss),detail:`Heap ${W(e.memory.heapUsed)} / ${W(e.memory.heapTotal)}`},{icon:R,label:`TCP 连接`,value:String(e.connections.total),detail:`代理 ${e.connections.proxySockets} · TLS ${e.connections.mitmTlsSockets} · WS ${e.connections.webSockets}`},{icon:c,label:`MITM 服务`,value:String(e.mitmServers.count),detail:`${e.mitmServers.activeSockets} 个活跃 socket`},{icon:ne,label:`文件描述符`,value:e.process.fdCount==null?`-`:String(e.process.fdCount),detail:`handles ${e.process.activeHandles??`-`} · requests ${e.process.activeRequests??`-`}`},{icon:F,label:`事件循环`,value:`${e.eventLoop.maxMs.toFixed(1)} ms`,detail:`mean ${e.eventLoop.meanMs.toFixed(1)} ms`}];return(0,B.jsxs)(`div`,{className:`app-workspace-content overflow-y-auto`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`运行健康`}),(0,B.jsx)(Y,{status:e.status})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[`PID `,e.pid]}),(0,B.jsxs)(`span`,{children:[`运行 `,G(e.uptimeSec)]}),(0,B.jsx)(`span`,{children:e.platform}),(0,B.jsxs)(`span`,{children:[`更新 `,K(e.generatedAt)]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border bg-background px-3 text-sm`,children:[(0,B.jsx)(d,{checked:H,onCheckedChange:Z,"aria-label":`自动刷新健康信息`}),(0,B.jsx)(`span`,{children:`自动刷新`})]}),(0,B.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void Q(!0),disabled:o,children:[(0,B.jsx)(l,{"data-icon":`inline-start`,className:r(o&&`animate-spin`)}),`刷新`]})]})]}),C&&(0,B.jsxs)(O,{variant:`destructive`,children:[(0,B.jsx)(D,{children:`刷新失败`}),(0,B.jsx)(E,{children:C})]}),(0,B.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-6`,children:ce.map(e=>(0,B.jsx)(oe,{...e},e.label))}),(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1.3fr)_minmax(360px,0.7fr)]`,children:[(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(g,{className:`border-b py-4`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{}),`健康检查`]}),(0,B.jsx)(h,{children:`阈值来自当前进程的 MEDDLE_WATCHDOG 配置。`})]}),(0,B.jsx)(v,{className:`p-0`,children:(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`项目`}),(0,B.jsx)(A,{children:`状态`}),(0,B.jsx)(A,{children:`当前值`}),(0,B.jsx)(A,{children:`阈值`})]})}),(0,B.jsx)(j,{children:e.checks.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`font-medium`,children:ie[e.name]||e.name}),(0,B.jsx)(N,{children:(0,B.jsx)(Y,{status:e.status})}),(0,B.jsx)(N,{children:q(e.value,e.unit)}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:J(e.limit,e.unit)})]},e.name))})]})})]}),(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(g,{className:`border-b py-4`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ee,{}),`守护策略`]}),(0,B.jsx)(h,{children:`连续命中严重阈值后按策略处理。`}),(0,B.jsx)(te,{children:(0,B.jsx)(T,{variant:e.watchdog.config.enabled?`default`:`secondary`,children:e.watchdog.config.enabled?`已启用`:`已关闭`})})]}),(0,B.jsxs)(v,{className:`grid gap-3 p-4 sm:grid-cols-2`,children:[(0,B.jsx)(X,{label:`动作`,value:e.watchdog.config.action===`exit`?`退出重启`:`仅告警`}),(0,B.jsx)(X,{label:`检测间隔`,value:G(e.watchdog.config.intervalMs/1e3)}),(0,B.jsx)(X,{label:`最小运行时间`,value:G(e.watchdog.config.minUptimeMs/1e3)}),(0,B.jsx)(X,{label:`失败阈值`,value:`${e.watchdog.consecutiveFailures}/${e.watchdog.config.failureThreshold}`}),(0,B.jsx)(X,{label:`CPU 阈值`,value:`${e.watchdog.config.cpuPercent}%`}),(0,B.jsx)(X,{label:`RSS 阈值`,value:W(e.watchdog.config.rssBytes)}),(0,B.jsx)(X,{label:`连接阈值`,value:String(e.watchdog.config.connectionCount)}),(0,B.jsx)(X,{label:`FD 阈值`,value:String(e.watchdog.config.fdCount)}),e.watchdog.lastReason&&(0,B.jsx)(`div`,{className:`sm:col-span-2`,children:(0,B.jsxs)(O,{children:[(0,B.jsx)(x,{}),(0,B.jsx)(D,{children:`最近命中`}),(0,B.jsx)(E,{children:e.watchdog.lastReason})]})})]})]})]}),(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(g,{className:`border-b py-4`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{}),`MITM 服务池`]}),(0,B.jsxs)(h,{children:[e.mitmServers.count,` 个动态 HTTPS 服务。`]})]}),(0,B.jsx)(v,{className:`p-0`,children:e.mitmServers.items.length>0?(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`Host`}),(0,B.jsx)(A,{children:`端口`}),(0,B.jsx)(A,{children:`Socket`}),(0,B.jsx)(A,{children:`空闲`})]})}),(0,B.jsx)(j,{children:e.mitmServers.items.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`max-w-[260px] truncate font-medium`,title:e.host,children:e.host}),(0,B.jsx)(N,{children:e.port??`-`}),(0,B.jsxs)(N,{children:[e.activeSockets,` / `,e.webSockets,` WS`]}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:e.idleForMs==null?`-`:G(e.idleForMs/1e3)})]},`${e.host}:${e.port??`dynamic`}`))})]}):(0,B.jsx)(f,{className:`border-0 py-10`,children:(0,B.jsxs)(b,{children:[(0,B.jsx)(m,{variant:`icon`,children:(0,B.jsx)(c,{})}),(0,B.jsx)(p,{children:`暂无动态 HTTPS 服务`}),(0,B.jsx)(w,{children:`当前没有活跃的 MITM 目标。`})]})})})]}),(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(g,{className:`border-b py-4`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(s,{}),`日志限流`]}),(0,B.jsxs)(h,{children:[`已抑制 `,$?.suppressedTotal??0,` 条重复日志。`]})]}),(0,B.jsx)(v,{className:`p-0`,children:$&&$.keys.length>0?(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`Key`}),(0,B.jsx)(A,{children:`级别`}),(0,B.jsx)(A,{children:`输出 / 抑制`}),(0,B.jsx)(A,{children:`最近`})]})}),(0,B.jsx)(j,{children:$.keys.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`max-w-[260px] truncate font-medium`,title:e.key,children:e.key}),(0,B.jsx)(N,{children:(0,B.jsx)(T,{variant:e.level===`error`?`destructive`:e.level===`warn`?`secondary`:`outline`,children:e.level})}),(0,B.jsxs)(N,{children:[e.emitted,` / `,e.suppressed]}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:K(e.lastSeenAt)})]},e.key))})]}):(0,B.jsx)(f,{className:`border-0 py-10`,children:(0,B.jsxs)(b,{children:[(0,B.jsx)(m,{variant:`icon`,children:(0,B.jsx)(s,{})}),(0,B.jsx)(p,{children:`暂无限流记录`}),(0,B.jsx)(w,{children:`当前没有被抑制的重复日志。`})]})})})]})]})]})}export{Z as HealthPanel};
1
+ import{a as e,f as t,l as n,n as r,t as i,u as a}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as o}from"./circle-x-C9USji_R.js";import{n as s,t as c}from"./server-Cpj4KNwN.js";import{t as l}from"./refresh-cw-CG3HaiQT.js";import{t as ee}from"./shield-check-OqUmVLQt.js";import{t as u}from"./wifi-D9M35Ajj.js";import{t as d}from"./switch-C-Xk56TK.js";import{C as f,D as p,E as m,F as h,L as g,M as _,N as te,P as v,R as y,T as b,W as x,j as S,pt as C,q as ne,w,z as T}from"./index-DboWpNx1.js";import{n as E,r as D,t as O}from"./alert-COF-DIAE.js";import{a as k,i as A,n as j,o as M,r as N,t as P}from"./table-CT97lAYq.js";var re=n(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),F=n(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),I=n(`hard-drive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),L=n(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),R=n(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),z=t(a(),1),B=e(),V={ok:`正常`,degraded:`降级`,critical:`严重`},ie={cpu:`CPU`,rss:`RSS 内存`,connections:`连接数`,mitmServers:`MITM 服务`,eventLoopDelay:`事件循环延迟`,fds:`文件描述符`};function H(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.generatedAt==`number`&&typeof t.status==`string`&&typeof t.pid==`number`&&typeof t.uptimeSec==`number`&&!!t.memory&&!!t.cpu&&!!t.connections&&!!t.mitmServers&&Array.isArray(t.checks)}async function U(){let e=await fetch(`/api/health`,{cache:`no-store`});if(!e.ok)throw Error(`健康接口返回 ${e.status}`);let t=await e.json();if(!H(t))throw Error(`健康接口返回格式不正确`);return t}function W(e){if(!Number.isFinite(e))return`-`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=t[0];for(let e=1;e<t.length&&n>=1024;e+=1)n/=1024,r=t[e];return`${n>=10?n.toFixed(0):n.toFixed(1)} ${r}`}function G(e){if(!Number.isFinite(e)||e<0)return`-`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=Math.floor(e%60);return t>0?`${t}天 ${n}小时`:n>0?`${n}小时 ${r}分钟`:r>0?`${r}分钟 ${i}秒`:`${i}秒`}function K(e){return e?new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(new Date(e)):`-`}function q(e,t){return t===`bytes`?W(e):t===`%`?`${e.toFixed(1)}%`:t===`ms`?`${e.toFixed(1)} ms`:String(e)}function J(e,t){return t===`bytes`?W(e):t===`%`?`${e}%`:t===`ms`?`${e} ms`:String(e)}function ae(e){if(!e||typeof e!=`object`)return null;let t=e;return Array.isArray(t.keys)?{windowMs:Number(t.windowMs)||0,maxPerWindow:Number(t.maxPerWindow)||0,keys:t.keys,suppressedTotal:Number(t.suppressedTotal)||0}:null}function Y({status:e}){return(0,B.jsxs)(T,{variant:e===`critical`?`destructive`:e===`degraded`?`secondary`:`default`,children:[e===`ok`?(0,B.jsx)(C,{}):e===`degraded`?(0,B.jsx)(x,{}):(0,B.jsx)(o,{}),V[e]]})}function oe({icon:e,label:t,value:n,detail:r}){return(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsx)(g,{className:`border-b px-4 py-3`,children:(0,B.jsxs)(y,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(e,{}),t]})}),(0,B.jsxs)(v,{className:`flex flex-col gap-1 p-4`,children:[(0,B.jsx)(`div`,{className:`text-2xl font-semibold tracking-tight`,children:n}),(0,B.jsx)(`div`,{className:`min-h-4 truncate text-xs text-muted-foreground`,title:r,children:r})]})]})}function X({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 rounded-lg border bg-background p-3`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsx)(`span`,{className:`truncate text-sm font-medium`,title:t,children:t})]})}function se(){return(0,B.jsxs)(`div`,{className:`app-workspace-content`,"aria-label":`正在读取健康状态`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(S,{className:`h-7 w-40`}),(0,B.jsx)(S,{className:`h-4 w-64`})]}),(0,B.jsx)(S,{className:`h-8 w-28`})]}),(0,B.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-6`,children:Array.from({length:6}).map((e,t)=>(0,B.jsx)(S,{className:`h-32 w-full`},t))}),(0,B.jsx)(S,{className:`h-80 w-full`})]})}function Z(){let[e,t]=(0,z.useState)(null),[n,a]=(0,z.useState)(!0),[o,S]=(0,z.useState)(!1),[C,V]=(0,z.useState)(``),[H,Z]=(0,z.useState)(!0),Q=(0,z.useCallback)(async(e=!1)=>{e?S(!0):a(!0),V(``);try{t(await U())}catch(e){V(e instanceof Error?e.message:`无法读取健康状态`)}finally{a(!1),S(!1)}},[]);(0,z.useEffect)(()=>{Q()},[Q]),(0,z.useEffect)(()=>{if(!H)return;let e=window.setInterval(()=>{Q(!0)},5e3);return()=>window.clearInterval(e)},[H,Q]);let $=(0,z.useMemo)(()=>ae(e?.logs),[e]);if(n&&!e)return(0,B.jsx)(se,{});if(!e)return(0,B.jsxs)(`div`,{className:`app-workspace-content`,children:[(0,B.jsxs)(O,{variant:`destructive`,children:[(0,B.jsx)(D,{children:`加载失败`}),(0,B.jsx)(E,{children:C||`无法读取健康状态`})]}),(0,B.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void Q(),children:[(0,B.jsx)(l,{"data-icon":`inline-start`}),`重新检测`]})]});let ce=[{icon:re,label:`CPU`,value:`${e.cpu.percent.toFixed(1)}%`,detail:`${e.cpu.cores} 核 · load ${e.cpu.loadAverage.map(e=>e.toFixed(2)).join(` / `)}`},{icon:I,label:`RSS 内存`,value:W(e.memory.rss),detail:`Heap ${W(e.memory.heapUsed)} / ${W(e.memory.heapTotal)}`},{icon:R,label:`TCP 连接`,value:String(e.connections.total),detail:`代理 ${e.connections.proxySockets} · TLS ${e.connections.mitmTlsSockets} · WS ${e.connections.webSockets}`},{icon:c,label:`MITM 服务`,value:String(e.mitmServers.count),detail:`${e.mitmServers.activeSockets} 个活跃 socket`},{icon:ne,label:`文件描述符`,value:e.process.fdCount==null?`-`:String(e.process.fdCount),detail:`handles ${e.process.activeHandles??`-`} · requests ${e.process.activeRequests??`-`}`},{icon:F,label:`事件循环`,value:`${e.eventLoop.maxMs.toFixed(1)} ms`,detail:`mean ${e.eventLoop.meanMs.toFixed(1)} ms`}];return(0,B.jsxs)(`div`,{className:`app-workspace-content overflow-y-auto`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`运行健康`}),(0,B.jsx)(Y,{status:e.status})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[`PID `,e.pid]}),(0,B.jsxs)(`span`,{children:[`运行 `,G(e.uptimeSec)]}),(0,B.jsx)(`span`,{children:e.platform}),(0,B.jsxs)(`span`,{children:[`更新 `,K(e.generatedAt)]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border bg-background px-3 text-sm`,children:[(0,B.jsx)(d,{checked:H,onCheckedChange:Z,"aria-label":`自动刷新健康信息`}),(0,B.jsx)(`span`,{children:`自动刷新`})]}),(0,B.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void Q(!0),disabled:o,children:[(0,B.jsx)(l,{"data-icon":`inline-start`,className:r(o&&`animate-spin`)}),`刷新`]})]})]}),C&&(0,B.jsxs)(O,{variant:`destructive`,children:[(0,B.jsx)(D,{children:`刷新失败`}),(0,B.jsx)(E,{children:C})]}),(0,B.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-6`,children:ce.map(e=>(0,B.jsx)(oe,{...e},e.label))}),(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1.3fr)_minmax(360px,0.7fr)]`,children:[(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(g,{className:`border-b py-4`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{}),`健康检查`]}),(0,B.jsx)(h,{children:`阈值来自当前进程的 MEDDLE_WATCHDOG 配置。`})]}),(0,B.jsx)(v,{className:`p-0`,children:(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`项目`}),(0,B.jsx)(A,{children:`状态`}),(0,B.jsx)(A,{children:`当前值`}),(0,B.jsx)(A,{children:`阈值`})]})}),(0,B.jsx)(j,{children:e.checks.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`font-medium`,children:ie[e.name]||e.name}),(0,B.jsx)(N,{children:(0,B.jsx)(Y,{status:e.status})}),(0,B.jsx)(N,{children:q(e.value,e.unit)}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:J(e.limit,e.unit)})]},e.name))})]})})]}),(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(g,{className:`border-b py-4`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ee,{}),`守护策略`]}),(0,B.jsx)(h,{children:`连续命中严重阈值后按策略处理。`}),(0,B.jsx)(te,{children:(0,B.jsx)(T,{variant:e.watchdog.config.enabled?`default`:`secondary`,children:e.watchdog.config.enabled?`已启用`:`已关闭`})})]}),(0,B.jsxs)(v,{className:`grid gap-3 p-4 sm:grid-cols-2`,children:[(0,B.jsx)(X,{label:`动作`,value:e.watchdog.config.action===`exit`?`退出重启`:`仅告警`}),(0,B.jsx)(X,{label:`检测间隔`,value:G(e.watchdog.config.intervalMs/1e3)}),(0,B.jsx)(X,{label:`最小运行时间`,value:G(e.watchdog.config.minUptimeMs/1e3)}),(0,B.jsx)(X,{label:`失败阈值`,value:`${e.watchdog.consecutiveFailures}/${e.watchdog.config.failureThreshold}`}),(0,B.jsx)(X,{label:`CPU 阈值`,value:`${e.watchdog.config.cpuPercent}%`}),(0,B.jsx)(X,{label:`RSS 阈值`,value:W(e.watchdog.config.rssBytes)}),(0,B.jsx)(X,{label:`连接阈值`,value:String(e.watchdog.config.connectionCount)}),(0,B.jsx)(X,{label:`FD 阈值`,value:String(e.watchdog.config.fdCount)}),e.watchdog.lastReason&&(0,B.jsx)(`div`,{className:`sm:col-span-2`,children:(0,B.jsxs)(O,{children:[(0,B.jsx)(x,{}),(0,B.jsx)(D,{children:`最近命中`}),(0,B.jsx)(E,{children:e.watchdog.lastReason})]})})]})]})]}),(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(g,{className:`border-b py-4`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{}),`MITM 服务池`]}),(0,B.jsxs)(h,{children:[e.mitmServers.count,` 个动态 HTTPS 服务。`]})]}),(0,B.jsx)(v,{className:`p-0`,children:e.mitmServers.items.length>0?(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`Host`}),(0,B.jsx)(A,{children:`端口`}),(0,B.jsx)(A,{children:`Socket`}),(0,B.jsx)(A,{children:`空闲`})]})}),(0,B.jsx)(j,{children:e.mitmServers.items.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`max-w-[260px] truncate font-medium`,title:e.host,children:e.host}),(0,B.jsx)(N,{children:e.port??`-`}),(0,B.jsxs)(N,{children:[e.activeSockets,` / `,e.webSockets,` WS`]}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:e.idleForMs==null?`-`:G(e.idleForMs/1e3)})]},`${e.host}:${e.port??`dynamic`}`))})]}):(0,B.jsx)(f,{className:`border-0 py-10`,children:(0,B.jsxs)(b,{children:[(0,B.jsx)(m,{variant:`icon`,children:(0,B.jsx)(c,{})}),(0,B.jsx)(p,{children:`暂无动态 HTTPS 服务`}),(0,B.jsx)(w,{children:`当前没有活跃的 MITM 目标。`})]})})})]}),(0,B.jsxs)(_,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(g,{className:`border-b py-4`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(s,{}),`日志限流`]}),(0,B.jsxs)(h,{children:[`已抑制 `,$?.suppressedTotal??0,` 条重复日志。`]})]}),(0,B.jsx)(v,{className:`p-0`,children:$&&$.keys.length>0?(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`Key`}),(0,B.jsx)(A,{children:`级别`}),(0,B.jsx)(A,{children:`输出 / 抑制`}),(0,B.jsx)(A,{children:`最近`})]})}),(0,B.jsx)(j,{children:$.keys.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`max-w-[260px] truncate font-medium`,title:e.key,children:e.key}),(0,B.jsx)(N,{children:(0,B.jsx)(T,{variant:e.level===`error`?`destructive`:e.level===`warn`?`secondary`:`outline`,children:e.level})}),(0,B.jsxs)(N,{children:[e.emitted,` / `,e.suppressed]}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:K(e.lastSeenAt)})]},e.key))})]}):(0,B.jsx)(f,{className:`border-0 py-10`,children:(0,B.jsxs)(b,{children:[(0,B.jsx)(m,{variant:`icon`,children:(0,B.jsx)(s,{})}),(0,B.jsx)(p,{children:`暂无限流记录`}),(0,B.jsx)(w,{children:`当前没有被抑制的重复日志。`})]})})})]})]})]})}export{Z as HealthPanel};