@opennodes/registry 0.1.39 → 0.1.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opennodes/registry",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "description": "OpenNodes (ONP) reference registry: node registration with proof-of-resource qualification (Stage A/B/C), transparent ranking, enforceable estimates, catalog importers (OpenRouter, Hugging Face, models.dev, Ollama), MCP surface, and the web app (catalog, chat, advisor, Node Builder)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/search.js CHANGED
@@ -164,6 +164,12 @@ export async function searchOfferingsPaged(store, query) {
164
164
  const counts = { hosted: items.filter((o) => !o.local).length, local: items.filter((o) => o.local).length };
165
165
  if (q('local') === 'true') items = items.filter((o) => o.local);
166
166
  if (q('local') === 'false') items = items.filter((o) => !o.local);
167
+ // `ids`: offering or model ids, comma-separated (the registry UI sends the models installed in the
168
+ // visitor's own Ollama, which the browser read from it directly)
169
+ if (q('ids') != null) {
170
+ const ids = new Set(q('ids').split(',').map((s) => s.trim()).filter(Boolean));
171
+ items = items.filter((o) => ids.has(o.offering_id) || ids.has(o.binding?.model_id));
172
+ }
167
173
 
168
174
  // Rank depends on the filtered set: annotate copies, never the shared cached offerings.
169
175
  items = items.map((o) => ({ ...o }));
@@ -146,6 +146,12 @@
146
146
  .kindtabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
147
147
  .kindtabs .counts { font-weight: 400; margin-left: 0.25rem; }
148
148
  .runrow code { font-size: 0.78rem; }
149
+ .olbox { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; font-size: 0.82rem; margin: 0 0 0.7rem; }
150
+ .olbox input { font: inherit; font-size: 0.78rem; width: 12.5rem; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 0.3rem 0.5rem; }
151
+ .olbox .ok { color: var(--accent); font-weight: 600; }
152
+ .olhelp { font-size: 0.8rem; margin: 0 0 0.8rem; }
153
+ .olhelp pre { font-size: 0.74rem; overflow-x: auto; margin: 0.3rem 0 0.6rem; }
154
+ .chip.inst { color: var(--on-accent, #fff); background: var(--accent); border-color: var(--accent); }
149
155
  .switch { width: 30px; height: 17px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s; flex: none; }
150
156
  .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--panel); transition: left 0.15s; }
151
157
  .switchrow.on .switch { background: var(--accent); } .switchrow.on .switch::after { left: 15px; }
@@ -261,6 +267,13 @@
261
267
  </div>
262
268
  <p class="sub hostedonly">Search across registered AI nodes and imported catalogs — pick a model on the left, its full card is on the right. Claimed values are never blended with measured ones.</p>
263
269
  <p class="sub localonly" hidden>Models you download and run yourself with Ollama: no server, no account, and your data stays on your machine. There is nothing to verify remotely, so they are ranked by popularity (Ollama pulls); memory needs are 4-bit estimates.</p>
270
+ <div class="olbox localonly" id="ol-box" hidden>
271
+ <button class="btn sec" id="ol-check" type="button">Check my Ollama</button>
272
+ <input id="ol-base" aria-label="Your Ollama address" spellcheck="false">
273
+ <span id="ol-status" class="sub">Asks the Ollama on your own computer which models you have. The answer stays in your browser; nothing is sent to this registry.</span>
274
+ <span class="switchrow" id="f-installed" hidden><span class="switch"></span><b style="font-size:0.78rem">Installed only</b></span>
275
+ </div>
276
+ <div class="olhelp localonly" id="ol-help" hidden></div>
264
277
  <div class="toolbar">
265
278
  <input type="text" id="f-q" placeholder="Search models, families, nodes…">
266
279
  <span class="switchrow hostedonly" id="f-verified" title="identity-fingerprinted · context-verified · continuously probed"><span class="switch"></span><b style="font-size:0.78rem">Verified only</b></span>
@@ -633,7 +646,108 @@ document.querySelectorAll('#m-kind [data-kind]').forEach((b) => b.addEventListen
633
646
  try { localStorage.setItem('onp-list-kind', listKind); } catch { /* storage blocked */ }
634
647
  applyKind();
635
648
  search();
649
+ if (listKind === 'local') autoCheckOllama();
636
650
  }));
