@ruvector/edge-net 0.5.0 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +281 -10
- package/core-invariants.js +942 -0
- package/models/adapter-hub.js +1008 -0
- package/models/adapter-security.js +792 -0
- package/models/benchmark.js +688 -0
- package/models/distribution.js +791 -0
- package/models/index.js +109 -0
- package/models/integrity.js +753 -0
- package/models/loader.js +725 -0
- package/models/microlora.js +1298 -0
- package/models/model-loader.js +922 -0
- package/models/model-optimizer.js +1245 -0
- package/models/model-registry.js +696 -0
- package/models/model-utils.js +548 -0
- package/models/models-cli.js +914 -0
- package/models/registry.json +214 -0
- package/models/training-utils.js +1418 -0
- package/models/wasm-core.js +1025 -0
- package/network-genesis.js +2847 -0
- package/onnx-worker.js +462 -8
- package/package.json +33 -3
- package/plugins/SECURITY-AUDIT.md +654 -0
- package/plugins/cli.js +43 -3
- package/plugins/implementations/e2e-encryption.js +57 -12
- package/plugins/plugin-loader.js +610 -21
- package/tests/model-optimizer.test.js +644 -0
- package/tests/network-genesis.test.js +562 -0
- package/tests/plugin-benchmark.js +1239 -0
- package/tests/plugin-system-test.js +163 -0
- package/tests/wasm-core.test.js +368 -0
package/models/index.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ruvector/edge-net Models Module
|
|
3
|
+
*
|
|
4
|
+
* Model optimization, quantization, and management for edge deployment
|
|
5
|
+
*
|
|
6
|
+
* @module @ruvector/edge-net/models
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Model optimization exports
|
|
10
|
+
export {
|
|
11
|
+
ModelOptimizer,
|
|
12
|
+
QuantizationEngine,
|
|
13
|
+
PruningEngine,
|
|
14
|
+
OnnxOptimizer,
|
|
15
|
+
DistillationEngine,
|
|
16
|
+
BenchmarkEngine,
|
|
17
|
+
TARGET_MODELS,
|
|
18
|
+
QUANTIZATION_CONFIGS,
|
|
19
|
+
PRUNING_STRATEGIES,
|
|
20
|
+
default,
|
|
21
|
+
} from './model-optimizer.js';
|
|
22
|
+
|
|
23
|
+
// Model utilities exports
|
|
24
|
+
export {
|
|
25
|
+
loadRegistry,
|
|
26
|
+
saveRegistry,
|
|
27
|
+
getModel,
|
|
28
|
+
getProfile,
|
|
29
|
+
formatSize,
|
|
30
|
+
parseSize,
|
|
31
|
+
hashFile,
|
|
32
|
+
hashBuffer,
|
|
33
|
+
getModelCacheDir,
|
|
34
|
+
isModelCached,
|
|
35
|
+
getCachedModelSize,
|
|
36
|
+
getDirectorySize,
|
|
37
|
+
estimateQuantizedSize,
|
|
38
|
+
getRecommendedQuantization,
|
|
39
|
+
downloadFile,
|
|
40
|
+
pinToIPFS,
|
|
41
|
+
getIPFSUrl,
|
|
42
|
+
getGCSUrl,
|
|
43
|
+
checkGCSExists,
|
|
44
|
+
createAdapterMetadata,
|
|
45
|
+
getAdapterPath,
|
|
46
|
+
createBenchmarkResult,
|
|
47
|
+
DEFAULT_CACHE_DIR,
|
|
48
|
+
REGISTRY_PATH,
|
|
49
|
+
GCS_CONFIG,
|
|
50
|
+
IPFS_CONFIG,
|
|
51
|
+
LORA_DEFAULTS,
|
|
52
|
+
} from './model-utils.js';
|
|
53
|
+
|
|
54
|
+
// Registry utilities
|
|
55
|
+
import { readFileSync } from 'fs';
|
|
56
|
+
import { join, dirname } from 'path';
|
|
57
|
+
import { fileURLToPath } from 'url';
|
|
58
|
+
|
|
59
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
60
|
+
const __dirname = dirname(__filename);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get the full model registry
|
|
64
|
+
* @returns {Object} Registry object
|
|
65
|
+
*/
|
|
66
|
+
export function getRegistry() {
|
|
67
|
+
try {
|
|
68
|
+
const registryPath = join(__dirname, 'registry.json');
|
|
69
|
+
return JSON.parse(readFileSync(registryPath, 'utf-8'));
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('[Models] Failed to load registry:', error.message);
|
|
72
|
+
return { version: '0.0.0', models: {}, profiles: {} };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* List all available models
|
|
78
|
+
* @param {Object} options - Filter options
|
|
79
|
+
* @param {string} [options.type] - Filter by type (embedding, generation)
|
|
80
|
+
* @param {number} [options.tier] - Filter by tier (1-4)
|
|
81
|
+
* @returns {Array} Array of model entries
|
|
82
|
+
*/
|
|
83
|
+
export function listModels(options = {}) {
|
|
84
|
+
const registry = getRegistry();
|
|
85
|
+
return Object.entries(registry.models)
|
|
86
|
+
.filter(([_, m]) => !options.type || m.type === options.type)
|
|
87
|
+
.filter(([_, m]) => !options.tier || m.tier === options.tier)
|
|
88
|
+
.map(([id, model]) => ({ id, ...model }));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get recommended model profile for a use case
|
|
93
|
+
* @param {string} profileId - Profile identifier
|
|
94
|
+
* @returns {Object|null} Profile configuration
|
|
95
|
+
*/
|
|
96
|
+
export function getRecommendedProfile(profileId) {
|
|
97
|
+
const registry = getRegistry();
|
|
98
|
+
return registry.profiles[profileId] || null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get all available profiles
|
|
103
|
+
* @returns {Array} Array of profile entries
|
|
104
|
+
*/
|
|
105
|
+
export function listProfiles() {
|
|
106
|
+
const registry = getRegistry();
|
|
107
|
+
return Object.entries(registry.profiles)
|
|
108
|
+
.map(([id, profile]) => ({ id, ...profile }));
|
|
109
|
+
}
|