@loop_ouroboros/mcp-hub-lite 1.2.8 → 1.2.9

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 (73) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/client/assets/{HomeView-CgEri1kD.js → HomeView-CGezWc0j.js} +1 -1
  3. package/dist/client/assets/{ResourceDetailView-B8Qo1_jK.js → ResourceDetailView-Bi5UsbFq.js} +1 -1
  4. package/dist/client/assets/{ResourceDetailView-DUJZbegl.css → ResourceDetailView-CDmWGdAK.css} +1 -1
  5. package/dist/client/assets/{ResourcesView-B12FzUdo.js → ResourcesView-B9anSm85.js} +1 -1
  6. package/dist/client/assets/{ServerDashboard-B3O-crvv.js → ServerDashboard-g5p4VC_-.js} +1 -1
  7. package/dist/client/assets/{ServerDetail-CXg8rI3q.css → ServerDetail-DCQH8HIb.css} +1 -1
  8. package/dist/client/assets/ServerDetail-DMoFqWCp.js +2 -0
  9. package/dist/client/assets/{ServerListView-SlZN8ppC.js → ServerListView-DZsy2gaQ.js} +1 -1
  10. package/dist/client/assets/{SettingsView-D8fiOG0O.js → SettingsView-DQSWb9xM.js} +1 -1
  11. package/dist/client/assets/{ToolCallDialog-DYEdhnCk.js → ToolCallDialog-BEyRp_J3.js} +1 -1
  12. package/dist/client/assets/ToolsView-BU7PKJwt.js +1 -0
  13. package/dist/client/assets/ToolsView-BkrQLjH9.css +1 -0
  14. package/dist/client/assets/{_baseClone-BYxCbA_9.js → _baseClone-DsVtZfPm.js} +1 -1
  15. package/dist/client/assets/{el-form-item-ySymCPMr.js → el-form-item-CTsVV8sm.js} +1 -1
  16. package/dist/client/assets/{el-input-C85p6Nqj.js → el-input-Bh1VGJTU.js} +1 -1
  17. package/dist/client/assets/{el-loading-DIjKEx81.js → el-loading-huOeK9cW.js} +1 -1
  18. package/dist/client/assets/{el-overlay-B_CxiSem.js → el-overlay-CR_KVhLU.js} +1 -1
  19. package/dist/client/assets/{el-radio-group-BjkTCPRf.js → el-radio-group-BSbtAW4k.js} +1 -1
  20. package/dist/client/assets/{el-skeleton-item-CupTKK6n.js → el-skeleton-item-BSxOLPFM.js} +1 -1
  21. package/dist/client/assets/{el-switch-BosIJ9jf.js → el-switch-BaQUQWTL.js} +1 -1
  22. package/dist/client/assets/{el-tab-pane-BydxdJoc.js → el-tab-pane-9JxLgdS7.js} +1 -1
  23. package/dist/client/assets/{el-table-column-DV5TZOUW.js → el-table-column-Du1l9Ww3.js} +1 -1
  24. package/dist/client/assets/{index-xJkq2euk.css → index-BNmwPGMT.css} +1 -1
  25. package/dist/client/assets/index-CsZoFRv1.js +2 -0
  26. package/dist/client/assets/{omit-DxDGRttI.js → omit-Btci9mp3.js} +1 -1
  27. package/dist/client/assets/{raf-Y9AoxecD.js → raf-tUu4BwZS.js} +1 -1
  28. package/dist/client/index.html +2 -2
  29. package/dist/server/src/api/web/search.d.ts +15 -0
  30. package/dist/server/src/api/web/search.d.ts.map +1 -1
  31. package/dist/server/src/api/web/search.js +22 -1
  32. package/dist/server/src/models/event.model.d.ts +0 -98
  33. package/dist/server/src/models/event.model.d.ts.map +1 -1
  34. package/dist/server/src/models/event.model.js +0 -4
  35. package/dist/server/src/models/server.model.d.ts +0 -2
  36. package/dist/server/src/models/server.model.d.ts.map +1 -1
  37. package/dist/server/src/models/system-tools.constants.d.ts +6 -2
  38. package/dist/server/src/models/system-tools.constants.d.ts.map +1 -1
  39. package/dist/server/src/models/system-tools.constants.js +3 -1
  40. package/dist/server/src/pid/types.d.ts +0 -5
  41. package/dist/server/src/pid/types.d.ts.map +1 -1
  42. package/dist/server/src/services/gateway/request-handlers/system-tools-handler.d.ts.map +1 -1
  43. package/dist/server/src/services/gateway/request-handlers/system-tools-handler.js +28 -1
  44. package/dist/server/src/services/hub-manager.service.d.ts.map +1 -1
  45. package/dist/server/src/services/hub-manager.service.js +6 -2
  46. package/dist/server/src/services/hub-tools/system-tool-definitions.d.ts +1 -0
  47. package/dist/server/src/services/hub-tools/system-tool-definitions.d.ts.map +1 -1
  48. package/dist/server/src/services/hub-tools/system-tool-definitions.js +25 -1
  49. package/dist/server/src/services/hub-tools.service.d.ts +21 -4
  50. package/dist/server/src/services/hub-tools.service.d.ts.map +1 -1
  51. package/dist/server/src/services/hub-tools.service.js +59 -1
  52. package/dist/server/src/services/system-tool-handler.d.ts.map +1 -1
  53. package/dist/server/src/services/system-tool-handler.js +9 -1
  54. package/dist/server/src/utils/instance-id.d.ts +0 -8
  55. package/dist/server/src/utils/instance-id.d.ts.map +1 -1
  56. package/dist/server/src/utils/instance-id.js +1 -1
  57. package/dist/server/src/utils/logger/index.d.ts +0 -22
  58. package/dist/server/src/utils/logger/index.d.ts.map +1 -1
  59. package/dist/server/src/utils/logger/index.js +0 -29
  60. package/dist/server/src/utils/sort-utils.d.ts +0 -16
  61. package/dist/server/src/utils/sort-utils.d.ts.map +1 -1
  62. package/dist/server/src/utils/sort-utils.js +0 -42
  63. package/dist/server/tests/unit/api/search.test.d.ts +2 -0
  64. package/dist/server/tests/unit/api/search.test.d.ts.map +1 -0
  65. package/dist/server/tests/unit/api/search.test.js +61 -0
  66. package/dist/server/tests/unit/services/hub-tools.service.test.js +2 -1
  67. package/dist/server/tests/unit/utils/logger.test.js +1 -23
  68. package/dist/server/tests/unit/utils/sort-utils.test.js +1 -92
  69. package/package.json +1 -1
  70. package/dist/client/assets/ServerDetail-Bz5_9yOY.js +0 -2
  71. package/dist/client/assets/ToolsView-BreAl-yn.js +0 -1
  72. package/dist/client/assets/ToolsView-BxgXvPC3.css +0 -1
  73. package/dist/client/assets/index-kC4mf0Vo.js +0 -2
@@ -9,7 +9,7 @@ import { createHash } from 'node:crypto';
9
9
  * @param obj - The object to hash
10
10
  * @returns An 8-character hex string
11
11
  */
