omnius 1.0.155 → 1.0.157
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 +1727 -245
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11733,6 +11733,8 @@ function _envRole() {
|
|
|
11733
11733
|
return role === 'light' || role === 'storage' || role === 'full' ? role : 'full';
|
|
11734
11734
|
}
|
|
11735
11735
|
var _nexusSignalingServer = process.env.OMNIUS_NEXUS_SIGNALING_SERVER || 'https://openagents.nexus';
|
|
11736
|
+
var _nexusDirectoryOrigin = (process.env.OMNIUS_NEXUS_DIRECTORY_ORIGIN || _nexusSignalingServer).replace(/\\/+$/, '');
|
|
11737
|
+
var _nexusSponsorsUrl = _nexusDirectoryOrigin + '/api/v1/sponsors';
|
|
11736
11738
|
var _nexusNatsServers = _envList('OMNIUS_NEXUS_NATS_SERVERS');
|
|
11737
11739
|
var _nexusManifestUrls = _envList('OMNIUS_NEXUS_MANIFEST_URLS');
|
|
11738
11740
|
var nexusOpts = {
|
|
@@ -11854,6 +11856,12 @@ var _sponsorDailyTokensUsed = 0;
|
|
|
11854
11856
|
var _sponsorDailyResetAt = Date.now() + 86400000;
|
|
11855
11857
|
var _sponsorBlockedRequests = 0;
|
|
11856
11858
|
var _sponsorTokenRateSamples = [];
|
|
11859
|
+
var _sponsorMediaConfig = null;
|
|
11860
|
+
var _sponsorMediaActive = {};
|
|
11861
|
+
var _sponsorMediaRequestWindow = {};
|
|
11862
|
+
var _sponsorMediaDailyJobs = {};
|
|
11863
|
+
var _sponsorMediaDailyResetAt = Date.now() + 86400000;
|
|
11864
|
+
var _mediaByRequest = {};
|
|
11857
11865
|
|
|
11858
11866
|
function _sponsorPrune(now) {
|
|
11859
11867
|
while (_sponsorRequestWindow.length > 0 && _sponsorRequestWindow[0] < now - 60000) _sponsorRequestWindow.shift();
|
|
@@ -11927,6 +11935,80 @@ function _sponsorRecordUsage(inputTokens, outputTokens, includeRate) {
|
|
|
11927
11935
|
if (includeRate !== false) _sponsorRecordTokenRate(output);
|
|
11928
11936
|
}
|
|
11929
11937
|
|
|
11938
|
+
function _sponsorMediaPrune(now) {
|
|
11939
|
+
now = now || Date.now();
|
|
11940
|
+
if (_sponsorMediaDailyResetAt <= now) {
|
|
11941
|
+
_sponsorMediaDailyJobs = {};
|
|
11942
|
+
_sponsorMediaDailyResetAt = now + 86400000;
|
|
11943
|
+
}
|
|
11944
|
+
for (var key of Object.keys(_sponsorMediaRequestWindow)) {
|
|
11945
|
+
var arr = _sponsorMediaRequestWindow[key] || [];
|
|
11946
|
+
while (arr.length > 0 && arr[0] < now - 60000) arr.shift();
|
|
11947
|
+
_sponsorMediaRequestWindow[key] = arr;
|
|
11948
|
+
}
|
|
11949
|
+
}
|
|
11950
|
+
|
|
11951
|
+
function _sponsorMediaLimitsFor(modality) {
|
|
11952
|
+
if (!_sponsorMediaConfig || !_sponsorMediaConfig[modality]) return null;
|
|
11953
|
+
return _sponsorMediaConfig[modality];
|
|
11954
|
+
}
|
|
11955
|
+
|
|
11956
|
+
function _sponsorMediaAdmit(modality) {
|
|
11957
|
+
var limits = _sponsorMediaLimitsFor(modality);
|
|
11958
|
+
if (!limits || !limits.enabled) return { ok: false, reason: modality + ' sponsorship is disabled.' };
|
|
11959
|
+
var now = Date.now();
|
|
11960
|
+
_sponsorMediaPrune(now);
|
|
11961
|
+
var active = _sponsorMediaActive[modality] || 0;
|
|
11962
|
+
var window = _sponsorMediaRequestWindow[modality] || [];
|
|
11963
|
+
var daily = _sponsorMediaDailyJobs[modality] || 0;
|
|
11964
|
+
var maxConcurrent = Math.max(0, Number(limits.maxConcurrent || 0));
|
|
11965
|
+
var jobsPerMinute = Math.max(0, Number(limits.jobsPerMinute || 0));
|
|
11966
|
+
var jobsPerDay = Math.max(0, Number(limits.jobsPerDay || 0));
|
|
11967
|
+
if (maxConcurrent <= 0 || jobsPerMinute <= 0 || jobsPerDay <= 0) {
|
|
11968
|
+
_sponsorBlockedRequests++;
|
|
11969
|
+
return { ok: false, reason: modality + ' sponsorship is paused or has no quota configured.' };
|
|
11970
|
+
}
|
|
11971
|
+
if (_sponsorLimits && _sponsorActiveRequests >= _sponsorLimits.maxConcurrent) {
|
|
11972
|
+
_sponsorBlockedRequests++;
|
|
11973
|
+
return { ok: false, reason: 'Too many sponsor requests (' + _sponsorActiveRequests + '/' + _sponsorLimits.maxConcurrent + '). Try again shortly.' };
|
|
11974
|
+
}
|
|
11975
|
+
if (active >= maxConcurrent) {
|
|
11976
|
+
_sponsorBlockedRequests++;
|
|
11977
|
+
return { ok: false, reason: 'Too many concurrent ' + modality + ' jobs (' + active + '/' + maxConcurrent + '). Try again shortly.' };
|
|
11978
|
+
}
|
|
11979
|
+
if (window.length >= jobsPerMinute) {
|
|
11980
|
+
_sponsorBlockedRequests++;
|
|
11981
|
+
return { ok: false, reason: modality + ' rate limited (' + jobsPerMinute + ' jobs/min).' };
|
|
11982
|
+
}
|
|
11983
|
+
if (daily >= jobsPerDay) {
|
|
11984
|
+
_sponsorBlockedRequests++;
|
|
11985
|
+
return { ok: false, reason: modality + ' daily job budget exhausted.' };
|
|
11986
|
+
}
|
|
11987
|
+
_sponsorActiveRequests++;
|
|
11988
|
+
_sponsorMediaActive[modality] = active + 1;
|
|
11989
|
+
window.push(now);
|
|
11990
|
+
_sponsorMediaRequestWindow[modality] = window;
|
|
11991
|
+
_sponsorMediaDailyJobs[modality] = daily + 1;
|
|
11992
|
+
return { ok: true };
|
|
11993
|
+
}
|
|
11994
|
+
|
|
11995
|
+
function _sponsorMediaRelease(modality) {
|
|
11996
|
+
if (_sponsorActiveRequests > 0) _sponsorActiveRequests--;
|
|
11997
|
+
var active = _sponsorMediaActive[modality] || 0;
|
|
11998
|
+
if (active > 0) _sponsorMediaActive[modality] = active - 1;
|
|
11999
|
+
}
|
|
12000
|
+
|
|
12001
|
+
function _sponsorMediaGatewaySnapshot() {
|
|
12002
|
+
_sponsorMediaPrune(Date.now());
|
|
12003
|
+
return {
|
|
12004
|
+
active: _sponsorMediaActive,
|
|
12005
|
+
requestsInWindow: Object.fromEntries(Object.keys(_sponsorMediaRequestWindow).map(function(k) { return [k, (_sponsorMediaRequestWindow[k] || []).length]; })),
|
|
12006
|
+
dailyJobsUsed: _sponsorMediaDailyJobs,
|
|
12007
|
+
dailyResetAt: _sponsorMediaDailyResetAt,
|
|
12008
|
+
limits: _sponsorMediaConfig,
|
|
12009
|
+
};
|
|
12010
|
+
}
|
|
12011
|
+
|
|
11930
12012
|
function _sponsorGatewaySnapshot() {
|
|
11931
12013
|
var now = Date.now();
|
|
11932
12014
|
_sponsorPrune(now);
|
|
@@ -11938,6 +12020,7 @@ function _sponsorGatewaySnapshot() {
|
|
|
11938
12020
|
blockedRequests: _sponsorBlockedRequests,
|
|
11939
12021
|
tokensPerSecond: _sponsorTokenRate(now),
|
|
11940
12022
|
limits: _sponsorLimits,
|
|
12023
|
+
media: _sponsorMediaGatewaySnapshot(),
|
|
11941
12024
|
};
|
|
11942
12025
|
}
|
|
11943
12026
|
|
|
@@ -12267,10 +12350,11 @@ function _coherePersistEndpointCatalog() {
|
|
|
12267
12350
|
source: m.source || _cohereEndpointCatalog.source,
|
|
12268
12351
|
passthrough: !!m.passthrough,
|
|
12269
12352
|
};
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12353
|
+
});
|
|
12354
|
+
pub.pricingMenu = Array.isArray(_cohereEndpointCatalog.pricingMenu) ? _cohereEndpointCatalog.pricingMenu : [];
|
|
12355
|
+
pub.endpointAuth = String(_cohereEndpointCatalog.endpointAuth || '');
|
|
12356
|
+
_writeJson(cohereEndpointCatalogFile, pub);
|
|
12357
|
+
}
|
|
12274
12358
|
function _cohereRememberEndpointCatalog(opts) {
|
|
12275
12359
|
opts = opts || {};
|
|
12276
12360
|
var passthrough = opts.passthrough === true;
|
|
@@ -12297,7 +12381,7 @@ function _cohereLoadPersistedEndpointCatalog() {
|
|
|
12297
12381
|
source: String(stored.source || 'cached'),
|
|
12298
12382
|
passthrough: stored.passthrough === true,
|
|
12299
12383
|
endpointUrl: String(stored.endpointUrl || ''),
|
|
12300
|
-
|
|
12384
|
+
endpointAuth: String(stored.endpointAuth || ''),
|
|
12301
12385
|
models: _cohereAnnotateModels(stored.models, String(stored.source || 'cached'), stored.passthrough === true),
|
|
12302
12386
|
pricingMenu: Array.isArray(stored.pricingMenu) ? stored.pricingMenu : [],
|
|
12303
12387
|
updatedAt: Number(stored.updatedAt || 0) || 0,
|
|
@@ -12895,7 +12979,9 @@ async function handleCmd(cmd) {
|
|
|
12895
12979
|
return;
|
|
12896
12980
|
}
|
|
12897
12981
|
// NX-07: Fetch per-model metadata from Ollama for capacity announcements
|
|
12898
|
-
var _saModels = args.models
|
|
12982
|
+
var _saModels = Array.isArray(args.models)
|
|
12983
|
+
? args.models
|
|
12984
|
+
: String(args.models || '').split(',').map(function(m) { return m.trim(); }).filter(Boolean);
|
|
12899
12985
|
var _saModelDetails = [];
|
|
12900
12986
|
try {
|
|
12901
12987
|
var _saOllamaUrl = process.env.OLLAMA_HOST || 'http://localhost:11434';
|
|
@@ -12916,24 +13002,34 @@ async function handleCmd(cmd) {
|
|
|
12916
13002
|
} catch {}
|
|
12917
13003
|
var sponsorLimitsArg = {};
|
|
12918
13004
|
try { sponsorLimitsArg = args.limits ? JSON.parse(args.limits) : {}; } catch {}
|
|
12919
|
-
|
|
13005
|
+
var sponsorServicesArg = [];
|
|
13006
|
+
try {
|
|
13007
|
+
if (args.services) sponsorServicesArg = typeof args.services === 'string' ? JSON.parse(args.services) : args.services;
|
|
13008
|
+
} catch {}
|
|
13009
|
+
var sponsorHeaderArg = {};
|
|
13010
|
+
try { sponsorHeaderArg = args.header ? (typeof args.header === 'string' ? JSON.parse(args.header) : args.header) : {}; } catch {}
|
|
13011
|
+
var sponsorData = {
|
|
12920
13012
|
type: 'sponsor.announce',
|
|
12921
13013
|
peerId: (connected ? nexus.peerId : 'unknown') || 'unknown',
|
|
12922
13014
|
libp2pPeerId: (connected ? nexus.peerId : '') || '',
|
|
12923
13015
|
name: args.name || 'Anonymous Sponsor',
|
|
12924
13016
|
models: _saModels.length > 0 ? _saModels : _saModelDetails.map(function(m) { return m.name; }),
|
|
12925
13017
|
modelDetails: _saModelDetails, // NX-07: per-model capacity
|
|
13018
|
+
services: Array.isArray(sponsorServicesArg) ? sponsorServicesArg : [],
|
|
13019
|
+
mediaCapabilities: Array.isArray(sponsorServicesArg) ? sponsorServicesArg.filter(function(s) { return s && s.kind && s.kind !== 'llm'; }) : [],
|
|
12926
13020
|
tunnelUrl: args.tunnel_url || null,
|
|
12927
13021
|
authKey: args.auth_key || '',
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
13022
|
+
limits: {
|
|
13023
|
+
maxRequestsPerMinute: parseInt(args.rpm || sponsorLimitsArg.maxRequestsPerMinute || '60', 10),
|
|
13024
|
+
maxTokensPerDay: parseInt(args.tpd || sponsorLimitsArg.maxTokensPerDay || '100000', 10),
|
|
13025
|
+
maxConcurrent: parseInt(args.max_concurrent || sponsorLimitsArg.maxConcurrent || '1', 10),
|
|
13026
|
+
media: sponsorLimitsArg.media,
|
|
13027
|
+
},
|
|
13028
|
+
banner: args.banner || null,
|
|
13029
|
+
message: args.message || '',
|
|
13030
|
+
linkUrl: args.link_url || '',
|
|
13031
|
+
linkText: args.link_text || '',
|
|
13032
|
+
header: sponsorHeaderArg && typeof sponsorHeaderArg === 'object' ? sponsorHeaderArg : {},
|
|
12937
13033
|
status: 'active',
|
|
12938
13034
|
timestamp: Date.now(),
|
|
12939
13035
|
};
|
|
@@ -12942,9 +13038,9 @@ async function handleCmd(cmd) {
|
|
|
12942
13038
|
globalThis._activeSponsorData = sponsorData;
|
|
12943
13039
|
dlog('sponsor_announce: published to nexus.sponsors.announce');
|
|
12944
13040
|
|
|
12945
|
-
// Persist to KV-backed sponsor directory (
|
|
13041
|
+
// Persist to KV-backed sponsor directory (OpenAgents Nexus worker)
|
|
12946
13042
|
try {
|
|
12947
|
-
var kvResp = await fetch(
|
|
13043
|
+
var kvResp = await fetch(_nexusSponsorsUrl, {
|
|
12948
13044
|
method: 'POST',
|
|
12949
13045
|
headers: { 'Content-Type': 'application/json' },
|
|
12950
13046
|
body: JSON.stringify(sponsorData),
|
|
@@ -13007,6 +13103,8 @@ async function handleCmd(cmd) {
|
|
|
13007
13103
|
rateLimit: String(sponsorData.limits.maxRequestsPerMinute) + '/min',
|
|
13008
13104
|
sponsor: sponsorData,
|
|
13009
13105
|
models: sponsorData.models,
|
|
13106
|
+
services: sponsorData.services,
|
|
13107
|
+
mediaCapabilities: sponsorData.mediaCapabilities,
|
|
13010
13108
|
limits: sponsorData.limits,
|
|
13011
13109
|
});
|
|
13012
13110
|
writeResp(id, { ok: true, output: 'Sponsor announced: ' + sponsorData.name + ' (' + sponsorData.models.length + ' models) [DHT+GossipSub+NATS+KV+Room]' });
|
|
@@ -13085,9 +13183,9 @@ async function handleCmd(cmd) {
|
|
|
13085
13183
|
var discoverTimeout = parseInt(args.timeout_ms || '5000', 10);
|
|
13086
13184
|
|
|
13087
13185
|
// ── Source 1: KV-backed persistent directory (MOST RELIABLE) ──
|
|
13088
|
-
// Query the
|
|
13089
|
-
|
|
13090
|
-
|
|
13186
|
+
// Query the OpenAgents Nexus worker for persisted sponsor listings
|
|
13187
|
+
try {
|
|
13188
|
+
var kvResp = await fetch(_nexusSponsorsUrl, { signal: AbortSignal.timeout(5000) });
|
|
13091
13189
|
if (kvResp.ok) {
|
|
13092
13190
|
var kvText = await kvResp.text();
|
|
13093
13191
|
var kvData = kvText.trim() ? JSON.parse(kvText) : { sponsors: [] };
|
|
@@ -14183,7 +14281,7 @@ async function handleCmd(cmd) {
|
|
|
14183
14281
|
if (typeof nexus.getRegisteredCapabilities === 'function' && typeof nexus.unregisterCapability === 'function') {
|
|
14184
14282
|
var oldCaps = nexus.getRegisteredCapabilities();
|
|
14185
14283
|
for (var oci = 0; oci < oldCaps.length; oci++) {
|
|
14186
|
-
if (oldCaps[oci].startsWith('inference:') || oldCaps[oci] === 'system_metrics' || oldCaps[oci] === '__list_capabilities') {
|
|
14284
|
+
if (oldCaps[oci].startsWith('inference:') || oldCaps[oci].startsWith('media:') || oldCaps[oci] === 'system_metrics' || oldCaps[oci] === '__list_capabilities') {
|
|
14187
14285
|
try { nexus.unregisterCapability(oldCaps[oci]); } catch {}
|
|
14188
14286
|
}
|
|
14189
14287
|
}
|
|
@@ -14217,6 +14315,18 @@ async function handleCmd(cmd) {
|
|
|
14217
14315
|
} else {
|
|
14218
14316
|
_sponsorLimits = null;
|
|
14219
14317
|
}
|
|
14318
|
+
try {
|
|
14319
|
+
var mediaConfigRaw = args.media_config || args.media_limits || '';
|
|
14320
|
+
if (mediaConfigRaw) {
|
|
14321
|
+
var mediaHelpersForConfig = await import('@omnius/execution');
|
|
14322
|
+
_sponsorMediaConfig = mediaHelpersForConfig.normalizeSponsorMediaConfig(JSON.parse(mediaConfigRaw));
|
|
14323
|
+
} else {
|
|
14324
|
+
_sponsorMediaConfig = null;
|
|
14325
|
+
}
|
|
14326
|
+
} catch (mediaConfigErr) {
|
|
14327
|
+
dlog('expose: media sponsor config parse failed: ' + (mediaConfigErr.message || mediaConfigErr));
|
|
14328
|
+
_sponsorMediaConfig = null;
|
|
14329
|
+
}
|
|
14220
14330
|
|
|
14221
14331
|
// Passthrough mode: forward from a remote /endpoint (Chutes, Groq, etc.)
|
|
14222
14332
|
var isPassthrough = args.passthrough === 'true';
|
|
@@ -14762,6 +14872,228 @@ async function handleCmd(cmd) {
|
|
|
14762
14872
|
});
|
|
14763
14873
|
}
|
|
14764
14874
|
|
|
14875
|
+
var mediaServices = [];
|
|
14876
|
+
if (_sponsorMediaConfig) {
|
|
14877
|
+
try {
|
|
14878
|
+
var mediaModule = await import('@omnius/execution');
|
|
14879
|
+
mediaServices = mediaModule.buildSponsorMediaServices(_sponsorMediaConfig);
|
|
14880
|
+
for (var msi = 0; msi < mediaServices.length; msi++) {
|
|
14881
|
+
const mediaService = mediaServices[msi];
|
|
14882
|
+
if (typeof nexus.registerCapability === 'function') {
|
|
14883
|
+
nexus.registerCapability(mediaService.capability, async (request, stream) => {
|
|
14884
|
+
var mediaStreamClosed = false;
|
|
14885
|
+
async function mediaWrite(msg) {
|
|
14886
|
+
if (mediaStreamClosed) return;
|
|
14887
|
+
try { await stream.write(msg); } catch (mwErr) {
|
|
14888
|
+
mediaStreamClosed = true;
|
|
14889
|
+
dlog('media stream.write failed: ' + (mwErr.message || mwErr));
|
|
14890
|
+
}
|
|
14891
|
+
}
|
|
14892
|
+
var mediaChunks = [];
|
|
14893
|
+
var mediaInputDone = false;
|
|
14894
|
+
stream.onData(function(msg) {
|
|
14895
|
+
if (msg.type === 'invoke.chunk') {
|
|
14896
|
+
mediaChunks.push(typeof msg.data === 'string' ? msg.data : JSON.stringify(msg.data));
|
|
14897
|
+
}
|
|
14898
|
+
if (msg.type === 'invoke.done' || msg.type === 'invoke.end' || msg.type === 'invoke.close') {
|
|
14899
|
+
mediaInputDone = true;
|
|
14900
|
+
}
|
|
14901
|
+
});
|
|
14902
|
+
await mediaWrite({ type: 'invoke.accept', version: 1, requestId: request.requestId, accepted: true });
|
|
14903
|
+
var mediaWaitMs = 0;
|
|
14904
|
+
while (!mediaInputDone && mediaChunks.length === 0 && mediaWaitMs < 5000) {
|
|
14905
|
+
await new Promise(function(r) { setTimeout(r, 10); });
|
|
14906
|
+
mediaWaitMs += 10;
|
|
14907
|
+
}
|
|
14908
|
+
var mediaRawInput = mediaChunks.join('');
|
|
14909
|
+
if (exposeAuthKey) {
|
|
14910
|
+
var mediaReqAuthKey = '';
|
|
14911
|
+
try {
|
|
14912
|
+
var mediaAuthData = JSON.parse(mediaRawInput);
|
|
14913
|
+
if (mediaAuthData && typeof mediaAuthData === 'object' && mediaAuthData.auth_key) mediaReqAuthKey = mediaAuthData.auth_key;
|
|
14914
|
+
} catch {}
|
|
14915
|
+
if (!mediaReqAuthKey && request.metadata && request.metadata.auth_key) mediaReqAuthKey = request.metadata.auth_key;
|
|
14916
|
+
if (mediaReqAuthKey !== exposeAuthKey) {
|
|
14917
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: 0, event: 'error', data: 'Unauthorized — invalid or missing auth key' });
|
|
14918
|
+
await mediaWrite({ type: 'invoke.done', version: 1, requestId: request.requestId, usage: { inputBytes: 0, outputBytes: 0 } });
|
|
14919
|
+
try { stream.close(); } catch {}
|
|
14920
|
+
return;
|
|
14921
|
+
}
|
|
14922
|
+
}
|
|
14923
|
+
|
|
14924
|
+
var mediaAdmissionOpen = false;
|
|
14925
|
+
var mediaStart = Date.now();
|
|
14926
|
+
var mediaModality = mediaService.kind;
|
|
14927
|
+
var mediaSeq = 0;
|
|
14928
|
+
try {
|
|
14929
|
+
var parsedMediaInput;
|
|
14930
|
+
try { parsedMediaInput = JSON.parse(mediaRawInput || '{}'); } catch { parsedMediaInput = { prompt: mediaRawInput || '' }; }
|
|
14931
|
+
var mediaHelpers = await import('@omnius/execution');
|
|
14932
|
+
var sanitized = mediaHelpers.sanitizeRemoteMediaGenerateRequest(parsedMediaInput, mediaService, _sponsorMediaConfig);
|
|
14933
|
+
if (!sanitized.ok) {
|
|
14934
|
+
throw new Error(sanitized.reason || 'Remote media request rejected');
|
|
14935
|
+
}
|
|
14936
|
+
|
|
14937
|
+
var admission = _sponsorMediaAdmit(mediaModality);
|
|
14938
|
+
if (!admission.ok) {
|
|
14939
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: mediaSeq++, event: 'error', data: admission.reason });
|
|
14940
|
+
await mediaWrite({ type: 'invoke.done', version: 1, requestId: request.requestId, usage: { inputBytes: mediaRawInput.length, outputBytes: 0 } });
|
|
14941
|
+
try {
|
|
14942
|
+
appendFileSync(meteringFile, JSON.stringify({
|
|
14943
|
+
timestamp: Date.now(),
|
|
14944
|
+
peerId: request.from || 'unknown',
|
|
14945
|
+
service: mediaService.capability,
|
|
14946
|
+
capability: mediaService.capability,
|
|
14947
|
+
modality: mediaModality,
|
|
14948
|
+
model: mediaService.model || 'auto',
|
|
14949
|
+
direction: 'inbound',
|
|
14950
|
+
blocked: true,
|
|
14951
|
+
reason: admission.reason,
|
|
14952
|
+
outputBytes: 0,
|
|
14953
|
+
}) + '\\n');
|
|
14954
|
+
} catch {}
|
|
14955
|
+
try { stream.close(); } catch {}
|
|
14956
|
+
return;
|
|
14957
|
+
}
|
|
14958
|
+
mediaAdmissionOpen = true;
|
|
14959
|
+
|
|
14960
|
+
var safeArgs = sanitized.value.args || {};
|
|
14961
|
+
var progressCb = async function(event) {
|
|
14962
|
+
var payload = {
|
|
14963
|
+
type: 'progress',
|
|
14964
|
+
stage: String(event && event.stage ? event.stage : 'run'),
|
|
14965
|
+
message: String(event && event.message ? event.message : ''),
|
|
14966
|
+
percent: event && typeof event.percent === 'number' ? event.percent : undefined,
|
|
14967
|
+
};
|
|
14968
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: mediaSeq++, event: 'progress', data: JSON.stringify(payload) });
|
|
14969
|
+
};
|
|
14970
|
+
|
|
14971
|
+
var tool;
|
|
14972
|
+
if (mediaModality === 'image') {
|
|
14973
|
+
tool = new mediaHelpers.ImageGenerateTool(process.cwd(), rawUrl);
|
|
14974
|
+
} else if (mediaModality === 'video') {
|
|
14975
|
+
tool = new mediaHelpers.VideoGenerateTool(process.cwd());
|
|
14976
|
+
} else {
|
|
14977
|
+
tool = new mediaHelpers.AudioGenerateTool(process.cwd());
|
|
14978
|
+
}
|
|
14979
|
+
if (tool && typeof tool.setProgressCallback === 'function') {
|
|
14980
|
+
tool.setProgressCallback(function(event) { progressCb(event).catch(function() {}); });
|
|
14981
|
+
}
|
|
14982
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: mediaSeq++, event: 'progress', data: JSON.stringify({ type: 'progress', stage: 'start', message: 'Starting ' + mediaModality + ' generation' }) });
|
|
14983
|
+
var mediaResult = await tool.execute(safeArgs);
|
|
14984
|
+
if (!mediaResult || !mediaResult.success) {
|
|
14985
|
+
throw new Error((mediaResult && (mediaResult.error || mediaResult.output)) || 'Media generation failed');
|
|
14986
|
+
}
|
|
14987
|
+
var mutated = Array.isArray(mediaResult.mutatedFiles) ? mediaResult.mutatedFiles : [];
|
|
14988
|
+
var primaryPath = '';
|
|
14989
|
+
for (var mpi = 0; mpi < mutated.length; mpi++) {
|
|
14990
|
+
var pth = String(mutated[mpi] || '');
|
|
14991
|
+
if (mediaModality === 'image' && /\\.(png|jpe?g|webp)$/i.test(pth)) { primaryPath = pth; break; }
|
|
14992
|
+
if (mediaModality === 'video' && /\\.(mp4|webm)$/i.test(pth)) { primaryPath = pth; break; }
|
|
14993
|
+
if ((mediaModality === 'sound' || mediaModality === 'music') && /\\.(wav|mp3|flac|ogg)$/i.test(pth)) { primaryPath = pth; break; }
|
|
14994
|
+
}
|
|
14995
|
+
if (!primaryPath && mutated[0]) primaryPath = String(mutated[0]);
|
|
14996
|
+
if (!primaryPath || !existsSync(primaryPath)) throw new Error('Generated media artifact was not found');
|
|
14997
|
+
var artifactBytes = readFileSync(primaryPath);
|
|
14998
|
+
var limits = _sponsorMediaLimitsFor(mediaModality) || {};
|
|
14999
|
+
var maxBytes = Math.max(0, Number(limits.maxOutputBytes || 0));
|
|
15000
|
+
if (maxBytes > 0 && artifactBytes.length > maxBytes) {
|
|
15001
|
+
throw new Error('Generated artifact exceeds sponsor output limit (' + artifactBytes.length + '/' + maxBytes + ' bytes)');
|
|
15002
|
+
}
|
|
15003
|
+
var artifactId = mediaModality + '-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
|
|
15004
|
+
var filename = require('node:path').basename(primaryPath);
|
|
15005
|
+
var mime = mediaHelpers.mediaMimeFromPath(primaryPath, mediaModality);
|
|
15006
|
+
var sha = createHash('sha256').update(artifactBytes).digest('hex');
|
|
15007
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: mediaSeq++, event: 'artifact.begin', data: JSON.stringify({ type: 'artifact.begin', artifactId: artifactId, filename: filename, mime: mime, sizeBytes: artifactBytes.length, sha256: sha }) });
|
|
15008
|
+
var chunkSize = 64 * 1024;
|
|
15009
|
+
var chunkSeq = 0;
|
|
15010
|
+
for (var off = 0; off < artifactBytes.length; off += chunkSize) {
|
|
15011
|
+
var chunk = artifactBytes.subarray(off, Math.min(off + chunkSize, artifactBytes.length));
|
|
15012
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: mediaSeq++, event: 'artifact.chunk', data: JSON.stringify({ type: 'artifact.chunk', artifactId: artifactId, seq: chunkSeq++, dataBase64: chunk.toString('base64') }) });
|
|
15013
|
+
}
|
|
15014
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: mediaSeq++, event: 'artifact.end', data: JSON.stringify({ type: 'artifact.end', artifactId: artifactId, sha256: sha, sizeBytes: artifactBytes.length }) });
|
|
15015
|
+
var metadata = {
|
|
15016
|
+
ok: true,
|
|
15017
|
+
type: 'result',
|
|
15018
|
+
modality: mediaModality,
|
|
15019
|
+
model: safeArgs.model || mediaService.model || 'auto',
|
|
15020
|
+
backend: safeArgs.backend || mediaService.backend || 'auto',
|
|
15021
|
+
artifact: { artifactId: artifactId, filename: filename, mime: mime, sizeBytes: artifactBytes.length, sha256: sha },
|
|
15022
|
+
output: mediaResult.output || '',
|
|
15023
|
+
durationMs: Date.now() - mediaStart,
|
|
15024
|
+
system: null,
|
|
15025
|
+
};
|
|
15026
|
+
try {
|
|
15027
|
+
var sm2 = await _collectSysMetrics();
|
|
15028
|
+
if (sm2) metadata.system = Object.assign({}, sm2, { gateway: _sponsorGatewaySnapshot() });
|
|
15029
|
+
} catch {}
|
|
15030
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: mediaSeq++, event: 'result', data: JSON.stringify(metadata) });
|
|
15031
|
+
await mediaWrite({ type: 'invoke.done', version: 1, requestId: request.requestId, usage: { inputBytes: mediaRawInput.length, outputBytes: artifactBytes.length } });
|
|
15032
|
+
_mediaByRequest[request.requestId] = {
|
|
15033
|
+
modality: mediaModality,
|
|
15034
|
+
model: String(safeArgs.model || mediaService.model || 'auto'),
|
|
15035
|
+
inputBytes: mediaRawInput.length,
|
|
15036
|
+
outputBytes: artifactBytes.length,
|
|
15037
|
+
durationMs: Date.now() - mediaStart,
|
|
15038
|
+
success: true,
|
|
15039
|
+
};
|
|
15040
|
+
try {
|
|
15041
|
+
appendFileSync(meteringFile, JSON.stringify({
|
|
15042
|
+
timestamp: Date.now(),
|
|
15043
|
+
peerId: request.from || 'unknown',
|
|
15044
|
+
service: mediaService.capability,
|
|
15045
|
+
capability: mediaService.capability,
|
|
15046
|
+
modality: mediaModality,
|
|
15047
|
+
model: String(safeArgs.model || mediaService.model || 'auto'),
|
|
15048
|
+
direction: 'inbound',
|
|
15049
|
+
inputBytes: mediaRawInput.length,
|
|
15050
|
+
outputBytes: artifactBytes.length,
|
|
15051
|
+
durationMs: Date.now() - mediaStart,
|
|
15052
|
+
success: true,
|
|
15053
|
+
}) + '\\n');
|
|
15054
|
+
} catch {}
|
|
15055
|
+
} catch (mediaErr) {
|
|
15056
|
+
var mediaErrMsg = mediaErr && mediaErr.message ? mediaErr.message : String(mediaErr);
|
|
15057
|
+
await mediaWrite({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: mediaSeq++, event: 'error', data: mediaErrMsg });
|
|
15058
|
+
await mediaWrite({ type: 'invoke.done', version: 1, requestId: request.requestId, usage: { inputBytes: mediaRawInput.length, outputBytes: 0 } });
|
|
15059
|
+
try {
|
|
15060
|
+
appendFileSync(meteringFile, JSON.stringify({
|
|
15061
|
+
timestamp: Date.now(),
|
|
15062
|
+
peerId: request.from || 'unknown',
|
|
15063
|
+
service: mediaService.capability,
|
|
15064
|
+
capability: mediaService.capability,
|
|
15065
|
+
modality: mediaModality,
|
|
15066
|
+
model: mediaService.model || 'auto',
|
|
15067
|
+
direction: 'inbound',
|
|
15068
|
+
inputBytes: mediaRawInput.length,
|
|
15069
|
+
outputBytes: 0,
|
|
15070
|
+
durationMs: Date.now() - mediaStart,
|
|
15071
|
+
success: false,
|
|
15072
|
+
reason: mediaErrMsg,
|
|
15073
|
+
}) + '\\n');
|
|
15074
|
+
} catch {}
|
|
15075
|
+
} finally {
|
|
15076
|
+
if (mediaAdmissionOpen) _sponsorMediaRelease(mediaModality);
|
|
15077
|
+
try { stream.close(); } catch {}
|
|
15078
|
+
}
|
|
15079
|
+
});
|
|
15080
|
+
}
|
|
15081
|
+
await _publishCapabilityRecord(mediaService.capability, {
|
|
15082
|
+
description: 'Omnius sponsored ' + mediaService.kind + ' generation',
|
|
15083
|
+
pricing: 'sponsored',
|
|
15084
|
+
rateLimit: String(mediaService.limits.jobsPerMinute || 'provider-policy') + '/min',
|
|
15085
|
+
service: mediaService,
|
|
15086
|
+
model: mediaService.model,
|
|
15087
|
+
modality: mediaService.kind,
|
|
15088
|
+
limits: mediaService.limits,
|
|
15089
|
+
});
|
|
15090
|
+
}
|
|
15091
|
+
dlog('expose: registered ' + mediaServices.length + ' media sponsor capabilities');
|
|
15092
|
+
} catch (mediaExposeErr) {
|
|
15093
|
+
dlog('expose: media capability registration failed: ' + (mediaExposeErr.message || mediaExposeErr));
|
|
15094
|
+
}
|
|
15095
|
+
}
|
|
15096
|
+
|
|
14765
15097
|
// Register system_metrics capability — returns CPU/GPU/memory utilization
|
|
14766
15098
|
if (typeof nexus.registerCapability === 'function') {
|
|
14767
15099
|
nexus.registerCapability('system_metrics', async (request, stream) => {
|
|
@@ -14892,7 +15224,7 @@ async function handleCmd(cmd) {
|
|
|
14892
15224
|
quantization: pm.quantization || '',
|
|
14893
15225
|
});
|
|
14894
15226
|
}
|
|
14895
|
-
var capsPayload = JSON.stringify({ capabilities: allCaps, models: modelsInfo, agentName: agentName, peerId: nexus.peerId });
|
|
15227
|
+
var capsPayload = JSON.stringify({ capabilities: allCaps, models: modelsInfo, services: mediaServices, mediaCapabilities: mediaServices, agentName: agentName, peerId: nexus.peerId });
|
|
14896
15228
|
await stream.write({ type: 'invoke.event', version: 1, requestId: request.requestId, seq: 0, event: 'result', data: capsPayload });
|
|
14897
15229
|
await stream.write({ type: 'invoke.done', version: 1, requestId: request.requestId, usage: { inputBytes: 0, outputBytes: capsPayload.length } });
|
|
14898
15230
|
stream.close();
|
|
@@ -14910,12 +15242,14 @@ async function handleCmd(cmd) {
|
|
|
14910
15242
|
quantization: pm.quantization || '',
|
|
14911
15243
|
};
|
|
14912
15244
|
}),
|
|
15245
|
+
services: mediaServices,
|
|
15246
|
+
mediaCapabilities: mediaServices,
|
|
14913
15247
|
});
|
|
14914
15248
|
}
|
|
14915
15249
|
|
|
14916
15250
|
// Write pricing menu to file
|
|
14917
15251
|
const pricingFile = join(nexusDir, 'pricing.json');
|
|
14918
|
-
writeFileSync(pricingFile, JSON.stringify({ updated: new Date().toISOString(), models: pricingMenu }, null, 2));
|
|
15252
|
+
writeFileSync(pricingFile, JSON.stringify({ updated: new Date().toISOString(), models: pricingMenu, services: mediaServices }, null, 2));
|
|
14919
15253
|
writeStatus({ exposedModels: pricingMenu.length });
|
|
14920
15254
|
|
|
14921
15255
|
const lines = ['Exposed ' + pricingMenu.length + ' model(s) as nexus capabilities:'];
|
|
@@ -14925,6 +15259,13 @@ async function handleCmd(cmd) {
|
|
|
14925
15259
|
: '$' + p.pricing.input_per_1m_tokens + '/$' + p.pricing.output_per_1m_tokens + ' per 1M tokens';
|
|
14926
15260
|
lines.push(' inference:' + p.model + ' — ' + cost);
|
|
14927
15261
|
}
|
|
15262
|
+
if (mediaServices.length > 0) {
|
|
15263
|
+
lines.push('');
|
|
15264
|
+
lines.push('Exposed ' + mediaServices.length + ' media generation service(s):');
|
|
15265
|
+
for (var msl = 0; msl < mediaServices.length; msl++) {
|
|
15266
|
+
lines.push(' ' + mediaServices[msl].capability + ' — sponsored ' + mediaServices[msl].kind);
|
|
15267
|
+
}
|
|
15268
|
+
}
|
|
14928
15269
|
lines.push('');
|
|
14929
15270
|
lines.push('Pricing menu saved to ' + pricingFile);
|
|
14930
15271
|
lines.push('Market rates: ' + Object.keys(marketRates).length + ' models from OpenRouter');
|
|
@@ -95984,7 +96325,7 @@ var require_auto = __commonJS({
|
|
|
95984
96325
|
// ../node_modules/acme-client/src/client.js
|
|
95985
96326
|
var require_client = __commonJS({
|
|
95986
96327
|
"../node_modules/acme-client/src/client.js"(exports, module) {
|
|
95987
|
-
var { createHash:
|
|
96328
|
+
var { createHash: createHash34 } = __require("crypto");
|
|
95988
96329
|
var { getPemBodyAsB64u } = require_crypto();
|
|
95989
96330
|
var { log: log22 } = require_logger();
|
|
95990
96331
|
var HttpClient = require_http();
|
|
@@ -96295,14 +96636,14 @@ var require_client = __commonJS({
|
|
|
96295
96636
|
*/
|
|
96296
96637
|
async getChallengeKeyAuthorization(challenge) {
|
|
96297
96638
|
const jwk = this.http.getJwk();
|
|
96298
|
-
const keysum =
|
|
96639
|
+
const keysum = createHash34("sha256").update(JSON.stringify(jwk));
|
|
96299
96640
|
const thumbprint = keysum.digest("base64url");
|
|
96300
96641
|
const result = `${challenge.token}.${thumbprint}`;
|
|
96301
96642
|
if (challenge.type === "http-01") {
|
|
96302
96643
|
return result;
|
|
96303
96644
|
}
|
|
96304
96645
|
if (challenge.type === "dns-01") {
|
|
96305
|
-
return
|
|
96646
|
+
return createHash34("sha256").update(result).digest("base64url");
|
|
96306
96647
|
}
|
|
96307
96648
|
if (challenge.type === "tls-alpn-01") {
|
|
96308
96649
|
return result;
|
|
@@ -132214,7 +132555,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
132214
132555
|
"../node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
132215
132556
|
"use strict";
|
|
132216
132557
|
var { writeFile: writeFile24, readFile: readFile23, mkdir: mkdir20 } = __require("node:fs/promises");
|
|
132217
|
-
var { dirname:
|
|
132558
|
+
var { dirname: dirname44, resolve: resolve56 } = __require("node:path");
|
|
132218
132559
|
var { setTimeout: setTimeout3, clearTimeout: clearTimeout3 } = __require("node:timers");
|
|
132219
132560
|
var { InvalidArgumentError, UndiciError } = require_errors2();
|
|
132220
132561
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -132445,7 +132786,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
132445
132786
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
132446
132787
|
}
|
|
132447
132788
|
const resolvedPath = resolve56(path12);
|
|
132448
|
-
await mkdir20(
|
|
132789
|
+
await mkdir20(dirname44(resolvedPath), { recursive: true });
|
|
132449
132790
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
132450
132791
|
hash,
|
|
132451
132792
|
snapshot
|
|
@@ -238982,7 +239323,7 @@ var require_websocket2 = __commonJS({
|
|
|
238982
239323
|
var http6 = __require("http");
|
|
238983
239324
|
var net5 = __require("net");
|
|
238984
239325
|
var tls2 = __require("tls");
|
|
238985
|
-
var { randomBytes: randomBytes29, createHash:
|
|
239326
|
+
var { randomBytes: randomBytes29, createHash: createHash34 } = __require("crypto");
|
|
238986
239327
|
var { Duplex: Duplex3, Readable } = __require("stream");
|
|
238987
239328
|
var { URL: URL3 } = __require("url");
|
|
238988
239329
|
var PerMessageDeflate3 = require_permessage_deflate2();
|
|
@@ -239642,7 +239983,7 @@ var require_websocket2 = __commonJS({
|
|
|
239642
239983
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
239643
239984
|
return;
|
|
239644
239985
|
}
|
|
239645
|
-
const digest3 =
|
|
239986
|
+
const digest3 = createHash34("sha1").update(key + GUID).digest("base64");
|
|
239646
239987
|
if (res.headers["sec-websocket-accept"] !== digest3) {
|
|
239647
239988
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
239648
239989
|
return;
|
|
@@ -240009,7 +240350,7 @@ var require_websocket_server = __commonJS({
|
|
|
240009
240350
|
var EventEmitter15 = __require("events");
|
|
240010
240351
|
var http6 = __require("http");
|
|
240011
240352
|
var { Duplex: Duplex3 } = __require("stream");
|
|
240012
|
-
var { createHash:
|
|
240353
|
+
var { createHash: createHash34 } = __require("crypto");
|
|
240013
240354
|
var extension3 = require_extension2();
|
|
240014
240355
|
var PerMessageDeflate3 = require_permessage_deflate2();
|
|
240015
240356
|
var subprotocol3 = require_subprotocol();
|
|
@@ -240310,7 +240651,7 @@ var require_websocket_server = __commonJS({
|
|
|
240310
240651
|
);
|
|
240311
240652
|
}
|
|
240312
240653
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
240313
|
-
const digest3 =
|
|
240654
|
+
const digest3 = createHash34("sha1").update(key + GUID).digest("base64");
|
|
240314
240655
|
const headers = [
|
|
240315
240656
|
"HTTP/1.1 101 Switching Protocols",
|
|
240316
240657
|
"Upgrade: websocket",
|
|
@@ -246107,15 +246448,15 @@ var init_ls = __esm({
|
|
|
246107
246448
|
});
|
|
246108
246449
|
|
|
246109
246450
|
// ../node_modules/@helia/unixfs/dist/src/commands/mkdir.js
|
|
246110
|
-
async function mkdir6(parentCid,
|
|
246111
|
-
if (
|
|
246451
|
+
async function mkdir6(parentCid, dirname44, blockstore, options2 = {}) {
|
|
246452
|
+
if (dirname44.includes("/")) {
|
|
246112
246453
|
throw new InvalidParametersError4("Path must not have slashes");
|
|
246113
246454
|
}
|
|
246114
246455
|
const entry = await exporter2(parentCid, blockstore, options2);
|
|
246115
246456
|
if (entry.type !== "directory") {
|
|
246116
246457
|
throw new NotADirectoryError(`${parentCid.toString()} was not a UnixFS directory`);
|
|
246117
246458
|
}
|
|
246118
|
-
log16("creating %s",
|
|
246459
|
+
log16("creating %s", dirname44);
|
|
246119
246460
|
const metadata = new UnixFS({
|
|
246120
246461
|
type: "directory",
|
|
246121
246462
|
mode: options2.mode,
|
|
@@ -246131,9 +246472,9 @@ async function mkdir6(parentCid, dirname43, blockstore, options2 = {}) {
|
|
|
246131
246472
|
await blockstore.put(emptyDirCid, buf);
|
|
246132
246473
|
const [directory, pblink] = await Promise.all([
|
|
246133
246474
|
cidToDirectory(parentCid, blockstore, options2),
|
|
246134
|
-
cidToPBLink(emptyDirCid,
|
|
246475
|
+
cidToPBLink(emptyDirCid, dirname44, blockstore, options2)
|
|
246135
246476
|
]);
|
|
246136
|
-
log16("adding empty dir called %s to %c",
|
|
246477
|
+
log16("adding empty dir called %s to %c", dirname44, parentCid);
|
|
246137
246478
|
const result = await addLink(directory, pblink, blockstore, {
|
|
246138
246479
|
...options2,
|
|
246139
246480
|
allowOverwriting: options2.force
|
|
@@ -246632,8 +246973,8 @@ var init_unixfs2 = __esm({
|
|
|
246632
246973
|
async *ls(cid, options2 = {}) {
|
|
246633
246974
|
yield* ls(cid, this.components.blockstore, options2);
|
|
246634
246975
|
}
|
|
246635
|
-
async mkdir(cid,
|
|
246636
|
-
return mkdir6(cid,
|
|
246976
|
+
async mkdir(cid, dirname44, options2 = {}) {
|
|
246977
|
+
return mkdir6(cid, dirname44, this.components.blockstore, options2);
|
|
246637
246978
|
}
|
|
246638
246979
|
async rm(cid, path12, options2 = {}) {
|
|
246639
246980
|
return rm3(cid, path12, this.components.blockstore, options2);
|
|
@@ -250030,8 +250371,8 @@ var require_pattern = __commonJS({
|
|
|
250030
250371
|
}
|
|
250031
250372
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
250032
250373
|
function isAffectDepthOfReadingPattern(pattern) {
|
|
250033
|
-
const
|
|
250034
|
-
return endsWithSlashGlobStar(pattern) || isStaticPattern(
|
|
250374
|
+
const basename35 = path12.basename(pattern);
|
|
250375
|
+
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename35);
|
|
250035
250376
|
}
|
|
250036
250377
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
250037
250378
|
function expandPatternsWithBraceExpansion(patterns) {
|
|
@@ -253117,13 +253458,13 @@ Justification: ${justification || "(none provided)"}`,
|
|
|
253117
253458
|
}
|
|
253118
253459
|
const snapshot = JSON.stringify(this.selfState, null, 2);
|
|
253119
253460
|
try {
|
|
253120
|
-
const { createHash:
|
|
253461
|
+
const { createHash: createHash34 } = await import("node:crypto");
|
|
253121
253462
|
const snapshotDir = join32(this.cwd, ".omnius", "identity", "snapshots");
|
|
253122
253463
|
await mkdir7(snapshotDir, { recursive: true });
|
|
253123
253464
|
const version4 = this.selfState.version;
|
|
253124
253465
|
const snapshotPath = join32(snapshotDir, `v${version4}.json`);
|
|
253125
253466
|
await writeFile12(snapshotPath, snapshot, "utf8");
|
|
253126
|
-
const hash =
|
|
253467
|
+
const hash = createHash34("sha256").update(snapshot).digest("hex");
|
|
253127
253468
|
await writeFile12(join32(this.cwd, ".omnius", "identity", "latest-hash.txt"), hash, "utf8");
|
|
253128
253469
|
let ipfsCid = "";
|
|
253129
253470
|
try {
|
|
@@ -253256,8 +253597,8 @@ New: ${newNarrative.slice(0, 200)}...`,
|
|
|
253256
253597
|
}
|
|
253257
253598
|
// ── Helpers ──────────────────────────────────────────────────────────────
|
|
253258
253599
|
createDefaultState() {
|
|
253259
|
-
const { createHash:
|
|
253260
|
-
const machineId =
|
|
253600
|
+
const { createHash: createHash34 } = __require("node:crypto");
|
|
253601
|
+
const machineId = createHash34("sha256").update(this.cwd).digest("hex").slice(0, 12);
|
|
253261
253602
|
return {
|
|
253262
253603
|
self_id: `omnius-${machineId}`,
|
|
253263
253604
|
version: 1,
|
|
@@ -253339,9 +253680,9 @@ New: ${newNarrative.slice(0, 200)}...`,
|
|
|
253339
253680
|
let cid;
|
|
253340
253681
|
if (this.selfState.version > prevVersion) {
|
|
253341
253682
|
try {
|
|
253342
|
-
const { createHash:
|
|
253683
|
+
const { createHash: createHash34 } = await import("node:crypto");
|
|
253343
253684
|
const stateJson = JSON.stringify(this.selfState);
|
|
253344
|
-
const hash =
|
|
253685
|
+
const hash = createHash34("sha256").update(stateJson).digest("hex").slice(0, 32);
|
|
253345
253686
|
const cidsPath = join32(this.cwd, ".omnius", "identity", "cids.json");
|
|
253346
253687
|
const cidsData = { latest: "", hash, version: this.selfState.version };
|
|
253347
253688
|
try {
|
|
@@ -262581,6 +262922,436 @@ ${llmAnnotation}` : result.llmContent;
|
|
|
262581
262922
|
}
|
|
262582
262923
|
});
|
|
262583
262924
|
|
|
262925
|
+
// packages/execution/dist/tools/sponsor-media.js
|
|
262926
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
262927
|
+
function normalizeSponsorMediaConfig(value2) {
|
|
262928
|
+
const input = typeof value2 === "object" && value2 !== null ? value2 : {};
|
|
262929
|
+
const config = structuredClone(DEFAULT_SPONSOR_MEDIA_LIMITS);
|
|
262930
|
+
for (const modality of SPONSOR_MEDIA_MODALITIES) {
|
|
262931
|
+
const raw = input[modality];
|
|
262932
|
+
if (!raw || typeof raw !== "object")
|
|
262933
|
+
continue;
|
|
262934
|
+
const src2 = raw;
|
|
262935
|
+
const dst = config[modality];
|
|
262936
|
+
dst.enabled = booleanValue(src2["enabled"], dst.enabled);
|
|
262937
|
+
dst.allowedModels = normalizeAllowedModels(src2["allowedModels"] ?? src2["allowed_models"], dst.allowedModels);
|
|
262938
|
+
dst.maxConcurrent = positiveInt(src2["maxConcurrent"] ?? src2["max_concurrent"], dst.maxConcurrent);
|
|
262939
|
+
dst.jobsPerMinute = positiveInt(src2["jobsPerMinute"] ?? src2["jobs_per_minute"], dst.jobsPerMinute);
|
|
262940
|
+
dst.jobsPerDay = positiveInt(src2["jobsPerDay"] ?? src2["jobs_per_day"], dst.jobsPerDay);
|
|
262941
|
+
dst.maxOutputBytes = positiveInt(src2["maxOutputBytes"] ?? src2["max_output_bytes"], dst.maxOutputBytes);
|
|
262942
|
+
dst.maxWidth = optionalPositiveInt(src2["maxWidth"] ?? src2["max_width"], dst.maxWidth);
|
|
262943
|
+
dst.maxHeight = optionalPositiveInt(src2["maxHeight"] ?? src2["max_height"], dst.maxHeight);
|
|
262944
|
+
dst.maxMegapixels = optionalPositiveNumber(src2["maxMegapixels"] ?? src2["max_megapixels"], dst.maxMegapixels);
|
|
262945
|
+
dst.maxDurationSec = optionalPositiveNumber(src2["maxDurationSec"] ?? src2["max_duration_sec"], dst.maxDurationSec);
|
|
262946
|
+
dst.maxFrames = optionalPositiveInt(src2["maxFrames"] ?? src2["max_frames"], dst.maxFrames);
|
|
262947
|
+
dst.maxFps = optionalPositiveInt(src2["maxFps"] ?? src2["max_fps"], dst.maxFps);
|
|
262948
|
+
dst.maxSteps = optionalPositiveInt(src2["maxSteps"] ?? src2["max_steps"], dst.maxSteps);
|
|
262949
|
+
}
|
|
262950
|
+
return config;
|
|
262951
|
+
}
|
|
262952
|
+
function sponsorMediaCapabilityName(modality, model = "auto") {
|
|
262953
|
+
return `${SPONSOR_MEDIA_CAPABILITY_PREFIX}${modality}:${slugCapabilityPart(model || "auto")}`;
|
|
262954
|
+
}
|
|
262955
|
+
function parseSponsorMediaCapability(capability) {
|
|
262956
|
+
const parts = capability.split(":");
|
|
262957
|
+
if (parts.length < 3 || parts[0] !== "media")
|
|
262958
|
+
return null;
|
|
262959
|
+
const modality = parts[1];
|
|
262960
|
+
if (!SPONSOR_MEDIA_MODALITIES.includes(modality))
|
|
262961
|
+
return null;
|
|
262962
|
+
return { modality, modelSlug: parts.slice(2).join(":") || "auto" };
|
|
262963
|
+
}
|
|
262964
|
+
function buildSponsorMediaServices(configLike) {
|
|
262965
|
+
const config = normalizeSponsorMediaConfig(configLike);
|
|
262966
|
+
const services = [];
|
|
262967
|
+
for (const modality of SPONSOR_MEDIA_MODALITIES) {
|
|
262968
|
+
const limits = config[modality];
|
|
262969
|
+
if (!limits.enabled)
|
|
262970
|
+
continue;
|
|
262971
|
+
const models = limits.allowedModels === "all" || limits.allowedModels.length === 0 ? ["auto"] : limits.allowedModels;
|
|
262972
|
+
for (const model of models) {
|
|
262973
|
+
services.push({
|
|
262974
|
+
kind: modality,
|
|
262975
|
+
capability: sponsorMediaCapabilityName(modality, model),
|
|
262976
|
+
model,
|
|
262977
|
+
input: mediaInputsFor(modality),
|
|
262978
|
+
output: mediaOutputsFor(modality),
|
|
262979
|
+
limits: serializeMediaLimits(limits)
|
|
262980
|
+
});
|
|
262981
|
+
}
|
|
262982
|
+
}
|
|
262983
|
+
return services;
|
|
262984
|
+
}
|
|
262985
|
+
function sanitizeRemoteMediaGenerateRequest(input, service, configLike) {
|
|
262986
|
+
const parsed = parseRemoteMediaRequest(input, service.kind);
|
|
262987
|
+
if (!parsed.ok)
|
|
262988
|
+
return parsed;
|
|
262989
|
+
const req2 = parsed.value;
|
|
262990
|
+
const config = normalizeSponsorMediaConfig(configLike);
|
|
262991
|
+
const modality = req2.modality;
|
|
262992
|
+
const limits = config[modality];
|
|
262993
|
+
if (!limits.enabled)
|
|
262994
|
+
return { ok: false, reason: `${modality} sponsorship is disabled` };
|
|
262995
|
+
if (service.kind !== modality)
|
|
262996
|
+
return { ok: false, reason: `Capability ${service.capability} cannot serve ${modality}` };
|
|
262997
|
+
const options2 = req2.options && typeof req2.options === "object" ? { ...req2.options } : {};
|
|
262998
|
+
for (const key of Object.keys(options2)) {
|
|
262999
|
+
if (REMOTE_UNSAFE_KEYS.has(key)) {
|
|
263000
|
+
return { ok: false, reason: `Remote media option '${key}' is not allowed` };
|
|
263001
|
+
}
|
|
263002
|
+
}
|
|
263003
|
+
for (const key of LOCAL_PATH_INPUT_KEYS) {
|
|
263004
|
+
const value2 = options2[key];
|
|
263005
|
+
if (value2 === void 0)
|
|
263006
|
+
continue;
|
|
263007
|
+
if (typeof value2 !== "string")
|
|
263008
|
+
return { ok: false, reason: `${key} must be a URL or uploaded artifact reference` };
|
|
263009
|
+
if (!isSafeRemoteInputRef(value2)) {
|
|
263010
|
+
return { ok: false, reason: `${key} cannot reference provider-local paths` };
|
|
263011
|
+
}
|
|
263012
|
+
}
|
|
263013
|
+
if (Array.isArray(req2.inputs) && req2.inputs.length > 0) {
|
|
263014
|
+
for (const remoteInput of req2.inputs) {
|
|
263015
|
+
if (!remoteInput || typeof remoteInput !== "object")
|
|
263016
|
+
return { ok: false, reason: "Invalid remote media input" };
|
|
263017
|
+
if (!remoteInput.dataBase64 && !remoteInput.url)
|
|
263018
|
+
return { ok: false, reason: "Remote media inputs require dataBase64 or url" };
|
|
263019
|
+
if (remoteInput.url && !isSafeRemoteInputRef(remoteInput.url))
|
|
263020
|
+
return { ok: false, reason: "Remote media input URL is not allowed" };
|
|
263021
|
+
}
|
|
263022
|
+
}
|
|
263023
|
+
const requestedModel = req2.model || (typeof options2["model"] === "string" ? String(options2["model"]) : "");
|
|
263024
|
+
const serviceModel = service.model && service.model !== "auto" ? service.model : "";
|
|
263025
|
+
const model = serviceModel || requestedModel;
|
|
263026
|
+
if (serviceModel && requestedModel && requestedModel !== serviceModel) {
|
|
263027
|
+
return { ok: false, reason: `Capability ${service.capability} only serves model ${serviceModel}` };
|
|
263028
|
+
}
|
|
263029
|
+
if (model && limits.allowedModels !== "all" && !limits.allowedModels.includes(model)) {
|
|
263030
|
+
return { ok: false, reason: `Model not allowed for ${modality}: ${model}` };
|
|
263031
|
+
}
|
|
263032
|
+
const args = {
|
|
263033
|
+
...options2,
|
|
263034
|
+
prompt: req2.prompt,
|
|
263035
|
+
action: "generate",
|
|
263036
|
+
playback: false
|
|
263037
|
+
};
|
|
263038
|
+
if (model)
|
|
263039
|
+
args["model"] = model;
|
|
263040
|
+
if (req2.backend)
|
|
263041
|
+
args["backend"] = req2.backend;
|
|
263042
|
+
if (modality === "sound" || modality === "music")
|
|
263043
|
+
args["kind"] = modality;
|
|
263044
|
+
args["fallback"] = options2["fallback"] === false ? false : true;
|
|
263045
|
+
const estimatedUnits = {
|
|
263046
|
+
inputChars: req2.prompt.length
|
|
263047
|
+
};
|
|
263048
|
+
if (modality === "image") {
|
|
263049
|
+
clampNumberArg(args, "width", limits.maxWidth);
|
|
263050
|
+
clampNumberArg(args, "height", limits.maxHeight);
|
|
263051
|
+
clampNumberArg(args, "steps", limits.maxSteps);
|
|
263052
|
+
const width = numberFrom(args["width"]);
|
|
263053
|
+
const height = numberFrom(args["height"]);
|
|
263054
|
+
if (width && height && limits.maxMegapixels && width * height / 1e6 > limits.maxMegapixels) {
|
|
263055
|
+
return { ok: false, reason: `Image exceeds ${limits.maxMegapixels} megapixels` };
|
|
263056
|
+
}
|
|
263057
|
+
if (width)
|
|
263058
|
+
estimatedUnits.width = width;
|
|
263059
|
+
if (height)
|
|
263060
|
+
estimatedUnits.height = height;
|
|
263061
|
+
const steps = numberFrom(args["steps"]);
|
|
263062
|
+
if (steps)
|
|
263063
|
+
estimatedUnits.steps = steps;
|
|
263064
|
+
} else if (modality === "video") {
|
|
263065
|
+
clampNumberArg(args, "width", limits.maxWidth);
|
|
263066
|
+
clampNumberArg(args, "height", limits.maxHeight);
|
|
263067
|
+
clampNumberArg(args, "duration_seconds", limits.maxDurationSec);
|
|
263068
|
+
clampNumberArg(args, "num_frames", limits.maxFrames);
|
|
263069
|
+
clampNumberArg(args, "fps", limits.maxFps);
|
|
263070
|
+
clampNumberArg(args, "steps", limits.maxSteps);
|
|
263071
|
+
const width = numberFrom(args["width"]);
|
|
263072
|
+
const height = numberFrom(args["height"]);
|
|
263073
|
+
if (width)
|
|
263074
|
+
estimatedUnits.width = width;
|
|
263075
|
+
if (height)
|
|
263076
|
+
estimatedUnits.height = height;
|
|
263077
|
+
const durationSec = numberFrom(args["duration_seconds"]);
|
|
263078
|
+
if (durationSec)
|
|
263079
|
+
estimatedUnits.durationSec = durationSec;
|
|
263080
|
+
const frames = numberFrom(args["num_frames"]);
|
|
263081
|
+
if (frames)
|
|
263082
|
+
estimatedUnits.frames = frames;
|
|
263083
|
+
const fps = numberFrom(args["fps"]);
|
|
263084
|
+
if (fps)
|
|
263085
|
+
estimatedUnits.fps = fps;
|
|
263086
|
+
const steps = numberFrom(args["steps"]);
|
|
263087
|
+
if (steps)
|
|
263088
|
+
estimatedUnits.steps = steps;
|
|
263089
|
+
} else {
|
|
263090
|
+
clampNumberArg(args, "duration", limits.maxDurationSec);
|
|
263091
|
+
clampNumberArg(args, "steps", limits.maxSteps);
|
|
263092
|
+
const durationSec = numberFrom(args["duration"]);
|
|
263093
|
+
if (durationSec)
|
|
263094
|
+
estimatedUnits.durationSec = durationSec;
|
|
263095
|
+
const steps = numberFrom(args["steps"]);
|
|
263096
|
+
if (steps)
|
|
263097
|
+
estimatedUnits.steps = steps;
|
|
263098
|
+
}
|
|
263099
|
+
return { ok: true, value: { args, estimatedUnits } };
|
|
263100
|
+
}
|
|
263101
|
+
function artifactManifestFromBytes(args) {
|
|
263102
|
+
const hash = createHash6("sha256").update(args.bytes).digest("hex");
|
|
263103
|
+
return {
|
|
263104
|
+
artifactId: args.artifactId,
|
|
263105
|
+
filename: args.filename,
|
|
263106
|
+
mime: args.mime,
|
|
263107
|
+
sizeBytes: args.bytes.byteLength,
|
|
263108
|
+
sha256: hash
|
|
263109
|
+
};
|
|
263110
|
+
}
|
|
263111
|
+
function mediaMimeFromPath(path12, modality) {
|
|
263112
|
+
const lc = path12.toLowerCase();
|
|
263113
|
+
if (lc.endsWith(".png"))
|
|
263114
|
+
return "image/png";
|
|
263115
|
+
if (lc.endsWith(".jpg") || lc.endsWith(".jpeg"))
|
|
263116
|
+
return "image/jpeg";
|
|
263117
|
+
if (lc.endsWith(".webp"))
|
|
263118
|
+
return "image/webp";
|
|
263119
|
+
if (lc.endsWith(".mp4"))
|
|
263120
|
+
return "video/mp4";
|
|
263121
|
+
if (lc.endsWith(".webm"))
|
|
263122
|
+
return "video/webm";
|
|
263123
|
+
if (lc.endsWith(".wav"))
|
|
263124
|
+
return "audio/wav";
|
|
263125
|
+
if (lc.endsWith(".mp3"))
|
|
263126
|
+
return "audio/mpeg";
|
|
263127
|
+
if (modality === "image")
|
|
263128
|
+
return "image/png";
|
|
263129
|
+
if (modality === "video")
|
|
263130
|
+
return "video/mp4";
|
|
263131
|
+
return "audio/wav";
|
|
263132
|
+
}
|
|
263133
|
+
function defaultExtensionForMime(mime) {
|
|
263134
|
+
if (mime === "image/png")
|
|
263135
|
+
return ".png";
|
|
263136
|
+
if (mime === "image/jpeg")
|
|
263137
|
+
return ".jpg";
|
|
263138
|
+
if (mime === "image/webp")
|
|
263139
|
+
return ".webp";
|
|
263140
|
+
if (mime === "video/mp4")
|
|
263141
|
+
return ".mp4";
|
|
263142
|
+
if (mime === "video/webm")
|
|
263143
|
+
return ".webm";
|
|
263144
|
+
if (mime === "audio/mpeg")
|
|
263145
|
+
return ".mp3";
|
|
263146
|
+
if (mime === "audio/wav" || mime === "audio/x-wav")
|
|
263147
|
+
return ".wav";
|
|
263148
|
+
return ".bin";
|
|
263149
|
+
}
|
|
263150
|
+
function parseRemoteMediaRequest(input, fallbackModality) {
|
|
263151
|
+
let raw = input;
|
|
263152
|
+
if (typeof raw === "string") {
|
|
263153
|
+
try {
|
|
263154
|
+
raw = JSON.parse(raw);
|
|
263155
|
+
} catch {
|
|
263156
|
+
raw = { prompt: raw };
|
|
263157
|
+
}
|
|
263158
|
+
}
|
|
263159
|
+
if (!raw || typeof raw !== "object")
|
|
263160
|
+
return { ok: false, reason: "Remote media request must be an object" };
|
|
263161
|
+
const obj = raw;
|
|
263162
|
+
const prompt = String(obj["prompt"] ?? "").trim();
|
|
263163
|
+
if (!prompt)
|
|
263164
|
+
return { ok: false, reason: "Remote media prompt is required" };
|
|
263165
|
+
const modality = String(obj["modality"] ?? fallbackModality);
|
|
263166
|
+
if (!SPONSOR_MEDIA_MODALITIES.includes(modality))
|
|
263167
|
+
return { ok: false, reason: `Unsupported media modality: ${String(obj["modality"])}` };
|
|
263168
|
+
return {
|
|
263169
|
+
ok: true,
|
|
263170
|
+
value: {
|
|
263171
|
+
modality,
|
|
263172
|
+
prompt,
|
|
263173
|
+
model: typeof obj["model"] === "string" && obj["model"].trim() ? obj["model"].trim() : void 0,
|
|
263174
|
+
backend: typeof obj["backend"] === "string" && obj["backend"].trim() ? obj["backend"].trim() : void 0,
|
|
263175
|
+
options: obj["options"] && typeof obj["options"] === "object" ? obj["options"] : void 0,
|
|
263176
|
+
inputs: Array.isArray(obj["inputs"]) ? obj["inputs"] : void 0,
|
|
263177
|
+
auth_key: typeof obj["auth_key"] === "string" ? obj["auth_key"] : void 0
|
|
263178
|
+
}
|
|
263179
|
+
};
|
|
263180
|
+
}
|
|
263181
|
+
function serializeMediaLimits(limits) {
|
|
263182
|
+
return {
|
|
263183
|
+
enabled: limits.enabled,
|
|
263184
|
+
allowedModels: limits.allowedModels,
|
|
263185
|
+
maxConcurrent: limits.maxConcurrent,
|
|
263186
|
+
jobsPerMinute: limits.jobsPerMinute,
|
|
263187
|
+
jobsPerDay: limits.jobsPerDay,
|
|
263188
|
+
maxOutputBytes: limits.maxOutputBytes,
|
|
263189
|
+
...limits.maxWidth !== void 0 ? { maxWidth: limits.maxWidth } : {},
|
|
263190
|
+
...limits.maxHeight !== void 0 ? { maxHeight: limits.maxHeight } : {},
|
|
263191
|
+
...limits.maxMegapixels !== void 0 ? { maxMegapixels: limits.maxMegapixels } : {},
|
|
263192
|
+
...limits.maxDurationSec !== void 0 ? { maxDurationSec: limits.maxDurationSec } : {},
|
|
263193
|
+
...limits.maxFrames !== void 0 ? { maxFrames: limits.maxFrames } : {},
|
|
263194
|
+
...limits.maxFps !== void 0 ? { maxFps: limits.maxFps } : {},
|
|
263195
|
+
...limits.maxSteps !== void 0 ? { maxSteps: limits.maxSteps } : {}
|
|
263196
|
+
};
|
|
263197
|
+
}
|
|
263198
|
+
function mediaInputsFor(modality) {
|
|
263199
|
+
if (modality === "image")
|
|
263200
|
+
return ["prompt"];
|
|
263201
|
+
if (modality === "video")
|
|
263202
|
+
return ["prompt", "image", "audio_input"];
|
|
263203
|
+
return ["prompt"];
|
|
263204
|
+
}
|
|
263205
|
+
function mediaOutputsFor(modality) {
|
|
263206
|
+
if (modality === "image")
|
|
263207
|
+
return ["image/png", "image/jpeg", "image/webp"];
|
|
263208
|
+
if (modality === "video")
|
|
263209
|
+
return ["video/mp4"];
|
|
263210
|
+
return ["audio/wav", "audio/mpeg"];
|
|
263211
|
+
}
|
|
263212
|
+
function slugCapabilityPart(value2) {
|
|
263213
|
+
const slug = value2.trim().replace(/[^a-zA-Z0-9._-]/g, "_").replace(/^_+|_+$/g, "");
|
|
263214
|
+
return slug || "auto";
|
|
263215
|
+
}
|
|
263216
|
+
function booleanValue(value2, fallback) {
|
|
263217
|
+
if (typeof value2 === "boolean")
|
|
263218
|
+
return value2;
|
|
263219
|
+
if (typeof value2 === "string")
|
|
263220
|
+
return /^(1|true|yes|on)$/i.test(value2.trim());
|
|
263221
|
+
return fallback;
|
|
263222
|
+
}
|
|
263223
|
+
function positiveInt(value2, fallback) {
|
|
263224
|
+
const n2 = Number(value2);
|
|
263225
|
+
return Number.isFinite(n2) && n2 > 0 ? Math.floor(n2) : fallback;
|
|
263226
|
+
}
|
|
263227
|
+
function optionalPositiveInt(value2, fallback) {
|
|
263228
|
+
if (value2 === void 0 || value2 === null || value2 === "")
|
|
263229
|
+
return fallback;
|
|
263230
|
+
const n2 = Number(value2);
|
|
263231
|
+
return Number.isFinite(n2) && n2 > 0 ? Math.floor(n2) : fallback;
|
|
263232
|
+
}
|
|
263233
|
+
function optionalPositiveNumber(value2, fallback) {
|
|
263234
|
+
if (value2 === void 0 || value2 === null || value2 === "")
|
|
263235
|
+
return fallback;
|
|
263236
|
+
const n2 = Number(value2);
|
|
263237
|
+
return Number.isFinite(n2) && n2 > 0 ? n2 : fallback;
|
|
263238
|
+
}
|
|
263239
|
+
function normalizeAllowedModels(value2, fallback) {
|
|
263240
|
+
if (value2 === "all")
|
|
263241
|
+
return "all";
|
|
263242
|
+
if (Array.isArray(value2)) {
|
|
263243
|
+
const models = value2.map((item) => String(item).trim()).filter(Boolean);
|
|
263244
|
+
return models.length > 0 ? [...new Set(models)] : fallback;
|
|
263245
|
+
}
|
|
263246
|
+
if (typeof value2 === "string" && value2.trim()) {
|
|
263247
|
+
const raw = value2.trim();
|
|
263248
|
+
if (raw === "all")
|
|
263249
|
+
return "all";
|
|
263250
|
+
const models = raw.split(",").map((item) => item.trim()).filter(Boolean);
|
|
263251
|
+
return models.length > 0 ? [...new Set(models)] : fallback;
|
|
263252
|
+
}
|
|
263253
|
+
return fallback;
|
|
263254
|
+
}
|
|
263255
|
+
function clampNumberArg(args, key, max) {
|
|
263256
|
+
if (max === void 0)
|
|
263257
|
+
return;
|
|
263258
|
+
const value2 = numberFrom(args[key]);
|
|
263259
|
+
if (value2 === void 0)
|
|
263260
|
+
return;
|
|
263261
|
+
args[key] = Math.min(value2, max);
|
|
263262
|
+
}
|
|
263263
|
+
function numberFrom(value2) {
|
|
263264
|
+
const n2 = Number(value2);
|
|
263265
|
+
return Number.isFinite(n2) && n2 > 0 ? n2 : void 0;
|
|
263266
|
+
}
|
|
263267
|
+
function isSafeRemoteInputRef(value2) {
|
|
263268
|
+
const raw = value2.trim();
|
|
263269
|
+
if (!raw)
|
|
263270
|
+
return false;
|
|
263271
|
+
if (/^https?:\/\//i.test(raw))
|
|
263272
|
+
return true;
|
|
263273
|
+
if (/^data:[a-z0-9.+/-]+;base64,/i.test(raw))
|
|
263274
|
+
return true;
|
|
263275
|
+
if (/^artifact:[a-zA-Z0-9._:-]+$/.test(raw))
|
|
263276
|
+
return true;
|
|
263277
|
+
return false;
|
|
263278
|
+
}
|
|
263279
|
+
var SPONSOR_MEDIA_MODALITIES, SPONSOR_MEDIA_CAPABILITY_PREFIX, DEFAULT_SPONSOR_MEDIA_LIMITS, REMOTE_UNSAFE_KEYS, LOCAL_PATH_INPUT_KEYS;
|
|
263280
|
+
var init_sponsor_media = __esm({
|
|
263281
|
+
"packages/execution/dist/tools/sponsor-media.js"() {
|
|
263282
|
+
"use strict";
|
|
263283
|
+
SPONSOR_MEDIA_MODALITIES = ["image", "video", "sound", "music"];
|
|
263284
|
+
SPONSOR_MEDIA_CAPABILITY_PREFIX = "media:";
|
|
263285
|
+
DEFAULT_SPONSOR_MEDIA_LIMITS = {
|
|
263286
|
+
image: {
|
|
263287
|
+
enabled: false,
|
|
263288
|
+
allowedModels: "all",
|
|
263289
|
+
maxConcurrent: 1,
|
|
263290
|
+
jobsPerMinute: 6,
|
|
263291
|
+
jobsPerDay: 60,
|
|
263292
|
+
maxOutputBytes: 25 * 1024 * 1024,
|
|
263293
|
+
maxWidth: 1024,
|
|
263294
|
+
maxHeight: 1024,
|
|
263295
|
+
maxMegapixels: 1.25,
|
|
263296
|
+
maxSteps: 40
|
|
263297
|
+
},
|
|
263298
|
+
video: {
|
|
263299
|
+
enabled: false,
|
|
263300
|
+
allowedModels: "all",
|
|
263301
|
+
maxConcurrent: 1,
|
|
263302
|
+
jobsPerMinute: 2,
|
|
263303
|
+
jobsPerDay: 12,
|
|
263304
|
+
maxOutputBytes: 250 * 1024 * 1024,
|
|
263305
|
+
maxWidth: 1280,
|
|
263306
|
+
maxHeight: 720,
|
|
263307
|
+
maxDurationSec: 8,
|
|
263308
|
+
maxFrames: 129,
|
|
263309
|
+
maxFps: 24,
|
|
263310
|
+
maxSteps: 50
|
|
263311
|
+
},
|
|
263312
|
+
sound: {
|
|
263313
|
+
enabled: false,
|
|
263314
|
+
allowedModels: "all",
|
|
263315
|
+
maxConcurrent: 1,
|
|
263316
|
+
jobsPerMinute: 4,
|
|
263317
|
+
jobsPerDay: 40,
|
|
263318
|
+
maxOutputBytes: 50 * 1024 * 1024,
|
|
263319
|
+
maxDurationSec: 15,
|
|
263320
|
+
maxSteps: 50
|
|
263321
|
+
},
|
|
263322
|
+
music: {
|
|
263323
|
+
enabled: false,
|
|
263324
|
+
allowedModels: "all",
|
|
263325
|
+
maxConcurrent: 1,
|
|
263326
|
+
jobsPerMinute: 2,
|
|
263327
|
+
jobsPerDay: 20,
|
|
263328
|
+
maxOutputBytes: 80 * 1024 * 1024,
|
|
263329
|
+
maxDurationSec: 30,
|
|
263330
|
+
maxSteps: 80
|
|
263331
|
+
}
|
|
263332
|
+
};
|
|
263333
|
+
REMOTE_UNSAFE_KEYS = /* @__PURE__ */ new Set([
|
|
263334
|
+
"action",
|
|
263335
|
+
"setup",
|
|
263336
|
+
"prewarm",
|
|
263337
|
+
"prepare",
|
|
263338
|
+
"pull",
|
|
263339
|
+
"python",
|
|
263340
|
+
"hf_token",
|
|
263341
|
+
"model_path",
|
|
263342
|
+
"playback"
|
|
263343
|
+
]);
|
|
263344
|
+
LOCAL_PATH_INPUT_KEYS = /* @__PURE__ */ new Set([
|
|
263345
|
+
"image",
|
|
263346
|
+
"image_path",
|
|
263347
|
+
"init_image",
|
|
263348
|
+
"source_image",
|
|
263349
|
+
"reference_image",
|
|
263350
|
+
"audio_input"
|
|
263351
|
+
]);
|
|
263352
|
+
}
|
|
263353
|
+
});
|
|
263354
|
+
|
|
262584
263355
|
// packages/execution/dist/tools/structured-read.js
|
|
262585
263356
|
import { readFile as readFile15, stat as stat5 } from "node:fs/promises";
|
|
262586
263357
|
import { resolve as resolve21, extname as extname5 } from "node:path";
|
|
@@ -265923,7 +266694,7 @@ import { execSync as execSync23, exec as execCb, spawnSync as spawnSync4 } from
|
|
|
265923
266694
|
import { readFile as readFile16, writeFile as writeFile20, mkdir as mkdir15 } from "node:fs/promises";
|
|
265924
266695
|
import { resolve as resolve28, join as join48 } from "node:path";
|
|
265925
266696
|
import { homedir as homedir13 } from "node:os";
|
|
265926
|
-
import { randomBytes as randomBytes12, createHash as
|
|
266697
|
+
import { randomBytes as randomBytes12, createHash as createHash7 } from "node:crypto";
|
|
265927
266698
|
function isValidCron(expr) {
|
|
265928
266699
|
const parts = expr.trim().split(/\s+/);
|
|
265929
266700
|
if (parts.length !== 5)
|
|
@@ -266359,7 +267130,7 @@ var init_scheduler = __esm({
|
|
|
266359
267130
|
}
|
|
266360
267131
|
const scope = String(args["scope"] ?? "local");
|
|
266361
267132
|
const fingerprint = `${resolve28(this.workingDir)}|${task}|${cronExpr}|${scope}`;
|
|
266362
|
-
const id = `sched-${
|
|
267133
|
+
const id = `sched-${createHash7("sha1").update(fingerprint).digest("hex").slice(0, 8)}`;
|
|
266363
267134
|
const oneShot = Boolean(args["one_shot"]);
|
|
266364
267135
|
const maxRuns = typeof args["max_runs"] === "number" ? args["max_runs"] : void 0;
|
|
266365
267136
|
const newTask = {
|
|
@@ -270515,7 +271286,7 @@ var init_import_graph = __esm({
|
|
|
270515
271286
|
import { createRequire as __createRequireGlob } from "node:module";
|
|
270516
271287
|
import ignore from "ignore";
|
|
270517
271288
|
import { readFile as readFile21, stat as stat6 } from "node:fs/promises";
|
|
270518
|
-
import { createHash as
|
|
271289
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
270519
271290
|
import { join as join56, relative as relative5, extname as extname8, basename as basename13 } from "node:path";
|
|
270520
271291
|
var __requireGlob, glob2, DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
|
|
270521
271292
|
var init_codebase_indexer = __esm({
|
|
@@ -270583,7 +271354,7 @@ var init_codebase_indexer = __esm({
|
|
|
270583
271354
|
if (fileStat.size > this.config.maxFileSize)
|
|
270584
271355
|
continue;
|
|
270585
271356
|
const content = await readFile21(fullPath);
|
|
270586
|
-
const hash =
|
|
271357
|
+
const hash = createHash8("sha256").update(content).digest("hex");
|
|
270587
271358
|
const ext = extname8(relativePath);
|
|
270588
271359
|
indexed.push({
|
|
270589
271360
|
path: fullPath,
|
|
@@ -410087,9 +410858,9 @@ ${lanes.join("\n")}
|
|
|
410087
410858
|
/*ignoreCase*/
|
|
410088
410859
|
false
|
|
410089
410860
|
)) {
|
|
410090
|
-
const
|
|
410091
|
-
if (
|
|
410092
|
-
const name10 = removeSuffix(removePrefix(
|
|
410861
|
+
const basename35 = getBaseFileName(a2.fileName);
|
|
410862
|
+
if (basename35 === "lib.d.ts" || basename35 === "lib.es6.d.ts") return 0;
|
|
410863
|
+
const name10 = removeSuffix(removePrefix(basename35, "lib."), ".d.ts");
|
|
410093
410864
|
const index = libs.indexOf(name10);
|
|
410094
410865
|
if (index !== -1) return index + 1;
|
|
410095
410866
|
}
|
|
@@ -474015,8 +474786,8 @@ ${options2.prefix}` : "\n" : options2.prefix
|
|
|
474015
474786
|
}
|
|
474016
474787
|
};
|
|
474017
474788
|
for (const file of files) {
|
|
474018
|
-
const
|
|
474019
|
-
if (
|
|
474789
|
+
const basename35 = getBaseFileName(file);
|
|
474790
|
+
if (basename35 === "package.json" || basename35 === "bower.json") {
|
|
474020
474791
|
createProjectWatcher(
|
|
474021
474792
|
file,
|
|
474022
474793
|
"FileWatcher"
|
|
@@ -477700,8 +478471,8 @@ All files are: ${JSON.stringify(names)}`,
|
|
|
477700
478471
|
var _a;
|
|
477701
478472
|
const fileOrDirectoryPath = removeIgnoredPath(this.toPath(fileOrDirectory));
|
|
477702
478473
|
if (!fileOrDirectoryPath) return;
|
|
477703
|
-
const
|
|
477704
|
-
if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (
|
|
478474
|
+
const basename35 = getBaseFileName(fileOrDirectoryPath);
|
|
478475
|
+
if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename35 === "package.json" || basename35 === "node_modules")) {
|
|
477705
478476
|
result.affectedModuleSpecifierCacheProjects.forEach((project) => {
|
|
477706
478477
|
var _a2;
|
|
477707
478478
|
(_a2 = project.getModuleSpecifierCache()) == null ? void 0 : _a2.clear();
|
|
@@ -486582,7 +487353,7 @@ var require_path_browserify = __commonJS({
|
|
|
486582
487353
|
_makeLong: function _makeLong(path12) {
|
|
486583
487354
|
return path12;
|
|
486584
487355
|
},
|
|
486585
|
-
dirname: function
|
|
487356
|
+
dirname: function dirname44(path12) {
|
|
486586
487357
|
assertPath(path12);
|
|
486587
487358
|
if (path12.length === 0) return ".";
|
|
486588
487359
|
var code8 = path12.charCodeAt(0);
|
|
@@ -486604,7 +487375,7 @@ var require_path_browserify = __commonJS({
|
|
|
486604
487375
|
if (hasRoot && end === 1) return "//";
|
|
486605
487376
|
return path12.slice(0, end);
|
|
486606
487377
|
},
|
|
486607
|
-
basename: function
|
|
487378
|
+
basename: function basename35(path12, ext) {
|
|
486608
487379
|
if (ext !== void 0 && typeof ext !== "string") throw new TypeError('"ext" argument must be a string');
|
|
486609
487380
|
assertPath(path12);
|
|
486610
487381
|
var start2 = 0;
|
|
@@ -514895,7 +515666,7 @@ var init_ts_morph_parser = __esm({
|
|
|
514895
515666
|
|
|
514896
515667
|
// packages/indexer/dist/code-graph-db.js
|
|
514897
515668
|
import { createRequire as createRequire2 } from "node:module";
|
|
514898
|
-
import { createHash as
|
|
515669
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
514899
515670
|
import { mkdirSync as mkdirSync16, readFileSync as readFileSync30 } from "node:fs";
|
|
514900
515671
|
import { join as join57, dirname as dirname14, extname as extname9 } from "node:path";
|
|
514901
515672
|
function loadDatabaseCtor() {
|
|
@@ -514967,7 +515738,7 @@ function extractFileImports(content, filePath) {
|
|
|
514967
515738
|
return imports.map((p2) => p2.replace(/\.(js|ts|jsx|tsx|mjs|cjs)$/, ""));
|
|
514968
515739
|
}
|
|
514969
515740
|
function hashContent(content) {
|
|
514970
|
-
return
|
|
515741
|
+
return createHash9("sha1").update(content).digest("hex").slice(0, 16);
|
|
514971
515742
|
}
|
|
514972
515743
|
function detectLanguage(filePath) {
|
|
514973
515744
|
return EXT_TO_LANG[extname9(filePath)] ?? "unknown";
|
|
@@ -523476,7 +524247,7 @@ var init_client3 = __esm({
|
|
|
523476
524247
|
import { existsSync as existsSync53, readFileSync as readFileSync39, writeFileSync as writeFileSync24, mkdirSync as mkdirSync27, chmodSync, statSync as statSync24 } from "node:fs";
|
|
523477
524248
|
import { join as join69, dirname as dirname16 } from "node:path";
|
|
523478
524249
|
import { homedir as homedir22 } from "node:os";
|
|
523479
|
-
import { randomBytes as randomBytes18, createHash as
|
|
524250
|
+
import { randomBytes as randomBytes18, createHash as createHash10 } from "node:crypto";
|
|
523480
524251
|
function secretsPath(scope, repoRoot) {
|
|
523481
524252
|
return scope === "global" ? join69(homedir22(), ".omnius", "secrets.json") : join69(repoRoot, ".omnius", "secrets.json");
|
|
523482
524253
|
}
|
|
@@ -523517,7 +524288,7 @@ function sanitizeHint(hint) {
|
|
|
523517
524288
|
return hint.toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 32) || "GENERIC";
|
|
523518
524289
|
}
|
|
523519
524290
|
function shortDigest(value2) {
|
|
523520
|
-
return
|
|
524291
|
+
return createHash10("sha256").update(value2).digest("hex").slice(0, 6);
|
|
523521
524292
|
}
|
|
523522
524293
|
function randomSuffix() {
|
|
523523
524294
|
return randomBytes18(3).toString("hex");
|
|
@@ -525213,7 +525984,7 @@ var init_environment_snapshot = __esm({
|
|
|
525213
525984
|
import { execSync as execSync43 } from "node:child_process";
|
|
525214
525985
|
import { existsSync as existsSync57, mkdirSync as mkdirSync29, writeFileSync as writeFileSync27, readFileSync as readFileSync43, readdirSync as readdirSync20, unlinkSync as unlinkSync12 } from "node:fs";
|
|
525215
525986
|
import { join as join72, basename as basename15 } from "node:path";
|
|
525216
|
-
import { createHash as
|
|
525987
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
525217
525988
|
function isYouTubeUrl2(url) {
|
|
525218
525989
|
return /(?:youtube\.com\/(?:watch|shorts|live|embed|v\/)|youtu\.be\/)/i.test(url);
|
|
525219
525990
|
}
|
|
@@ -525241,7 +526012,7 @@ function ensureFfmpeg() {
|
|
|
525241
526012
|
function imageHash(imagePath) {
|
|
525242
526013
|
try {
|
|
525243
526014
|
const data = readFileSync43(imagePath);
|
|
525244
|
-
return
|
|
526015
|
+
return createHash11("md5").update(data).digest("hex").slice(0, 12);
|
|
525245
526016
|
} catch {
|
|
525246
526017
|
return "unknown";
|
|
525247
526018
|
}
|
|
@@ -526897,6 +527668,7 @@ __export(dist_exports, {
|
|
|
526897
527668
|
DEFAULT_MUSIC_MODEL: () => DEFAULT_MUSIC_MODEL,
|
|
526898
527669
|
DEFAULT_OLLAMA_IMAGE_MODEL: () => DEFAULT_OLLAMA_IMAGE_MODEL,
|
|
526899
527670
|
DEFAULT_SOUND_MODEL: () => DEFAULT_SOUND_MODEL,
|
|
527671
|
+
DEFAULT_SPONSOR_MEDIA_LIMITS: () => DEFAULT_SPONSOR_MEDIA_LIMITS,
|
|
526900
527672
|
DESKTOP_DEPS: () => DESKTOP_DEPS,
|
|
526901
527673
|
DebateTool: () => DebateTool,
|
|
526902
527674
|
DesktopClickTool: () => DesktopClickTool,
|
|
@@ -526959,6 +527731,8 @@ __export(dist_exports, {
|
|
|
526959
527731
|
ReplTool: () => ReplTool,
|
|
526960
527732
|
ReplayWithInterventionTool: () => ReplayWithInterventionTool,
|
|
526961
527733
|
RepoMapTool: () => RepoMapTool,
|
|
527734
|
+
SPONSOR_MEDIA_CAPABILITY_PREFIX: () => SPONSOR_MEDIA_CAPABILITY_PREFIX,
|
|
527735
|
+
SPONSOR_MEDIA_MODALITIES: () => SPONSOR_MEDIA_MODALITIES,
|
|
526962
527736
|
SchedulerTool: () => SchedulerTool,
|
|
526963
527737
|
ScreenshotTool: () => ScreenshotTool,
|
|
526964
527738
|
SdrScanTool: () => SdrScanTool,
|
|
@@ -527005,6 +527779,7 @@ __export(dist_exports, {
|
|
|
527005
527779
|
aliasTool: () => aliasTool,
|
|
527006
527780
|
applyPatch: () => applyPatch,
|
|
527007
527781
|
applyToolResultTriage: () => applyToolResultTriage,
|
|
527782
|
+
artifactManifestFromBytes: () => artifactManifestFromBytes,
|
|
527008
527783
|
audioGenerationDir: () => audioGenerationDir,
|
|
527009
527784
|
audioGenerationSetupPlan: () => audioGenerationSetupPlan,
|
|
527010
527785
|
audioGenerationVenvDir: () => audioGenerationVenvDir,
|
|
@@ -527018,6 +527793,7 @@ __export(dist_exports, {
|
|
|
527018
527793
|
buildMcpToolName: () => buildMcpToolName,
|
|
527019
527794
|
buildScaffoldedPrompt: () => buildScaffoldedPrompt,
|
|
527020
527795
|
buildSkillsSummary: () => buildSkillsSummary,
|
|
527796
|
+
buildSponsorMediaServices: () => buildSponsorMediaServices,
|
|
527021
527797
|
buildSubProcessArgs: () => buildSubProcessArgs,
|
|
527022
527798
|
buildToolManifestFromModule: () => buildToolManifestFromModule,
|
|
527023
527799
|
canInvokeTool: () => canInvokeTool,
|
|
@@ -527037,6 +527813,7 @@ __export(dist_exports, {
|
|
|
527037
527813
|
createTransport: () => createTransport,
|
|
527038
527814
|
createWorktree: () => createWorktree2,
|
|
527039
527815
|
defaultExposureForTool: () => defaultExposureForTool,
|
|
527816
|
+
defaultExtensionForMime: () => defaultExtensionForMime,
|
|
527040
527817
|
deleteTodos: () => deleteTodos,
|
|
527041
527818
|
detectElevationMethod: () => detectElevationMethod,
|
|
527042
527819
|
detectLegacyCaches: () => detectLegacyCaches,
|
|
@@ -527128,14 +527905,17 @@ __export(dist_exports, {
|
|
|
527128
527905
|
markReverted: () => markReverted,
|
|
527129
527906
|
markSessionValidated: () => markSessionValidated,
|
|
527130
527907
|
measureRepoCacheBytes: () => measureRepoCacheBytes,
|
|
527908
|
+
mediaMimeFromPath: () => mediaMimeFromPath,
|
|
527131
527909
|
migrateLegacyCaches: () => migrateLegacyCaches,
|
|
527132
527910
|
networkEgressErrorMessage: () => networkEgressErrorMessage,
|
|
527133
527911
|
normalizeMcpName: () => normalizeMcpName,
|
|
527134
527912
|
normalizeNetworkHostname: () => normalizeNetworkHostname,
|
|
527913
|
+
normalizeSponsorMediaConfig: () => normalizeSponsorMediaConfig,
|
|
527135
527914
|
omniusHomeDir: () => omniusHomeDir,
|
|
527136
527915
|
packetPath: () => packetPath,
|
|
527137
527916
|
parseMcpMarkdown: () => parseMcpMarkdown,
|
|
527138
527917
|
parseMcpToolName: () => parseMcpToolName,
|
|
527918
|
+
parseSponsorMediaCapability: () => parseSponsorMediaCapability,
|
|
527139
527919
|
playSoundFile: () => playSoundFile,
|
|
527140
527920
|
promoteWorkingNotes: () => promoteWorkingNotes,
|
|
527141
527921
|
quarantineSecret: () => quarantineSecret,
|
|
@@ -527166,6 +527946,7 @@ __export(dist_exports, {
|
|
|
527166
527946
|
runTypecheck: () => runTypecheck,
|
|
527167
527947
|
runValidationPipeline: () => runValidationPipeline,
|
|
527168
527948
|
sanitizeReminderDeliveryText: () => sanitizeReminderDeliveryText,
|
|
527949
|
+
sanitizeRemoteMediaGenerateRequest: () => sanitizeRemoteMediaGenerateRequest,
|
|
527169
527950
|
saveCustomToolDefinition: () => saveCustomToolDefinition,
|
|
527170
527951
|
saveMcpServerToConfig: () => saveMcpServerToConfig,
|
|
527171
527952
|
savePacket: () => savePacket,
|
|
@@ -527179,6 +527960,7 @@ __export(dist_exports, {
|
|
|
527179
527960
|
sha256Text: () => sha256Text,
|
|
527180
527961
|
shannonEntropy: () => shannonEntropy,
|
|
527181
527962
|
spawnFullSubAgent: () => spawnFullSubAgent,
|
|
527963
|
+
sponsorMediaCapabilityName: () => sponsorMediaCapabilityName,
|
|
527182
527964
|
stableJson: () => stableJson,
|
|
527183
527965
|
stopFullSubAgent: () => stopFullSubAgent,
|
|
527184
527966
|
summarizeLog: () => summarizeLog,
|
|
@@ -527266,6 +528048,7 @@ var init_dist5 = __esm({
|
|
|
527266
528048
|
init_audio_generate();
|
|
527267
528049
|
init_model_store();
|
|
527268
528050
|
init_video_generate();
|
|
528051
|
+
init_sponsor_media();
|
|
527269
528052
|
init_structured_read();
|
|
527270
528053
|
init_vision();
|
|
527271
528054
|
init_desktop_click();
|
|
@@ -531825,14 +532608,14 @@ var init_artifact_inspector = __esm({
|
|
|
531825
532608
|
// packages/orchestrator/dist/lesson-bank.js
|
|
531826
532609
|
import { existsSync as existsSync66, mkdirSync as mkdirSync32, appendFileSync as appendFileSync2, readFileSync as readFileSync51 } from "node:fs";
|
|
531827
532610
|
import { join as join79, dirname as dirname22 } from "node:path";
|
|
531828
|
-
import { createHash as
|
|
532611
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
531829
532612
|
function tokenize2(text) {
|
|
531830
532613
|
if (!text)
|
|
531831
532614
|
return [];
|
|
531832
532615
|
return text.toLowerCase().split(TOKENIZE_RE).filter((t2) => t2.length >= 3).slice(0, 80);
|
|
531833
532616
|
}
|
|
531834
532617
|
function shortHash(s2) {
|
|
531835
|
-
return
|
|
532618
|
+
return createHash12("sha256").update(s2).digest("hex").slice(0, 16);
|
|
531836
532619
|
}
|
|
531837
532620
|
function solicit(args) {
|
|
531838
532621
|
const { taskGoal, stem, reflections, successOutputPreview } = args;
|
|
@@ -535457,7 +536240,7 @@ var init_pprRetrieval = __esm({
|
|
|
535457
536240
|
import { join as join85 } from "node:path";
|
|
535458
536241
|
import { mkdirSync as mkdirSync34, existsSync as existsSync72 } from "node:fs";
|
|
535459
536242
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
535460
|
-
import { createHash as
|
|
536243
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
535461
536244
|
function readEpisodeAffect2(metadata) {
|
|
535462
536245
|
if (!metadata || typeof metadata !== "object")
|
|
535463
536246
|
return null;
|
|
@@ -535675,7 +536458,7 @@ var init_episodeStore = __esm({
|
|
|
535675
536458
|
insert(ep) {
|
|
535676
536459
|
const id = randomUUID8();
|
|
535677
536460
|
const now = Date.now();
|
|
535678
|
-
const contentHash2 =
|
|
536461
|
+
const contentHash2 = createHash13("sha256").update(ep.content).digest("hex").slice(0, 16);
|
|
535679
536462
|
const modality = ep.modality ?? "text";
|
|
535680
536463
|
const rawImportance = ep.importance ?? autoImportance(ep.toolName ?? null, modality, ep.content);
|
|
535681
536464
|
const modulated = ep.emotionalState ? modulateImportance(sanitizeImportance(rawImportance), ep.emotionalState) : sanitizeImportance(rawImportance);
|
|
@@ -536209,9 +536992,9 @@ var init_temporalGraph = __esm({
|
|
|
536209
536992
|
});
|
|
536210
536993
|
|
|
536211
536994
|
// packages/memory/dist/multimodalIdentity.js
|
|
536212
|
-
import { createHash as
|
|
536995
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
536213
536996
|
function stableHash(value2) {
|
|
536214
|
-
return
|
|
536997
|
+
return createHash14("sha256").update(value2).digest("hex").slice(0, 24);
|
|
536215
536998
|
}
|
|
536216
536999
|
function normalizeAtom(value2) {
|
|
536217
537000
|
return value2.trim().toLowerCase().replace(/\s+/g, " ");
|
|
@@ -536568,9 +537351,9 @@ var init_gistCompressor = __esm({
|
|
|
536568
537351
|
});
|
|
536569
537352
|
|
|
536570
537353
|
// packages/memory/dist/graphWalk.js
|
|
536571
|
-
import { createHash as
|
|
537354
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
536572
537355
|
function seededUnit(seed) {
|
|
536573
|
-
const digest3 =
|
|
537356
|
+
const digest3 = createHash15("sha256").update(seed || "graph-walk").digest();
|
|
536574
537357
|
const value2 = digest3.readUInt32BE(0);
|
|
536575
537358
|
return value2 / 4294967295;
|
|
536576
537359
|
}
|
|
@@ -540701,7 +541484,7 @@ var init_memoryStageContext = __esm({
|
|
|
540701
541484
|
});
|
|
540702
541485
|
|
|
540703
541486
|
// packages/memory/dist/sessionGist.js
|
|
540704
|
-
import { createHash as
|
|
541487
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
540705
541488
|
function inferDomain(input) {
|
|
540706
541489
|
const blob = [
|
|
540707
541490
|
input.goal,
|
|
@@ -540726,7 +541509,7 @@ function inferDomain(input) {
|
|
|
540726
541509
|
return ranked[0][0];
|
|
540727
541510
|
}
|
|
540728
541511
|
function computeGoalHash(goal) {
|
|
540729
|
-
return
|
|
541512
|
+
return createHash16("sha256").update(goal.trim().toLowerCase()).digest("hex").slice(0, 16);
|
|
540730
541513
|
}
|
|
540731
541514
|
function clip(text, n2) {
|
|
540732
541515
|
if (!text)
|
|
@@ -540937,12 +541720,12 @@ var init_toolOutcomes = __esm({
|
|
|
540937
541720
|
});
|
|
540938
541721
|
|
|
540939
541722
|
// packages/memory/dist/stagnationRecipes.js
|
|
540940
|
-
import { createHash as
|
|
541723
|
+
import { createHash as createHash17 } from "node:crypto";
|
|
540941
541724
|
function fingerprintSignature(fp) {
|
|
540942
541725
|
const normClusters = (fp.errorClusters ?? []).map((s2) => (s2 || "").toLowerCase().replace(/[0-9]+/g, "N").replace(/\s+/g, " ").trim()).filter(Boolean).sort();
|
|
540943
541726
|
const tool = (fp.stuckTool ?? "").toLowerCase().trim();
|
|
540944
541727
|
const blob = `tool=${tool};clusters=${normClusters.join("|")}`;
|
|
540945
|
-
return
|
|
541728
|
+
return createHash17("sha256").update(blob).digest("hex").slice(0, 16);
|
|
540946
541729
|
}
|
|
540947
541730
|
function crystallize(store2, input) {
|
|
540948
541731
|
const sig = fingerprintSignature(input.fingerprint);
|
|
@@ -540999,7 +541782,7 @@ var init_stagnationRecipes = __esm({
|
|
|
540999
541782
|
});
|
|
541000
541783
|
|
|
541001
541784
|
// packages/memory/dist/codebaseMap.js
|
|
541002
|
-
import { createHash as
|
|
541785
|
+
import { createHash as createHash18, randomUUID as randomUUID12 } from "node:crypto";
|
|
541003
541786
|
function freshNodeId() {
|
|
541004
541787
|
return randomUUID12();
|
|
541005
541788
|
}
|
|
@@ -541013,7 +541796,7 @@ var init_codebaseMap = __esm({
|
|
|
541013
541796
|
touchCount = /* @__PURE__ */ new Map();
|
|
541014
541797
|
constructor(db, repoRoot, commitSha) {
|
|
541015
541798
|
this.db = db;
|
|
541016
|
-
this.repoFp =
|
|
541799
|
+
this.repoFp = createHash18("sha256").update(`${repoRoot}::${commitSha ?? "no-commit"}`).digest("hex").slice(0, 16);
|
|
541017
541800
|
this.ensureSchema();
|
|
541018
541801
|
}
|
|
541019
541802
|
ensureSchema() {
|
|
@@ -541195,7 +541978,7 @@ var init_codebaseMap = __esm({
|
|
|
541195
541978
|
}
|
|
541196
541979
|
/** Stable composite id: `<kind>:<sha16(path)>` so insert ON CONFLICT works. */
|
|
541197
541980
|
idFor(kind, path12) {
|
|
541198
|
-
const h =
|
|
541981
|
+
const h = createHash18("sha256").update(`${this.repoFp}:${kind}:${path12}`).digest("hex").slice(0, 24);
|
|
541199
541982
|
return `${kind}-${h}`;
|
|
541200
541983
|
}
|
|
541201
541984
|
};
|
|
@@ -543706,7 +544489,7 @@ import { existsSync as existsSync80, readFileSync as readFileSync62, statSync as
|
|
|
543706
544489
|
import { execSync as execSync46 } from "node:child_process";
|
|
543707
544490
|
import { homedir as homedir29, platform as platform3, arch as arch2, totalmem as totalmem3, freemem as freemem3, hostname as hostname3 } from "node:os";
|
|
543708
544491
|
import { join as join93 } from "node:path";
|
|
543709
|
-
import { createHash as
|
|
544492
|
+
import { createHash as createHash19 } from "node:crypto";
|
|
543710
544493
|
function capturePreflightSnapshot(workingDir) {
|
|
543711
544494
|
const warnings = [];
|
|
543712
544495
|
const configFingerprints = {};
|
|
@@ -543873,7 +544656,7 @@ function expandPath(p2) {
|
|
|
543873
544656
|
return p2;
|
|
543874
544657
|
}
|
|
543875
544658
|
function sha2563(s2) {
|
|
543876
|
-
return
|
|
544659
|
+
return createHash19("sha256").update(s2).digest("hex").slice(0, 16);
|
|
543877
544660
|
}
|
|
543878
544661
|
function freeDiskBytes(path12 = "/tmp") {
|
|
543879
544662
|
try {
|
|
@@ -550135,8 +550918,8 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
550135
550918
|
if (process.env["OMNIUS_DISABLE_ADAPTIVE_RETRIEVAL"] !== "1") {
|
|
550136
550919
|
const goalForSig = (this._taskState.goal || "").slice(0, 200);
|
|
550137
550920
|
const recentTools = this._toolSequence.slice(-5).join("|");
|
|
550138
|
-
const { createHash:
|
|
550139
|
-
const sig =
|
|
550921
|
+
const { createHash: createHash34 } = await import("node:crypto");
|
|
550922
|
+
const sig = createHash34("sha256").update(`${goalForSig}::${recentTools}`).digest("hex").slice(0, 16);
|
|
550140
550923
|
if (this._lastPprSig === sig && this._lastPprMemoryLines.length > 0) {
|
|
550141
550924
|
compacted.push({
|
|
550142
550925
|
role: "system",
|
|
@@ -563592,10 +564375,10 @@ transcribe-cli error: ${transcribeCliError}` : "";
|
|
|
563592
564375
|
wordTimestamps: false
|
|
563593
564376
|
});
|
|
563594
564377
|
if (outputDir) {
|
|
563595
|
-
const { basename:
|
|
564378
|
+
const { basename: basename35 } = await import("node:path");
|
|
563596
564379
|
const transcriptDir = join102(outputDir, ".omnius", "transcripts");
|
|
563597
564380
|
mkdirSync48(transcriptDir, { recursive: true });
|
|
563598
|
-
const outFile = join102(transcriptDir, `${
|
|
564381
|
+
const outFile = join102(transcriptDir, `${basename35(filePath)}.txt`);
|
|
563599
564382
|
writeFileSync43(outFile, result.text, "utf-8");
|
|
563600
564383
|
}
|
|
563601
564384
|
return {
|
|
@@ -563611,10 +564394,10 @@ transcribe-cli error: ${transcribeCliError}` : "";
|
|
|
563611
564394
|
const fb = await transcribeFileViaWhisper(filePath, this.config.model);
|
|
563612
564395
|
if (fb) {
|
|
563613
564396
|
if (outputDir) {
|
|
563614
|
-
const { basename:
|
|
564397
|
+
const { basename: basename35 } = await import("node:path");
|
|
563615
564398
|
const transcriptDir = join102(outputDir, ".omnius", "transcripts");
|
|
563616
564399
|
mkdirSync48(transcriptDir, { recursive: true });
|
|
563617
|
-
const outFile = join102(transcriptDir, `${
|
|
564400
|
+
const outFile = join102(transcriptDir, `${basename35(filePath)}.txt`);
|
|
563618
564401
|
writeFileSync43(outFile, fb.text, "utf-8");
|
|
563619
564402
|
}
|
|
563620
564403
|
return fb;
|
|
@@ -565862,7 +566645,7 @@ var require_websocket3 = __commonJS({
|
|
|
565862
566645
|
var http6 = __require("http");
|
|
565863
566646
|
var net5 = __require("net");
|
|
565864
566647
|
var tls2 = __require("tls");
|
|
565865
|
-
var { randomBytes: randomBytes29, createHash:
|
|
566648
|
+
var { randomBytes: randomBytes29, createHash: createHash34 } = __require("crypto");
|
|
565866
566649
|
var { Duplex: Duplex3, Readable } = __require("stream");
|
|
565867
566650
|
var { URL: URL3 } = __require("url");
|
|
565868
566651
|
var PerMessageDeflate3 = require_permessage_deflate3();
|
|
@@ -566522,7 +567305,7 @@ var require_websocket3 = __commonJS({
|
|
|
566522
567305
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
566523
567306
|
return;
|
|
566524
567307
|
}
|
|
566525
|
-
const digest3 =
|
|
567308
|
+
const digest3 = createHash34("sha1").update(key + GUID).digest("base64");
|
|
566526
567309
|
if (res.headers["sec-websocket-accept"] !== digest3) {
|
|
566527
567310
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
566528
567311
|
return;
|
|
@@ -566889,7 +567672,7 @@ var require_websocket_server2 = __commonJS({
|
|
|
566889
567672
|
var EventEmitter15 = __require("events");
|
|
566890
567673
|
var http6 = __require("http");
|
|
566891
567674
|
var { Duplex: Duplex3 } = __require("stream");
|
|
566892
|
-
var { createHash:
|
|
567675
|
+
var { createHash: createHash34 } = __require("crypto");
|
|
566893
567676
|
var extension3 = require_extension3();
|
|
566894
567677
|
var PerMessageDeflate3 = require_permessage_deflate3();
|
|
566895
567678
|
var subprotocol3 = require_subprotocol2();
|
|
@@ -567190,7 +567973,7 @@ var require_websocket_server2 = __commonJS({
|
|
|
567190
567973
|
);
|
|
567191
567974
|
}
|
|
567192
567975
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
567193
|
-
const digest3 =
|
|
567976
|
+
const digest3 = createHash34("sha1").update(key + GUID).digest("base64");
|
|
567194
567977
|
const headers = [
|
|
567195
567978
|
"HTTP/1.1 101 Switching Protocols",
|
|
567196
567979
|
"Upgrade: websocket",
|
|
@@ -567943,6 +568726,10 @@ var init_command_registry = __esm({
|
|
|
567943
568726
|
["/ipfs import <cid>", "Import a shared IPFS tool or skill reference"],
|
|
567944
568727
|
["/sponsor", "Sponsor inference - onboarding wizard or dashboard"],
|
|
567945
568728
|
["/sponsor status", "Show sponsor dashboard with usage metrics"],
|
|
568729
|
+
["/sponsor image <prompt>", "Generate an image on a sponsored peer"],
|
|
568730
|
+
["/sponsor video <prompt>", "Generate a video on a sponsored peer"],
|
|
568731
|
+
["/sponsor sound <prompt>", "Generate a sound effect on a sponsored peer"],
|
|
568732
|
+
["/sponsor music <prompt>", "Generate music on a sponsored peer"],
|
|
567946
568733
|
["/sponsor pause", "Pause active sponsorship"],
|
|
567947
568734
|
["/sponsor remove", "Remove sponsorship entirely"],
|
|
567948
568735
|
["/endpoint sponsor", "Browse and connect to sponsored inference from the nexus mesh"],
|
|
@@ -571976,14 +572763,14 @@ var init_voice_session = __esm({
|
|
|
571976
572763
|
});
|
|
571977
572764
|
|
|
571978
572765
|
// packages/cli/src/tui/scoped-personality.ts
|
|
571979
|
-
import { createHash as
|
|
572766
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
571980
572767
|
import { appendFileSync as appendFileSync5, existsSync as existsSync88, mkdirSync as mkdirSync49, readFileSync as readFileSync69, writeFileSync as writeFileSync44 } from "node:fs";
|
|
571981
572768
|
import { join as join103, resolve as resolve39 } from "node:path";
|
|
571982
572769
|
function safeName(input) {
|
|
571983
572770
|
return input.replace(/[^A-Za-z0-9_.-]/g, "-").slice(0, 80) || "default";
|
|
571984
572771
|
}
|
|
571985
572772
|
function scopeHash(scope) {
|
|
571986
|
-
return
|
|
572773
|
+
return createHash20("sha1").update(`${scope.kind}:${scope.id}`).digest("hex").slice(0, 16);
|
|
571987
572774
|
}
|
|
571988
572775
|
function scopedPersonalityDir(repoRoot, kind) {
|
|
571989
572776
|
return resolve39(repoRoot, ".omnius", "scoped-personality", kind);
|
|
@@ -572314,7 +573101,7 @@ var init_scoped_personality = __esm({
|
|
|
572314
573101
|
});
|
|
572315
573102
|
|
|
572316
573103
|
// packages/cli/src/tui/voice-soul.ts
|
|
572317
|
-
import { createHash as
|
|
573104
|
+
import { createHash as createHash21 } from "node:crypto";
|
|
572318
573105
|
import { existsSync as existsSync89, readdirSync as readdirSync29, readFileSync as readFileSync70 } from "node:fs";
|
|
572319
573106
|
import { basename as basename20, join as join104, resolve as resolve40 } from "node:path";
|
|
572320
573107
|
function compactText(text, limit) {
|
|
@@ -572329,7 +573116,7 @@ function blockText(text, limit) {
|
|
|
572329
573116
|
... [truncated]`;
|
|
572330
573117
|
}
|
|
572331
573118
|
function scopeStateKey(scope, surface) {
|
|
572332
|
-
return
|
|
573119
|
+
return createHash21("sha1").update(`${surface}:${scope.kind}:${scope.id}`).digest("hex").slice(0, 16);
|
|
572333
573120
|
}
|
|
572334
573121
|
function safeName2(input) {
|
|
572335
573122
|
return input.replace(/[^A-Za-z0-9_.-]/g, "-").slice(0, 80) || "default";
|
|
@@ -572857,6 +573644,26 @@ function serializeSponsorModels(stats) {
|
|
|
572857
573644
|
(a2, b) => (b.tokensIn + b.tokensOut || b.requests) - (a2.tokensIn + a2.tokensOut || a2.requests)
|
|
572858
573645
|
);
|
|
572859
573646
|
}
|
|
573647
|
+
function parseMediaUsageKey(key) {
|
|
573648
|
+
const [rawModality, ...modelParts] = key.split(":");
|
|
573649
|
+
const modality = SPONSOR_MEDIA_MODALITIES.includes(rawModality) ? rawModality : "image";
|
|
573650
|
+
return { modality, model: modelParts.join(":") || "auto" };
|
|
573651
|
+
}
|
|
573652
|
+
function serializeSponsorMedia(stats) {
|
|
573653
|
+
return Array.from(stats.mediaUsage.entries()).map(([key, meter]) => {
|
|
573654
|
+
const parsed = parseMediaUsageKey(key);
|
|
573655
|
+
return {
|
|
573656
|
+
key,
|
|
573657
|
+
modality: parsed.modality,
|
|
573658
|
+
model: parsed.model,
|
|
573659
|
+
jobs: meter.jobs,
|
|
573660
|
+
bytesOut: meter.bytesOut,
|
|
573661
|
+
failures: meter.failures,
|
|
573662
|
+
avgLatencyMs: meter.jobs > 0 ? Math.round(meter.totalLatencyMs / meter.jobs) : 0,
|
|
573663
|
+
lastUsed: meter.lastUsed
|
|
573664
|
+
};
|
|
573665
|
+
}).sort((a2, b) => (b.jobs || b.bytesOut) - (a2.jobs || a2.bytesOut));
|
|
573666
|
+
}
|
|
572860
573667
|
function serializeSponsorPeers(stats) {
|
|
572861
573668
|
return Array.from(stats.users.values()).map((user) => ({
|
|
572862
573669
|
peer: user.ip,
|
|
@@ -572872,7 +573679,20 @@ function serializeSponsorPeers(stats) {
|
|
|
572872
573679
|
tokensIn: meter.tokensIn,
|
|
572873
573680
|
tokensOut: meter.tokensOut,
|
|
572874
573681
|
lastUsed: meter.lastUsed
|
|
572875
|
-
})).sort((a2, b) => b.tokensIn + b.tokensOut - (a2.tokensIn + a2.tokensOut))
|
|
573682
|
+
})).sort((a2, b) => b.tokensIn + b.tokensOut - (a2.tokensIn + a2.tokensOut)),
|
|
573683
|
+
media: Array.from(user.media.entries()).map(([key, meter]) => {
|
|
573684
|
+
const parsed = parseMediaUsageKey(key);
|
|
573685
|
+
return {
|
|
573686
|
+
key,
|
|
573687
|
+
modality: parsed.modality,
|
|
573688
|
+
model: parsed.model,
|
|
573689
|
+
jobs: meter.jobs,
|
|
573690
|
+
bytesOut: meter.bytesOut,
|
|
573691
|
+
failures: meter.failures,
|
|
573692
|
+
avgLatencyMs: meter.jobs > 0 ? Math.round(meter.totalLatencyMs / meter.jobs) : 0,
|
|
573693
|
+
lastUsed: meter.lastUsed
|
|
573694
|
+
};
|
|
573695
|
+
}).sort((a2, b) => (b.jobs || b.bytesOut) - (a2.jobs || a2.bytesOut))
|
|
572876
573696
|
})).sort((a2, b) => (b.tokensIn + b.tokensOut || b.requests) - (a2.tokensIn + a2.tokensOut || a2.requests));
|
|
572877
573697
|
}
|
|
572878
573698
|
function nextSponsorDailyReset(now = Date.now()) {
|
|
@@ -573070,6 +573890,7 @@ var HOP_BY_HOP_HEADERS, CF_HEADERS_PREFIX, DEFAULT_EXPOSE_MAX_BODY_BYTES, INTERN
|
|
|
573070
573890
|
var init_expose = __esm({
|
|
573071
573891
|
"packages/cli/src/tui/expose.ts"() {
|
|
573072
573892
|
"use strict";
|
|
573893
|
+
init_dist5();
|
|
573073
573894
|
init_render();
|
|
573074
573895
|
init_usage_bars();
|
|
573075
573896
|
init_typed_node_events();
|
|
@@ -573155,6 +573976,7 @@ var init_expose = __esm({
|
|
|
573155
573976
|
tokensPerSecond: 0,
|
|
573156
573977
|
startedAt: Date.now(),
|
|
573157
573978
|
modelUsage: /* @__PURE__ */ new Map(),
|
|
573979
|
+
mediaUsage: /* @__PURE__ */ new Map(),
|
|
573158
573980
|
users: /* @__PURE__ */ new Map(),
|
|
573159
573981
|
budgetTokensRemaining: 0,
|
|
573160
573982
|
budgetTokensTotal: 0,
|
|
@@ -573267,8 +574089,10 @@ var init_expose = __esm({
|
|
|
573267
574089
|
maxConcurrent: this._sponsorLimits.maxConcurrent,
|
|
573268
574090
|
blockedRequests: this._sponsorBlockedRequests,
|
|
573269
574091
|
allowedModels: this._sponsorLimits.allowedModels === "all" ? "all" : [...this._sponsorLimits.allowedModels],
|
|
574092
|
+
mediaLimits: this._sponsorLimits.media ? normalizeSponsorMediaConfig(this._sponsorLimits.media) : void 0,
|
|
573270
574093
|
peers: serializeSponsorPeers(this._stats),
|
|
573271
|
-
models: serializeSponsorModels(this._stats)
|
|
574094
|
+
models: serializeSponsorModels(this._stats),
|
|
574095
|
+
media: serializeSponsorMedia(this._stats)
|
|
573272
574096
|
};
|
|
573273
574097
|
}
|
|
573274
574098
|
recordServedTokens(tokens, now = Date.now()) {
|
|
@@ -573526,7 +574350,8 @@ var init_expose = __esm({
|
|
|
573526
574350
|
tokensIn: 0,
|
|
573527
574351
|
tokensOut: 0,
|
|
573528
574352
|
activeRequests: 0,
|
|
573529
|
-
models: /* @__PURE__ */ new Map()
|
|
574353
|
+
models: /* @__PURE__ */ new Map(),
|
|
574354
|
+
media: /* @__PURE__ */ new Map()
|
|
573530
574355
|
};
|
|
573531
574356
|
this._stats.users.set(userIp, user);
|
|
573532
574357
|
}
|
|
@@ -574030,6 +574855,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
574030
574855
|
this.emit("stats", {
|
|
574031
574856
|
...this._stats,
|
|
574032
574857
|
modelUsage: new Map(this._stats.modelUsage),
|
|
574858
|
+
mediaUsage: new Map(this._stats.mediaUsage),
|
|
574033
574859
|
users: new Map(this._stats.users),
|
|
574034
574860
|
sponsorUsage: this._stats.sponsorUsage ? { ...this._stats.sponsorUsage } : null
|
|
574035
574861
|
});
|
|
@@ -574095,6 +574921,10 @@ ${this.formatConnectionInfo()}`);
|
|
|
574095
574921
|
total: s2.sponsorUsage.maxConcurrent
|
|
574096
574922
|
})}`);
|
|
574097
574923
|
lines.push(` ${c3.cyan("Blocked".padEnd(18))} ${s2.sponsorUsage.blockedRequests}`);
|
|
574924
|
+
const enabledMedia = s2.sponsorUsage.mediaLimits ? SPONSOR_MEDIA_MODALITIES.filter((modality) => s2.sponsorUsage?.mediaLimits?.[modality]?.enabled) : [];
|
|
574925
|
+
if (enabledMedia.length > 0) {
|
|
574926
|
+
lines.push(` ${c3.cyan("Media".padEnd(18))} ${enabledMedia.join(", ")}`);
|
|
574927
|
+
}
|
|
574098
574928
|
}
|
|
574099
574929
|
const visibleModels = Array.from(s2.modelUsage.entries()).filter(([model]) => !INTERNAL_CAPABILITIES.has(model));
|
|
574100
574930
|
if (visibleModels.length > 0) {
|
|
@@ -574112,6 +574942,15 @@ ${this.formatConnectionInfo()}`);
|
|
|
574112
574942
|
lines.push(` ${c3.cyan(model.padEnd(30))} ${count} reqs ${c3.dim(`in:${fmtTokens(mIn)} out:${fmtTokens(mOut)}`)}`);
|
|
574113
574943
|
}
|
|
574114
574944
|
}
|
|
574945
|
+
const mediaUsage = serializeSponsorMedia(s2);
|
|
574946
|
+
if (mediaUsage.length > 0) {
|
|
574947
|
+
lines.push("");
|
|
574948
|
+
lines.push(` ${c3.bold("Media Jobs")}`);
|
|
574949
|
+
for (const media of mediaUsage.slice(0, 10)) {
|
|
574950
|
+
const mb = media.bytesOut > 0 ? `${(media.bytesOut / (1024 * 1024)).toFixed(1)}MB` : "0MB";
|
|
574951
|
+
lines.push(` ${c3.cyan(media.key.padEnd(30))} ${media.jobs} jobs ${c3.dim(`${mb} out ${media.avgLatencyMs}ms avg`)}`);
|
|
574952
|
+
}
|
|
574953
|
+
}
|
|
574115
574954
|
if (s2.users.size > 0) {
|
|
574116
574955
|
lines.push("");
|
|
574117
574956
|
lines.push(` ${c3.bold("Active Users")} (${s2.users.size})`);
|
|
@@ -574180,6 +575019,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
574180
575019
|
tokensPerSecond: 0,
|
|
574181
575020
|
startedAt: Date.now(),
|
|
574182
575021
|
modelUsage: /* @__PURE__ */ new Map(),
|
|
575022
|
+
mediaUsage: /* @__PURE__ */ new Map(),
|
|
574183
575023
|
users: /* @__PURE__ */ new Map(),
|
|
574184
575024
|
budgetTokensRemaining: 0,
|
|
574185
575025
|
budgetTokensTotal: 0,
|
|
@@ -574318,8 +575158,10 @@ ${this.formatConnectionInfo()}`);
|
|
|
574318
575158
|
maxConcurrent: this._sponsorLimits.maxConcurrent,
|
|
574319
575159
|
blockedRequests: this._sponsorBlockedRequests,
|
|
574320
575160
|
allowedModels: this._sponsorLimits.allowedModels === "all" ? "all" : [...this._sponsorLimits.allowedModels],
|
|
575161
|
+
mediaLimits: this._sponsorLimits.media ? normalizeSponsorMediaConfig(this._sponsorLimits.media) : void 0,
|
|
574321
575162
|
peers: serializeSponsorPeers(this._stats),
|
|
574322
|
-
models: serializeSponsorModels(this._stats)
|
|
575163
|
+
models: serializeSponsorModels(this._stats),
|
|
575164
|
+
media: serializeSponsorMedia(this._stats)
|
|
574323
575165
|
};
|
|
574324
575166
|
}
|
|
574325
575167
|
recordServedTokens(tokens, now = Date.now()) {
|
|
@@ -574344,6 +575186,9 @@ ${this.formatConnectionInfo()}`);
|
|
|
574344
575186
|
exposeArgs.daily_tokens_used = String(this._dailyTokensUsed);
|
|
574345
575187
|
exposeArgs.daily_tokens_reset_at = String(this._dailyTokensResetAt);
|
|
574346
575188
|
exposeArgs.allowed_models = this._sponsorLimits.allowedModels === "all" ? "all" : this._sponsorLimits.allowedModels.join(",");
|
|
575189
|
+
if (this._sponsorLimits.media) {
|
|
575190
|
+
exposeArgs.media_config = JSON.stringify(normalizeSponsorMediaConfig(this._sponsorLimits.media));
|
|
575191
|
+
}
|
|
574347
575192
|
}
|
|
574348
575193
|
return exposeArgs;
|
|
574349
575194
|
}
|
|
@@ -574594,6 +575439,55 @@ ${this.formatConnectionInfo()}`);
|
|
|
574594
575439
|
this.refreshSponsorUsageStats();
|
|
574595
575440
|
continue;
|
|
574596
575441
|
}
|
|
575442
|
+
if (record.modality) {
|
|
575443
|
+
const modality = String(record.modality);
|
|
575444
|
+
const modelName = String(record.model || "auto");
|
|
575445
|
+
const mediaKey2 = `${modality}:${modelName}`;
|
|
575446
|
+
const outputBytes = safeNonNegativeInt(record.outputBytes ?? record.artifactBytes ?? 0);
|
|
575447
|
+
const durationMs = safeNonNegativeInt(record.durationMs);
|
|
575448
|
+
let mediaMeter = this._stats.mediaUsage.get(mediaKey2);
|
|
575449
|
+
if (!mediaMeter) {
|
|
575450
|
+
mediaMeter = { jobs: 0, bytesOut: 0, failures: 0, lastUsed: 0, totalLatencyMs: 0 };
|
|
575451
|
+
this._stats.mediaUsage.set(mediaKey2, mediaMeter);
|
|
575452
|
+
}
|
|
575453
|
+
mediaMeter.jobs++;
|
|
575454
|
+
mediaMeter.bytesOut += outputBytes;
|
|
575455
|
+
mediaMeter.failures += record.success === false ? 1 : 0;
|
|
575456
|
+
mediaMeter.lastUsed = Date.now();
|
|
575457
|
+
mediaMeter.totalLatencyMs += durationMs;
|
|
575458
|
+
this.recordSponsorRequest();
|
|
575459
|
+
const peerId2 = record.from || record.peerId || "unknown";
|
|
575460
|
+
const shortPeer2 = peerId2.length > 16 ? peerId2.slice(0, 16) + "..." : peerId2;
|
|
575461
|
+
let user2 = this._stats.users.get(shortPeer2);
|
|
575462
|
+
if (!user2) {
|
|
575463
|
+
user2 = {
|
|
575464
|
+
ip: shortPeer2,
|
|
575465
|
+
firstSeen: Date.now(),
|
|
575466
|
+
lastSeen: Date.now(),
|
|
575467
|
+
requests: 0,
|
|
575468
|
+
tokensIn: 0,
|
|
575469
|
+
tokensOut: 0,
|
|
575470
|
+
activeRequests: 0,
|
|
575471
|
+
models: /* @__PURE__ */ new Map(),
|
|
575472
|
+
media: /* @__PURE__ */ new Map()
|
|
575473
|
+
};
|
|
575474
|
+
this._stats.users.set(shortPeer2, user2);
|
|
575475
|
+
}
|
|
575476
|
+
user2.requests++;
|
|
575477
|
+
user2.lastSeen = Date.now();
|
|
575478
|
+
let userMedia = user2.media.get(mediaKey2);
|
|
575479
|
+
if (!userMedia) {
|
|
575480
|
+
userMedia = { jobs: 0, bytesOut: 0, failures: 0, lastUsed: 0, totalLatencyMs: 0 };
|
|
575481
|
+
user2.media.set(mediaKey2, userMedia);
|
|
575482
|
+
}
|
|
575483
|
+
userMedia.jobs++;
|
|
575484
|
+
userMedia.bytesOut += outputBytes;
|
|
575485
|
+
userMedia.failures += record.success === false ? 1 : 0;
|
|
575486
|
+
userMedia.lastUsed = Date.now();
|
|
575487
|
+
userMedia.totalLatencyMs += durationMs;
|
|
575488
|
+
this._stats.modelUsage.set(mediaKey2, (this._stats.modelUsage.get(mediaKey2) ?? 0) + 1);
|
|
575489
|
+
continue;
|
|
575490
|
+
}
|
|
574597
575491
|
let tokIn = 0;
|
|
574598
575492
|
let tokOut = 0;
|
|
574599
575493
|
if (typeof record.inputTokens === "number" && typeof record.outputTokens === "number") {
|
|
@@ -574629,7 +575523,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
574629
575523
|
tokensIn: 0,
|
|
574630
575524
|
tokensOut: 0,
|
|
574631
575525
|
activeRequests: 0,
|
|
574632
|
-
models: /* @__PURE__ */ new Map()
|
|
575526
|
+
models: /* @__PURE__ */ new Map(),
|
|
575527
|
+
media: /* @__PURE__ */ new Map()
|
|
574633
575528
|
};
|
|
574634
575529
|
this._stats.users.set(shortPeer, user);
|
|
574635
575530
|
}
|
|
@@ -574684,6 +575579,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
574684
575579
|
this.emit("stats", {
|
|
574685
575580
|
...this._stats,
|
|
574686
575581
|
modelUsage: new Map(this._stats.modelUsage),
|
|
575582
|
+
mediaUsage: new Map(this._stats.mediaUsage),
|
|
574687
575583
|
users: new Map(this._stats.users),
|
|
574688
575584
|
sponsorUsage: this._stats.sponsorUsage ? { ...this._stats.sponsorUsage } : null
|
|
574689
575585
|
});
|
|
@@ -574823,7 +575719,7 @@ var init_types = __esm({
|
|
|
574823
575719
|
});
|
|
574824
575720
|
|
|
574825
575721
|
// packages/cli/src/tui/p2p/secret-vault.ts
|
|
574826
|
-
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes21, scryptSync as scryptSync2, createHash as
|
|
575722
|
+
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes21, scryptSync as scryptSync2, createHash as createHash22 } from "node:crypto";
|
|
574827
575723
|
import { readFileSync as readFileSync72, writeFileSync as writeFileSync46, existsSync as existsSync91, mkdirSync as mkdirSync51 } from "node:fs";
|
|
574828
575724
|
import { dirname as dirname28 } from "node:path";
|
|
574829
575725
|
var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
|
|
@@ -575068,7 +575964,7 @@ var init_secret_vault = __esm({
|
|
|
575068
575964
|
/** Generate a deterministic fingerprint of vault contents (for sync verification) */
|
|
575069
575965
|
fingerprint() {
|
|
575070
575966
|
const names = Array.from(this.secrets.keys()).sort();
|
|
575071
|
-
const hash =
|
|
575967
|
+
const hash = createHash22("sha256");
|
|
575072
575968
|
for (const name10 of names) {
|
|
575073
575969
|
hash.update(name10 + ":");
|
|
575074
575970
|
hash.update(this.secrets.get(name10).value);
|
|
@@ -575083,7 +575979,7 @@ var init_secret_vault = __esm({
|
|
|
575083
575979
|
// packages/cli/src/tui/p2p/peer-mesh.ts
|
|
575084
575980
|
import { EventEmitter as EventEmitter9 } from "node:events";
|
|
575085
575981
|
import { createServer as createServer6 } from "node:http";
|
|
575086
|
-
import { randomBytes as randomBytes22, createHash as
|
|
575982
|
+
import { randomBytes as randomBytes22, createHash as createHash23, generateKeyPairSync } from "node:crypto";
|
|
575087
575983
|
var PING_INTERVAL_MS, PEER_TIMEOUT_MS, GOSSIP_INTERVAL_MS, MAX_PEERS, PeerMesh;
|
|
575088
575984
|
var init_peer_mesh = __esm({
|
|
575089
575985
|
"packages/cli/src/tui/p2p/peer-mesh.ts"() {
|
|
@@ -575100,7 +575996,7 @@ var init_peer_mesh = __esm({
|
|
|
575100
575996
|
const { publicKey: publicKey2, privateKey } = generateKeyPairSync("ed25519");
|
|
575101
575997
|
this.publicKey = publicKey2.export({ type: "spki", format: "der" });
|
|
575102
575998
|
this.privateKey = privateKey.export({ type: "pkcs8", format: "der" });
|
|
575103
|
-
this.peerId =
|
|
575999
|
+
this.peerId = createHash23("sha256").update(this.publicKey).digest("base64url").slice(0, 22);
|
|
575104
576000
|
this.capabilities = options2.capabilities;
|
|
575105
576001
|
this.displayName = options2.displayName;
|
|
575106
576002
|
this._authKey = options2.authKey ?? randomBytes22(24).toString("base64url");
|
|
@@ -576438,7 +577334,7 @@ __export(omnius_directory_exports, {
|
|
|
576438
577334
|
import { appendFileSync as appendFileSync6, cpSync as cpSync2, existsSync as existsSync94, mkdirSync as mkdirSync53, readFileSync as readFileSync75, writeFileSync as writeFileSync48, readdirSync as readdirSync31, statSync as statSync36, unlinkSync as unlinkSync17, openSync as openSync2, closeSync as closeSync2, renameSync as renameSync4, watch as fsWatch2 } from "node:fs";
|
|
576439
577335
|
import { join as join110, relative as relative9, basename as basename21, dirname as dirname31, resolve as resolve41 } from "node:path";
|
|
576440
577336
|
import { homedir as homedir34 } from "node:os";
|
|
576441
|
-
import { createHash as
|
|
577337
|
+
import { createHash as createHash24 } from "node:crypto";
|
|
576442
577338
|
function isGitRoot(dir) {
|
|
576443
577339
|
const gitPath = join110(dir, ".git");
|
|
576444
577340
|
if (!existsSync94(gitPath)) return false;
|
|
@@ -576892,7 +577788,7 @@ function buildHandoffPrompt(repoRoot) {
|
|
|
576892
577788
|
return lines.join("\n");
|
|
576893
577789
|
}
|
|
576894
577790
|
function computeDedupeHash(task, savedAt) {
|
|
576895
|
-
return
|
|
577791
|
+
return createHash24("sha256").update(`${task}|${savedAt}`).digest("hex").slice(0, 16);
|
|
576896
577792
|
}
|
|
576897
577793
|
function generateSessionId() {
|
|
576898
577794
|
const timestamp = Date.now().toString(36);
|
|
@@ -591805,7 +592701,8 @@ function defaultConfig2() {
|
|
|
591805
592701
|
maxRequestsPerMinute: 60,
|
|
591806
592702
|
maxTokensPerDay: 1e5,
|
|
591807
592703
|
maxConcurrent: 5,
|
|
591808
|
-
allowedModels: "all"
|
|
592704
|
+
allowedModels: "all",
|
|
592705
|
+
media: normalizeSponsorMediaConfig(DEFAULT_SPONSOR_MEDIA_LIMITS)
|
|
591809
592706
|
},
|
|
591810
592707
|
cohereEnabled: true,
|
|
591811
592708
|
status: "inactive",
|
|
@@ -591813,6 +592710,10 @@ function defaultConfig2() {
|
|
|
591813
592710
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
591814
592711
|
};
|
|
591815
592712
|
}
|
|
592713
|
+
function normalizeLoadedSponsorConfig(config) {
|
|
592714
|
+
config.rateLimits.media = normalizeSponsorMediaConfig(config.rateLimits.media);
|
|
592715
|
+
return config;
|
|
592716
|
+
}
|
|
591816
592717
|
function endpointAuthToken(authHeader) {
|
|
591817
592718
|
const raw = (authHeader || "").trim();
|
|
591818
592719
|
if (!raw) return void 0;
|
|
@@ -592454,13 +593355,106 @@ async function stepTransport(config, rl, availableRows) {
|
|
|
592454
593355
|
}
|
|
592455
593356
|
return false;
|
|
592456
593357
|
}
|
|
593358
|
+
function mediaLimitSummary(modality, media) {
|
|
593359
|
+
const limits = media[modality];
|
|
593360
|
+
if (modality === "image") {
|
|
593361
|
+
return `${limits.maxConcurrent} concurrent, ${limits.jobsPerDay}/day, ${limits.maxWidth}x${limits.maxHeight}, ${limits.maxSteps} steps`;
|
|
593362
|
+
}
|
|
593363
|
+
if (modality === "video") {
|
|
593364
|
+
return `${limits.maxConcurrent} concurrent, ${limits.jobsPerDay}/day, ${limits.maxDurationSec}s, ${limits.maxFrames} frames, ${limits.maxOutputBytes} bytes`;
|
|
593365
|
+
}
|
|
593366
|
+
return `${limits.maxConcurrent} concurrent, ${limits.jobsPerDay}/day, ${limits.maxDurationSec}s, ${limits.maxOutputBytes} bytes`;
|
|
593367
|
+
}
|
|
593368
|
+
async function stepMedia(config, rl, availableRows) {
|
|
593369
|
+
const media = normalizeSponsorMediaConfig(config.rateLimits.media);
|
|
593370
|
+
config.rateLimits.media = media;
|
|
593371
|
+
const items = [
|
|
593372
|
+
{ key: "hdr", label: "Sponsored Media Generation" },
|
|
593373
|
+
{ key: "desc", label: " Remote consumers use /sponsor image|video|sound|music. Setup/prewarm stays provider-only." }
|
|
593374
|
+
];
|
|
593375
|
+
for (const modality of SPONSOR_MEDIA_MODALITIES) {
|
|
593376
|
+
const limits = media[modality];
|
|
593377
|
+
items.push({
|
|
593378
|
+
key: `toggle:${modality}`,
|
|
593379
|
+
label: ` ${limits.enabled ? "[x]" : "[ ]"} ${modality}`,
|
|
593380
|
+
detail: mediaLimitSummary(modality, media)
|
|
593381
|
+
});
|
|
593382
|
+
}
|
|
593383
|
+
items.push({ key: "sep", label: "" });
|
|
593384
|
+
items.push({ key: "next", label: selectColors.green(" Next Step →") });
|
|
593385
|
+
const updateItem = (item, modality) => {
|
|
593386
|
+
const limits = media[modality];
|
|
593387
|
+
item.label = ` ${limits.enabled ? "[x]" : "[ ]"} ${modality}`;
|
|
593388
|
+
item.detail = mediaLimitSummary(modality, media);
|
|
593389
|
+
};
|
|
593390
|
+
const result = await tuiSelect({
|
|
593391
|
+
items,
|
|
593392
|
+
title: "Step 5/7 — Media Generation",
|
|
593393
|
+
rl,
|
|
593394
|
+
skipKeys: ["hdr", "desc", "sep"],
|
|
593395
|
+
availableRows,
|
|
593396
|
+
customKeyHint: " space/Enter toggle e edit limits",
|
|
593397
|
+
onAction: (item, action) => {
|
|
593398
|
+
if (action !== "space" || !item.key.startsWith("toggle:")) return false;
|
|
593399
|
+
const modality = item.key.slice("toggle:".length);
|
|
593400
|
+
media[modality].enabled = !media[modality].enabled;
|
|
593401
|
+
updateItem(item, modality);
|
|
593402
|
+
return true;
|
|
593403
|
+
},
|
|
593404
|
+
onEnter: (item, helpers) => {
|
|
593405
|
+
if (item.key.startsWith("toggle:")) {
|
|
593406
|
+
const modality = item.key.slice("toggle:".length);
|
|
593407
|
+
media[modality].enabled = !media[modality].enabled;
|
|
593408
|
+
updateItem(item, modality);
|
|
593409
|
+
helpers.render();
|
|
593410
|
+
return true;
|
|
593411
|
+
}
|
|
593412
|
+
return false;
|
|
593413
|
+
},
|
|
593414
|
+
onCustomKey: (item, key, helpers) => {
|
|
593415
|
+
if (key !== "e" && key !== "E" || !item.key.startsWith("toggle:")) return false;
|
|
593416
|
+
const modality = item.key.slice("toggle:".length);
|
|
593417
|
+
const limits = media[modality];
|
|
593418
|
+
helpers.getInput("Max concurrent jobs:", String(limits.maxConcurrent)).then((concurrent) => {
|
|
593419
|
+
const c8 = parseInt(concurrent ?? "", 10);
|
|
593420
|
+
if (Number.isFinite(c8) && c8 > 0) limits.maxConcurrent = c8;
|
|
593421
|
+
helpers.getInput("Jobs/day:", String(limits.jobsPerDay)).then((daily) => {
|
|
593422
|
+
const d2 = parseInt(daily ?? "", 10);
|
|
593423
|
+
if (Number.isFinite(d2) && d2 > 0) limits.jobsPerDay = d2;
|
|
593424
|
+
const durationKey = modality === "image" ? "Max steps:" : "Max duration seconds:";
|
|
593425
|
+
const durationValue = modality === "image" ? limits.maxSteps : limits.maxDurationSec;
|
|
593426
|
+
helpers.getInput(durationKey, String(durationValue ?? "")).then((value2) => {
|
|
593427
|
+
const n2 = parseInt(value2 ?? "", 10);
|
|
593428
|
+
if (Number.isFinite(n2) && n2 > 0) {
|
|
593429
|
+
if (modality === "image") limits.maxSteps = n2;
|
|
593430
|
+
else limits.maxDurationSec = n2;
|
|
593431
|
+
}
|
|
593432
|
+
updateItem(item, modality);
|
|
593433
|
+
helpers.render();
|
|
593434
|
+
});
|
|
593435
|
+
});
|
|
593436
|
+
});
|
|
593437
|
+
return true;
|
|
593438
|
+
},
|
|
593439
|
+
renderRow: (item, focused, _isActive) => {
|
|
593440
|
+
const prefix = focused ? selectColors.blue("❯ ") : " ";
|
|
593441
|
+
if (item.key === "hdr") return selectColors.bold(item.label);
|
|
593442
|
+
if (item.key === "desc") return selectColors.dim(item.label);
|
|
593443
|
+
if (item.detail) return `${prefix}${item.label}
|
|
593444
|
+
${selectColors.dim(item.detail)}`;
|
|
593445
|
+
return `${prefix}${item.label}`;
|
|
593446
|
+
}
|
|
593447
|
+
});
|
|
593448
|
+
if (!result.confirmed) return false;
|
|
593449
|
+
return result.key === "next";
|
|
593450
|
+
}
|
|
592457
593451
|
async function stepCohere(config, rl, availableRows) {
|
|
592458
593452
|
const items = [
|
|
592459
593453
|
{ key: "hdr", label: "COHERE — Distributed Intelligence (Experimental)" },
|
|
592460
593454
|
{ key: "desc1", label: "" },
|
|
592461
593455
|
{ key: "desc2", label: " COHERE lets your node collaborate with other sponsors" },
|
|
592462
593456
|
{ key: "desc3", label: " on the Omnius meshnet. When someone asks a question" },
|
|
592463
|
-
{ key: "desc4", label: " on
|
|
593457
|
+
{ key: "desc4", label: " on openagents.nexus, your node can:" },
|
|
592464
593458
|
{ key: "desc5", label: "" },
|
|
592465
593459
|
{ key: "desc6", label: " • Answer queries using your local models" },
|
|
592466
593460
|
{ key: "desc7", label: " • Bid on questions based on model fit + GPU load" },
|
|
@@ -592480,7 +593474,7 @@ async function stepCohere(config, rl, availableRows) {
|
|
|
592480
593474
|
];
|
|
592481
593475
|
const result = await tuiSelect({
|
|
592482
593476
|
items,
|
|
592483
|
-
title: "Step
|
|
593477
|
+
title: "Step 6/7 — COHERE Distributed Intelligence",
|
|
592484
593478
|
rl,
|
|
592485
593479
|
skipKeys: ["hdr", "desc1", "desc2", "desc3", "desc4", "desc5", "desc6", "desc7", "desc8", "desc9", "desc10", "desc11", "desc12", "desc13", "desc14", "desc15", "desc16", "sep1", "sep2"],
|
|
592486
593480
|
availableRows,
|
|
@@ -592517,6 +593511,9 @@ async function stepReview(config, rl, availableRows) {
|
|
|
592517
593511
|
const transports = [];
|
|
592518
593512
|
if (config.transport.cloudflared) transports.push("Cloudflared Tunnel");
|
|
592519
593513
|
if (config.transport.libp2p) transports.push("libp2p P2P");
|
|
593514
|
+
const media = normalizeSponsorMediaConfig(config.rateLimits.media);
|
|
593515
|
+
config.rateLimits.media = media;
|
|
593516
|
+
const mediaEnabled = SPONSOR_MEDIA_MODALITIES.filter((modality) => media[modality].enabled);
|
|
592520
593517
|
const items = [
|
|
592521
593518
|
{ key: "hdr", label: "Review Sponsorship Configuration" },
|
|
592522
593519
|
{ key: "info_ep", label: ` Endpoints: ${epList}` },
|
|
@@ -592524,16 +593521,17 @@ async function stepReview(config, rl, availableRows) {
|
|
|
592524
593521
|
{ key: "info_link", label: ` Link: ${config.header.linkEnabled ? `${config.header.linkUrl} [${config.header.linkText || config.header.message}]` : "(none)"}` },
|
|
592525
593522
|
{ key: "info_transport", label: ` Transport: ${transports.join(" + ")}` },
|
|
592526
593523
|
{ key: "info_limits", label: ` Limits: ${config.rateLimits.maxRequestsPerMinute} req/min, ${config.rateLimits.maxTokensPerDay.toLocaleString()} tokens/day` },
|
|
593524
|
+
{ key: "info_media", label: ` Media: ${mediaEnabled.length > 0 ? mediaEnabled.join(", ") : "disabled"}` },
|
|
592527
593525
|
{ key: "info_cohere", label: ` COHERE: ${config.cohereEnabled ? "enabled (distributed inference)" : "disabled"}` },
|
|
592528
593526
|
{ key: "sep", label: "" },
|
|
592529
|
-
{ key: "go_live", label: selectColors.green(" ✦ Go Live & Sponsor
|
|
593527
|
+
{ key: "go_live", label: selectColors.green(" ✦ Go Live & Sponsor Services ") },
|
|
592530
593528
|
{ key: "cancel", label: selectColors.dim(" Cancel") }
|
|
592531
593529
|
];
|
|
592532
593530
|
const result = await tuiSelect({
|
|
592533
593531
|
items,
|
|
592534
|
-
title: "Step
|
|
593532
|
+
title: "Step 7/7 — Review & Go Live",
|
|
592535
593533
|
rl,
|
|
592536
|
-
skipKeys: ["hdr", "sep", "info_ep", "info_msg", "info_link", "info_transport", "info_limits", "info_cohere"],
|
|
593534
|
+
skipKeys: ["hdr", "sep", "info_ep", "info_msg", "info_link", "info_transport", "info_limits", "info_media", "info_cohere"],
|
|
592537
593535
|
availableRows
|
|
592538
593536
|
});
|
|
592539
593537
|
if (!result.confirmed || result.key === "cancel") return false;
|
|
@@ -592542,11 +593540,14 @@ async function stepReview(config, rl, availableRows) {
|
|
|
592542
593540
|
async function showSponsorDashboard(config, projectDir2, rl, availableRows, sponsorUsage) {
|
|
592543
593541
|
const isPaused = config.status === "paused";
|
|
592544
593542
|
const enabledEps = config.endpoints.filter((e2) => e2.enabled);
|
|
593543
|
+
config.rateLimits.media = normalizeSponsorMediaConfig(config.rateLimits.media);
|
|
593544
|
+
const enabledMedia = SPONSOR_MEDIA_MODALITIES.filter((modality) => config.rateLimits.media?.[modality]?.enabled);
|
|
592545
593545
|
const dailyTokensLimit = sponsorUsage?.dailyTokensLimit || config.rateLimits.maxTokensPerDay;
|
|
592546
593546
|
const requestsPerMinuteLimit = sponsorUsage?.requestsPerMinuteLimit || config.rateLimits.maxRequestsPerMinute;
|
|
592547
593547
|
const maxConcurrent = sponsorUsage?.maxConcurrent || config.rateLimits.maxConcurrent;
|
|
592548
593548
|
const topModels = (sponsorUsage?.models ?? []).slice(0, 5);
|
|
592549
593549
|
const topPeers = (sponsorUsage?.peers ?? []).slice(0, 5);
|
|
593550
|
+
const topMedia = (sponsorUsage?.media ?? []).slice(0, 5);
|
|
592550
593551
|
const usageItems = [
|
|
592551
593552
|
{
|
|
592552
593553
|
key: "info_usage_totals",
|
|
@@ -592602,12 +593603,23 @@ async function showSponsorDashboard(config, projectDir2, rl, availableRows, spon
|
|
|
592602
593603
|
});
|
|
592603
593604
|
}
|
|
592604
593605
|
}
|
|
593606
|
+
if (topMedia.length > 0) {
|
|
593607
|
+
usageItems.push({ key: "info_usage_media_hdr", label: " Media" });
|
|
593608
|
+
for (const [idx, media] of topMedia.entries()) {
|
|
593609
|
+
const mb = media.bytesOut > 0 ? `${(media.bytesOut / (1024 * 1024)).toFixed(1)}MB` : "0MB";
|
|
593610
|
+
usageItems.push({
|
|
593611
|
+
key: `info_usage_media_${idx}`,
|
|
593612
|
+
label: ` ${media.key}: ${media.jobs} jobs · ${mb}`
|
|
593613
|
+
});
|
|
593614
|
+
}
|
|
593615
|
+
}
|
|
592605
593616
|
const items = [
|
|
592606
593617
|
{ key: "hdr", label: "Sponsor Dashboard" },
|
|
592607
593618
|
{ key: "info_status", label: ` Status: ${isPaused ? "● PAUSED" : "● ACTIVE"}` },
|
|
592608
593619
|
{ key: "info_ep", label: ` Endpoints: ${enabledEps.map((e2) => e2.label).join(", ")}` },
|
|
592609
593620
|
{ key: "info_transport", label: ` Transport: ${[config.transport.cloudflared ? "Cloudflared" : "", config.transport.libp2p ? "libp2p" : ""].filter(Boolean).join(" + ")}` },
|
|
592610
593621
|
{ key: "info_limits", label: ` Limits: ${config.rateLimits.maxRequestsPerMinute} req/min, ${config.rateLimits.maxTokensPerDay.toLocaleString()} tokens/day, ${config.rateLimits.maxConcurrent} concurrent` },
|
|
593622
|
+
{ key: "info_media", label: ` Media: ${enabledMedia.length > 0 ? enabledMedia.join(", ") : "disabled"}` },
|
|
592611
593623
|
{ key: "info_usage_hdr", label: " Usage" },
|
|
592612
593624
|
...usageItems,
|
|
592613
593625
|
{ key: "sep", label: "" },
|
|
@@ -592626,7 +593638,7 @@ async function showSponsorDashboard(config, projectDir2, rl, availableRows, spon
|
|
|
592626
593638
|
return result.key || "close";
|
|
592627
593639
|
}
|
|
592628
593640
|
async function runSponsorWizard(ctx3) {
|
|
592629
|
-
let config = loadSponsorConfig(ctx3.projectDir) || defaultConfig2();
|
|
593641
|
+
let config = normalizeLoadedSponsorConfig(loadSponsorConfig(ctx3.projectDir) || defaultConfig2());
|
|
592630
593642
|
renderInfo("Starting sponsor onboarding wizard...\n");
|
|
592631
593643
|
if (!await stepEndpoints(config, ctx3.ollamaUrl, ctx3.rl, ctx3.availableRows, ctx3.projectDir)) {
|
|
592632
593644
|
renderInfo("Sponsor wizard cancelled.");
|
|
@@ -592644,6 +593656,11 @@ async function runSponsorWizard(ctx3) {
|
|
|
592644
593656
|
return null;
|
|
592645
593657
|
}
|
|
592646
593658
|
saveSponsorConfig(ctx3.projectDir, config);
|
|
593659
|
+
if (!await stepMedia(config, ctx3.rl, ctx3.availableRows)) {
|
|
593660
|
+
renderInfo("Sponsor wizard cancelled.");
|
|
593661
|
+
return null;
|
|
593662
|
+
}
|
|
593663
|
+
saveSponsorConfig(ctx3.projectDir, config);
|
|
592647
593664
|
if (!await stepCohere(config, ctx3.rl, ctx3.availableRows)) {
|
|
592648
593665
|
renderInfo("Sponsor wizard cancelled.");
|
|
592649
593666
|
return null;
|
|
@@ -592685,6 +593702,7 @@ var init_sponsor_wizard = __esm({
|
|
|
592685
593702
|
init_tui_select();
|
|
592686
593703
|
init_render();
|
|
592687
593704
|
init_usage_bars();
|
|
593705
|
+
init_dist5();
|
|
592688
593706
|
}
|
|
592689
593707
|
});
|
|
592690
593708
|
|
|
@@ -596871,6 +597889,7 @@ __export(commands_exports, {
|
|
|
596871
597889
|
});
|
|
596872
597890
|
import * as nodeOs from "node:os";
|
|
596873
597891
|
import { execSync as nodeExecSync } from "node:child_process";
|
|
597892
|
+
import { createHash as createHash25 } from "node:crypto";
|
|
596874
597893
|
import {
|
|
596875
597894
|
existsSync as existsSync107,
|
|
596876
597895
|
readFileSync as readFileSync86,
|
|
@@ -596883,17 +597902,23 @@ import {
|
|
|
596883
597902
|
appendFileSync as appendFileSync8,
|
|
596884
597903
|
writeSync as writeSync2
|
|
596885
597904
|
} from "node:fs";
|
|
596886
|
-
import { relative as relative11, join as join120 } from "node:path";
|
|
597905
|
+
import { basename as basename23, dirname as dirname35, relative as relative11, join as join120 } from "node:path";
|
|
596887
597906
|
async function parseJsonResponse(resp, source) {
|
|
596888
597907
|
const body = await resp.text();
|
|
596889
597908
|
const trimmed = body.trim();
|
|
597909
|
+
const status = resp.status ? ` (HTTP ${resp.status})` : "";
|
|
597910
|
+
const ok3 = typeof resp.ok === "boolean" ? resp.ok : !resp.status || resp.status >= 200 && resp.status < 300;
|
|
597911
|
+
if (!ok3) {
|
|
597912
|
+
const preview = trimmed ? `: ${trimmed.slice(0, 160)}` : "";
|
|
597913
|
+
throw new Error(`${source} request failed${status}${preview}`);
|
|
597914
|
+
}
|
|
596890
597915
|
if (!trimmed) {
|
|
596891
|
-
throw new Error(`${source} returned an empty response${
|
|
597916
|
+
throw new Error(`${source} returned an empty response${status}`);
|
|
596892
597917
|
}
|
|
596893
597918
|
try {
|
|
596894
597919
|
return JSON.parse(trimmed);
|
|
596895
597920
|
} catch {
|
|
596896
|
-
throw new Error(`${source} returned malformed JSON${
|
|
597921
|
+
throw new Error(`${source} returned malformed JSON${status}`);
|
|
596897
597922
|
}
|
|
596898
597923
|
}
|
|
596899
597924
|
async function _immediateReregister(newUrl) {
|
|
@@ -596901,7 +597926,7 @@ async function _immediateReregister(newUrl) {
|
|
|
596901
597926
|
_lastRegisteredSponsorPayload.tunnelUrl = newUrl;
|
|
596902
597927
|
_lastRegisteredSponsorPayload.status = "active";
|
|
596903
597928
|
try {
|
|
596904
|
-
await fetch(
|
|
597929
|
+
await fetch(NEXUS_SPONSORS_URL, {
|
|
596905
597930
|
method: "POST",
|
|
596906
597931
|
headers: { "Content-Type": "application/json" },
|
|
596907
597932
|
body: JSON.stringify(_lastRegisteredSponsorPayload),
|
|
@@ -596966,7 +597991,7 @@ function startSponsorHeartbeat(payload, getExposeGateway) {
|
|
|
596966
597991
|
}
|
|
596967
597992
|
}
|
|
596968
597993
|
try {
|
|
596969
|
-
await fetch(
|
|
597994
|
+
await fetch(NEXUS_SPONSORS_URL, {
|
|
596970
597995
|
method: "POST",
|
|
596971
597996
|
headers: { "Content-Type": "application/json" },
|
|
596972
597997
|
body: JSON.stringify(_lastRegisteredSponsorPayload),
|
|
@@ -597277,12 +598302,12 @@ async function ensureVoiceDeps(ctx3) {
|
|
|
597277
598302
|
renderInfo(res.log.split("\n").slice(-3).join(" ").slice(0, 200));
|
|
597278
598303
|
}
|
|
597279
598304
|
if (typeof mod2.getVenvPython === "function") {
|
|
597280
|
-
const { dirname:
|
|
598305
|
+
const { dirname: dirname44 } = await import("node:path");
|
|
597281
598306
|
const { existsSync: existsSync137 } = await import("node:fs");
|
|
597282
598307
|
const venvPy = mod2.getVenvPython();
|
|
597283
598308
|
if (existsSync137(venvPy)) {
|
|
597284
598309
|
process.env.TRANSCRIBE_PYTHON = venvPy;
|
|
597285
|
-
const venvBin =
|
|
598310
|
+
const venvBin = dirname44(venvPy);
|
|
597286
598311
|
const sep4 = process.platform === "win32" ? ";" : ":";
|
|
597287
598312
|
const cur = process.env.PATH || "";
|
|
597288
598313
|
if (!cur.split(sep4).includes(venvBin)) {
|
|
@@ -601238,6 +602263,11 @@ sleep 1
|
|
|
601238
602263
|
return "handled";
|
|
601239
602264
|
}
|
|
601240
602265
|
case "sponsor": {
|
|
602266
|
+
const mediaCommand = parseSponsorMediaCommand(arg);
|
|
602267
|
+
if (mediaCommand) {
|
|
602268
|
+
await handleSponsorMediaCommand(ctx3, mediaCommand.modality, mediaCommand.rest);
|
|
602269
|
+
return "handled";
|
|
602270
|
+
}
|
|
601241
602271
|
if (!ctx3.rl) {
|
|
601242
602272
|
renderWarning("Sponsor wizard requires interactive mode.");
|
|
601243
602273
|
return "handled";
|
|
@@ -601265,10 +602295,11 @@ sleep 1
|
|
|
601265
602295
|
});
|
|
601266
602296
|
}
|
|
601267
602297
|
try {
|
|
601268
|
-
await fetch(
|
|
602298
|
+
await fetch(NEXUS_SPONSORS_URL, {
|
|
601269
602299
|
method: "POST",
|
|
601270
602300
|
headers: { "Content-Type": "application/json" },
|
|
601271
602301
|
body: JSON.stringify({
|
|
602302
|
+
peerId: pauseGw?.peerId || existingConfig.header?.message || "unknown",
|
|
601272
602303
|
name: existingConfig.header?.message || "unknown",
|
|
601273
602304
|
status: "inactive",
|
|
601274
602305
|
tunnelUrl: pauseGw?.tunnelUrl || ""
|
|
@@ -601308,11 +602339,12 @@ sleep 1
|
|
|
601308
602339
|
);
|
|
601309
602340
|
try {
|
|
601310
602341
|
const retirePayload = {
|
|
602342
|
+
peerId: existingConfig.header?.message || "unknown",
|
|
601311
602343
|
name: existingConfig.header?.message || "unknown",
|
|
601312
602344
|
status: "inactive",
|
|
601313
602345
|
tunnelUrl: ""
|
|
601314
602346
|
};
|
|
601315
|
-
await fetch(
|
|
602347
|
+
await fetch(NEXUS_SPONSORS_URL, {
|
|
601316
602348
|
method: "POST",
|
|
601317
602349
|
headers: { "Content-Type": "application/json" },
|
|
601318
602350
|
body: JSON.stringify(retirePayload),
|
|
@@ -601351,10 +602383,11 @@ sleep 1
|
|
|
601351
602383
|
saveSponsorConfig2(projectDir2, existingConfig);
|
|
601352
602384
|
stopSponsorHeartbeat();
|
|
601353
602385
|
try {
|
|
601354
|
-
await fetch(
|
|
602386
|
+
await fetch(NEXUS_SPONSORS_URL, {
|
|
601355
602387
|
method: "POST",
|
|
601356
602388
|
headers: { "Content-Type": "application/json" },
|
|
601357
602389
|
body: JSON.stringify({
|
|
602390
|
+
peerId: existingConfig.header?.message || "unknown",
|
|
601358
602391
|
name: existingConfig.header?.message || "unknown",
|
|
601359
602392
|
status: "inactive"
|
|
601360
602393
|
}),
|
|
@@ -601371,17 +602404,19 @@ sleep 1
|
|
|
601371
602404
|
if (resumeGw && "setSponsorLimits" in resumeGw) {
|
|
601372
602405
|
resumeGw.setSponsorLimits(existingConfig.rateLimits);
|
|
601373
602406
|
}
|
|
601374
|
-
if (resumeGw?.tunnelUrl) {
|
|
602407
|
+
if (resumeGw?.tunnelUrl || resumeGw?.peerId) {
|
|
601375
602408
|
const resumePayload = {
|
|
602409
|
+
peerId: resumeGw.peerId || existingConfig.header?.message || "unknown",
|
|
602410
|
+
libp2pPeerId: resumeGw.peerId || "",
|
|
601376
602411
|
name: existingConfig.header?.message || "Omnius Sponsor",
|
|
601377
|
-
tunnelUrl: resumeGw.tunnelUrl,
|
|
602412
|
+
tunnelUrl: resumeGw.tunnelUrl || "",
|
|
601378
602413
|
authKey: resumeGw.authKey || "",
|
|
601379
602414
|
models: [],
|
|
601380
602415
|
status: "active"
|
|
601381
602416
|
};
|
|
601382
602417
|
startSponsorHeartbeat(resumePayload, ctx3.getExposeGateway);
|
|
601383
602418
|
try {
|
|
601384
|
-
await fetch(
|
|
602419
|
+
await fetch(NEXUS_SPONSORS_URL, {
|
|
601385
602420
|
method: "POST",
|
|
601386
602421
|
headers: { "Content-Type": "application/json" },
|
|
601387
602422
|
body: JSON.stringify(resumePayload),
|
|
@@ -601484,6 +602519,21 @@ sleep 1
|
|
|
601484
602519
|
if (allModels.length > 0) {
|
|
601485
602520
|
config.rateLimits.allowedModels = allModels;
|
|
601486
602521
|
}
|
|
602522
|
+
config.rateLimits.media = normalizeSponsorMediaConfig(config.rateLimits.media);
|
|
602523
|
+
const sponsorServices = [
|
|
602524
|
+
...allModels.map((model) => ({
|
|
602525
|
+
kind: "llm",
|
|
602526
|
+
capability: `inference:${model.replace(/[^a-zA-Z0-9._-]/g, "_")}`,
|
|
602527
|
+
model,
|
|
602528
|
+
input: ["messages", "prompt"],
|
|
602529
|
+
output: ["text"],
|
|
602530
|
+
limits: {
|
|
602531
|
+
maxRequestsPerMinute: config.rateLimits.maxRequestsPerMinute,
|
|
602532
|
+
maxTokensPerDay: config.rateLimits.maxTokensPerDay
|
|
602533
|
+
}
|
|
602534
|
+
})),
|
|
602535
|
+
...buildSponsorMediaServices(config.rateLimits.media)
|
|
602536
|
+
];
|
|
601487
602537
|
renderInfo(
|
|
601488
602538
|
`Sponsoring ${primaryProvider.label} endpoint: ${new URL(primaryUrl).host}`
|
|
601489
602539
|
);
|
|
@@ -601742,8 +602792,11 @@ sleep 1
|
|
|
601742
602792
|
limits: {
|
|
601743
602793
|
maxRequestsPerMinute: config.rateLimits.maxRequestsPerMinute,
|
|
601744
602794
|
maxTokensPerDay: config.rateLimits.maxTokensPerDay,
|
|
601745
|
-
maxConcurrent: config.rateLimits.maxConcurrent
|
|
602795
|
+
maxConcurrent: config.rateLimits.maxConcurrent,
|
|
602796
|
+
media: config.rateLimits.media
|
|
601746
602797
|
},
|
|
602798
|
+
services: sponsorServices,
|
|
602799
|
+
mediaCapabilities: sponsorServices.filter((service) => service.kind !== "llm"),
|
|
601747
602800
|
banner: "none",
|
|
601748
602801
|
message: config.header.message || sponsorName,
|
|
601749
602802
|
linkUrl: config.header.linkUrl,
|
|
@@ -601758,7 +602811,7 @@ sleep 1
|
|
|
601758
602811
|
};
|
|
601759
602812
|
try {
|
|
601760
602813
|
const kvResp = await fetch(
|
|
601761
|
-
|
|
602814
|
+
NEXUS_SPONSORS_URL,
|
|
601762
602815
|
{
|
|
601763
602816
|
method: "POST",
|
|
601764
602817
|
headers: { "Content-Type": "application/json" },
|
|
@@ -605321,6 +606374,32 @@ function mapNumberRecord(value2) {
|
|
|
605321
606374
|
}
|
|
605322
606375
|
return out;
|
|
605323
606376
|
}
|
|
606377
|
+
function cleanCohereModelName(value2) {
|
|
606378
|
+
const raw = String(value2 ?? "").replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, "").trim();
|
|
606379
|
+
if (!raw) return null;
|
|
606380
|
+
const withoutBadge = raw.replace(/^\[(?:EXPOSED|HIDDEN)\]\s*/i, "").trim();
|
|
606381
|
+
const lower = withoutBadge.toLowerCase();
|
|
606382
|
+
if (lower.startsWith("allowlist:") || lower.startsWith("models exposed:") || lower.startsWith("models available:") || lower.startsWith("endpoint:") || lower.startsWith("source:") || lower.startsWith("url:") || lower.includes("downloaded models") || lower.includes("no filter active") || lower.includes("embed") || lower.includes("nomic-bert") || lower.includes("rerank") || lower.includes("whisper") || lower.includes("tts")) {
|
|
606383
|
+
return null;
|
|
606384
|
+
}
|
|
606385
|
+
const beforeMeta = withoutBadge.split(" (")[0]?.trim() || withoutBadge;
|
|
606386
|
+
if (!beforeMeta || beforeMeta.startsWith("──")) return null;
|
|
606387
|
+
return beforeMeta;
|
|
606388
|
+
}
|
|
606389
|
+
function uniqueCohereModelNames(values) {
|
|
606390
|
+
const out = [];
|
|
606391
|
+
const seen = /* @__PURE__ */ new Set();
|
|
606392
|
+
for (const value2 of values) {
|
|
606393
|
+
const pieces = typeof value2 === "string" && value2.includes(",") ? value2.split(",") : [value2];
|
|
606394
|
+
for (const piece of pieces) {
|
|
606395
|
+
const name10 = cleanCohereModelName(piece);
|
|
606396
|
+
if (!name10 || seen.has(name10)) continue;
|
|
606397
|
+
seen.add(name10);
|
|
606398
|
+
out.push(name10);
|
|
606399
|
+
}
|
|
606400
|
+
}
|
|
606401
|
+
return out;
|
|
606402
|
+
}
|
|
605324
606403
|
function parseCohereStatsOutput(output, isActive = false) {
|
|
605325
606404
|
try {
|
|
605326
606405
|
const parsed = JSON.parse(output);
|
|
@@ -605341,7 +606420,7 @@ function parseCohereStatsOutput(output, isActive = false) {
|
|
|
605341
606420
|
bytesOut: numberField(parsed.bytesOut),
|
|
605342
606421
|
modelsUsed: mapNumberRecord(parsed.modelsUsed),
|
|
605343
606422
|
peersServed: mapNumberRecord(parsed.peersServed),
|
|
605344
|
-
allowedModels: Array.isArray(parsed.allowedModels) ? parsed.allowedModels
|
|
606423
|
+
allowedModels: Array.isArray(parsed.allowedModels) ? uniqueCohereModelNames(parsed.allowedModels) : null,
|
|
605345
606424
|
endpoint: {
|
|
605346
606425
|
source: String(endpointRaw.source ?? "unknown"),
|
|
605347
606426
|
passthrough: endpointRaw.passthrough === true,
|
|
@@ -605378,9 +606457,18 @@ async function fetchCohereDashboardState(ctx3) {
|
|
|
605378
606457
|
if (r2.success) {
|
|
605379
606458
|
try {
|
|
605380
606459
|
const parsed = JSON.parse(r2.output);
|
|
605381
|
-
|
|
606460
|
+
if (Array.isArray(parsed.modelDetails)) {
|
|
606461
|
+
const exposedDetails = parsed.modelDetails.filter((model) => model?.exposed !== false).map((model) => model?.name);
|
|
606462
|
+
state.modelList = uniqueCohereModelNames(exposedDetails);
|
|
606463
|
+
}
|
|
606464
|
+
if (state.modelList.length === 0 && Array.isArray(parsed.exposedModels)) {
|
|
606465
|
+
state.modelList = uniqueCohereModelNames(parsed.exposedModels);
|
|
606466
|
+
}
|
|
606467
|
+
if (state.modelList.length === 0 && Array.isArray(parsed.models)) {
|
|
606468
|
+
state.modelList = uniqueCohereModelNames(parsed.models);
|
|
606469
|
+
}
|
|
605382
606470
|
} catch {
|
|
605383
|
-
state.modelList = r2.output.split("\n")
|
|
606471
|
+
state.modelList = uniqueCohereModelNames(r2.output.split("\n"));
|
|
605384
606472
|
}
|
|
605385
606473
|
}
|
|
605386
606474
|
} catch {
|
|
@@ -605405,8 +606493,8 @@ function cohereStatusLines(stats, modelList) {
|
|
|
605405
606493
|
`Data: in ${formatFileSize(stats.bytesIn)} · out ${formatFileSize(stats.bytesOut)}`,
|
|
605406
606494
|
"",
|
|
605407
606495
|
`Endpoint: ${stats.endpoint.source}${stats.endpoint.passthrough ? " passthrough" : ""}${stats.endpoint.endpointUrl ? ` · ${stats.endpoint.endpointUrl}` : ""}`,
|
|
605408
|
-
`Models
|
|
605409
|
-
`Allowlist: ${stats.allowedModels ? stats.allowedModels.join(", ") || "(empty)" : "
|
|
606496
|
+
`Models exposed: ${modelList.length || stats.endpoint.modelCount}${stats.endpoint.cachedOnly ? " (cached)" : ""}`,
|
|
606497
|
+
`Allowlist: ${stats.allowedModels ? stats.allowedModels.join(", ") || "(empty)" : "ALL (no filter active)"}`,
|
|
605410
606498
|
`Top models: ${modelEntries.length ? modelEntries.slice(0, 5).map(([m2, n2]) => `${m2} (${n2})`).join(", ") : "none yet"}`,
|
|
605411
606499
|
`Peers served: ${peerEntries.length ? peerEntries.slice(0, 5).map(([p2, n2]) => `${p2.slice(0, 20)} (${n2})`).join(", ") : "none yet"}`
|
|
605412
606500
|
];
|
|
@@ -606033,14 +607121,14 @@ async function handleVoiceMenu(ctx3, save2, hasLocal) {
|
|
|
606033
607121
|
if (!jsonDrop.confirmed || !jsonDrop.path) {
|
|
606034
607122
|
continue;
|
|
606035
607123
|
}
|
|
606036
|
-
const { basename:
|
|
607124
|
+
const { basename: basename35, join: pathJoin } = await import("node:path");
|
|
606037
607125
|
const {
|
|
606038
607126
|
copyFileSync: copyFileSync5,
|
|
606039
607127
|
mkdirSync: mkdirSync84,
|
|
606040
607128
|
existsSync: exists2
|
|
606041
607129
|
} = await import("node:fs");
|
|
606042
607130
|
const { homedir: homedir56 } = await import("node:os");
|
|
606043
|
-
const modelName =
|
|
607131
|
+
const modelName = basename35(onnxDrop.path, ".onnx").replace(
|
|
606044
607132
|
/[^a-zA-Z0-9_-]/g,
|
|
606045
607133
|
"-"
|
|
606046
607134
|
);
|
|
@@ -606427,7 +607515,7 @@ async function handleVoiceList(ctx3, focusFilename) {
|
|
|
606427
607515
|
copyFileSync: cpf,
|
|
606428
607516
|
mkdirSync: mkd
|
|
606429
607517
|
} = __require("node:fs");
|
|
606430
|
-
const { basename:
|
|
607518
|
+
const { basename: basename35, join: pjoin } = __require("node:path");
|
|
606431
607519
|
if (!fe(src2)) {
|
|
606432
607520
|
renderError(`File not found: ${src2}`);
|
|
606433
607521
|
helpers.render();
|
|
@@ -606440,7 +607528,7 @@ async function handleVoiceList(ctx3, focusFilename) {
|
|
|
606440
607528
|
"clone-refs"
|
|
606441
607529
|
);
|
|
606442
607530
|
mkd(refsDir, { recursive: true });
|
|
606443
|
-
const destName =
|
|
607531
|
+
const destName = basename35(src2);
|
|
606444
607532
|
const dest = pjoin(refsDir, destName);
|
|
606445
607533
|
cpf(src2, dest);
|
|
606446
607534
|
renderInfo(`Imported "${destName}" → ${dest}`);
|
|
@@ -606924,6 +608012,340 @@ async function handleEndpoint(arg, ctx3, local = false) {
|
|
|
606924
608012
|
);
|
|
606925
608013
|
}
|
|
606926
608014
|
}
|
|
608015
|
+
function parseSponsorMediaCommand(arg) {
|
|
608016
|
+
const trimmed = arg.trim();
|
|
608017
|
+
if (!trimmed) return null;
|
|
608018
|
+
const firstSpace = trimmed.indexOf(" ");
|
|
608019
|
+
const head = (firstSpace >= 0 ? trimmed.slice(0, firstSpace) : trimmed).toLowerCase();
|
|
608020
|
+
if (head !== "image" && head !== "video" && head !== "sound" && head !== "music") return null;
|
|
608021
|
+
return {
|
|
608022
|
+
modality: head,
|
|
608023
|
+
rest: firstSpace >= 0 ? trimmed.slice(firstSpace + 1).trim() : ""
|
|
608024
|
+
};
|
|
608025
|
+
}
|
|
608026
|
+
function parseSponsorMediaArgs(rest) {
|
|
608027
|
+
const tokens = shellLikeTokens(rest);
|
|
608028
|
+
const promptParts = [];
|
|
608029
|
+
const options2 = {};
|
|
608030
|
+
let model;
|
|
608031
|
+
let backend;
|
|
608032
|
+
for (let i2 = 0; i2 < tokens.length; i2++) {
|
|
608033
|
+
const token = tokens[i2];
|
|
608034
|
+
if (!token.startsWith("--")) {
|
|
608035
|
+
promptParts.push(token);
|
|
608036
|
+
continue;
|
|
608037
|
+
}
|
|
608038
|
+
const eq = token.indexOf("=");
|
|
608039
|
+
const key = token.slice(2, eq >= 0 ? eq : void 0).replace(/-/g, "_");
|
|
608040
|
+
const rawValue = eq >= 0 ? token.slice(eq + 1) : tokens[i2 + 1];
|
|
608041
|
+
if (eq < 0 && rawValue && !rawValue.startsWith("--")) i2++;
|
|
608042
|
+
const value2 = coerceSponsorMediaOption(rawValue ?? "true");
|
|
608043
|
+
if (key === "model" && typeof value2 === "string") model = value2;
|
|
608044
|
+
else if (key === "backend" && typeof value2 === "string") backend = value2;
|
|
608045
|
+
else options2[key] = value2;
|
|
608046
|
+
}
|
|
608047
|
+
return { prompt: promptParts.join(" ").trim(), options: options2, model, backend };
|
|
608048
|
+
}
|
|
608049
|
+
function shellLikeTokens(input) {
|
|
608050
|
+
const tokens = [];
|
|
608051
|
+
let current = "";
|
|
608052
|
+
let quote = "";
|
|
608053
|
+
let escaped = false;
|
|
608054
|
+
for (const ch of input) {
|
|
608055
|
+
if (escaped) {
|
|
608056
|
+
current += ch;
|
|
608057
|
+
escaped = false;
|
|
608058
|
+
continue;
|
|
608059
|
+
}
|
|
608060
|
+
if (ch === "\\") {
|
|
608061
|
+
escaped = true;
|
|
608062
|
+
continue;
|
|
608063
|
+
}
|
|
608064
|
+
if (quote) {
|
|
608065
|
+
if (ch === quote) quote = "";
|
|
608066
|
+
else current += ch;
|
|
608067
|
+
continue;
|
|
608068
|
+
}
|
|
608069
|
+
if (ch === "'" || ch === '"') {
|
|
608070
|
+
quote = ch;
|
|
608071
|
+
continue;
|
|
608072
|
+
}
|
|
608073
|
+
if (ch === " " || ch === " ") {
|
|
608074
|
+
if (current) {
|
|
608075
|
+
tokens.push(current);
|
|
608076
|
+
current = "";
|
|
608077
|
+
}
|
|
608078
|
+
continue;
|
|
608079
|
+
}
|
|
608080
|
+
current += ch;
|
|
608081
|
+
}
|
|
608082
|
+
if (current) tokens.push(current);
|
|
608083
|
+
return tokens;
|
|
608084
|
+
}
|
|
608085
|
+
function coerceSponsorMediaOption(value2) {
|
|
608086
|
+
const lower = value2.toLowerCase();
|
|
608087
|
+
if (lower === "true" || lower === "yes" || lower === "on") return true;
|
|
608088
|
+
if (lower === "false" || lower === "no" || lower === "off") return false;
|
|
608089
|
+
const n2 = Number(value2);
|
|
608090
|
+
if (Number.isFinite(n2) && value2.trim() !== "") return n2;
|
|
608091
|
+
return value2;
|
|
608092
|
+
}
|
|
608093
|
+
async function discoverSponsorMediaCandidates(ctx3, modality) {
|
|
608094
|
+
const rawSponsors = [];
|
|
608095
|
+
const projectDir2 = ctx3.repoRoot ?? process.cwd();
|
|
608096
|
+
try {
|
|
608097
|
+
const nexus = new NexusTool(projectDir2);
|
|
608098
|
+
const status = String((await nexus.execute({ action: "status" }))?.output ?? "");
|
|
608099
|
+
if (!/Connected:\s*true/i.test(status) && ctx3.nexusConnect) {
|
|
608100
|
+
await ctx3.nexusConnect();
|
|
608101
|
+
}
|
|
608102
|
+
const discovered = await nexus.execute({ action: "sponsor_discover", timeout_ms: "5000" });
|
|
608103
|
+
const output = String(discovered?.output ?? "");
|
|
608104
|
+
if (output) {
|
|
608105
|
+
const parsed = JSON.parse(output);
|
|
608106
|
+
rawSponsors.push(...Array.isArray(parsed.sponsors) ? parsed.sponsors : []);
|
|
608107
|
+
}
|
|
608108
|
+
} catch {
|
|
608109
|
+
}
|
|
608110
|
+
try {
|
|
608111
|
+
const resp = await fetch(NEXUS_SPONSORS_URL, { signal: AbortSignal.timeout(5e3) });
|
|
608112
|
+
if (resp.ok) {
|
|
608113
|
+
const data = await parseJsonResponse(resp, "Sponsor directory");
|
|
608114
|
+
rawSponsors.push(...(data.sponsors ?? []).filter((s2) => s2.status === "active"));
|
|
608115
|
+
}
|
|
608116
|
+
} catch {
|
|
608117
|
+
}
|
|
608118
|
+
try {
|
|
608119
|
+
const knownFile = join120(projectDir2, ".omnius", "sponsor", "known-sponsors.json");
|
|
608120
|
+
if (existsSync107(knownFile)) {
|
|
608121
|
+
const saved = JSON.parse(readFileSync86(knownFile, "utf8"));
|
|
608122
|
+
if (Array.isArray(saved)) rawSponsors.push(...saved);
|
|
608123
|
+
}
|
|
608124
|
+
} catch {
|
|
608125
|
+
}
|
|
608126
|
+
const seen = /* @__PURE__ */ new Set();
|
|
608127
|
+
const candidates = [];
|
|
608128
|
+
for (const raw of rawSponsors) {
|
|
608129
|
+
const peerId = String(raw?.libp2pPeerId || raw?.peerId || "").trim();
|
|
608130
|
+
if (!peerId) continue;
|
|
608131
|
+
const services = normalizeSponsorServices(raw);
|
|
608132
|
+
const mediaServices = services.filter((service) => service.kind === modality);
|
|
608133
|
+
if (mediaServices.length === 0) continue;
|
|
608134
|
+
const sponsor = {
|
|
608135
|
+
name: String(raw?.name || "Unknown Sponsor"),
|
|
608136
|
+
peerId,
|
|
608137
|
+
authKey: String(raw?.authKey || raw?.auth_key || "").trim() || void 0,
|
|
608138
|
+
services
|
|
608139
|
+
};
|
|
608140
|
+
for (const service of mediaServices) {
|
|
608141
|
+
const key = `${peerId}:${service.capability}`;
|
|
608142
|
+
if (seen.has(key)) continue;
|
|
608143
|
+
seen.add(key);
|
|
608144
|
+
candidates.push({ sponsor, service });
|
|
608145
|
+
}
|
|
608146
|
+
}
|
|
608147
|
+
return candidates;
|
|
608148
|
+
}
|
|
608149
|
+
function normalizeSponsorServices(raw) {
|
|
608150
|
+
const services = Array.isArray(raw?.services) ? raw.services : Array.isArray(raw?.mediaCapabilities) ? raw.mediaCapabilities : [];
|
|
608151
|
+
return services.map((service) => {
|
|
608152
|
+
const kind = String(service?.kind || "");
|
|
608153
|
+
if (kind !== "llm" && kind !== "image" && kind !== "video" && kind !== "sound" && kind !== "music") return null;
|
|
608154
|
+
const capability = String(service?.capability || "").trim();
|
|
608155
|
+
if (!capability) return null;
|
|
608156
|
+
return {
|
|
608157
|
+
kind,
|
|
608158
|
+
capability,
|
|
608159
|
+
model: String(service?.model || "auto"),
|
|
608160
|
+
backend: service?.backend ? String(service.backend) : void 0,
|
|
608161
|
+
input: Array.isArray(service?.input) ? service.input.map(String) : [],
|
|
608162
|
+
output: Array.isArray(service?.output) ? service.output.map(String) : [],
|
|
608163
|
+
limits: service?.limits && typeof service.limits === "object" ? service.limits : {}
|
|
608164
|
+
};
|
|
608165
|
+
}).filter((service) => Boolean(service));
|
|
608166
|
+
}
|
|
608167
|
+
async function handleSponsorMediaCommand(ctx3, modality, rest) {
|
|
608168
|
+
const parsedArgs = parseSponsorMediaArgs(rest);
|
|
608169
|
+
if (!parsedArgs.prompt) {
|
|
608170
|
+
renderInfo(`Usage: /sponsor ${modality} "<prompt>" [--model name] [--backend name]`);
|
|
608171
|
+
return;
|
|
608172
|
+
}
|
|
608173
|
+
renderInfo(`Scanning for sponsored ${modality} generation services...`);
|
|
608174
|
+
const candidates = await discoverSponsorMediaCandidates(ctx3, modality);
|
|
608175
|
+
if (candidates.length === 0) {
|
|
608176
|
+
renderWarning(`No sponsored ${modality} generation services found.`);
|
|
608177
|
+
return;
|
|
608178
|
+
}
|
|
608179
|
+
let selected = candidates[0];
|
|
608180
|
+
if (ctx3.rl && candidates.length > 1) {
|
|
608181
|
+
const items = [
|
|
608182
|
+
{ key: "hdr", label: `Sponsored ${modality} Services` },
|
|
608183
|
+
...candidates.map((candidate, index) => ({
|
|
608184
|
+
key: String(index),
|
|
608185
|
+
label: ` ${candidate.sponsor.name}`,
|
|
608186
|
+
detail: `${candidate.service.capability} · model ${candidate.service.model || "auto"}`
|
|
608187
|
+
}))
|
|
608188
|
+
];
|
|
608189
|
+
const result2 = await tuiSelect({
|
|
608190
|
+
items,
|
|
608191
|
+
title: `Choose Sponsored ${modality}`,
|
|
608192
|
+
rl: ctx3.rl,
|
|
608193
|
+
skipKeys: ["hdr"],
|
|
608194
|
+
availableRows: ctx3.availableContentRows?.()
|
|
608195
|
+
});
|
|
608196
|
+
if (!result2.confirmed) {
|
|
608197
|
+
renderInfo("Cancelled.");
|
|
608198
|
+
return;
|
|
608199
|
+
}
|
|
608200
|
+
selected = candidates[Number(result2.key) || 0] ?? selected;
|
|
608201
|
+
}
|
|
608202
|
+
const projectDir2 = ctx3.repoRoot ?? process.cwd();
|
|
608203
|
+
const streamDir = join120(projectDir2, ".omnius", "sponsor", "streams");
|
|
608204
|
+
mkdirSync59(streamDir, { recursive: true });
|
|
608205
|
+
const streamFile = join120(streamDir, `media-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.jsonl`);
|
|
608206
|
+
writeFileSync54(streamFile, "", "utf8");
|
|
608207
|
+
const request = {
|
|
608208
|
+
modality,
|
|
608209
|
+
prompt: parsedArgs.prompt,
|
|
608210
|
+
...parsedArgs.model ? { model: parsedArgs.model } : {},
|
|
608211
|
+
...parsedArgs.backend ? { backend: parsedArgs.backend } : {},
|
|
608212
|
+
options: parsedArgs.options,
|
|
608213
|
+
...selected.sponsor.authKey ? { auth_key: selected.sponsor.authKey } : {}
|
|
608214
|
+
};
|
|
608215
|
+
renderInfo(`Requesting ${modality} from ${selected.sponsor.name} (${selected.service.capability})...`);
|
|
608216
|
+
const nexus = new NexusTool(projectDir2);
|
|
608217
|
+
const start2 = await nexus.execute({
|
|
608218
|
+
action: "invoke_capability",
|
|
608219
|
+
target_peer: selected.sponsor.peerId,
|
|
608220
|
+
capability: selected.service.capability,
|
|
608221
|
+
input: JSON.stringify(request),
|
|
608222
|
+
stream_file: streamFile
|
|
608223
|
+
});
|
|
608224
|
+
if (!start2.success) {
|
|
608225
|
+
renderError(start2.error || start2.output || "Remote media invocation failed to start.");
|
|
608226
|
+
return;
|
|
608227
|
+
}
|
|
608228
|
+
const result = await collectSponsorMediaStream({
|
|
608229
|
+
streamFile,
|
|
608230
|
+
outputRoot: join120(projectDir2, ".omnius", "remote-media", selected.sponsor.peerId.slice(0, 16)),
|
|
608231
|
+
modality
|
|
608232
|
+
});
|
|
608233
|
+
if (!result.ok) {
|
|
608234
|
+
renderError(result.error);
|
|
608235
|
+
return;
|
|
608236
|
+
}
|
|
608237
|
+
renderInfo(`${modality} generated: ${result.path}`);
|
|
608238
|
+
if (result.metadata?.model) renderInfo(`Model: ${result.metadata.model}`);
|
|
608239
|
+
}
|
|
608240
|
+
async function collectSponsorMediaStream(args) {
|
|
608241
|
+
mkdirSync59(args.outputRoot, { recursive: true });
|
|
608242
|
+
let offset = 0;
|
|
608243
|
+
let pending2 = "";
|
|
608244
|
+
let done = false;
|
|
608245
|
+
let lastProgress = "";
|
|
608246
|
+
let metadata = null;
|
|
608247
|
+
const artifacts = /* @__PURE__ */ new Map();
|
|
608248
|
+
const deadline = Date.now() + 30 * 60 * 1e3;
|
|
608249
|
+
while (!done && Date.now() < deadline) {
|
|
608250
|
+
await new Promise((resolve56) => setTimeout(resolve56, 250));
|
|
608251
|
+
if (!existsSync107(args.streamFile)) continue;
|
|
608252
|
+
const raw = readFileSync86(args.streamFile, "utf8");
|
|
608253
|
+
if (raw.length <= offset) continue;
|
|
608254
|
+
pending2 += raw.slice(offset);
|
|
608255
|
+
offset = raw.length;
|
|
608256
|
+
const lines = pending2.split("\n");
|
|
608257
|
+
pending2 = lines.pop() ?? "";
|
|
608258
|
+
for (const line of lines) {
|
|
608259
|
+
if (!line.trim()) continue;
|
|
608260
|
+
let eventLine;
|
|
608261
|
+
try {
|
|
608262
|
+
eventLine = JSON.parse(line);
|
|
608263
|
+
} catch {
|
|
608264
|
+
continue;
|
|
608265
|
+
}
|
|
608266
|
+
if (eventLine.type === "done") {
|
|
608267
|
+
done = true;
|
|
608268
|
+
continue;
|
|
608269
|
+
}
|
|
608270
|
+
if (eventLine.type === "error") {
|
|
608271
|
+
return { ok: false, error: String(eventLine.error || "Remote media stream failed") };
|
|
608272
|
+
}
|
|
608273
|
+
if (eventLine.type !== "event") continue;
|
|
608274
|
+
if (eventLine.event === "error") {
|
|
608275
|
+
return { ok: false, error: String(eventLine.data || "Remote media generation failed") };
|
|
608276
|
+
}
|
|
608277
|
+
const payload = parseMaybeJson(eventLine.data);
|
|
608278
|
+
if (eventLine.event === "progress") {
|
|
608279
|
+
const msg = String(payload?.message || payload?.stage || eventLine.data || "");
|
|
608280
|
+
if (msg && msg !== lastProgress) {
|
|
608281
|
+
lastProgress = msg;
|
|
608282
|
+
renderInfo(`${args.modality}: ${msg}`);
|
|
608283
|
+
}
|
|
608284
|
+
continue;
|
|
608285
|
+
}
|
|
608286
|
+
if (eventLine.event === "artifact.begin") {
|
|
608287
|
+
const artifactId2 = String(payload?.artifactId || "artifact");
|
|
608288
|
+
artifacts.set(artifactId2, {
|
|
608289
|
+
filename: String(payload?.filename || `${artifactId2}${defaultExtensionForMime(String(payload?.mime || ""))}`),
|
|
608290
|
+
mime: String(payload?.mime || mediaMimeFromPath(payload?.filename || "", args.modality)),
|
|
608291
|
+
chunks: [],
|
|
608292
|
+
sizeBytes: typeof payload?.sizeBytes === "number" ? payload.sizeBytes : void 0,
|
|
608293
|
+
sha256: typeof payload?.sha256 === "string" ? payload.sha256 : void 0
|
|
608294
|
+
});
|
|
608295
|
+
continue;
|
|
608296
|
+
}
|
|
608297
|
+
if (eventLine.event === "artifact.chunk") {
|
|
608298
|
+
const artifactId2 = String(payload?.artifactId || "artifact");
|
|
608299
|
+
let artifact2 = artifacts.get(artifactId2);
|
|
608300
|
+
if (!artifact2) {
|
|
608301
|
+
artifact2 = { filename: `${artifactId2}.bin`, mime: "application/octet-stream", chunks: [] };
|
|
608302
|
+
artifacts.set(artifactId2, artifact2);
|
|
608303
|
+
}
|
|
608304
|
+
if (typeof payload?.dataBase64 === "string") {
|
|
608305
|
+
artifact2.chunks.push(Buffer.from(payload.dataBase64, "base64"));
|
|
608306
|
+
}
|
|
608307
|
+
continue;
|
|
608308
|
+
}
|
|
608309
|
+
if (eventLine.event === "artifact.end") {
|
|
608310
|
+
const artifactId2 = String(payload?.artifactId || "artifact");
|
|
608311
|
+
const artifact2 = artifacts.get(artifactId2);
|
|
608312
|
+
if (artifact2) {
|
|
608313
|
+
artifact2.sha256 = String(payload?.sha256 || artifact2.sha256 || "");
|
|
608314
|
+
artifact2.sizeBytes = typeof payload?.sizeBytes === "number" ? payload.sizeBytes : artifact2.sizeBytes;
|
|
608315
|
+
}
|
|
608316
|
+
continue;
|
|
608317
|
+
}
|
|
608318
|
+
if (eventLine.event === "result") {
|
|
608319
|
+
metadata = payload;
|
|
608320
|
+
}
|
|
608321
|
+
}
|
|
608322
|
+
}
|
|
608323
|
+
if (!done) return { ok: false, error: "Remote media stream timed out." };
|
|
608324
|
+
const first2 = artifacts.entries().next();
|
|
608325
|
+
if (first2.done) return { ok: false, error: "Remote media completed without an artifact." };
|
|
608326
|
+
const [artifactId, artifact] = first2.value;
|
|
608327
|
+
const bytes = Buffer.concat(artifact.chunks);
|
|
608328
|
+
if (artifact.sizeBytes !== void 0 && bytes.length !== artifact.sizeBytes) {
|
|
608329
|
+
return { ok: false, error: `Artifact size mismatch for ${artifactId}: ${bytes.length}/${artifact.sizeBytes}` };
|
|
608330
|
+
}
|
|
608331
|
+
if (artifact.sha256) {
|
|
608332
|
+
const sha = createHash25("sha256").update(bytes).digest("hex");
|
|
608333
|
+
if (sha !== artifact.sha256) return { ok: false, error: `Artifact hash mismatch for ${artifactId}` };
|
|
608334
|
+
}
|
|
608335
|
+
const safeName3 = basename23(artifact.filename).replace(/[^\w.-]/g, "_") || `artifact${defaultExtensionForMime(artifact.mime)}`;
|
|
608336
|
+
const outputPath3 = join120(args.outputRoot, safeName3);
|
|
608337
|
+
mkdirSync59(dirname35(outputPath3), { recursive: true });
|
|
608338
|
+
writeFileSync54(outputPath3, bytes);
|
|
608339
|
+
return { ok: true, path: outputPath3, metadata };
|
|
608340
|
+
}
|
|
608341
|
+
function parseMaybeJson(value2) {
|
|
608342
|
+
if (typeof value2 !== "string") return value2;
|
|
608343
|
+
try {
|
|
608344
|
+
return JSON.parse(value2);
|
|
608345
|
+
} catch {
|
|
608346
|
+
return value2;
|
|
608347
|
+
}
|
|
608348
|
+
}
|
|
606927
608349
|
async function handleSponsoredEndpoint(ctx3, local) {
|
|
606928
608350
|
renderInfo("Scanning for sponsored inference endpoints...");
|
|
606929
608351
|
const sponsors = [];
|
|
@@ -607029,6 +608451,8 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
607029
608451
|
peerId: ns.peerId || void 0,
|
|
607030
608452
|
authKey: ns.authKey || "",
|
|
607031
608453
|
models: Array.isArray(ns.models) ? ns.models : (ns.models || "").split(",").filter(Boolean),
|
|
608454
|
+
services: normalizeSponsorServices(ns),
|
|
608455
|
+
mediaCapabilities: normalizeSponsorServices(ns).filter((service) => service.kind !== "llm"),
|
|
607032
608456
|
limits: {
|
|
607033
608457
|
rpm: ns.limits?.maxRequestsPerMinute || 60,
|
|
607034
608458
|
tpd: ns.limits?.maxTokensPerDay || 1e5
|
|
@@ -607072,7 +608496,7 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
607072
608496
|
}
|
|
607073
608497
|
}
|
|
607074
608498
|
try {
|
|
607075
|
-
const kvResp = await fetch(
|
|
608499
|
+
const kvResp = await fetch(NEXUS_SPONSORS_URL, {
|
|
607076
608500
|
signal: AbortSignal.timeout(5e3)
|
|
607077
608501
|
});
|
|
607078
608502
|
if (kvResp.ok) {
|
|
@@ -607093,6 +608517,8 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
607093
608517
|
peerId: ks.peerId || void 0,
|
|
607094
608518
|
authKey: ks.authKey || "",
|
|
607095
608519
|
models: Array.isArray(ks.models) ? ks.models : [],
|
|
608520
|
+
services: normalizeSponsorServices(ks),
|
|
608521
|
+
mediaCapabilities: normalizeSponsorServices(ks).filter((service) => service.kind !== "llm"),
|
|
607096
608522
|
limits: {
|
|
607097
608523
|
rpm: ks.limits?.maxRequestsPerMinute || 60,
|
|
607098
608524
|
tpd: ks.limits?.maxTokensPerDay || 1e5
|
|
@@ -607274,7 +608700,8 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
607274
608700
|
selected.peerId,
|
|
607275
608701
|
selected.authKey || void 0,
|
|
607276
608702
|
ctx3,
|
|
607277
|
-
local
|
|
608703
|
+
local,
|
|
608704
|
+
selected.models
|
|
607278
608705
|
);
|
|
607279
608706
|
} else {
|
|
607280
608707
|
renderError(
|
|
@@ -607305,7 +608732,7 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
607305
608732
|
}
|
|
607306
608733
|
renderInfo(`Connected to sponsored endpoint: ${selected.name}`);
|
|
607307
608734
|
}
|
|
607308
|
-
async function handlePeerEndpoint(peerId, authKey, ctx3, local) {
|
|
608735
|
+
async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels = []) {
|
|
607309
608736
|
process.stdout.write(`
|
|
607310
608737
|
${c3.dim("Detected:")} ${c3.bold("libp2p peer")}
|
|
607311
608738
|
`);
|
|
@@ -607380,19 +608807,28 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local) {
|
|
|
607380
608807
|
|
|
607381
608808
|
`
|
|
607382
608809
|
);
|
|
608810
|
+
let models = [];
|
|
607383
608811
|
try {
|
|
607384
|
-
|
|
608812
|
+
models = await fetchModels(peerUrl, authKey);
|
|
608813
|
+
if (models.length === 0 && advertisedModels.length > 0) {
|
|
608814
|
+
models = advertisedModels.map((name10) => ({
|
|
608815
|
+
name: name10,
|
|
608816
|
+
size: "unknown",
|
|
608817
|
+
modified: "",
|
|
608818
|
+
sizeBytes: 0
|
|
608819
|
+
}));
|
|
608820
|
+
}
|
|
607385
608821
|
if (models.length > 0) {
|
|
607386
608822
|
try {
|
|
607387
608823
|
const { writeFileSync: writeFileSync76, mkdirSync: mkdirSync84 } = await import("node:fs");
|
|
607388
|
-
const { join: join154, dirname:
|
|
608824
|
+
const { join: join154, dirname: dirname44 } = await import("node:path");
|
|
607389
608825
|
const cachePath = join154(
|
|
607390
608826
|
ctx3.repoRoot || process.cwd(),
|
|
607391
608827
|
".omnius",
|
|
607392
608828
|
"nexus",
|
|
607393
608829
|
"peer-models-cache.json"
|
|
607394
608830
|
);
|
|
607395
|
-
mkdirSync84(
|
|
608831
|
+
mkdirSync84(dirname44(cachePath), { recursive: true });
|
|
607396
608832
|
writeFileSync76(
|
|
607397
608833
|
cachePath,
|
|
607398
608834
|
JSON.stringify(
|
|
@@ -607456,9 +608892,48 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local) {
|
|
|
607456
608892
|
);
|
|
607457
608893
|
}
|
|
607458
608894
|
} catch {
|
|
607459
|
-
|
|
607460
|
-
|
|
607461
|
-
|
|
608895
|
+
if (advertisedModels.length > 0) {
|
|
608896
|
+
models = advertisedModels.map((name10) => ({
|
|
608897
|
+
name: name10,
|
|
608898
|
+
size: "unknown",
|
|
608899
|
+
modified: "",
|
|
608900
|
+
sizeBytes: 0
|
|
608901
|
+
}));
|
|
608902
|
+
renderWarning("Live model probe failed; using sponsor directory model advertisement.");
|
|
608903
|
+
try {
|
|
608904
|
+
const { writeFileSync: writeFileSync76, mkdirSync: mkdirSync84 } = await import("node:fs");
|
|
608905
|
+
const { join: join154, dirname: dirname44 } = await import("node:path");
|
|
608906
|
+
const cachePath = join154(
|
|
608907
|
+
ctx3.repoRoot || process.cwd(),
|
|
608908
|
+
".omnius",
|
|
608909
|
+
"nexus",
|
|
608910
|
+
"peer-models-cache.json"
|
|
608911
|
+
);
|
|
608912
|
+
mkdirSync84(dirname44(cachePath), { recursive: true });
|
|
608913
|
+
writeFileSync76(
|
|
608914
|
+
cachePath,
|
|
608915
|
+
JSON.stringify({
|
|
608916
|
+
peerId,
|
|
608917
|
+
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
608918
|
+
models: models.map((m2) => ({ name: m2.name, size: m2.size, parameterSize: m2.parameterSize }))
|
|
608919
|
+
}, null, 2)
|
|
608920
|
+
);
|
|
608921
|
+
} catch {
|
|
608922
|
+
}
|
|
608923
|
+
const currentModel = ctx3.config.model;
|
|
608924
|
+
const found = findModel(models, currentModel);
|
|
608925
|
+
if (!found && models.length > 0) {
|
|
608926
|
+
const autoModel = models[0].name;
|
|
608927
|
+
ctx3.setModel(autoModel);
|
|
608928
|
+
if (local) ctx3.saveLocalSettings({ model: autoModel });
|
|
608929
|
+
else ctx3.saveSettings({ model: autoModel });
|
|
608930
|
+
renderModelSwitch(currentModel, autoModel);
|
|
608931
|
+
}
|
|
608932
|
+
} else {
|
|
608933
|
+
renderWarning(
|
|
608934
|
+
"Could not discover models on peer. Use /models to try again later."
|
|
608935
|
+
);
|
|
608936
|
+
}
|
|
607462
608937
|
}
|
|
607463
608938
|
ctx3.refreshModelCache?.();
|
|
607464
608939
|
if (ctx3.hasActiveTask?.()) {
|
|
@@ -608367,10 +609842,10 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
608367
609842
|
try {
|
|
608368
609843
|
const { createRequire: createRequire10 } = await import("node:module");
|
|
608369
609844
|
const { fileURLToPath: fileURLToPath21 } = await import("node:url");
|
|
608370
|
-
const { dirname:
|
|
609845
|
+
const { dirname: dirname44, join: join154 } = await import("node:path");
|
|
608371
609846
|
const { existsSync: existsSync137 } = await import("node:fs");
|
|
608372
609847
|
const req2 = createRequire10(import.meta.url);
|
|
608373
|
-
const thisDir =
|
|
609848
|
+
const thisDir = dirname44(fileURLToPath21(import.meta.url));
|
|
608374
609849
|
const candidates = [
|
|
608375
609850
|
join154(thisDir, "..", "package.json"),
|
|
608376
609851
|
join154(thisDir, "..", "..", "package.json"),
|
|
@@ -609941,7 +611416,7 @@ async function showExposeDashboard(gateway, rl, ctx3) {
|
|
|
609941
611416
|
renderInfo("Expose gateway stopped.");
|
|
609942
611417
|
}
|
|
609943
611418
|
}
|
|
609944
|
-
var _sponsorHeartbeatTimer, _lastRegisteredSponsorPayload, __COMMAND_REGISTRY, DASH_INTERNAL;
|
|
611419
|
+
var NEXUS_DIRECTORY_ORIGIN, NEXUS_SPONSORS_URL, _sponsorHeartbeatTimer, _lastRegisteredSponsorPayload, __COMMAND_REGISTRY, DASH_INTERNAL;
|
|
609945
611420
|
var init_commands = __esm({
|
|
609946
611421
|
"packages/cli/src/tui/commands.ts"() {
|
|
609947
611422
|
"use strict";
|
|
@@ -609972,6 +611447,8 @@ var init_commands = __esm({
|
|
|
609972
611447
|
init_audio_waveform();
|
|
609973
611448
|
init_neovim_mode();
|
|
609974
611449
|
init_daemon_registry();
|
|
611450
|
+
NEXUS_DIRECTORY_ORIGIN = (process.env["OMNIUS_NEXUS_DIRECTORY_ORIGIN"] || process.env["OMNIUS_NEXUS_SIGNALING_SERVER"] || "https://openagents.nexus").replace(/\/+$/, "");
|
|
611451
|
+
NEXUS_SPONSORS_URL = `${NEXUS_DIRECTORY_ORIGIN}/api/v1/sponsors`;
|
|
609975
611452
|
_sponsorHeartbeatTimer = null;
|
|
609976
611453
|
_lastRegisteredSponsorPayload = null;
|
|
609977
611454
|
__COMMAND_REGISTRY = /* @__PURE__ */ new Map();
|
|
@@ -610214,7 +611691,7 @@ var init_commands = __esm({
|
|
|
610214
611691
|
|
|
610215
611692
|
// packages/cli/src/tui/project-context.ts
|
|
610216
611693
|
import { existsSync as existsSync108, readFileSync as readFileSync87, readdirSync as readdirSync36 } from "node:fs";
|
|
610217
|
-
import { join as join121, basename as
|
|
611694
|
+
import { join as join121, basename as basename24 } from "node:path";
|
|
610218
611695
|
import { execSync as execSync54 } from "node:child_process";
|
|
610219
611696
|
import { homedir as homedir42 } from "node:os";
|
|
610220
611697
|
function getModelTier(modelName) {
|
|
@@ -610295,7 +611772,7 @@ function loadMemoryContext(repoRoot) {
|
|
|
610295
611772
|
try {
|
|
610296
611773
|
const raw = readFileSync87(join121(dir, file), "utf-8");
|
|
610297
611774
|
const entries = JSON.parse(raw);
|
|
610298
|
-
const topic =
|
|
611775
|
+
const topic = basename24(file, ".json");
|
|
610299
611776
|
for (const [k, v] of Object.entries(entries)) {
|
|
610300
611777
|
if (!v?.value) continue;
|
|
610301
611778
|
all2.push({ topic, key: k, value: String(v.value), scope, ts: v.timestamp ?? "" });
|
|
@@ -610559,7 +612036,7 @@ __export(visual_identity_association_exports, {
|
|
|
610559
612036
|
formatVisualIdentityAssociationContext: () => formatVisualIdentityAssociationContext,
|
|
610560
612037
|
stageVisualIdentityAssertion: () => stageVisualIdentityAssertion
|
|
610561
612038
|
});
|
|
610562
|
-
import { basename as
|
|
612039
|
+
import { basename as basename25 } from "node:path";
|
|
610563
612040
|
function normalizePersonName(name10) {
|
|
610564
612041
|
return name10.trim().toLowerCase().replace(/\s+/g, " ");
|
|
610565
612042
|
}
|
|
@@ -610881,7 +612358,7 @@ async function associateVisualIdentityFromImage(options2) {
|
|
|
610881
612358
|
relation: "same_person_candidate",
|
|
610882
612359
|
confidence: match.confidence,
|
|
610883
612360
|
assertedBy: { id: "visual_memory", displayName: "visual_memory", isBot: true },
|
|
610884
|
-
note: `Prior enrolled visual-memory face match for ${
|
|
612361
|
+
note: `Prior enrolled visual-memory face match for ${basename25(options2.imagePath)}`
|
|
610885
612362
|
}]
|
|
610886
612363
|
});
|
|
610887
612364
|
if (result2.episodeId) committedEpisodeIds.push(result2.episodeId);
|
|
@@ -610926,7 +612403,7 @@ async function associateVisualIdentityFromImage(options2) {
|
|
|
610926
612403
|
relation: "depicts",
|
|
610927
612404
|
confidence: item.confidence,
|
|
610928
612405
|
assertedBy: item.sender || options2.sender,
|
|
610929
|
-
note: item.note || `Applied explicit pending identity assertion to ${
|
|
612406
|
+
note: item.note || `Applied explicit pending identity assertion to ${basename25(options2.imagePath)}`
|
|
610930
612407
|
}]
|
|
610931
612408
|
});
|
|
610932
612409
|
if (result2.episodeId) committedEpisodeIds.push(result2.episodeId);
|
|
@@ -610984,7 +612461,7 @@ var init_visual_identity_association = __esm({
|
|
|
610984
612461
|
|
|
610985
612462
|
// packages/cli/src/tui/identity-memory-tool.ts
|
|
610986
612463
|
import { existsSync as existsSync109 } from "node:fs";
|
|
610987
|
-
import { basename as
|
|
612464
|
+
import { basename as basename26, extname as extname14, resolve as resolve45 } from "node:path";
|
|
610988
612465
|
function personKey2(name10) {
|
|
610989
612466
|
return `person:${name10.trim().toLowerCase().replace(/\s+/g, " ")}`;
|
|
610990
612467
|
}
|
|
@@ -611053,7 +612530,7 @@ async function resolveMediaFromArgs(args, opts) {
|
|
|
611053
612530
|
path: path12,
|
|
611054
612531
|
media,
|
|
611055
612532
|
modality: inferModality(media),
|
|
611056
|
-
label:
|
|
612533
|
+
label: basename26(path12)
|
|
611057
612534
|
};
|
|
611058
612535
|
}
|
|
611059
612536
|
function edgeDirection(edge, nodeId, otherText) {
|
|
@@ -611211,7 +612688,7 @@ var init_identity_memory_tool = __esm({
|
|
|
611211
612688
|
} else if (shouldEnrollFace) {
|
|
611212
612689
|
faceLine = "face enrollment: skipped because no resolved image path was available";
|
|
611213
612690
|
}
|
|
611214
|
-
const mediaLine = resolvedMedia ? `media: ${resolvedMedia.label ||
|
|
612691
|
+
const mediaLine = resolvedMedia ? `media: ${resolvedMedia.label || basename26(resolvedMedia.path)} (${resolvedMedia.path})` : "media: none; stored as scoped textual identity evidence only";
|
|
611215
612692
|
const output = [
|
|
611216
612693
|
`Stored identity evidence for ${name10}.`,
|
|
611217
612694
|
`relation: ${relation}`,
|
|
@@ -612152,7 +613629,7 @@ var init_banner = __esm({
|
|
|
612152
613629
|
|
|
612153
613630
|
// packages/cli/src/tui/carousel-descriptors.ts
|
|
612154
613631
|
import { existsSync as existsSync111, readFileSync as readFileSync89, writeFileSync as writeFileSync56, mkdirSync as mkdirSync62, readdirSync as readdirSync37 } from "node:fs";
|
|
612155
|
-
import { join as join124, basename as
|
|
613632
|
+
import { join as join124, basename as basename27 } from "node:path";
|
|
612156
613633
|
function loadToolProfile(repoRoot) {
|
|
612157
613634
|
const filePath = join124(repoRoot, OMNIUS_DIR, "context", TOOL_PROFILE_FILE);
|
|
612158
613635
|
try {
|
|
@@ -612248,7 +613725,7 @@ function generateDescriptors(repoRoot) {
|
|
|
612248
613725
|
extractFromSessions(repoRoot, tags);
|
|
612249
613726
|
extractFromMemory(repoRoot, tags);
|
|
612250
613727
|
extractFromToolProfile(profile, tags);
|
|
612251
|
-
const repoName2 =
|
|
613728
|
+
const repoName2 = basename27(repoRoot);
|
|
612252
613729
|
if (repoName2 && !tags.includes(repoName2)) {
|
|
612253
613730
|
tags.push(repoName2);
|
|
612254
613731
|
}
|
|
@@ -613428,7 +614905,7 @@ var init_edit_history = __esm({
|
|
|
613428
614905
|
|
|
613429
614906
|
// packages/cli/src/tui/promptLoader.ts
|
|
613430
614907
|
import { readFileSync as readFileSync90, existsSync as existsSync112 } from "node:fs";
|
|
613431
|
-
import { join as join126, dirname as
|
|
614908
|
+
import { join as join126, dirname as dirname36 } from "node:path";
|
|
613432
614909
|
import { fileURLToPath as fileURLToPath16 } from "node:url";
|
|
613433
614910
|
function loadPrompt3(promptPath, vars) {
|
|
613434
614911
|
let content = cache7.get(promptPath);
|
|
@@ -613448,7 +614925,7 @@ var init_promptLoader3 = __esm({
|
|
|
613448
614925
|
"packages/cli/src/tui/promptLoader.ts"() {
|
|
613449
614926
|
"use strict";
|
|
613450
614927
|
__filename5 = fileURLToPath16(import.meta.url);
|
|
613451
|
-
__dirname6 =
|
|
614928
|
+
__dirname6 = dirname36(__filename5);
|
|
613452
614929
|
devPath2 = join126(__dirname6, "..", "..", "prompts");
|
|
613453
614930
|
publishedPath2 = join126(__dirname6, "..", "prompts");
|
|
613454
614931
|
PROMPTS_DIR3 = existsSync112(devPath2) ? devPath2 : publishedPath2;
|
|
@@ -613458,7 +614935,7 @@ var init_promptLoader3 = __esm({
|
|
|
613458
614935
|
|
|
613459
614936
|
// packages/cli/src/tui/dream-engine.ts
|
|
613460
614937
|
import { mkdirSync as mkdirSync64, writeFileSync as writeFileSync57, readFileSync as readFileSync91, existsSync as existsSync113, readdirSync as readdirSync38 } from "node:fs";
|
|
613461
|
-
import { join as join127, basename as
|
|
614938
|
+
import { join as join127, basename as basename28 } from "node:path";
|
|
613462
614939
|
import { execSync as execSync55 } from "node:child_process";
|
|
613463
614940
|
function setDreamWriteContent(fn) {
|
|
613464
614941
|
_dreamWriteContent = fn;
|
|
@@ -613671,7 +615148,7 @@ var init_dream_engine = __esm({
|
|
|
613671
615148
|
const rawPath = String(args["path"] ?? "");
|
|
613672
615149
|
const content = String(args["content"] ?? "");
|
|
613673
615150
|
if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
|
|
613674
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join127(this.autoresearchDir,
|
|
615151
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join127(this.autoresearchDir, basename28(rawPath)) : join127(this.autoresearchDir, rawPath);
|
|
613675
615152
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
613676
615153
|
return { success: false, output: "", error: "Autoresearch mode: writes are confined to .omnius/autoresearch/", durationMs: Date.now() - start2 };
|
|
613677
615154
|
}
|
|
@@ -613706,7 +615183,7 @@ var init_dream_engine = __esm({
|
|
|
613706
615183
|
const rawPath = String(args["path"] ?? "");
|
|
613707
615184
|
const oldStr = String(args["old_string"] ?? "");
|
|
613708
615185
|
const newStr = String(args["new_string"] ?? "");
|
|
613709
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join127(this.autoresearchDir,
|
|
615186
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join127(this.autoresearchDir, basename28(rawPath)) : join127(this.autoresearchDir, rawPath);
|
|
613710
615187
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
613711
615188
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .omnius/autoresearch/", durationMs: Date.now() - start2 };
|
|
613712
615189
|
}
|
|
@@ -613759,7 +615236,7 @@ var init_dream_engine = __esm({
|
|
|
613759
615236
|
const rawPath = String(args["path"] ?? "");
|
|
613760
615237
|
const content = String(args["content"] ?? "");
|
|
613761
615238
|
if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
|
|
613762
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join127(this.dreamsDir,
|
|
615239
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join127(this.dreamsDir, basename28(rawPath)) : join127(this.dreamsDir, rawPath);
|
|
613763
615240
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
613764
615241
|
return { success: false, output: "", error: "Dream mode: writes are confined to .omnius/dreams/", durationMs: Date.now() - start2 };
|
|
613765
615242
|
}
|
|
@@ -613794,7 +615271,7 @@ var init_dream_engine = __esm({
|
|
|
613794
615271
|
const rawPath = String(args["path"] ?? "");
|
|
613795
615272
|
const oldStr = String(args["old_string"] ?? "");
|
|
613796
615273
|
const newStr = String(args["new_string"] ?? "");
|
|
613797
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join127(this.dreamsDir,
|
|
615274
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join127(this.dreamsDir, basename28(rawPath)) : join127(this.dreamsDir, rawPath);
|
|
613798
615275
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
613799
615276
|
return { success: false, output: "", error: "Dream mode: edits are confined to .omnius/dreams/", durationMs: Date.now() - start2 };
|
|
613800
615277
|
}
|
|
@@ -615395,7 +616872,7 @@ var init_bless_engine = __esm({
|
|
|
615395
616872
|
|
|
615396
616873
|
// packages/cli/src/tui/dmn-engine.ts
|
|
615397
616874
|
import { existsSync as existsSync114, readFileSync as readFileSync92, writeFileSync as writeFileSync58, mkdirSync as mkdirSync65, readdirSync as readdirSync39, unlinkSync as unlinkSync21 } from "node:fs";
|
|
615398
|
-
import { join as join128, basename as
|
|
616875
|
+
import { join as join128, basename as basename29 } from "node:path";
|
|
615399
616876
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
615400
616877
|
const competenceReport = competence.length > 0 ? competence.map((c8) => {
|
|
615401
616878
|
const rate = c8.attempts > 0 ? Math.round(c8.successes / c8.attempts * 100) : 0;
|
|
@@ -616146,7 +617623,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
616146
617623
|
try {
|
|
616147
617624
|
const files = readdirSync39(dir).filter((f2) => f2.endsWith(".json"));
|
|
616148
617625
|
for (const f2 of files) {
|
|
616149
|
-
const topic =
|
|
617626
|
+
const topic = basename29(f2, ".json");
|
|
616150
617627
|
if (!topics.includes(topic)) topics.push(topic);
|
|
616151
617628
|
}
|
|
616152
617629
|
} catch {
|
|
@@ -616200,7 +617677,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
616200
617677
|
|
|
616201
617678
|
// packages/cli/src/tui/snr-engine.ts
|
|
616202
617679
|
import { existsSync as existsSync115, readdirSync as readdirSync40, readFileSync as readFileSync93 } from "node:fs";
|
|
616203
|
-
import { join as join129, basename as
|
|
617680
|
+
import { join as join129, basename as basename30 } from "node:path";
|
|
616204
617681
|
function computeDPrime(signalScores, noiseScores) {
|
|
616205
617682
|
if (signalScores.length === 0 || noiseScores.length === 0) return 0;
|
|
616206
617683
|
const mean = (arr) => arr.reduce((s2, v) => s2 + v, 0) / arr.length;
|
|
@@ -616494,7 +617971,7 @@ Call task_complete with the JSON array when done.`,
|
|
|
616494
617971
|
try {
|
|
616495
617972
|
const files = readdirSync40(dir).filter((f2) => f2.endsWith(".json"));
|
|
616496
617973
|
for (const f2 of files) {
|
|
616497
|
-
const topic =
|
|
617974
|
+
const topic = basename30(f2, ".json");
|
|
616498
617975
|
if (topics.length > 0 && !topics.includes(topic)) continue;
|
|
616499
617976
|
try {
|
|
616500
617977
|
const data = JSON.parse(readFileSync93(join129(dir, f2), "utf-8"));
|
|
@@ -617977,8 +619454,8 @@ import {
|
|
|
617977
619454
|
} from "node:fs";
|
|
617978
619455
|
import { mkdir as mkdir19 } from "node:fs/promises";
|
|
617979
619456
|
import {
|
|
617980
|
-
basename as
|
|
617981
|
-
dirname as
|
|
619457
|
+
basename as basename31,
|
|
619458
|
+
dirname as dirname37,
|
|
617982
619459
|
extname as extname15,
|
|
617983
619460
|
isAbsolute as isAbsolute7,
|
|
617984
619461
|
join as join130,
|
|
@@ -618142,7 +619619,7 @@ function scopedTool(base3, root, mode) {
|
|
|
618142
619619
|
if (mode === "edit" && !existsSync116(guarded.path.abs)) {
|
|
618143
619620
|
const materialized = materializeTelegramCreativeArtifactForSend(rootAbs, guarded.path.rel);
|
|
618144
619621
|
if (!materialized.ok) return denied(materialized.error);
|
|
618145
|
-
mkdirSync66(
|
|
619622
|
+
mkdirSync66(dirname37(guarded.path.abs), { recursive: true });
|
|
618146
619623
|
writeFileSync59(guarded.path.abs, readFileSync94(materialized.path));
|
|
618147
619624
|
materialized.cleanup?.();
|
|
618148
619625
|
restoredEditPath = guarded.path.abs;
|
|
@@ -618211,7 +619688,7 @@ function guardPath(root, rawPath) {
|
|
|
618211
619688
|
error: `Path escapes the public creative workspace. Use a relative path under ${rootAbs}.`
|
|
618212
619689
|
};
|
|
618213
619690
|
}
|
|
618214
|
-
if (
|
|
619691
|
+
if (basename31(abs) === MANIFEST_FILE) {
|
|
618215
619692
|
return { ok: false, error: "The creative workspace manifest is internal and cannot be edited." };
|
|
618216
619693
|
}
|
|
618217
619694
|
return { ok: true, path: { abs, rel } };
|
|
@@ -618303,7 +619780,7 @@ function rememberCreated(root, absPath) {
|
|
|
618303
619780
|
manifest.objects[rel] = {
|
|
618304
619781
|
logicalRel: rel,
|
|
618305
619782
|
storedRel,
|
|
618306
|
-
originalName:
|
|
619783
|
+
originalName: basename31(guarded.path.abs),
|
|
618307
619784
|
prefixBytes: prefix.length,
|
|
618308
619785
|
encrypted: true,
|
|
618309
619786
|
key: key.toString("base64"),
|
|
@@ -618354,7 +619831,7 @@ function materializeTelegramCreativeArtifactForSend(root, rawPath) {
|
|
|
618354
619831
|
}
|
|
618355
619832
|
const stageDir = join130(rootAbs, SEND_DIR, `${Date.now()}-${randomBytes23(8).toString("hex")}`);
|
|
618356
619833
|
mkdirSync66(stageDir, { recursive: true });
|
|
618357
|
-
const staged = join130(stageDir, object.originalName ||
|
|
619834
|
+
const staged = join130(stageDir, object.originalName || basename31(rel));
|
|
618358
619835
|
writeFileSync59(staged, payload);
|
|
618359
619836
|
return {
|
|
618360
619837
|
ok: true,
|
|
@@ -618522,7 +619999,7 @@ var init_telegram_creative_tools = __esm({
|
|
|
618522
619999
|
}
|
|
618523
620000
|
let result;
|
|
618524
620001
|
try {
|
|
618525
|
-
await mkdir19(
|
|
620002
|
+
await mkdir19(dirname37(guarded.path.abs), { recursive: true });
|
|
618526
620003
|
const tts = new TtsGenerateTool();
|
|
618527
620004
|
result = await tts.execute({
|
|
618528
620005
|
text,
|
|
@@ -619024,7 +620501,7 @@ var init_soul_observations = __esm({
|
|
|
619024
620501
|
// packages/cli/src/tui/telegram-channel-dmn.ts
|
|
619025
620502
|
import { existsSync as existsSync117, mkdirSync as mkdirSync67, readdirSync as readdirSync41, readFileSync as readFileSync95, writeFileSync as writeFileSync60 } from "node:fs";
|
|
619026
620503
|
import { join as join131 } from "node:path";
|
|
619027
|
-
import { createHash as
|
|
620504
|
+
import { createHash as createHash26 } from "node:crypto";
|
|
619028
620505
|
function safeFilePart(value2) {
|
|
619029
620506
|
return value2.replace(/[^A-Za-z0-9_.-]+/g, "_").slice(0, 80) || "telegram";
|
|
619030
620507
|
}
|
|
@@ -619032,7 +620509,7 @@ function daydreamRoot(repoRoot) {
|
|
|
619032
620509
|
return join131(repoRoot, ".omnius", "telegram-daydreams");
|
|
619033
620510
|
}
|
|
619034
620511
|
function sessionDir(repoRoot, sessionKey) {
|
|
619035
|
-
const hash =
|
|
620512
|
+
const hash = createHash26("sha1").update(sessionKey).digest("hex").slice(0, 20);
|
|
619036
620513
|
return join131(daydreamRoot(repoRoot), safeFilePart(hash));
|
|
619037
620514
|
}
|
|
619038
620515
|
function compactLine2(value2, max = 220) {
|
|
@@ -619117,7 +620594,7 @@ function buildReplyOpportunities(input, openQuestions) {
|
|
|
619117
620594
|
return opportunities;
|
|
619118
620595
|
}
|
|
619119
620596
|
function daydreamOpportunityId(input, trigger) {
|
|
619120
|
-
return
|
|
620597
|
+
return createHash26("sha1").update(`${input.sessionKey}:${input.generatedAtMs}:${trigger}`).digest("hex").slice(0, 16);
|
|
619121
620598
|
}
|
|
619122
620599
|
function clamp019(value2) {
|
|
619123
620600
|
if (!Number.isFinite(value2)) return 0;
|
|
@@ -619437,7 +620914,7 @@ function buildTelegramChannelDaydream(input, corpus, extraction, extractionCommi
|
|
|
619437
620914
|
const seed = `${input.sessionKey}:${input.generatedAtMs}:${input.history.length}`;
|
|
619438
620915
|
return {
|
|
619439
620916
|
version: 3,
|
|
619440
|
-
id:
|
|
620917
|
+
id: createHash26("sha1").update(seed).digest("hex").slice(0, 16),
|
|
619441
620918
|
sessionKey: input.sessionKey,
|
|
619442
620919
|
chatId: input.chatId,
|
|
619443
620920
|
chatTitle: input.chatTitle,
|
|
@@ -619650,12 +621127,12 @@ var init_telegram_channel_dmn = __esm({
|
|
|
619650
621127
|
});
|
|
619651
621128
|
|
|
619652
621129
|
// packages/cli/src/tui/telegram-reflection-corpus.ts
|
|
619653
|
-
import { createHash as
|
|
621130
|
+
import { createHash as createHash27 } from "node:crypto";
|
|
619654
621131
|
function telegramReflectionMemoryDbPaths(repoRoot) {
|
|
619655
621132
|
return omniusMemoryDbPaths(repoRoot);
|
|
619656
621133
|
}
|
|
619657
621134
|
function stableHash2(value2, length4 = 16) {
|
|
619658
|
-
return
|
|
621135
|
+
return createHash27("sha1").update(value2).digest("hex").slice(0, length4);
|
|
619659
621136
|
}
|
|
619660
621137
|
function clean3(value2) {
|
|
619661
621138
|
return String(value2 ?? "").replace(/\s+/g, " ").trim();
|
|
@@ -620385,7 +621862,7 @@ var init_telegram_reflection_extraction = __esm({
|
|
|
620385
621862
|
});
|
|
620386
621863
|
|
|
620387
621864
|
// packages/cli/src/tui/telegram-social-state-types.ts
|
|
620388
|
-
import { createHash as
|
|
621865
|
+
import { createHash as createHash28 } from "node:crypto";
|
|
620389
621866
|
function telegramSocialActorKey(actor) {
|
|
620390
621867
|
if (!actor) return "unknown";
|
|
620391
621868
|
if (typeof actor.userId === "number") return `user:${actor.userId}`;
|
|
@@ -620409,7 +621886,7 @@ function appendUnique(items, value2, max) {
|
|
|
620409
621886
|
return next.slice(-max);
|
|
620410
621887
|
}
|
|
620411
621888
|
function hashTelegramSocialId(parts) {
|
|
620412
|
-
return
|
|
621889
|
+
return createHash28("sha1").update(parts.map((part) => String(part ?? "")).join(":")).digest("hex").slice(0, 16);
|
|
620413
621890
|
}
|
|
620414
621891
|
function cleanUsername(value2) {
|
|
620415
621892
|
if (typeof value2 !== "string") return void 0;
|
|
@@ -621187,10 +622664,10 @@ var init_vision_ingress = __esm({
|
|
|
621187
622664
|
|
|
621188
622665
|
// packages/cli/src/tui/telegram-bridge.ts
|
|
621189
622666
|
import { mkdirSync as mkdirSync68, existsSync as existsSync119, unlinkSync as unlinkSync24, readdirSync as readdirSync42, statSync as statSync43, statfsSync as statfsSync5, readFileSync as readFileSync97, writeFileSync as writeFileSync62, appendFileSync as appendFileSync10 } from "node:fs";
|
|
621190
|
-
import { join as join133, resolve as resolve47, basename as
|
|
622667
|
+
import { join as join133, resolve as resolve47, basename as basename32, relative as relative13, isAbsolute as isAbsolute8, extname as extname16 } from "node:path";
|
|
621191
622668
|
import { homedir as homedir43 } from "node:os";
|
|
621192
622669
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
621193
|
-
import { createHash as
|
|
622670
|
+
import { createHash as createHash29, randomBytes as randomBytes24, randomInt } from "node:crypto";
|
|
621194
622671
|
function cleanTelegramDecisionNote(value2, maxLength = 260) {
|
|
621195
622672
|
if (typeof value2 !== "string") return void 0;
|
|
621196
622673
|
const clean5 = stripTelegramHiddenThinking(value2).replace(/\s+/g, " ").trim();
|
|
@@ -622129,7 +623606,7 @@ function buildTelegramRuntimeContext(now = /* @__PURE__ */ new Date(), repoRoot)
|
|
|
622129
623606
|
].filter(Boolean).join("\n");
|
|
622130
623607
|
}
|
|
622131
623608
|
function telegramSessionIdFromKey(sessionKey) {
|
|
622132
|
-
return `telegram-${
|
|
623609
|
+
return `telegram-${createHash29("sha1").update(sessionKey).digest("hex").slice(0, 16)}`;
|
|
622133
623610
|
}
|
|
622134
623611
|
function normalizeTelegramSubAgentLimit(value2) {
|
|
622135
623612
|
const parsed = typeof value2 === "number" ? value2 : typeof value2 === "string" && value2.trim() ? Number(value2.trim()) : TELEGRAM_SUB_AGENT_DEFAULT_LIMIT;
|
|
@@ -623744,7 +625221,7 @@ External acquisition contract:
|
|
|
623744
625221
|
return !!this.adminAuthChallenge && this.adminAuthChallenge.expiresAtMs > Date.now();
|
|
623745
625222
|
}
|
|
623746
625223
|
hashAdminAuthCode(code8) {
|
|
623747
|
-
return
|
|
625224
|
+
return createHash29("sha256").update(`omnius-telegram-admin:${code8.trim()}`).digest("hex");
|
|
623748
625225
|
}
|
|
623749
625226
|
viewIdForMessage(msg) {
|
|
623750
625227
|
return `telegram-${this.sessionKeyForMessage(msg).replace(/[^A-Za-z0-9_-]/g, "-")}`;
|
|
@@ -624667,11 +626144,11 @@ ${mediaContext}` : ""
|
|
|
624667
626144
|
return payload;
|
|
624668
626145
|
}
|
|
624669
626146
|
telegramConversationPath(sessionKey) {
|
|
624670
|
-
const safe =
|
|
626147
|
+
const safe = createHash29("sha1").update(sessionKey).digest("hex").slice(0, 20);
|
|
624671
626148
|
return join133(this.telegramConversationDir, `${safe}.json`);
|
|
624672
626149
|
}
|
|
624673
626150
|
telegramConversationLedgerPath(sessionKey) {
|
|
624674
|
-
const safe =
|
|
626151
|
+
const safe = createHash29("sha1").update(sessionKey).digest("hex").slice(0, 20);
|
|
624675
626152
|
return join133(this.telegramConversationDir, `${safe}.events.jsonl`);
|
|
624676
626153
|
}
|
|
624677
626154
|
telegramDb() {
|
|
@@ -624899,7 +626376,7 @@ ${mediaContext}` : ""
|
|
|
624899
626376
|
users,
|
|
624900
626377
|
relationships: Array.isArray(raw.relationships) ? raw.relationships.slice(0, TELEGRAM_ASSOCIATIVE_RELATION_LIMIT).map((fact) => this.normalizeTelegramAssociativeFact(fact)) : [],
|
|
624901
626378
|
actions: Array.isArray(raw.actions) ? raw.actions.slice(-TELEGRAM_ASSOCIATIVE_ACTION_LIMIT).map((action) => ({
|
|
624902
|
-
id: String(action.id ||
|
|
626379
|
+
id: String(action.id || createHash29("sha1").update(JSON.stringify(action)).digest("hex").slice(0, 12)),
|
|
624903
626380
|
ts: typeof action.ts === "number" ? action.ts : Date.now(),
|
|
624904
626381
|
role: action.role === "assistant" ? "assistant" : "user",
|
|
624905
626382
|
speaker: String(action.speaker || "unknown"),
|
|
@@ -624916,7 +626393,7 @@ ${mediaContext}` : ""
|
|
|
624916
626393
|
const text = String(raw.text || "").trim();
|
|
624917
626394
|
const now = Date.now();
|
|
624918
626395
|
return {
|
|
624919
|
-
id: String(raw.id ||
|
|
626396
|
+
id: String(raw.id || createHash29("sha1").update(text || String(now)).digest("hex").slice(0, 12)),
|
|
624920
626397
|
text,
|
|
624921
626398
|
tags: Array.isArray(raw.tags) ? raw.tags.map(String).slice(0, 16) : [],
|
|
624922
626399
|
speakers: Array.isArray(raw.speakers) ? raw.speakers.map(String).slice(0, 16) : [],
|
|
@@ -625118,7 +626595,7 @@ ${mediaContext}` : ""
|
|
|
625118
626595
|
}
|
|
625119
626596
|
telegramHistoryBackfillMessageId(sessionKey, entry, index) {
|
|
625120
626597
|
if (typeof entry.messageId === "number" && Number.isFinite(entry.messageId)) return entry.messageId;
|
|
625121
|
-
const digest3 =
|
|
626598
|
+
const digest3 = createHash29("sha1").update(`${sessionKey}:${index}:${entry.role}:${entry.ts ?? ""}:${entry.text}`).digest("hex").slice(0, 8);
|
|
625122
626599
|
return -Number.parseInt(digest3, 16);
|
|
625123
626600
|
}
|
|
625124
626601
|
backfillTelegramLoadedHistory(sessionKey, history) {
|
|
@@ -625889,7 +627366,7 @@ ${mediaContext}` : ""
|
|
|
625889
627366
|
}
|
|
625890
627367
|
const matchingEntry = mediaEntries.find((entry) => {
|
|
625891
627368
|
if (resolve47(entry.localPath) === resolve47(raw)) return true;
|
|
625892
|
-
if (
|
|
627369
|
+
if (basename32(entry.localPath) === raw) return true;
|
|
625893
627370
|
if (entry.fileUniqueId === raw || entry.fileId === raw) return true;
|
|
625894
627371
|
if (entry.messageId && String(entry.messageId) === raw) return true;
|
|
625895
627372
|
if (entry.messageId && `message_id:${entry.messageId}` === raw.toLowerCase()) return true;
|
|
@@ -625926,7 +627403,7 @@ ${mediaContext}` : ""
|
|
|
625926
627403
|
}
|
|
625927
627404
|
return entries.find((entry2) => {
|
|
625928
627405
|
if (resolve47(entry2.localPath) === resolve47(ref)) return true;
|
|
625929
|
-
if (
|
|
627406
|
+
if (basename32(entry2.localPath) === ref) return true;
|
|
625930
627407
|
if (entry2.fileUniqueId === ref || entry2.fileId === ref) return true;
|
|
625931
627408
|
if (entry2.messageId && String(entry2.messageId) === ref) return true;
|
|
625932
627409
|
return false;
|
|
@@ -625954,7 +627431,7 @@ ${mediaContext}` : ""
|
|
|
625954
627431
|
caption: entry.caption
|
|
625955
627432
|
},
|
|
625956
627433
|
modality,
|
|
625957
|
-
label: `Telegram message_id ${entry.messageId || "unknown"} ${
|
|
627434
|
+
label: `Telegram message_id ${entry.messageId || "unknown"} ${basename32(entry.localPath)}`,
|
|
625958
627435
|
extractedContent: entry.extractedContent
|
|
625959
627436
|
};
|
|
625960
627437
|
}
|
|
@@ -626011,7 +627488,7 @@ ${mediaContext}` : ""
|
|
|
626011
627488
|
const now = entry.ts ?? Date.now();
|
|
626012
627489
|
memory.updatedAt = now;
|
|
626013
627490
|
const speaker = telegramHistorySpeaker(entry);
|
|
626014
|
-
const actionId =
|
|
627491
|
+
const actionId = createHash29("sha1").update(`${sessionKey}:${entry.role}:${entry.messageId ?? ""}:${now}:${entry.text}`).digest("hex").slice(0, 16);
|
|
626015
627492
|
if (!memory.actions.some((action) => action.id === actionId)) {
|
|
626016
627493
|
memory.actions.push({
|
|
626017
627494
|
id: actionId,
|
|
@@ -626133,7 +627610,7 @@ ${mediaContext}` : ""
|
|
|
626133
627610
|
let fact = facts.find((item) => item.text.toLowerCase() === key);
|
|
626134
627611
|
if (!fact) {
|
|
626135
627612
|
fact = {
|
|
626136
|
-
id:
|
|
627613
|
+
id: createHash29("sha1").update(`${entry.chatId ?? ""}:${key}`).digest("hex").slice(0, 12),
|
|
626137
627614
|
text: clean5,
|
|
626138
627615
|
tags: telegramMemoryTags(clean5, entry.mediaSummary),
|
|
626139
627616
|
speakers: [],
|
|
@@ -626188,7 +627665,7 @@ ${mediaContext}` : ""
|
|
|
626188
627665
|
const titleTags = tags.slice(0, 4);
|
|
626189
627666
|
const title = titleTags.length > 0 ? `${speaker} / ${titleTags.join(" ")}` : `${speaker} / conversation`;
|
|
626190
627667
|
const card = {
|
|
626191
|
-
id:
|
|
627668
|
+
id: createHash29("sha1").update(`${sessionKey}:${now}:${speaker}:${text}`).digest("hex").slice(0, 12),
|
|
626192
627669
|
title,
|
|
626193
627670
|
notes: [],
|
|
626194
627671
|
tags: [],
|
|
@@ -626905,8 +628382,8 @@ ${cardLines.join("\n")}`);
|
|
|
626905
628382
|
const caption = entry.caption ? ` caption=${telegramContextJsonString(entry.caption, 120)}` : "";
|
|
626906
628383
|
const extracted = entry.extractedContent ? `
|
|
626907
628384
|
extracted=${telegramContextJsonString(entry.extractedContent.replace(/\s+/g, " "), 220)}` : "";
|
|
626908
|
-
const alias = entry.messageId ? `message_id:${entry.messageId}` :
|
|
626909
|
-
return `- ${alias}${replyMark}: ${kind}; file ${
|
|
628385
|
+
const alias = entry.messageId ? `message_id:${entry.messageId}` : basename32(entry.localPath);
|
|
628386
|
+
return `- ${alias}${replyMark}: ${kind}; file ${basename32(entry.localPath)}${caption}${extracted}`;
|
|
626910
628387
|
});
|
|
626911
628388
|
sections.push([
|
|
626912
628389
|
"### Recent Chat Media",
|
|
@@ -628330,7 +629807,7 @@ ${list}` : "No shared group target is currently known for this sender. Ask in th
|
|
|
628330
629807
|
}
|
|
628331
629808
|
telegramRunnerStateDir(sessionKey) {
|
|
628332
629809
|
if (!this.repoRoot) return void 0;
|
|
628333
|
-
const safe =
|
|
629810
|
+
const safe = createHash29("sha1").update(sessionKey).digest("hex").slice(0, 20);
|
|
628334
629811
|
return join133(this.repoRoot, ".omnius", "telegram-runner-state", safe);
|
|
628335
629812
|
}
|
|
628336
629813
|
buildTelegramAdminOverviewContext(currentSessionKey) {
|
|
@@ -631781,12 +633258,12 @@ Scoped workspace: ${scopedRoot}`,
|
|
|
631781
633258
|
return { success: true, output: `No recent ${kind} media is available in this Telegram chat scope.`, durationMs: performance.now() - start2 };
|
|
631782
633259
|
}
|
|
631783
633260
|
const lines = entries.map((entry, index) => {
|
|
631784
|
-
const pathAlias = entry.messageId ? `message_id:${entry.messageId}` :
|
|
633261
|
+
const pathAlias = entry.messageId ? `message_id:${entry.messageId}` : basename32(entry.localPath);
|
|
631785
633262
|
const parts = [
|
|
631786
633263
|
`${index + 1}. message_id ${entry.messageId || "unknown"}`,
|
|
631787
633264
|
currentMsg?.replyToMessageId === entry.messageId ? "replied-to" : "",
|
|
631788
633265
|
telegramCachedMediaIsImage(entry) ? "image" : telegramCachedMediaIsPdf(entry) ? "pdf" : telegramCachedMediaIsAudio(entry) ? "audio" : telegramCachedMediaIsVideo(entry) ? "video" : entry.mediaType,
|
|
631789
|
-
`file=${
|
|
633266
|
+
`file=${basename32(entry.localPath)}`,
|
|
631790
633267
|
`path_alias=${pathAlias}`,
|
|
631791
633268
|
entry.caption ? `caption=${telegramContextJsonString(entry.caption, 140)}` : ""
|
|
631792
633269
|
].filter(Boolean);
|
|
@@ -631913,8 +633390,8 @@ Scoped workspace: ${scopedRoot}`,
|
|
|
631913
633390
|
if (bridge.telegramFileSendAlreadyDeliveredForMessage(currentMsg, sendFingerprint)) {
|
|
631914
633391
|
return {
|
|
631915
633392
|
success: true,
|
|
631916
|
-
output: `Telegram file already sent in this turn: ${
|
|
631917
|
-
llmContent: `Already sent ${
|
|
633393
|
+
output: `Telegram file already sent in this turn: ${basename32(file.path)} as ${kind} to ${String(target.chatId)}`,
|
|
633394
|
+
llmContent: `Already sent ${basename32(file.path)} to Telegram as ${kind}; do not send it again.`,
|
|
631918
633395
|
durationMs: performance.now() - start2,
|
|
631919
633396
|
mutated: false,
|
|
631920
633397
|
mutatedFiles: []
|
|
@@ -631931,8 +633408,8 @@ Scoped workspace: ${scopedRoot}`,
|
|
|
631931
633408
|
bridge.rememberTelegramDeliveredArtifactForMessage(currentMsg, ledgerPath);
|
|
631932
633409
|
return {
|
|
631933
633410
|
success: true,
|
|
631934
|
-
output: `Sent Telegram file: ${
|
|
631935
|
-
llmContent: `Sent ${
|
|
633411
|
+
output: `Sent Telegram file: ${basename32(file.path)} as ${kind} to ${String(target.chatId)}${messageId ? ` (message_id ${messageId})` : ""}`,
|
|
633412
|
+
llmContent: `Sent ${basename32(file.path)} to Telegram as ${kind}.`,
|
|
631936
633413
|
durationMs: performance.now() - start2,
|
|
631937
633414
|
mutated: false,
|
|
631938
633415
|
mutatedFiles: []
|
|
@@ -632417,7 +633894,7 @@ ${text}`.trim());
|
|
|
632417
633894
|
if (!existsSync119(media.value)) throw new Error(`File does not exist: ${media.value}`);
|
|
632418
633895
|
const buffer2 = readFileSync97(media.value);
|
|
632419
633896
|
const boundary = `----omnius-media-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
632420
|
-
const filename =
|
|
633897
|
+
const filename = basename32(media.value);
|
|
632421
633898
|
const contentType = mimeForPath(media.value, media.kind);
|
|
632422
633899
|
const parts = [];
|
|
632423
633900
|
const addField = (name10, value2) => {
|
|
@@ -632657,7 +634134,7 @@ Content-Type: ${contentType}\r
|
|
|
632657
634134
|
continue;
|
|
632658
634135
|
}
|
|
632659
634136
|
const buffer2 = readFileSync97(pathOrFileId);
|
|
632660
|
-
const filename =
|
|
634137
|
+
const filename = basename32(pathOrFileId);
|
|
632661
634138
|
parts.push(Buffer.from(`--${boundary}\r
|
|
632662
634139
|
`));
|
|
632663
634140
|
parts.push(Buffer.from(
|
|
@@ -633868,7 +635345,7 @@ __export(projects_exports, {
|
|
|
633868
635345
|
});
|
|
633869
635346
|
import { readFileSync as readFileSync99, writeFileSync as writeFileSync64, mkdirSync as mkdirSync70, existsSync as existsSync121, statSync as statSync44, renameSync as renameSync7 } from "node:fs";
|
|
633870
635347
|
import { homedir as homedir45 } from "node:os";
|
|
633871
|
-
import { basename as
|
|
635348
|
+
import { basename as basename33, join as join135, resolve as resolve48 } from "node:path";
|
|
633872
635349
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
633873
635350
|
function readAll2() {
|
|
633874
635351
|
try {
|
|
@@ -633916,7 +635393,7 @@ function registerProject(root, pid) {
|
|
|
633916
635393
|
} else {
|
|
633917
635394
|
entry = {
|
|
633918
635395
|
root: canonical,
|
|
633919
|
-
name:
|
|
635396
|
+
name: basename33(canonical) || canonical,
|
|
633920
635397
|
firstSeen: now,
|
|
633921
635398
|
lastSeen: now,
|
|
633922
635399
|
pid: pid ?? null,
|
|
@@ -634856,14 +636333,14 @@ var init_access_policy = __esm({
|
|
|
634856
636333
|
});
|
|
634857
636334
|
|
|
634858
636335
|
// packages/cli/src/api/project-preferences.ts
|
|
634859
|
-
import { createHash as
|
|
636336
|
+
import { createHash as createHash30 } from "node:crypto";
|
|
634860
636337
|
import { existsSync as existsSync122, mkdirSync as mkdirSync71, readFileSync as readFileSync100, renameSync as renameSync8, writeFileSync as writeFileSync65, unlinkSync as unlinkSync26 } from "node:fs";
|
|
634861
636338
|
import { homedir as homedir46 } from "node:os";
|
|
634862
636339
|
import { join as join136, resolve as resolve49 } from "node:path";
|
|
634863
636340
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
634864
636341
|
function projectKey(root) {
|
|
634865
636342
|
const canonical = resolve49(root);
|
|
634866
|
-
return
|
|
636343
|
+
return createHash30("sha256").update(canonical).digest("hex").slice(0, 16);
|
|
634867
636344
|
}
|
|
634868
636345
|
function projectDir(root) {
|
|
634869
636346
|
return join136(PROJECTS_DIR, projectKey(root));
|
|
@@ -635916,7 +637393,7 @@ var init_audit_log = __esm({
|
|
|
635916
637393
|
// packages/cli/src/api/disk-task-output.ts
|
|
635917
637394
|
import { open } from "node:fs/promises";
|
|
635918
637395
|
import { existsSync as existsSync124, mkdirSync as mkdirSync73, statSync as statSync45 } from "node:fs";
|
|
635919
|
-
import { dirname as
|
|
637396
|
+
import { dirname as dirname39 } from "node:path";
|
|
635920
637397
|
import * as fsConstants from "node:constants";
|
|
635921
637398
|
var O_NOFOLLOW2, O_APPEND2, O_CREAT2, O_WRONLY2, OPEN_FLAGS_WRITE, OPEN_MODE, DiskTaskOutput;
|
|
635922
637399
|
var init_disk_task_output = __esm({
|
|
@@ -635935,7 +637412,7 @@ var init_disk_task_output = __esm({
|
|
|
635935
637412
|
fileSize = 0;
|
|
635936
637413
|
constructor(outputPath3) {
|
|
635937
637414
|
this.path = outputPath3;
|
|
635938
|
-
mkdirSync73(
|
|
637415
|
+
mkdirSync73(dirname39(outputPath3), { recursive: true });
|
|
635939
637416
|
}
|
|
635940
637417
|
/** Queue content for async append. Non-blocking. */
|
|
635941
637418
|
append(chunk) {
|
|
@@ -636041,7 +637518,7 @@ var init_disk_task_output = __esm({
|
|
|
636041
637518
|
});
|
|
636042
637519
|
|
|
636043
637520
|
// packages/cli/src/api/http.ts
|
|
636044
|
-
import { createHash as
|
|
637521
|
+
import { createHash as createHash31 } from "node:crypto";
|
|
636045
637522
|
function problemDetails(opts) {
|
|
636046
637523
|
const p2 = {
|
|
636047
637524
|
type: opts.type ?? "about:blank",
|
|
@@ -636104,7 +637581,7 @@ function paginated(items, page2, total) {
|
|
|
636104
637581
|
}
|
|
636105
637582
|
function computeEtag(payload) {
|
|
636106
637583
|
const json = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
636107
|
-
const hash =
|
|
637584
|
+
const hash = createHash31("sha1").update(json).digest("hex").slice(0, 16);
|
|
636108
637585
|
return `W/"${hash}"`;
|
|
636109
637586
|
}
|
|
636110
637587
|
function checkNotModified(req2, res, etag) {
|
|
@@ -650048,7 +651525,7 @@ var init_profiles = __esm({
|
|
|
650048
651525
|
// packages/cli/src/docker.ts
|
|
650049
651526
|
import { execSync as execSync57, spawn as spawn31 } from "node:child_process";
|
|
650050
651527
|
import { existsSync as existsSync132, mkdirSync as mkdirSync78, writeFileSync as writeFileSync70 } from "node:fs";
|
|
650051
|
-
import { join as join145, resolve as resolve50, dirname as
|
|
651528
|
+
import { join as join145, resolve as resolve50, dirname as dirname40 } from "node:path";
|
|
650052
651529
|
import { homedir as homedir52 } from "node:os";
|
|
650053
651530
|
import { fileURLToPath as fileURLToPath17 } from "node:url";
|
|
650054
651531
|
function getDockerDir() {
|
|
@@ -650059,7 +651536,7 @@ function getDockerDir() {
|
|
|
650059
651536
|
} catch {
|
|
650060
651537
|
}
|
|
650061
651538
|
try {
|
|
650062
|
-
const thisDir =
|
|
651539
|
+
const thisDir = dirname40(fileURLToPath17(import.meta.url));
|
|
650063
651540
|
return join145(thisDir, "..", "..", "..", "docker");
|
|
650064
651541
|
} catch {
|
|
650065
651542
|
}
|
|
@@ -650346,7 +651823,7 @@ __export(embedding_workers_exports, {
|
|
|
650346
651823
|
startEmbeddingWorkers: () => startEmbeddingWorkers,
|
|
650347
651824
|
stopEmbeddingWorkers: () => stopEmbeddingWorkers
|
|
650348
651825
|
});
|
|
650349
|
-
import { basename as
|
|
651826
|
+
import { basename as basename34, join as join146 } from "node:path";
|
|
650350
651827
|
function startEmbeddingWorkers(opts) {
|
|
650351
651828
|
if (_running) return;
|
|
650352
651829
|
_running = true;
|
|
@@ -650412,7 +651889,7 @@ async function runEmbeddingTask(modality, episodeId, taskId, opts) {
|
|
|
650412
651889
|
try {
|
|
650413
651890
|
if (!_aligner) {
|
|
650414
651891
|
const stateRoot = process.env.OMNIUS_DIR || process.cwd();
|
|
650415
|
-
const omniusDir =
|
|
651892
|
+
const omniusDir = basename34(stateRoot) === ".omnius" ? stateRoot : join146(stateRoot, ".omnius");
|
|
650416
651893
|
const memDir = join146(omniusDir, "memory");
|
|
650417
651894
|
_aligner = new EmbeddingAligner(
|
|
650418
651895
|
`${modality}-${emb.length}`,
|
|
@@ -650528,12 +652005,12 @@ import * as http5 from "node:http";
|
|
|
650528
652005
|
import * as https3 from "node:https";
|
|
650529
652006
|
import { createRequire as createRequire7 } from "node:module";
|
|
650530
652007
|
import { fileURLToPath as fileURLToPath18 } from "node:url";
|
|
650531
|
-
import { dirname as
|
|
652008
|
+
import { dirname as dirname41, join as join147, resolve as resolve51 } from "node:path";
|
|
650532
652009
|
import { homedir as homedir53 } from "node:os";
|
|
650533
652010
|
import { spawn as spawn32, execSync as execSync58 } from "node:child_process";
|
|
650534
652011
|
import { mkdirSync as mkdirSync79, writeFileSync as writeFileSync71, readFileSync as readFileSync108, readdirSync as readdirSync47, existsSync as existsSync133, watch as fsWatch4, renameSync as renameSync9, unlinkSync as unlinkSync28 } from "node:fs";
|
|
650535
652012
|
import { randomBytes as randomBytes27, randomUUID as randomUUID17 } from "node:crypto";
|
|
650536
|
-
import { createHash as
|
|
652013
|
+
import { createHash as createHash33 } from "node:crypto";
|
|
650537
652014
|
function memoryDbPaths3(baseDir = process.cwd()) {
|
|
650538
652015
|
const dir = join147(baseDir, ".omnius");
|
|
650539
652016
|
return {
|
|
@@ -650544,7 +652021,7 @@ function memoryDbPaths3(baseDir = process.cwd()) {
|
|
|
650544
652021
|
}
|
|
650545
652022
|
function getVersion3() {
|
|
650546
652023
|
try {
|
|
650547
|
-
const thisDir =
|
|
652024
|
+
const thisDir = dirname41(fileURLToPath18(import.meta.url));
|
|
650548
652025
|
const candidates = [
|
|
650549
652026
|
join147(thisDir, "..", "package.json"),
|
|
650550
652027
|
join147(thisDir, "..", "..", "package.json"),
|
|
@@ -650653,7 +652130,7 @@ async function refreshEndpointRegistry() {
|
|
|
650653
652130
|
});
|
|
650654
652131
|
if (process.env["OMNIUS_SKIP_SPONSOR_DISCOVERY"] === "1") return;
|
|
650655
652132
|
try {
|
|
650656
|
-
const resp = await fetch(
|
|
652133
|
+
const resp = await fetch(NEXUS_SPONSORS_URL2, {
|
|
650657
652134
|
signal: AbortSignal.timeout(5e3)
|
|
650658
652135
|
});
|
|
650659
652136
|
if (resp.ok) {
|
|
@@ -653160,7 +654637,7 @@ async function handleV1Update(req2, res, requestId) {
|
|
|
653160
654637
|
}, { subject: req2._authUser ?? "anonymous" });
|
|
653161
654638
|
const fs11 = require4("node:fs");
|
|
653162
654639
|
const nodeBin = process.execPath;
|
|
653163
|
-
const nodeDir =
|
|
654640
|
+
const nodeDir = dirname41(nodeBin);
|
|
653164
654641
|
const { execSync: es } = require4("node:child_process");
|
|
653165
654642
|
const isWin2 = process.platform === "win32";
|
|
653166
654643
|
let npmBin = "";
|
|
@@ -653175,7 +654652,7 @@ async function handleV1Update(req2, res, requestId) {
|
|
|
653175
654652
|
const dir = join147(homedir53(), ".omnius");
|
|
653176
654653
|
fs11.mkdirSync(dir, { recursive: true });
|
|
653177
654654
|
const logFd = fs11.openSync(logPath3, "w");
|
|
653178
|
-
const npmPrefix =
|
|
654655
|
+
const npmPrefix = dirname41(nodeDir);
|
|
653179
654656
|
let globalBinDir = "";
|
|
653180
654657
|
try {
|
|
653181
654658
|
if (isWin2) {
|
|
@@ -656455,7 +657932,7 @@ function listScheduledTasks() {
|
|
|
656455
657932
|
const schedule = String(t2?.schedule || t2?.cron || t2?.when || "");
|
|
656456
657933
|
const enabled2 = typeof t2?.enabled === "boolean" ? t2.enabled : true;
|
|
656457
657934
|
const realId = typeof t2?.id === "string" && t2.id ? t2.id : null;
|
|
656458
|
-
const fallbackId =
|
|
657935
|
+
const fallbackId = createHash33("sha1").update(`${file}#${i2}`).digest("hex").slice(0, 16);
|
|
656459
657936
|
const uid = realId || fallbackId;
|
|
656460
657937
|
const key = `${uid}`;
|
|
656461
657938
|
if (seen.has(key)) return;
|
|
@@ -656572,8 +658049,8 @@ function deleteScheduledById(id) {
|
|
|
656572
658049
|
if (id) candidates.push(id);
|
|
656573
658050
|
if (typeof entry?.id === "string" && entry.id && !candidates.includes(entry.id)) candidates.push(entry.id);
|
|
656574
658051
|
try {
|
|
656575
|
-
const { createHash:
|
|
656576
|
-
const fallback =
|
|
658052
|
+
const { createHash: createHash34 } = require4("node:crypto");
|
|
658053
|
+
const fallback = createHash34("sha1").update(`${target.file}#${target.index}`).digest("hex").slice(0, 16);
|
|
656577
658054
|
if (!candidates.includes(fallback)) candidates.push(fallback);
|
|
656578
658055
|
} catch {
|
|
656579
658056
|
}
|
|
@@ -658220,7 +659697,7 @@ function setTimerEnabled(name10, enabled2) {
|
|
|
658220
659697
|
return false;
|
|
658221
659698
|
}
|
|
658222
659699
|
}
|
|
658223
|
-
var require4, endpointRegistry, modelRouteMap, endpointUsage, _lastEndpointDiagnostics, BACKEND_TIMEOUT_DEFAULT_MS, BACKEND_TIMEOUT_MAX_MS, MODEL_LIST_TIMEOUT_DEFAULT_MS, metrics, startedAt, runningProcesses, perKeyUsage, CRON_MARKER2;
|
|
659700
|
+
var require4, NEXUS_DIRECTORY_ORIGIN2, NEXUS_SPONSORS_URL2, endpointRegistry, modelRouteMap, endpointUsage, _lastEndpointDiagnostics, BACKEND_TIMEOUT_DEFAULT_MS, BACKEND_TIMEOUT_MAX_MS, MODEL_LIST_TIMEOUT_DEFAULT_MS, metrics, startedAt, runningProcesses, perKeyUsage, CRON_MARKER2;
|
|
658224
659701
|
var init_serve = __esm({
|
|
658225
659702
|
"packages/cli/src/api/serve.ts"() {
|
|
658226
659703
|
"use strict";
|
|
@@ -658251,6 +659728,8 @@ var init_serve = __esm({
|
|
|
658251
659728
|
init_docker();
|
|
658252
659729
|
init_typed_node_events();
|
|
658253
659730
|
require4 = createRequire7(import.meta.url);
|
|
659731
|
+
NEXUS_DIRECTORY_ORIGIN2 = (process.env["OMNIUS_NEXUS_DIRECTORY_ORIGIN"] || process.env["OMNIUS_NEXUS_SIGNALING_SERVER"] || "https://openagents.nexus").replace(/\/+$/, "");
|
|
659732
|
+
NEXUS_SPONSORS_URL2 = `${NEXUS_DIRECTORY_ORIGIN2}/api/v1/sponsors`;
|
|
658254
659733
|
endpointRegistry = [];
|
|
658255
659734
|
modelRouteMap = /* @__PURE__ */ new Map();
|
|
658256
659735
|
endpointUsage = /* @__PURE__ */ new Map();
|
|
@@ -658349,7 +659828,7 @@ var init_clipboard_media = __esm({
|
|
|
658349
659828
|
|
|
658350
659829
|
// packages/cli/src/tui/interactive.ts
|
|
658351
659830
|
import { cwd } from "node:process";
|
|
658352
|
-
import { resolve as resolve52, join as join149, dirname as
|
|
659831
|
+
import { resolve as resolve52, join as join149, dirname as dirname42, extname as extname17, relative as relative14 } from "node:path";
|
|
658353
659832
|
import { createRequire as createRequire8 } from "node:module";
|
|
658354
659833
|
import { fileURLToPath as fileURLToPath19 } from "node:url";
|
|
658355
659834
|
import {
|
|
@@ -658376,7 +659855,7 @@ function formatTimeAgo2(date) {
|
|
|
658376
659855
|
function getVersion4() {
|
|
658377
659856
|
try {
|
|
658378
659857
|
const require5 = createRequire8(import.meta.url);
|
|
658379
|
-
const thisDir =
|
|
659858
|
+
const thisDir = dirname42(fileURLToPath19(import.meta.url));
|
|
658380
659859
|
const candidates = [
|
|
658381
659860
|
join149(thisDir, "..", "package.json"),
|
|
658382
659861
|
join149(thisDir, "..", "..", "package.json"),
|
|
@@ -663368,7 +664847,7 @@ Log: ${nexusLogPath}`)
|
|
|
663368
664847
|
const { getNodeMnemonic: getNodeMnemonic2 } = await Promise.resolve().then(() => (init_banner(), banner_exports));
|
|
663369
664848
|
agName = getNodeMnemonic2();
|
|
663370
664849
|
}
|
|
663371
|
-
fetch(
|
|
664850
|
+
fetch(NEXUS_AGENT_DIRECTORY_URL, {
|
|
663372
664851
|
method: "POST",
|
|
663373
664852
|
headers: { "Content-Type": "application/json" },
|
|
663374
664853
|
body: JSON.stringify({
|
|
@@ -663412,7 +664891,7 @@ Log: ${nexusLogPath}`)
|
|
|
663412
664891
|
} catch {
|
|
663413
664892
|
}
|
|
663414
664893
|
const spResp = await fetch(
|
|
663415
|
-
|
|
664894
|
+
NEXUS_SPONSORS_URL3,
|
|
663416
664895
|
{ signal: AbortSignal.timeout(8e3) }
|
|
663417
664896
|
);
|
|
663418
664897
|
if (spResp.ok) {
|
|
@@ -666547,13 +668026,13 @@ NEW TASK: ${fullInput}`;
|
|
|
666547
668026
|
writeContent(() => renderError(errMsg));
|
|
666548
668027
|
if (failureStore) {
|
|
666549
668028
|
try {
|
|
666550
|
-
const { createHash:
|
|
668029
|
+
const { createHash: createHash34 } = await import("node:crypto");
|
|
666551
668030
|
failureStore.insert({
|
|
666552
668031
|
taskId: "",
|
|
666553
668032
|
sessionId: `${Date.now()}`,
|
|
666554
668033
|
repoRoot,
|
|
666555
668034
|
failureType: "runtime-error",
|
|
666556
|
-
fingerprint:
|
|
668035
|
+
fingerprint: createHash34("sha256").update(errMsg.slice(0, 200)).digest("hex").slice(0, 16),
|
|
666557
668036
|
filePath: null,
|
|
666558
668037
|
errorMessage: errMsg.slice(0, 500),
|
|
666559
668038
|
context: null,
|
|
@@ -667276,7 +668755,7 @@ Rules:
|
|
|
667276
668755
|
process.exit(1);
|
|
667277
668756
|
}
|
|
667278
668757
|
}
|
|
667279
|
-
var _interactiveSessionActive, _interactiveSessionReason, _voiceChatSession2, taskManager, _apiCallbacks, _shellToolRef, _replToolRef, _fullSubAgentToolRef, _agentToolRef, _sendMessageToolRef, _agentLifecycleMgr, _activeRunnerRef, _parentRunnerForArchive, _wireSubAgentCallbacks, _wireAgentToolCallbacks, _wireSubAgentToolCallbacks, _autoUpdatedThisSession, _mcpManager, _pluginManager, _mcpTools, SELF_IMPROVE_INTERVAL, _tasksSinceImprove;
|
|
668758
|
+
var NEXUS_DIRECTORY_ORIGIN3, NEXUS_AGENT_DIRECTORY_URL, NEXUS_SPONSORS_URL3, _interactiveSessionActive, _interactiveSessionReason, _voiceChatSession2, taskManager, _apiCallbacks, _shellToolRef, _replToolRef, _fullSubAgentToolRef, _agentToolRef, _sendMessageToolRef, _agentLifecycleMgr, _activeRunnerRef, _parentRunnerForArchive, _wireSubAgentCallbacks, _wireAgentToolCallbacks, _wireSubAgentToolCallbacks, _autoUpdatedThisSession, _mcpManager, _pluginManager, _mcpTools, SELF_IMPROVE_INTERVAL, _tasksSinceImprove;
|
|
667280
668759
|
var init_interactive = __esm({
|
|
667281
668760
|
"packages/cli/src/tui/interactive.ts"() {
|
|
667282
668761
|
"use strict";
|
|
@@ -667331,6 +668810,9 @@ var init_interactive = __esm({
|
|
|
667331
668810
|
init_neovim_mode();
|
|
667332
668811
|
init_task_manager_singleton();
|
|
667333
668812
|
init_tui_tasks_renderer();
|
|
668813
|
+
NEXUS_DIRECTORY_ORIGIN3 = (process.env["OMNIUS_NEXUS_DIRECTORY_ORIGIN"] || process.env["OMNIUS_NEXUS_SIGNALING_SERVER"] || "https://openagents.nexus").replace(/\/+$/, "");
|
|
668814
|
+
NEXUS_AGENT_DIRECTORY_URL = `${NEXUS_DIRECTORY_ORIGIN3}/api/v1/directory`;
|
|
668815
|
+
NEXUS_SPONSORS_URL3 = `${NEXUS_DIRECTORY_ORIGIN3}/api/v1/sponsors`;
|
|
667334
668816
|
_interactiveSessionActive = false;
|
|
667335
668817
|
_interactiveSessionReason = "";
|
|
667336
668818
|
_voiceChatSession2 = null;
|
|
@@ -668338,7 +669820,7 @@ init_typed_node_events();
|
|
|
668338
669820
|
import { createRequire as createRequire9 } from "node:module";
|
|
668339
669821
|
import { parseArgs as nodeParseArgs2 } from "node:util";
|
|
668340
669822
|
import { fileURLToPath as fileURLToPath20 } from "node:url";
|
|
668341
|
-
import { dirname as
|
|
669823
|
+
import { dirname as dirname43, join as join153 } from "node:path";
|
|
668342
669824
|
|
|
668343
669825
|
// packages/cli/src/cli.ts
|
|
668344
669826
|
init_typed_node_events();
|
|
@@ -668486,7 +669968,7 @@ try {
|
|
|
668486
669968
|
function getVersion5() {
|
|
668487
669969
|
try {
|
|
668488
669970
|
const require5 = createRequire9(import.meta.url);
|
|
668489
|
-
const pkgPath = join153(
|
|
669971
|
+
const pkgPath = join153(dirname43(fileURLToPath20(import.meta.url)), "..", "package.json");
|
|
668490
669972
|
const pkg = require5(pkgPath);
|
|
668491
669973
|
return pkg.version;
|
|
668492
669974
|
} catch {
|