maxion-mcp-gateway 1.0.1

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.
Files changed (78) hide show
  1. package/.env +3 -0
  2. package/.mcpbignore +3 -0
  3. package/.well-known/mcp/server-card.json +28 -0
  4. package/Cargo.lock +2578 -0
  5. package/Cargo.toml.bak +19 -0
  6. package/Deploy_Ecosystem.ps1 +31 -0
  7. package/May_8th_Pre_Release_Update.md +67 -0
  8. package/README.md +41 -0
  9. package/Run-Transparent.ps1 +33 -0
  10. package/Start-MaxionEngine.bat +7 -0
  11. package/Sync_WebHub.ps1 +24 -0
  12. package/admin_dashboard.html +238 -0
  13. package/admin_emulator.js +46 -0
  14. package/admin_host.js +126 -0
  15. package/ai-plugin.json +17 -0
  16. package/amplify.yml +17 -0
  17. package/apply_patches.js +91 -0
  18. package/aws-lambda-stripe/index.js +75 -0
  19. package/aws-lambda-stripe/lineage_api.js +57 -0
  20. package/aws-lambda-stripe/package-lock.json +298 -0
  21. package/aws_lambda_handler.js +301 -0
  22. package/build_worker_zip.js +21 -0
  23. package/clean_page.js +53 -0
  24. package/clean_page_2.js +37 -0
  25. package/clean_trials_safe.js +35 -0
  26. package/configure_aws.js +102 -0
  27. package/cors.json +10 -0
  28. package/create_lambda.js +85 -0
  29. package/create_mock_user.js +30 -0
  30. package/dashboard_server_head.js +430 -0
  31. package/dashboard_server_head_utf8.js +430 -0
  32. package/deploy_installers.js +67 -0
  33. package/deploy_lineage_lambda.js +36 -0
  34. package/deploy_maxion.js +56 -0
  35. package/deploy_real_lambda.js +63 -0
  36. package/deploy_submitter.js +25 -0
  37. package/deploy_web_hub.js +203 -0
  38. package/deploy_worker_now.js +25 -0
  39. package/diamonize-lsa-mcp/index.js +79 -0
  40. package/diamonize-lsa-mcp/package-lock.json +1161 -0
  41. package/diamonize-lsa-mcp/package.json +24 -0
  42. package/diamonize-lsa-mcp/smithery.yaml +11 -0
  43. package/generate_mcps.js +243 -0
  44. package/inject_ui.js +41 -0
  45. package/jk-mcp-server/index.js +245 -0
  46. package/jk-mcp-server/package-lock.json +1158 -0
  47. package/jk-mcp-server/package.json +24 -0
  48. package/lineage-0-vc-mcp/index.js +169 -0
  49. package/lineage-0-vc-mcp/package-lock.json +1161 -0
  50. package/lineage-0-vc-mcp/package.json +24 -0
  51. package/lineage-0-vc-mcp/smithery.yaml +11 -0
  52. package/logger.js +62 -0
  53. package/manifest.json +69 -0
  54. package/maxion-mcp/index.js +92 -0
  55. package/maxion-mcp/package-lock.json +1161 -0
  56. package/maxion-mcp/package.json +24 -0
  57. package/maxion-mcp/smithery.yaml +11 -0
  58. package/mcp_wrapper.js +195 -0
  59. package/outreach_leads.md +23 -0
  60. package/package.json +27 -0
  61. package/poll_test.js +30 -0
  62. package/quezar-storage-mcp/index.js +96 -0
  63. package/quezar-storage-mcp/package-lock.json +1161 -0
  64. package/quezar-storage-mcp/package.json +24 -0
  65. package/quezar-storage-mcp/smithery.yaml +11 -0
  66. package/scripts/calc_benchmark.ps1 +63 -0
  67. package/scripts/clean_aws_s3.js +71 -0
  68. package/scripts/diamonize_benchmark.ps1 +39 -0
  69. package/scripts/quezar_benchmark.ps1 +54 -0
  70. package/scripts/real_physical_benchmark.ps1 +74 -0
  71. package/scripts/run_live_benchmarks.ps1 +37 -0
  72. package/scripts/shatter_maxion.ps1 +34 -0
  73. package/scripts/social_visibility_bot.js +53 -0
  74. package/simulate_lead.js +30 -0
  75. package/smithery.yaml +31 -0
  76. package/test_aws_models.js +62 -0
  77. package/test_fallback.js +28 -0
  78. package/update_lambda.js +143 -0
