@aibranch/llm-meta-widget 0.13.0 → 0.14.0

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/README.md CHANGED
@@ -61,7 +61,7 @@ Option 3 if it does not.
61
61
 
62
62
  ```ruby
63
63
  # Gemfile
64
- gem "llm_meta_widget", "~> 0.13.0"
64
+ gem "llm_meta_widget", "~> 0.14.0"
65
65
  ```
66
66
 
67
67
  ```bash
@@ -152,26 +152,25 @@ The widget is a custom element in a single self-contained ES module, so the
152
152
  whole integration is two lines of HTML:
153
153
 
154
154
  ```html
155
- <script type="module" src="https://cdn.jsdelivr.net/npm/@aibranch/llm-meta-widget@0.13"></script>
155
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@aibranch/llm-meta-widget@0.14"></script>
156
156
  <llm-meta-widget llm-url="https://your-meta-server.example"
157
157
  model="gpt-oss-120b"
158
158
  greeting="Hi — ask me anything about this page."></llm-meta-widget>
159
159
  ```
160
160
 
161
- **`@0.13` is a version range, and it stops at 0.13.x on purpose.** You receive
161
+ **`@0.14` is a version range, and it stops at 0.14.x on purpose.** You receive
162
162
  bug fixes without editing your page, and a release that breaks your page cannot
163
163
  arrive on its own.
164
164
 
165
- Moving to 0.14 is therefore a change you make yourself. Read
165
+ Moving to 0.15 is therefore a change you make yourself. Read
166
166
  [CHANGELOG.md](CHANGELOG.md) before you do, because this is where what your page
167
167
  must provide can change. For example, 0.10.0 changed how the widget finds a page
168
168
  card: by media type rather than by element id. A page that declared its card the
169
169
  new way while still loading `@0.9` lost every tool, prompt and resource it had
170
170
  declared. Nothing failed, anywhere. The CHANGELOG entry for 0.10.0 describes it.
171
171
 
172
- 0.13.0 moves where a page declares its transport. That one is safe to take
173
- first, because 0.13.x still reads the old spelling and warns; the page can move
174
- afterwards.
172
+ 0.13.0 moved where a page declares its transport, and 0.14.0 stopped reading
173
+ the old spelling. Move your card to `transports` before taking 0.14.x.
175
174
 
176
175
  A Rails app is protected from that mismatch, because the `Gemfile` will not
177
176
  resolve a widget version the page cannot use. A page that loads the widget from
@@ -272,8 +271,8 @@ primitive type:
272
271
  <script type="application/mcp-static-primitives+json">
273
272
  {
274
273
  "name": "org.example/your-page",
275
- "remotes": [ { "type": "page-global", "global": "mcp" } ],
276
274
  "_meta": { "io.modelcontextprotocol/static-primitives": {
275
+ "transports": [ { "type": "page-global", "global": "mcp" } ],
277
276
  "tools": [
278
277
  { "name": "add_dictionaries",
279
278
  "description": "Add the named dictionaries to the current selection.",
@@ -305,11 +304,18 @@ primitive type:
305
304
  A tool's schema may be spelled `inputSchema`, as MCP spells it, or
306
305
  `input_schema`. Both are accepted.
307
306
 
308
- `remotes` is how a consumer other than this widget finds your handlers, so the
309
- global is declared rather than assumed. Leave it out and the widget reads
307
+ `transports` is how a consumer other than this widget finds your handlers, so
308
+ the global is declared rather than assumed. It is a list, and the consumer uses
309
+ the first entry whose `type` it supports; `page-global` is the only type this
310
+ widget supports today. Leave `transports` out and the widget reads
310
311
  `window.aiActions`, `window.aiPrompts` and `window.aiResources` instead — see
311
312
  "Say where your handlers live".
312
313
 
314
+ Widgets from 0.11.1 to 0.12.2 read this declaration from a `remotes` list at the
315
+ top level of the card, and 0.13.x read either spelling. From 0.14.0 the old one
316
+ is not read at all: a card that still carries it gets no handlers, and the
317
+ widget reports that in the browser console. Write `transports`.
318
+
313
319
  A page may declare `prompts` in the same block. See [The page card](#the-page-card)
314
320
  for prompts, for the size and volatility hints on a resource, and for what
315
321
  happens when a document holds several blocks.
@@ -515,8 +521,8 @@ name the global that holds its handlers. Both are below.
515
521
  <script type="application/mcp-static-primitives+json">
516
522
  {
517
523
  "name": "org.example/your-page",
518
- "remotes": [ { "type": "page-global", "global": "mcp" } ],
519
524
  "_meta": { "io.modelcontextprotocol/static-primitives": {
525
+ "transports": [ { "type": "page-global", "global": "mcp" } ],
520
526
  "tools": [ { "name": "set_text", "description": "…", "inputSchema": { } } ],
521
527
  "prompts": [ { "name": "annotate", "description": "Annotate this page" } ],
522
528
  "resources": [ { "uri": "page:text", "name": "Text", "description": "the text to annotate",
@@ -526,8 +532,8 @@ name the global that holds its handlers. Both are below.
526
532
  </script>
527
533
  ```
