llm_meta_widget 0.7.5 → 0.7.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d2cc5c7bfb6fa54893df26cef21788e90384052cda6a60acc05aca7fdc90f61
4
- data.tar.gz: 43aa3c8567f74595ff9b66e6fcbf2e71291da2c3699c4ac84c1b3b07b6c2a6b6
3
+ metadata.gz: 1590b5b56f4d164501425b88c2fddd28a07a19a229e6d3a6737a00a1f78b2a31
4
+ data.tar.gz: f8ba25f792c18736fd031757b18d8e2be7bdd85155f084e92f2cc683218a69c0
5
5
  SHA512:
6
- metadata.gz: 43d04fc32c9e167cb7958f80ef2f5d8632621703542f7679e444c1f55b12cf68276945b4adb45a17e6e699a4ec9ee3c9ac017b646e8069ecf1688abd7e5376ef
7
- data.tar.gz: b2b04bf2577dfc7ee3de38581734b4385354c81146b9523d2d33d78d6aa126ff0dfadc42018889f2f4fcd2ab859f7148bf5e0694f096377060497b28a91a9dd6
6
+ metadata.gz: 7cb9aad1047fca745e0c50c47e00c3c3504aaa34a104d2662ce1b2818abed81cddfdc7437a272b99629f4c61afba8b81a49deec8f97aff1f28a53ab29058410a
7
+ data.tar.gz: b5c75d48fc1e0583cf2e417e4f57f609742bf7342524f85a344c5ee89cb778db5b38f7703e15ebfc1d5f6a54d7b5bb2aab3c82765bbfadfc780104830712bd25
@@ -299,7 +299,11 @@ function boot(cfg) {
299
299
  // baseline (if any), then the level-1 picker adds/removes entries as
300
300
  // the visitor toggles server checkboxes. Passed to runChatLoop on
301
301
  // every submit so the current selection is respected turn-by-turn.
302
- var remoteTools = remoteToolsEl ? JSON.parse(remoteToolsEl.textContent) : [];
302
+ // Keep the baseline separately: refreshRemoteToolsFromPicker() rebuilds
303
+ // remoteTools wholesale, so without a pristine copy the pre-configured
304
+ // tools vanish the moment the picker first renders.
305
+ var baselineRemoteTools = remoteToolsEl ? JSON.parse(remoteToolsEl.textContent) : [];
306
+ var remoteTools = baselineRemoteTools.slice();
303
307
 
304
308
  // Level-1 picker caches. hubMcpServers[] is the list of anon-visible
305
309
  // servers fetched from GET /api/mcp_servers; each server has an
@@ -310,6 +314,10 @@ function boot(cfg) {
310
314
  // state (all-on / indeterminate / all-off).
311
315
  var hubMcpServers = [];
312
316
  var selectedToolIds = new Set();
317
+ // A pre-configured tool IS a selection: seed the set so the picker renders
318
+ // it checked and the visitor can turn it off, rather than the picker
319
+ // silently overriding the page.
320
+ baselineRemoteTools.forEach(function(t) { selectedToolIds.add(t.id); });
313
321
 
314
322
  function anyAllowedByAllowlist(name, allowlist) {
315
323
  return allowlist === null || allowlist.indexOf(name) >= 0;
@@ -319,9 +327,11 @@ function boot(cfg) {
319
327
  // Flatten every SELECTED tool (across all servers) into remoteTools,
320
328
  // adapted to runChatLoop's expected { id, name, description, input_schema }.
321
329
  var flat = [];
330
+ var seen = {};
322
331
  hubMcpServers.forEach(function(s) {
323
332
  (s.tools || []).forEach(function(t) {
324
333
  if (!selectedToolIds.has(t.id)) return;
334
+ seen[t.id] = true;
325
335
  flat.push({
326
336
  id: t.id,
327
337
  name: t.name,
@@ -330,6 +340,12 @@ function boot(cfg) {
330
340
  });
331
341
  });
332
342
  });
343
+ // A baseline tool whose server the picker never listed (not anon-visible,
344
+ // or the fetch failed) has no checkbox to be found through — keep it
345
+ // unless the visitor explicitly turned it off.
346
+ baselineRemoteTools.forEach(function(t) {
347
+ if (!seen[t.id] && selectedToolIds.has(t.id)) { flat.push(t); seen[t.id] = true; }
348
+ });
333
349
  remoteTools = flat;
334
350
  if (toolsCountEl) {
335
351
  toolsCountEl.textContent = flat.length;
@@ -3765,17 +3765,23 @@ function boot(cfg) {
3765
3765
  var actionsSchemaEl = document.getElementById(ACTIONS_SCHEMA_ID);
3766
3766
  var localTools = actionsSchemaEl ? JSON.parse(actionsSchemaEl.textContent) : [];
3767
3767
  var remoteToolsEl = document.getElementById(REMOTE_TOOLS_SCHEMA_ID);
3768
- var remoteTools = remoteToolsEl ? JSON.parse(remoteToolsEl.textContent) : [];
3768
+ var baselineRemoteTools = remoteToolsEl ? JSON.parse(remoteToolsEl.textContent) : [];
3769
+ var remoteTools = baselineRemoteTools.slice();
3769
3770
  var hubMcpServers = [];
3770
3771
  var selectedToolIds = /* @__PURE__ */ new Set();
3772
+ baselineRemoteTools.forEach(function(t) {
3773
+ selectedToolIds.add(t.id);
3774
+ });
3771
3775
  function anyAllowedByAllowlist(name, allowlist) {
3772
3776
  return allowlist === null || allowlist.indexOf(name) >= 0;
3773
3777
  }
3774
3778
  function refreshRemoteToolsFromPicker() {
3775
3779
  var flat = [];
3780
+ var seen = {};
3776
3781
  hubMcpServers.forEach(function(s) {
3777
3782
  (s.tools || []).forEach(function(t) {
3778
3783
  if (!selectedToolIds.has(t.id)) return;
3784
+ seen[t.id] = true;
3779
3785
  flat.push({
3780
3786
  id: t.id,
3781
3787
  name: t.name,
@@ -3784,6 +3790,12 @@ function boot(cfg) {
3784
3790
  });
3785
3791
  });
3786
3792
  });
3793
+ baselineRemoteTools.forEach(function(t) {
3794
+ if (!seen[t.id] && selectedToolIds.has(t.id)) {
3795
+ flat.push(t);
3796
+ seen[t.id] = true;
3797
+ }
3798
+ });
3787
3799
  remoteTools = flat;
3788
3800
  if (toolsCountEl) {
3789
3801
  toolsCountEl.textContent = flat.length;
@@ -1,3 +1,3 @@
1
1
  module LlmMetaWidget
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_meta_widget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jdkim