llm_meta_widget 0.8.4 → 0.8.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: 0a3adfcaccf5824c1c15fc457ee01716fa1df373d21f4734b68096ef08effed1
4
- data.tar.gz: 22c9d53cbfed853404279136f90da67410608c1f87d9a076c999813481965d9b
3
+ metadata.gz: 83ad21e8631c42b769a30bc71493cf7b73590f16e62a6bdd5747d147e4aeb9c5
4
+ data.tar.gz: e65e1289d90bff0db65c8905f4018f2eddaa48e680f1d17afe709a9ac2a59a5f
5
5
  SHA512:
6
- metadata.gz: 96a6c2e40b6477807230de39d3eb02668353ec1c29d9155ff083d3e2afdd5149ce58a5199d2d912e1f311d87be3d6c4cd1c2c67d5f5c7e36f32b967a2b80f567
7
- data.tar.gz: ca5587496e4b076f9cb0215f61573d09f26a6068a8c0377b4bc4e542577223c94d0f87a9ac81fcb7d3afff484ed88df8aadec2038ec3b909e9e579527bdf82c2
6
+ metadata.gz: de457ef4d34b201e3d0cfd5e53b3171fa1e9ed88aaa99da68a92fe00a0fe82769942ac25783982ba9397544e2018e645755b6a5f3cc5cfa62d11d2e173648c3b
7
+ data.tar.gz: 3d28002e0c0d593cf6b287943e32863a341aaeee82da14b0fd01aa23e46cad77722c434bc06e6b19c792c30dd95c61bd90e0ccb6de694565c845a4ab69ed223a
@@ -408,6 +408,13 @@ function boot(cfg) {
408
408
  (payload.llms || []).forEach(function(llm) {
409
409
  if (llm.family !== "ollama") return;
410
410
  (llm.available_models || []).forEach(function(m) {
411
+ // This widget exists to call tools — page actions and MCP. A model
412
+ // that declares no tool support fails hard the moment any tool is
413
+ // declared ("<model> does not support tools"), so offering it in the
414
+ // picker is a trap: the visitor picks it and the next turn errors.
415
+ // `=== false` on purpose — a hub that omits the field is older, not
416
+ // a claim of no support, and must keep working.
417
+ if (m.supports_tools === false) return;
411
418
  if (anyAllowedByAllowlist(m.value, MODEL_ALLOWLIST)) {
412
419
  flat.push({ value: m.value, label: m.label });
413
420
  }
@@ -616,7 +623,7 @@ function boot(cfg) {
616
623
  read: readMcpResource,
617
624
  onSkip: function(plan) {
618
625
  console.info("[llm_meta_widget] not attaching " + plan.uri +
619
- " (" + plan.reason + ", sizeBytes=" + plan.sizeBytes + ")");
626
+ " (" + plan.reason + ", size=" + plan.size + ")");
620
627
  }
621
628
  });
622
629
  // A volatile resource comes back with no context — it is read
@@ -550,23 +550,33 @@ function parseSseFrame(raw) {
550
550
  }
551
551
  var STATIC_PRIMITIVES_META = "io.modelcontextprotocol/static-primitives";
552
552
  var VOLATILITIES = ["stable", "volatile"];
553
+ var usableSize = (n) => typeof n === "number" && isFinite(n) ? n : null;
553
554
  function resourceHints(entry) {
554
555
  const meta = entry && entry._meta && entry._meta[STATIC_PRIMITIVES_META] || {};
555
556
  return {
556
557
  // A non-numeric or absent size means "unknown", never 0 — 0 would read
557
558
  // as a free resource and sail through every budget check.
558
- sizeBytes: typeof meta.sizeBytes === "number" && isFinite(meta.sizeBytes) ? meta.sizeBytes : null,
559
+ // Base `size` wins; `_meta.sizeBytes` is the earlier draft's spelling and
560
+ // is accepted so a new client keeps its budget gate against an old server.
561
+ size: usableSize(entry && entry.size) ?? usableSize(meta.sizeBytes),
562
+ // Deprecated alias, kept for one release so renaming the field is not a
563
+ // breaking change: orchestrator.js is a published entry point, so anything
564
+ // it returns is public API. Dropped at 0.9.0 together with the
565
+ // `_meta.sizeBytes` fallback above — one deprecation, one bump.
566
+ get sizeBytes() {
567
+ return this.size;
568
+ },
559
569
  volatility: VOLATILITIES.indexOf(meta.volatility) === -1 ? "stable" : meta.volatility,
560
570
  autoAttach: typeof meta.autoAttach === "boolean" ? meta.autoAttach : true
561
571
  };
562
572
  }
563
573
  function planResourceAttachment(entry, budgetBytes) {
564
- const { sizeBytes, volatility, autoAttach } = resourceHints(entry);
565
- const base = { sizeBytes, volatility, uri: entry && entry.uri };
574
+ const { size, volatility, autoAttach } = resourceHints(entry);
575
+ const base = { size, sizeBytes: size, volatility, uri: entry && entry.uri };
566
576
  if (!autoAttach) {
567
577
  return { ...base, fetch: false, autoAttach: false, reason: "not-auto-attach" };
568
578
  }
569
- if (sizeBytes !== null && sizeBytes > budgetBytes) {
579
+ if (size !== null && size > budgetBytes) {
570
580
  return { ...base, fetch: false, autoAttach: false, reason: "over-budget" };
571
581
  }
572
582
  return {
@@ -575,7 +585,7 @@ function planResourceAttachment(entry, budgetBytes) {
575
585
  autoAttach: true,
576
586
  // Unknown size still gets fetched, then trimmed — the trim is the
577
587
  // safety net for servers that do not declare a size.
578
- reason: sizeBytes === null ? "size-unknown" : "within-budget"
588
+ reason: size === null ? "size-unknown" : "within-budget"
579
589
  };
580
590
  }
581
591
  function trimResourceText(text, maxBytes) {
@@ -3868,6 +3878,7 @@ function boot(cfg) {
3868
3878
  (payload.llms || []).forEach(function(llm) {
3869
3879
  if (llm.family !== "ollama") return;
3870
3880
  (llm.available_models || []).forEach(function(m) {
3881
+ if (m.supports_tools === false) return;
3871
3882
  if (anyAllowedByAllowlist(m.value, MODEL_ALLOWLIST)) {
3872
3883
  flat.push({ value: m.value, label: m.label });
3873
3884
  }
@@ -4030,7 +4041,7 @@ function boot(cfg) {
4030
4041
  list: listMcpResources,
4031
4042
  read: readMcpResource,
4032
4043
  onSkip: function(plan) {
4033
- console.info("[llm_meta_widget] not attaching " + plan.uri + " (" + plan.reason + ", sizeBytes=" + plan.sizeBytes + ")");
4044
+ console.info("[llm_meta_widget] not attaching " + plan.uri + " (" + plan.reason + ", size=" + plan.size + ")");
4034
4045
  }
4035
4046
  });
4036
4047
  if (loaded && loaded.plan && loaded.plan.fetch) {
@@ -819,8 +819,13 @@ function parseSseFrame(raw) {
819
819
  // follow-on). Three optional fields a server may declare on a resources/list
820
820
  // entry:
821
821
  //
822
- // sizeBytes - byte length of the payload resources/read would return, so a
822
+ // size - byte count of the payload resources/read would return, so a
823
823
  // client can decide whether to attach it BEFORE fetching it.
824
+ // This is the BASE Resource field, not an extension field: the
825
+ // extension only strengthens it to "MUST be exact when present".
826
+ // Read from `_meta.sizeBytes` too, which is where the earlier
827
+ // draft put it — servers deployed against that draft (PD among
828
+ // them) are still emitting it.
824
829
  // volatility - "stable" (content fixed) or "volatile" (varies between
825
830
  // turns, so a client re-reads it each turn).
826
831
  // autoAttach - may a client attach this without the user asking for it?
@@ -837,12 +842,21 @@ export const STATIC_PRIMITIVES_META = "io.modelcontextprotocol/static-primitives
837
842
 
838
843
  const VOLATILITIES = [ "stable", "volatile" ]
839
844
 
845
+ const usableSize = (n) => (typeof n === "number" && isFinite(n) ? n : null)
846
+
840
847
  export function resourceHints(entry) {
841
848
  const meta = (entry && entry._meta && entry._meta[STATIC_PRIMITIVES_META]) || {}
842
849
  return {
843
850
  // A non-numeric or absent size means "unknown", never 0 — 0 would read
844
851
  // as a free resource and sail through every budget check.
845
- sizeBytes: typeof meta.sizeBytes === "number" && isFinite(meta.sizeBytes) ? meta.sizeBytes : null,
852
+ // Base `size` wins; `_meta.sizeBytes` is the earlier draft's spelling and
853
+ // is accepted so a new client keeps its budget gate against an old server.
854
+ size: usableSize(entry && entry.size) ?? usableSize(meta.sizeBytes),
855
+ // Deprecated alias, kept for one release so renaming the field is not a
856
+ // breaking change: orchestrator.js is a published entry point, so anything
857
+ // it returns is public API. Dropped at 0.9.0 together with the
858
+ // `_meta.sizeBytes` fallback above — one deprecation, one bump.
859
+ get sizeBytes() { return this.size },
846
860
  volatility: VOLATILITIES.indexOf(meta.volatility) === -1 ? "stable" : meta.volatility,
847
861
  autoAttach: typeof meta.autoAttach === "boolean" ? meta.autoAttach : true
848
862
  }
@@ -851,13 +865,16 @@ export function resourceHints(entry) {
851
865
  // The pre-flight decision, made from the resources/list entry alone.
852
866
  // `fetch: false` means the bytes never cross the wire at all.
853
867
  export function planResourceAttachment(entry, budgetBytes) {
854
- const { sizeBytes, volatility, autoAttach } = resourceHints(entry)
855
- const base = { sizeBytes, volatility, uri: entry && entry.uri }
868
+ const { size, volatility, autoAttach } = resourceHints(entry)
869
+ // `sizeBytes` is the deprecated alias again: this function is exported too,
870
+ // and it returned that name before the field was aligned with the base
871
+ // Resource interface. Dropped at 0.9.0 with the rest.
872
+ const base = { size, sizeBytes: size, volatility, uri: entry && entry.uri }
856
873
 
857
874
  if (!autoAttach) {
858
875
  return { ...base, fetch: false, autoAttach: false, reason: "not-auto-attach" }
859
876
  }
860
- if (sizeBytes !== null && sizeBytes > budgetBytes) {
877
+ if (size !== null && size > budgetBytes) {
861
878
  // The client's budget overrides the server's willingness — which is why
862
879
  // autoAttach has to be a boolean here rather than a restatement of a hint.
863
880
  return { ...base, fetch: false, autoAttach: false, reason: "over-budget" }
@@ -868,7 +885,7 @@ export function planResourceAttachment(entry, budgetBytes) {
868
885
  autoAttach: true,
869
886
  // Unknown size still gets fetched, then trimmed — the trim is the
870
887
  // safety net for servers that do not declare a size.
871
- reason: sizeBytes === null ? "size-unknown" : "within-budget"
888
+ reason: size === null ? "size-unknown" : "within-budget"
872
889
  }
873
890
  }
874
891
 
@@ -1,3 +1,3 @@
1
1
  module LlmMetaWidget
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.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.8.4
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jdkim