llm_meta_widget 0.8.0 → 0.8.2

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: 5bd30ac6cb4c389fbc600db77a91fd6cc9b363290c970043917706f26288041a
4
- data.tar.gz: 44696139fdb278e97b039971e27284de9bb4a082a3b2fe12c1341a88b4e94b96
3
+ metadata.gz: f19be36c0ac6c12b514836a44a383e8d417c59cddd97f771947044f6d027091f
4
+ data.tar.gz: 33ebfee68850e7396faff9739d306273e281950f11ae2eeb4fba88d4a6924386
5
5
  SHA512:
6
- metadata.gz: 02277ce080547d0f35deb01b761abfa2a40face578f012c607594c08b80152c700c30b72d13652339b044d10ecf0d2e5eb305026ee816d5928290e39f28147d0
7
- data.tar.gz: 4f349cddfa82766fd1a203d9c29ebd8f56b428ff0d241ec7399e19c29cf1d59c5783ca8122e225c33aa9c578abe4fa51db27d4d9dbeb8bb7894fd1a5803bdca5
6
+ metadata.gz: e320dce7bc260d9ef3f646328536d01c2eeec6ae40b4ca20c3aaac390ace093507f04f4e0f060e1db3497a94e81bc899936663f09c79c1c85e5abbc62d663b77
7
+ data.tar.gz: 73b783e9b2a436f2fe44d1fc447276d9e243cf3e7387f884684823412a54d9dbfe3f14c37f9e2a7078c67234c6561380f9c76089526240dc8e1997da9cb6df53
data/README.md CHANGED
@@ -2,9 +2,15 @@
2
2
 