651
+
652
+ /* ---------- your Ollama: which local models are installed ----------
653
+ The browser asks the visitor's own Ollama (/api/tags) directly — only after a click, or on later
654
+ visits once a check has succeeded. The list of models never reaches this registry, except as the
655
+ ids of an "installed only" search. */
656
+ const OLLAMA_DEFAULT = 'http://127.0.0.1:11434';
657
+ const ollama = { base: OLLAMA_DEFAULT, installed: null, state: 'unknown', count: 0 };
658
+ try { ollama.base = localStorage.getItem('onp-ollama-base') || OLLAMA_DEFAULT; } catch { /* storage blocked */ }
659
+ $('#ol-base').value = ollama.base;
660
+ const olHost = () => { try { return new URL(ollama.base).host; } catch { return ollama.base; } };
661
+ /** Tags of this local model installed in the visitor's Ollama ("3b", "latest"), or null. */
662
+ function installedTags(o) {
663
+ if (!ollama.installed || !o?.local) return null;
664
+ return ollama.installed.get(String(o.binding?.model_id ?? o.offering_id).split(':')[0].toLowerCase()) ?? null;
665
+ }
666
+ async function checkOllama() {
667
+ ollama.base = ($('#ol-base').value.trim() || OLLAMA_DEFAULT).replace(/\/+$/, '');
668
+ try { localStorage.setItem('onp-ollama-base', ollama.base); } catch { /* storage blocked */ }
669
+ $('#ol-check').disabled = true;
670
+ $('#ol-status').textContent = 'asking your Ollama…';
671
+ try {
672
+ const r = await fetch(ollama.base + '/api/tags', { signal: AbortSignal.timeout(5000) });
673
+ if (!r.ok) throw new Error('status ' + r.status);
674
+ const { models = [] } = await r.json();
675
+ ollama.installed = new Map();
676
+ for (const m of models) {
677
+ const [base, tag = 'latest'] = String(m.name ?? m.model ?? '').toLowerCase().split(':');
678
+ if (!base) continue;
679
+ if (!ollama.installed.has(base)) ollama.installed.set(base, []);
680
+ ollama.installed.get(base).push(tag);
681
+ }
682
+ ollama.count = models.length;
683
+ ollama.state = 'ok';
684
+ try { localStorage.setItem('onp-ollama-ok', '1'); } catch { /* storage blocked */ }
685
+ } catch {
686
+ ollama.installed = null;
687
+ // A no-cors request still reaches a running server: if it goes through, Ollama is up and only
688
+ // refuses this page's origin (OLLAMA_ORIGINS); if it fails too, nothing answered.
689
+ let reachable = false;
690
+ try { await fetch(ollama.base + '/api/version', { mode: 'no-cors', signal: AbortSignal.timeout(4000) }); reachable = true; } catch { /* not running */ }
691
+ ollama.state = reachable ? 'blocked' : 'down';
692
+ } finally { $('#ol-check').disabled = false; }
693
+ const filtered = $('#f-installed').classList.contains('on');
694
+ renderOllamaStatus();
695
+ markInstalled();
696
+ if (filtered) search(); // re-filter by the new answer, or drop the filter if Ollama no longer answers
697
+ }
698
+ function autoCheckOllama() {
699
+ let remembered = false;
700
+ try { remembered = localStorage.getItem('onp-ollama-ok') === '1'; } catch { /* storage blocked */ }
701
+ if (remembered && ollama.state === 'unknown') checkOllama();
702
+ }
703
+ function renderOllamaStatus() {
704
+ const status = $('#ol-status'), help = $('#ol-help');
705
+ $('#f-installed').hidden = ollama.state !== 'ok';
706
+ if (ollama.state !== 'ok') $('#f-installed').classList.remove('on');
707
+ help.hidden = true;
708
+ if (ollama.state === 'ok') {
709
+ status.innerHTML = `<span class="ok">✓ Your Ollama at ${esc(olHost())}</span> has ${ollama.count} model${ollama.count === 1 ? '' : 's'} — installed ones are marked.`;
710
+ return;
711
+ }
712
+ const origin = location.origin;
713
+ if (ollama.state === 'blocked') {
714
+ status.innerHTML = `<b>Ollama is running at ${esc(olHost())} but does not allow this page.</b> Allow it once, then quit and restart Ollama:`;
715
+ help.innerHTML = `<b>Windows</b> (PowerShell or cmd)<pre><code>setx OLLAMA_ORIGINS "${esc(origin)}"</code></pre>
716
+ <b>macOS</b><pre><code>launchctl setenv OLLAMA_ORIGINS "${esc(origin)}"</code></pre>
717
+ <b>Linux</b> (systemd): <code>sudo systemctl edit ollama</code>, add the two lines below, then <code>sudo systemctl restart ollama</code><pre><code>[Service]
718
+ Environment="OLLAMA_ORIGINS=${esc(origin)}"</code></pre>
719
+ <span class="sub">This lets this page read which models you have and use the playground; other sites stay blocked. To allow more origins, separate them with commas.</span>`;
720
+ help.hidden = false;
721
+ return;
722
+ }
723
+ status.innerHTML = `<b>No Ollama answered at ${esc(olHost())}.</b> Start it, or install it from <a href="https://ollama.com/download" target="_blank" rel="noopener">ollama.com</a>, then check again. If your browser asked whether this page may reach devices on your network, allow it.`;
724
+ }
725
+ /** Mark installed models in the list, on the open card and in the playground note. */
726
+ function markInstalled() {
727
+ document.querySelectorAll('.mitem').forEach((el) => {
728
+ const o = lastResults.find((x) => `${x.node_id}/${x.offering_id}` === el.dataset.key);
729
+ if (!o?.local) return;
730
+ const tags = installedTags(o);
731
+ const chip = el.querySelector('.chip.loc, .chip.inst');
732
+ if (!chip) return;
733
+ chip.className = tags ? 'chip inst' : 'chip loc';
734
+ chip.textContent = tags ? 'INSTALLED' : 'LOCAL';
735
+ chip.title = tags ? 'installed in your Ollama: ' + tags.join(', ') : '';
736
+ });
737
+ const inst = $('#md-inst');
738
+ if (inst) {
739
+ const o = pgOfferings.find((x) => x.local);
740
+ const tags = installedTags(o);
741
+ inst.hidden = ollama.state !== 'ok' || !o;
742
+ inst.className = tags ? 'chip inst' : 'chip';
743
+ inst.textContent = tags ? `INSTALLED: ${tags.join(', ')}` : 'NOT INSTALLED';
744
+ }
745
+ pgUpdateNote();
746
+ }
747
+ $('#ol-check').addEventListener('click', checkOllama);
748
+ $('#ol-base').addEventListener('keydown', (e) => { if (e.key === 'Enter') checkOllama(); });
749
+ $('#f-installed').addEventListener('click', () => { $('#f-installed').classList.toggle('on'); search(); });
750
+ if (listKind === 'local') autoCheckOllama();
637
751
  const sup = new Set();
