omnius 1.0.154 → 1.0.155
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/dist/index.js +449 -127
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12170,6 +12170,298 @@ function _readJson(path, fallback) {
|
|
|
12170
12170
|
function _writeJson(path, value) {
|
|
12171
12171
|
try { writeFileSync(path, JSON.stringify(value, null, 2)); } catch {}
|
|
12172
12172
|
}
|
|
12173
|
+
const cohereEndpointCatalogFile = join(nexusDir, 'cohere-endpoint-catalog.json');
|
|
12174
|
+
var _cohereEndpointCatalog = {
|
|
12175
|
+
source: 'ollama',
|
|
12176
|
+
passthrough: false,
|
|
12177
|
+
endpointUrl: process.env.OLLAMA_HOST || process.env.OLLAMA_URL || 'http://localhost:11434',
|
|
12178
|
+
endpointAuth: '',
|
|
12179
|
+
models: [],
|
|
12180
|
+
pricingMenu: [],
|
|
12181
|
+
updatedAt: 0,
|
|
12182
|
+
};
|
|
12183
|
+
function _cohereRedactUrl(url) {
|
|
12184
|
+
var raw = String(url || '').trim();
|
|
12185
|
+
if (!raw) return '';
|
|
12186
|
+
try {
|
|
12187
|
+
var u = new URL(raw);
|
|
12188
|
+
u.username = '';
|
|
12189
|
+
u.password = '';
|
|
12190
|
+
u.search = '';
|
|
12191
|
+
u.hash = '';
|
|
12192
|
+
return u.toString().replace(/\\/+$/, '');
|
|
12193
|
+
} catch {
|
|
12194
|
+
return raw.replace(/([?&](?:api[_-]?key|key|token|auth)=)[^&]+/ig, '$1***');
|
|
12195
|
+
}
|
|
12196
|
+
}
|
|
12197
|
+
function _cohereNormalizeBaseUrl(rawUrl, passthrough) {
|
|
12198
|
+
var raw = String(rawUrl || '').trim() || 'http://localhost:11434';
|
|
12199
|
+
if (!passthrough) return raw.replace(/\\/+$/, '');
|
|
12200
|
+
return raw
|
|
12201
|
+
.replace(/\\/+$/, '')
|
|
12202
|
+
.replace(/\\/chat\\/completions$/, '')
|
|
12203
|
+
.replace(/\\/completions$/, '')
|
|
12204
|
+
.replace(/\\/models(\\/.*)?$/, '')
|
|
12205
|
+
.replace(/\\/v1$/, '')
|
|
12206
|
+
.replace(/\\/+$/, '');
|
|
12207
|
+
}
|
|
12208
|
+
function _cohereNormalizeModelRecord(model, source, passthrough) {
|
|
12209
|
+
if (!model) return null;
|
|
12210
|
+
var name = String(model.name || model.model || model.id || '').trim();
|
|
12211
|
+
if (!name) return null;
|
|
12212
|
+
var details = model.details || {};
|
|
12213
|
+
return {
|
|
12214
|
+
name: name,
|
|
12215
|
+
size: Number(model.size || 0) || 0,
|
|
12216
|
+
family: String(model.family || details.family || model.owned_by || ''),
|
|
12217
|
+
parameterSize: String(model.parameterSize || details.parameter_size || ''),
|
|
12218
|
+
quantization: String(model.quantization || details.quantization_level || ''),
|
|
12219
|
+
source: source || (passthrough ? 'openai-compatible' : 'ollama'),
|
|
12220
|
+
passthrough: !!passthrough,
|
|
12221
|
+
};
|
|
12222
|
+
}
|
|
12223
|
+
function _cohereModelLooksChatCapable(model) {
|
|
12224
|
+
var name = String(model && model.name || '').toLowerCase();
|
|
12225
|
+
var family = String(model && model.family || '').toLowerCase();
|
|
12226
|
+
var text = name + ' ' + family;
|
|
12227
|
+
if (!name) return false;
|
|
12228
|
+
if (/embed|embedding|rerank|nomic-bert|bge-|e5-|clip|whisper|tts|audio/i.test(text)) return false;
|
|
12229
|
+
if (/image|flux|stable.?diffusion|sdxl|dall|midjourney|vision-encoder/i.test(text)) return false;
|
|
12230
|
+
return true;
|
|
12231
|
+
}
|
|
12232
|
+
function _cohereChatScore(model) {
|
|
12233
|
+
var name = String(model && model.name || '').toLowerCase();
|
|
12234
|
+
var family = String(model && model.family || '').toLowerCase();
|
|
12235
|
+
var score = 1;
|
|
12236
|
+
if (/qwen3\\.5|qwen35|qwen3/i.test(name + ' ' + family)) score = 10;
|
|
12237
|
+
else if (/gpt-|claude|gemini|deepseek|llama|mistral|mixtral|command-r|nemotron|gemma/i.test(name + ' ' + family)) score = 8;
|
|
12238
|
+
else if (/chat|instruct|turbo|sonnet|opus|haiku/i.test(name + ' ' + family)) score = 6;
|
|
12239
|
+
if (/^omnius-/i.test(name)) score += 3;
|
|
12240
|
+
if (model && model.passthrough) score += 1;
|
|
12241
|
+
return score;
|
|
12242
|
+
}
|
|
12243
|
+
function _cohereAnnotateModels(models, source, passthrough) {
|
|
12244
|
+
var out = [];
|
|
12245
|
+
var input = Array.isArray(models) ? models : [];
|
|
12246
|
+
for (var i = 0; i < input.length; i++) {
|
|
12247
|
+
var rec = _cohereNormalizeModelRecord(input[i], source, passthrough);
|
|
12248
|
+
if (!rec || !_cohereModelLooksChatCapable(rec)) continue;
|
|
12249
|
+
rec._chatScore = _cohereChatScore(rec);
|
|
12250
|
+
out.push(rec);
|
|
12251
|
+
}
|
|
12252
|
+
return out;
|
|
12253
|
+
}
|
|
12254
|
+
function _cohereApplyAllowlist(models) {
|
|
12255
|
+
if (!_cohereAllowedModels) return Array.isArray(models) ? models : [];
|
|
12256
|
+
return (Array.isArray(models) ? models : []).filter(function(m) { return _cohereAllowedModels.has(m.name); });
|
|
12257
|
+
}
|
|
12258
|
+
function _coherePersistEndpointCatalog() {
|
|
12259
|
+
var pub = _cohereEndpointSnapshot(_cohereEndpointCatalog);
|
|
12260
|
+
pub.models = (_cohereEndpointCatalog.models || []).map(function(m) {
|
|
12261
|
+
return {
|
|
12262
|
+
name: m.name,
|
|
12263
|
+
size: m.size || 0,
|
|
12264
|
+
family: m.family || '',
|
|
12265
|
+
parameterSize: m.parameterSize || '',
|
|
12266
|
+
quantization: m.quantization || '',
|
|
12267
|
+
source: m.source || _cohereEndpointCatalog.source,
|
|
12268
|
+
passthrough: !!m.passthrough,
|
|
12269
|
+
};
|
|
12270
|
+
});
|
|
12271
|
+
pub.pricingMenu = Array.isArray(_cohereEndpointCatalog.pricingMenu) ? _cohereEndpointCatalog.pricingMenu : [];
|
|
12272
|
+
_writeJson(cohereEndpointCatalogFile, pub);
|
|
12273
|
+
}
|
|
12274
|
+
function _cohereRememberEndpointCatalog(opts) {
|
|
12275
|
+
opts = opts || {};
|
|
12276
|
+
var passthrough = opts.passthrough === true;
|
|
12277
|
+
var source = String(opts.source || (passthrough ? 'openai-compatible' : 'ollama'));
|
|
12278
|
+
var endpointUrl = _cohereNormalizeBaseUrl(opts.endpointUrl || opts.ollamaUrl || process.env.OLLAMA_HOST || process.env.OLLAMA_URL || 'http://localhost:11434', passthrough);
|
|
12279
|
+
var models = _cohereAnnotateModels(opts.models || [], source, passthrough);
|
|
12280
|
+
_cohereEndpointCatalog = {
|
|
12281
|
+
source: source,
|
|
12282
|
+
passthrough: passthrough,
|
|
12283
|
+
endpointUrl: endpointUrl,
|
|
12284
|
+
endpointAuth: String(opts.endpointAuth || ''),
|
|
12285
|
+
models: models,
|
|
12286
|
+
pricingMenu: Array.isArray(opts.pricingMenu) ? opts.pricingMenu : [],
|
|
12287
|
+
updatedAt: Date.now(),
|
|
12288
|
+
};
|
|
12289
|
+
_coherePersistEndpointCatalog();
|
|
12290
|
+
dlog('COHERE endpoint catalog updated: source=' + source + ' passthrough=' + passthrough + ' models=' + models.length);
|
|
12291
|
+
return _cohereEndpointCatalog;
|
|
12292
|
+
}
|
|
12293
|
+
function _cohereLoadPersistedEndpointCatalog() {
|
|
12294
|
+
var stored = _readJson(cohereEndpointCatalogFile, null);
|
|
12295
|
+
if (!stored || !Array.isArray(stored.models)) return null;
|
|
12296
|
+
return {
|
|
12297
|
+
source: String(stored.source || 'cached'),
|
|
12298
|
+
passthrough: stored.passthrough === true,
|
|
12299
|
+
endpointUrl: String(stored.endpointUrl || ''),
|
|
12300
|
+
endpointAuth: '',
|
|
12301
|
+
models: _cohereAnnotateModels(stored.models, String(stored.source || 'cached'), stored.passthrough === true),
|
|
12302
|
+
pricingMenu: Array.isArray(stored.pricingMenu) ? stored.pricingMenu : [],
|
|
12303
|
+
updatedAt: Number(stored.updatedAt || 0) || 0,
|
|
12304
|
+
cachedOnly: true,
|
|
12305
|
+
};
|
|
12306
|
+
}
|
|
12307
|
+
async function _cohereFetchEndpointCatalog(baseUrl, endpointAuth, passthrough) {
|
|
12308
|
+
var endpointUrl = _cohereNormalizeBaseUrl(baseUrl, passthrough);
|
|
12309
|
+
if (passthrough) {
|
|
12310
|
+
var headers = { 'Content-Type': 'application/json' };
|
|
12311
|
+
if (endpointAuth) headers['Authorization'] = 'Bearer ' + endpointAuth;
|
|
12312
|
+
var resp = await fetch(endpointUrl + '/v1/models', { headers: headers, signal: AbortSignal.timeout(10000) });
|
|
12313
|
+
if (!resp.ok) throw new Error('/v1/models HTTP ' + resp.status);
|
|
12314
|
+
var data = await resp.json();
|
|
12315
|
+
var list = Array.isArray(data.data) ? data.data : (Array.isArray(data.models) ? data.models : []);
|
|
12316
|
+
return {
|
|
12317
|
+
source: 'openai-compatible',
|
|
12318
|
+
passthrough: true,
|
|
12319
|
+
endpointUrl: endpointUrl,
|
|
12320
|
+
endpointAuth: String(endpointAuth || ''),
|
|
12321
|
+
models: _cohereAnnotateModels(list.map(function(m) {
|
|
12322
|
+
return {
|
|
12323
|
+
name: m.id || m.name || m.model,
|
|
12324
|
+
family: m.owned_by || m.family || '',
|
|
12325
|
+
size: m.size || 0,
|
|
12326
|
+
};
|
|
12327
|
+
}), 'openai-compatible', true),
|
|
12328
|
+
pricingMenu: [],
|
|
12329
|
+
updatedAt: Date.now(),
|
|
12330
|
+
};
|
|
12331
|
+
}
|
|
12332
|
+
var tagsResp = await fetch(endpointUrl + '/api/tags', { signal: AbortSignal.timeout(10000) });
|
|
12333
|
+
if (!tagsResp.ok) throw new Error('/api/tags HTTP ' + tagsResp.status);
|
|
12334
|
+
var tags = await tagsResp.json();
|
|
12335
|
+
return {
|
|
12336
|
+
source: 'ollama',
|
|
12337
|
+
passthrough: false,
|
|
12338
|
+
endpointUrl: endpointUrl,
|
|
12339
|
+
endpointAuth: '',
|
|
12340
|
+
models: _cohereAnnotateModels(tags.models || [], 'ollama', false),
|
|
12341
|
+
pricingMenu: [],
|
|
12342
|
+
updatedAt: Date.now(),
|
|
12343
|
+
};
|
|
12344
|
+
}
|
|
12345
|
+
async function _cohereGetModelCatalog(opts) {
|
|
12346
|
+
opts = opts || {};
|
|
12347
|
+
var now = Date.now();
|
|
12348
|
+
var active = _cohereEndpointCatalog;
|
|
12349
|
+
if (!opts.forceRefresh && active && active.models && active.models.length > 0 && now - (active.updatedAt || 0) < 60000) {
|
|
12350
|
+
return active;
|
|
12351
|
+
}
|
|
12352
|
+
if (active && active.endpointUrl && (!active.cachedOnly || active.endpointAuth || !active.passthrough)) {
|
|
12353
|
+
try {
|
|
12354
|
+
var fresh = await _cohereFetchEndpointCatalog(active.endpointUrl, active.endpointAuth || '', !!active.passthrough);
|
|
12355
|
+
fresh.pricingMenu = Array.isArray(active.pricingMenu) ? active.pricingMenu : [];
|
|
12356
|
+
_cohereEndpointCatalog = fresh;
|
|
12357
|
+
_coherePersistEndpointCatalog();
|
|
12358
|
+
return _cohereEndpointCatalog;
|
|
12359
|
+
} catch (err) {
|
|
12360
|
+
dlog('COHERE endpoint catalog refresh failed: ' + (err.message || err));
|
|
12361
|
+
if (active.models && active.models.length > 0) return active;
|
|
12362
|
+
}
|
|
12363
|
+
}
|
|
12364
|
+
var persisted = _cohereLoadPersistedEndpointCatalog();
|
|
12365
|
+
if (persisted && persisted.models && persisted.models.length > 0) return persisted;
|
|
12366
|
+
try {
|
|
12367
|
+
var fallback = await _cohereFetchEndpointCatalog(process.env.OLLAMA_HOST || process.env.OLLAMA_URL || 'http://localhost:11434', '', false);
|
|
12368
|
+
_cohereEndpointCatalog = fallback;
|
|
12369
|
+
_coherePersistEndpointCatalog();
|
|
12370
|
+
return _cohereEndpointCatalog;
|
|
12371
|
+
} catch (err2) {
|
|
12372
|
+
dlog('COHERE local Ollama catalog unavailable: ' + (err2.message || err2));
|
|
12373
|
+
}
|
|
12374
|
+
return Object.assign({}, active || {}, { models: [] });
|
|
12375
|
+
}
|
|
12376
|
+
function _cohereEndpointSnapshot(catalog) {
|
|
12377
|
+
var c = catalog || _cohereEndpointCatalog || {};
|
|
12378
|
+
return {
|
|
12379
|
+
source: String(c.source || 'unknown'),
|
|
12380
|
+
passthrough: c.passthrough === true,
|
|
12381
|
+
endpointUrl: _cohereRedactUrl(c.endpointUrl || ''),
|
|
12382
|
+
modelCount: Array.isArray(c.models) ? c.models.length : 0,
|
|
12383
|
+
updatedAt: Number(c.updatedAt || 0) || 0,
|
|
12384
|
+
cachedOnly: c.cachedOnly === true,
|
|
12385
|
+
};
|
|
12386
|
+
}
|
|
12387
|
+
function _cohereSelectModel(catalog, tier) {
|
|
12388
|
+
var models = _cohereApplyAllowlist(catalog && catalog.models || []);
|
|
12389
|
+
if (models.length === 0) return { model: '', models: [] };
|
|
12390
|
+
var passthrough = catalog && catalog.passthrough === true;
|
|
12391
|
+
var gb = 1024 * 1024 * 1024;
|
|
12392
|
+
var maxThresh = tier === 0 ? 8 * gb : tier === 1 ? 50 * gb : tier === 2 ? 100 * gb : Infinity;
|
|
12393
|
+
var minSize = tier === 0 ? 0 : tier === 1 ? 4 * gb : tier === 2 ? 12 * gb : 25 * gb;
|
|
12394
|
+
models.sort(function(a, b) {
|
|
12395
|
+
var sa = a._chatScore || 1, sb = b._chatScore || 1;
|
|
12396
|
+
if (sa !== sb) return sb - sa;
|
|
12397
|
+
return (a.size || 0) - (b.size || 0);
|
|
12398
|
+
});
|
|
12399
|
+
var selected = '';
|
|
12400
|
+
if (_cLastModel) {
|
|
12401
|
+
var warm = models.find(function(m) { return m.name === _cLastModel; });
|
|
12402
|
+
if (warm && (passthrough || ((warm.size || 0) >= minSize && (warm.size || 0) <= maxThresh))) selected = warm.name;
|
|
12403
|
+
}
|
|
12404
|
+
if (!selected) {
|
|
12405
|
+
var fit = passthrough
|
|
12406
|
+
? models
|
|
12407
|
+
: models.filter(function(m) { return (m.size || 0) >= minSize && (m.size || 0) <= maxThresh; });
|
|
12408
|
+
selected = fit.length > 0 ? fit[0].name : '';
|
|
12409
|
+
}
|
|
12410
|
+
if (!selected && models.length > 0) selected = models[0].name;
|
|
12411
|
+
return { model: selected, models: models };
|
|
12412
|
+
}
|
|
12413
|
+
async function _cohereDirectEndpointFallback(catalog, model, requestData) {
|
|
12414
|
+
if (!catalog || catalog.passthrough !== true || !catalog.endpointUrl) {
|
|
12415
|
+
throw new Error('No passthrough endpoint is active for direct COHERE fallback');
|
|
12416
|
+
}
|
|
12417
|
+
var headers = { 'Content-Type': 'application/json' };
|
|
12418
|
+
if (catalog.endpointAuth) headers['Authorization'] = 'Bearer ' + catalog.endpointAuth;
|
|
12419
|
+
var messages = [];
|
|
12420
|
+
if (requestData && Array.isArray(requestData.messages) && requestData.messages.length > 0) {
|
|
12421
|
+
messages = requestData.messages;
|
|
12422
|
+
} else {
|
|
12423
|
+
messages = [{ role: 'user', content: String(requestData && requestData.query || '') }];
|
|
12424
|
+
}
|
|
12425
|
+
var maxTokens = Number(requestData && (requestData.maxTokens || requestData.max_tokens)) || 1024;
|
|
12426
|
+
var temperature = Number(requestData && requestData.temperature);
|
|
12427
|
+
var body = {
|
|
12428
|
+
model: model,
|
|
12429
|
+
messages: messages,
|
|
12430
|
+
stream: false,
|
|
12431
|
+
max_tokens: maxTokens > 0 ? maxTokens : 1024,
|
|
12432
|
+
temperature: Number.isFinite(temperature) ? temperature : 0.2,
|
|
12433
|
+
think: false,
|
|
12434
|
+
};
|
|
12435
|
+
var resp = await fetch(_cohereNormalizeBaseUrl(catalog.endpointUrl, true) + '/v1/chat/completions', {
|
|
12436
|
+
method: 'POST',
|
|
12437
|
+
headers: headers,
|
|
12438
|
+
body: JSON.stringify(body),
|
|
12439
|
+
signal: AbortSignal.timeout(120000),
|
|
12440
|
+
});
|
|
12441
|
+
if (!resp.ok) {
|
|
12442
|
+
var errText = '';
|
|
12443
|
+
try { errText = await resp.text(); } catch {}
|
|
12444
|
+
throw new Error('passthrough /v1/chat/completions HTTP ' + resp.status + ': ' + errText.slice(0, 200));
|
|
12445
|
+
}
|
|
12446
|
+
var data = await resp.json();
|
|
12447
|
+
var choices = data.choices || [];
|
|
12448
|
+
var first = choices[0] && choices[0].message ? choices[0].message : {};
|
|
12449
|
+
var content = String(first.content || first.reasoning || '').replace(/<think>[\\s\\S]*?<\\/think>/g, '').trim();
|
|
12450
|
+
var usage = data.usage || {};
|
|
12451
|
+
return {
|
|
12452
|
+
content: content,
|
|
12453
|
+
usage: {
|
|
12454
|
+
inputTokens: usage.prompt_tokens || usage.input_tokens || 0,
|
|
12455
|
+
outputTokens: usage.completion_tokens || usage.output_tokens || 0,
|
|
12456
|
+
},
|
|
12457
|
+
};
|
|
12458
|
+
}
|
|
12459
|
+
try {
|
|
12460
|
+
var _cohereStartupCatalog = _cohereLoadPersistedEndpointCatalog();
|
|
12461
|
+
if (_cohereStartupCatalog && _cohereStartupCatalog.models && _cohereStartupCatalog.models.length > 0) {
|
|
12462
|
+
_cohereEndpointCatalog = _cohereStartupCatalog;
|
|
12463
|
+
}
|
|
12464
|
+
} catch {}
|
|
12173
12465
|
async function _dhtPutBounded(dht, key, value, label) {
|
|
12174
12466
|
var op = (async function() {
|
|
12175
12467
|
for await (var _ of dht.put(key, value)) {}
|
|
@@ -13556,7 +13848,20 @@ async function handleCmd(cmd) {
|
|
|
13556
13848
|
|
|
13557
13849
|
// WO-1.5: Publish capacity announcement on enable
|
|
13558
13850
|
if (typeof _publishCapacityAnnouncement === 'function') {
|
|
13559
|
-
try { _publishCapacityAnnouncement(); } catch {}
|
|
13851
|
+
try { await _publishCapacityAnnouncement(); } catch {}
|
|
13852
|
+
}
|
|
13853
|
+
try {
|
|
13854
|
+
var _ceCatalog = await _cohereGetModelCatalog({});
|
|
13855
|
+
await _publishCapabilityRecord('cohere_inference', {
|
|
13856
|
+
description: 'COHERE distributed inference provider',
|
|
13857
|
+
pricing: 'free',
|
|
13858
|
+
rateLimit: _sponsorLimits ? String(_sponsorLimits.maxRequestsPerMinute) + '/min' : 'provider-policy',
|
|
13859
|
+
endpoint: _cohereEndpointSnapshot(_ceCatalog),
|
|
13860
|
+
models: (_ceCatalog.models || []).map(function(m) { return m.name; }),
|
|
13861
|
+
passthrough: _ceCatalog.passthrough === true,
|
|
13862
|
+
});
|
|
13863
|
+
} catch (_cePubErr) {
|
|
13864
|
+
dlog('COHERE capability publish failed: ' + (_cePubErr.message || _cePubErr));
|
|
13560
13865
|
}
|
|
13561
13866
|
writeResp(id, { ok: true, output: 'COHERE inference handler enabled' });
|
|
13562
13867
|
break;
|
|
@@ -13589,7 +13894,8 @@ async function handleCmd(cmd) {
|
|
|
13589
13894
|
bytesOut: _cohereStats.bytesOut,
|
|
13590
13895
|
modelsUsed: _cohereStats.modelsUsed,
|
|
13591
13896
|
peersServed: _cohereStats.peersServed,
|
|
13592
|
-
allowedModels: _cohereAllowedModels ? [..._cohereAllowedModels] : null
|
|
13897
|
+
allowedModels: _cohereAllowedModels ? [..._cohereAllowedModels] : null,
|
|
13898
|
+
endpoint: _cohereEndpointSnapshot(),
|
|
13593
13899
|
};
|
|
13594
13900
|
if (args.format === 'json' || args.json === true || args.json === 'true' || args.json === '1') {
|
|
13595
13901
|
writeResp(id, { ok: true, output: JSON.stringify(_csSnapshot) });
|
|
@@ -13627,9 +13933,15 @@ async function handleCmd(cmd) {
|
|
|
13627
13933
|
_csLines.push(' ' + _csPeers[_cpi][0].slice(0, 20) + '...: ' + _csPeers[_cpi][1] + ' queries');
|
|
13628
13934
|
}
|
|
13629
13935
|
_csLines.push('');
|
|
13936
|
+
_csLines.push('── Endpoint ──');
|
|
13937
|
+
var _csEndpoint = _cohereEndpointSnapshot();
|
|
13938
|
+
_csLines.push(' Source: ' + _csEndpoint.source + (_csEndpoint.passthrough ? ' (passthrough)' : ''));
|
|
13939
|
+
_csLines.push(' URL: ' + (_csEndpoint.endpointUrl || '(not set)'));
|
|
13940
|
+
_csLines.push(' Models: ' + _csEndpoint.modelCount + (_csEndpoint.cachedOnly ? ' (cached)' : ''));
|
|
13941
|
+
_csLines.push('');
|
|
13630
13942
|
_csLines.push('── Model Allowlist ──');
|
|
13631
13943
|
if (!_cohereAllowedModels) {
|
|
13632
|
-
_csLines.push(' All
|
|
13944
|
+
_csLines.push(' All endpoint models exposed (no filter)');
|
|
13633
13945
|
} else {
|
|
13634
13946
|
_csLines.push(' ' + [..._cohereAllowedModels].join(', '));
|
|
13635
13947
|
}
|
|
@@ -13659,21 +13971,36 @@ async function handleCmd(cmd) {
|
|
|
13659
13971
|
break;
|
|
13660
13972
|
}
|
|
13661
13973
|
case 'cohere_list_models': {
|
|
13662
|
-
var
|
|
13663
|
-
var _clmModels = [];
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
_clmModels
|
|
13668
|
-
|
|
13669
|
-
|
|
13974
|
+
var _clmCatalog = await _cohereGetModelCatalog({ forceRefresh: args.refresh === 'true' || args.refresh === true || args.refresh === '1' });
|
|
13975
|
+
var _clmModels = Array.isArray(_clmCatalog.models) ? _clmCatalog.models : [];
|
|
13976
|
+
var _clmPayload = {
|
|
13977
|
+
models: _clmModels.map(function(m) { return m.name; }),
|
|
13978
|
+
exposedModels: _cohereApplyAllowlist(_clmModels).map(function(m) { return m.name; }),
|
|
13979
|
+
modelDetails: _clmModels.map(function(m) {
|
|
13980
|
+
return Object.assign({}, m, { exposed: !_cohereAllowedModels || _cohereAllowedModels.has(m.name) });
|
|
13981
|
+
}),
|
|
13982
|
+
source: _clmCatalog.source || 'unknown',
|
|
13983
|
+
passthrough: _clmCatalog.passthrough === true,
|
|
13984
|
+
endpoint: _cohereEndpointSnapshot(_clmCatalog),
|
|
13985
|
+
allowedModels: _cohereAllowedModels ? [..._cohereAllowedModels] : null,
|
|
13986
|
+
};
|
|
13987
|
+
if (args.format === 'json' || args.json === true || args.json === 'true' || args.json === '1') {
|
|
13988
|
+
writeResp(id, { ok: true, output: JSON.stringify(_clmPayload) });
|
|
13989
|
+
break;
|
|
13990
|
+
}
|
|
13991
|
+
var _clmLines = ['── Endpoint Models ──'];
|
|
13992
|
+
var _clmEndpoint = _cohereEndpointSnapshot(_clmCatalog);
|
|
13993
|
+
_clmLines.push(' Source: ' + _clmEndpoint.source + (_clmEndpoint.passthrough ? ' (passthrough)' : ''));
|
|
13994
|
+
_clmLines.push(' URL: ' + (_clmEndpoint.endpointUrl || '(not set)'));
|
|
13995
|
+
_clmLines.push('');
|
|
13670
13996
|
for (var _clmi = 0; _clmi < _clmModels.length; _clmi++) {
|
|
13671
13997
|
var _clmM = _clmModels[_clmi];
|
|
13672
13998
|
var _clmAllowed = !_cohereAllowedModels || _cohereAllowedModels.has(_clmM.name);
|
|
13673
13999
|
var _clmSizeGB = (_clmM.size / (1024*1024*1024)).toFixed(1);
|
|
13674
|
-
|
|
14000
|
+
var _clmMeta = _clmM.size > 0 ? _clmSizeGB + 'GB' : (_clmM.passthrough ? 'external' : 'size unknown');
|
|
14001
|
+
_clmLines.push(' ' + (_clmAllowed ? '[EXPOSED]' : '[HIDDEN] ') + ' ' + _clmM.name + ' (' + _clmMeta + (_clmM.family ? ', ' + _clmM.family : '') + ')');
|
|
13675
14002
|
}
|
|
13676
|
-
if (_clmModels.length === 0) _clmLines.push(' (no models found —
|
|
14003
|
+
if (_clmModels.length === 0) _clmLines.push(' (no endpoint models found — check /endpoint and /expose passthrough)');
|
|
13677
14004
|
_clmLines.push('');
|
|
13678
14005
|
_clmLines.push(_cohereAllowedModels ? 'Allowlist: ' + [..._cohereAllowedModels].join(', ') : 'Allowlist: ALL (no filter active)');
|
|
13679
14006
|
writeResp(id, { ok: true, output: _clmLines.join('\\n') });
|
|
@@ -14392,6 +14719,32 @@ async function handleCmd(cmd) {
|
|
|
14392
14719
|
}
|
|
14393
14720
|
}
|
|
14394
14721
|
|
|
14722
|
+
var _exCohereCatalog = _cohereRememberEndpointCatalog({
|
|
14723
|
+
source: isPassthrough ? 'openai-compatible' : 'ollama',
|
|
14724
|
+
passthrough: isPassthrough,
|
|
14725
|
+
endpointUrl: ollamaUrl,
|
|
14726
|
+
endpointAuth: endpointAuth,
|
|
14727
|
+
models: models,
|
|
14728
|
+
pricingMenu: pricingMenu,
|
|
14729
|
+
});
|
|
14730
|
+
if (cohereActive) {
|
|
14731
|
+
try {
|
|
14732
|
+
await _publishCapabilityRecord('cohere_inference', {
|
|
14733
|
+
description: 'COHERE distributed inference provider',
|
|
14734
|
+
pricing: 'free',
|
|
14735
|
+
rateLimit: _sponsorLimits ? String(_sponsorLimits.maxRequestsPerMinute) + '/min' : 'provider-policy',
|
|
14736
|
+
endpoint: _cohereEndpointSnapshot(_exCohereCatalog),
|
|
14737
|
+
models: (_exCohereCatalog.models || []).map(function(m) { return m.name; }),
|
|
14738
|
+
passthrough: isPassthrough,
|
|
14739
|
+
});
|
|
14740
|
+
} catch (_exCoherePubErr) {
|
|
14741
|
+
dlog('COHERE expose capability publish failed: ' + (_exCoherePubErr.message || _exCoherePubErr));
|
|
14742
|
+
}
|
|
14743
|
+
if (typeof _publishCapacityAnnouncement === 'function') {
|
|
14744
|
+
try { await _publishCapacityAnnouncement(); } catch {}
|
|
14745
|
+
}
|
|
14746
|
+
}
|
|
14747
|
+
|
|
14395
14748
|
for (var pci = 0; pci < pricingMenu.length; pci++) {
|
|
14396
14749
|
var capPricing = pricingMenu[pci];
|
|
14397
14750
|
await _publishCapabilityRecord('inference:' + capPricing.model.replace(/[^a-zA-Z0-9._-]/g, '_'), {
|
|
@@ -15340,13 +15693,12 @@ process.on('unhandledRejection', (reason) => {
|
|
|
15340
15693
|
}
|
|
15341
15694
|
|
|
15342
15695
|
// ── COHERE distributed inference handler ─────────────────────────
|
|
15343
|
-
//
|
|
15344
|
-
//
|
|
15345
|
-
// publish response to nexus.cohere.response.
|
|
15696
|
+
// Subscribe to nexus.cohere.query, process through the active Omnius
|
|
15697
|
+
// endpoint catalog, publish response to nexus.cohere.response.
|
|
15346
15698
|
// SECURITY INVARIANTS:
|
|
15347
15699
|
// 1. Handler constructs ISOLATED messages — no history, no system prompt
|
|
15348
|
-
// 2.
|
|
15349
|
-
// 3.
|
|
15700
|
+
// 2. Model discovery is read-only: /api/tags or /v1/models
|
|
15701
|
+
// 3. Inference uses /v1/run first; direct fallback is passthrough-only
|
|
15350
15702
|
// 4. Model allowlist filters which models are served to remote queries
|
|
15351
15703
|
// 5. Inbound queries scanned for leaked secrets
|
|
15352
15704
|
if (_natsConn && _natsCodec) {
|
|
@@ -15534,89 +15886,34 @@ process.on('unhandledRejection', (reason) => {
|
|
|
15534
15886
|
dlog('COHERE query: ' + _cData.queryId + ' — ' + (_cData.query || '').slice(0, 80) + ' [elected, score=' + _cBidScore.toFixed(2) + ', bids=' + _cBids.size + ']');
|
|
15535
15887
|
const _cStart = Date.now();
|
|
15536
15888
|
|
|
15537
|
-
//
|
|
15538
|
-
// GET
|
|
15539
|
-
//
|
|
15889
|
+
// Endpoint safety: COHERE model discovery is read-only.
|
|
15890
|
+
// Ollama providers: GET /api/tags only
|
|
15891
|
+
// Passthrough providers: GET /v1/models only
|
|
15892
|
+
// Remote COHERE queries never call Ollama model-management endpoints.
|
|
15540
15893
|
// The following are NEVER called from remote requests:
|
|
15541
15894
|
// POST /api/pull — download model (BLOCKED)
|
|
15542
15895
|
// DELETE /api/delete — remove model (BLOCKED)
|
|
15543
15896
|
// POST /api/push — upload model (BLOCKED)
|
|
15544
15897
|
// POST /api/create — create model (BLOCKED)
|
|
15545
15898
|
// POST /api/copy — copy model (BLOCKED)
|
|
15546
|
-
|
|
15899
|
+
var _cCatalog = null;
|
|
15547
15900
|
let _cModel = '';
|
|
15548
15901
|
try {
|
|
15549
|
-
|
|
15550
|
-
|
|
15551
|
-
|
|
15552
|
-
var _cAllModels = (_cTags.models || []).filter(function(m) {
|
|
15553
|
-
var name = (m.name || '').toLowerCase();
|
|
15554
|
-
var family = ((m.details && m.details.family) || '').toLowerCase();
|
|
15555
|
-
var families = (m.details && m.details.families) || [];
|
|
15556
|
-
var famStr = families.join(' ').toLowerCase();
|
|
15557
|
-
// Exclude embeddings
|
|
15558
|
-
if (/embed|nomic-bert/i.test(name) || /embed|nomic-bert/i.test(family)) return false;
|
|
15559
|
-
// Exclude image generation models (flux, sd, sdxl, image-turbo, etc.)
|
|
15560
|
-
if (/image|flux|stable.?diffusion|sdxl|sd[0-9]|dall|turbo.*image|image.*turbo/i.test(name)) return false;
|
|
15561
|
-
if (/flux|diffusion/i.test(family)) return false;
|
|
15562
|
-
// Exclude pure vision models (keep multimodal like qwen3-vl that also do chat)
|
|
15563
|
-
if (/^clip$|^vit$/i.test(family)) return false;
|
|
15564
|
-
return true;
|
|
15565
|
-
});
|
|
15566
|
-
// Score models for chat/tool capability: prefer qwen, then tool-capable families
|
|
15567
|
-
var _cChatFamilies = { qwen35: 10, qwen35moe: 10, qwen3: 9, qwen3moe: 9, qwen3next: 9, nemotron_h_moe: 8, mistral3: 7, llama: 6, gemma3: 6, seed_oss: 5, phi2: 3 };
|
|
15568
|
-
for (var _cmi = 0; _cmi < _cAllModels.length; _cmi++) {
|
|
15569
|
-
var _cmFam = ((_cAllModels[_cmi].details && _cAllModels[_cmi].details.family) || '').toLowerCase();
|
|
15570
|
-
_cAllModels[_cmi]._chatScore = _cChatFamilies[_cmFam] || 1;
|
|
15571
|
-
// Boost omnius- prefixed models (known good configs)
|
|
15572
|
-
if (/^omnius-/i.test(_cAllModels[_cmi].name)) _cAllModels[_cmi]._chatScore += 3;
|
|
15573
|
-
}
|
|
15574
|
-
// Apply model allowlist — only serve allowed models to remote queries
|
|
15575
|
-
var _cModels = _cohereAllowedModels
|
|
15576
|
-
? _cAllModels.filter(function(m) { return _cohereAllowedModels.has(m.name); })
|
|
15577
|
-
: _cAllModels;
|
|
15902
|
+
_cCatalog = await _cohereGetModelCatalog({});
|
|
15903
|
+
var _cSelected = _cohereSelectModel(_cCatalog, _cTier);
|
|
15904
|
+
var _cModels = _cSelected.models || [];
|
|
15578
15905
|
if (_cModels.length === 0 && _cohereAllowedModels) {
|
|
15579
|
-
dlog('COHERE: no allowed models match
|
|
15906
|
+
dlog('COHERE: no allowed models match endpoint catalog. Allowlist: ' + [..._cohereAllowedModels].join(', '));
|
|
15580
15907
|
_cohereStats.queriesErrors++;
|
|
15581
15908
|
_saveStats();
|
|
15582
15909
|
continue;
|
|
15583
15910
|
}
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
|
|
15587
|
-
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
// Sort by chat capability score (desc), then size within same score (asc)
|
|
15592
|
-
_cModels.sort(function(a, b) {
|
|
15593
|
-
var sa = a._chatScore || 1, sb = b._chatScore || 1;
|
|
15594
|
-
if (sa !== sb) return sb - sa; // higher chat score first
|
|
15595
|
-
return (a.size || 0) - (b.size || 0); // then smaller first within same score
|
|
15596
|
-
});
|
|
15597
|
-
|
|
15598
|
-
// Prefer warm model ONLY if it meets the minimum size for this tier
|
|
15599
|
-
if (_cLastModel) {
|
|
15600
|
-
var _cWarm = _cModels.find(function(m) { return m.name === _cLastModel; });
|
|
15601
|
-
if (_cWarm && (_cWarm.size || 0) >= _cMinSize && (_cWarm.size || 0) <= _cMaxThresh) {
|
|
15602
|
-
_cModel = _cWarm.name;
|
|
15603
|
-
}
|
|
15604
|
-
}
|
|
15605
|
-
// Otherwise pick best-scored model that fits the tier range
|
|
15606
|
-
// Models already sorted by chatScore desc, so first match is best
|
|
15607
|
-
if (!_cModel) {
|
|
15608
|
-
var _cFit = _cModels.filter(function(m) { return (m.size || 0) >= _cMinSize && (m.size || 0) <= _cMaxThresh; });
|
|
15609
|
-
// Pick the one with highest chat score (already sorted)
|
|
15610
|
-
_cModel = _cFit.length > 0 ? _cFit[0].name : '';
|
|
15611
|
-
}
|
|
15612
|
-
// Fallback: if no model fits the range, take the best-scored available
|
|
15613
|
-
if (!_cModel && _cModels.length > 0) {
|
|
15614
|
-
_cModel = _cModels[0].name; // first = highest chatScore
|
|
15615
|
-
dlog('COHERE: no model fits tier ' + _cTier + ' range [' + (_cMinSize / _cGB).toFixed(0) + 'GB-' + (_cMaxThresh / _cGB).toFixed(0) + 'GB], using best-scored: ' + _cModel);
|
|
15616
|
-
}
|
|
15617
|
-
dlog('COHERE routing: tier=' + ['trivial','moderate','complex','expert'][_cTier] + ' model=' + _cModel + ' (chatScore=' + ((_cModels.find(function(m){return m.name===_cModel})||{})._chatScore||'?') + ')');
|
|
15618
|
-
} catch {}
|
|
15619
|
-
if (!_cModel) { dlog('COHERE: no Ollama models available'); _cohereStats.queriesErrors++; _saveStats(); continue; }
|
|
15911
|
+
_cModel = _cSelected.model || '';
|
|
15912
|
+
dlog('COHERE routing: source=' + ((_cCatalog && _cCatalog.source) || 'unknown') + ' passthrough=' + (!!(_cCatalog && _cCatalog.passthrough)) + ' tier=' + ['trivial','moderate','complex','expert'][_cTier] + ' model=' + _cModel + ' (chatScore=' + ((_cModels.find(function(m){return m.name===_cModel})||{})._chatScore||'?') + ')');
|
|
15913
|
+
} catch (_cCatalogErr) {
|
|
15914
|
+
dlog('COHERE catalog error: ' + (_cCatalogErr.message || _cCatalogErr));
|
|
15915
|
+
}
|
|
15916
|
+
if (!_cModel) { dlog('COHERE: no endpoint models available'); _cohereStats.queriesErrors++; _saveStats(); continue; }
|
|
15620
15917
|
try {
|
|
15621
15918
|
// Scan inbound query for leaked secrets (defense-in-depth)
|
|
15622
15919
|
const _cSecretPatterns = [/sk-[a-zA-Z0-9]{20,}/g, /ghp_[a-zA-Z0-9]{36,}/g, /AKIA[0-9A-Z]{16}/g];
|
|
@@ -15652,6 +15949,10 @@ process.on('unhandledRejection', (reason) => {
|
|
|
15652
15949
|
if (_cApiAvailable) {
|
|
15653
15950
|
dlog('COHERE: routing through full AgenticRunner at ' + _cApiUrl + '/v1/run');
|
|
15654
15951
|
try {
|
|
15952
|
+
var _cRunEnv = {};
|
|
15953
|
+
if (_cCatalog && _cCatalog.endpointUrl) _cRunEnv.OMNIUS_BACKEND_URL = _cCatalog.endpointUrl;
|
|
15954
|
+
if (_cCatalog && _cCatalog.endpointAuth) _cRunEnv.OMNIUS_API_KEY = _cCatalog.endpointAuth;
|
|
15955
|
+
if (_cModel) _cRunEnv.OMNIUS_MODEL = _cModel;
|
|
15655
15956
|
var _cRunResp = await fetch(_cApiUrl + '/v1/run', {
|
|
15656
15957
|
method: 'POST',
|
|
15657
15958
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -15662,6 +15963,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
15662
15963
|
timeout_s: 90,
|
|
15663
15964
|
sandbox: 'none',
|
|
15664
15965
|
profile: 'cohere-mesh',
|
|
15966
|
+
env: _cRunEnv,
|
|
15665
15967
|
}),
|
|
15666
15968
|
signal: AbortSignal.timeout(120000),
|
|
15667
15969
|
});
|
|
@@ -15701,22 +16003,34 @@ process.on('unhandledRejection', (reason) => {
|
|
|
15701
16003
|
if (_cContent) {
|
|
15702
16004
|
dlog('COHERE: AgenticRunner responded (' + _cContent.length + ' chars)');
|
|
15703
16005
|
} else {
|
|
15704
|
-
dlog('COHERE: AgenticRunner returned empty
|
|
16006
|
+
dlog('COHERE: AgenticRunner returned empty');
|
|
15705
16007
|
}
|
|
15706
16008
|
} catch (_cRunErr) {
|
|
15707
|
-
dlog('COHERE: AgenticRunner error: ' + (_cRunErr.message || _cRunErr)
|
|
16009
|
+
dlog('COHERE: AgenticRunner error: ' + (_cRunErr.message || _cRunErr));
|
|
15708
16010
|
}
|
|
15709
16011
|
} else {
|
|
15710
|
-
dlog('COHERE: Omnius API not available at ' + _cApiUrl
|
|
15711
|
-
|
|
16012
|
+
dlog('COHERE: Omnius API not available at ' + _cApiUrl);
|
|
16013
|
+
}
|
|
16014
|
+
|
|
16015
|
+
// No raw local-Ollama fallback. If the user explicitly exposed an
|
|
16016
|
+
// OpenAI-compatible passthrough endpoint, use that endpoint directly
|
|
16017
|
+
// as a degraded fallback so COHERE still serves external providers.
|
|
16018
|
+
if (!_cContent && _cCatalog && _cCatalog.passthrough === true) {
|
|
16019
|
+
try {
|
|
16020
|
+
var _cDirect = await _cohereDirectEndpointFallback(_cCatalog, _cModel, _cData);
|
|
16021
|
+
_cContent = _cDirect.content || '';
|
|
16022
|
+
_cUsage = _cDirect.usage;
|
|
16023
|
+
if (_cContent) dlog('COHERE: direct passthrough fallback responded (' + _cContent.length + ' chars)');
|
|
16024
|
+
} catch (_cDirectErr) {
|
|
16025
|
+
dlog('COHERE: direct passthrough fallback failed: ' + (_cDirectErr.message || _cDirectErr));
|
|
16026
|
+
}
|
|
15712
16027
|
}
|
|
15713
16028
|
|
|
15714
|
-
// NO raw Ollama fallback — all queries MUST go through AgenticRunner
|
|
15715
|
-
// If /v1/run failed or API unavailable, report the error instead of
|
|
15716
|
-
// sending garbage responses without tools/context/system prompt.
|
|
15717
16029
|
if (!_cContent) {
|
|
15718
|
-
_cContent =
|
|
15719
|
-
|
|
16030
|
+
_cContent = _cApiAvailable
|
|
16031
|
+
? '[COHERE error] AgenticRunner returned empty response. Check Omnius API server logs.'
|
|
16032
|
+
: '[COHERE error] Omnius API server not running on this node. Start it with: omnius serve, or expose an OpenAI-compatible endpoint with /expose passthrough.';
|
|
16033
|
+
dlog('COHERE: no content from AgenticRunner or passthrough endpoint');
|
|
15720
16034
|
}
|
|
15721
16035
|
|
|
15722
16036
|
const _cLatency = Date.now() - _cStart;
|
|
@@ -16072,24 +16386,8 @@ process.on('unhandledRejection', (reason) => {
|
|
|
16072
16386
|
async function _publishCapacityAnnouncement() {
|
|
16073
16387
|
if (!cohereActive || !_natsConn || !_natsCodec) return;
|
|
16074
16388
|
try {
|
|
16075
|
-
var
|
|
16076
|
-
var _capModels = [];
|
|
16077
|
-
try {
|
|
16078
|
-
var _capTags = await fetch(_capOllamaUrl + '/api/tags').then(function(r) { return r.json(); });
|
|
16079
|
-
_capModels = (_capTags.models || []).map(function(m) {
|
|
16080
|
-
return {
|
|
16081
|
-
name: m.name,
|
|
16082
|
-
size: m.size || 0,
|
|
16083
|
-
family: m.details ? m.details.family || '' : '',
|
|
16084
|
-
parameterSize: m.details ? m.details.parameter_size || '' : '',
|
|
16085
|
-
quantization: m.details ? m.details.quantization_level || '' : '',
|
|
16086
|
-
};
|
|
16087
|
-
});
|
|
16088
|
-
} catch {}
|
|
16089
|
-
// Filter by allowlist
|
|
16090
|
-
if (_cohereAllowedModels) {
|
|
16091
|
-
_capModels = _capModels.filter(function(m) { return _cohereAllowedModels.has(m.name); });
|
|
16092
|
-
}
|
|
16389
|
+
var _capCatalog = await _cohereGetModelCatalog({});
|
|
16390
|
+
var _capModels = _cohereApplyAllowlist(_capCatalog.models || []);
|
|
16093
16391
|
var _capMetrics = await _collectSysMetrics();
|
|
16094
16392
|
// CO-02: Enriched per-model capacity — warm/cold, specialty, estimated latency
|
|
16095
16393
|
var _capEnriched = _capModels.map(function(m) {
|
|
@@ -16122,6 +16420,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
16122
16420
|
agentName: agentName,
|
|
16123
16421
|
agentType: agentType,
|
|
16124
16422
|
cohereActive: cohereActive,
|
|
16423
|
+
endpoint: _cohereEndpointSnapshot(_capCatalog),
|
|
16125
16424
|
models: _capEnriched,
|
|
16126
16425
|
warmModel: _cLastModel || null,
|
|
16127
16426
|
modelCount: _capEnriched.length,
|
|
@@ -16129,7 +16428,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
16129
16428
|
totalVram: _capTotalVram,
|
|
16130
16429
|
availableVram: _capAvailVram,
|
|
16131
16430
|
specialties: _capSpecialties,
|
|
16132
|
-
capabilities: ['inference'
|
|
16431
|
+
capabilities: ['inference', 'cohere_inference'],
|
|
16133
16432
|
allowedModels: _cohereAllowedModels ? [..._cohereAllowedModels] : null,
|
|
16134
16433
|
stats: {
|
|
16135
16434
|
queriesAnswered: _cohereStats.queriesAnswered,
|
|
@@ -16198,6 +16497,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
16198
16497
|
multiaddrs: [],
|
|
16199
16498
|
timestamp: Date.now(),
|
|
16200
16499
|
capabilities: _capModels.map(function(m) { return m.name; }),
|
|
16500
|
+
endpoint: _cohereEndpointSnapshot(_capCatalog),
|
|
16201
16501
|
identityCid: _idCid || undefined,
|
|
16202
16502
|
identityHash: _idHash || undefined,
|
|
16203
16503
|
identityVersion: _idVersion || undefined,
|
|
@@ -17131,11 +17431,15 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
17131
17431
|
},
|
|
17132
17432
|
format: {
|
|
17133
17433
|
type: "string",
|
|
17134
|
-
description: "For cohere_stats: set to 'json' for structured
|
|
17434
|
+
description: "For cohere_stats/cohere_list_models: set to 'json' for structured output"
|
|
17135
17435
|
},
|
|
17136
17436
|
json: {
|
|
17137
17437
|
type: "string",
|
|
17138
|
-
description: "For cohere_stats: set to '1' for structured
|
|
17438
|
+
description: "For cohere_stats/cohere_list_models: set to '1' for structured output"
|
|
17439
|
+
},
|
|
17440
|
+
refresh: {
|
|
17441
|
+
type: "string",
|
|
17442
|
+
description: "For cohere_list_models: set to '1' to refresh the active endpoint catalog"
|
|
17139
17443
|
}
|
|
17140
17444
|
},
|
|
17141
17445
|
required: ["action"],
|
|
@@ -17282,7 +17586,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
17282
17586
|
result = await this.sendDaemonCmd("cohere_deny_model", { model: String(args.model ?? "") });
|
|
17283
17587
|
break;
|
|
17284
17588
|
case "cohere_list_models":
|
|
17285
|
-
result = await this.sendDaemonCmd("cohere_list_models", {});
|
|
17589
|
+
result = await this.sendDaemonCmd("cohere_list_models", { format: String(args.format ?? ""), json: String(args.json ?? ""), refresh: String(args.refresh ?? "") });
|
|
17286
17590
|
break;
|
|
17287
17591
|
case "ipfs_add":
|
|
17288
17592
|
result = await this.sendDaemonCmd("ipfs_add", { content: String(args.content ?? args.message ?? "") });
|
|
@@ -604995,7 +605299,14 @@ function emptyCohereStats(isActive = false) {
|
|
|
604995
605299
|
bytesOut: 0,
|
|
604996
605300
|
modelsUsed: {},
|
|
604997
605301
|
peersServed: {},
|
|
604998
|
-
allowedModels: null
|
|
605302
|
+
allowedModels: null,
|
|
605303
|
+
endpoint: {
|
|
605304
|
+
source: "unknown",
|
|
605305
|
+
passthrough: false,
|
|
605306
|
+
endpointUrl: "",
|
|
605307
|
+
modelCount: 0,
|
|
605308
|
+
updatedAt: 0
|
|
605309
|
+
}
|
|
604999
605310
|
};
|
|
605000
605311
|
}
|
|
605001
605312
|
function numberField(value2) {
|
|
@@ -605014,6 +605325,7 @@ function parseCohereStatsOutput(output, isActive = false) {
|
|
|
605014
605325
|
try {
|
|
605015
605326
|
const parsed = JSON.parse(output);
|
|
605016
605327
|
const active = typeof parsed.active === "boolean" ? parsed.active : String(parsed.status ?? "").toLowerCase() === "active";
|
|
605328
|
+
const endpointRaw = parsed.endpoint && typeof parsed.endpoint === "object" ? parsed.endpoint : {};
|
|
605017
605329
|
return {
|
|
605018
605330
|
status: active ? "active" : "inactive",
|
|
605019
605331
|
active,
|
|
@@ -605029,7 +605341,15 @@ function parseCohereStatsOutput(output, isActive = false) {
|
|
|
605029
605341
|
bytesOut: numberField(parsed.bytesOut),
|
|
605030
605342
|
modelsUsed: mapNumberRecord(parsed.modelsUsed),
|
|
605031
605343
|
peersServed: mapNumberRecord(parsed.peersServed),
|
|
605032
|
-
allowedModels: Array.isArray(parsed.allowedModels) ? parsed.allowedModels.map(String) : null
|
|
605344
|
+
allowedModels: Array.isArray(parsed.allowedModels) ? parsed.allowedModels.map(String) : null,
|
|
605345
|
+
endpoint: {
|
|
605346
|
+
source: String(endpointRaw.source ?? "unknown"),
|
|
605347
|
+
passthrough: endpointRaw.passthrough === true,
|
|
605348
|
+
endpointUrl: String(endpointRaw.endpointUrl ?? ""),
|
|
605349
|
+
modelCount: numberField(endpointRaw.modelCount),
|
|
605350
|
+
updatedAt: numberField(endpointRaw.updatedAt),
|
|
605351
|
+
cachedOnly: endpointRaw.cachedOnly === true
|
|
605352
|
+
}
|
|
605033
605353
|
};
|
|
605034
605354
|
} catch {
|
|
605035
605355
|
return emptyCohereStats(isActive);
|
|
@@ -605054,10 +605374,11 @@ async function fetchCohereDashboardState(ctx3) {
|
|
|
605054
605374
|
} catch {
|
|
605055
605375
|
}
|
|
605056
605376
|
try {
|
|
605057
|
-
const r2 = await nexus.execute({ action: "cohere_list_models" });
|
|
605377
|
+
const r2 = await nexus.execute({ action: "cohere_list_models", format: "json" });
|
|
605058
605378
|
if (r2.success) {
|
|
605059
605379
|
try {
|
|
605060
|
-
|
|
605380
|
+
const parsed = JSON.parse(r2.output);
|
|
605381
|
+
state.modelList = Array.isArray(parsed.models) ? parsed.models.map(String) : [];
|
|
605061
605382
|
} catch {
|
|
605062
605383
|
state.modelList = r2.output.split("\n").map((l2) => l2.trim()).filter(Boolean);
|
|
605063
605384
|
}
|
|
@@ -605083,8 +605404,9 @@ function cohereStatusLines(stats, modelList) {
|
|
|
605083
605404
|
`Sent out: ${stats.queriesSent} · avg latency ${stats.avgLatencyMs}ms`,
|
|
605084
605405
|
`Data: in ${formatFileSize(stats.bytesIn)} · out ${formatFileSize(stats.bytesOut)}`,
|
|
605085
605406
|
"",
|
|
605086
|
-
`
|
|
605087
|
-
`
|
|
605407
|
+
`Endpoint: ${stats.endpoint.source}${stats.endpoint.passthrough ? " passthrough" : ""}${stats.endpoint.endpointUrl ? ` · ${stats.endpoint.endpointUrl}` : ""}`,
|
|
605408
|
+
`Models available: ${modelList.length || stats.endpoint.modelCount}${stats.endpoint.cachedOnly ? " (cached)" : ""}`,
|
|
605409
|
+
`Allowlist: ${stats.allowedModels ? stats.allowedModels.join(", ") || "(empty)" : "all endpoint models"}`,
|
|
605088
605410
|
`Top models: ${modelEntries.length ? modelEntries.slice(0, 5).map(([m2, n2]) => `${m2} (${n2})`).join(", ") : "none yet"}`,
|
|
605089
605411
|
`Peers served: ${peerEntries.length ? peerEntries.slice(0, 5).map(([p2, n2]) => `${p2.slice(0, 20)} (${n2})`).join(", ") : "none yet"}`
|
|
605090
605412
|
];
|
|
@@ -605098,7 +605420,7 @@ async function showCohereDashboard(ctx3) {
|
|
|
605098
605420
|
while (true) {
|
|
605099
605421
|
const currentActive = ctx3.isCohere?.() ?? false;
|
|
605100
605422
|
const toggleLabel = currentActive ? "Disable COHERE" : "Enable COHERE";
|
|
605101
|
-
const toggleDetail = currentActive ? `Active — forwarding ${ctx3.config.model}` : "Join the distributed cognitive commons";
|
|
605423
|
+
const toggleDetail = currentActive ? `Active — forwarding ${ctx3.config.model} via current endpoint` : "Join the distributed cognitive commons";
|
|
605102
605424
|
const items = [
|
|
605103
605425
|
{
|
|
605104
605426
|
key: "hdr-status",
|
|
@@ -663757,7 +664079,7 @@ The user pasted a clipboard image saved at ${relPath}. Use the OCR, vision analy
|
|
|
663757
664079
|
try {
|
|
663758
664080
|
if (!commandCtx.isExposeActive?.()) {
|
|
663759
664081
|
writeContent(
|
|
663760
|
-
() => renderInfo("COHERE: exposing
|
|
664082
|
+
() => renderInfo("COHERE: exposing current endpoint to mesh...")
|
|
663761
664083
|
);
|
|
663762
664084
|
await commandCtx.exposeStart?.("passthrough");
|
|
663763
664085
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.155",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.155",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED