@infernetprotocol/cli 0.1.40 → 0.1.41
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/package.json +6 -6
- package/examples/app.js +0 -153
- package/lib/runtime-config.js +0 -130
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infernetprotocol/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"description": "GPU-node CLI / daemon for the Infernet Protocol — register a GPU server with a Supabase control plane and start earning.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"ora": "^9.4.0",
|
|
31
31
|
"react": "^17.0.2",
|
|
32
32
|
"react-blessed": "^0.7.2",
|
|
33
|
-
"@infernetprotocol/auth": "0.1.
|
|
34
|
-
"@infernetprotocol/
|
|
35
|
-
"@infernetprotocol/
|
|
36
|
-
"@infernetprotocol/
|
|
37
|
-
"@infernetprotocol/gpu": "0.1.
|
|
33
|
+
"@infernetprotocol/auth": "0.1.41",
|
|
34
|
+
"@infernetprotocol/config": "0.1.41",
|
|
35
|
+
"@infernetprotocol/deploy-providers": "0.1.41",
|
|
36
|
+
"@infernetprotocol/engine": "0.1.41",
|
|
37
|
+
"@infernetprotocol/gpu": "0.1.41"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
package/examples/app.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Infernet Protocol - Main Application
|
|
3
|
-
* Demonstrates the use of the Supabase-backed database layer.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import db from '@infernetprotocol/db';
|
|
7
|
-
import config from '../lib/runtime-config.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Initialize the application
|
|
11
|
-
*/
|
|
12
|
-
async function init() {
|
|
13
|
-
try {
|
|
14
|
-
console.log('Initializing Infernet Protocol application...');
|
|
15
|
-
|
|
16
|
-
await db.connect(config.supabase.url);
|
|
17
|
-
|
|
18
|
-
console.log('Application initialized successfully');
|
|
19
|
-
return true;
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.error('Failed to initialize application:', error);
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Example: Register a new provider node
|
|
28
|
-
* @param {Object} providerData - Provider data
|
|
29
|
-
* @returns {Promise<Object>} - Created provider record
|
|
30
|
-
*/
|
|
31
|
-
async function registerProvider(providerData) {
|
|
32
|
-
try {
|
|
33
|
-
const Provider = db.model('provider');
|
|
34
|
-
const provider = await Provider.register({
|
|
35
|
-
name: providerData.name || `Provider-${Date.now()}`,
|
|
36
|
-
gpu_model: providerData.gpuModel,
|
|
37
|
-
price: providerData.price || 0
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
console.log('Provider registered:', provider);
|
|
41
|
-
return provider;
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.error('Failed to register provider:', error);
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Example: Submit a new inference job
|
|
50
|
-
* @param {Object} jobData - Job data
|
|
51
|
-
* @returns {Promise<Object>} - Created job record
|
|
52
|
-
*/
|
|
53
|
-
async function submitJob(jobData) {
|
|
54
|
-
try {
|
|
55
|
-
const Job = db.model('job');
|
|
56
|
-
const job = await Job.create({
|
|
57
|
-
title: jobData.title || `Job-${Date.now()}`,
|
|
58
|
-
status: 'pending',
|
|
59
|
-
payment_offer: jobData.paymentOffer,
|
|
60
|
-
model_name: jobData.model,
|
|
61
|
-
client_name: jobData.clientName
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
console.log('Job submitted:', job);
|
|
65
|
-
|
|
66
|
-
if (jobData.isMultiNode) {
|
|
67
|
-
await assignAggregator(job.id);
|
|
68
|
-
} else {
|
|
69
|
-
await assignProvider(job.id);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return job;
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.error('Failed to submit job:', error);
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Example: Assign an aggregator to a multi-node job
|
|
81
|
-
* @param {string} jobId - Job ID
|
|
82
|
-
* @returns {Promise<Object>} - Updated job record
|
|
83
|
-
*/
|
|
84
|
-
async function assignAggregator(jobId) {
|
|
85
|
-
try {
|
|
86
|
-
const Aggregator = db.model('aggregator');
|
|
87
|
-
const Job = db.model('job');
|
|
88
|
-
|
|
89
|
-
const aggregators = await Aggregator.findAvailable();
|
|
90
|
-
if (aggregators.length === 0) {
|
|
91
|
-
throw new Error('No aggregators available');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const aggregator = aggregators[0];
|
|
95
|
-
const updatedJob = await Job.assignToAggregator(jobId, aggregator.id);
|
|
96
|
-
await Aggregator.updateLoad(aggregator.id, 1);
|
|
97
|
-
|
|
98
|
-
console.log(`Job ${jobId} assigned to aggregator ${aggregator.id}`);
|
|
99
|
-
return updatedJob;
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.error(`Failed to assign aggregator for job ${jobId}:`, error);
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Example: Assign a provider to a single-node job
|
|
108
|
-
* @param {string} jobId - Job ID
|
|
109
|
-
* @returns {Promise<Object>} - Updated job record
|
|
110
|
-
*/
|
|
111
|
-
async function assignProvider(jobId) {
|
|
112
|
-
try {
|
|
113
|
-
const Provider = db.model('provider');
|
|
114
|
-
const Job = db.model('job');
|
|
115
|
-
|
|
116
|
-
const providers = await Provider.findAvailable();
|
|
117
|
-
if (providers.length === 0) {
|
|
118
|
-
throw new Error('No suitable providers available');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const provider = providers[0];
|
|
122
|
-
const updatedJob = await Job.assignToProvider(jobId, provider.id);
|
|
123
|
-
await Provider.updateStatus(provider.id, 'busy');
|
|
124
|
-
|
|
125
|
-
console.log(`Job ${jobId} assigned to provider ${provider.id}`);
|
|
126
|
-
return updatedJob;
|
|
127
|
-
} catch (error) {
|
|
128
|
-
console.error(`Failed to assign provider for job ${jobId}:`, error);
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Example: Cleanup and shutdown
|
|
135
|
-
*/
|
|
136
|
-
async function shutdown() {
|
|
137
|
-
try {
|
|
138
|
-
console.log('Shutting down application...');
|
|
139
|
-
await db.disconnect();
|
|
140
|
-
console.log('Application shutdown complete');
|
|
141
|
-
} catch (error) {
|
|
142
|
-
console.error('Error during shutdown:', error);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export {
|
|
147
|
-
init,
|
|
148
|
-
registerProvider,
|
|
149
|
-
submitJob,
|
|
150
|
-
assignAggregator,
|
|
151
|
-
assignProvider,
|
|
152
|
-
shutdown
|
|
153
|
-
};
|
package/lib/runtime-config.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration settings for Infernet Protocol
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Load environment variables from .env file
|
|
6
|
-
import dotenv from 'dotenv';
|
|
7
|
-
dotenv.config();
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
// Supabase configuration (self-hosted via `supabase start` or cloud)
|
|
11
|
-
supabase: {
|
|
12
|
-
url: process.env.SUPABASE_URL || 'http://127.0.0.1:54321',
|
|
13
|
-
serviceRoleKey: process.env.SUPABASE_SERVICE_ROLE_KEY,
|
|
14
|
-
schema: process.env.SUPABASE_SCHEMA || 'public'
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
// Server configuration
|
|
18
|
-
server: {
|
|
19
|
-
port: parseInt(process.env.PORT || '3000', 10),
|
|
20
|
-
host: process.env.HOST || '0.0.0.0',
|
|
21
|
-
apiPrefix: process.env.API_PREFIX || '/api/v1',
|
|
22
|
-
corsOrigins: (process.env.CORS_ORIGINS || '*').split(',')
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
// Node configuration
|
|
26
|
-
node: {
|
|
27
|
-
type: process.env.NODE_TYPE || 'provider', // provider, client, or aggregator
|
|
28
|
-
id: process.env.NODE_ID || `node_${Date.now()}`,
|
|
29
|
-
discoveryInterval: parseInt(process.env.DISCOVERY_INTERVAL || '60000', 10), // milliseconds
|
|
30
|
-
bootstrapNodes: (process.env.BOOTSTRAP_NODES || '').split(',').filter(Boolean),
|
|
31
|
-
maxConnections: parseInt(process.env.MAX_CONNECTIONS || '100', 10),
|
|
32
|
-
heartbeatInterval: parseInt(process.env.HEARTBEAT_INTERVAL || '30000', 10), // milliseconds
|
|
33
|
-
enableRemoteSeeding: process.env.ENABLE_REMOTE_SEEDING === 'true' || true, // Enable seeding from remote P2P instance
|
|
34
|
-
remoteNodeUrl: process.env.REMOTE_NODE_URL || 'https://infernetprotocol.com/nodes' // URL to fetch remote nodes from
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
// WebSocket configuration
|
|
38
|
-
websocket: {
|
|
39
|
-
port: parseInt(process.env.WS_PORT || '3001', 10),
|
|
40
|
-
host: process.env.WS_HOST || '0.0.0.0',
|
|
41
|
-
path: process.env.WS_PATH || '/ws',
|
|
42
|
-
heartbeatInterval: parseInt(process.env.WS_HEARTBEAT_INTERVAL || '30000', 10),
|
|
43
|
-
reconnectInterval: parseInt(process.env.WS_RECONNECT_INTERVAL || '5000', 10),
|
|
44
|
-
maxReconnectAttempts: parseInt(process.env.WS_MAX_RECONNECT_ATTEMPTS || '10', 10)
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
// DHT configuration
|
|
48
|
-
dht: {
|
|
49
|
-
bootstrapNodes: (process.env.DHT_BOOTSTRAP_NODES || '').split(',').filter(Boolean),
|
|
50
|
-
kBucketSize: parseInt(process.env.DHT_K_BUCKET_SIZE || '20', 10),
|
|
51
|
-
refreshInterval: parseInt(process.env.DHT_REFRESH_INTERVAL || '3600000', 10), // 1 hour
|
|
52
|
-
staleTimeout: parseInt(process.env.DHT_STALE_TIMEOUT || '900000', 10) // 15 minutes
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
// Docker configuration for task execution
|
|
56
|
-
docker: {
|
|
57
|
-
socketPath: process.env.DOCKER_SOCKET || '/var/run/docker.sock',
|
|
58
|
-
defaultImage: process.env.DEFAULT_DOCKER_IMAGE || 'ubuntu:latest',
|
|
59
|
-
networkMode: process.env.DOCKER_NETWORK_MODE || 'bridge',
|
|
60
|
-
cpuLimit: process.env.DOCKER_CPU_LIMIT,
|
|
61
|
-
memoryLimit: process.env.DOCKER_MEMORY_LIMIT,
|
|
62
|
-
gpuOptions: process.env.DOCKER_GPU_OPTIONS
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
// NOSTR configuration for decentralized identity
|
|
66
|
-
nostr: {
|
|
67
|
-
privateKey: process.env.NOSTR_PRIVATE_KEY,
|
|
68
|
-
publicKey: process.env.NOSTR_PUBLIC_KEY,
|
|
69
|
-
relays: (process.env.NOSTR_RELAYS || 'wss://relay.damus.io,wss://relay.nostr.info').split(','),
|
|
70
|
-
enableNIP05: process.env.NOSTR_ENABLE_NIP05 === 'true' || false,
|
|
71
|
-
nip05Domain: process.env.NOSTR_NIP05_DOMAIN,
|
|
72
|
-
nip05Identifier: process.env.NOSTR_NIP05_IDENTIFIER
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// Payment configuration
|
|
76
|
-
payment: {
|
|
77
|
-
methods: (process.env.PAYMENT_METHODS || 'lightning,polygon').split(','),
|
|
78
|
-
minimumAmount: parseFloat(process.env.PAYMENT_MINIMUM_AMOUNT || '0.0001'),
|
|
79
|
-
escrowEnabled: process.env.PAYMENT_ESCROW_ENABLED === 'true' || false,
|
|
80
|
-
lightning: {
|
|
81
|
-
nodeUrl: process.env.LIGHTNING_NODE_URL,
|
|
82
|
-
macaroon: process.env.LIGHTNING_MACAROON,
|
|
83
|
-
certificatePath: process.env.LIGHTNING_CERTIFICATE_PATH,
|
|
84
|
-
invoiceExpirySeconds: parseInt(process.env.LIGHTNING_INVOICE_EXPIRY || '3600', 10)
|
|
85
|
-
},
|
|
86
|
-
polygon: {
|
|
87
|
-
rpcUrl: process.env.POLYGON_RPC_URL,
|
|
88
|
-
privateKey: process.env.POLYGON_PRIVATE_KEY,
|
|
89
|
-
contractAddress: process.env.POLYGON_CONTRACT_ADDRESS,
|
|
90
|
-
gasLimit: parseInt(process.env.POLYGON_GAS_LIMIT || '250000', 10)
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
// Security configuration
|
|
95
|
-
security: {
|
|
96
|
-
encryptionKey: process.env.ENCRYPTION_KEY,
|
|
97
|
-
jwtSecret: process.env.JWT_SECRET,
|
|
98
|
-
jwtExpiryHours: parseInt(process.env.JWT_EXPIRY_HOURS || '24', 10),
|
|
99
|
-
useSecureEnclave: process.env.USE_SECURE_ENCLAVE === 'true' || false,
|
|
100
|
-
rateLimitRequests: parseInt(process.env.RATE_LIMIT_REQUESTS || '100', 10),
|
|
101
|
-
rateLimitWindowMs: parseInt(process.env.RATE_LIMIT_WINDOW_MS || '900000', 10) // 15 minutes
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
// Logging configuration
|
|
105
|
-
logging: {
|
|
106
|
-
level: process.env.LOG_LEVEL || 'info',
|
|
107
|
-
format: process.env.LOG_FORMAT || 'json',
|
|
108
|
-
file: process.env.LOG_FILE || './logs/infernet.log',
|
|
109
|
-
maxSize: parseInt(process.env.LOG_MAX_SIZE || '10485760', 10), // 10MB
|
|
110
|
-
maxFiles: parseInt(process.env.LOG_MAX_FILES || '5', 10),
|
|
111
|
-
console: process.env.LOG_TO_CONSOLE !== 'false'
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
// Content delivery configuration
|
|
115
|
-
contentDelivery: {
|
|
116
|
-
storageDir: process.env.CONTENT_STORAGE_DIR || './storage',
|
|
117
|
-
maxContentSize: parseInt(process.env.MAX_CONTENT_SIZE || '10737418240', 10), // 10GB default
|
|
118
|
-
tempDir: process.env.TEMP_DIR || './tmp',
|
|
119
|
-
cleanupInterval: parseInt(process.env.CLEANUP_INTERVAL || '3600000', 10), // 1 hour
|
|
120
|
-
contentExpiryHours: parseInt(process.env.CONTENT_EXPIRY_HOURS || '24', 10)
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
// Job execution configuration
|
|
124
|
-
jobs: {
|
|
125
|
-
maxConcurrent: parseInt(process.env.MAX_CONCURRENT_JOBS || '5', 10),
|
|
126
|
-
timeout: parseInt(process.env.JOB_TIMEOUT || '3600000', 10), // 1 hour default
|
|
127
|
-
retryLimit: parseInt(process.env.JOB_RETRY_LIMIT || '3', 10),
|
|
128
|
-
retryDelay: parseInt(process.env.JOB_RETRY_DELAY || '60000', 10) // 1 minute
|
|
129
|
-
}
|
|
130
|
-
};
|