@@ -0,0 +1,430 @@
1
+ const express = require('express');
2
+ const path = require('path');
3
+ const si = require('systeminformation');
4
+ const os = require('os');
5
+ const { exec } = require('child_process');
6
+ const cors = require('cors');
7
+ require('dotenv').config(); // Load environment variables for Stripe & Supabase
8
+
9
+ const app = express();
10
+ app.use(cors());
11
+ const PORT = 11011;
12
+
13
+ // --- STRIPE LINK REGISTRY ---
14
+ // Load and validate Stripe links at boot. This is the single source of truth.
15
+ // If stripe_links.json is missing or malformed, the server will log a critical error.
16
+ const STRIPE_LINKS_PATH = path.join(__dirname, '..', 'stripe_links.json');
17
+ let STRIPE_REGISTRY = {};
18
+ try {
19
+ const fs_sync = require('fs');
20
+ STRIPE_REGISTRY = JSON.parse(fs_sync.readFileSync(STRIPE_LINKS_PATH, 'utf-8'));
21
+ console.error(`[Stripe Registry] Loaded ${Object.keys(STRIPE_REGISTRY).length} payment links from stripe_links.json.`);
22
+ // Validate all links are live (not test_) before allowing them to be served
23
+ for (const [key, url] of Object.entries(STRIPE_REGISTRY)) {
24
+ if (typeof url === 'string' && url.includes('/test_')) {
25
+ console.error(`[Stripe Registry] WARNING: Product '${key}' has a TEST Stripe URL. It will NOT be served to production users.`);
26
+ }
27
+ }
28
+ } catch (e) {
29
+ console.error('[Stripe Registry] CRITICAL: Failed to load stripe_links.json. Payment links unavailable.', e.message);
30
+ }
31
+
32
+ app.use(express.json({ limit: '500mb' }));
33
+ app.use(express.urlencoded({ limit: '500mb', extended: true }));
34
+
35
+ // Serve the modern dashboard
36
+ app.get('/', (req, res) => {
37
+ res.sendFile(path.join(__dirname, '..', 'public', 'dashboard.html'));
38
+ });
39
+
40
+ // ----------------------------------------------------
41
+ // STATE VARIABLES & PERSISTENCE
42
+ // ----------------------------------------------------
43
+ const fs = require('fs');
44
+ const CONFIG_PATH = path.join(os.homedir(), '.maxion_config.json');
45
+
46
+ let isEngineOn = true;
47
+ let engineStartTime = Date.now();
48
+ let lifetimeStats = { hours: 0, energy: 0 };
49
+ let currentStressLevel = 'none';
50
+
51
+ // Load persistent trial data
52
+ try {
53
+ if (fs.existsSync(CONFIG_PATH)) {
54
+ const data = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
55
+ if (data && data.hours) {
56
+ lifetimeStats = data;
57
+ }
58
+ }
59
+ } catch (e) {
60
+ console.error('[Dashboard] Error loading config:', e);
61
+ }
62
+
63
+ const saveStats = () => {
64
+ try {
65
+ fs.writeFileSync(CONFIG_PATH, JSON.stringify(lifetimeStats));
66
+ } catch (e) {
67
+ console.error('[Dashboard] Error saving config:', e);
68
+ }
69
+ };
70
+
71
+ // Periodically sync time to disk so it isn't lost on crash
72
+ setInterval(() => {
73
+ if (isEngineOn && !hasValidSubscription) {
74
+ const sessionH = ((Date.now() - engineStartTime) / 3600000);
75
+ lifetimeStats.hours += sessionH * 1.4;
76
+ lifetimeStats.energy += sessionH * 85;
77
+ engineStartTime = Date.now(); // Reset baseline
78
+ saveStats();
79
+ }
80
+ }, 60000); // Save every 1 minute
81
+
82
+ let stressWorkers = [];
83
+ let hasValidSubscription = false; // Flag to bypass the 1-hour trial limit
84
+ // End of STATE VARIABLES
85
+ // ----------------------------------------------------
86
+ // MAXION RUST CORE INTEGRATION
87
+ // ----------------------------------------------------
88
+ let maxionCore = null;
89
+ try {
90
+ const addon = require('../maxion_rust_core/maxion_rust_core.win32-x64-msvc.node');
91
+ maxionCore = new addon.MaxionCore();
92
+ console.error('[Dashboard] Native Rust Core bindings fully operational.');
93
+ } catch (e) {
94
+ console.error('[Dashboard] Warning: Native Rust Core not loaded:', e.message);
95
+ }
96
+
97
+ app.post('/api/stress_test', (req, res) => {
98
+ const level = req.query.level || 'mild';
99
+ console.error(`[Dashboard] Stress test triggered: Level ${level}`);
100
+
101
+ // Clear old workers
102
+ stressWorkers.forEach(w => {
103
+ try { w.kill(); } catch(e){}
104
+ });
105
+ stressWorkers = [];
106
+ currentStressLevel = level;
107
+
108
+ if (level === 'none') {
109
+ return res.json({ success: true, activeWorkers: 0 });
110
+ }
111
+
112
+ const cpus = os.cpus().length;
113
+ let workerCount = 1; // mild
114
+ if (level === 'moderate') workerCount = Math.max(1, Math.floor(cpus / 2));
115
+ if (level === 'crazy') workerCount = cpus;
116
+
117
+ const workerPath = path.join(__dirname, 'stress_worker.js');
118
+ for (let i = 0; i < workerCount; i++) {
119
+ const args = level === 'crazy' ? ['--crazy'] : [];
120
+ const p = require('child_process').fork(workerPath, args);
121
+ stressWorkers.push(p);
122
+ }
123
+
124
+ // Auto-stop after 30 seconds
125
+ setTimeout(() => {
126
+ stressWorkers.forEach(w => {
127
+ try { w.kill('SIGKILL'); } catch(e){}
128
+ });
129
+ stressWorkers = [];
130
+ currentStressLevel = 'none';
131
+ console.error('[Dashboard] Stress test concluded.');
132
+ }, 30000);
133
+
134
+ res.json({ success: true, activeWorkers: workerCount });
135
+ });
136
+
137
+ app.get('/api/telemetry', async (req, res) => {
138
+ try {
139
+ const [cpuData, memData, tempData] = await Promise.all([
140
+ si.currentLoad(),
141
+ si.mem(),
142
+ si.cpuTemperature()
143
+ ]);
144
+
145
+ let load = cpuData.currentLoad;
146
+ let estimatedTemp = (tempData.main && tempData.main > 0)
147
+ ? tempData.main
148
+ : Math.max(35, 40 + (load * 0.45) + (Math.random() * 1.5));
149
+
150
+ const hoursActive = isEngineOn ? (Date.now() - engineStartTime) / 3600000 : 0;
151
+ const sessionHours = (hoursActive * 1.4);
152
+ const sessionEnergy = (hoursActive * 85);
153
+
154
+ // Trial Lockout Logic (1.0 Hours)
155
+ const TRIAL_LIMIT_HOURS = 1.0;
156
+ let trialExpired = !hasValidSubscription && (lifetimeStats.hours + sessionHours) >= TRIAL_LIMIT_HOURS;
157
+
158
+ if (isEngineOn && trialExpired) {
159
+ isEngineOn = false;
160
+ lifetimeStats.hours += sessionHours;
161
+ lifetimeStats.energy += sessionEnergy;
162
+ saveStats(); // Save locked state
163
+ if (maxionCore) maxionCore.disengage_optimizer();
164
+ console.error('[Dashboard] TRIAL LIMIT EXCEEDED!');
165
+ }
166
+
167
+ res.json({
168
+ cpuLoad: load.toFixed(1),
169
+ memoryUsage: ((memData.active / memData.total) * 100).toFixed(1),
170
+ temperature: estimatedTemp.toFixed(1),
171
+ lifeEnergy: (lifetimeStats.energy + sessionEnergy).toFixed(1),
172
+ trialExpired: trialExpired,
173
+ hasValidSubscription: hasValidSubscription,
174
+ stressLevel: currentStressLevel,
175
+ isEngineOn: isEngineOn
176
+ });
177
+ } catch (e) {
178
+ res.status(500).json({ error: 'Failed to fetch telemetry' });
179
+ }
180
+ });
181
+
182
+ app.post('/api/toggle', (req, res) => {
183
+ const state = req.query.state;
184
+ if (state === 'on') {
185
+ if (!hasValidSubscription && lifetimeStats.hours >= 1.0) {
186
+ return res.json({ success: false, error: 'TRIAL_EXPIRED' });
187
+ }
188
+ isEngineOn = true;
189
+ engineStartTime = Date.now();
190
+ if (maxionCore) maxionCore.engage_optimizer();
191
+ } else {
192
+ if (isEngineOn) {
193
+ const sessionH = ((Date.now() - engineStartTime) / 3600000);
194
+ lifetimeStats.hours += sessionH * 1.4;
195
+ lifetimeStats.energy += sessionH * 85;
196
+ saveStats(); // Save on toggle off
197
+ if (maxionCore) maxionCore.disengage_optimizer();
198
+ }
199
+ isEngineOn = false;
200
+ }
201
+ res.json({ success: true, state });
202
+ });
203
+
204
+ // ----------------------------------------------------
205
+ // AUTHENTICATION & SUBSCRIPTION VERIFICATION
206
+ // ----------------------------------------------------
207
+ app.post('/api/verify', async (req, res) => {
208
+ const { identifier } = req.body;
209
+ if (!identifier) return res.json({ success: false, error: 'Please provide an email or token.' });
210
+
211
+ try {
212
+ const { validateAccess } = require('./auth_gatekeeper');
213
+ const { promo } = req.body;
214
+ const isAuthorized = await validateAccess(identifier, promo);
215
+
216
+ if (isAuthorized) {
217
+ hasValidSubscription = true;
218
+ console.error(`[Dashboard] Subscription verified for: ${identifier}`);
219
+ res.json({ success: true });
220
+ } else {
221
+ res.json({ success: false, error: 'Subscription not found or expired. Please check your Stripe payment or subscribe.' });
222
+ }
223
+ } catch (e) {
224
+ console.error('[Dashboard] Verification error:', e);
225
+ res.status(500).json({ success: false, error: 'Internal server error during verification.' });
226
+ }
227
+ });
228
+
229
+ // Provide public configuration to the frontend (e.g. Stripe checkout URL)
230
+ // Product is specified via ?product=quezar|maxion|diamonize|bundle
231
+ // CRITICAL: Only live (non-test) links are served. If a product is not found or
232
+ // only has a test URL, the endpoint returns a 503 to prevent silent access grants.
233
+ app.get('/api/config', (req, res) => {
234
+ const product = req.query.product || 'quezar';
235
+ const link = STRIPE_REGISTRY[product];
236
+
237
+ // Hard block: never serve a test URL to a production client
238
+ if (!link || link.includes('/test_')) {
239
+ console.error(`[Stripe Registry] BLOCKED: Request for product '${product}' has no valid live payment URL.`);
240
+ return res.status(503).json({
241
+ error: 'STRIPE_LINK_UNAVAILABLE',
242
+ message: `No live payment URL is configured for product: '${product}'. Contact support.`
243
+ });
244
+ }
245
+
246
+ res.json({
247
+ stripePaymentLink: link,
248
+ product
249
+ });
250
+ });
251
+
252
+ // ----------------------------------------------------
253
+ // QUEZAR DIGITAL STORAGE API
254
+ // ----------------------------------------------------
255
+ let quezarLattice = null;
256
+ let maxionAscension = null;
257
+
258
+ try {
259
+ const { MaxionV16 } = require('./quezar/MaxionAscension');
260
+ const { QuezarLattice } = require('./quezar/QuezarApex');
261
+ maxionAscension = new MaxionV16();
262
+ maxionAscension.bootPyramidCore();
263
+ quezarLattice = new QuezarLattice(maxionAscension);
264
+ console.error('[Quezar API] Digital Storage Lattice booted securely.');
265
+ } catch (e) {
266
+ console.error('[Quezar API] Failed to initialize storage lattice:', e);
267
+ }
268
+
269
+ // Tracks active ingestion sessions for live progress streaming
270
+ const quezarIngestionSessions = new Map();
271
+
272
+ app.post('/api/quezar/upload', (req, res) => {
273
+ if (!isEngineOn) return res.status(403).json({ error: 'Engine offline. Trial Expired or Sub needed.' });
274
+ if (!quezarLattice) return res.status(500).json({ error: 'Quezar Storage Offline' });
275
+
276
+ try {
277
+ const { payload } = req.body;
278
+ if (!payload) return res.status(400).json({ error: 'No payload provided' });
279
+
280
+ // Generate a unique session ID for this ingestion so the client can poll progress
281
+ const sessionId = require('crypto').randomBytes(8).toString('hex');
282
+ const payloadBytes = Buffer.byteLength(payload, 'utf8');
283
+
284
+ // Register session: phase 0 = ascension, phase 1 = lattice anchor, phase 2 = vault persist
285
+ quezarIngestionSessions.set(sessionId, { phase: 0, phaseLabel: 'ASCENDING_DATA', progress: 0, bytesIn: payloadBytes, complete: false, error: null });
286
+
287
+ // Run ingestion asynchronously so client can poll /api/quezar/progress
288
+ setImmediate(async () => {
289
+ const session = quezarIngestionSessions.get(sessionId);
290
+ try {
291
+ // Phase 0: Maxion Ascension
292
+ session.phase = 0; session.phaseLabel = 'ASCENDING_DATA'; session.progress = 10;
293
+ await new Promise(r => setTimeout(r, 60)); // simulate hardware phase sync
294
+
295
+ const { ascendedPayload, signature } = maxionAscension.ascendData(payload);
296
+ session.progress = 35;
297
+
298
+ // Phase 1: Geometric Coordinate Derivation
299
+ session.phase = 1; session.phaseLabel = 'DERIVING_5D_COORDINATES'; session.progress = 50;
300
+ const salt = Date.now();
301
+ const coords = [
302
+ Math.floor(Math.random() * 999),
303
+ Math.floor(Math.random() * 999),
304
+ Math.floor(Math.random() * 999),
305
+ 851.7,
306
+ salt % 1000
307
+ ];
308
+ await new Promise(r => setTimeout(r, 40));
309
+
310
+ // Phase 2: Lattice Anchor + Vault Persist
311
+ session.phase = 2; session.phaseLabel = 'ANCHORING_TO_VAULT'; session.progress = 75;
312
+ quezarLattice.anchorSeedToApex(coords, ascendedPayload, signature);
313
+ await new Promise(r => setTimeout(r, 30));
314
+
315
+ // Phase 3: Compression Telemetry
316
+ session.phase = 3; session.phaseLabel = 'CALCULATING_COMPRESSION'; session.progress = 90;
317
+ const zlib = require('zlib');
318
+ const compressedBuffer = zlib.brotliCompressSync(Buffer.from(ascendedPayload, 'utf8'));
319
+ const actualCompressedSize = compressedBuffer.length;
320
+
321
+ session.progress = 100;
322
+ session.phaseLabel = 'INGESTION_COMPLETE';
323
+ session.complete = true;
324
+ session.result = { coords, compressedSize: actualCompressedSize };
325
+ } catch (e) {
326
+ session.error = e.message || 'Lattice Upload Failed';
327
+ session.complete = true;
328
+ }
329
+ });
330
+
331
+ // Immediately return session ID so client can begin polling progress
332
+ res.json({ success: true, sessionId, payloadBytes });
333
+ } catch (e) {
334
+ res.status(500).json({ error: 'Lattice Upload Failed' });
335
+ }
336
+ });
337
+
338
+ // Progress polling endpoint for Quezar ingestion sessions
339
+ app.get('/api/quezar/progress/:sessionId', (req, res) => {
340
+ const session = quezarIngestionSessions.get(req.params.sessionId);
341
+ if (!session) return res.status(404).json({ error: 'Session not found' });
342
+
343
+ const response = {
344
+ phase: session.phase,
345
+ phaseLabel: session.phaseLabel,
346
+ progress: session.progress,
347
+ bytesIn: session.bytesIn,
348
+ complete: session.complete,
349
+ error: session.error || null,
350
+ result: session.result || null
351
+ };
352
+
353
+ // Auto-cleanup completed sessions after delivering final status
354
+ if (session.complete) {
355
+ setTimeout(() => quezarIngestionSessions.delete(req.params.sessionId), 30000);
356
+ }
357
+
358
+ res.json(response);
359
+ });
360
+
361
+ app.post('/api/quezar/retrieve', (req, res) => {
362
+ if (!isEngineOn) return res.status(403).json({ error: 'Engine offline. Trial Expired or Sub needed.' });
363
+ if (!quezarLattice) return res.status(500).json({ error: 'Quezar Storage Offline' });
364
+
365
+ try {
366
+ const { coords } = req.body;
367
+ if (!coords || coords.length !== 5) return res.status(400).json({ error: 'Invalid Coordinates' });
368
+
369
+ const reconstructedData = quezarLattice.dynamicallyReconstruct(coords);
370
+ if (!reconstructedData) return res.status(404).json({ error: 'Data not found or corrupted' });
371
+
372
+ res.json({ success: true, payload: reconstructedData });
373
+ } catch (e) {
374
+ res.status(500).json({ error: 'Lattice Retrieval Failed' });
375
+ }
376
+ });
377
+
378
+ app.post('/api/authorize', (req, res) => {
379
+ // Hidden internal API called by Gatekeeper when access is verified securely
380
+ hasValidSubscription = true;
381
+ res.json({ success: true });
382
+ });
383
+
384
+ app.get('/api/status', (req, res) => {
385
+ res.json({ isEngineOn });
386
+ });
387
+
388
+ app.listen(PORT, () => {
389
+ console.error(`[Maxion Cool Breeze] Dashboard Server running on port ${PORT}`);
390
+
391
+ const startUrl = `http://localhost:${PORT}`;
392
+ // Auto-launch dashboards in browser only if not running in Electron
393
+ if (!process.versions.electron) {
394
+ if (process.platform === 'win32') {
395
+ exec(`start chrome --app="${startUrl}"`, (err) => {
396
+ if (err) exec(`start msedge --app="${startUrl}"`, (e2) => {
397
+ if (e2) exec(`start "" "${startUrl}"`);
398
+ });
399
+ });
400
+ } else {
401
+ exec(`open "${startUrl}"`);
402
+ }
403
+ }
404
+
405
+ // Persistence Protocol: Ensure Maxion is always running
406
+ const registerPersistence = () => {
407
+ if (process.platform !== 'win32') return;
408
+
409
+ const exePath = process.execPath;
410
+ const taskName = "MaxionCoolBreeze_Guardian";
411
+
412
+ // 1. Register with Windows Task Scheduler (Runs on Logon, restarts if failed)
413
+ const schtaskCmd = `schtasks /create /f /tn "${taskName}" /tr "\\"${exePath}\\"" /sc onlogon /rl highest`;
414
+
415
+ // 2. Add to Registry Run key (Redundancy)
416
+ const regCmd = `reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" /v "MaxionCoolBreeze" /t REG_SZ /d "\\"${exePath}\\"" /f`;
417
+
418
+ exec(schtaskCmd, (err) => {
419
+ if (err) console.error('[Persistence] Task Scheduler registration failed:', err.message);
420
+ else console.error('[Persistence] Task Scheduler Guardian established.');
421
+ });
422
+
423
+ exec(regCmd, (err) => {
424
+ if (err) console.error('[Persistence] Registry registration failed:', err.message);
425
+ else console.error('[Persistence] Registry Run key established.');
426
+ });
427
+ };
428
+
429
+ registerPersistence();
430
+ });
@@ -0,0 +1,67 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');
4
+ const { CloudFrontClient, CreateInvalidationCommand } = require('@aws-sdk/client-cloudfront');
5
+ require('dotenv').config();
6
+
7
+ const BUCKET_NAME = 'jk-advanced-tech-web';
8
+ const DISTRIBUTION_ID = 'E24SYIB6L2F9VO';
9
+
10
+ const awsConfig = {
11
+ region: 'us-east-2',
12
+ credentials: {
13
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
14
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
15
+ }
16
+ };
17
+
18
+ const s3Client = new S3Client(awsConfig);
19
+ const cfClient = new CloudFrontClient({ ...awsConfig, region: 'us-east-1' });
20
+
21
+ async function uploadFile(bucket, filePath, s3Key) {
22
+ if (!fs.existsSync(filePath)) {
23
+ throw new Error(`File not found: ${filePath}`);
24
+ }
25
+ const fileBuffer = fs.readFileSync(filePath);
26
+ const command = new PutObjectCommand({
27
+ Bucket: bucket,
28
+ Key: s3Key,
29
+ Body: fileBuffer,
30
+ ContentType: 'application/x-msdownload'
31
+ });
32
+ await s3Client.send(command);
33
+ console.log(`[UPLOAD] Successfully uploaded ${s3Key}`);
34
+ }
35
+
36
+ async function main() {
37
+ try {
38
+ const maxionPath = path.join(__dirname, 'web-hub', 'public', 'maxion-v16-installer.exe');
39
+ const diamonizePath = path.join(__dirname, 'web-hub', 'public', 'diamonize-lsa-installer.exe');
40
+ const quezarPath = path.join(__dirname, 'web-hub', 'public', 'quezar-storage-installer.exe');
41
+
42
+ console.log('Uploading Maxion installer...');
43
+ await uploadFile(BUCKET_NAME, maxionPath, 'maxion-v16-installer.exe');
44
+
45
+ console.log('Uploading Diamonize installer...');
46
+ await uploadFile(BUCKET_NAME, diamonizePath, 'diamonize-lsa-installer.exe');
47
+
48
+ console.log('Uploading Quezar installer...');
49
+ await uploadFile(BUCKET_NAME, quezarPath, 'quezar-storage-installer.exe');
50
+
51
+ console.log('Invalidating CloudFront cache...');
52
+ const cfCommand = new CreateInvalidationCommand({
53
+ DistributionId: DISTRIBUTION_ID,
54
+ InvalidationBatch: {
55
+ CallerReference: `deploy-installers-${Date.now()}`,
56
+ Paths: { Quantity: 1, Items: ['/*'] }
57
+ }
58
+ });
59
+ const cfResponse = await cfClient.send(cfCommand);
60
+ console.log(`[OK] Cache invalidation created. Invalidation ID: ${cfResponse.Invalidation.Id}`);
61
+ console.log('Done Deploying Installers!');
62
+ } catch(e) {
63
+ console.error('Error deploying installers:', e);
64
+ process.exit(1);
65
+ }
66
+ }
67
+ main();
@@ -0,0 +1,36 @@
1
+ require('dotenv').config();
2
+ const fs = require('fs');
3
+ const { LambdaClient, UpdateFunctionCodeCommand, CreateFunctionCommand } = require('@aws-sdk/client-lambda');
4
+
5
+ const awsConfig = {
6
+ region: 'us-east-1',
7
+ credentials: {
8
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
9
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
10
+ }
11
+ };
12
+
13
+ const lambdaClient = new LambdaClient(awsConfig);
14
+ const FUNCTION_NAME = 'lineage_api'; // The name of the lambda
15
+
16
+ async function deployLambda() {
17
+ const zipBuffer = fs.readFileSync('C:\\Users\\aruuh\\.gemini\\antigravity\\scratch\\Maxion_Cool_Breeze\\aws-lambda-stripe\\lineage_api.zip');
18
+
19
+ try {
20
+ console.log(`Attempting to update existing Lambda function: ${FUNCTION_NAME}...`);
21
+ const updateCommand = new UpdateFunctionCodeCommand({
22
+ FunctionName: FUNCTION_NAME,
23
+ ZipFile: zipBuffer
24
+ });
25
+ const result = await lambdaClient.send(updateCommand);
26
+ console.log(`โœ… Successfully updated ${FUNCTION_NAME}. ARN: ${result.FunctionArn}`);
27
+ } catch (error) {
28
+ if (error.name === 'ResourceNotFoundException') {
29
+ console.log(`โŒ Function ${FUNCTION_NAME} does not exist. You will need to create it manually in the AWS Console with an appropriate IAM execution role, then you can use this script to deploy code updates.`);
30
+ } else {
31
+ console.error(`โŒ Failed to deploy Lambda:`, error);
32
+ }
33
+ }
34
+ }
35
+
36
+ deployLambda();
@@ -0,0 +1,56 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');
4
+ const { CloudFrontClient, CreateInvalidationCommand } = require('@aws-sdk/client-cloudfront');
5
+ require('dotenv').config();
6
+
7
+ const BUCKET_NAME = 'jk-advanced-tech-web';
8
+ const DISTRIBUTION_ID = 'E24SYIB6L2F9VO';
9
+
10
+ const awsConfig = {
11
+ region: 'us-east-2',
12
+ credentials: {
13
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
14
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
15
+ }
16
+ };
17
+
18
+ const s3Client = new S3Client(awsConfig);
19
+ const cfClient = new CloudFrontClient({ ...awsConfig, region: 'us-east-1' });
20
+
21
+ async function uploadFile(bucket, filePath, s3Key) {
22
+ if (!fs.existsSync(filePath)) {
23
+ throw new Error('File not found: ' + filePath);
24
+ }
25
+ const fileBuffer = fs.readFileSync(filePath);
26
+ const command = new PutObjectCommand({
27
+ Bucket: bucket,
28
+ Key: s3Key,
29
+ Body: fileBuffer,
30
+ ContentType: 'application/x-msdownload'
31
+ });
32
+ await s3Client.send(command);
33
+ console.log('[UPLOAD] Successfully uploaded ' + s3Key);
34
+ }
35
+
36
+ async function main() {
37
+ try {
38
+ const maxionPath = path.join(__dirname, 'dist', 'maxion', 'maxion-v16-installer Setup 1.0.1.exe');
39
+ console.log('Uploading Maxion installer...');
40
+ await uploadFile(BUCKET_NAME, maxionPath, 'maxion-v16-installer.exe');
41
+
42
+ console.log('Invalidating CloudFront cache...');
43
+ const cfCommand = new CreateInvalidationCommand({
44
+ DistributionId: DISTRIBUTION_ID,
45
+ InvalidationBatch: {
46
+ CallerReference: 'deploy-maxion-' + Date.now(),
47
+ Paths: { Quantity: 1, Items: ['/*'] }
48
+ }
49
+ });
50
+ const cfResponse = await cfClient.send(cfCommand);
51
+ console.log('[OK] Cache invalidation created.');
52
+ } catch(e) {
53
+ console.error('Error deploying:', e);
54
+ }
55
+ }
56
+ main();
@@ -0,0 +1,63 @@
1
+ require('dotenv').config();
2
+ const { LambdaClient, UpdateFunctionCodeCommand } = require("@aws-sdk/client-lambda");
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { execSync } = require('child_process');
6
+
7
+ const FUNCTION_NAME = 'lineage_api';
8
+ const region = "us-east-1";
9
+
10
+ if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
11
+ console.error("โŒ AWS Credentials not found in environment. Please check your .env file.");
12
+ process.exit(1);
13
+ }
14
+
15
+ const creds = {
16
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
17
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
18
+ };
19
+
20
+ const lambdaClient = new LambdaClient({ region, credentials: creds });
21
+
22
+ async function deploy() {
23
+ try {
24
+ console.log("๐Ÿ“ฆ Packaging single-file Lambda handler (leveraging AWS SDK native runtime)...");
25
+
26
+ const tempIndex = path.join(__dirname, 'index.js');
27
+ const zipPath = path.join(__dirname, 'lineage_real_lambda.zip');
28
+
29
+ // Copy handler as index.js temporarily
30
+ fs.copyFileSync(path.join(__dirname, 'aws_lambda_handler.js'), tempIndex);
31
+
32
+ if (fs.existsSync(zipPath)) {
33
+ fs.unlinkSync(zipPath);
34
+ }
35
+
36
+ // Compress index.js into a single ZIP file
37
+ execSync(`powershell -Command "Compress-Archive -Path '${tempIndex}' -DestinationPath '${zipPath}' -Force"`);
38
+
39
+ // Remove temporary index.js immediately
40
+ fs.unlinkSync(tempIndex);
41
+ console.log("โœ… ZIP package generated successfully.");
42
+
43
+ console.log(`๐Ÿš€ Uploading to AWS Lambda function '${FUNCTION_NAME}'...`);
44
+ const zipBuffer = fs.readFileSync(zipPath);
45
+
46
+ const response = await lambdaClient.send(new UpdateFunctionCodeCommand({
47
+ FunctionName: FUNCTION_NAME,
48
+ ZipFile: zipBuffer
49
+ }));
50
+
51
+ console.log(`โœ… DEPLOYMENT SUCCESSFUL! Function ARN: ${response.FunctionArn}`);
52
+
53
+ // Cleanup
54
+ fs.unlinkSync(zipPath);
55
+ console.log("๐Ÿงน Cleaned up temporary build files.");
56
+ process.exit(0);
57
+ } catch (e) {
58
+ console.error("โŒ Deployment failed:", e);
59
+ process.exit(1);
60
+ }
61
+ }
62
+
63
+ deploy();
@@ -0,0 +1,25 @@
1
+ require('dotenv').config();
2
+ const { LambdaClient, UpdateFunctionCodeCommand } = require("@aws-sdk/client-lambda");
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const creds = { accessKeyId: process.env.AWS_ACCESS_KEY_ID, secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY };
7
+ const lambda = new LambdaClient({ region: "us-east-1", credentials: creds });
8
+
9
+ const zipPath = path.join(__dirname, 'submitter.zip');
10
+
11
+ async function deploy() {
12
+ try {
13
+ const zipBuffer = fs.readFileSync(zipPath);
14
+ console.log("Updating LineageRefinePrompt (API Handler) on AWS...");
15
+ const res = await lambda.send(new UpdateFunctionCodeCommand({
16
+ FunctionName: 'LineageRefinePrompt',
17
+ ZipFile: zipBuffer
18
+ }));
19
+ console.log("SUCCESS! Lambda updated. Version:", res.Version);
20
+ } catch (e) {
21
+ console.error("ERROR:", e.message);
22
+ }
23
+ }
24
+
25
+ deploy();