638
752
  document.querySelectorAll('.toggle').forEach((b) => b.addEventListener('click', () => {
639
753
  b.classList.toggle('on'); b.classList.contains('on') ? sup.add(b.dataset.sup) : sup.delete(b.dataset.sup); search();
@@ -750,7 +864,10 @@ async function search() {
750
864
  if ($('#f-eea').classList.contains('on')) p.set('jurisdiction', 'eea');
751
865
  if ($('#f-price').value) p.set('max_input_price', $('#f-price').value);
752
866
  if (sup.size) p.set('supports', [...sup].join(','));
753
- } else if ($('#f-mem').value) p.set('memory_gb', $('#f-mem').value);
867
+ } else {
868
+ if ($('#f-mem').value) p.set('memory_gb', $('#f-mem').value);
869
+ if ($('#f-installed').classList.contains('on') && ollama.installed) p.set('ids', [...ollama.installed.keys()].join(','));
870
+ }
754
871
  p.set('sort', $('#f-sort').value);
755
872
  listQuery = p.toString();
756
873
  try {
@@ -831,11 +948,12 @@ function sizesBit(o) {
831
948
  return (sz.length > 1 ? `${sz[0].tag}–${sz.at(-1).tag}` : sz[0].tag) + ` · from ~${sz[0].memory_gb} GB`;
832
949
  }
833
950
  function renderLocalItem(o) {
951
+ const tags = installedTags(o);
834
952
  return `<div class="mitem" data-artifact="${esc(o.model.artifact)}" data-key="${esc(o.node_id + '/' + o.offering_id)}">
835
953
  <div class="t">
836
954
  <span class="nm">${esc(o.model.name)}</span>
837
955
  ${o.specialty ? `<span class="chip">${esc(o.specialty)}</span>` : ''}
838
- <span class="chip loc">LOCAL</span>
956
+ ${tags ? `<span class="chip inst" title="installed in your Ollama: ${esc(tags.join(', '))}">INSTALLED</span>` : '<span class="chip loc">LOCAL</span>'}
839
957
  </div>
840
958
  <div class="b">
841
959
  ${sizesBit(o) ? `<span>${esc(sizesBit(o))}</span>` : ''}
@@ -1022,10 +1140,11 @@ async function loadModel(artifact) {
1022
1140
  `<span class="chip">${esc(first.modality)}</span>`,
1023
1141
  first.model.family ? `<span class="chip">${esc(first.model.family)}</span>` : '',
1024
1142
  isLocal && first.specialty && first.specialty !== first.modality ? `<span class="chip">${esc(first.specialty)}</span>` : '',
1025
- isLocal ? '<span class="chip loc">LOCAL</span>' : '',
1143
+ isLocal ? '<span class="chip loc">LOCAL</span><span class="chip" id="md-inst" hidden></span>' : '',
1026
1144
  ...extLinks,
1027
1145
  ].join('');
1028
1146
  $('#md-offtitle').textContent = isLocal ? 'Run it' : 'Offerings';
1147
+ if (isLocal) autoCheckOllama();
1029
1148
  $('#md-count').textContent = isLocal ? 'with Ollama, on your own machine' : list.length + ' node' + (list.length === 1 ? '' : 's');
1030
1149
 
1031
1150
  // description (imported catalogs carry one; absent otherwise)
@@ -1068,7 +1187,7 @@ async function loadModel(artifact) {
1068
1187
  $('#pg-customrow').hidden = pgOfferings.length > 0; // listing-only offerings leave just the custom endpoint
1069
1188
  $('#pg-out').textContent = '';
1070
1189
  $('#pg-meta').textContent = '';
1071
- pgUpdateNote();
1190
+ markInstalled();
1072
1191
  $('#pg-hosted').innerHTML = '';
1073
1192
  if (pgOfferings.length && pgOfferings.every(runsLocally)) showHostedAlternatives(first, artifact);
1074
1193
  const runName = first.binding?.model_id ?? first.model.name;
@@ -1194,6 +1313,15 @@ function pgUpdateNote() {
1194
1313
  note.innerHTML = `This listing has no server behind it: Send goes to ${app} on <b>your own computer</b> (${esc(localHost(o))}), `
1195
1314
  + `and answers only if ${app} is running with this model installed${o.local?.run ? ` (<code class="mono">${esc(o.local.run)}</code>)` : ''}. `
1196
1315
  + 'It tests your machine, not a node.';
1316
+ if (o.local && ollama.state === 'ok') {
1317
+ const tags = installedTags(o);
1318
+ const id = o.binding?.model_id ?? o.offering_id;
1319
+ note.innerHTML += tags
1320
+ ? ` <b>Installed in your Ollama</b> (${esc(tags.map((t) => id + ':' + t).join(', '))}), so ${embed ? 'Embed' : 'Send'} should answer.`
1321
+ : ` <b>Not installed in your Ollama yet:</b> <code class="mono">ollama pull ${esc(id)}</code> first.`;
1322
+ } else if (o.local && ollama.state === 'blocked') {
1323
+ note.innerHTML += ' <b>Your Ollama does not allow this page yet</b> — see "Check my Ollama" on the local models list.';
1324
+ }
1197
1325
  }
1198
1326
  /** On a local-only model page: hosted listings of the same model, so it can be tried without installing anything. */
1199
1327
  async function showHostedAlternatives(first, artifact) {