3
3
  Embeddable browser chat widget for the [llm_meta](https://github.com/pubannotation) ecosystem.
4
4
 
5
- Client-orchestrated: the widget fetches host-side action schemas + host-published `.well-known/mcp.json` manifests at boot, dispatches tool_calls locally (page-embedded actions) or directly to MCP endpoints (host-wide well-known), and consumes the meta-server's SSE `single_llm_calls` API. Ships as a custom element in one self-contained ES module — on npm for any host, and in a Rails gem whose helper serves the identical file.
5
+ The browser does the orchestrating. At boot the widget reads the tools your page
6
+ declares and any `.well-known/mcp.json` your host publishes. When the model calls
7
+ a tool, the widget runs it: in the page itself, or against an MCP endpoint
8
+ directly. Only the chat goes through the meta-server, over SSE.
6
9
 
7
- **No** Devise, DB migrations, ChatManager, or PromptNavigator. The gem adds only `rails >= 8.0` as a runtime dep — so hosts that haven't bumped to 8.1 can adopt it without a Rails upgrade — and hosts that are not Rails at all skip the gem entirely.
10
+ It ships as a custom element in one self-contained ES module. The same file is on
11
+ npm for any host, and in a Rails gem whose helper serves it for you.
12
+
13
+ **No** Devise, DB migrations, ChatManager, or PromptNavigator. The gem adds only `rails >= 8.0` as a runtime dep — so hosts that haven't bumped to 8.1 can adopt it without a Rails upgrade — and hosts that do not use Rails do not need the gem.
8
14
 
9
15
  ## What you need first
10
16
 
@@ -37,7 +43,7 @@ that section.
37
43
  | Your app | What you add | What you write |
38
44
  |---|---|---|
39
45
  | **Rails** | the gem, one line in your `Gemfile` | one helper call in a view. The helper writes the `<llm-meta-widget>` tag for you, so you never write that tag yourself |
40
- | **Anything else** — Python, Go, PHP, plain HTML… | one `<script>` tag from the CDN | the `<llm-meta-widget>` tag yourself |
46
+ | **Anything else** — Python, Go, PHP, plain HTML… | one `<script>` tag from the CDN, or an npm dependency you bundle | the `<llm-meta-widget>` tag yourself |
41
47
 
42
48
  Both ways load the same file and run the same widget.
43
49
 
@@ -108,7 +114,7 @@ Two more things worth knowing before you go further:
108
114
  - The model name is the hub's name for it (`GET /api/llms` lists them), not
109
115
  the provider's.
110
116
 
111
- Once that works, the widget can converse but cannot *do* anything. To let the
117
+ Once that works, the widget can talk, but it cannot *do* anything yet. To let the
112
118
  LLM act on your page or call your own services, declare tools using any of the
113
119
  **three tool classes** below.
114
120
 
@@ -124,7 +130,7 @@ that is not Rails needs no gem, no template engine and no asset pipeline — two
124
130
  lines of HTML:
125
131
 
126
132
  ```html
127
- <script type="module" src="https://cdn.jsdelivr.net/npm/@aibranch/llm-meta-widget@0.7"></script>
133
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@aibranch/llm-meta-widget@0.8"></script>
128
134
  <llm-meta-widget llm-url="https://your-meta-server.example"
129
135
  model="qwen3-6-35b-fast"
130
136
  greeting="Hi — ask me anything about this page."></llm-meta-widget>
@@ -135,27 +141,73 @@ instead of ERB. Both produce the same widget, so the advice in that section
135
141
  — CORS, a reachable `llm_url`, the hub's name for the model — applies here
136
142
  too.
137
143
 
144
+ **`@0.8` is a version range, and it stops at 0.8.x on purpose.** You receive bug
145
+ fixes without editing your page, and a release that breaks your page cannot
146
+ arrive on its own.
147
+
148
+ Moving to 0.9 is therefore a change you make yourself. Read
149
+ [CHANGELOG.md](CHANGELOG.md) before you do, because this is where what your page
150
+ must provide can change. For example, 0.8.0 changed the shape of
151
+ `window.aiState`. A page that used the new shape while still loading `@0.7`
152
+ would have shown an error string in place of every value, with no other warning.
153
+
154
+ A Rails app is protected from that mismatch, because the `Gemfile` will not
155
+ resolve a widget version the page cannot use. A page that loads the widget from
156
+ the CDN has no such check, so the version you write in that URL is the only
157
+ protection you have.
158
+
138
159
  Nothing else is needed: the stylesheets and the markdown renderer are bundled
139
160
  in, and the element injects its own styles. The host serves no CSS and no JS.
140
161
 
141
- Three ways to get that one file, in descending order of convenience:
162
+ ### If you have a JS build pipeline, install it instead
163
+
164
+ Vite, webpack, esbuild, Next.js, SvelteKit, Astro — if your app already builds
165
+ JavaScript, take the widget as a dependency rather than a script tag:
166
+
167
+ ```bash
168
+ npm install @aibranch/llm-meta-widget
169
+ ```
170
+
171
+ ```js
172
+ // Once, at your app's entry point. Importing the package is all you need: it
173
+ // defines the custom element. There is no function to call and nothing to name.
174
+ import "@aibranch/llm-meta-widget";
175
+ ```
176
+
177
+ Then write the `<llm-meta-widget>` tag exactly as above — same attributes, same
178
+ behaviour.
179
+
180
+ **Why do this, when the script tag is only one line?** Because your build then
181
+ checks the version for you. The version is pinned in your lockfile and installed by `npm ci`
182
+ with integrity checking, so you know which widget your page runs and your
183
+ colleague's build runs the same one. On the CDN path the version lives in a URL
184
+ that nothing checks. That matters most at a breaking release: 0.8.0 changed the
185
+ shape of `window.aiState`, and a lockfile makes the upgrade a deliberate, visible
186
+ step instead of a URL someone edits.
187
+
188
+ The only cost is that this path needs a build pipeline. The CDN path needs none,
189
+ which is why it is listed first.
190
+
191
+ Four ways to get that one file, in descending order of convenience:
142
192
 
143
193
  - **the CDN**, as above — `@aibranch/llm-meta-widget` on npm, no path needed
144
194
  because the package's `main` is the bundle;
195
+ - **npm install plus your own bundler**, as above — the same package, resolved
196
+ through `exports` and pinned by your lockfile;
145
197
  - **the gem**, which serves the identical file at
146
198
  `/llm_meta_widget_assets/llm-meta-widget.js` for Rails hosts, and is what the
147
199
  `llm_meta_widget` helper points at;
148
200
  - **self-hosted** — copy it out of the package or the gem and serve it as a
149
201
  static asset, if you would rather not depend on a CDN.
150
202
 
151
- Going without the gem removes the Rails pieces — the helper and the partial.
152
- It does not remove your page's own contract, because those parts belong to the
153
- page rather than to Rails: the `#ai-actions` JSON block, `window.aiState` and
154
- `window.aiActions` are declared exactly as they are under Rails (see the three
155
- tool classes below).
203
+ Going without the gem removes the Rails parts: the helper and the partial. It
204
+ does not change what your page itself must provide, because those parts belong to
205
+ the page, not to Rails. You declare the `#ai-actions` JSON block, `window.aiState`
206
+ and `window.aiActions` exactly as a Rails page does — see the three tool classes
207
+ below.
156
208
 
157
- **Attributes** map one-to-one onto the helper's keyword options. Three are not
158
- obvious and are the ones that bite:
209
+ **Attributes** match the helper's keyword options one to one. Three of them are
210
+ easy to get wrong:
159
211
 
160
212
  | attribute | notes |
161
213
  |---|---|
@@ -166,11 +218,11 @@ obvious and are the ones that bite:
166
218
  | `actions-schema-id`, `state-global`, `actions-global`, `remote-tools-schema-id` | as the helper options |
167
219
  | `models`, `hub-tools` | comma-separated. Omitted **or empty** means no allowlist — an allowlist permitting nothing is never what anyone meant |
168
220
  | `enable-model-picker`, `enable-tool-picker` | **value attributes, not boolean attributes.** They default to true, so presence cannot mean true. Disable with `enable-tool-picker="false"`; any other value is true |
169
- | `well-known-urls` | **tri-state**, because an attribute cannot express nil-versus-empty: omitted = auto-discover same-origin `/.well-known/mcp.json`; `""` = discovery off; `"a,b"` = fetch those |
221
+ | `well-known-urls` | **Three different states**, because an attribute cannot tell "not set" from "set to empty": omitted = auto-discover same-origin `/.well-known/mcp.json`; `""` = discovery off; `"a,b"` = fetch those |
170
222
 
171
- That last one is the quiet failure to watch for: expecting discovery off and
172
- getting a same-origin fetch looks like nothing at all, except a 404 in the
173
- console.
223
+ The last one fails quietly. If you expect discovery to be off but leave the
224
+ attribute out, the widget fetches your own origin instead. Nothing appears to
225
+ happen, except a 404 in the browser console.
174
226
 
175
227
  One widget per page. The panel uses fixed element ids, so a second
176
228
  `<llm-meta-widget>` is ignored with a console warning rather than fighting the
@@ -1,3 +1,3 @@
1
1
  module LlmMetaWidget
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.2"
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.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jdkim