12
- export function generateInstanceHash(obj) {
12
+ function generateInstanceHash(obj) {
13
13
  function stableStringify(value) {
14
14
  if (value === null || typeof value !== 'object') {
15
15
  return JSON.stringify(value);
@@ -10,27 +10,5 @@ export { formatTimestamp, formatLogLevel, formatPid, createColoredLogMessage, cr
10
10
  export { isToolsListResponse, simplifyToolsListResponse, hasImageContent, simplifyImageContent, formatMcpMessageForLogging, isNotificationMessage, logNotificationMessage } from './log-output.js';
11
11
  export { Logger } from './logger.js';
12
12
  import { Logger } from './logger.js';
13
- import type { LogContext } from './log-context.js';
14
13
  export declare const logger: Logger;
15
- /**
16
- * Log a message with color formatting for console and plain text for file output.
17
- *
18
- * This function provides a convenient way to log messages that appear with
19
- * ANSI color codes in the console but are written as plain text to log files.
20
- * It uses the logger's internal formatting methods to ensure consistent output.
21
- *
22
- * @param coloredMessage - The message to display in the console with color formatting
23
- * @param plainMessage - The message to write to log files in plain text format
24
- * @param context - Optional logging context including PID, server name, trace ID, etc.
25
- *
26
- * @example
27
- * ```typescript
28
- * logWithColor(
29
- * '\x1b[32m[SUCCESS]\x1b[0m Server started',
30
- * '[SUCCESS] Server started',
31
- * { serverName: 'mcp-hub', pid: process.pid }
32
- * );
33
- * ```
34
- */
35
- export declare function logWithColor(coloredMessage: string, plainMessage: string, context?: LogContext): void;
36
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/logger/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGhE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EACL,eAAe,EACf,cAAc,EACd,SAAS,EACT,uBAAuB,EACvB,gBAAgB,EAChB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,eAAO,MAAM,MAAM,QAAe,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,UAAU,GACnB,IAAI,CAQN"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/logger/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGhE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EACL,eAAe,EACf,cAAc,EACd,SAAS,EACT,uBAAuB,EACvB,gBAAgB,EAChB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,eAAO,MAAM,MAAM,QAAe,CAAC"}
@@ -14,33 +14,4 @@ export { isToolsListResponse, simplifyToolsListResponse, hasImageContent, simpli
14
14
  export { Logger } from './logger.js';
15
15
  // Create and export the default logger instance
16
16
  import { Logger } from './logger.js';
17
- import { createColoredLogMessage, createLogMessage } from './log-formatter.js';
18
17
  export const logger = new Logger();
19
- /**
20
- * Log a message with color formatting for console and plain text for file output.
21
- *
22
- * This function provides a convenient way to log messages that appear with
23
- * ANSI color codes in the console but are written as plain text to log files.
24
- * It uses the logger's internal formatting methods to ensure consistent output.
25
- *
26
- * @param coloredMessage - The message to display in the console with color formatting
27
- * @param plainMessage - The message to write to log files in plain text format
28
- * @param context - Optional logging context including PID, server name, trace ID, etc.
29
- *
30
- * @example
31
- * ```typescript
32
- * logWithColor(
33
- * '\x1b[32m[SUCCESS]\x1b[0m Server started',
34
- * '[SUCCESS] Server started',
35
- * { serverName: 'mcp-hub', pid: process.pid }
36
- * );
37
- * ```
38
- */
39
- export function logWithColor(coloredMessage, plainMessage, context) {
40
- const coloredLogMsg = createColoredLogMessage('info', coloredMessage, context);
41
- console.info(coloredLogMsg);
42
- if (logger.logFileStream) {
43
- const plainLogMsg = createLogMessage('info', plainMessage, context);
44
- logger.logFileStream.write(plainLogMsg + '\n');
45
- }
46
- }
@@ -1,14 +1,6 @@
1
1
  /**
2
2
  * Object key sorting utilities for consistent configuration.
3
3
  */
4
- /**
5
- * Sorts object keys alphabetically using localeCompare.
6
- * Returns a new object with sorted keys, preserving the original object.
7
- *
8
- * @param obj - Object to sort
9
- * @returns New object with sorted keys
10
- */
11
- export declare function sortObjectKeys<T extends Record<string, unknown>>(obj: T): T;
12
4
  /**
13
5
  * Sorts object keys alphabetically, case-insensitive.
14
6
  * Returns a new object with sorted keys, preserving the original object and original key case.
@@ -17,14 +9,6 @@ export declare function sortObjectKeys<T extends Record<string, unknown>>(obj: T
17
9
  * @returns New object with sorted keys (case-insensitive sort)
18
10
  */
19
11
  export declare function sortObjectKeysCaseInsensitive<T extends Record<string, unknown>>(obj: T): T;
20
- /**
21
- * Recursively sorts all object keys in a nested structure.
22
- * Returns a new object with all nested keys sorted, preserving the original object.
23
- *
24
- * @param obj - Object to sort recursively
25
- * @returns New object with all nested keys sorted
26
- */
27
- export declare function sortObjectKeysDeep<T>(obj: T): T;
28
12
  /**
29
13
  * Sorts env and headers objects in a server configuration.
30
14
  * This is a convenience function for server template/instance configurations.
@@ -1 +1 @@
1
- {"version":3,"file":"sort-utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/sort-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoDH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAW3E;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAa1F;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAmB/C;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,CAAC,SAAS;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAC5E,MAAM,EAAE,CAAC,GAAG,CAAC,CAcd"}
1
+ {"version":3,"file":"sort-utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/sort-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoDH;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAa1F;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,CAAC,SAAS;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAC5E,MAAM,EAAE,CAAC,GAAG,CAAC,CAcd"}
@@ -49,24 +49,6 @@ function normalizeConfigUrls(obj) {
49
49
  }
50
50
  return obj;
51
51
  }
52
- /**
53
- * Sorts object keys alphabetically using localeCompare.
54
- * Returns a new object with sorted keys, preserving the original object.
55
- *
56
- * @param obj - Object to sort
57
- * @returns New object with sorted keys
58
- */
59
- export function sortObjectKeys(obj) {
60
- if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
61
- return obj;
62
- }
63
- const sortedObj = {};
64
- const keys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
65
- for (const key of keys) {
66
- sortedObj[key] = obj[key];
67
- }
68
- return sortedObj;
69
- }
70
52
  /**
71
53
  * Sorts object keys alphabetically, case-insensitive.
72
54
  * Returns a new object with sorted keys, preserving the original object and original key case.
@@ -85,30 +67,6 @@ export function sortObjectKeysCaseInsensitive(obj) {
85
67
  }
86
68
  return sortedObj;
87
69
  }
88
- /**
89
- * Recursively sorts all object keys in a nested structure.
90
- * Returns a new object with all nested keys sorted, preserving the original object.
91
- *
92
- * @param obj - Object to sort recursively
93
- * @returns New object with all nested keys sorted
94
- */
95
- export function sortObjectKeysDeep(obj) {
96
- if (!obj) {
97
- return obj;
98
- }
99
- if (Array.isArray(obj)) {
100
- return obj.map((item) => sortObjectKeysDeep(item));
101
- }
102
- if (typeof obj === 'object') {
103
- const sortedObj = {};
104
- const keys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
105
- for (const key of keys) {
106
- sortedObj[key] = sortObjectKeysDeep(obj[key]);
107
- }
108
- return sortedObj;
109
- }
110
- return obj;
111
- }
112
70
  /**
113
71
  * Sorts env and headers objects in a server configuration.
114
72
  * This is a convenience function for server template/instance configurations.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=search.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.test.d.ts","sourceRoot":"","sources":["../../../../../tests/unit/api/search.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { filterByAggregatedTools } from '../../../src/api/web/search.js';
3
+ function mockConfig(aggregatedTools = []) {
4
+ return {
5
+ template: {
6
+ type: 'stdio',
7
+ command: 'test',
8
+ args: [],
9
+ env: {},
10
+ headers: {},
11
+ aggregatedTools,
12
+ timeout: 30000
13
+ },
14
+ instances: [],
15
+ tagDefinitions: []
16
+ };
17
+ }
18
+ function mockTool(name, serverName = 'test-server') {
19
+ return { name, description: `Tool ${name}`, serverName };
20
+ }
21
+ describe('filterByAggregatedTools', () => {
22
+ it('should skip tools when aggregatedTools is empty', () => {
23
+ const tools = [mockTool('tool1'), mockTool('tool2')];
24
+ const getConfig = () => mockConfig([]);
25
+ const result = filterByAggregatedTools(tools, getConfig);
26
+ expect(result).toHaveLength(0);
27
+ });
28
+ it('should only include tools in aggregatedTools list', () => {
29
+ const tools = [mockTool('tool1'), mockTool('tool2'), mockTool('tool3')];
30
+ const getConfig = () => mockConfig(['tool1', 'tool3']);
31
+ const result = filterByAggregatedTools(tools, getConfig);
32
+ expect(result).toHaveLength(2);
33
+ expect(result.map((t) => t.name)).toEqual(['tool1', 'tool3']);
34
+ });
35
+ it('should skip tools when server config not found', () => {
36
+ const tools = [mockTool('tool1')];
37
+ const getConfig = () => undefined;
38
+ const result = filterByAggregatedTools(tools, getConfig);
39
+ expect(result).toHaveLength(0);
40
+ });
41
+ it('should filter tools from multiple servers independently', () => {
42
+ const tools = [
43
+ mockTool('a', 'server-a'),
44
+ mockTool('b', 'server-a'),
45
+ mockTool('x', 'server-b'),
46
+ mockTool('y', 'server-b')
47
+ ];
48
+ const configs = {
49
+ 'server-a': mockConfig(['a']),
50
+ 'server-b': mockConfig([])
51
+ };
52
+ const getConfig = (name) => configs[name];
53
+ const result = filterByAggregatedTools(tools, getConfig);
54
+ expect(result).toHaveLength(1);
55
+ expect(result[0].name).toBe('a');
56
+ });
57
+ it('should return empty array when no tools provided', () => {
58
+ const result = filterByAggregatedTools([], () => mockConfig(['tool1']));
59
+ expect(result).toHaveLength(0);
60
+ });
61
+ });
@@ -615,7 +615,8 @@ describe('HubToolsService', () => {
615
615
  expect(systemToolNames).toContain('call_tool');
616
616
  expect(systemToolNames).toContain('update_server_description');
617
617
  expect(systemToolNames).toContain('list_tags');
618
- expect(systemToolNames).toHaveLength(6);
618
+ expect(systemToolNames).toContain('search_tools');
619
+ expect(systemToolNames).toHaveLength(7);
619
620
  // Assert server tools - should have only name and description
620
621
  expect(allTools['Server 1'].tools).toEqual(expectedToolSummariesServer1);
621
622
  expect(allTools['Server 2'].tools).toEqual(expectedToolSummariesServer2);
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import os from 'node:os';
5
- import { Logger, logWithColor } from '../../../src/utils/logger.js';
5
+ import { Logger } from '../../../src/utils/logger.js';
6
6
  import { setJsonPrettyConfigGetter, setDevModeEnabled } from '../../../src/utils/json-utils.js';
7
7
  import { createColoredLogMessage, createLogMessage, getCallerInfo, formatCallerInfo } from '../../../src/utils/logger/log-formatter.js';
8
8
  describe('Logger', () => {
@@ -363,28 +363,6 @@ describe('Logger', () => {
363
363
  expect(writeSpy).toHaveBeenCalledWith(expect.stringContaining('file line 3'));
364
364
  vi.restoreAllMocks();
365
365
  });
366
- it('should handle logWithColor function with traceId and spanId', () => {
367
- // Reset logger instance to avoid interference between tests
368
- const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => { });
369
- logWithColor('colored message', 'plain message', {
370
- pid: 123,
371
- serverName: 'test-server',
372
- traceId: '1234567890abcdef1234567890abcdef',
373
- spanId: 'abcdef1234567890'
374
- });
375
- expect(consoleInfoSpy).toHaveBeenCalledWith(expect.stringContaining('[TID:1234567890abcdef1234567890abcdef]'));
376
- expect(consoleInfoSpy).toHaveBeenCalledWith(expect.stringContaining('[SID:abcdef1234567890]'));
377
- // Restore console methods
378
- consoleInfoSpy.mockRestore();
379
- });
380
- it('should handle logWithColor function without context', () => {
381
- // Reset logger instance to avoid interference between tests
382
- const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => { });
383
- logWithColor('colored message', 'plain message');
384
- expect(consoleInfoSpy).toHaveBeenCalled();
385
- // Restore console methods
386
- consoleInfoSpy.mockRestore();
387
- });
388
366
  describe('dev log rotation', () => {
389
367
  it('should create devLogRotator when enableDevLog is called', () => {
390
368
  // Mock fs modules to avoid file system operations
@@ -1,50 +1,6 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { sortObjectKeys, sortObjectKeysCaseInsensitive, sortObjectKeysDeep, sortServerConfigEnvHeaders } from '../../../src/utils/sort-utils.js';
2
+ import { sortObjectKeysCaseInsensitive, sortServerConfigEnvHeaders } from '../../../src/utils/sort-utils.js';
3
3
  describe('sort-utils', () => {
4
- describe('sortObjectKeys', () => {
5
- it('should sort object keys alphabetically using localeCompare', () => {
6
- const obj = {
7
- zebra: 'value3',
8
- apple: 'value1',
9
- banana: 'value2'
10
- };
11
- const result = sortObjectKeys(obj);
12
- expect(Object.keys(result)).toEqual(['apple', 'banana', 'zebra']);
13
- expect(result).toEqual({
14
- apple: 'value1',
15
- banana: 'value2',
16
- zebra: 'value3'
17
- });
18
- });
19
- it('should return the same object if input is null or undefined', () => {
20
- expect(sortObjectKeys(null)).toBe(null);
21
- expect(sortObjectKeys(undefined)).toBe(undefined);
22
- });
23
- it('should return the same object if input is an array', () => {
24
- const arr = [3, 1, 2];
25
- expect(sortObjectKeys(arr)).toBe(arr);
26
- });
27
- it('should return the same object if input is not an object', () => {
28
- expect(sortObjectKeys('string')).toBe('string');
29
- expect(sortObjectKeys(42)).toBe(42);
30
- expect(sortObjectKeys(true)).toBe(true);
31
- });
32
- it('should preserve the original object (return a new object)', () => {
33
- const obj = {
34
- zebra: 'value3',
35
- apple: 'value1'
36
- };
37
- const result = sortObjectKeys(obj);
38
- expect(result).not.toBe(obj);
39
- expect(obj).toEqual({
40
- zebra: 'value3',
41
- apple: 'value1'
42
- });
43
- });
44
- it('should handle empty object', () => {
45
- expect(sortObjectKeys({})).toEqual({});
46
- });
47
- });
48
4
  describe('sortObjectKeysCaseInsensitive', () => {
49
5
  it('should sort object keys alphabetically, case-insensitive', () => {
50
6
  const obj = {
@@ -77,53 +33,6 @@ describe('sort-utils', () => {
77
33
  expect(sortObjectKeysCaseInsensitive(undefined)).toBe(undefined);
78
34
  });
79
35
  });
80
- describe('sortObjectKeysDeep', () => {
81
- it('should recursively sort all object keys in a nested structure', () => {
82
- const obj = {
83
- zebra: {
84
- delta: 'value4',
85
- alpha: 'value1'
86
- },
87
- apple: {
88
- charlie: 'value3',
89
- bravo: 'value2'
90
- }
91
- };
92
- const result = sortObjectKeysDeep(obj);
93
- expect(Object.keys(result)).toEqual(['apple', 'zebra']);
94
- expect(Object.keys(result.apple)).toEqual(['bravo', 'charlie']);
95
- expect(Object.keys(result.zebra)).toEqual(['alpha', 'delta']);
96
- });
97
- it('should handle arrays and recursively sort objects within arrays', () => {
98
- const obj = {
99
- items: [
100
- { zebra: 'value3', apple: 'value1' },
101
- { delta: 'value4', alpha: 'value1' }
102
- ]
103
- };
104
- const result = sortObjectKeysDeep(obj);
105
- expect(Array.isArray(result.items)).toBe(true);
106
- expect(Object.keys(result.items[0])).toEqual(['apple', 'zebra']);
107
- expect(Object.keys(result.items[1])).toEqual(['alpha', 'delta']);
108
- });
109
- it('should handle mixed types in nested structure', () => {
110
- const obj = {
111
- number: 42,
112
- string: 'hello',
113
- boolean: true,
114
- array: [1, 2, 3],
115
- object: {
116
- nested: {
117
- z: 'last',
118
- a: 'first'
119
- }
120
- }
121
- };
122
- const result = sortObjectKeysDeep(obj);
123
- expect(Object.keys(result)).toEqual(['array', 'boolean', 'number', 'object', 'string']);
124
- expect(Object.keys(result.object.nested)).toEqual(['a', 'z']);
125
- });
126
- });
127
36
  describe('sortServerConfigEnvHeaders', () => {
128
37
  it('should sort env and headers objects in a server configuration', () => {
129
38
  const config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loop_ouroboros/mcp-hub-lite",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "A lightweight MCP management platform designed for independent developers",
5
5
  "license": "MIT",
6
6
  "author": "loop_ouroboros",
@@ -1,2 +0,0 @@
1
- import{q as Qe,x as ft,y as vt,_ as pt,T as gt,b as Se,z as yt,j as de,A as ht,B as Xe,C as Ze,D as Ye,F as bt,G as Ke,H as _t,I as $t,v as st,r as Me,n as Ct,k as ie,p as fe,J as wt,K as kt,E as I,L as xt,M as St,N as Vt,O as It,P as Tt,Q as Dt,u as Pe,a as Et,R as Bt,s as et,S as Ut,t as Rt,o as At}from"./index-kC4mf0Vo.js";import{E as zt,a as Nt}from"./el-tab-pane-BydxdJoc.js";import{n as he,a2 as Ce,x as i,y as H,G as f,H as Ae,O as s,C as n,J as Q,I as ke,K as tt,A as b,U as we,V as M,$ as o,aj as be,v as jt,L as ze,a0 as E,M as Ot,t as ue,c as q,r as O,Q as Mt,ak as Ne,h as ee,j as Pt,F as Ft,al as Lt,p as je,a as Fe,a7 as ot,a8 as rt,l as at,d as it,aa as me,u as y,P as Z,ai as K,Z as Ht,ac as Jt,ab as Le,am as qt,k as Be}from"./vue-vendor-Dwcr0jep.js";import{E as Ve,a as He}from"./el-input-C85p6Nqj.js";import{_ as Wt,a as ut}from"./ServerStatusTags.vue_vue_type_script_setup_true_lang-DmGg4uuV.js";import{c as Gt,u as Qt,d as Xt,e as Zt,a as Je,b as qe,E as We}from"./el-overlay-B_CxiSem.js";import{i as Yt,E as ct,a as dt}from"./el-switch-BosIJ9jf.js";import{E as Kt,a as ea}from"./el-radio-group-BjkTCPRf.js";import{_ as Ie}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{E as ta,a as aa,b as la}from"./el-table-column-DV5TZOUW.js";import{T as na}from"./ToolCallDialog-DYEdhnCk.js";import"./raf-Y9AoxecD.js";import"./event-BB_Ol6Sd.js";import"./omit-DxDGRttI.js";import"./_baseClone-BYxCbA_9.js";const Oe="_trap-focus-children",ge=[],lt=e=>{if(ge.length===0)return;const m=ft(e),a=ge[ge.length-1][Oe];if(a.length>0&&m===vt.tab){if(a.length===1){e.preventDefault(),document.activeElement!==a[0]&&a[0].focus();return}const d=e.shiftKey,t=e.target===a[0],g=e.target===a[a.length-1];t&&d&&(e.preventDefault(),a[a.length-1].focus()),g&&!d&&(e.preventDefault(),a[0].focus())}},sa={beforeMount(e){e[Oe]=Qe(e),ge.push(e),ge.length<=1&&document.addEventListener("keydown",lt)},updated(e){he(()=>{e[Oe]=Qe(e)})},unmounted(){ge.shift(),ge.length===0&&document.removeEventListener("keydown",lt)}},oa=ue({name:"ElMessageBox",directives:{TrapFocus:sa},components:{ElButton:de,ElFocusTrap:yt,ElInput:Ve,ElOverlay:Gt,ElIcon:Se,...gt},inheritAttrs:!1,props:{buttonSize:{type:String,validator:Yt},modal:{type:Boolean,default:!0},lockScroll:{type:Boolean,default:!0},showClose:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},closeOnHashChange:{type:Boolean,default:!0},center:Boolean,draggable:Boolean,overflow:Boolean,roundButton:Boolean,container:{type:String,default:"body"},boxType:{type:String,default:""}},emits:["vanish","action"],setup(e,{emit:m}){const{locale:a,zIndex:d,ns:t,size:g}=ht("message-box",q(()=>e.buttonSize)),{t:u}=a,{nextZIndex:S}=d,U=O(!1),v=Mt({autofocus:!0,beforeClose:null,callback:null,cancelButtonText:"",cancelButtonClass:"",confirmButtonText:"",confirmButtonClass:"",customClass:"",customStyle:{},dangerouslyUseHTMLString:!1,distinguishCancelAndClose:!1,icon:"",closeIcon:"",inputPattern:null,inputPlaceholder:"",inputType:"text",inputValue:"",inputValidator:void 0,inputErrorMessage:"",message:"",modalFade:!0,modalClass:"",showCancelButton:!1,showConfirmButton:!0,type:"",title:void 0,showInput:!1,action:"",confirmButtonLoading:!1,cancelButtonLoading:!1,confirmButtonLoadingIcon:Ne(Xe),cancelButtonLoadingIcon:Ne(Xe),confirmButtonDisabled:!1,editorErrorMessage:"",validateError:!1,zIndex:S()}),l=q(()=>{const T=v.type;return{[t.bm("icon",T)]:T&&Ze[T]}}),h=Ye(),B=Ye(),w=q(()=>{const T=v.type;return v.icon||T&&Ze[T]||""}),_=q(()=>!!v.message),$=O(),L=O(),R=O(),te=O(),ne=O(),se=q(()=>v.confirmButtonClass);ee(()=>v.inputValue,async T=>{await he(),e.boxType==="prompt"&&T&&W()},{immediate:!0}),ee(()=>U.value,T=>{var G,ae;T&&(e.boxType!=="prompt"&&(v.autofocus?R.value=(ae=(G=ne.value)==null?void 0:G.$el)!=null?ae:$.value:R.value=$.value),v.zIndex=S()),e.boxType==="prompt"&&(T?he().then(()=>{var ye;te.value&&te.value.$el&&(v.autofocus?R.value=(ye=oe())!=null?ye:$.value:R.value=$.value)}):(v.editorErrorMessage="",v.validateError=!1))});const ce=q(()=>e.draggable),j=q(()=>e.overflow),{isDragging:p}=Qt($,L,ce,j);Pt(async()=>{await he(),e.closeOnHashChange&&window.addEventListener("hashchange",z)}),Ft(()=>{e.closeOnHashChange&&window.removeEventListener("hashchange",z)});function z(){U.value&&(U.value=!1,he(()=>{v.action&&m("action",v.action)}))}const c=()=>{e.closeOnClickModal&&x(v.distinguishCancelAndClose?"close":"cancel")},C=Zt(c),P=T=>{if(v.inputType!=="textarea")return T.preventDefault(),x("confirm")},x=T=>{var G;e.boxType==="prompt"&&T==="confirm"&&!W()||(v.action=T,v.beforeClose?(G=v.beforeClose)==null||G.call(v,T,v,z):z())},W=()=>{if(e.boxType==="prompt"){const T=v.inputPattern;if(T&&!T.test(v.inputValue||""))return v.editorErrorMessage=v.inputErrorMessage||u("el.messagebox.error"),v.validateError=!0,!1;const G=v.inputValidator;if(je(G)){const ae=G(v.inputValue);if(ae===!1)return v.editorErrorMessage=v.inputErrorMessage||u("el.messagebox.error"),v.validateError=!0,!1;if(Fe(ae))return v.editorErrorMessage=ae,v.validateError=!0,!1}}return v.editorErrorMessage="",v.validateError=!1,!0},oe=()=>{var T,G;const ae=(T=te.value)==null?void 0:T.$refs;return(G=ae?.input)!=null?G:ae?.textarea},re=()=>{x("close")},J=()=>{e.closeOnPressEscape&&re()};return e.lockScroll&&Xt(U,{ns:t}),{...Lt(v),ns:t,overlayEvent:C,visible:U,hasMessage:_,typeClass:l,contentId:h,inputId:B,btnSize:g,iconComponent:w,confirmButtonClasses:se,rootRef:$,focusStartRef:R,headerRef:L,inputRef:te,isDragging:p,confirmRef:ne,doClose:z,handleClose:re,onCloseRequested:J,handleWrapperClick:c,handleInputEnter:P,handleAction:x,t:u}}}),ra=["aria-label","aria-describedby"],ia=["aria-label"],ua=["id"];function ca(e,m,a,d,t,g){const u=Ce("el-icon"),S=Ce("el-input"),U=Ce("el-button"),v=Ce("el-focus-trap"),l=Ce("el-overlay");return i(),H(Ot,{name:"fade-in-linear",onAfterLeave:m[11]||(m[11]=h=>e.$emit("vanish")),persisted:""},{default:f(()=>[Ae(s(l,{"z-index":e.zIndex,"overlay-class":[e.ns.is("message-box"),e.modalClass],mask:e.modal},{default:f(()=>[n("div",{role:"dialog","aria-label":e.title,"aria-modal":"true","aria-describedby":e.showInput?void 0:e.contentId,class:Q(`${e.ns.namespace.value}-overlay-message-box`),onClick:m[8]||(m[8]=(...h)=>e.overlayEvent.onClick&&e.overlayEvent.onClick(...h)),onMousedown:m[9]||(m[9]=(...h)=>e.overlayEvent.onMousedown&&e.overlayEvent.onMousedown(...h)),onMouseup:m[10]||(m[10]=(...h)=>e.overlayEvent.onMouseup&&e.overlayEvent.onMouseup(...h))},[s(v,{loop:"",trapped:e.visible,"focus-trap-el":e.rootRef,"focus-start-el":e.focusStartRef,onReleaseRequested:e.onCloseRequested},{default:f(()=>[n("div",{ref:"rootRef",class:Q([e.ns.b(),e.customClass,e.ns.is("draggable",e.draggable),e.ns.is("dragging",e.isDragging),{[e.ns.m("center")]:e.center}]),style:tt(e.customStyle),tabindex:"-1",onClick:m[7]||(m[7]=ke(()=>{},["stop"]))},[e.title!==null&&e.title!==void 0?(i(),b("div",{key:0,ref:"headerRef",class:Q([e.ns.e("header"),{"show-close":e.showClose}])},[n("div",{class:Q(e.ns.e("title"))},[e.iconComponent&&e.center?(i(),H(u,{key:0,class:Q([e.ns.e("status"),e.typeClass])},{default:f(()=>[(i(),H(we(e.iconComponent)))]),_:1},8,["class"])):M("v-if",!0),n("span",null,o(e.title),1)],2),e.showClose?(i(),b("button",{key:0,type:"button",class:Q(e.ns.e("headerbtn")),"aria-label":e.t("el.messagebox.close"),onClick:m[0]||(m[0]=h=>e.handleAction(e.distinguishCancelAndClose?"close":"cancel")),onKeydown:m[1]||(m[1]=be(ke(h=>e.handleAction(e.distinguishCancelAndClose?"close":"cancel"),["prevent"]),["enter"]))},[s(u,{class:Q(e.ns.e("close"))},{default:f(()=>[(i(),H(we(e.closeIcon||"close")))]),_:1},8,["class"])],42,ia)):M("v-if",!0)],2)):M("v-if",!0),n("div",{id:e.contentId,class:Q(e.ns.e("content"))},[n("div",{class:Q(e.ns.e("container"))},[e.iconComponent&&!e.center&&e.hasMessage?(i(),H(u,{key:0,class:Q([e.ns.e("status"),e.typeClass])},{default:f(()=>[(i(),H(we(e.iconComponent)))]),_:1},8,["class"])):M("v-if",!0),e.hasMessage?(i(),b("div",{key:1,class:Q(e.ns.e("message"))},[jt(e.$slots,"default",{},()=>[e.dangerouslyUseHTMLString?(i(),H(we(e.showInput?"label":"p"),{key:1,for:e.showInput?e.inputId:void 0,innerHTML:e.message},null,8,["for","innerHTML"])):(i(),H(we(e.showInput?"label":"p"),{key:0,for:e.showInput?e.inputId:void 0,textContent:o(e.message)},null,8,["for","textContent"]))])],2)):M("v-if",!0)],2),Ae(n("div",{class:Q(e.ns.e("input"))},[s(S,{id:e.inputId,ref:"inputRef",modelValue:e.inputValue,"onUpdate:modelValue":m[2]||(m[2]=h=>e.inputValue=h),type:e.inputType,placeholder:e.inputPlaceholder,"aria-invalid":e.validateError,class:Q({invalid:e.validateError}),onKeydown:be(e.handleInputEnter,["enter"])},null,8,["id","modelValue","type","placeholder","aria-invalid","class","onKeydown"]),n("div",{class:Q(e.ns.e("errormsg")),style:tt({visibility:e.editorErrorMessage?"visible":"hidden"})},o(e.editorErrorMessage),7)],2),[[ze,e.showInput]])],10,ua),n("div",{class:Q(e.ns.e("btns"))},[e.showCancelButton?(i(),H(U,{key:0,loading:e.cancelButtonLoading,"loading-icon":e.cancelButtonLoadingIcon,class:Q([e.cancelButtonClass]),round:e.roundButton,size:e.btnSize,onClick:m[3]||(m[3]=h=>e.handleAction("cancel")),onKeydown:m[4]||(m[4]=be(ke(h=>e.handleAction("cancel"),["prevent"]),["enter"]))},{default:f(()=>[E(o(e.cancelButtonText||e.t("el.messagebox.cancel")),1)]),_:1},8,["loading","loading-icon","class","round","size"])):M("v-if",!0),Ae(s(U,{ref:"confirmRef",type:"primary",loading:e.confirmButtonLoading,"loading-icon":e.confirmButtonLoadingIcon,class:Q([e.confirmButtonClasses]),round:e.roundButton,disabled:e.confirmButtonDisabled,size:e.btnSize,onClick:m[5]||(m[5]=h=>e.handleAction("confirm")),onKeydown:m[6]||(m[6]=be(ke(h=>e.handleAction("confirm"),["prevent"]),["enter"]))},{default:f(()=>[E(o(e.confirmButtonText||e.t("el.messagebox.confirm")),1)]),_:1},8,["loading","loading-icon","class","round","disabled","size"]),[[ze,e.showConfirmButton]])],2)],6)]),_:3},8,["trapped","focus-trap-el","focus-start-el","onReleaseRequested"])],42,ra)]),_:3},8,["z-index","overlay-class","mask"]),[[ze,e.visible]])]),_:3})}var da=pt(oa,[["render",ca],["__file","/home/runner/work/element-plus/element-plus/packages/components/message-box/src/index.vue"]]);const xe=new Map,ma=e=>{let m=document.body;return e.appendTo&&(Fe(e.appendTo)&&(m=document.querySelector(e.appendTo)),Ke(e.appendTo)&&(m=e.appendTo),Ke(m)||(m=document.body)),m},fa=(e,m,a=null)=>{const d=s(da,e,je(e.message)||ot(e.message)?{default:je(e.message)?e.message:()=>e.message}:null);return d.appContext=a,rt(d,m),ma(e).appendChild(m.firstElementChild),d.component},va=()=>document.createElement("div"),pa=(e,m)=>{const a=va();e.onVanish=()=>{rt(null,a),xe.delete(t)},e.onAction=g=>{const u=xe.get(t);let S;e.showInput?S={value:t.inputValue,action:g}:S=g,e.callback?e.callback(S,d.proxy):g==="cancel"||g==="close"?e.distinguishCancelAndClose&&g!=="cancel"?u.reject("close"):u.reject("cancel"):u.resolve(S)};const d=fa(e,a,m),t=d.proxy;for(const g in e)at(e,g)&&!at(t.$props,g)&&(g==="closeIcon"&&it(e[g])?t[g]=Ne(e[g]):t[g]=e[g]);return t.visible=!0,t};function _e(e,m=null){if(!bt)return Promise.reject();let a;return Fe(e)||ot(e)?e={message:e}:a=e.callback,new Promise((d,t)=>{const g=pa(e,m??_e._context);xe.set(g,{options:e,callback:a,resolve:d,reject:t})})}const ga=["alert","confirm","prompt"],ya={alert:{closeOnPressEscape:!1,closeOnClickModal:!1},confirm:{showCancelButton:!0},prompt:{showCancelButton:!0,showInput:!0}};ga.forEach(e=>{_e[e]=ha(e)});function ha(e){return(m,a,d,t)=>{let g="";return it(a)?(d=a,g=""):_t(a)?g="":g=a,_e(Object.assign({title:g,message:m,type:"",...ya[e]},d,{boxType:e}),t)}}_e.close=()=>{xe.forEach((e,m)=>{m.doClose()}),xe.clear()};_e._context=null;const pe=_e;pe.install=e=>{pe._context=e._context,e.config.globalProperties.$msgbox=pe,e.config.globalProperties.$messageBox=pe,e.config.globalProperties.$alert=pe.alert,e.config.globalProperties.$confirm=pe.confirm,e.config.globalProperties.$prompt=pe.prompt};const mt=pe,ba={class:"flex items-center justify-between shrink-0"},_a={class:"flex items-center gap-4"},$a={class:"flex flex-col items-start gap-2"},Ca={class:"flex items-center gap-2"},wa={class:"text-2xl font-bold text-gray-900 dark:text-white"},ka={class:"flex gap-2"},xa=ue({__name:"ServerDetailHeader",props:{server:{}},emits:["back","delete","restart-all","start-all","stop-all"],setup(e,{emit:m}){const a=e,d=m;me();const t=q(()=>a.server.rawV11Config?.instances?.length?a.server.rawV11Config.instances.length:a.server.instances?.length?a.server.instances.length:1),g=q(()=>t.value),u=q(()=>a.server.instances?.length?a.server.instances.filter(w=>w.status==="online").length:a.server.status==="online"?1:0),S=q(()=>a.server.instances?.length?a.server.instances.filter(w=>w.status!=="online").length:t.value>1?t.value-u.value:a.server.status!=="online"?1:0);function U(){d("back")}function v(){d("delete")}function l(){d("restart-all")}function h(){d("start-all")}function B(){d("stop-all")}return(w,_)=>{const $=de,L=He;return i(),b("div",ba,[n("div",_a,[s($,{icon:y($t),plain:"",onClick:U,class:"shrink-0"},{default:f(()=>[E(o(w.$t("action.back")),1)]),_:1},8,["icon"]),n("div",$a,[n("div",Ca,[n("h2",wa,o(e.server.name),1),e.server.version?(i(),H(L,{key:0,size:"small",class:"ml-2"},{default:f(()=>[E(o(e.server.version),1)]),_:1})):M("",!0)]),s(Wt,{server:e.server},null,8,["server"])])]),n("div",ka,[S.value>0?(i(),H($,{key:0,type:"success",icon:y(st),onClick:h},{default:f(()=>[E(o(w.$t("action.startAll"))+" ("+o(S.value)+") ",1)]),_:1},8,["icon"])):M("",!0),u.value>0?(i(),H($,{key:1,type:"primary",icon:y(Me),onClick:l},{default:f(()=>[E(o(w.$t("action.restartAll"))+" ("+o(g.value)+") ",1)]),_:1},8,["icon"])):M("",!0),u.value>0?(i(),H($,{key:2,type:"warning",icon:y(Ct),onClick:B},{default:f(()=>[E(o(w.$t("action.stopAll"))+" ("+o(u.value)+") ",1)]),_:1},8,["icon"])):M("",!0),s($,{type:"danger",icon:y(ie),onClick:v},{default:f(()=>[E(o(w.$t("action.deleteServer")),1)]),_:1},8,["icon"])])])}}}),Sa={class:"config-template-form h-full flex flex-col min-h-0"},Va={class:"space-y-4 flex-1 overflow-y-auto min-h-0"},Ia={class:"px-4"},Ta={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},Da={key:0,class:"px-4"},Ea={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},Ba={key:1,class:"px-4"},Ua={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},Ra={key:2,class:"px-4"},Aa={class:"flex items-center justify-between mb-2"},za={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},Na={key:0,class:"space-y-2"},ja={class:"px-4"},Oa={class:"flex items-center justify-between mb-2"},Ma={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},Pa={key:0,class:"space-y-2"},Fa={key:3,class:"px-4"},La={class:"flex items-center justify-between mb-2"},Ha={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},Ja={key:0,class:"space-y-2"},qa={class:"px-4"},Wa={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},Ga={class:"px-4"},Qa={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},Xa={key:4,class:"px-4"},Za={class:"flex items-center justify-between mb-2"},Ya={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},Ka={key:0,class:"flex gap-2 items-start"},el={class:"px-4"},tl={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},al={class:"flex gap-2 pt-4 pb-4 border-t border-gray-200 dark:border-gray-700 px-4"},ll=ue({__name:"ConfigTemplateForm",props:{config:{}},emits:["update:template","save","edit-json"],setup(e,{emit:m}){const a=e,d=m;me();const t=O({...a.config,template:{...a.config.template,instanceSelectionStrategy:a.config.template.instanceSelectionStrategy||"random"}});let g=0,u=0;const S=O({}),U=O({});ee(()=>a.config,p=>{t.value={...p,template:{...p.template,instanceSelectionStrategy:p.template.instanceSelectionStrategy||"random"}},l(),h()},{immediate:!0});const v=q({get:()=>t.value?.template?.timeout?t.value.template.timeout/1e3:60,set:p=>{t.value&&(t.value.template.timeout=p*1e3)}});function l(){t.value?.template?.env&&(S.value={},Object.keys(t.value.template.env).forEach(p=>{S.value[p]=`env-${g++}`}))}function h(){t.value?.template?.headers&&(U.value={},Object.keys(t.value.template.headers).forEach(p=>{U.value[p]=`header-${u++}`}))}function B(){t.value.template.args||(t.value.template.args=[]),t.value.template.args.push(""),d("update:template",{...t.value.template})}function w(p){t.value.template.args?.splice(p,1),d("update:template",{...t.value.template})}function _(){t.value.template.env||(t.value.template.env={});const p=`NEW_VAR_${Object.keys(t.value.template.env).length}`;t.value.template.env[p]="",S.value[p]=`env-${g++}`,d("update:template",{...t.value.template})}function $(p){delete t.value.template.env[p],delete S.value[p],d("update:template",{...t.value.template})}function L(p,z){if(p===z)return;const c=t.value.template.env[p]||"",C=S.value[p]||`env-${g++}`;delete t.value.template.env[p],delete S.value[p],t.value.template.env[z]=c,S.value[z]=C,d("update:template",{...t.value.template})}function R(){t.value.template.headers||(t.value.template.headers={});const p=`NEW_HEADER_${Object.keys(t.value.template.headers).length}`;t.value.template.headers[p]="",U.value[p]=`header-${u++}`,d("update:template",{...t.value.template})}function te(p){delete t.value.template.headers[p],delete U.value[p],d("update:template",{...t.value.template})}function ne(p,z){if(p===z)return;const c=t.value.template.headers[p]||"",C=U.value[p]||`header-${u++}`;delete t.value.template.headers[p],delete U.value[p],t.value.template.headers[z]=c,U.value[z]=C,d("update:template",{...t.value.template})}function se(){t.value.template.proxy?t.value.template.proxy=void 0:t.value.template.proxy={url:""},d("update:template",{...t.value.template})}function ce(){const p={command:t.value.template.command,args:t.value.template.args,env:t.value.template.env,headers:t.value.template.headers,type:t.value.template.type,timeout:t.value.template.timeout,url:t.value.template.url,aggregatedTools:t.value.template.aggregatedTools,description:t.value.template.description,proxy:t.value.template.proxy,instanceSelectionStrategy:t.value.template.instanceSelectionStrategy};d("update:template",p),d("save")}function j(){d("edit-json")}return(p,z)=>{const c=ea,C=Kt,P=Ve,x=de,W=ct,oe=qe,re=Je;return i(),b("div",Sa,[n("div",Va,[n("div",Ia,[n("label",Ta,o(p.$t("serverDetail.config.transport")),1),s(C,{modelValue:t.value.template.type,"onUpdate:modelValue":z[0]||(z[0]=J=>t.value.template.type=J),class:"flex gap-4"},{default:f(()=>[s(c,{value:"stdio"},{default:f(()=>[E(o(p.$t("serverDetail.config.transportStdio")),1)]),_:1}),s(c,{value:"sse"},{default:f(()=>[E(o(p.$t("serverDetail.config.transportSse")),1)]),_:1}),s(c,{value:"streamable-http"},{default:f(()=>[E(o(p.$t("serverDetail.config.transportHttp")),1)]),_:1})]),_:1},8,["modelValue"])]),t.value.template.type==="stdio"?(i(),b("div",Da,[n("label",Ea,o(p.$t("serverDetail.config.executable")),1),s(P,{modelValue:t.value.template.command,"onUpdate:modelValue":z[1]||(z[1]=J=>t.value.template.command=J)},null,8,["modelValue"])])):(i(),b("div",Ba,[n("label",Ua,o(p.$t("serverDetail.config.url")),1),s(P,{modelValue:t.value.template.url,"onUpdate:modelValue":z[2]||(z[2]=J=>t.value.template.url=J)},null,8,["modelValue"])])),t.value.template.type==="stdio"?(i(),b("div",Ra,[n("div",Aa,[n("label",za,o(p.$t("serverDetail.config.args")),1),s(x,{size:"small",icon:y(fe),onClick:B},{default:f(()=>[E(o(p.$t("serverDetail.config.addArg")),1)]),_:1},8,["icon"])]),t.value.template.args&&t.value.template.args.length>0?(i(),b("div",Na,[(i(!0),b(Z,null,K(t.value.template.args,(J,T)=>(i(),b("div",{key:T,class:"flex gap-2 px-4"},[s(P,{modelValue:t.value.template.args[T],"onUpdate:modelValue":G=>t.value.template.args[T]=G,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue"]),s(x,{size:"small",type:"danger",icon:y(ie),onClick:G=>w(T)},null,8,["icon","onClick"])]))),128))])):M("",!0)])):M("",!0),n("div",ja,[n("div",Oa,[n("label",Ma,o(p.$t("serverDetail.config.env")),1),s(x,{size:"small",icon:y(fe),onClick:_},{default:f(()=>[E(o(p.$t("serverDetail.config.addEnv")),1)]),_:1},8,["icon"])]),t.value.template.env&&Object.keys(t.value.template.env).length>0?(i(),b("div",Pa,[(i(!0),b(Z,null,K(t.value.template.env,(J,T)=>(i(),b("div",{key:S.value[T],class:"flex gap-2 items-start px-4",style:{display:"flex",gap:"0.5rem",width:"100%"}},[s(P,{"model-value":T,style:{width:"30%","min-width":"150px"},placeholder:p.$t("addServer.keyPlaceholder"),"onUpdate:modelValue":G=>L(T,G)},null,8,["model-value","placeholder","onUpdate:modelValue"]),s(P,{modelValue:t.value.template.env[T],"onUpdate:modelValue":G=>t.value.template.env[T]=G,style:{flex:"1"},placeholder:p.$t("addServer.valuePlaceholder")},null,8,["modelValue","onUpdate:modelValue","placeholder"]),s(x,{size:"small",type:"danger",icon:y(ie),onClick:G=>$(T)},null,8,["icon","onClick"])]))),128))])):M("",!0)]),t.value.template.type!=="stdio"?(i(),b("div",Fa,[n("div",La,[n("label",Ha,o(p.$t("serverDetail.config.headers")),1),s(x,{size:"small",icon:y(fe),onClick:R},{default:f(()=>[E(o(p.$t("serverDetail.config.addHeader")),1)]),_:1},8,["icon"])]),t.value.template.headers&&Object.keys(t.value.template.headers).length>0?(i(),b("div",Ja,[(i(!0),b(Z,null,K(t.value.template.headers,(J,T)=>(i(),b("div",{key:U.value[T],class:"flex gap-2 items-start px-4",style:{display:"flex",gap:"0.5rem",width:"100%"}},[s(P,{"model-value":T,style:{width:"30%","min-width":"150px"},placeholder:p.$t("addServer.keyPlaceholder"),"onUpdate:modelValue":G=>ne(T,G)},null,8,["model-value","placeholder","onUpdate:modelValue"]),s(P,{modelValue:t.value.template.headers[T],"onUpdate:modelValue":G=>t.value.template.headers[T]=G,style:{flex:"1"},placeholder:p.$t("addServer.valuePlaceholder")},null,8,["modelValue","onUpdate:modelValue","placeholder"]),s(x,{size:"small",type:"danger",icon:y(ie),onClick:G=>te(T)},null,8,["icon","onClick"])]))),128))])):M("",!0)])):M("",!0),n("div",qa,[n("label",Wa,o(p.$t("serverDetail.config.timeout")),1),s(W,{modelValue:v.value,"onUpdate:modelValue":z[3]||(z[3]=J=>v.value=J),min:1,max:3600},null,8,["modelValue"])]),n("div",Ga,[n("label",Qa,o(p.$t("common.description")),1),s(P,{modelValue:t.value.template.description,"onUpdate:modelValue":z[4]||(z[4]=J=>t.value.template.description=J),type:"textarea",rows:3,placeholder:p.$t("serverDetail.config.descriptionPlaceholder")},null,8,["modelValue","placeholder"])]),t.value.template.type!=="stdio"?(i(),b("div",Xa,[n("div",Za,[n("label",Ya,o(p.$t("serverDetail.config.proxy")),1),t.value.template.proxy?(i(),H(x,{key:1,size:"small",type:"danger",icon:y(ie),onClick:se},{default:f(()=>[E(o(p.$t("serverDetail.config.removeProxy")),1)]),_:1},8,["icon"])):(i(),H(x,{key:0,size:"small",icon:y(fe),onClick:se},{default:f(()=>[E(o(p.$t("serverDetail.config.addProxy")),1)]),_:1},8,["icon"]))]),t.value.template.proxy?(i(),b("div",Ka,[s(P,{modelValue:t.value.template.proxy.url,"onUpdate:modelValue":z[5]||(z[5]=J=>t.value.template.proxy.url=J),placeholder:p.$t("serverDetail.config.proxyPlaceholder")},null,8,["modelValue","placeholder"])])):M("",!0)])):M("",!0),n("div",el,[n("label",tl,o(p.$t("serverDetail.config.instanceSelectionStrategy")),1),s(re,{modelValue:t.value.template.instanceSelectionStrategy,"onUpdate:modelValue":z[6]||(z[6]=J=>t.value.template.instanceSelectionStrategy=J),placeholder:p.$t("serverDetail.config.strategyRandom")+"(默认)"},{default:f(()=>[s(oe,{value:"random",label:p.$t("serverDetail.config.strategyRandom")},null,8,["label"]),s(oe,{value:"round-robin",label:p.$t("serverDetail.config.strategyRoundRobin")},null,8,["label"]),s(oe,{value:"tag-match-unique",label:p.$t("serverDetail.config.strategyTagMatchUnique")},null,8,["label"])]),_:1},8,["modelValue","placeholder"])]),n("div",al,[s(x,{type:"primary",onClick:ce},{default:f(()=>[E(o(p.$t("serverDetail.config.save")),1)]),_:1}),s(x,{onClick:j},{default:f(()=>[E(o(p.$t("serverDetail.config.editByJson")),1)]),_:1})])])])}}}),nl=Ie(ll,[["__scopeId","data-v-d857c695"]]),sl={class:"h-full flex flex-col"},ol={class:"flex items-center justify-between gap-2 mb-2 shrink-0"},rl={class:"flex items-center gap-2"},il=ue({__name:"LogViewer",props:{logs:{},autoScroll:{type:Boolean,default:!0}},emits:["update:autoScroll","clear","copy"],setup(e,{emit:m}){const a=e,d=m;me();const t=O(null),g=O(a.autoScroll);ee(()=>a.autoScroll,l=>{g.value=l}),ee(()=>a.logs.length,()=>{g.value&&he(()=>{t.value&&(t.value.scrollTop=t.value.scrollHeight)})});function u(l){const h=!!l;g.value=h,d("update:autoScroll",h)}function S(){d("clear")}function U(){d("copy")}function v(l){switch(l){case"debug":return"text-gray-400";case"info":return"text-blue-400";case"warn":return"text-yellow-400";case"error":return"text-red-400";default:return"text-gray-300"}}return(l,h)=>{const B=ta,w=de;return i(),b("div",sl,[n("div",ol,[n("div",rl,[s(B,{modelValue:g.value,"onUpdate:modelValue":[h[0]||(h[0]=_=>g.value=_),u],label:l.$t("serverDetail.logs.autoScroll"),class:"text-gray-600 dark:text-gray-400"},null,8,["modelValue","label"]),s(w,{size:"small",icon:y(ie),plain:"",onClick:S},{default:f(()=>[E(o(l.$t("serverDetail.logs.clear")),1)]),_:1},8,["icon"]),s(w,{size:"small",icon:y(wt),plain:"",onClick:U},{default:f(()=>[E(o(l.$t("common.copy")),1)]),_:1},8,["icon"])])]),n("div",{class:"bg-gray-900 dark:bg-black p-4 rounded-lg font-mono text-sm flex-1 min-h-0 overflow-y-auto text-gray-300",ref_key:"logsContainer",ref:t},[(i(!0),b(Z,null,K(e.logs,(_,$)=>(i(),b("div",{key:$,class:"mb-1 break-words"},[n("span",{class:Q(v(_.level))},o(y(ut)(_.timestamp))+" ["+o(_.level.toUpperCase())+"] "+o(_.message),3)]))),128))],512)])}}}),ul={class:"h-full flex flex-col"},cl={class:"flex h-full gap-4"},dl={class:"w-1/3 border-r border-gray-200 dark:border-gray-700 pr-4 overflow-y-auto"},ml={class:"font-bold mb-4"},fl={key:0,class:"space-y-2"},vl=["onClick"],pl={class:"min-w-0 flex-1 mr-2"},gl={class:"font-medium truncate"},yl={key:1,class:"text-gray-500 text-sm italic"},hl={class:"flex-1 min-h-0 overflow-y-auto px-4 flex flex-col"},bl={class:"flex justify-between items-center mb-4 shrink-0"},_l={class:"font-bold"},$l={key:0},Cl={class:"mb-4 text-gray-600 dark:text-gray-300"},wl={class:"font-medium mb-2"},kl={class:"bg-gray-50 dark:bg-[#0f172a] p-4 rounded-lg overflow-x-auto text-sm font-mono border border-gray-200 dark:border-gray-700"},xl={key:1,class:"flex-1 flex items-center justify-center text-gray-400"},Sl=ue({__name:"ToolsTab",props:{tools:{},allowedTools:{default:null}},emits:["select-tool","update-tool-visibility","call-tool"],setup(e,{emit:m}){const a=e,d=m;me();const t=O(null);function g(v){t.value=v,d("select-tool",v)}function u(v){return a.allowedTools===void 0||a.allowedTools===null||a.allowedTools.length===0?!1:Array.isArray(a.allowedTools)?a.allowedTools.includes(v):!1}function S(v,l){d("update-tool-visibility",v,l)}function U(){t.value&&d("call-tool",t.value)}return(v,l)=>{const h=dt,B=de;return i(),b("div",ul,[n("div",cl,[n("div",dl,[n("h3",ml,o(v.$t("serverDetail.tools.available")),1),e.tools&&e.tools.length>0?(i(),b("div",fl,[(i(!0),b(Z,null,K(e.tools,w=>(i(),b("div",{key:w.name,class:Q(["p-3 rounded-lg cursor-pointer transition-colors flex items-center justify-between group",t.value?.name===w.name?"bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-800":"hover:bg-gray-100 dark:hover:bg-gray-800 border border-transparent"]),onClick:_=>g(w)},[n("div",pl,[n("div",gl,o(w.name),1)]),s(h,{"model-value":u(w.name),"onUpdate:modelValue":_=>S(w.name,!!_),class:"mr-4","active-text":v.$t("serverDetail.tools.aggregated")},null,8,["model-value","onUpdate:modelValue","active-text"])],10,vl))),128))])):(i(),b("div",yl,o(v.$t("serverDetail.tools.none")),1))]),n("div",hl,[n("div",bl,[n("h3",_l,o(v.$t("serverDetail.tools.details"))+": "+o(t.value?.name||""),1),t.value?(i(),H(B,{key:0,type:"primary",size:"small",onClick:U},{default:f(()=>[E(o(v.$t("serverDetail.tools.call")),1)]),_:1})):M("",!0)]),t.value?(i(),b("div",$l,[n("p",Cl,o(t.value.description),1),n("h4",wl,o(v.$t("serverDetail.tools.schema")),1),n("pre",kl,o(JSON.stringify(t.value.inputSchema,null,2)),1)])):(i(),b("div",xl,o(v.$t("serverDetail.tools.selectHint")),1))])])])}}}),Vl={class:"h-full overflow-y-auto"},Il={class:"flex items-center gap-2"},Tl={class:"font-medium"},Dl={key:0,class:"text-center py-8 text-gray-500"},El=ue({__name:"ResourcesTab",props:{resources:{}},emits:["view-resource"],setup(e,{emit:m}){const a=m;me();function d(t){a("view-resource",t)}return(t,g)=>{const u=Se,S=la,U=de,v=aa;return i(),b("div",Vl,[s(v,{data:e.resources||[],style:{width:"100%"},class:"custom-table"},{default:f(()=>[s(S,{prop:"name",label:t.$t("common.name"),width:"200"},{default:f(({row:l})=>[n("div",Il,[s(u,null,{default:f(()=>[s(y(kt))]),_:1}),n("span",Tl,o(l.name),1)])]),_:1},8,["label"]),s(S,{prop:"uri",label:t.$t("common.uri"),"min-width":"300"},null,8,["label"]),s(S,{prop:"mimeType",label:t.$t("common.mimeType"),width:"150"},null,8,["label"]),s(S,{label:"",width:"100",align:"right"},{default:f(({row:l})=>[s(U,{size:"small",plain:"",onClick:h=>d(l)},{default:f(()=>[E(o(t.$t("action.view")),1)]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"]),!e.resources||e.resources.length===0?(i(),b("div",Dl,o(t.$t("serverDetail.resources.none")),1)):M("",!0)])}}}),Bl={class:"dialog-footer"},Ul=ue({__name:"JsonConfigEditor",props:{modelValue:{type:Boolean},config:{},serverName:{}},emits:["update:modelValue","save"],setup(e,{emit:m}){const a=e,d=m,{t}=me(),g=O(""),u=q({get:()=>a.modelValue,set:h=>d("update:modelValue",h)}),S=q(()=>t("serverDetail.editJsonTitle")||"Edit JSON Config");ee(()=>a.modelValue,h=>{h&&U()});function U(){const h={env:a.config.env||{},enabled:a.config.enabled,description:a.config.description};a.config.headers&&Object.keys(a.config.headers).length>0&&(h.headers=a.config.headers),a.config.timeout&&(h.timeout=a.config.timeout),a.config.type==="stdio"?(h.command=a.config.command,h.args=a.config.args||[]):h.url=a.config.url;const B={mcpServers:{[a.serverName]:h}};g.value=JSON.stringify(B,null,2)}function v(){u.value=!1}function l(){try{const h=JSON.parse(g.value);if(!h.mcpServers)throw new Error("Missing mcpServers key");const B=Object.keys(h.mcpServers);if(B.length===0)throw new Error("No server config found");const w=B[0]||"",_=h.mcpServers[w],$={...a.config};_.command?($.type="stdio",$.command=_.command,$.args=_.args||[],delete $.url):_.url&&($.type=_.type==="sse"?"sse":"streamable-http",$.url=_.url,delete $.command,delete $.args),_.env&&($.env=_.env),_.headers&&($.headers=_.headers),_.timeout!==void 0&&($.timeout=_.timeout),_.enabled!==void 0&&($.enabled=_.enabled),_.description!==void 0&&($.description=_.description),d("save",$),u.value=!1,I.success(t("action.configSaved"))}catch(h){h instanceof Error?I.error("Invalid JSON: "+h.message):I.error("Invalid JSON: "+String(h))}}return(h,B)=>{const w=Ve,_=de,$=We;return i(),H($,{modelValue:u.value,"onUpdate:modelValue":B[1]||(B[1]=L=>u.value=L),title:S.value,width:"600px"},{footer:f(()=>[n("span",Bl,[s(_,{onClick:v},{default:f(()=>[E(o(h.$t("action.cancel")),1)]),_:1}),s(_,{type:"primary",onClick:l},{default:f(()=>[E(o(h.$t("action.save")),1)]),_:1})])]),default:f(()=>[s(w,{modelValue:g.value,"onUpdate:modelValue":B[0]||(B[0]=L=>g.value=L),type:"textarea",rows:15,"font-family":"monospace"},null,8,["modelValue"])]),_:1},8,["modelValue","title"])}}}),Rl={class:"dialog-footer"},nt=ue({__name:"InstanceSelectDialog",props:{modelValue:{type:Boolean},instances:{},title:{default:""}},emits:["update:modelValue","confirm"],setup(e,{emit:m}){const a=e,d=m,{t}=me(),g=O(null),u=q({get:()=>a.modelValue,set:h=>d("update:modelValue",h)}),S=q(()=>a.title||t("serverDetail.selectInstanceTitle")||"Select Instance");function U(h){return`#${h.index??0} [${h.displayName||t("serverDetail.instances.unnamed")}]`}function v(){u.value=!1,g.value=null}function l(){g.value!==null&&(d("confirm",g.value),u.value=!1,g.value=null)}return(h,B)=>{const w=qe,_=Je,$=de,L=We;return i(),H(L,{modelValue:u.value,"onUpdate:modelValue":B[1]||(B[1]=R=>u.value=R),title:S.value,width:"500px"},{footer:f(()=>[n("span",Rl,[s($,{onClick:v},{default:f(()=>[E(o(h.$t("action.cancel")),1)]),_:1}),s($,{type:"primary",onClick:l,disabled:g.value===null},{default:f(()=>[E(o(h.$t("action.confirm")),1)]),_:1},8,["disabled"])])]),default:f(()=>[s(_,{modelValue:g.value,"onUpdate:modelValue":B[0]||(B[0]=R=>g.value=R),placeholder:h.$t("serverDetail.selectInstancePlaceholder"),class:"w-full"},{default:f(()=>[(i(!0),b(Z,null,K(e.instances,R=>(i(),H(w,{key:R.index??0,label:U(R),value:R.index??0},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["modelValue","title"])}}}),Al={class:"instance-card-list"},zl={class:"mb-4 flex justify-between items-center"},Nl={class:"text-lg font-semibold text-gray-900 dark:text-white"},jl={key:0,class:"mb-4"},Ol={class:"flex items-center justify-between"},Ml={class:"flex items-center gap-3"},Pl={class:"flex items-center gap-2"},Fl={class:"font-mono text-sm text-purple-600 dark:text-purple-400"},Ll={class:"flex flex-col gap-3 mb-4"},Hl=["onClick"],Jl={class:"flex items-center justify-between"},ql={class:"flex items-center gap-3"},Wl={class:"flex items-center gap-2"},Gl={class:"font-mono text-sm text-gray-500 dark:text-gray-400"},Ql={class:"font-medium text-gray-900 dark:text-white"},Xl={key:1,class:"px-2 py-0.5 rounded-full text-xs bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Zl=ue({__name:"InstanceCardList",props:{instances:{},selectedIndex:{},serverName:{},showTemplateNode:{type:Boolean,default:!0},templateSelected:{type:Boolean,default:!1}},emits:["select","select-template","add","update-display-name","delete","reassign-indexes"],setup(e,{emit:m}){const a=e,d=m,t=O(!1),g=O(null),u=O(""),S=O(),U=q(()=>[...a.instances].sort((j,p)=>(j.index??0)-(p.index??0)));function v(j){return j.status||"offline"}function l(){return a.templateSelected?"border-purple-500 bg-purple-50 dark:bg-purple-900/20 shadow-md":"border-purple-200 dark:border-purple-800 hover:border-purple-300 dark:hover:border-purple-700 hover:shadow-sm bg-white dark:bg-gray-800"}function h(j){return a.selectedIndex===j?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 shadow-md":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 hover:shadow-sm"}function B(j){switch(j){case"online":return"bg-green-500";case"error":return"bg-red-500";case"starting":case"stopping":return"bg-yellow-500";default:return"bg-gray-400"}}function w(j){switch(j){case"online":return"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400";case"error":return"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400";case"starting":case"stopping":return"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400";default:return"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}}function _(){d("select-template")}function $(j){d("select",j)}function L(){d("add")}function R(j){t.value=!0,g.value=j.index??null,u.value=j.displayName||"",setTimeout(()=>{S.value?.focus()},100)}function te(j){const p=u.value.trim();d("update-display-name",j,p),ne()}function ne(){t.value=!1,g.value=null,u.value=""}function se(j){d("delete",j)}function ce(){d("reassign-indexes")}return(j,p)=>{const z=de,c=He,C=Ve,P=xt;return i(),b("div",Al,[n("div",zl,[n("h3",Nl,o(j.$t("serverDetail.instances.title")),1),s(z,{size:"small",icon:y(Me),plain:"",onClick:ce},{default:f(()=>[E(o(j.$t("serverDetail.instances.reassignIndexes")),1)]),_:1},8,["icon"])]),e.showTemplateNode?(i(),b("div",jl,[n("div",{class:Q(["template-card p-4 rounded-lg border transition-all duration-200 cursor-pointer",l()]),onClick:_},[n("div",Ol,[n("div",Ml,[p[2]||(p[2]=n("div",{class:"w-3 h-3 rounded-full bg-purple-500"},null,-1)),n("div",Pl,[n("span",Fl,o(j.$t("common.template")),1),s(c,{size:"small",type:"info"},{default:f(()=>[E(o(j.$t("serverDetail.instances.templateTag")),1)]),_:1})])])])],2)])):M("",!0),n("div",Ll,[(i(!0),b(Z,null,K(U.value,x=>(i(),b("div",{key:x.index??0,class:Q(["instance-card p-4 rounded-lg border transition-all duration-200 cursor-pointer",h(x.index??0)]),onClick:W=>$(x.index??0)},[n("div",Jl,[n("div",ql,[n("div",{class:Q(["w-3 h-3 rounded-full",B(v(x))])},null,2),n("div",Wl,[!t.value||g.value!==x.index?(i(),b(Z,{key:0},[n("span",Gl," #"+o(x.index??0),1),n("span",Ql," ["+o(x.displayName||j.$t("serverDetail.instances.unnamed"))+"] ",1)],64)):(i(),H(C,{key:1,modelValue:u.value,"onUpdate:modelValue":p[0]||(p[0]=W=>u.value=W),size:"small",onKeyup:[be(W=>te(x.index??0),["enter"]),be(ne,["escape"])],ref_for:!0,ref_key:"displayNameInputRef",ref:S,onBlur:W=>te(x.index??0),class:"max-w-xs"},null,8,["modelValue","onKeyup","onBlur"]))]),x.pid&&v(x)==="online"?M("",!0):(i(),b("div",{key:0,class:Q(["px-2 py-0.5 rounded-full text-xs",w(v(x))])},o(j.$t(`serverDetail.status.${v(x)}`)),3)),x.transportType==="stdio"&&x.pid&&v(x)==="online"?(i(),b("div",Xl," PID: "+o(x.pid),1)):M("",!0)]),n("div",{class:"flex items-center gap-2",onClick:p[1]||(p[1]=ke(()=>{},["stop"]))},[!t.value||g.value!==x.index?(i(),b(Z,{key:0},[s(P,{content:j.$t("serverDetail.instances.editDisplayName")||"Edit display name",placement:"top"},{default:f(()=>[s(z,{icon:y(St),circle:"",plain:"",size:"small",onClick:W=>R(x)},null,8,["icon","onClick"])]),_:2},1032,["content"]),s(z,{icon:y(ie),circle:"",plain:"",size:"small",type:"danger",onClick:W=>se(x.index??0)},null,8,["icon","onClick"])],64)):M("",!0)])])],10,Hl))),128))]),s(z,{icon:y(fe),class:"w-full",onClick:L},{default:f(()=>[E(o(j.$t("serverDetail.instances.add")),1)]),_:1},8,["icon"])])}}}),Yl=Ie(Zl,[["__scopeId","data-v-24e76b86"]]),Kl={class:"preview-content"},en={class:"action-bar flex justify-end mb-4"},tn={class:"config-display"},an={class:"config-json"},ln=ue({__name:"MergedConfigPreviewDialog",props:{modelValue:{type:Boolean},mergedConfig:{}},emits:["update:modelValue"],setup(e){const m=e,{t:a}=me(),d=q(()=>JSON.stringify(m.mergedConfig,null,2));async function t(){try{await navigator.clipboard.writeText(d.value),I.success(a("action.copiedToClipboard"))}catch{I.error(a("action.copyFailed"))}}return(g,u)=>{const S=Se,U=de,v=We;return i(),H(v,{"model-value":e.modelValue,"onUpdate:modelValue":u[0]||(u[0]=l=>g.$emit("update:modelValue",l)),title:g.$t("serverDetail.instanceConfig.mergedPreview"),width:"70%","destroy-on-close":"",class:"merged-config-dialog"},{default:f(()=>[n("div",Kl,[n("div",en,[s(U,{type:"primary",onClick:t},{default:f(()=>[s(S,null,{default:f(()=>[s(y(Vt))]),_:1}),E(" "+o(g.$t("common.copy")),1)]),_:1})]),n("div",tn,[n("pre",an,o(d.value),1)])])]),_:1},8,["model-value","title"])}}}),nn=Ie(ln,[["__scopeId","data-v-84fcda8e"]]),sn={class:"instance-config h-full flex flex-col min-h-0"},on={class:"header-bar flex justify-between items-center mb-4 px-4 flex-shrink-0"},rn={class:"flex items-center gap-4"},un={class:"text-lg font-semibold text-gray-900 dark:text-white"},cn={class:"flex gap-2"},dn={class:"config-form space-y-4 flex-1 overflow-y-auto min-h-0 pb-4"},mn={class:"px-4"},fn={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},vn={class:"flex items-center gap-2"},pn={class:"text-xs text-gray-500 dark:text-gray-400"},gn={class:"px-4"},yn={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},hn={class:"flex gap-2 items-start"},bn={class:"text-xs text-gray-500 dark:text-gray-400 pt-2 whitespace-nowrap"},_n={key:0,class:"px-4"},$n={class:"flex items-center justify-between mb-2"},Cn={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},wn={key:0,class:"space-y-2 mb-3"},kn={class:"text-xs text-gray-500 dark:text-gray-400 pt-2 whitespace-nowrap"},xn={key:1,class:"space-y-2"},Sn={class:"px-4"},Vn={class:"flex items-center justify-between mb-2"},In={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},Tn={key:0,class:"space-y-2 mb-3"},Dn={class:"text-xs text-gray-500 dark:text-gray-400 pt-2 whitespace-nowrap"},En={key:1,class:"space-y-2"},Bn={key:1,class:"px-4"},Un={class:"flex items-center justify-between mb-2"},Rn={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},An={key:0,class:"space-y-2 mb-3"},zn={class:"text-xs text-gray-500 dark:text-gray-400 pt-2 whitespace-nowrap"},Nn={key:1,class:"space-y-2"},jn={class:"px-4"},On={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},Mn={class:"flex gap-2 items-center"},Pn={class:"text-xs text-gray-500 dark:text-gray-400"},Fn={class:"px-4"},Ln={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},Hn={class:"flex gap-2 items-start"},Jn={class:"text-xs text-gray-500 dark:text-gray-400 pt-2 whitespace-nowrap"},qn={key:2,class:"px-4"},Wn={class:"flex items-center justify-between mb-2"},Gn={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},Qn={key:0,class:"space-y-2 mb-3"},Xn={class:"flex gap-2 items-start"},Zn={class:"text-xs text-gray-500 dark:text-gray-400 pt-2 whitespace-nowrap"},Yn={key:1,class:"flex gap-2 items-start"},Kn={class:"px-4"},es={class:"flex items-center justify-between mb-2"},ts={class:"block text-sm font-bold text-gray-700 dark:text-gray-300"},as={key:0,class:"text-center py-4 text-gray-500"},ls={key:1,class:"space-y-2"},ns={class:"text-xs text-gray-500 ml-2"},ss={class:"px-4"},os={class:"block text-sm font-bold text-gray-700 dark:text-gray-300 mb-2"},rs={class:"flex gap-2 items-center"},is={class:"flex gap-2 pt-4 pb-4 border-t border-gray-200 dark:border-gray-700 px-4"},us=ue({__name:"InstanceConfig",props:{templateConfig:{},instanceConfig:{},serverName:{},instanceStatus:{default:"offline"},systemTagDefinitions:{}},emits:["update","start-instance","stop-instance","restart-instance","view-logs"],setup(e,{emit:m}){const a=e,d=m,{t}=me();function g(){d("start-instance")}function u(){d("stop-instance")}function S(){d("restart-instance")}function U(){d("view-logs")}const v=O(!1),l=O({enabled:!0,...a.instanceConfig});let h=0,B=0,w=0;const _=O({}),$=O({}),L=O({}),R=O({}),te=q(()=>a.templateConfig.args&&a.templateConfig.args.length>0),ne=q(()=>a.templateConfig.env&&Object.keys(a.templateConfig.env).length>0),se=q(()=>a.templateConfig.headers&&Object.keys(a.templateConfig.headers).length>0);ee(()=>a.instanceConfig,r=>{l.value={...r},_.value={},r.env&&Object.keys(r.env).forEach(V=>{_.value[V]=`env-${h++}`}),$.value={},r.headers&&Object.keys(r.headers).forEach(V=>{$.value[V]=`header-${B++}`}),L.value={},R.value={},r.tags&&Object.keys(r.tags).forEach(V=>{L.value[V]=`tag-${w++}`,a.systemTagDefinitions.some(le=>le.key===V)?R.value[V]=V:(R.value[V]=V,console.warn(`未定义的标签键: ${V}`))})},{immediate:!0});const ce=q(()=>{const r={...a.templateConfig};return l.value.args&&l.value.args.length>0&&(r.args=[...a.templateConfig.args||[],...l.value.args]),l.value.env&&Object.keys(l.value.env).length>0&&(r.env={...a.templateConfig.env||{},...l.value.env}),l.value.headers&&Object.keys(l.value.headers).length>0&&(r.headers={...a.templateConfig.headers||{},...l.value.headers}),l.value.proxy&&(r.proxy=l.value.proxy),l.value.tags&&Object.keys(l.value.tags).length>0&&(r.tags=l.value.tags),l.value.displayName&&(r.displayName=l.value.displayName),l.value.enabled!==void 0&&(r.enabled=l.value.enabled),r});function j(r){switch(r){case"stdio":return t("serverDetail.config.transportStdio");case"sse":return t("serverDetail.config.transportSse");case"streamable-http":return t("serverDetail.config.transportHttp");default:return r}}function p(){d("update",l.value)}function z(){l.value.proxy?l.value.proxy=void 0:l.value.proxy={url:""}}function c(){l.value.args||(l.value.args=[]),l.value.args.push("")}function C(r){l.value.args&&l.value.args.splice(r,1)}function P(){l.value.env||(l.value.env={});const r=`NEW_ENV_${Date.now()}`;l.value.env[r]="",_.value[r]=`env-${h++}`}function x(r){l.value.env&&(delete l.value.env[r],delete _.value[r])}function W(r,V){if(!l.value.env||!r||!V||r===V)return;const N=l.value.env[r]??"",le=_.value[r]||`env-${h++}`;delete l.value.env[r],delete _.value[r],l.value.env[V]=N,_.value[V]=le}function oe(){l.value.headers||(l.value.headers={});const r=`X-New-Header-${Date.now()}`;l.value.headers[r]="",$.value[r]=`header-${B++}`}function re(r){l.value.headers&&(delete l.value.headers[r],delete $.value[r])}function J(r,V){if(!l.value.headers||!r||!V||r===V)return;const N=l.value.headers[r]??"",le=$.value[r]||`header-${B++}`;delete l.value.headers[r],delete $.value[r],l.value.headers[V]=N,$.value[V]=le}function T(){if(l.value.tags||(l.value.tags={}),a.systemTagDefinitions.length>0){const r=a.systemTagDefinitions[0];if(r){const V=r.key;let N=V,le=1;for(;l.value.tags&&Object.prototype.hasOwnProperty.call(l.value.tags,N);)N=`${V}-${le}`,le++;l.value.tags[N]="",L.value[N]=`tag-${w++}`,R.value[N]=V}}else{I.warning("请先在设置中定义标签");const r=`new-tag-${Date.now()}`;l.value.tags[r]="",L.value[r]=`tag-${w++}`,R.value[r]=r}}function G(r){l.value.tags&&(delete l.value.tags[r],delete L.value[r],delete R.value[r])}function ae(r,V){if(!l.value.tags||!V)return;const N=l.value.tags[r]??"",le=L.value[r]||`tag-${w++}`;delete l.value.tags[r],delete L.value[r],delete R.value[r],l.value.tags[V]=N,L.value[V]=le,R.value[V]=V}function ye(r){const V=a.systemTagDefinitions.find(N=>N.key===r);return V?V.type:null}function Te(r){const V=a.systemTagDefinitions.find(N=>N.key===r);return V?.type==="enum"?V.values||[]:[]}function $e(r){return a.systemTagDefinitions.find(N=>N.key===r)?.description||"输入标签值"}function Ue(){window.location.hash="#/settings/tags"}return(r,V)=>{const N=de,le=Se,ve=He,Y=Ve,Re=ct,De=qe,Ee=Je,F=dt;return i(),b("div",sn,[n("div",on,[n("div",rn,[n("h3",un,o(r.$t("serverDetail.instanceConfig.title")),1),n("div",cn,[s(N,{icon:y(Me),plain:"",onClick:S},{default:f(()=>[E(o(r.$t("action.restart")),1)]),_:1},8,["icon"]),e.instanceStatus==="error"?(i(),H(N,{key:0,type:"danger",plain:"",icon:y(It),onClick:U},{default:f(()=>[E(o(r.$t("action.viewLogs")),1)]),_:1},8,["icon"])):e.instanceStatus==="online"?(i(),H(N,{key:1,type:"warning",plain:"",icon:y(Tt),onClick:u},{default:f(()=>[E(o(r.$t("action.stop")),1)]),_:1},8,["icon"])):(i(),H(N,{key:2,type:"success",icon:y(st),onClick:g},{default:f(()=>[E(o(r.$t("action.start")),1)]),_:1},8,["icon"]))])]),s(N,{onClick:V[0]||(V[0]=D=>v.value=!0)},{default:f(()=>[s(le,null,{default:f(()=>[s(y(Dt))]),_:1}),E(" "+o(r.$t("serverDetail.instanceConfig.viewMerged")),1)]),_:1})]),n("div",dn,[n("div",mn,[n("label",fn,o(r.$t("serverDetail.config.transport")),1),n("div",vn,[s(ve,{size:"small",type:"info"},{default:f(()=>[E(o(j(e.templateConfig.type)),1)]),_:1}),n("span",pn,o(r.$t("serverDetail.instanceConfig.fromTemplate")),1)])]),n("div",gn,[n("label",yn,o(e.templateConfig.type==="stdio"?r.$t("serverDetail.config.executable"):r.$t("serverDetail.config.url")),1),n("div",hn,[s(Y,{"model-value":e.templateConfig.type==="stdio"?e.templateConfig.command:e.templateConfig.url,disabled:"",class:"flex-1"},null,8,["model-value"]),n("span",bn,o(r.$t("serverDetail.instanceConfig.fromTemplate")),1)])]),e.templateConfig.type==="stdio"?(i(),b("div",_n,[n("div",$n,[n("label",Cn,o(r.$t("serverDetail.config.args")),1),s(N,{size:"small",icon:y(fe),onClick:c},{default:f(()=>[E(o(r.$t("serverDetail.config.addArg")),1)]),_:1},8,["icon"])]),te.value?(i(),b("div",wn,[(i(!0),b(Z,null,K(e.templateConfig.args,(D,k)=>(i(),b("div",{key:`template-arg-${k}`,class:"flex gap-2 items-start"},[s(Y,{"model-value":D,disabled:"",class:"flex-1"},null,8,["model-value"]),n("span",kn,o(r.$t("serverDetail.instanceConfig.fromTemplate")),1)]))),128))])):M("",!0),l.value.args&&l.value.args.length>0?(i(),b("div",xn,[(i(!0),b(Z,null,K(l.value.args,(D,k)=>(i(),b("div",{key:`instance-arg-${k}`,class:"flex gap-2 items-start"},[s(Y,{modelValue:l.value.args[k],"onUpdate:modelValue":A=>l.value.args[k]=A,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue"]),s(N,{size:"small",type:"danger",icon:y(ie),onClick:A=>C(k)},null,8,["icon","onClick"]),s(ve,{size:"small",type:"success"},{default:f(()=>[E(o(r.$t("common.instance")),1)]),_:1})]))),128))])):M("",!0)])):M("",!0),n("div",Sn,[n("div",Vn,[n("label",In,o(r.$t("serverDetail.config.env")),1),s(N,{size:"small",icon:y(fe),onClick:P},{default:f(()=>[E(o(r.$t("serverDetail.config.addEnv")),1)]),_:1},8,["icon"])]),ne.value?(i(),b("div",Tn,[(i(!0),b(Z,null,K(e.templateConfig.env,(D,k)=>(i(),b("div",{key:`template-env-${k}`,class:"flex gap-2 items-start",style:{display:"flex",gap:"0.5rem",width:"100%"}},[s(Y,{"model-value":k,disabled:"",style:{width:"30%","min-width":"150px"}},null,8,["model-value"]),s(Y,{"model-value":e.templateConfig.env[k],disabled:"",style:{flex:"1"}},null,8,["model-value"]),n("span",Dn,o(r.$t("serverDetail.instanceConfig.fromTemplate")),1)]))),128))])):M("",!0),l.value.env&&Object.keys(l.value.env).length>0?(i(),b("div",En,[(i(!0),b(Z,null,K(l.value.env,(D,k)=>(i(),b("div",{key:_.value[k],class:"flex gap-2 items-start",style:{display:"flex",gap:"0.5rem",width:"100%"}},[s(Y,{"model-value":k,style:{width:"30%","min-width":"150px"},placeholder:r.$t("addServer.keyPlaceholder"),"onUpdate:modelValue":A=>W(k,A)},null,8,["model-value","placeholder","onUpdate:modelValue"]),s(Y,{modelValue:l.value.env[k],"onUpdate:modelValue":A=>l.value.env[k]=A,style:{flex:"1"},placeholder:r.$t("addServer.valuePlaceholder")},null,8,["modelValue","onUpdate:modelValue","placeholder"]),s(N,{size:"small",type:"danger",icon:y(ie),onClick:A=>x(k)},null,8,["icon","onClick"]),s(ve,{size:"small",type:"success"},{default:f(()=>[E(o(r.$t("common.instance")),1)]),_:1})]))),128))])):M("",!0)]),e.templateConfig.type!=="stdio"?(i(),b("div",Bn,[n("div",Un,[n("label",Rn,o(r.$t("serverDetail.config.headers")),1),s(N,{size:"small",icon:y(fe),onClick:oe},{default:f(()=>[E(o(r.$t("serverDetail.config.addHeader")),1)]),_:1},8,["icon"])]),se.value?(i(),b("div",An,[(i(!0),b(Z,null,K(e.templateConfig.headers,(D,k)=>(i(),b("div",{key:`template-header-${k}`,class:"flex gap-2 items-start",style:{display:"flex",gap:"0.5rem",width:"100%"}},[s(Y,{"model-value":k,disabled:"",style:{width:"30%","min-width":"150px"}},null,8,["model-value"]),s(Y,{"model-value":e.templateConfig.headers[k],disabled:"",style:{flex:"1"}},null,8,["model-value"]),n("span",zn,o(r.$t("serverDetail.instanceConfig.fromTemplate")),1)]))),128))])):M("",!0),l.value.headers&&Object.keys(l.value.headers).length>0?(i(),b("div",Nn,[(i(!0),b(Z,null,K(l.value.headers,(D,k)=>(i(),b("div",{key:$.value[k],class:"flex gap-2 items-start",style:{display:"flex",gap:"0.5rem",width:"100%"}},[s(Y,{"model-value":k,style:{width:"30%","min-width":"150px"},placeholder:r.$t("addServer.keyPlaceholder"),"onUpdate:modelValue":A=>J(k,A)},null,8,["model-value","placeholder","onUpdate:modelValue"]),s(Y,{modelValue:l.value.headers[k],"onUpdate:modelValue":A=>l.value.headers[k]=A,style:{flex:"1"},placeholder:r.$t("addServer.valuePlaceholder")},null,8,["modelValue","onUpdate:modelValue","placeholder"]),s(N,{size:"small",type:"danger",icon:y(ie),onClick:A=>re(k)},null,8,["icon","onClick"]),s(ve,{size:"small",type:"success"},{default:f(()=>[E(o(r.$t("common.instance")),1)]),_:1})]))),128))])):M("",!0)])):M("",!0),n("div",jn,[n("label",On,o(r.$t("serverDetail.config.timeout")),1),n("div",Mn,[s(Re,{"model-value":e.templateConfig.timeout?e.templateConfig.timeout/1e3:60,disabled:"",min:1,max:3600},null,8,["model-value"]),n("span",Pn,o(r.$t("serverDetail.instanceConfig.fromTemplate")),1)])]),n("div",Fn,[n("label",Ln,o(r.$t("common.description")),1),n("div",Hn,[s(Y,{"model-value":e.templateConfig.description,type:"textarea",rows:3,disabled:"",class:"flex-1"},null,8,["model-value"]),n("span",Jn,o(r.$t("serverDetail.instanceConfig.fromTemplate")),1)])]),e.templateConfig.type!=="stdio"?(i(),b("div",qn,[n("div",Wn,[n("label",Gn,o(r.$t("serverDetail.config.proxy")),1),l.value.proxy?(i(),H(N,{key:1,size:"small",type:"danger",icon:y(ie),onClick:z},{default:f(()=>[E(o(r.$t("serverDetail.config.removeProxy")),1)]),_:1},8,["icon"])):(i(),H(N,{key:0,size:"small",icon:y(fe),onClick:z},{default:f(()=>[E(o(r.$t("serverDetail.config.addProxy")),1)]),_:1},8,["icon"]))]),e.templateConfig.proxy&&!l.value.proxy?(i(),b("div",Qn,[n("div",Xn,[s(Y,{"model-value":e.templateConfig.proxy.url,disabled:""},null,8,["model-value"]),n("span",Zn,o(r.$t("serverDetail.instanceConfig.fromTemplate")),1)])])):M("",!0),l.value.proxy?(i(),b("div",Yn,[s(Y,{modelValue:l.value.proxy.url,"onUpdate:modelValue":V[1]||(V[1]=D=>l.value.proxy.url=D),placeholder:r.$t("serverDetail.config.proxyPlaceholder")},null,8,["modelValue","placeholder"]),s(ve,{size:"small",type:"success"},{default:f(()=>[E(o(r.$t("common.instance")),1)]),_:1})])):M("",!0)])):M("",!0),n("div",Kn,[n("div",es,[n("label",ts,o(r.$t("serverDetail.config.tags")),1),s(N,{size:"small",icon:y(fe),onClick:T},{default:f(()=>[E(o(r.$t("common.addTag")),1)]),_:1},8,["icon"])]),e.systemTagDefinitions.length===0?(i(),b("div",as,[V[5]||(V[5]=n("p",null,"暂无标签定义",-1)),s(N,{size:"small",type:"primary",onClick:Ue},{default:f(()=>[...V[4]||(V[4]=[E(" 前往标签设置 ",-1)])]),_:1})])):l.value.tags&&Object.keys(l.value.tags).length>0?(i(),b("div",ls,[(i(!0),b(Z,null,K(l.value.tags,(D,k)=>(i(),b("div",{key:L.value[k],class:"flex gap-2 items-start",style:{display:"flex",gap:"0.5rem",width:"100%"}},[s(Ee,{modelValue:R.value[k],"onUpdate:modelValue":A=>R.value[k]=A,style:{width:"30%","min-width":"150px"},filterable:"",placeholder:"选择标签键",onChange:A=>ae(k,A)},{default:f(()=>[(i(!0),b(Z,null,K(e.systemTagDefinitions,A=>(i(),H(De,{key:A.key,label:A.key,value:A.key},{default:f(()=>[n("span",null,o(A.key),1),n("span",ns,o(A.type),1)]),_:2},1032,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","onChange"]),R.value[k]&&ye(R.value[k])==="enum"?(i(),H(Ee,{key:0,modelValue:l.value.tags[k],"onUpdate:modelValue":A=>l.value.tags[k]=A,style:{flex:"1"},filterable:"",placeholder:"选择标签值"},{default:f(()=>[(i(!0),b(Z,null,K(Te(R.value[k]),A=>(i(),H(De,{key:A,label:A,value:A},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):(i(),H(Y,{key:1,modelValue:l.value.tags[k],"onUpdate:modelValue":A=>l.value.tags[k]=A,style:{flex:"1"},placeholder:R.value[k]?$e(R.value[k]):"输入标签值"},null,8,["modelValue","onUpdate:modelValue","placeholder"])),s(N,{size:"small",type:"danger",icon:y(ie),onClick:A=>G(k)},null,8,["icon","onClick"]),s(ve,{size:"small",type:"success"},{default:f(()=>[E(o(r.$t("common.instance")),1)]),_:1})]))),128))])):M("",!0)]),n("div",ss,[n("label",os,o(r.$t("serverDetail.config.autoStart")),1),n("div",rs,[s(F,{modelValue:l.value.enabled,"onUpdate:modelValue":V[2]||(V[2]=D=>l.value.enabled=D)},null,8,["modelValue"]),s(ve,{size:"small",type:"success"},{default:f(()=>[E(o(r.$t("common.instance")),1)]),_:1})])]),n("div",is,[s(N,{type:"primary",onClick:p},{default:f(()=>[E(o(r.$t("serverDetail.config.save")),1)]),_:1})])]),s(nn,{modelValue:v.value,"onUpdate:modelValue":V[3]||(V[3]=D=>v.value=D),"merged-config":ce.value},null,8,["modelValue","merged-config"])])}}}),cs=Ie(us,[["__scopeId","data-v-64c5af9a"]]);function ds(e){const m=Le(),a=Jt(),d=Pe(),t=O("config"),g=O(null),u=O("config");function S(){const w=a.name;return w==="server-detail-tools"?"tools":w==="server-detail-resources"?"resources":"config"}function U(w){if(!e.value?.name)return;const _=w,$=_==="tools"?"server-detail-tools":_==="resources"?"server-detail-resources":"server-detail-config";m.push({name:$,params:{name:e.value.name}})}function v(){g.value=null}function l(w){g.value=w}function h(){a.query.selection==="template"?g.value=null:a.query.instanceIndex!==void 0?g.value=parseInt(a.query.instanceIndex,10):g.value=null}function B(){a.query.instanceTab==="logs"?u.value="logs":u.value="config"}return Ht(()=>{const w=a.params.name;if(w){const _=d.servers.find($=>$.name===w);_&&d.selectServer(_.id)}t.value=S(),h(),B()}),ee(()=>a.params.name,w=>{if(w){const _=d.servers.find($=>$.name===w);_&&d.selectServer(_.id)}}),ee(()=>a.name,()=>{t.value=S(),h(),B()}),ee(u,w=>{if(!e.value?.name)return;const _={...a.query},$={};for(const[L,R]of Object.entries(_))R!=null&&($[L]=R);w==="config"?delete $.instanceTab:$.instanceTab=w,m.replace({name:a.name,params:a.params,query:$})}),ee(()=>d.servers.length,()=>{const w=a.params.name;if(w&&!d.selectedServer){const _=d.servers.find($=>$.name===w);_&&d.selectServer(_.id)}h(),B()}),ee(()=>e.value?.id,(w,_)=>{w&&w!==_&&(t.value=S())},{immediate:!0}),ee(g,w=>{if(!e.value?.name)return;const _={...a.query},$={};for(const[L,R]of Object.entries(_))R!=null&&($[L]=R);w===null?($.selection="template",delete $.instanceIndex):($.instanceIndex=String(w),delete $.selection),m.replace({name:a.name,params:a.params,query:$})}),{activeTopTab:t,selectedInstanceIndex:g,activeInstanceTab:u,getTabFromRoute:S,navigateToTab:U,handleSelectTemplate:v,handleSelectInstance:l}}function ms(e,m){const a=Pe(),{t:d}=me(),t=q(()=>(console.log("[useServerInstances] Computing allServers, store.servers:",a.servers),a.servers.filter(c=>c.name===e.value?.name))),g=q(()=>(console.log("[useServerInstances] Computing serverInstances"),e.value?.rawV11Config?.instances?e.value.rawV11Config.instances.map((c,C)=>{const x=t.value.find(J=>J.instances?.some(T=>T.id===c.id))?.instances?.find(J=>J.id===c.id);let W="offline",oe;const re=e.value?.rawV11Config?.template?.type;return x?.status?(W=x.status,oe=x.pid??void 0):W="offline",{id:c.id,timestamp:c.timestamp??Date.now(),index:c.index??C,displayName:c.displayName,status:W,pid:oe,transportType:re}}):(console.log("[useServerInstances] No instances found in rawV11Config"),[]))),u=q(()=>m.value===null?null:g.value.find(c=>c.index===m.value)||null),S=q(()=>{const c=u.value;if(!c||!e.value?.rawV11Config?.instances)return{args:[],env:{},headers:{},tags:{},enabled:!0};let C;return c.index!==void 0&&(C=e.value.rawV11Config.instances.find(P=>P.index===c.index)),C||(C=e.value.rawV11Config.instances.find(P=>P.id===c.id)),C?{args:C.args??[],env:C.env??{},headers:C.headers??{},tags:C.tags??{},displayName:C.displayName,enabled:C.enabled!==void 0?C.enabled:!0}:{args:[],env:{},headers:{},tags:{},displayName:c.displayName,enabled:!0}}),U=q(()=>e.value?.rawV11Config?.template?e.value.rawV11Config.template:{type:"stdio",args:[],env:{},headers:{},timeout:6e4,aggregatedTools:[]});function v(){return m.value===null?"offline":g.value.find(C=>C.index===m.value)?.status||"offline"}function l(){return m.value===null?null:g.value.find(C=>C.index===m.value)?.id||null}async function h(c){try{console.log("[startServerInstance] Starting instance:",c),a.updateServerStatus(c,"starting"),await a.startServer(c),I.success(d("action.started"))}catch(C){console.error("[startServerInstance] Error:",C),C instanceof Error?I.error(C.message):I.error(String(C))}}async function B(){const c=l();if(!c){I.warning(d("serverDetail.noInstanceSelected"));return}await h(c)}async function w(c){try{console.log("[stopServerInstance] Stopping instance:",c),await a.stopServer(c),I.success(d("action.stopped"))}catch(C){console.error("[stopServerInstance] Error:",C),C instanceof Error?I.error(C.message):I.error(String(C))}}async function _(){const c=l();if(!c){I.warning(d("serverDetail.noInstanceSelected"));return}await w(c)}async function $(c){try{console.log("[restartServerInstance] Restarting instance:",c),a.updateServerStatus(c,"starting");const C=g.value.find(P=>P.id===c);C&&C.status==="online"&&await a.stopServer(c),await a.startServer(c),I.success(d("action.restarted"))}catch(C){console.error("[restartServerInstance] Error:",C),C instanceof Error?I.error(C.message):I.error(String(C))}}async function L(){const c=l();if(!c){I.warning(d("serverDetail.noInstanceSelected"));return}await $(c)}async function R(){if(e.value?.name)try{await a.startAllServerInstances(e.value.name),I.success(d("action.started"))}catch(c){c instanceof Error?I.error(c.message):I.error(String(c))}}async function te(){if(e.value?.name)try{await a.stopAllServerInstances(e.value.name),I.success(d("action.stopped"))}catch(c){c instanceof Error?I.error(c.message):I.error(String(c))}}async function ne(){if(e.value?.name)try{await a.restartAllServerInstances(e.value.name),I.success(d("action.restarted"))}catch(c){c instanceof Error?I.error(c.message):I.error(String(c))}}async function se(){if(e.value?.name)try{const c=`temp-${Date.now()}`,C=e.value.rawV11Config?.instances||[],P=C.length>0?Math.max(...C.map(W=>W.index??0)):-1,x={id:c,timestamp:Date.now(),index:P+1,enabled:!0,args:[],env:{},headers:{},tags:{}};e.value.rawV11Config&&(e.value.rawV11Config.instances||(e.value.rawV11Config.instances=[]),e.value.rawV11Config.instances.push(x)),await a.addServerInstance(e.value.name),I.success(d("action.instanceAdded"))}catch(c){c instanceof Error?I.error(c.message):I.error(String(c))}}async function ce(c,C){if(e.value?.name)try{const x=e.value.rawV11Config?.instances?.find(W=>W.index===c);x&&(x.displayName=C),await a.updateServerInstance(e.value.name,c,{displayName:C}),I.success(d("action.displayNameUpdated"))}catch(P){P instanceof Error?I.error(P.message):I.error(String(P))}}async function j(c){if(e.value?.name)try{await mt.confirm(d("serverDetail.deleteInstanceConfirm"),d("action.delete"),{confirmButtonText:d("action.delete"),cancelButtonText:d("action.cancel"),type:"warning"});const C=e.value.rawV11Config?.instances;if(C){const P=C.findIndex(x=>x.index===c);P!==-1&&C.splice(P,1)}m.value===c&&(m.value=null),await a.removeServerInstance(e.value.name,c),I.success(d("action.instanceDeleted"))}catch(C){C!=="cancel"&&(C instanceof Error?I.error(C.message||"Failed to delete instance"):I.error(String(C)||"Failed to delete instance"))}}async function p(){if(e.value?.name)try{await a.reassignInstanceIndexes(e.value.name),I.success(d("action.indexesReassigned"))}catch(c){c instanceof Error?I.error(c.message):I.error(String(c))}}async function z(c){if(!(!e.value?.name||m.value===null))try{const C=m.value,x=e.value.rawV11Config?.instances?.find(W=>W.index===C);x&&(c.args!==void 0&&(x.args=c.args),c.env!==void 0&&(x.env=c.env),c.headers!==void 0&&(x.headers=c.headers),c.tags!==void 0&&(x.tags=c.tags),c.proxy!==void 0&&(x.proxy=c.proxy),c.displayName!==void 0&&(x.displayName=c.displayName),c.enabled!==void 0&&(x.enabled=c.enabled)),await a.updateServerInstance(e.value.name,C,c),I.success(d("action.configSaved"))}catch(C){C instanceof Error?I.error(C.message):I.error(String(C))}}return{serverInstances:g,selectedInstance:u,selectedInstanceConfig:S,templateConfigForInstance:U,allServers:t,getSelectedInstanceStatus:v,getSelectedInstanceServerId:l,startSelectedInstance:B,stopSelectedInstance:_,restartSelectedInstance:L,startAllInstances:R,stopAllInstances:te,restartAllInstances:ne,handleAddInstance:se,handleUpdateDisplayName:ce,handleDeleteInstance:j,handleReassignIndexes:p,handleUpdateInstanceConfig:z}}function fs(e){const m=Le(),a=O(null),d=O(!1),t=O(!1),g=O(null),u=O(!1),S=O(null),U=O(null);function v(B){e.value&&m.push({name:"resource-detail",params:{name:e.value.name},query:{uri:B.uri,name:B.name,mimeType:B.mimeType}})}function l(B){g.value=B,t.value=!1,d.value=!0}function h(B){const w=S.value;w&&v(w),S.value=null,u.value=!1,U.value=null}return ee(S,B=>{B!==null&&(u.value=!0,S.value=null)}),{showInstanceSelectForTool:t,selectedInstanceForTool:g,showCallDialog:d,pendingTool:a,showInstanceSelectForResourceDialog:u,showInstanceSelectForResource:S,selectedInstanceForResource:U,callToolWithInstance:l,viewResourceWithInstance:h}}const vs={key:0,class:"server-detail py-6 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto w-full h-full flex flex-col overflow-hidden transition-colors duration-300"},ps={class:"custom-tabs-label"},gs={class:"flex h-full gap-4 mt-4"},ys={class:"w-1/3 border-r border-gray-200 dark:border-gray-700 pr-4 overflow-y-auto"},hs={class:"flex-1 min-h-0 overflow-y-auto pl-4 pr-4"},bs={key:0,class:"h-full flex flex-col min-h-0"},_s={class:"flex-1 min-h-0 overflow-hidden"},$s={key:1,class:"h-full flex flex-col min-h-0"},Cs={class:"flex-1 min-h-0 overflow-hidden"},ws={class:"custom-tabs-label"},ks={class:"flex-1 min-h-0 overflow-hidden"},xs={class:"custom-tabs-label"},Ss={key:2,class:"flex-1 flex items-center justify-center text-gray-400"},Vs={class:"custom-tabs-label"},Is={class:"custom-tabs-label"},Ts={key:1,class:"h-full flex items-center justify-center text-gray-400"},Ds=ue({__name:"ServerDetail",setup(e){const m=Pe();Et();const a=Bt(),{config:d}=qt(a),{t}=me(),g=Le(),u=q(()=>m.selectedServer),S=q(()=>d.value?.tagDefinitions||[]),{activeTopTab:U,selectedInstanceIndex:v,activeInstanceTab:l,navigateToTab:h,handleSelectTemplate:B,handleSelectInstance:w}=ds(u),{serverInstances:_,selectedInstanceConfig:$,templateConfigForInstance:L,getSelectedInstanceStatus:R,startSelectedInstance:te,stopSelectedInstance:ne,restartSelectedInstance:se,startAllInstances:ce,stopAllInstances:j,restartAllInstances:p,handleAddInstance:z,handleUpdateDisplayName:c,handleDeleteInstance:C,handleReassignIndexes:P,handleUpdateInstanceConfig:x}=ms(u,v),{showInstanceSelectForTool:W,selectedInstanceForTool:oe,showCallDialog:re,pendingTool:J,showInstanceSelectForResourceDialog:T,showInstanceSelectForResource:G,callToolWithInstance:ae,viewResourceWithInstance:ye}=fs(u),Te=O(!0),$e=O(!1),Ue=O(null);ee([U,()=>u.value?.name],async([F,D])=>{D&&(F==="tools"?await m.fetchTools(D):F==="resources"&&await m.fetchResources(D))},{immediate:!0}),ee([l,()=>u.value?.name,v],([F,D,k])=>{D&&F==="logs"&&m.fetchLogs(D,k??0)});function r(){m.selectedServerId=null,g.push({name:"servers"})}const V=async()=>{if(u.value)try{await mt.confirm(t("serverDetail.deleteConfirm"),t("action.delete"),{confirmButtonText:t("action.delete"),cancelButtonText:t("action.cancel"),type:"warning"}),await m.deleteServer(u.value.id),I.success(t("action.serverDeleted")),m.selectedServerId=null,g.push({name:"servers"})}catch(F){F!=="cancel"&&(F instanceof Error?I.error(F.message||"Failed to delete server"):I.error(String(F)||"Failed to delete server"))}},N=async(F,D)=>{if(!u.value)return;let k=u.value.config.aggregatedTools;k==null&&(u.value.tools?k=u.value.tools.map(A=>A.name):k=[]),D?k.includes(F)||(k=[...k,F]):k=k.filter(A=>A!==F),u.value.config.aggregatedTools=k;try{await m.updateServer(u.value.id,{config:u.value.config}),I.success(t("action.configSaved"))}catch(A){A instanceof Error?I.error(A.message):I.error(String(A))}},le=async()=>{if(u.value)try{await m.updateServer(u.value.id,{config:u.value.rawV11Config?.template}),I.success(t("action.configSaved"))}catch(F){F instanceof Error?I.error(F.message):I.error(String(F))}},ve=F=>{u.value?.rawV11Config&&(u.value.rawV11Config.template=F)},Y=()=>{$e.value=!0},Re=async F=>{u.value&&(u.value.rawV11Config&&(u.value.rawV11Config.template={...u.value.rawV11Config.template,...F}),await m.updateServer(u.value.id,{config:u.value.rawV11Config?.template}))},De=async()=>{u.value&&(await m.clearLogs(u.value.id),I.success(t("action.logsCleared")))},Ee=()=>{if(u.value){const F=u.value.logs.map(D=>`${ut(D.timestamp)} [${D.level.toUpperCase()}] ${D.message}`).join(`
2
- `);navigator.clipboard.writeText(F),I.success(t("action.logsCopied"))}};return(F,D)=>{const k=Se,A=Nt,Ge=zt;return u.value?(i(),b("div",vs,[s(xa,{server:u.value,onBack:r,onDelete:V,onRestartAll:y(p),onStartAll:y(ce),onStopAll:y(j)},null,8,["server","onRestartAll","onStartAll","onStopAll"]),s(Ge,{"model-value":y(U),onTabChange:D[6]||(D[6]=X=>y(h)(String(X))),class:"flex-1 flex flex-col overflow-hidden custom-tabs"},{default:f(()=>[s(A,{name:"config",class:"h-full flex flex-col"},{label:f(()=>[n("span",ps,[s(k,null,{default:f(()=>[s(y(et))]),_:1}),n("span",null,o(F.$t("common.config"))+" ("+o(y(_).length)+")",1)])]),default:f(()=>[n("div",gs,[n("div",ys,[s(Yl,{instances:y(_),"selected-index":y(v),"server-name":u.value.name,"show-template-node":!0,"template-selected":y(v)===null,onSelect:y(w),onSelectTemplate:y(B),onAdd:y(z),onUpdateDisplayName:y(c),onDelete:y(C),onReassignIndexes:y(P)},null,8,["instances","selected-index","server-name","template-selected","onSelect","onSelectTemplate","onAdd","onUpdateDisplayName","onDelete","onReassignIndexes"])]),n("div",hs,[y(v)===null?(i(),b("div",bs,[n("div",_s,[s(nl,{config:u.value.rawV11Config||{template:{type:"stdio",args:[],env:{},headers:{},timeout:6e4,aggregatedTools:[],instanceSelectionStrategy:"random"},instances:[],tagDefinitions:[]},"onUpdate:template":ve,onSave:le,onEditJson:Y},null,8,["config"])])])):y(v)!==null?(i(),b("div",$s,[n("div",Cs,[s(Ge,{modelValue:y(l),"onUpdate:modelValue":D[2]||(D[2]=X=>Be(l)?l.value=X:null),class:"instance-detail-tabs h-full flex flex-col"},{default:f(()=>[s(A,{name:"config",class:"h-full flex flex-col min-h-0"},{label:f(()=>[n("span",ws,[s(k,null,{default:f(()=>[s(y(et))]),_:1}),n("span",null,o(F.$t("common.config")),1)])]),default:f(()=>[n("div",ks,[s(cs,{"template-config":y(L),"instance-config":y($),"server-name":u.value.name,"instance-status":y(R)(),"system-tag-definitions":S.value,onUpdate:y(x),onStartInstance:y(te),onStopInstance:y(ne),onRestartInstance:y(se),onViewLogs:D[0]||(D[0]=X=>l.value="logs")},null,8,["template-config","instance-config","server-name","instance-status","system-tag-definitions","onUpdate","onStartInstance","onStopInstance","onRestartInstance"])])]),_:1}),s(A,{name:"logs",class:"h-full flex flex-col"},{label:f(()=>[n("span",xs,[s(k,null,{default:f(()=>[s(y(Ut))]),_:1}),n("span",null,o(F.$t("common.logs")),1)])]),default:f(()=>[s(il,{logs:u.value.logs,"auto-scroll":Te.value,"onUpdate:autoScroll":D[1]||(D[1]=X=>Te.value=X),onClear:De,onCopy:Ee},null,8,["logs","auto-scroll"])]),_:1})]),_:1},8,["modelValue"])])])):(i(),b("div",Ss,o(F.$t("serverDetail.noSelection")),1))])])]),_:1}),s(A,{name:"tools",class:"h-full flex flex-col"},{label:f(()=>[n("span",Vs,[s(k,null,{default:f(()=>[s(y(Rt))]),_:1}),n("span",null,o(F.$t("common.tools"))+" ("+o(u.value.toolsCount||0)+")",1)])]),default:f(()=>[s(Sl,{tools:u.value.tools||[],"allowed-tools":u.value.config.aggregatedTools,onSelectTool:D[3]||(D[3]=X=>Ue.value=X),onUpdateToolVisibility:N,onCallTool:D[4]||(D[4]=X=>{W.value=!0,J.value=X})},null,8,["tools","allowed-tools"])]),_:1}),s(A,{name:"resources",class:"h-full flex flex-col"},{label:f(()=>[n("span",Is,[s(k,null,{default:f(()=>[s(y(At))]),_:1}),n("span",null,o(F.$t("common.resources"))+" ("+o(u.value.resourcesCount||0)+")",1)])]),default:f(()=>[s(El,{resources:u.value.resources,onViewResource:D[5]||(D[5]=X=>{G.value=X})},null,8,["resources"])]),_:1})]),_:1},8,["model-value"]),s(Ul,{modelValue:$e.value,"onUpdate:modelValue":D[7]||(D[7]=X=>$e.value=X),config:u.value.config,"server-name":u.value.name,onSave:Re},null,8,["modelValue","config","server-name"]),s(nt,{modelValue:y(W),"onUpdate:modelValue":D[8]||(D[8]=X=>Be(W)?W.value=X:null),instances:y(_),title:F.$t("serverDetail.selectInstanceForTool"),onConfirm:y(ae)},null,8,["modelValue","instances","title","onConfirm"]),s(nt,{modelValue:y(T),"onUpdate:modelValue":D[9]||(D[9]=X=>Be(T)?T.value=X:null),instances:y(_),title:F.$t("serverDetail.selectInstanceForResource"),onConfirm:y(ye)},null,8,["modelValue","instances","title","onConfirm"]),y(J)&&y(oe)!==null?(i(),H(na,{key:0,modelValue:y(re),"onUpdate:modelValue":D[10]||(D[10]=X=>Be(re)?re.value=X:null),"server-name":u.value.name,"tool-name":y(J).name,description:y(J).description,"input-schema":y(J).inputSchema},null,8,["modelValue","server-name","tool-name","description","input-schema"])):M("",!0)])):(i(),b("div",Ts,o(F.$t("serverDetail.noServerSelected")),1))}}}),qs=Ie(Ds,[["__scopeId","data-v-3cac3428"]]);export{qs as default};
@@ -1 +0,0 @@
1
- import{u as H,U as J,b as M,l as U,j as Q,V as W,W as j,s as X,X as K}from"./index-kC4mf0Vo.js";import{a as Y}from"./el-skeleton-item-CupTKK6n.js";import{E as Z}from"./el-input-C85p6Nqj.js";import{t as P,A as i,C as t,J as E,$ as n,V as R,x as a,aa as ee,r as m,c as te,j as se,O as l,G as y,u as g,a0 as z,H as F,L,P as T,ai as V,y as S}from"./vue-vendor-Dwcr0jep.js";import{T as oe}from"./ToolCallDialog-DYEdhnCk.js";import{_ as ae}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./event-BB_Ol6Sd.js";import"./el-overlay-B_CxiSem.js";const le={class:"min-w-0 mb-3"},ne={class:"flex items-center gap-2 mb-2"},re=["title"],ie=["title"],O=P({__name:"ToolCard",props:{title:{},description:{},tagName:{},tagClass:{}},emits:["call"],setup(c){return(f,v)=>(a(),i("div",{class:"bg-white dark:bg-[#1e293b] border border-gray-200 dark:border-gray-700 rounded-lg p-4 flex flex-col justify-between shadow-sm hover:shadow-md transition-shadow h-full cursor-pointer",onClick:v[0]||(v[0]=_=>f.$emit("call"))},[t("div",le,[t("div",ne,[c.tagName?(a(),i("span",{key:0,class:E(["shrink-0 px-2 py-0.5 rounded-full text-xs font-medium whitespace-nowrap",c.tagClass||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"])},n(c.tagName),3)):R("",!0),t("span",{class:"font-bold text-gray-900 dark:text-gray-100 font-mono text-base break-all",title:c.title},n(c.title),9,re)]),t("p",{class:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",title:c.description},n(c.description||f.$t("tools.noDescription")),9,ie)])]))}}),ce={class:"tools-view py-6 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto w-full h-full flex flex-col overflow-hidden bg-gray-50 dark:bg-[#0f172a] transition-colors duration-300"},de={class:"mb-6 shrink-0"},ue={class:"text-2xl font-semibold text-gray-900 dark:text-white mb-4"},me={class:"relative"},ve={class:"flex-1 overflow-y-auto custom-scrollbar space-y-8 pr-2"},pe={class:"text-lg font-bold text-gray-900 dark:text-white"},ge={class:"text-sm font-normal text-gray-500 ml-2"},fe={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-8 transition-all duration-300"},he={class:"flex items-center gap-2 mb-4"},xe={class:"text-lg font-bold text-gray-900 dark:text-white"},ye={class:"text-sm font-normal text-gray-500 ml-2"},_e={key:0,class:"space-y-4"},be={key:1,class:"text-center py-8 text-gray-500"},ke={key:2,class:"space-y-6"},we=["onClick"],Ce={class:"text-xs bg-gray-100 dark:bg-gray-800 px-2 py-0.5 rounded-full"},$e={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 transition-all duration-300"},Ne=P({__name:"ToolsView",setup(c){const{t:f}=ee(),v=m(""),_=m(!1),D=m([]),k=H(),w=m([]),C=m(!1),p=m(null),h=m(new Set),b=m(!1);function q(e){h.value.has(e)?h.value.delete(e):h.value.add(e)}async function A(){try{const e=await U.get("/web/hub-tools/system");w.value=e.map(s=>({...s,serverName:"mcp-hub-lite"})).sort((s,d)=>s.name.localeCompare(d.name))}catch(e){console.error("Failed to fetch system tools:",e)}}function I(e){p.value={...e,serverName:e.serverName},C.value=!0}async function B(){_.value=!0;try{const e=await U.get(`/web/search?q=${encodeURIComponent(v.value)}`);D.value=e.results||[]}catch(e){console.error("Failed to fetch tools:",e)}finally{_.value=!1}}function G(){B()}const $=te(()=>{const e={};return D.value.forEach(s=>{if(!s?.tool)return;const x=k.servers.find(N=>N.name===s.tool.serverName)?.status==="online"?f("tools.online"):f("tools.offline"),r=s.tool.serverName?`${s.tool.serverName} (${x})`:"Unknown";e[r]||(e[r]=[]),e[r].push(s)}),Object.entries(e).map(([s,d])=>({serverName:s,tools:d.sort((x,r)=>x.tool.name.localeCompare(r.tool.name))})).sort((s,d)=>s.serverName.localeCompare(d.serverName))});return se(()=>{A(),B(),k.servers.length===0&&k.fetchServers()}),(e,s)=>{const d=Q,x=Z,r=M,N=Y;return a(),i("div",ce,[t("div",de,[t("h2",ue,n(e.$t("tools.title")),1),t("div",me,[l(x,{modelValue:v.value,"onUpdate:modelValue":s[0]||(s[0]=o=>v.value=o),placeholder:e.$t("tools.searchPlaceholder"),class:"w-full",size:"large","prefix-icon":g(J),onInput:G},{append:y(()=>[l(d,{icon:g(W)},null,8,["icon"])]),_:1},8,["modelValue","placeholder","prefix-icon"])])]),t("div",ve,[t("section",null,[t("div",{class:"flex items-center gap-2 mb-4 cursor-pointer select-none hover:text-gray-700 dark:hover:text-gray-200 transition-colors",onClick:s[1]||(s[1]=o=>b.value=!b.value)},[l(r,{class:E(["transition-transform duration-200",{"-rotate-90":b.value}])},{default:y(()=>[l(g(j))]),_:1},8,["class"]),l(r,{class:"text-gray-900 dark:text-white",size:20},{default:y(()=>[l(g(X))]),_:1}),t("h3",pe,[z(n(e.$t("tools.systemTools"))+" ",1),t("span",ge,"("+n(w.value.length)+")",1)])]),F(t("div",fe,[(a(!0),i(T,null,V(w.value,o=>(a(),S(O,{key:o.name,title:o.name,description:o.description,"tag-name":e.$t("tools.systemTag"),"tag-class":"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",onCall:u=>I(o)},null,8,["title","description","tag-name","onCall"]))),128))],512),[[L,!b.value]])]),t("section",null,[t("div",he,[l(r,{class:"text-gray-900 dark:text-white",size:20},{default:y(()=>[l(g(K))]),_:1}),t("h3",xe,[z(n(e.$t("tools.aggregatedTools"))+" ",1),t("span",ye,"("+n($.value.reduce((o,u)=>o+u.tools.length,0))+")",1)])]),_.value?(a(),i("div",_e,[l(N,{animated:"",count:3})])):$.value.length===0?(a(),i("div",be,n(e.$t("tools.noToolsFound")),1)):(a(),i("div",ke,[(a(!0),i(T,null,V($.value,o=>(a(),i("div",{key:o.serverName,class:"space-y-3"},[t("div",{class:"flex items-center gap-2 text-sm font-medium text-gray-500 dark:text-gray-400 px-1 cursor-pointer select-none hover:text-gray-700 dark:hover:text-gray-200 transition-colors",onClick:u=>q(o.serverName)},[l(r,{class:E(["transition-transform duration-200",{"-rotate-90":h.value.has(o.serverName)}])},{default:y(()=>[l(g(j))]),_:1},8,["class"]),t("span",null,n(o.serverName),1),t("span",Ce,n(o.tools.length),1)],8,we),F(t("div",$e,[(a(!0),i(T,null,V(o.tools,u=>(a(),S(O,{key:u.tool.name,title:u.tool.name,description:u.tool.description,onCall:Te=>I(u.tool)},null,8,["title","description","onCall"]))),128))],512),[[L,!h.value.has(o.serverName)]])]))),128))]))])]),p.value?(a(),S(oe,{key:0,modelValue:C.value,"onUpdate:modelValue":s[2]||(s[2]=o=>C.value=o),"server-name":p.value.serverName,"tool-name":p.value.name,description:p.value.description,"input-schema":p.value.inputSchema},null,8,["modelValue","server-name","tool-name","description","input-schema"])):R("",!0)])}}}),ze=ae(Ne,[["__scopeId","data-v-dfaeaf82"]]);export{ze as default};