@opennodes/registry 0.1.56 → 0.1.57
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 +15 -5
- package/bin.js +3 -0
- package/package.json +3 -3
- package/src/importers.js +151 -0
- package/src/reimport.js +43 -5
- package/src/search.js +3 -0
- package/src/server.js +20 -1
- package/src/web/index.html +28 -4
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
The OpenNodes Protocol (ONP) reference registry — an open, federatable discovery service for AI inference nodes.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npx @opennodes/registry@0.1.
|
|
7
|
-
ONP_DB=./registry.db npx @opennodes/registry@0.1.
|
|
8
|
-
ONP_DB=postgres://user:pass@host/db npx @opennodes/registry@0.1.
|
|
6
|
+
npx @opennodes/registry@0.1.57 # web app + API on http://127.0.0.1:4300
|
|
7
|
+
ONP_DB=./registry.db npx @opennodes/registry@0.1.57 # persistent SQLite + persistent signing key
|
|
8
|
+
ONP_DB=postgres://user:pass@host/db npx @opennodes/registry@0.1.57
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
What it does:
|
|
@@ -29,14 +29,24 @@ What it does:
|
|
|
29
29
|
- **Errors:** a misspelt `trust`, `lineage`, `retention` or `no_training` value gets `400 bad-query`, never a wider result.
|
|
30
30
|
- **Request counts** (ONP-3 §6.6): how often search, recommend and the MCP tools returned each node, per ISO week, in node detail (`request_counts`, 12 weeks) and at `GET /v0/stats/requests?weeks=4&node_id=…`. Only node ids and counts are stored, never the query, task or client.
|
|
31
31
|
- **Search and transparent ranking** (`/v0/offerings`, `sort=rank|price|ttft|tps`) with per-result `rank_explanation`; **enforceable estimates** (`POST /v0/estimate`) pinned to card revisions; the **advisor** (`POST /v0/recommend`).
|
|
32
|
-
- **Catalog importers** — OpenRouter, Hugging Face Inference Providers, models.dev, the Ollama library — so search is useful on day one, with imported listings labeled and claimable by their operators.
|
|
32
|
+
- **Catalog importers** — OpenRouter, Hugging Face Inference Providers, models.dev, the Ollama library, the AI Horde — so search is useful on day one, with imported listings labeled and claimable by their operators.
|
|
33
33
|
- **Where models run** (`/v0/locations`, `?format=csv` or `?format=geojson`): serving sites by country with their evidence (`claimed`, `documented`, `measured`, `attested`), a map point, and the models each serves (ONP-2 §3a, ONP-3 §5c). `near=lat,lon&within_km=` finds what runs close to a point. The GeoJSON opens directly in QGIS, ArcGIS, kepler.gl or any web map; the web app draws it on an interactive map. Built from card locations, the per-provider OpenRouter import (the headquarters, datacentres and region tags providers declare there) and curated seeds in [`src/data/`](src/data/) (Canada, Europe, and every registry provider worldwide). Search takes `region=`, `location_basis=` and `exclude_lineage=`.
|
|
34
34
|
- **Residency commitments** (`/v0/residency`, `?format=csv`): what each provider officially promises about where prompts, outputs and stored data stay (`processing`, `storage`, `none` or `unstated`; scope; `default`, `opt_in` or `enterprise`), with source and date (ONP-2 §3b, ONP-3 §5d). Each site in `/v0/locations` carries the commitments that cover it, and `residency=processing|storage` filters by them.
|
|
35
35
|
- **MCP surface** at `/mcp` (including `find_locations` and `find_residency`) and a signed **export feed** for federation.
|
|
36
36
|
- **Web app** at `/`: OpenRouter-style catalog with model and node pages, hardware and measured performance, playground, multi-model chat (compare / jury / pipeline / iterative), the advisor, the Node Builder, and the "Where models run" page.
|
|
37
37
|
|
|
38
|
-
Environment: `PORT`, `ONP_DB`, `ONP_REGISTRY_KEY`, `ONP_ADMIN_TOKEN`, `ONP_TRUSTED_JURISDICTIONS` (trusted pool operators, default `EU,CA`), `ONP_LOCATION=1` (server-location checks; the trusted pool needs them), `ONP_ALLOW_PRIVATE=1` (dev only: permit localhost nodes), `ONP_STAGE_C=0`, `ONP_REIMPORT=1`, `ONP_REIMPORT_SOURCES` (default `openrouter,huggingface`; also `models-dev`, `ollama`, and `openrouter-providers`, which makes one request per OpenRouter model, so give it a long `ONP_REIMPORT_MS`), `ONP_LOCATION_SEEDS=0` (skip the curated location seeds), `ONP_MAP_TILES` (basemap for the locations map: unset = OpenStreetMap, `off` = no map, or an XYZ URL template with `ONP_MAP_ATTRIBUTION`). The map loads Leaflet from cdnjs, pinned with subresource integrity, only on the "Where models run" page. Viewers' browsers then fetch tiles from the tile server. OpenStreetMap's tile policy asks for light use, so a busy registry should point `ONP_MAP_TILES` at its own or a commercial tile service.
|
|
38
|
+
Environment: `PORT`, `ONP_DB`, `ONP_REGISTRY_KEY`, `ONP_ADMIN_TOKEN`, `ONP_TRUSTED_JURISDICTIONS` (trusted pool operators, default `EU,CA`), `ONP_LOCATION=1` (server-location checks; the trusted pool needs them), `ONP_ALLOW_PRIVATE=1` (dev only: permit localhost nodes), `ONP_STAGE_C=0`, `ONP_REIMPORT=1`, `ONP_REIMPORT_SOURCES` (default `openrouter,huggingface`; also `models-dev`, `ollama`, `horde` (refreshed every `ONP_REIMPORT_HORDE_MS`, default one hour), and `openrouter-providers`, which makes one request per OpenRouter model, so give it a long `ONP_REIMPORT_MS`), `ONP_LOCATION_SEEDS=0` (skip the curated location seeds), `ONP_MAP_TILES` (basemap for the locations map: unset = OpenStreetMap, `off` = no map, or an XYZ URL template with `ONP_MAP_ATTRIBUTION`). The map loads Leaflet from cdnjs, pinned with subresource integrity, only on the "Where models run" page. Viewers' browsers then fetch tiles from the tile server. OpenStreetMap's tile policy asks for light use, so a busy registry should point `ONP_MAP_TILES` at its own or a commercial tile service.
|
|
39
39
|
|
|
40
40
|
Location seeds are dated JSON files (`locations-{seed}.json`): providers, their sites with `basis`, `source` and `checked`, and the models each site serves. A provider whose models are listed becomes a listing-only node `import.seed.{seed}.{id}`; one that publishes no model list is shown with a note. An entry with `nodes` describes existing registry nodes instead: its sites are shown under the first of them, with that node's models when `placement` is `all`. With `placement: "all"`, or `serves_from: "{seed}:{id}"` (the node's whole API runs at that entry's sites), search and recommend also use the live sites as the node's serving locations, marked `via: "seed"`, for offerings whose card declares none, except for listings reached through the Hugging Face router or OpenRouter. Providers carry `kind` and `residency`; `residency_of: "{seed}:{id}"` reuses another entry's commitments (the Canadian and European regions of a cloud share the cloud's). Corrections and new countries are welcome by pull request: cite the provider's own page for `documented`, anything else is `claimed`.
|
|
41
41
|
|
|
42
|
+
The AI Horde import (`horde`, or `POST /v0/import/horde` with an admin token) lists the [AI Horde](https://aihorde.net)'s text models as one node, `import.aihorde.text`. The Horde is a free network run by the non-profit Haidra: volunteers run the models on their own machines, and the queue is ordered by kudos, a non-monetary credit for contributed compute.
|
|
43
|
+
- **What the registry reads:** only the public model status (`/api/v2/status/models?type=text&chat=true`, sent with the `Client-Agent` header the Horde asks for) and Haidra's [text model reference](https://github.com/Haidra-Org/AI-Horde-text-model-reference). The reference is AGPL-3.0, so only its facts are used: model names and Hugging Face URLs, not its descriptions. The registry never sends a prompt, and imported listings are never probed. A ping on one answers 409 `imported-listing`.
|
|
44
|
+
- **What gets listed:** only models with online chat workers and a Hugging Face record in the reference. Workers declare the names themselves, and a name without a public record is skipped, not given a made-up artefact.
|
|
45
|
+
- **Pricing and data policy:** each offering is `free` with `retention: logged`. Volunteers can read and keep prompts and outputs, so there is no operator country, the listings stay in the open pool, and the trusted view and sensitive requests never include them.
|
|
46
|
+
- **Lineage:** declared only for a developer's own from-scratch release (`HORDE_FROM_SCRATCH` in `src/importers.js`).
|
|
47
|
+
- **Reported figures:** worker count, queue and ETA are what the Horde reports, shown as `observed.upstream` with `basis: "reported"`. With nothing to list, the node is delisted until workers return.
|
|
48
|
+
- **Calling a model:** people call the models at Haidra's OpenAI-compatible front (`https://oai.aihorde.net/v1`) with their own AI Horde key.
|
|
49
|
+
|
|
50
|
+
ONP has no field yet for two things this listing has to say: that the people running the hardware can read prompts (proposed: `data_policy.statement`), and that queue order follows a credit rather than a price, with a free output allowance (proposed: `free_tier.priority` and `free_tier.max_output_tokens`). The node description says both in words.
|
|
51
|
+
|
|
42
52
|
Part of [OpenNodes](https://opennodes.io) · [specification](https://github.com/opennodes-io/opennodes/tree/main/spec) · Apache-2.0.
|
package/bin.js
CHANGED
|
@@ -47,6 +47,9 @@ const registry = await startRegistry({
|
|
|
47
47
|
reimport: process.env.ONP_REIMPORT === '1' ? {
|
|
48
48
|
intervalMs: Number(process.env.ONP_REIMPORT_MS ?? 6 * 3600 * 1000),
|
|
49
49
|
sources: (process.env.ONP_REIMPORT_SOURCES ?? 'openrouter,huggingface').split(','),
|
|
50
|
+
// `horde` (opt-in: add it to ONP_REIMPORT_SOURCES) refreshes hourly by default; workers come and go fast.
|
|
51
|
+
// Anything unset, unreadable or under a minute falls back to the hour: the Horde is never polled in a loop.
|
|
52
|
+
sourceIntervals: { horde: ((ms) => (Number.isFinite(ms) && ms >= 60_000 ? ms : 3600 * 1000))(Number(process.env.ONP_REIMPORT_HORDE_MS || NaN)) },
|
|
50
53
|
} : null,
|
|
51
54
|
});
|
|
52
55
|
if (process.env.ONP_ALLOW_PRIVATE === '1') console.log('WARNING: SSRF guard disabled (ONP_ALLOW_PRIVATE=1) — dev only');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opennodes/registry",
|
|
3
|
-
"version": "0.1.
|
|
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)",
|
|
3
|
+
"version": "0.1.57",
|
|
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, AI Horde), MCP surface, and the web app (catalog, chat, advisor, Node Builder)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "src/server.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@opennodes/core": "0.1.
|
|
46
|
+
"@opennodes/core": "0.1.26",
|
|
47
47
|
"pg": "^8.13.1"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/importers.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// DS-IMP-01: seed importers so search is useful before any real registration.
|
|
2
2
|
// Imported records enter as unverified, unsigned, source='import', and are
|
|
3
3
|
// excluded from verified tiers until claimed by their operator.
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
4
5
|
import { validateCard } from '@opennodes/core';
|
|
5
6
|
import { ARTIFACT } from './vendors.js';
|
|
6
7
|
|
|
8
|
+
const { version: REGISTRY_VERSION } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
9
|
+
|
|
7
10
|
const slug = (s) => String(s).toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^[^a-z0-9]+/, '').slice(0, 100);
|
|
8
11
|
const vendorSlug = (s) => slug(s).replace(/[._]/g, '-');
|
|
9
12
|
/** The value as a string if it is a concrete http(s) URL, else undefined. Templated
|
|
@@ -409,6 +412,154 @@ export async function importOpenRouter(store, catalog) {
|
|
|
409
412
|
return { providers: 1, offerings: offeringList.length, skipped: [] };
|
|
410
413
|
}
|
|
411
414
|
|
|
415
|
+
/* ------------------------------------------------------------------ AI Horde */
|
|
416
|
+
|
|
417
|
+
// The AI Horde (aihorde.net, run by the non-profit Haidra) is a free network of volunteer GPUs: workers
|
|
418
|
+
// poll a coordinator and run whole models on their own machines, and queue priority follows kudos, a
|
|
419
|
+
// non-monetary credit earned by contributing compute. The registry only reads the public model status
|
|
420
|
+
// and Haidra's model reference; it never sends a prompt there (imports are never probed).
|
|
421
|
+
|
|
422
|
+
/** Text models with at least one online chat worker: the ones the OpenAI-compatible front can serve. */
|
|
423
|
+
export const HORDE_STATUS_URL = 'https://aihorde.net/api/v2/status/models?type=text&chat=true';
|
|
424
|
+
/** Haidra's text model reference (AGPL-3.0): Horde model name -> display name and Hugging Face record (`url`). */
|
|
425
|
+
export const HORDE_TEXT_REFERENCE_URL = 'https://raw.githubusercontent.com/Haidra-Org/AI-Horde-text-model-reference/main/db.json';
|
|
426
|
+
/** Haidra's own OpenAI-compatible front for the Horde (documented in the AI-Horde server README). */
|
|
427
|
+
export const HORDE_OPENAI_BASE = 'https://oai.aihorde.net/v1';
|
|
428
|
+
/** Horde asks every client for `Client-Agent: name:version:contact`. The contact is the project, never a person. */
|
|
429
|
+
export const HORDE_CLIENT_AGENT = `opennodes-registry:${REGISTRY_VERSION}:https://opennodes.io`;
|
|
430
|
+
/** The Horde FAQ (who can read prompts) and the date it and the privacy policy were read for this data policy. */
|
|
431
|
+
export const HORDE_POLICY_SOURCE = 'https://aihorde.net/faq';
|
|
432
|
+
export const HORDE_POLICY_CHECKED = '2026-11-20';
|
|
433
|
+
const HORDE_NODE_ID = 'import.aihorde.text';
|
|
434
|
+
const HORDE_EMPTY = 'AI Horde import: no text model with online chat workers and a public model record';
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Lineage for Horde models, only where it is certain: a Hugging Face repo that is the developer's own
|
|
438
|
+
* from-scratch release (the developer trained the base itself, and any distillation teacher is its own
|
|
439
|
+
* model). A fine-tune, merge, quantization or re-upload under another account matches none of these and
|
|
440
|
+
* stays unknown: a list naming only the base developer would read as clean (ONP-2 §5). Distilled
|
|
441
|
+
* releases (`*-Distill-*`) are excluded even under a listed account.
|
|
442
|
+
*/
|
|
443
|
+
export const HORDE_FROM_SCRATCH = Object.freeze([
|
|
444
|
+
[/^Qwen\/Qwen\d/, 'CN'], // Qwen/Qwen3-14B, Qwen/Qwen3.8-Flash-Next
|
|
445
|
+
[/^zai-org\/GLM-/, 'CN'],
|
|
446
|
+
[/^google\/gemma-/, 'US'],
|
|
447
|
+
[/^meta-llama\/(Meta-)?Llama-/, 'US'],
|
|
448
|
+
[/^mistralai\/(Mistral|Ministral|Magistral)-/, 'FR'],
|
|
449
|
+
]);
|
|
450
|
+
|
|
451
|
+
/** `org/repo` of a Hugging Face model URL, or null. */
|
|
452
|
+
const hfRepo = (url) => {
|
|
453
|
+
const m = /^https:\/\/huggingface\.co\/([A-Za-z0-9][\w.-]*)\/([\w.-]+)\/?$/.exec(String(url ?? '').trim());
|
|
454
|
+
return m ? `${m[1]}/${m[2]}` : null;
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
/** The developer country for a from-scratch release, else null (unknown). */
|
|
458
|
+
export function hordeLineage(repo) {
|
|
459
|
+
if (!repo || /distill/i.test(repo)) return null;
|
|
460
|
+
return HORDE_FROM_SCRATCH.find(([re]) => re.test(repo))?.[1] ?? null;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** Horde chat feature declarations -> ONP `serving.supports` (each declared by at least one worker). */
|
|
464
|
+
const HORDE_FEATURES = {
|
|
465
|
+
tools: 'tool_calls', json_object: 'json_mode', json_schema: 'structured_outputs',
|
|
466
|
+
vision: 'vision', reasoning_effort: 'reasoning',
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Import the AI Horde's text models as one synthetic node (`import.aihorde.text`).
|
|
471
|
+
* `status` is GET /v2/status/models?type=text&chat=true; `reference` is Haidra's text model reference
|
|
472
|
+
* (db.json). An offering is made only for a model with online chat workers and a Hugging Face record in
|
|
473
|
+
* the reference: model names are declared by the workers, and an open-weight model is named by its public
|
|
474
|
+
* record (ONP-2 §5), so a name with no record is skipped, never given a made-up artifact. Worker count and
|
|
475
|
+
* queue go into the store as the `upstream` observation (reported by the Horde, not measured here).
|
|
476
|
+
* With nothing to list, the node is delisted rather than left showing workers that have gone.
|
|
477
|
+
*/
|
|
478
|
+
export async function importHorde(store, status, reference = {}) {
|
|
479
|
+
if (!Array.isArray(status)) return { providers: 0, offerings: 0, skipped: ['status is not a list'] };
|
|
480
|
+
const reportedAt = new Date().toISOString();
|
|
481
|
+
const offeringList = [];
|
|
482
|
+
const upstream = new Map();
|
|
483
|
+
const skipped = [];
|
|
484
|
+
for (const m of status) {
|
|
485
|
+
const name = typeof m?.name === 'string' ? m.name : null;
|
|
486
|
+
const workers = Number(m?.chat?.workers ?? 0);
|
|
487
|
+
if (!name || m.type !== 'text' || !(workers >= 1)) continue;
|
|
488
|
+
const ref = reference?.[name];
|
|
489
|
+
const repo = hfRepo(ref?.url);
|
|
490
|
+
if (!repo || !ARTIFACT.test(`hf:${repo}`)) { skipped.push(`${name}: no public model record`); continue; }
|
|
491
|
+
const features = Array.isArray(m.chat.features) ? m.chat.features : [];
|
|
492
|
+
const vision = features.includes('vision');
|
|
493
|
+
const supports = ['streaming', ...new Set(features.map((f) => HORDE_FEATURES[f]).filter(Boolean))];
|
|
494
|
+
const lineage = hordeLineage(repo);
|
|
495
|
+
let offeringId = slug(name.replace(/\//g, '-')) || 'model';
|
|
496
|
+
if (offeringList.some((o) => o.offering_id === offeringId)) offeringId = slug(`${offeringId}-${offeringList.length}`);
|
|
497
|
+
offeringList.push({
|
|
498
|
+
offering_id: offeringId,
|
|
499
|
+
modality: vision ? 'multimodal' : 'text',
|
|
500
|
+
modalities: { input: vision ? ['text', 'image'] : ['text'], output: ['text'] },
|
|
501
|
+
model: {
|
|
502
|
+
name: ref.display_name || ref.model_name || name,
|
|
503
|
+
family: vendorSlug(repo.split('/')[0]),
|
|
504
|
+
artifact: `hf:${repo}`,
|
|
505
|
+
...(lineage ? { lineage_origins: [lineage] } : {}),
|
|
506
|
+
// No `description`: the reference is AGPL-3.0, so only its facts (names, record URL) are used.
|
|
507
|
+
},
|
|
508
|
+
serving: {
|
|
509
|
+
supports,
|
|
510
|
+
...(Number.isInteger(m.chat.max_context_length) && m.chat.max_context_length > 0 ? { context_window: m.chat.max_context_length } : {}),
|
|
511
|
+
...(Number.isInteger(m.chat.max_length) && m.chat.max_length > 0 ? { max_output_tokens: m.chat.max_length } : {}),
|
|
512
|
+
},
|
|
513
|
+
binding: { profile: 'onp.openai.chat/v1', model_id: name },
|
|
514
|
+
// Free; queue order by kudos and the free output allowance have no ONP field yet (see the README).
|
|
515
|
+
pricing: { currency: 'USD', input_per_mtok: 0, output_per_mtok: 0, schemes: ['free'] },
|
|
516
|
+
// Volunteers run the models on their own machines and can read and keep prompts and outputs.
|
|
517
|
+
// Nobody can promise anything about training for them, so training_on_inputs stays unstated.
|
|
518
|
+
data_policy: { retention: 'logged', source: HORDE_POLICY_SOURCE, checked: HORDE_POLICY_CHECKED },
|
|
519
|
+
});
|
|
520
|
+
upstream.set(offeringId, {
|
|
521
|
+
source: 'aihorde', basis: 'reported', reported_at: reportedAt, workers,
|
|
522
|
+
queued_tokens: Number(m.queued ?? 0), jobs: Number(m.jobs ?? 0), eta_s: Number(m.eta ?? 0),
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const node = await store.getNode(HORDE_NODE_ID);
|
|
527
|
+
if (!offeringList.length) {
|
|
528
|
+
if (node?.state === 'indexed') await store.setState(HORDE_NODE_ID, 'delisted', HORDE_EMPTY);
|
|
529
|
+
return { providers: 0, offerings: 0, skipped: [...skipped, 'nothing to list'] };
|
|
530
|
+
}
|
|
531
|
+
const card = {
|
|
532
|
+
onp: '0.1',
|
|
533
|
+
revision: reportedAt,
|
|
534
|
+
node: {
|
|
535
|
+
id: HORDE_NODE_ID,
|
|
536
|
+
name: 'AI Horde (volunteer GPUs)',
|
|
537
|
+
description: 'Imported from the AI Horde public model status (aihorde.net), run by the non-profit Haidra. '
|
|
538
|
+
+ 'Free: volunteers run the models on their own machines, and the queue is ordered by kudos, so requests '
|
|
539
|
+
+ 'with the anonymous key 0000000000 wait longest; a free registered key gets better priority. '
|
|
540
|
+
+ 'Volunteer workers can technically read and keep prompts and outputs: never send personal data. '
|
|
541
|
+
+ 'Worker counts and queues are a snapshot reported by the Horde. Call it with your own AI Horde key '
|
|
542
|
+
+ 'at the OpenAI-compatible front. Terms: https://aihorde.net/terms. Privacy: https://aihorde.net/privacy. '
|
|
543
|
+
+ 'FAQ: https://aihorde.net/faq. Metadata only, unclaimed by the operator.',
|
|
544
|
+
operator: { name: 'AI Horde (Haidra, volunteer workers)', url: 'https://aihorde.net' },
|
|
545
|
+
},
|
|
546
|
+
endpoints: { openai: HORDE_OPENAI_BASE, health: 'https://aihorde.net/api/v2/status/heartbeat', docs: 'https://oai.aihorde.net/docs' },
|
|
547
|
+
offerings: offeringList,
|
|
548
|
+
payment: { schemes: [{ scheme: 'free' }] },
|
|
549
|
+
};
|
|
550
|
+
const err = await saveImportedCard(store, HORDE_NODE_ID, 'https://aihorde.net', 'import:aihorde', card);
|
|
551
|
+
if (err) return { providers: 0, offerings: 0, skipped: [...skipped, err] };
|
|
552
|
+
// Back after an empty snapshot; a delisting by anyone else stays.
|
|
553
|
+
if (node?.state === 'delisted' && (await store.transitionsFor(HORDE_NODE_ID)).at(-1)?.reason === HORDE_EMPTY) {
|
|
554
|
+
await store.setState(HORDE_NODE_ID, 'indexed', 'AI Horde import: chat workers back online');
|
|
555
|
+
}
|
|
556
|
+
for (const [offeringId, value] of upstream) await store.setObservation(HORDE_NODE_ID, offeringId, 'upstream', value);
|
|
557
|
+
return {
|
|
558
|
+
providers: 1, offerings: offeringList.length, skipped,
|
|
559
|
+
workers: [...upstream.values()].reduce((n, u) => n + u.workers, 0),
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
|
|
412
563
|
/* ------------------------------------------------------------------ locations (ONP-2 §3a) */
|
|
413
564
|
|
|
414
565
|
/** Save a listing-only card: like saveImportedCard, but without invocation endpoints. */
|
package/src/reimport.js
CHANGED
|
@@ -3,24 +3,51 @@
|
|
|
3
3
|
import {
|
|
4
4
|
importModelsDev, importHuggingFace, importOpenRouter,
|
|
5
5
|
importOllamaLibrary, parseOllamaLibrary,
|
|
6
|
-
importOpenRouterProviders, fetchOpenRouterEndpoints,
|
|
6
|
+
importOpenRouterProviders, fetchOpenRouterEndpoints, importHorde,
|
|
7
7
|
HF_ROUTER_URL, HF_HUB_URL, OPENROUTER_URL, OPENROUTER_PROVIDERS_URL, OLLAMA_LIBRARY_URL,
|
|
8
|
+
HORDE_STATUS_URL, HORDE_TEXT_REFERENCE_URL, HORDE_CLIENT_AGENT,
|
|
8
9
|
} from './importers.js';
|
|
9
10
|
|
|
10
11
|
export const MODELS_DEV_URL = 'https://models.dev/api.json';
|
|
11
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Sources that go stale faster than the catalog interval. AI Horde workers come and go within minutes,
|
|
15
|
+
* so its snapshot is refreshed hourly (one status read an hour is far inside the Horde's limits).
|
|
16
|
+
*/
|
|
17
|
+
export const SOURCE_INTERVALS = Object.freeze({ horde: 3600 * 1000 });
|
|
18
|
+
|
|
19
|
+
/** A source's interval: its own when it is a number of at least a minute, never above `intervalMs`. */
|
|
20
|
+
const intervalOf = (s, intervalMs, sourceIntervals) => {
|
|
21
|
+
const own = sourceIntervals?.[s];
|
|
22
|
+
return Math.min(Number.isFinite(own) && own >= 60_000 ? own : intervalMs, intervalMs);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** The sources due at `now`: never run, or last run at least their interval ago. */
|
|
26
|
+
export function dueSources(sources, lastRun, now, intervalMs, sourceIntervals = SOURCE_INTERVALS) {
|
|
27
|
+
return sources.filter((s) => !lastRun.has(s) || now - lastRun.get(s) >= intervalOf(s, intervalMs, sourceIntervals));
|
|
28
|
+
}
|
|
29
|
+
|
|
12
30
|
export function startReimport(store, {
|
|
13
31
|
safeFetch,
|
|
14
32
|
intervalMs = 6 * 3600 * 1000, // the HF re-test cadence
|
|
15
33
|
sources = ['openrouter', 'huggingface'],
|
|
34
|
+
sourceIntervals = SOURCE_INTERVALS,
|
|
16
35
|
onCycle = null,
|
|
17
36
|
} = {}) {
|
|
18
37
|
let stopped = false;
|
|
38
|
+
const lastRun = new Map();
|
|
19
39
|
const json = async (url, t = 120_000) => (await safeFetch(url, {}, t)).json();
|
|
40
|
+
// A refused or failed read must never look like an empty catalog: that would delist the Horde node.
|
|
41
|
+
const jsonOk = async (url, opts, t = 60_000) => {
|
|
42
|
+
const res = await safeFetch(url, opts, t);
|
|
43
|
+
if (!res.ok) throw new Error(`${new URL(url).host} answered ${res.status}`);
|
|
44
|
+
return res.json();
|
|
45
|
+
};
|
|
20
46
|
|
|
21
|
-
async function cycle() {
|
|
47
|
+
async function cycle(only = sources) {
|
|
22
48
|
const results = {};
|
|
23
|
-
for (const source of
|
|
49
|
+
for (const source of only) {
|
|
50
|
+
lastRun.set(source, Date.now());
|
|
24
51
|
try {
|
|
25
52
|
if (source === 'openrouter') {
|
|
26
53
|
results[source] = await importOpenRouter(store, await json(OPENROUTER_URL));
|
|
@@ -40,6 +67,14 @@ export function startReimport(store, {
|
|
|
40
67
|
} else if (source === 'ollama') {
|
|
41
68
|
const html = await (await safeFetch(OLLAMA_LIBRARY_URL, {}, 120_000)).text();
|
|
42
69
|
results[source] = await importOllamaLibrary(store, parseOllamaLibrary(html));
|
|
70
|
+
} else if (source === 'horde') {
|
|
71
|
+
// Public status only (with the Client-Agent the Horde asks of every client); no prompt is sent.
|
|
72
|
+
const status = await jsonOk(HORDE_STATUS_URL, { headers: { 'client-agent': HORDE_CLIENT_AGENT } });
|
|
73
|
+
// The reference gives each model its public record. Without it nothing can be listed honestly,
|
|
74
|
+
// so a failed read keeps the previous snapshot instead of emptying it.
|
|
75
|
+
const reference = await jsonOk(HORDE_TEXT_REFERENCE_URL, {}, 120_000);
|
|
76
|
+
if (!reference || typeof reference !== 'object' || !Object.keys(reference).length) throw new Error('empty AI Horde model reference');
|
|
77
|
+
results[source] = await importHorde(store, status, reference);
|
|
43
78
|
} else {
|
|
44
79
|
results[source] = { error: `unknown source: ${source}` };
|
|
45
80
|
}
|
|
@@ -51,10 +86,13 @@ export function startReimport(store, {
|
|
|
51
86
|
return results;
|
|
52
87
|
}
|
|
53
88
|
|
|
89
|
+
// Wake at the shortest interval among the sources and run only the ones that are due.
|
|
90
|
+
const tick = Math.min(intervalMs, ...sources.map((s) => intervalOf(s, intervalMs, sourceIntervals)));
|
|
54
91
|
const loop = async () => {
|
|
55
92
|
if (stopped) return;
|
|
56
|
-
|
|
57
|
-
if (
|
|
93
|
+
const due = dueSources(sources, lastRun, Date.now(), intervalMs, sourceIntervals);
|
|
94
|
+
if (due.length) await cycle(due).catch(() => {});
|
|
95
|
+
if (!stopped) setTimeout(loop, tick).unref?.();
|
|
58
96
|
};
|
|
59
97
|
setTimeout(loop, 2000).unref?.(); // first cycle shortly after boot
|
|
60
98
|
|
package/src/search.js
CHANGED
|
@@ -195,6 +195,9 @@ async function buildOfferings(store) {
|
|
|
195
195
|
probes: checks.length,
|
|
196
196
|
ttft_ms: obs.ttft_ms ?? null,
|
|
197
197
|
tps: obs.tps ?? null,
|
|
198
|
+
// What an imported network reports about itself (AI Horde: workers, queue), basis `reported`:
|
|
199
|
+
// the upstream's own figures at `reported_at`, never measured by this registry.
|
|
200
|
+
...(obs.upstream ? { upstream: obs.upstream } : {}),
|
|
198
201
|
availability,
|
|
199
202
|
},
|
|
200
203
|
endpoints: card.endpoints,
|
package/src/server.js
CHANGED
|
@@ -27,8 +27,9 @@ import { checkNodeLocation, declaredOrigins } from './location.js';
|
|
|
27
27
|
import {
|
|
28
28
|
importModelsDev, importHuggingFace, importOpenRouter,
|
|
29
29
|
importOllamaLibrary, parseOllamaLibrary,
|
|
30
|
-
importOpenRouterProviders, fetchOpenRouterEndpoints, importLocationSeed,
|
|
30
|
+
importOpenRouterProviders, fetchOpenRouterEndpoints, importLocationSeed, importHorde,
|
|
31
31
|
HF_ROUTER_URL, HF_HUB_URL, OPENROUTER_URL, OPENROUTER_PROVIDERS_URL, OLLAMA_LIBRARY_URL,
|
|
32
|
+
HORDE_STATUS_URL, HORDE_TEXT_REFERENCE_URL, HORDE_CLIENT_AGENT,
|
|
32
33
|
} from './importers.js';
|
|
33
34
|
import { locationRoutes, loadLocationSeeds, seedPlacements, seedNodeSites, nodeServes } from './locations.js';
|
|
34
35
|
import { makeRequestCounter, nodeIdsIn } from './counts.js';
|
|
@@ -423,6 +424,9 @@ export async function startRegistry({
|
|
|
423
424
|
if (!registerLimiter(clientOf(req))) return problem(res, 429, 'rate-limited', 'too many refresh requests from this address; try again later');
|
|
424
425
|
const node = await store.getNode(params.id);
|
|
425
426
|
if (!node) return problem(res, 404, 'unknown-node', params.id);
|
|
427
|
+
// A ping runs Stage A, which calls the endpoint. Imports are never probed: some upstreams (the AI
|
|
428
|
+
// Horde) answer requests without a key, so a public ping must not become traffic to them.
|
|
429
|
+
if (node.source === 'import') return problem(res, 409, 'imported-listing', `${node.id} is an imported catalog listing; the registry does not probe it`);
|
|
426
430
|
try {
|
|
427
431
|
const { card } = await indexCard(params.id, node.card_url);
|
|
428
432
|
if (location) relocateIfStale(params.id, card).catch(() => {}); // background: a new API host is checked again now
|
|
@@ -780,6 +784,21 @@ export async function startRegistry({
|
|
|
780
784
|
sendJson(res, 200, await importOpenRouter(store, catalog));
|
|
781
785
|
}],
|
|
782
786
|
|
|
787
|
+
// AI Horde importer (admin): inline {status, reference}, or read the live public status (with the
|
|
788
|
+
// Client-Agent the Horde asks for) and Haidra's text model reference. Nothing is sent to a worker.
|
|
789
|
+
['POST', '/v0/import/horde', async (req, res) => {
|
|
790
|
+
if (!adminOk(req, res)) return;
|
|
791
|
+
const body = await readJson(req, 20_000_000);
|
|
792
|
+
const read = async (url, opts) => {
|
|
793
|
+
const r = await safeFetch(url, opts, 60_000);
|
|
794
|
+
if (!r.ok) throw new Error(`${new URL(url).host} answered ${r.status}`);
|
|
795
|
+
return r.json();
|
|
796
|
+
};
|
|
797
|
+
const status = body.status ?? await read(HORDE_STATUS_URL, { headers: { 'client-agent': HORDE_CLIENT_AGENT } });
|
|
798
|
+
const reference = body.reference ?? await read(HORDE_TEXT_REFERENCE_URL, {});
|
|
799
|
+
sendJson(res, 200, await importHorde(store, status, reference));
|
|
800
|
+
}],
|
|
801
|
+
|
|
783
802
|
// OpenRouter per-provider importer with declared locations (admin): inline
|
|
784
803
|
// {providers, models, endpoints: {modelId: [...]}}, or fetch the live APIs (one call per model).
|
|
785
804
|
['POST', '/v0/import/openrouter-providers', async (req, res) => {
|
package/src/web/index.html
CHANGED
|
@@ -924,11 +924,19 @@ const invocable = (o) => o.invocable !== false && Boolean(o.endpoints?.openai);
|
|
|
924
924
|
const runsLocally = (o) => Boolean(o.local) || /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/i.test(o.endpoints?.openai ?? '');
|
|
925
925
|
/** endpoints.docs only when it is a plain web link (cards are third-party data). */
|
|
926
926
|
const docsUrl = (endpoints) => /^https?:\/\//i.test(endpoints?.docs ?? '') ? endpoints.docs : null;
|
|
927
|
+
/** The AI Horde import: volunteers' machines, so a catalog listing in the open pool, never a claim to verify. */
|
|
928
|
+
const HORDE_NODE = 'import.aihorde.text';
|
|
927
929
|
function provLine(o) {
|
|
928
930
|
const obs = o.observed || {};
|
|
929
931
|
const bits = [`revision ${esc((o.card_revision || '').slice(0, 10))}`];
|
|
930
932
|
if (obs.probes > 0) bits.push(`probes ${Math.round((obs.probe_success ?? 0) * obs.probes)}/${obs.probes} pass`);
|
|
931
|
-
if (o.source === 'import') bits.push('catalog import
|
|
933
|
+
if (o.source === 'import') bits.push(o.node_id === HORDE_NODE ? 'catalog import from the AI Horde\'s public status — never probed by this registry'
|
|
934
|
+
: 'catalog import — operator can claim this listing to get verified');
|
|
935
|
+
const up = obs.upstream;
|
|
936
|
+
if (up && Number.isFinite(up.workers)) {
|
|
937
|
+
bits.push(`${up.workers} volunteer worker${up.workers === 1 ? '' : 's'} online, queue ${Number(up.eta_s) > 0 ? `≈${Math.round(up.eta_s)} s` : 'empty'}`
|
|
938
|
+
+ ` — reported by ${up.source === 'aihorde' ? 'the AI Horde' : 'the upstream'}${up.reported_at ? ` at ${esc(String(up.reported_at).slice(0, 16).replace('T', ' '))} UTC` : ''}, not measured here`);
|
|
939
|
+
}
|
|
932
940
|
if (!invocable(o)) bits.push('listing only — no known API endpoint, so it cannot be called from here'
|
|
933
941
|
+ (docsUrl(o.endpoints) ? ` (<a href="${esc(docsUrl(o.endpoints))}" target="_blank" rel="noopener">provider docs ↗</a>)` : ''));
|
|
934
942
|
return bits.join(' · ');
|
|
@@ -1709,7 +1717,9 @@ function importKeyHint(offering, base, key) {
|
|
|
1709
1717
|
const host = new URL(base).host;
|
|
1710
1718
|
if (offering.local || /^(localhost|127\.0\.0\.1|\[::1\])(:|$)/.test(host)) return null; // your own machine: no key
|
|
1711
1719
|
const where = host.includes('huggingface') ? 'a Hugging Face token (huggingface.co/settings/tokens)'
|
|
1712
|
-
: host.includes('openrouter') ? 'an OpenRouter API key (openrouter.ai/keys)'
|
|
1720
|
+
: host.includes('openrouter') ? 'an OpenRouter API key (openrouter.ai/keys)'
|
|
1721
|
+
: host === 'oai.aihorde.net' ? 'an AI Horde key (free at aihorde.net/register; the anonymous key 0000000000 works but waits longest; volunteers can read prompts, so no personal data)'
|
|
1722
|
+
: `an API key for ${host}`;
|
|
1713
1723
|
return `This is an imported catalog listing served by ${host}: your browser calls it directly, which needs ${where} — paste it in the API key field (stored only in this browser). Or run it locally with BYOK: npx @opennodes/cli gateway --key ${host}=<key>. Registered OpenNodes nodes need no key.`;
|
|
1714
1724
|
}
|
|
1715
1725
|
async function callTarget(t, messages, maxTokens = 1024) {
|
|
@@ -2563,6 +2573,19 @@ async function loadFeed() {
|
|
|
2563
2573
|
const CLAIM_GUIDE = 'https://github.com/opennodes-io/opennodes/tree/main/node-kit#card-only-listing-you-already-run-an-openai-compatible-api';
|
|
2564
2574
|
function claimBanner(n, card) {
|
|
2565
2575
|
if (n.source !== 'import' || ['delisted', 'claimed'].includes(n.state)) return '';
|
|
2576
|
+
if (n.id === HORDE_NODE) {
|
|
2577
|
+
return `<div class="panel pad" style="max-width:56rem; margin:0.4rem 0 0.8rem; border-left:3px solid var(--accent)">
|
|
2578
|
+
<p style="margin:0 0 0.35rem; font-weight:600">About this listing</p>
|
|
2579
|
+
<p style="margin:0 0 0.6rem; font-size:0.86rem; color:var(--muted); overflow-wrap:anywhere">The AI Horde is a free network run by the non-profit Haidra: volunteers run the models on their own machines, and the queue is ordered by kudos. This registry reads only the Horde's public model status and Haidra's model reference, about once an hour, and never sends a prompt. Volunteer workers can technically read prompts and outputs, so these listings stay in the open pool: never use them for personal data. To call a model, use your own AI Horde key (or the anonymous key <span class="mono">0000000000</span>, which waits longest) at the Horde's OpenAI-compatible front. Haidra: to change or remove this listing, write to us.</p>
|
|
2580
|
+
<span style="display:inline-flex; gap:0.6rem; flex-wrap:wrap; font-size:0.84rem">
|
|
2581
|
+
<a href="https://aihorde.net/terms" target="_blank" rel="noopener">Horde terms ↗</a>
|
|
2582
|
+
<a href="https://aihorde.net/privacy" target="_blank" rel="noopener">Privacy ↗</a>
|
|
2583
|
+
<a href="https://aihorde.net/faq" target="_blank" rel="noopener">FAQ ↗</a>
|
|
2584
|
+
<a href="https://aihorde.net/register" target="_blank" rel="noopener">Get a free key ↗</a>
|
|
2585
|
+
<a href="mailto:operators@opennodes.io?subject=${encodeURIComponent('AI Horde listing')}">operators@opennodes.io</a>
|
|
2586
|
+
</span>
|
|
2587
|
+
</div>`;
|
|
2588
|
+
}
|
|
2566
2589
|
const name = card.node?.operator?.name || card.node?.name || n.id;
|
|
2567
2590
|
let host = null;
|
|
2568
2591
|
try { host = new URL(card.endpoints?.openai).hostname; } catch { /* listing without an API */ }
|
|
@@ -2625,8 +2648,9 @@ function dataPolicyLine(o) {
|
|
|
2625
2648
|
}
|
|
2626
2649
|
|
|
2627
2650
|
/** Server-location check (registry location.js) in plain words; `check` is the node's server_check for its current card. */
|
|
2628
|
-
function locationRow(loc, imported, check) {
|
|
2651
|
+
function locationRow(loc, imported, check, country = null) {
|
|
2629
2652
|
const claim = imported ? 'inferred for this unclaimed listing' : 'declared by the operator';
|
|
2653
|
+
if (!loc && imported && !country) return `<tr><td style="color:var(--muted)" class="mono">server</td><td style="font-size:0.8rem">not checked <span style="color:var(--muted)">· this listing names no operator country, so it has nothing to be checked against</span></td></tr>`;
|
|
2630
2654
|
if (!loc) return `<tr><td style="color:var(--muted)" class="mono">server</td><td style="font-size:0.8rem">not checked yet <span style="color:var(--muted)">· the operator's country is ${claim}, not verified</span></td></tr>`;
|
|
2631
2655
|
const srv = loc.server || {};
|
|
2632
2656
|
const words = {
|
|
@@ -2703,7 +2727,7 @@ async function loadNode(id) {
|
|
|
2703
2727
|
<div class="panel pad" style="max-width:56rem; margin-top:0.6rem"><table class="grid">
|
|
2704
2728
|
<tr><td style="color:var(--muted); width:8rem" class="mono">endpoint</td><td class="mono" style="font-size:0.74rem">${card.endpoints?.openai ? esc(card.endpoints.openai) : '— <span style="font-family:inherit; color:var(--muted)">listing only: no known API endpoint, not callable from OpenNodes</span>'}</td></tr>
|
|
2705
2729
|
${docsUrl(card.endpoints) ? `<tr><td style="color:var(--muted)" class="mono">docs</td><td class="mono" style="font-size:0.74rem"><a href="${esc(docsUrl(card.endpoints))}" target="_blank" rel="noopener">${esc(docsUrl(card.endpoints))}</a></td></tr>` : ''}
|
|
2706
|
-
${locationRow(n.location, n.source === 'import', n.server_check)}
|
|
2730
|
+
${locationRow(n.location, n.source === 'import', n.server_check, card.node?.operator?.country ?? null)}
|
|
2707
2731
|
${card.hardware ? `<tr><td style="color:var(--muted)" class="mono">hardware</td><td style="font-size:0.78rem">${hwStr({ hardware: card.hardware })}</td></tr>` : ''}
|
|
2708
2732
|
${returnedRow(n.request_counts, n.id)}
|
|
2709
2733
|
${testedRow(n, offers.length, untested.size)}
|