agent-discover 1.0.8 → 1.0.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.
package/dist/ui/app.js CHANGED
@@ -6,6 +6,13 @@
6
6
  (function () {
7
7
  'use strict';
8
8
 
9
+ var AD = (window.AD = window.AD || {});
10
+ AD._baseUrl = '';
11
+ AD._fetch = function (url, opts) {
12
+ return fetch(AD._baseUrl + url, opts);
13
+ };
14
+ AD._wsUrl = null;
15
+
9
16
  let state = { servers: [], active: [], version: '0.0.0' };
10
17
  let ws = null;
11
18
  let browseResults = [];
@@ -19,7 +26,7 @@
19
26
 
20
27
  function connect() {
21
28
  const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
22
- ws = new WebSocket(proto + '//' + location.host);
29
+ ws = new WebSocket(proto + '//' + (AD._wsUrl || location.host));
23
30
 
24
31
  ws.onopen = function () {
25
32
  setConnectionStatus('connected', 'Connected');
@@ -138,7 +145,7 @@
138
145
  var el = document.getElementById('browse-list');
139
146
  el.innerHTML = '<div class="loading">Searching...</div>';
140
147
 
141
- fetch('/api/browse?query=' + encodeURIComponent(query) + '&limit=20')
148
+ AD._fetch('/api/browse?query=' + encodeURIComponent(query) + '&limit=20')
142
149
  .then(function (r) {
143
150
  return r.json();
144
151
  })
@@ -576,7 +583,7 @@
576
583
  // -------------------------------------------------------------------------
577
584
 
578
585
  window.__activateServer = function (id) {
579
- fetch('/api/servers/' + id + '/activate', { method: 'POST' })
586
+ AD._fetch('/api/servers/' + id + '/activate', { method: 'POST' })
580
587
  .then(function (r) {
581
588
  return r.json().then(function (data) {
582
589
  if (data.error) {
@@ -592,7 +599,7 @@
592
599
  };
593
600
 
594
601
  window.__deactivateServer = function (id) {
595
- fetch('/api/servers/' + id + '/deactivate', { method: 'POST' })
602
+ AD._fetch('/api/servers/' + id + '/deactivate', { method: 'POST' })
596
603
  .then(function (r) {
597
604
  return r.json();
598
605
  })
@@ -606,7 +613,7 @@
606
613
 
607
614
  window.__deleteServer = function (id, name) {
608
615
  if (!confirm('Delete server "' + name + '"?')) return;
609
- fetch('/api/servers/' + id, { method: 'DELETE' })
616
+ AD._fetch('/api/servers/' + id, { method: 'DELETE' })
610
617
  .then(function (r) {
611
618
  return r.json();
612
619
  })
@@ -649,7 +656,7 @@
649
656
  serverData.args = ['-y', pkg ? pkg.name || server.name : server.name || safeName];
650
657
  }
651
658
 
652
- fetch('/api/servers', {
659
+ AD._fetch('/api/servers', {
653
660
  method: 'POST',
654
661
  headers: { 'Content-Type': 'application/json' },
655
662
  body: JSON.stringify(serverData),
@@ -662,7 +669,7 @@
662
669
  if (serverData.command === 'npx' && data && data.id) {
663
670
  btn.innerHTML =
664
671
  '<span class="material-symbols-outlined" style="font-size:14px">downloading</span>Downloading...';
665
- return fetch('/api/servers/' + data.id + '/preinstall', { method: 'POST' })
672
+ return AD._fetch('/api/servers/' + data.id + '/preinstall', { method: 'POST' })
666
673
  .then(function () {
667
674
  btn.innerHTML =
668
675
  '<span class="material-symbols-outlined" style="font-size:14px">check_circle</span>Ready';
@@ -705,7 +712,7 @@
705
712
  '<span class="material-symbols-outlined" style="font-size:14px">hourglass_top</span> Checking...';
706
713
  }
707
714
 
708
- fetch('/api/npm-check?package=' + encodeURIComponent(pkg))
715
+ AD._fetch('/api/npm-check?package=' + encodeURIComponent(pkg))
709
716
  .then(function (r) {
710
717
  return r.json();
711
718
  })
@@ -720,7 +727,7 @@
720
727
  }
721
728
 
722
729
  var safeName = pkg.replace(/@/g, '').replace(/\//g, '-');
723
- return fetch('/api/servers', {
730
+ return AD._fetch('/api/servers', {
724
731
  method: 'POST',
725
732
  headers: { 'Content-Type': 'application/json' },
726
733
  body: JSON.stringify({
@@ -742,7 +749,7 @@
742
749
  btn.innerHTML =
743
750
  '<span class="material-symbols-outlined" style="font-size:14px">downloading</span> Downloading...';
744
751
  }
745
- return fetch('/api/servers/' + data.id + '/preinstall', { method: 'POST' })
752
+ return AD._fetch('/api/servers/' + data.id + '/preinstall', { method: 'POST' })
746
753
  .then(function () {
747
754
  showToast('Installed and downloaded ' + pkg, 'success');
748
755
  })
@@ -947,13 +954,20 @@
947
954
  // Init
948
955
  // -------------------------------------------------------------------------
949
956
 
950
- document.addEventListener('DOMContentLoaded', function () {
957
+ function _init() {
951
958
  initTabs();
952
959
  initTheme();
953
960
  initSearch();
954
961
  connect();
955
962
  initThemeSync();
956
- });
963
+ }
964
+
965
+ // Auto-init for standalone
966
+ if (document.readyState === 'loading') {
967
+ document.addEventListener('DOMContentLoaded', _init);
968
+ } else {
969
+ _init();
970
+ }
957
971
 
958
972
  // -------------------------------------------------------------------------
959
973
  // Theme sync from parent (agent-desk) via executeJavaScript
@@ -1075,4 +1089,29 @@
1075
1089
  if (themeToggle) themeToggle.style.display = 'none';
1076
1090
  });
1077
1091
  }
1092
+
1093
+ AD.mount = function (container, options) {
1094
+ options = options || {};
1095
+ AD._baseUrl = options.baseUrl || '';
1096
+ AD._wsUrl = options.wsUrl || null;
1097
+ if (options.cssUrl && !document.getElementById('ad-plugin-css')) {
1098
+ var link = document.createElement('link');
1099
+ link.id = 'ad-plugin-css';
1100
+ link.rel = 'stylesheet';
1101
+ link.href = options.cssUrl;
1102
+ document.head.appendChild(link);
1103
+ }
1104
+ if (typeof AD._template === 'function') {
1105
+ container.innerHTML = AD._template();
1106
+ }
1107
+ _init();
1108
+ };
1109
+
1110
+ AD.unmount = function () {
1111
+ if (ws) {
1112
+ ws.onclose = null;
1113
+ ws.close();
1114
+ ws = null;
1115
+ }
1116
+ };
1078
1117
  })();
@@ -94,6 +94,7 @@
94
94
  </div>
95
95
 
96
96
  <script src="morphdom.min.js"></script>
97
+ <script src="template.js"></script>
97
98
  <script src="app.js"></script>
98
99
  </body>
99
100
  </html>
@@ -0,0 +1,67 @@
1
+ /* eslint-disable */
2
+ var AD = (window.AD = window.AD || {});
3
+ AD._template = function () {
4
+ return (
5
+ '<div class="layout">' +
6
+ '<aside class="sidebar">' +
7
+ '<div class="sidebar-header">' +
8
+ '<span class="material-symbols-outlined sidebar-icon">widgets</span>' +
9
+ '<div>' +
10
+ '<div class="sidebar-title">agent-discover</div>' +
11
+ '<div class="sidebar-version" id="version">v0.0.0</div>' +
12
+ '</div>' +
13
+ '</div>' +
14
+ '<nav class="sidebar-nav">' +
15
+ '<button class="nav-item active" data-tab="installed">' +
16
+ '<span class="material-symbols-outlined">dns</span>' +
17
+ '<span>Servers</span>' +
18
+ '<span class="badge" id="installed-count">0</span>' +
19
+ '</button>' +
20
+ '<button class="nav-item" data-tab="browse">' +
21
+ '<span class="material-symbols-outlined">explore</span>' +
22
+ '<span>Browse</span>' +
23
+ '</button>' +
24
+ '</nav>' +
25
+ '<div class="sidebar-footer">' +
26
+ '<span class="connection-status" id="conn-status">' +
27
+ '<span class="conn-dot"></span>' +
28
+ 'Connecting...' +
29
+ '</span>' +
30
+ '<button class="theme-toggle" id="theme-toggle" title="Toggle theme">' +
31
+ '<span class="material-symbols-outlined">dark_mode</span>' +
32
+ '</button>' +
33
+ '</div>' +
34
+ '</aside>' +
35
+ '<main class="content">' +
36
+ '<section class="tab-panel active" id="tab-installed">' +
37
+ '<div class="panel-header">' +
38
+ '<h2 class="section-title">Servers</h2>' +
39
+ '</div>' +
40
+ '<div id="installed-list" class="server-grid">' +
41
+ '<div class="empty-state">' +
42
+ '<span class="material-symbols-outlined empty-icon">dns</span>' +
43
+ '<p>No servers registered</p>' +
44
+ '<p class="hint">Use registry_install or browse the marketplace</p>' +
45
+ '</div>' +
46
+ '</div>' +
47
+ '</section>' +
48
+ '<section class="tab-panel" id="tab-browse">' +
49
+ '<div class="panel-header">' +
50
+ '<h2 class="section-title">Browse MCP Registry</h2>' +
51
+ '<div class="search-bar">' +
52
+ '<span class="material-symbols-outlined">search</span>' +
53
+ '<input type="text" id="browse-search" placeholder="Search MCP servers..." autocomplete="off" />' +
54
+ '</div>' +
55
+ '</div>' +
56
+ '<div id="browse-list" class="server-grid">' +
57
+ '<div class="empty-state">' +
58
+ '<span class="material-symbols-outlined empty-icon">explore</span>' +
59
+ '<p>Search the official MCP registry</p>' +
60
+ '<p class="hint">Type a query above to discover servers</p>' +
61
+ '</div>' +
62
+ '</div>' +
63
+ '</section>' +
64
+ '</main>' +
65
+ '</div>'
66
+ );
67
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-discover",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "mcpName": "io.github.keshrath/agent-discover",
5
5
  "description": "MCP server registry and marketplace — discover, install, activate, and manage MCP tools on demand",
6
6
  "type": "module",