omnius 1.0.591 → 1.0.592
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/.aiwg/addons/omnius-docs/README.md +15 -1
- package/.aiwg/addons/omnius-docs/manifest.json +28 -68
- package/.aiwg/addons/omnius-docs/skills/agent-failure-recovery/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/browser-interaction-validation/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/evidence-directed-delivery/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/hardware-evidence-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/omnius-docs/SKILL.md +17 -7
- package/.aiwg/addons/omnius-docs/skills/omnius-inference-docs/SKILL.md +27 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-integration-docs/SKILL.md +21 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-ops-docs/SKILL.md +2 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-realtime-docs/SKILL.md +2 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-sponsor-docs/SKILL.md +2 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-telegram-docs/SKILL.md +2 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-tools-docs/SKILL.md +23 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-version-compatibility-docs/SKILL.md +23 -0
- package/.aiwg/addons/omnius-docs/skills/runtime-provenance-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/secrets-and-config-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/test-surface-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/workspace-reality-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-rest-docs/README.md +3 -0
- package/.aiwg/addons/omnius-rest-docs/manifest.json +27 -20
- package/.aiwg/addons/omnius-rest-docs/skills/omnius-rest-docs/SKILL.md +9 -5
- package/README.md +36 -0
- package/dist/discovery.d.ts +50 -0
- package/dist/index.js +5975 -4021
- package/dist/library.d.ts +7 -0
- package/dist/library.js +950 -0
- package/dist/postinstall-daemon.cjs +18 -0
- package/dist/providerRegistry.d.ts +80 -0
- package/dist/service-version.d.ts +35 -0
- package/docs/.vitepress/config.mts +8 -0
- package/docs/DISCOVERY.json +20224 -0
- package/docs/DISCOVERY.md +648 -0
- package/docs/HANDOFF-crl-encoder-decoder-fix.md +129 -0
- package/docs/agent-memory/INDEX.md +9 -4
- package/docs/agent-memory/index.md +7 -0
- package/docs/concept-relational-language.md +869 -0
- package/docs/context-management-medium-models-proposal.md +449 -0
- package/docs/dedup-false-positive-meta-analysis.md +96 -0
- package/docs/discovery/catalog-overrides.json +724 -0
- package/docs/duplicate-calls-root-cause-analysis.md +91 -0
- package/docs/duplicate-calls-root-cause-deep.md +155 -0
- package/docs/ephemeral-skill-pack-small-context.md +57 -0
- package/docs/explorations/context-window-todo-association.md +156 -0
- package/docs/explorations/todo-association-verify.json +30 -0
- package/docs/explorations/verification-ledger.json +45 -0
- package/docs/explorations/verify-todo-association.sh +30 -0
- package/docs/flowstate.md +806 -0
- package/docs/getting-started/install.md +24 -0
- package/docs/getting-started/model-providers.md +13 -0
- package/docs/guides/agent-integration.md +87 -0
- package/docs/guides/bring-your-own-inference.md +126 -0
- package/docs/guides/tools-and-web-search.md +95 -0
- package/docs/index.md +14 -0
- package/docs/longhaul-35b-workorders.md +496 -0
- package/docs/memory-integration-analysis.md +303 -0
- package/docs/model-capability-awareness-and-multimodal-memory-root-fix.md +799 -0
- package/docs/multimodal-identity-memory-implementation.md +76 -0
- package/docs/omnius-self-edit-eval-2026-06-10.md +169 -0
- package/docs/opencode-agentic-loop-comparison.md +290 -0
- package/docs/operations/security-and-remote-access.md +2 -2
- package/docs/operations/version-compatibility.md +63 -0
- package/docs/proposals/git-progress-tracking-strategy.md +289 -0
- package/docs/proposals/opencode-modules/backendAdapter.ts +443 -0
- package/docs/proposals/opencode-modules/childSession.ts +288 -0
- package/docs/proposals/opencode-modules/compactionAgent.ts +101 -0
- package/docs/proposals/opencode-modules/orchestrator.ts +387 -0
- package/docs/proposals/opencode-modules/runner.ts +258 -0
- package/docs/reference/auth-map.md +87 -196
- package/docs/reference/configuration.md +27 -0
- package/docs/reference/rest-api.md +7 -0
- package/docs/reference/slash-commands.md +125 -2
- package/docs/research/_archived/README.md +18 -0
- package/docs/research/_archived/context_window_attention_model.py +418 -0
- package/docs/research/_archived/context_window_attention_spec.md +55 -0
- package/docs/research/_archived/context_window_attention_weights.json +68 -0
- package/docs/research/k-splanifolds.pdf +0 -0
- package/docs/research/personality-verbosity-control.md +293 -0
- package/docs/rest/INDEX.md +7 -0
- package/docs/rest/QUICKREF.md +18 -0
- package/docs/rest/REST-DOCS-MANIFEST.json +1 -0
- package/docs/rest/auth-and-scopes.md +7 -1
- package/docs/rest/endpoints/discovery.md +44 -0
- package/docs/rest/endpoints/events.md +5 -0
- package/docs/rest/endpoints/tools.md +9 -0
- package/docs/reviews/adversary-system-review.md +42 -0
- package/docs/sana-and-video-generation-integration-plan.md +712 -0
- package/docs/session-diary-llm-training-analysis.md +218 -0
- package/docs/telegram-dmn-curiosity-outreach-scaffold.md +91 -0
- package/docs/telegram-mid-horizon-download-loop-handoff.md +468 -0
- package/docs/telegram-reflection-corpus-integration-plan.md +306 -0
- package/docs/telegram-unified-tooling-architecture.md +332 -0
- package/docs/threat-model.md +868 -0
- package/docs/trajectory-grounding.md +160 -0
- package/docs/voice-flow-architecture.md +489 -0
- package/docs/work-orders/WO-AM-GAPS.md +638 -0
- package/docs/work-orders/daemon-hud-ui-overhaul.md +82 -0
- package/docs/work-orders/hermes-architecture-deltas/01-public-scrutiny-provenance-control/INDEX.md +21 -0
- package/docs/work-orders/hermes-architecture-deltas/01-public-scrutiny-provenance-control/WORKORDER.md +225 -0
- package/docs/work-orders/hermes-architecture-deltas/02-context-engine-plugin-boundary/INDEX.md +20 -0
- package/docs/work-orders/hermes-architecture-deltas/02-context-engine-plugin-boundary/WORKORDER.md +198 -0
- package/docs/work-orders/hermes-architecture-deltas/03-typed-gateway-event-stream/INDEX.md +19 -0
- package/docs/work-orders/hermes-architecture-deltas/03-typed-gateway-event-stream/WORKORDER.md +172 -0
- package/docs/work-orders/hermes-architecture-deltas/04-task-local-gateway-context/INDEX.md +19 -0
- package/docs/work-orders/hermes-architecture-deltas/04-task-local-gateway-context/WORKORDER.md +169 -0
- package/docs/work-orders/hermes-architecture-deltas/05-process-lifecycle-monitoring-notifications/INDEX.md +22 -0
- package/docs/work-orders/hermes-architecture-deltas/05-process-lifecycle-monitoring-notifications/WORKORDER.md +189 -0
- package/docs/work-orders/hermes-architecture-deltas/06-vision-evidence-routing-ladder/INDEX.md +22 -0
- package/docs/work-orders/hermes-architecture-deltas/06-vision-evidence-routing-ladder/WORKORDER.md +199 -0
- package/docs/work-orders/hermes-architecture-deltas/07-durable-multi-agent-kanban/INDEX.md +20 -0
- package/docs/work-orders/hermes-architecture-deltas/07-durable-multi-agent-kanban/WORKORDER.md +174 -0
- package/docs/work-orders/hermes-architecture-deltas/08-completion-critic-reconciliation-ledger/INDEX.md +22 -0
- package/docs/work-orders/hermes-architecture-deltas/08-completion-critic-reconciliation-ledger/WORKORDER.md +226 -0
- package/docs/work-orders/hermes-architecture-deltas/INDEX.md +38 -0
- package/docs/work-orders/omnius-context-engineering-behavior-fixes.md +281 -0
- package/docs/work-orders/telegram-dropbear-context-rca-workorder.md +202 -0
- package/docs/work-orders/world-class-memory-compiler/README.md +162 -0
- package/docs/work-orders/world-class-memory-compiler/TRACKER.md +179 -0
- package/docs/work-orders/world-class-memory-compiler/WO-01-exact-request-budget.md +79 -0
- package/docs/work-orders/world-class-memory-compiler/WO-02-typed-memory-fabric.md +65 -0
- package/docs/work-orders/world-class-memory-compiler/WO-03-dependency-working-set.md +55 -0
- package/docs/work-orders/world-class-memory-compiler/WO-04-inference-memory-compiler.md +67 -0
- package/docs/work-orders/world-class-memory-compiler/WO-05-artifact-fidelity-materialization.md +72 -0
- package/docs/work-orders/world-class-memory-compiler/WO-06-temporal-hybrid-retrieval.md +49 -0
- package/docs/work-orders/world-class-memory-compiler/WO-07-evaluation-harness.md +45 -0
- package/docs/work-orders/world-class-memory-compiler/WO-08-rollout-legacy-removal.md +45 -0
- package/docs/x402-remote-inference-plan.md +323 -0
- package/npm-shrinkwrap.json +108 -117
- package/package.json +7 -6
- package/templates/AGENTS.md +6 -0
- package/templates/OMNIUS.md +20 -0
package/dist/library.js
ADDED
|
@@ -0,0 +1,950 @@
|
|
|
1
|
+
import { createRequire as __omnius_createRequire } from "node:module"; import { fileURLToPath as __omnius_fileURLToPath } from "node:url"; import { dirname as __omnius_dirname } from "node:path"; const require = __omnius_createRequire(import.meta.url); const __filename = __omnius_fileURLToPath(import.meta.url); const __dirname = __omnius_dirname(__filename);
|
|
2
|
+
|
|
3
|
+
// packages/cli/src/discovery.ts
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { dirname, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
var DISCOVERY_SCHEMA_VERSION = "1.0.0";
|
|
8
|
+
var DEFAULT_LIMIT = 20;
|
|
9
|
+
var MAX_LIMIT = 200;
|
|
10
|
+
function discoveryCandidates() {
|
|
11
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const configured = process.env["OMNIUS_DOCS_ROOT"]?.trim();
|
|
13
|
+
const candidates = [
|
|
14
|
+
configured ? configured.endsWith(".json") ? resolve(configured) : resolve(configured, "DISCOVERY.json") : "",
|
|
15
|
+
// Published package: dist/index.js or dist/library.js -> ../docs.
|
|
16
|
+
resolve(here, "..", "docs", "DISCOVERY.json"),
|
|
17
|
+
// Workspace source/dist layouts.
|
|
18
|
+
resolve(here, "..", "..", "..", "docs", "DISCOVERY.json"),
|
|
19
|
+
resolve(here, "..", "..", "..", "..", "docs", "DISCOVERY.json"),
|
|
20
|
+
resolve(process.cwd(), "docs", "DISCOVERY.json")
|
|
21
|
+
];
|
|
22
|
+
return [...new Set(candidates.filter(Boolean))];
|
|
23
|
+
}
|
|
24
|
+
function findDiscoveryCatalogPath() {
|
|
25
|
+
for (const candidate of discoveryCandidates()) {
|
|
26
|
+
if (existsSync(candidate)) return candidate;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
function isDiscoveryEntry(value) {
|
|
31
|
+
if (!value || typeof value !== "object") return false;
|
|
32
|
+
const item = value;
|
|
33
|
+
return typeof item["id"] === "string" && typeof item["kind"] === "string" && typeof item["title"] === "string" && typeof item["summary"] === "string";
|
|
34
|
+
}
|
|
35
|
+
function loadDiscoveryCatalog() {
|
|
36
|
+
const path = findDiscoveryCatalogPath();
|
|
37
|
+
if (!path) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
"Omnius discovery catalog is unavailable. Reinstall the package or set OMNIUS_DOCS_ROOT to the bundled docs directory."
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
43
|
+
if (typeof parsed.schema_version !== "string" || !Array.isArray(parsed.entries) || !parsed.entries.every(isDiscoveryEntry)) {
|
|
44
|
+
throw new Error(`Invalid Omnius discovery catalog: ${path}`);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
...parsed,
|
|
48
|
+
schema_version: parsed.schema_version,
|
|
49
|
+
entries: [...parsed.entries].sort((a, b) => a.id.localeCompare(b.id))
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function normalized(value) {
|
|
53
|
+
return value.normalize("NFKC").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
54
|
+
}
|
|
55
|
+
function tokens(value) {
|
|
56
|
+
return [...new Set(normalized(value).split(/\s+/).filter(Boolean))];
|
|
57
|
+
}
|
|
58
|
+
function scoreEntry(entry, query) {
|
|
59
|
+
const q = normalized(query);
|
|
60
|
+
if (!q) return 1;
|
|
61
|
+
const queryTokens = tokens(q);
|
|
62
|
+
const id = normalized(entry.id);
|
|
63
|
+
const title = normalized(entry.title);
|
|
64
|
+
const aliases = (entry.aliases ?? []).map(normalized);
|
|
65
|
+
const keywords = (entry.keywords ?? []).map(normalized);
|
|
66
|
+
const summary = normalized(entry.summary);
|
|
67
|
+
const referenced = normalized(
|
|
68
|
+
[
|
|
69
|
+
...(entry.interfaces ?? []).map((item) => `${item.type} ${item.target} ${item.description ?? ""}`),
|
|
70
|
+
...(entry.references ?? []).map((item) => `${item.type} ${item.target} ${item.relation ?? ""}`)
|
|
71
|
+
].join(" ")
|
|
72
|
+
);
|
|
73
|
+
let score = 0;
|
|
74
|
+
if (id === q) score += 1e3;
|
|
75
|
+
if (aliases.includes(q)) score += 800;
|
|
76
|
+
if (title === q) score += 700;
|
|
77
|
+
if (id.startsWith(q) || title.startsWith(q)) score += 300;
|
|
78
|
+
let matchedTokens = 0;
|
|
79
|
+
for (const token of queryTokens) {
|
|
80
|
+
let matched = false;
|
|
81
|
+
if (tokens(`${id} ${title}`).includes(token)) {
|
|
82
|
+
score += 40;
|
|
83
|
+
matched = true;
|
|
84
|
+
}
|
|
85
|
+
if (aliases.some((value) => tokens(value).includes(token))) {
|
|
86
|
+
score += 25;
|
|
87
|
+
matched = true;
|
|
88
|
+
}
|
|
89
|
+
if (keywords.some((value) => tokens(value).includes(token))) {
|
|
90
|
+
score += 25;
|
|
91
|
+
matched = true;
|
|
92
|
+
}
|
|
93
|
+
if (tokens(summary).includes(token)) {
|
|
94
|
+
score += 10;
|
|
95
|
+
matched = true;
|
|
96
|
+
}
|
|
97
|
+
if (tokens(referenced).includes(token)) {
|
|
98
|
+
score += 3;
|
|
99
|
+
matched = true;
|
|
100
|
+
}
|
|
101
|
+
if (matched) matchedTokens++;
|
|
102
|
+
}
|
|
103
|
+
if (queryTokens.length > 0 && matchedTokens === queryTokens.length) score += 50;
|
|
104
|
+
return score;
|
|
105
|
+
}
|
|
106
|
+
function discoverCapabilities(query = "", options = {}, catalog = loadDiscoveryCatalog()) {
|
|
107
|
+
const limit = Math.min(MAX_LIMIT, Math.max(1, Math.floor(options.limit ?? DEFAULT_LIMIT)));
|
|
108
|
+
const offset = Math.max(0, Math.floor(options.offset ?? 0));
|
|
109
|
+
return rankCapabilities(query, options.kind, catalog).slice(offset, offset + limit);
|
|
110
|
+
}
|
|
111
|
+
function rankCapabilities(query = "", kind, catalog = loadDiscoveryCatalog()) {
|
|
112
|
+
return catalog.entries.filter((entry) => !kind || entry.kind === kind).map((entry) => ({ score: scoreEntry(entry, query), entry })).filter((result) => !query.trim() || result.score > 0).sort((a, b) => b.score - a.score || a.entry.id.localeCompare(b.entry.id));
|
|
113
|
+
}
|
|
114
|
+
function showCapability(id, catalog = loadDiscoveryCatalog()) {
|
|
115
|
+
const exact = catalog.entries.find((entry) => entry.id === id);
|
|
116
|
+
if (exact) return exact;
|
|
117
|
+
const wanted = normalized(id);
|
|
118
|
+
return catalog.entries.find(
|
|
119
|
+
(entry) => normalized(entry.id) === wanted || normalized(entry.title) === wanted || (entry.aliases ?? []).some((alias) => normalized(alias) === wanted)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
function discoverySchemaVersion() {
|
|
123
|
+
return DISCOVERY_SCHEMA_VERSION;
|
|
124
|
+
}
|
|
125
|
+
function discoveryDocsRoot() {
|
|
126
|
+
const catalog = findDiscoveryCatalogPath();
|
|
127
|
+
return catalog ? dirname(catalog) : null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// packages/cli/src/service-version.ts
|
|
131
|
+
var OmniusVersionError = class extends Error {
|
|
132
|
+
code;
|
|
133
|
+
installedVersion;
|
|
134
|
+
minimumVersion;
|
|
135
|
+
constructor(code, message, details = {}) {
|
|
136
|
+
super(message);
|
|
137
|
+
this.name = "OmniusVersionError";
|
|
138
|
+
this.code = code;
|
|
139
|
+
this.installedVersion = details.installedVersion;
|
|
140
|
+
this.minimumVersion = details.minimumVersion;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
var VERSION_GATED_EXECUTION_PATHS = /* @__PURE__ */ new Set([
|
|
144
|
+
"/v1/run",
|
|
145
|
+
"/v1/chat",
|
|
146
|
+
"/api/chat",
|
|
147
|
+
"/v1/chat/completions",
|
|
148
|
+
"/v1/generate",
|
|
149
|
+
"/api/generate"
|
|
150
|
+
]);
|
|
151
|
+
function isVersionGatedExecutionRequest(method, pathname) {
|
|
152
|
+
if (method !== "POST") return false;
|
|
153
|
+
return VERSION_GATED_EXECUTION_PATHS.has(pathname) || /^\/v1\/tools\/[^/]+\/call$/.test(pathname) || /^\/v1\/commands\/.+/.test(pathname);
|
|
154
|
+
}
|
|
155
|
+
function parseOmniusVersion(value) {
|
|
156
|
+
const match = value.trim().match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);
|
|
157
|
+
if (!match) return null;
|
|
158
|
+
return {
|
|
159
|
+
major: Number(match[1]),
|
|
160
|
+
minor: Number(match[2]),
|
|
161
|
+
patch: Number(match[3]),
|
|
162
|
+
prerelease: match[4] ? match[4].split(".") : []
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function compareIdentifier(left, right) {
|
|
166
|
+
const leftNumber = /^\d+$/.test(left) ? Number(left) : null;
|
|
167
|
+
const rightNumber = /^\d+$/.test(right) ? Number(right) : null;
|
|
168
|
+
if (leftNumber !== null && rightNumber !== null) return leftNumber - rightNumber;
|
|
169
|
+
if (leftNumber !== null) return -1;
|
|
170
|
+
if (rightNumber !== null) return 1;
|
|
171
|
+
return left.localeCompare(right);
|
|
172
|
+
}
|
|
173
|
+
function compareOmniusVersions(left, right) {
|
|
174
|
+
const a = parseOmniusVersion(left);
|
|
175
|
+
const b = parseOmniusVersion(right);
|
|
176
|
+
if (!a || !b) {
|
|
177
|
+
throw new OmniusVersionError("invalid_version", `Invalid semantic version: ${!a ? left : right}`);
|
|
178
|
+
}
|
|
179
|
+
for (const field of ["major", "minor", "patch"]) {
|
|
180
|
+
if (a[field] !== b[field]) return a[field] - b[field];
|
|
181
|
+
}
|
|
182
|
+
if (a.prerelease.length === 0 && b.prerelease.length > 0) return 1;
|
|
183
|
+
if (a.prerelease.length > 0 && b.prerelease.length === 0) return -1;
|
|
184
|
+
for (let index = 0; index < Math.max(a.prerelease.length, b.prerelease.length); index++) {
|
|
185
|
+
const av = a.prerelease[index];
|
|
186
|
+
const bv = b.prerelease[index];
|
|
187
|
+
if (av === void 0) return -1;
|
|
188
|
+
if (bv === void 0) return 1;
|
|
189
|
+
const compared = compareIdentifier(av, bv);
|
|
190
|
+
if (compared !== 0) return compared;
|
|
191
|
+
}
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
function assertServiceVersion(info, minimumVersion) {
|
|
195
|
+
const installed = info.package_version || info.version;
|
|
196
|
+
if (compareOmniusVersions(installed, minimumVersion) < 0) {
|
|
197
|
+
throw new OmniusVersionError(
|
|
198
|
+
"stale_runtime",
|
|
199
|
+
`Omnius ${installed} is older than required version ${minimumVersion}`,
|
|
200
|
+
{ installedVersion: installed, minimumVersion }
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async function getServiceVersion(baseUrl, options = {}) {
|
|
205
|
+
const url = new URL("/version", baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`);
|
|
206
|
+
const response = await fetch(url, {
|
|
207
|
+
headers: options.apiKey ? { Authorization: `Bearer ${options.apiKey}` } : void 0,
|
|
208
|
+
signal: options.signal
|
|
209
|
+
});
|
|
210
|
+
if (!response.ok) {
|
|
211
|
+
throw new OmniusVersionError(
|
|
212
|
+
"invalid_response",
|
|
213
|
+
`Omnius version request failed with HTTP ${response.status}`
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
const value = await response.json();
|
|
217
|
+
const version = typeof value["package_version"] === "string" ? value["package_version"] : typeof value["version"] === "string" ? value["version"] : "";
|
|
218
|
+
if (!parseOmniusVersion(version)) {
|
|
219
|
+
throw new OmniusVersionError("invalid_response", "Omnius /version returned no valid package version");
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
version: typeof value["version"] === "string" ? value["version"] : version,
|
|
223
|
+
package_version: version,
|
|
224
|
+
boot_version: typeof value["boot_version"] === "string" ? value["boot_version"] : void 0,
|
|
225
|
+
boot_package_hash: typeof value["boot_package_hash"] === "string" || value["boot_package_hash"] === null ? value["boot_package_hash"] : void 0,
|
|
226
|
+
api_version: typeof value["api_version"] === "string" ? value["api_version"] : void 0,
|
|
227
|
+
discovery_schema_version: typeof value["discovery_schema_version"] === "string" ? value["discovery_schema_version"] : void 0,
|
|
228
|
+
node: typeof value["node"] === "string" ? value["node"] : void 0,
|
|
229
|
+
platform: typeof value["platform"] === "string" ? value["platform"] : void 0
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// packages/backend-vllm/dist/providerRegistry.js
|
|
234
|
+
var CHAT_CAPABILITIES = [
|
|
235
|
+
"chat",
|
|
236
|
+
"streaming",
|
|
237
|
+
"models",
|
|
238
|
+
"tools",
|
|
239
|
+
"structured-output"
|
|
240
|
+
];
|
|
241
|
+
var OPENAI_CAPABILITIES = [
|
|
242
|
+
...CHAT_CAPABILITIES,
|
|
243
|
+
"embeddings"
|
|
244
|
+
];
|
|
245
|
+
var noAuth = (required = false) => ({
|
|
246
|
+
strategy: "none",
|
|
247
|
+
required
|
|
248
|
+
});
|
|
249
|
+
var bearerAuth = (required, keyPrefix, staticHeaders) => ({
|
|
250
|
+
strategy: "bearer",
|
|
251
|
+
required,
|
|
252
|
+
...keyPrefix ? { keyPrefix } : {},
|
|
253
|
+
...staticHeaders ? { staticHeaders } : {}
|
|
254
|
+
});
|
|
255
|
+
var descriptor = (value) => Object.freeze({
|
|
256
|
+
...value,
|
|
257
|
+
aliases: Object.freeze([...value.aliases]),
|
|
258
|
+
paths: Object.freeze({ ...value.paths }),
|
|
259
|
+
auth: Object.freeze({
|
|
260
|
+
...value.auth,
|
|
261
|
+
...value.auth.staticHeaders ? { staticHeaders: Object.freeze({ ...value.auth.staticHeaders }) } : {}
|
|
262
|
+
}),
|
|
263
|
+
capabilities: Object.freeze([...value.capabilities])
|
|
264
|
+
});
|
|
265
|
+
var registrations = [
|
|
266
|
+
{
|
|
267
|
+
descriptor: descriptor({
|
|
268
|
+
id: "anthropic",
|
|
269
|
+
aliases: ["claude"],
|
|
270
|
+
label: "Anthropic (Claude)",
|
|
271
|
+
protocol: "anthropic-messages",
|
|
272
|
+
local: false,
|
|
273
|
+
apiPrefix: "/v1",
|
|
274
|
+
paths: {
|
|
275
|
+
chat: "/v1/messages",
|
|
276
|
+
models: "/v1/models"
|
|
277
|
+
},
|
|
278
|
+
auth: {
|
|
279
|
+
strategy: "anthropic-api-key",
|
|
280
|
+
required: true,
|
|
281
|
+
keyPrefix: "sk-ant-",
|
|
282
|
+
staticHeaders: { "anthropic-version": "2023-06-01" }
|
|
283
|
+
},
|
|
284
|
+
capabilities: CHAT_CAPABILITIES,
|
|
285
|
+
defaultUrl: "https://api.anthropic.com/v1",
|
|
286
|
+
apiKeyUrl: "https://console.anthropic.com/settings/keys",
|
|
287
|
+
docsUrl: "https://docs.anthropic.com/en/api",
|
|
288
|
+
description: "Claude through Anthropic's native Messages API."
|
|
289
|
+
}),
|
|
290
|
+
match: (url) => url.hostname.toLowerCase() === "api.anthropic.com"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
descriptor: descriptor({
|
|
294
|
+
id: "gemini",
|
|
295
|
+
aliases: ["google", "google-ai"],
|
|
296
|
+
label: "Google Gemini",
|
|
297
|
+
protocol: "openai-chat",
|
|
298
|
+
local: false,
|
|
299
|
+
apiPrefix: "/v1beta/openai",
|
|
300
|
+
paths: {
|
|
301
|
+
chat: "/v1beta/openai/chat/completions",
|
|
302
|
+
models: "/v1beta/openai/models",
|
|
303
|
+
embeddings: "/v1beta/openai/embeddings"
|
|
304
|
+
},
|
|
305
|
+
auth: bearerAuth(true, void 0, {
|
|
306
|
+
"x-goog-api-client": "omnius/{version}"
|
|
307
|
+
}),
|
|
308
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
309
|
+
defaultUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
310
|
+
apiKeyUrl: "https://aistudio.google.com/app/apikey",
|
|
311
|
+
docsUrl: "https://ai.google.dev/gemini-api/docs/openai",
|
|
312
|
+
description: "Gemini through Google's official OpenAI-compatible API."
|
|
313
|
+
}),
|
|
314
|
+
match: (url) => url.hostname.toLowerCase() === "generativelanguage.googleapis.com"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
descriptor: descriptor({
|
|
318
|
+
id: "openai",
|
|
319
|
+
aliases: [],
|
|
320
|
+
label: "OpenAI",
|
|
321
|
+
protocol: "openai-chat",
|
|
322
|
+
local: false,
|
|
323
|
+
apiPrefix: "/v1",
|
|
324
|
+
paths: {
|
|
325
|
+
chat: "/v1/chat/completions",
|
|
326
|
+
models: "/v1/models",
|
|
327
|
+
embeddings: "/v1/embeddings"
|
|
328
|
+
},
|
|
329
|
+
auth: bearerAuth(true, "sk-"),
|
|
330
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
331
|
+
defaultUrl: "https://api.openai.com/v1",
|
|
332
|
+
apiKeyUrl: "https://platform.openai.com/api-keys",
|
|
333
|
+
docsUrl: "https://platform.openai.com/docs/api-reference",
|
|
334
|
+
description: "OpenAI API models."
|
|
335
|
+
}),
|
|
336
|
+
match: (url) => url.hostname.toLowerCase() === "api.openai.com"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
descriptor: descriptor({
|
|
340
|
+
id: "openrouter",
|
|
341
|
+
aliases: [],
|
|
342
|
+
label: "OpenRouter",
|
|
343
|
+
protocol: "openai-chat",
|
|
344
|
+
local: false,
|
|
345
|
+
apiPrefix: "/api/v1",
|
|
346
|
+
paths: {
|
|
347
|
+
chat: "/api/v1/chat/completions",
|
|
348
|
+
models: "/api/v1/models",
|
|
349
|
+
embeddings: "/api/v1/embeddings"
|
|
350
|
+
},
|
|
351
|
+
auth: bearerAuth(true, "sk-or-"),
|
|
352
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
353
|
+
defaultUrl: "https://openrouter.ai/api/v1",
|
|
354
|
+
apiKeyUrl: "https://openrouter.ai/keys",
|
|
355
|
+
docsUrl: "https://openrouter.ai/docs",
|
|
356
|
+
description: "OpenAI-compatible routing across hosted models."
|
|
357
|
+
}),
|
|
358
|
+
match: (url) => url.hostname.toLowerCase() === "openrouter.ai"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
descriptor: descriptor({
|
|
362
|
+
id: "groq",
|
|
363
|
+
aliases: [],
|
|
364
|
+
label: "Groq",
|
|
365
|
+
protocol: "openai-chat",
|
|
366
|
+
local: false,
|
|
367
|
+
apiPrefix: "/openai/v1",
|
|
368
|
+
paths: {
|
|
369
|
+
chat: "/openai/v1/chat/completions",
|
|
370
|
+
models: "/openai/v1/models",
|
|
371
|
+
embeddings: "/openai/v1/embeddings"
|
|
372
|
+
},
|
|
373
|
+
auth: bearerAuth(true, "gsk_"),
|
|
374
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
375
|
+
defaultUrl: "https://api.groq.com/openai/v1",
|
|
376
|
+
apiKeyUrl: "https://console.groq.com/keys",
|
|
377
|
+
docsUrl: "https://console.groq.com/docs",
|
|
378
|
+
description: "Groq OpenAI-compatible inference."
|
|
379
|
+
}),
|
|
380
|
+
match: (url) => url.hostname.toLowerCase() === "api.groq.com"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
descriptor: descriptor({
|
|
384
|
+
id: "deepinfra",
|
|
385
|
+
aliases: [],
|
|
386
|
+
label: "DeepInfra",
|
|
387
|
+
protocol: "openai-chat",
|
|
388
|
+
local: false,
|
|
389
|
+
apiPrefix: "/v1/openai",
|
|
390
|
+
paths: {
|
|
391
|
+
chat: "/v1/openai/chat/completions",
|
|
392
|
+
models: "/v1/openai/models",
|
|
393
|
+
embeddings: "/v1/openai/embeddings"
|
|
394
|
+
},
|
|
395
|
+
auth: bearerAuth(true),
|
|
396
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
397
|
+
defaultUrl: "https://api.deepinfra.com/v1/openai",
|
|
398
|
+
apiKeyUrl: "https://deepinfra.com/dash/api_keys",
|
|
399
|
+
docsUrl: "https://deepinfra.com/docs/openai_api",
|
|
400
|
+
description: "DeepInfra OpenAI-compatible hosted models."
|
|
401
|
+
}),
|
|
402
|
+
match: (url) => url.hostname.toLowerCase() === "api.deepinfra.com"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
descriptor: descriptor({
|
|
406
|
+
id: "fireworks",
|
|
407
|
+
aliases: ["fireworks-ai"],
|
|
408
|
+
label: "Fireworks AI",
|
|
409
|
+
protocol: "openai-chat",
|
|
410
|
+
local: false,
|
|
411
|
+
apiPrefix: "/inference/v1",
|
|
412
|
+
paths: {
|
|
413
|
+
chat: "/inference/v1/chat/completions",
|
|
414
|
+
models: "/inference/v1/models",
|
|
415
|
+
embeddings: "/inference/v1/embeddings"
|
|
416
|
+
},
|
|
417
|
+
auth: bearerAuth(true, "fw_"),
|
|
418
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
419
|
+
defaultUrl: "https://api.fireworks.ai/inference/v1",
|
|
420
|
+
apiKeyUrl: "https://fireworks.ai/account/api-keys",
|
|
421
|
+
docsUrl: "https://docs.fireworks.ai",
|
|
422
|
+
description: "Fireworks OpenAI-compatible inference."
|
|
423
|
+
}),
|
|
424
|
+
match: (url) => url.hostname.toLowerCase() === "api.fireworks.ai"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
descriptor: descriptor({
|
|
428
|
+
id: "together",
|
|
429
|
+
aliases: ["together-ai"],
|
|
430
|
+
label: "Together AI",
|
|
431
|
+
protocol: "openai-chat",
|
|
432
|
+
local: false,
|
|
433
|
+
apiPrefix: "/v1",
|
|
434
|
+
paths: {
|
|
435
|
+
chat: "/v1/chat/completions",
|
|
436
|
+
models: "/v1/models",
|
|
437
|
+
embeddings: "/v1/embeddings"
|
|
438
|
+
},
|
|
439
|
+
auth: bearerAuth(true),
|
|
440
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
441
|
+
defaultUrl: "https://api.together.xyz/v1",
|
|
442
|
+
apiKeyUrl: "https://api.together.xyz/settings/api-keys",
|
|
443
|
+
docsUrl: "https://docs.together.ai",
|
|
444
|
+
description: "Together OpenAI-compatible inference."
|
|
445
|
+
}),
|
|
446
|
+
match: (url) => url.hostname.toLowerCase() === "api.together.xyz"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
descriptor: descriptor({
|
|
450
|
+
id: "chutes",
|
|
451
|
+
aliases: ["chutes-ai"],
|
|
452
|
+
label: "Chutes AI",
|
|
453
|
+
protocol: "openai-chat",
|
|
454
|
+
local: false,
|
|
455
|
+
apiPrefix: "/v1",
|
|
456
|
+
paths: {
|
|
457
|
+
chat: "/v1/chat/completions",
|
|
458
|
+
models: "/v1/models",
|
|
459
|
+
embeddings: "/v1/embeddings"
|
|
460
|
+
},
|
|
461
|
+
auth: bearerAuth(true, "cpk_"),
|
|
462
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
463
|
+
defaultUrl: "https://llm.chutes.ai/v1",
|
|
464
|
+
apiKeyUrl: "https://chutes.ai/app/api",
|
|
465
|
+
docsUrl: "https://docs.chutes.ai",
|
|
466
|
+
description: "Chutes OpenAI-compatible model endpoint."
|
|
467
|
+
}),
|
|
468
|
+
match: (url) => ["llm.chutes.ai", "chutes.ai"].includes(url.hostname.toLowerCase())
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
descriptor: descriptor({
|
|
472
|
+
id: "mistral",
|
|
473
|
+
aliases: ["mistral-ai"],
|
|
474
|
+
label: "Mistral AI",
|
|
475
|
+
protocol: "openai-chat",
|
|
476
|
+
local: false,
|
|
477
|
+
apiPrefix: "/v1",
|
|
478
|
+
paths: {
|
|
479
|
+
chat: "/v1/chat/completions",
|
|
480
|
+
models: "/v1/models",
|
|
481
|
+
embeddings: "/v1/embeddings"
|
|
482
|
+
},
|
|
483
|
+
auth: bearerAuth(true),
|
|
484
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
485
|
+
defaultUrl: "https://api.mistral.ai/v1",
|
|
486
|
+
apiKeyUrl: "https://console.mistral.ai/api-keys",
|
|
487
|
+
docsUrl: "https://docs.mistral.ai",
|
|
488
|
+
description: "Mistral hosted model endpoint."
|
|
489
|
+
}),
|
|
490
|
+
match: (url) => url.hostname.toLowerCase() === "api.mistral.ai"
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
descriptor: descriptor({
|
|
494
|
+
id: "cerebras",
|
|
495
|
+
aliases: [],
|
|
496
|
+
label: "Cerebras",
|
|
497
|
+
protocol: "openai-chat",
|
|
498
|
+
local: false,
|
|
499
|
+
apiPrefix: "/v1",
|
|
500
|
+
paths: {
|
|
501
|
+
chat: "/v1/chat/completions",
|
|
502
|
+
models: "/v1/models",
|
|
503
|
+
embeddings: "/v1/embeddings"
|
|
504
|
+
},
|
|
505
|
+
auth: bearerAuth(true, "csk-"),
|
|
506
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
507
|
+
defaultUrl: "https://api.cerebras.ai/v1",
|
|
508
|
+
apiKeyUrl: "https://cloud.cerebras.ai/platform",
|
|
509
|
+
docsUrl: "https://inference-docs.cerebras.ai",
|
|
510
|
+
description: "Cerebras OpenAI-compatible inference."
|
|
511
|
+
}),
|
|
512
|
+
match: (url) => url.hostname.toLowerCase() === "api.cerebras.ai"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
descriptor: descriptor({
|
|
516
|
+
id: "sambanova",
|
|
517
|
+
aliases: ["samba-nova"],
|
|
518
|
+
label: "SambaNova",
|
|
519
|
+
protocol: "openai-chat",
|
|
520
|
+
local: false,
|
|
521
|
+
apiPrefix: "/v1",
|
|
522
|
+
paths: {
|
|
523
|
+
chat: "/v1/chat/completions",
|
|
524
|
+
models: "/v1/models",
|
|
525
|
+
embeddings: "/v1/embeddings"
|
|
526
|
+
},
|
|
527
|
+
auth: bearerAuth(true),
|
|
528
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
529
|
+
defaultUrl: "https://api.sambanova.ai/v1",
|
|
530
|
+
apiKeyUrl: "https://cloud.sambanova.ai/apis",
|
|
531
|
+
docsUrl: "https://docs.sambanova.ai",
|
|
532
|
+
description: "SambaNova OpenAI-compatible inference."
|
|
533
|
+
}),
|
|
534
|
+
match: (url) => url.hostname.toLowerCase() === "api.sambanova.ai"
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
descriptor: descriptor({
|
|
538
|
+
id: "nvidia",
|
|
539
|
+
aliases: ["nvidia-nim", "nim"],
|
|
540
|
+
label: "NVIDIA NIM",
|
|
541
|
+
protocol: "openai-chat",
|
|
542
|
+
local: false,
|
|
543
|
+
apiPrefix: "/v1",
|
|
544
|
+
paths: {
|
|
545
|
+
chat: "/v1/chat/completions",
|
|
546
|
+
models: "/v1/models",
|
|
547
|
+
embeddings: "/v1/embeddings"
|
|
548
|
+
},
|
|
549
|
+
auth: bearerAuth(true, "nvapi-"),
|
|
550
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
551
|
+
defaultUrl: "https://integrate.api.nvidia.com/v1",
|
|
552
|
+
apiKeyUrl: "https://build.nvidia.com",
|
|
553
|
+
docsUrl: "https://docs.api.nvidia.com/nim",
|
|
554
|
+
description: "NVIDIA-hosted NIM models."
|
|
555
|
+
}),
|
|
556
|
+
match: (url) => url.hostname.toLowerCase() === "integrate.api.nvidia.com"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
descriptor: descriptor({
|
|
560
|
+
id: "hyperbolic",
|
|
561
|
+
aliases: [],
|
|
562
|
+
label: "Hyperbolic",
|
|
563
|
+
protocol: "openai-chat",
|
|
564
|
+
local: false,
|
|
565
|
+
apiPrefix: "/v1",
|
|
566
|
+
paths: {
|
|
567
|
+
chat: "/v1/chat/completions",
|
|
568
|
+
models: "/v1/models",
|
|
569
|
+
embeddings: "/v1/embeddings"
|
|
570
|
+
},
|
|
571
|
+
auth: bearerAuth(true),
|
|
572
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
573
|
+
defaultUrl: "https://api.hyperbolic.xyz/v1",
|
|
574
|
+
apiKeyUrl: "https://app.hyperbolic.xyz/settings",
|
|
575
|
+
docsUrl: "https://docs.hyperbolic.xyz",
|
|
576
|
+
description: "Hyperbolic OpenAI-compatible inference."
|
|
577
|
+
}),
|
|
578
|
+
match: (url) => url.hostname.toLowerCase() === "api.hyperbolic.xyz"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
descriptor: descriptor({
|
|
582
|
+
id: "ollama",
|
|
583
|
+
aliases: [],
|
|
584
|
+
label: "Ollama (local)",
|
|
585
|
+
protocol: "ollama",
|
|
586
|
+
local: true,
|
|
587
|
+
apiPrefix: "",
|
|
588
|
+
paths: {
|
|
589
|
+
chat: "/v1/chat/completions",
|
|
590
|
+
nativeChat: "/api/chat",
|
|
591
|
+
models: "/api/tags",
|
|
592
|
+
embeddings: "/api/embed",
|
|
593
|
+
health: "/api/tags"
|
|
594
|
+
},
|
|
595
|
+
auth: noAuth(),
|
|
596
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
597
|
+
defaultUrl: "http://127.0.0.1:11434",
|
|
598
|
+
docsUrl: "https://docs.ollama.com/api",
|
|
599
|
+
description: "Local Ollama runtime."
|
|
600
|
+
}),
|
|
601
|
+
match: (url) => url.port === "11434"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
descriptor: descriptor({
|
|
605
|
+
id: "lmstudio",
|
|
606
|
+
aliases: ["lm-studio"],
|
|
607
|
+
label: "LM Studio (local)",
|
|
608
|
+
protocol: "openai-chat",
|
|
609
|
+
local: true,
|
|
610
|
+
apiPrefix: "/v1",
|
|
611
|
+
paths: {
|
|
612
|
+
chat: "/v1/chat/completions",
|
|
613
|
+
models: "/v1/models",
|
|
614
|
+
embeddings: "/v1/embeddings"
|
|
615
|
+
},
|
|
616
|
+
auth: bearerAuth(false),
|
|
617
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
618
|
+
defaultUrl: "http://127.0.0.1:1234/v1",
|
|
619
|
+
docsUrl: "https://lmstudio.ai/docs",
|
|
620
|
+
description: "Local LM Studio OpenAI-compatible server."
|
|
621
|
+
}),
|
|
622
|
+
match: (url) => url.port === "1234"
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
descriptor: descriptor({
|
|
626
|
+
id: "vllm",
|
|
627
|
+
aliases: ["v-llm"],
|
|
628
|
+
label: "vLLM (local)",
|
|
629
|
+
protocol: "openai-chat",
|
|
630
|
+
local: true,
|
|
631
|
+
apiPrefix: "/v1",
|
|
632
|
+
paths: {
|
|
633
|
+
chat: "/v1/chat/completions",
|
|
634
|
+
models: "/v1/models",
|
|
635
|
+
embeddings: "/v1/embeddings",
|
|
636
|
+
health: "/health"
|
|
637
|
+
},
|
|
638
|
+
auth: bearerAuth(false),
|
|
639
|
+
capabilities: OPENAI_CAPABILITIES,
|
|
640
|
+
defaultUrl: "http://127.0.0.1:8000/v1",
|
|
641
|
+
docsUrl: "https://docs.vllm.ai",
|
|
642
|
+
description: "Self-hosted vLLM OpenAI-compatible endpoint."
|
|
643
|
+
}),
|
|
644
|
+
match: (url) => url.port === "8000"
|
|
645
|
+
}
|
|
646
|
+
];
|
|
647
|
+
var descriptors = registrations.map((entry) => entry.descriptor);
|
|
648
|
+
var providerProtocols = /* @__PURE__ */ new Set([
|
|
649
|
+
"ollama",
|
|
650
|
+
"openai-chat",
|
|
651
|
+
"anthropic-messages"
|
|
652
|
+
]);
|
|
653
|
+
function validatedProtocol(value) {
|
|
654
|
+
if (value === void 0)
|
|
655
|
+
return void 0;
|
|
656
|
+
if (providerProtocols.has(value))
|
|
657
|
+
return value;
|
|
658
|
+
throw new UnknownProviderProtocolError(`Unknown inference protocol: ${String(value)}. Select ollama, openai-chat, or anthropic-messages.`);
|
|
659
|
+
}
|
|
660
|
+
function normalizePath(path) {
|
|
661
|
+
if (!path || path === "/")
|
|
662
|
+
return "";
|
|
663
|
+
return `/${path.replace(/^\/+|\/+$/g, "")}`;
|
|
664
|
+
}
|
|
665
|
+
function withoutTrailingSlash(value) {
|
|
666
|
+
return value.replace(/\/+$/, "");
|
|
667
|
+
}
|
|
668
|
+
function parseProviderUrl(raw) {
|
|
669
|
+
const value = raw.trim();
|
|
670
|
+
if (!value) {
|
|
671
|
+
throw new UnknownProviderProtocolError("Inference endpoint URL is empty; select a provider or supply an explicit protocol.");
|
|
672
|
+
}
|
|
673
|
+
try {
|
|
674
|
+
return new URL(value);
|
|
675
|
+
} catch {
|
|
676
|
+
throw new UnknownProviderProtocolError(`Invalid inference endpoint URL: ${value}`);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function descriptorForId(id) {
|
|
680
|
+
const normalized2 = id?.trim().toLowerCase();
|
|
681
|
+
if (!normalized2)
|
|
682
|
+
return void 0;
|
|
683
|
+
return descriptors.find((entry) => entry.id === normalized2 || entry.aliases.some((alias) => alias.toLowerCase() === normalized2));
|
|
684
|
+
}
|
|
685
|
+
function detectDescriptor(url) {
|
|
686
|
+
return registrations.find((entry) => entry.match(url))?.descriptor;
|
|
687
|
+
}
|
|
688
|
+
function serviceBaseForKnown(rawUrl, provider) {
|
|
689
|
+
const url = parseProviderUrl(rawUrl);
|
|
690
|
+
let path = normalizePath(url.pathname);
|
|
691
|
+
const suffixes = [
|
|
692
|
+
...Object.values(provider.paths).filter((value) => typeof value === "string"),
|
|
693
|
+
provider.apiPrefix
|
|
694
|
+
].filter(Boolean).sort((left, right) => right.length - left.length);
|
|
695
|
+
for (const suffix of suffixes) {
|
|
696
|
+
if (path.toLowerCase().endsWith(suffix.toLowerCase())) {
|
|
697
|
+
path = normalizePath(path.slice(0, -suffix.length));
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return withoutTrailingSlash(`${url.origin}${path}`);
|
|
702
|
+
}
|
|
703
|
+
function customDescriptor(protocol, rawUrl) {
|
|
704
|
+
const url = parseProviderUrl(rawUrl);
|
|
705
|
+
let endpointPath = normalizePath(url.pathname);
|
|
706
|
+
const resourceSuffixes = protocol === "anthropic-messages" ? ["/messages", "/models"] : protocol === "openai-chat" ? ["/chat/completions", "/completions", "/embeddings", "/models"] : ["/v1/chat/completions", "/api/chat", "/api/tags", "/api/embed"];
|
|
707
|
+
for (const suffix of resourceSuffixes) {
|
|
708
|
+
if (endpointPath.toLowerCase().endsWith(suffix)) {
|
|
709
|
+
endpointPath = normalizePath(endpointPath.slice(0, -suffix.length));
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if (!endpointPath) {
|
|
714
|
+
if (protocol === "openai-chat" || protocol === "anthropic-messages") {
|
|
715
|
+
endpointPath = "/v1";
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
const paths = protocol === "ollama" ? {
|
|
719
|
+
chat: `${endpointPath}/v1/chat/completions`,
|
|
720
|
+
nativeChat: `${endpointPath}/api/chat`,
|
|
721
|
+
models: `${endpointPath}/api/tags`,
|
|
722
|
+
embeddings: `${endpointPath}/api/embed`,
|
|
723
|
+
health: `${endpointPath}/api/tags`
|
|
724
|
+
} : protocol === "anthropic-messages" ? {
|
|
725
|
+
chat: `${endpointPath}/messages`,
|
|
726
|
+
models: `${endpointPath}/models`
|
|
727
|
+
} : {
|
|
728
|
+
chat: `${endpointPath}/chat/completions`,
|
|
729
|
+
models: `${endpointPath}/models`,
|
|
730
|
+
embeddings: `${endpointPath}/embeddings`
|
|
731
|
+
};
|
|
732
|
+
return descriptor({
|
|
733
|
+
id: "custom",
|
|
734
|
+
aliases: [],
|
|
735
|
+
label: protocol === "anthropic-messages" ? "Custom Anthropic Messages endpoint" : protocol === "ollama" ? "Custom Ollama endpoint" : "Custom OpenAI-compatible endpoint",
|
|
736
|
+
protocol,
|
|
737
|
+
local: ["localhost", "127.0.0.1", "0.0.0.0", "::1"].includes(url.hostname.toLowerCase()),
|
|
738
|
+
apiPrefix: endpointPath,
|
|
739
|
+
paths,
|
|
740
|
+
auth: protocol === "anthropic-messages" ? {
|
|
741
|
+
strategy: "anthropic-api-key",
|
|
742
|
+
required: false,
|
|
743
|
+
staticHeaders: { "anthropic-version": "2023-06-01" }
|
|
744
|
+
} : protocol === "ollama" ? noAuth() : bearerAuth(false),
|
|
745
|
+
capabilities: protocol === "anthropic-messages" ? CHAT_CAPABILITIES : OPENAI_CAPABILITIES,
|
|
746
|
+
defaultUrl: `${url.origin}${endpointPath}`,
|
|
747
|
+
description: `Custom endpoint with explicit ${protocol} protocol.`
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
function legacyProtocol(value) {
|
|
751
|
+
switch (value?.trim().toLowerCase()) {
|
|
752
|
+
case "ollama":
|
|
753
|
+
return "ollama";
|
|
754
|
+
case "vllm":
|
|
755
|
+
case "openai":
|
|
756
|
+
case "openai-compatible":
|
|
757
|
+
case "openai-chat":
|
|
758
|
+
return "openai-chat";
|
|
759
|
+
case "anthropic":
|
|
760
|
+
case "claude":
|
|
761
|
+
case "anthropic-messages":
|
|
762
|
+
return "anthropic-messages";
|
|
763
|
+
default:
|
|
764
|
+
return void 0;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function urlsFor(serviceBaseUrl, provider) {
|
|
768
|
+
const result = {};
|
|
769
|
+
for (const [kind, path] of Object.entries(provider.paths)) {
|
|
770
|
+
if (typeof path === "string") {
|
|
771
|
+
result[kind] = `${serviceBaseUrl}${path}`;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return result;
|
|
775
|
+
}
|
|
776
|
+
var UnknownProviderProtocolError = class extends Error {
|
|
777
|
+
code = "OMNIUS_PROVIDER_PROTOCOL_REQUIRED";
|
|
778
|
+
constructor(message) {
|
|
779
|
+
super(message);
|
|
780
|
+
this.name = "UnknownProviderProtocolError";
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
function listProviderDescriptors() {
|
|
784
|
+
return [...descriptors].sort((left, right) => Number(right.local) - Number(left.local)).map((entry) => ({
|
|
785
|
+
...entry,
|
|
786
|
+
aliases: [...entry.aliases],
|
|
787
|
+
paths: { ...entry.paths },
|
|
788
|
+
auth: {
|
|
789
|
+
...entry.auth,
|
|
790
|
+
...entry.auth.staticHeaders ? { staticHeaders: { ...entry.auth.staticHeaders } } : {}
|
|
791
|
+
},
|
|
792
|
+
capabilities: [...entry.capabilities]
|
|
793
|
+
}));
|
|
794
|
+
}
|
|
795
|
+
function detectProviderDescriptor(rawUrl) {
|
|
796
|
+
try {
|
|
797
|
+
return detectDescriptor(parseProviderUrl(rawUrl));
|
|
798
|
+
} catch {
|
|
799
|
+
return void 0;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
function resolveProviderDescriptor(options) {
|
|
803
|
+
const explicitProtocol = validatedProtocol(options.protocol);
|
|
804
|
+
const requestedProviderId = options.providerId?.trim().toLowerCase();
|
|
805
|
+
const selected = descriptorForId(options.providerId);
|
|
806
|
+
if (requestedProviderId === "custom") {
|
|
807
|
+
if (!explicitProtocol || !options.baseUrl) {
|
|
808
|
+
throw new UnknownProviderProtocolError("Custom inference providers require both baseUrl and an explicit protocol.");
|
|
809
|
+
}
|
|
810
|
+
return customDescriptor(explicitProtocol, options.baseUrl);
|
|
811
|
+
}
|
|
812
|
+
if (requestedProviderId && !selected) {
|
|
813
|
+
throw new UnknownProviderProtocolError(`Unknown inference provider id: ${requestedProviderId}.`);
|
|
814
|
+
}
|
|
815
|
+
const detected = options.baseUrl ? detectProviderDescriptor(options.baseUrl) : void 0;
|
|
816
|
+
if (explicitProtocol && (selected ?? detected) && (selected ?? detected).protocol !== explicitProtocol) {
|
|
817
|
+
const known = selected ?? detected;
|
|
818
|
+
throw new UnknownProviderProtocolError(`Protocol ${explicitProtocol} conflicts with provider ${known.id} (${known.protocol}).`);
|
|
819
|
+
}
|
|
820
|
+
if (selected)
|
|
821
|
+
return selected;
|
|
822
|
+
if (detected)
|
|
823
|
+
return detected;
|
|
824
|
+
const protocol = explicitProtocol ?? legacyProtocol(options.legacyBackendType);
|
|
825
|
+
if (!protocol) {
|
|
826
|
+
throw new UnknownProviderProtocolError(`Cannot infer the inference protocol for ${options.baseUrl ?? "this endpoint"}. Set protocol to ollama, openai-chat, or anthropic-messages before probing or running inference.`);
|
|
827
|
+
}
|
|
828
|
+
if (!options.baseUrl) {
|
|
829
|
+
throw new UnknownProviderProtocolError(`An endpoint URL is required for the explicit ${protocol} protocol.`);
|
|
830
|
+
}
|
|
831
|
+
return customDescriptor(protocol, options.baseUrl);
|
|
832
|
+
}
|
|
833
|
+
function resolveProviderTransport(options) {
|
|
834
|
+
const selected = descriptorForId(options.providerId);
|
|
835
|
+
const customSelected = options.providerId?.trim().toLowerCase() === "custom";
|
|
836
|
+
const detected = options.baseUrl ? detectProviderDescriptor(options.baseUrl) : void 0;
|
|
837
|
+
const provider = resolveProviderDescriptor(options);
|
|
838
|
+
const rawUrl = options.baseUrl ?? provider.defaultUrl;
|
|
839
|
+
if (!rawUrl) {
|
|
840
|
+
throw new UnknownProviderProtocolError(`Provider ${provider.id} has no default endpoint; supply baseUrl explicitly.`);
|
|
841
|
+
}
|
|
842
|
+
const isCustom = provider.id === "custom";
|
|
843
|
+
const serviceBaseUrl = serviceBaseForKnown(rawUrl, provider);
|
|
844
|
+
const endpointBaseUrl = `${serviceBaseUrl}${provider.apiPrefix}`;
|
|
845
|
+
const source = selected ? "provider-id" : customSelected ? "explicit-protocol" : detected ? "known-url" : options.protocol ? "explicit-protocol" : "legacy-backend-type";
|
|
846
|
+
return {
|
|
847
|
+
descriptor: provider,
|
|
848
|
+
providerId: provider.id,
|
|
849
|
+
protocol: provider.protocol,
|
|
850
|
+
serviceBaseUrl,
|
|
851
|
+
endpointBaseUrl: withoutTrailingSlash(endpointBaseUrl),
|
|
852
|
+
urls: Object.freeze(urlsFor(serviceBaseUrl, provider)),
|
|
853
|
+
source: isCustom && source === "known-url" ? "explicit-protocol" : source
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
function buildProviderHeaders(provider, options = {}) {
|
|
857
|
+
const metadata = "descriptor" in provider ? provider.descriptor : provider;
|
|
858
|
+
const headers = {};
|
|
859
|
+
if (options.includeJsonContentType !== false) {
|
|
860
|
+
headers["Content-Type"] = "application/json";
|
|
861
|
+
}
|
|
862
|
+
for (const [name, template] of Object.entries(metadata.auth.staticHeaders ?? {})) {
|
|
863
|
+
headers[name] = template.replace("{version}", options.clientVersion?.trim() || "unknown");
|
|
864
|
+
}
|
|
865
|
+
const key = options.apiKey?.trim();
|
|
866
|
+
if (key) {
|
|
867
|
+
if (metadata.auth.strategy === "anthropic-api-key") {
|
|
868
|
+
headers["x-api-key"] = key;
|
|
869
|
+
} else if (metadata.auth.strategy === "bearer") {
|
|
870
|
+
headers["Authorization"] = `Bearer ${key}`;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return headers;
|
|
874
|
+
}
|
|
875
|
+
function providerUrl(provider, kind) {
|
|
876
|
+
const url = provider.urls[kind];
|
|
877
|
+
if (!url) {
|
|
878
|
+
throw new UnknownProviderProtocolError(`Provider ${provider.providerId} does not expose ${kind}.`);
|
|
879
|
+
}
|
|
880
|
+
return url;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// packages/backend-vllm/dist/normalizeUrl.js
|
|
884
|
+
function normalizeBaseUrl(url) {
|
|
885
|
+
let value = url.trim().replace(/\/+$/, "");
|
|
886
|
+
value = value.replace(/\/chat\/completions$/, "");
|
|
887
|
+
value = value.replace(/\/completions$/, "");
|
|
888
|
+
value = value.replace(/\/embeddings$/, "");
|
|
889
|
+
value = value.replace(/\/models(?:\/.*)?$/, "");
|
|
890
|
+
value = value.replace(/\/+$/, "");
|
|
891
|
+
value = value.replace(/\/v1\/openai$/, "");
|
|
892
|
+
value = value.replace(/\/+$/, "");
|
|
893
|
+
value = value.replace(/\/v1$/, "");
|
|
894
|
+
return value.replace(/\/+$/, "");
|
|
895
|
+
}
|
|
896
|
+
function toProviderInfo(provider) {
|
|
897
|
+
const normalizedDefault = provider.defaultUrl ? normalizeBaseUrl(provider.defaultUrl) : "";
|
|
898
|
+
const absoluteModelsUrl = provider.defaultUrl && provider.paths.models ? `${new URL(provider.defaultUrl).origin}${provider.paths.models}` : "";
|
|
899
|
+
const modelsPath = normalizedDefault && absoluteModelsUrl.startsWith(normalizedDefault) ? absoluteModelsUrl.slice(normalizedDefault.length) || "/models" : provider.paths.models ?? `${provider.apiPrefix}/models`;
|
|
900
|
+
return {
|
|
901
|
+
id: provider.id,
|
|
902
|
+
label: provider.label,
|
|
903
|
+
local: provider.local,
|
|
904
|
+
authRequired: provider.auth.required,
|
|
905
|
+
...provider.auth.keyPrefix ? { keyPrefix: provider.auth.keyPrefix } : {},
|
|
906
|
+
// Compatibility path relative to normalizeBaseUrl(defaultUrl). New code
|
|
907
|
+
// should use resolveProviderTransport().urls.models directly.
|
|
908
|
+
modelsPath,
|
|
909
|
+
...provider.defaultUrl ? { defaultUrl: provider.defaultUrl } : {},
|
|
910
|
+
...provider.apiKeyUrl ? { apiKeyUrl: provider.apiKeyUrl } : {},
|
|
911
|
+
...provider.docsUrl ? { docsUrl: provider.docsUrl } : {},
|
|
912
|
+
description: provider.description,
|
|
913
|
+
protocol: provider.protocol,
|
|
914
|
+
apiPrefix: provider.apiPrefix,
|
|
915
|
+
aliases: provider.aliases
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
var PROVIDER_PRESETS = [
|
|
919
|
+
...listProviderDescriptors().map(toProviderInfo),
|
|
920
|
+
{
|
|
921
|
+
id: "custom",
|
|
922
|
+
label: "Custom endpoint",
|
|
923
|
+
local: false,
|
|
924
|
+
authRequired: false,
|
|
925
|
+
modelsPath: "/v1/models",
|
|
926
|
+
description: "Custom endpoint; an explicit ollama, openai-chat, or anthropic-messages protocol is required."
|
|
927
|
+
}
|
|
928
|
+
];
|
|
929
|
+
export {
|
|
930
|
+
OmniusVersionError,
|
|
931
|
+
UnknownProviderProtocolError,
|
|
932
|
+
assertServiceVersion,
|
|
933
|
+
buildProviderHeaders,
|
|
934
|
+
compareOmniusVersions,
|
|
935
|
+
detectProviderDescriptor,
|
|
936
|
+
discoverCapabilities,
|
|
937
|
+
discoveryDocsRoot,
|
|
938
|
+
discoverySchemaVersion,
|
|
939
|
+
findDiscoveryCatalogPath,
|
|
940
|
+
getServiceVersion,
|
|
941
|
+
isVersionGatedExecutionRequest,
|
|
942
|
+
listProviderDescriptors,
|
|
943
|
+
loadDiscoveryCatalog,
|
|
944
|
+
parseOmniusVersion,
|
|
945
|
+
providerUrl,
|
|
946
|
+
rankCapabilities,
|
|
947
|
+
resolveProviderDescriptor,
|
|
948
|
+
resolveProviderTransport,
|
|
949
|
+
showCapability
|
|
950
|
+
};
|