528
534
 
529
- `name` identifies the card, as it does for a server. `remotes` says where the
530
- handlers live — see "Say where your handlers live" below. Only the `_meta`
535
+ `name` identifies the card, as it does for a server. `transports` says where
536
+ the handlers live — see "Say where your handlers live" below. Only the `_meta`
531
537
  block is required by this widget; the rest is what makes the card readable by
532
538
  anything else.
533
539
 
@@ -573,8 +579,8 @@ them:
573
579
  ```html
574
580
  <script type="application/mcp-static-primitives+json">
575
581
  { "name": "org.example/your-page",
576
- "remotes": [ { "type": "page-global", "global": "mcp" } ],
577
- "_meta": { "io.modelcontextprotocol/static-primitives": { "tools": [ ... ] } } }
582
+ "_meta": { "io.modelcontextprotocol/static-primitives": {
583
+ "transports": [ { "type": "page-global", "global": "mcp" } ], "tools": [ ... ] } } }
578
584
  </script>
579
585
  <script>
580
586
  window.mcp = {
@@ -722,6 +728,47 @@ as **optional**, and fill them from page state where you can. An argument the
722
728
  visitor must type in makes the button useless to the visitor who needed it most:
723
729
  to press it, they would already have to know your form.
724
730
 
731
+ ## When a turn does not fit the model's context
732
+
733
+ A model holds a fixed number of tokens. A long conversation, a large reference
734
+ resource and a few big tool results can exceed it, and the provider then refuses
735
+ the whole turn. The widget tries to keep a turn inside the limit instead, and
736
+ tells the reader whenever it has to change something. You do not configure any
737
+ of this, but your page's visitors will see the messages, so it is worth knowing
738
+ what they mean.
739
+
740
+ The widget learns each model's context window from the server's model list. If
741
+ the server does not report one, none of the behaviour below applies and the turn
742
+ is sent as it is.
743
+
744
+ **One oversized tool result is shortened.** A single result may use at most 40%
745
+ of the window. A larger one is cut to that size, and the model is told in the
746
+ result itself how much was shown and that it can call the tool again with a
747
+ narrower query. The panel says, for example:
748
+
749
+ > Shortened an oversized togovar_search_variant result to fit the context:
750
+ > 121,000 tokens, where one result may use at most 51,000. Ask again with a
751
+ > narrower question for the complete result.
752
+
753
+ **Older tool results are given up when the whole turn is too long.** This is for
754
+ a conversation that has grown over many turns, not for one large result. The
755
+ oldest results go first, one at a time, until the turn fits. The questions, the
756
+ answers and the model's own summaries of what it read are never touched, and a
757
+ dropped result leaves a note in its place so the model knows to ask again.
758
+
759
+ **A reference resource that does not fit is not attached.** Each turn may carry
760
+ about 6% of the window as reference data — roughly 8 KB for a 32,000-token model
761
+ and 32 KB for a 128,000-token one. A resource larger than that is not fetched at
762
+ all, and the panel says so, naming the resource and both figures. The model is
763
+ not told, because it cannot fetch a resource itself; the reader can act, by
764
+ choosing a model with a larger window or asking you for a smaller resource.
765
+
766
+ If you publish a large document through MCP, consider offering it in sections
767
+ behind one tool that takes a section name, rather than as a single tool result.
768
+ The list of section names in the tool's own schema costs a few hundred tokens
769
+ and is visible to every client, while a document of tens of kilobytes crowds out
770
+ the conversation it is supposed to support.
771
+
725
772
  ## Further reading
726
773
 
727
774
  - **The static-primitives extension** — `io.modelcontextprotocol/static-primitives`,
@@ -701,12 +701,8 @@ function declaredPageGlobal(card, warn = console.warn) {
701
701
  warn("[llm-meta-widget] page card declares transports " + JSON.stringify(declared.map((t) => t && t.type)) + ", none of which this widget supports; not dispatching to the page");
702
702
  return null;
703
703
  }
704
- for (const remote of card && card.remotes || []) {
705
- if (!remote || remote.type !== PAGE_GLOBAL_TRANSPORT) continue;
706
- if (typeof remote.global === "string" && remote.global.trim() !== "") {
707
- warn(`[llm-meta-widget] page card declares its transport in top-level "remotes", which is deprecated; move it to _meta["${STATIC_PRIMITIVES_META}"].transports`);
708
- return remote.global.trim();
709
- }
704
+ if ((card && card.remotes || []).some((r) => r && r.type === PAGE_GLOBAL_TRANSPORT)) {
705
+ warn(`[llm-meta-widget] page card declares its transport in top-level "remotes", which is no longer read. Move it to _meta["${STATIC_PRIMITIVES_META}"].transports`);
710
706
  }
711
707
  return null;
712
708
  }
@@ -1130,10 +1130,9 @@ export const PAGE_GLOBAL_TRANSPORT = "page-global"
1130
1130
  // `page-postmessage`, `page-jsonrpc` and `page-worker` are reserved, and a card
1131
1131
  // declaring only those gets no handlers rather than the wrong ones.
1132
1132
  //
1133
- // Top-level `remotes` is the pre-d44bd25a shape that 0.11.1 and 0.12.2 read. It
1134
- // is accepted for one release so a page and a widget can be updated in either
1135
- // order without the page going dark in between, and it warns so the author
1136
- // knows to move.
1133
+ // Top-level `remotes` is the pre-d44bd25a shape that 0.11.1 to 0.12.2 read and
1134
+ // 0.13.x accepted. It is no longer read, but a card still carrying it is
1135
+ // reported, because the alternative is a page that quietly stops working.
1137
1136
  export function declaredPageGlobal(card, warn = console.warn) {
1138
1137
  const declared = (card && card.transports) || []
1139
1138
  for (const transport of declared) {
@@ -1149,14 +1148,14 @@ export function declaredPageGlobal(card, warn = console.warn) {
1149
1148
  return null
1150
1149
  }
1151
1150
 
1152
- for (const remote of (card && card.remotes) || []) {
1153
- if (!remote || remote.type !== PAGE_GLOBAL_TRANSPORT) continue
1154
- if (typeof remote.global === "string" && remote.global.trim() !== "") {
1155
- warn('[llm-meta-widget] page card declares its transport in top-level ' +
1156
- '"remotes", which is deprecated; move it to ' +
1157
- `_meta["${STATIC_PRIMITIVES_META}"].transports`)
1158
- return remote.global.trim()
1159
- }
1151
+ // No longer read. Reporting it is still worth a few lines: without this a
1152
+ // card that declares its transport only in the old place gets no handlers,
1153
+ // falls through to the legacy globals, and a page that deliberately defines
1154
+ // none — as PubDictionaries does — simply stops working with nothing said.
1155
+ if (((card && card.remotes) || []).some((r) => r && r.type === PAGE_GLOBAL_TRANSPORT)) {
1156
+ warn('[llm-meta-widget] page card declares its transport in top-level ' +
1157
+ '"remotes", which is no longer read. Move it to ' +
1158
+ `_meta["${STATIC_PRIMITIVES_META}"].transports`)
1160
1159
  }
1161
1160
  return null
1162
1161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibranch/llm-meta-widget",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "//version": "Must stay in step with lib/llm_meta_widget/version.rb. Two independently versioned copies of the same client is the drift docs/custom-element-distribution.md warns about: bump both, release both.",
5
5
  "description": "Embeddable browser chat widget: a custom element that discovers tools at page, origin and hub scope and dispatches each tool call to the right one. Two lines of HTML on any host, Rails or not.",
6
6
  "keywords": [