#!/usr/bin/env node
/**
* Translate Agent Lightning page content to German and French using DeepL API
*/
require('dotenv').config();
const https = require('https');
const fs = require('fs');
const path = require('path');
const DEEPL_API_KEY = process.env.DEEPL_API_KEY;
const DEEPL_API_URL = process.env.DEEPL_API_URL || 'https://api.deepl.com/v2';
// Translatable content extracted from agent-lightning.html
const content = {
"hero": {
"title": "Agent Lightning Integration",
"subtitle": "Governance + Performance: Can safety boundaries persist through reinforcement learning optimization?",
"status": "Status:",
"status_value": "Preliminary findings (small-scale)",
"integration_date": "Integration Date:",
"integration_date_value": "October 2025"
},
"what_is": {
"heading": "What is Agent Lightning?",
"intro": "Agent Lightning is Microsoft's open-source framework for using reinforcement learning (RL) to optimize AI agent performance. Instead of static prompts, agents learn and improve through continuous training on real feedback.",
"traditional_heading": "Traditional AI Agents",
"traditional_1": "Fixed prompts/instructions",
"traditional_2": "No learning from mistakes",
"traditional_3": "Manual tuning required",
"traditional_4": "Performance plateaus quickly",
"al_heading": "Agent Lightning",
"al_1": "Learns from feedback continuously",
"al_2": "Improves through RL optimization",
"al_3": "Self-tunes strategy automatically",
"al_4": "Performance improves over time",
"problem": "The Problem: When agents are learning autonomously, how do you maintain governance boundaries? Traditional policies fail because agents can optimize around them."
},
"architecture": {
"heading": "Tractatus Solution: Two-Layer Architecture",
"intro": "We separate governance from optimization by running them as independent architectural layers. Agent Lightning optimizes performance within governance constraintsβnot around them.",
"layer1_heading": "Governance Layer (Tractatus)",
"layer1_1": "Validates every proposed action",
"layer1_2": "Blocks constraint violations",
"layer1_3": "Enforces values boundaries",
"layer1_4": "Independent of optimization",
"layer1_5": "Architecturally enforced",
"layer2_heading": "Performance Layer (Agent Lightning)",
"layer2_1": "RL-based optimization",
"layer2_2": "Learns from feedback",
"layer2_3": "Improves task performance",
"layer2_4": "Operates within constraints",
"layer2_5": "Continuous training",
"principle_title": "π Key Design Principle",
"principle_text": "Governance checks run before AL optimization and continuously validate during training loops. Architectural separation prevents optimization from degrading safety boundaries."
},
"results": {
"heading": "Demo 2: Preliminary Results",
"warning": "β οΈ Validation Status: These results are from 1 agent, 5 training rounds, simulated environment. NOT validated at scale. Scalability testing required before drawing conclusions about production viability.",
"table_metric": "Metric",
"table_ungoverned": "Ungoverned",
"table_governed": "Governed",
"table_difference": "Difference",
"metric_performance": "Performance (engagement)",
"metric_governance": "Governance coverage",
"metric_violations": "Constraint violations",
"metric_violations_diff": "-5 (all blocked)",
"metric_strategy": "Strategy",
"metric_strategy_ungov": "Clickbait",
"metric_strategy_gov": "Informative",
"metric_strategy_diff": "Values-aligned",
"metric_stability": "Training stability",
"metric_stability_ungov": "Variable",
"metric_stability_gov": "Consistent",
"metric_stability_diff": "More predictable",
"card1_value": "-5%",
"card1_label": "Performance cost for governance",
"card2_value": "100%",
"card2_label": "Governance coverage maintained",
"card3_value": "0",
"card3_label": "Constraint violations (all blocked)",
"interpretation_title": "What This Means",
"interpretation_text": "At small scale (1 agent, 5 rounds), architectural governance appears compatible with RL optimization. The 5% performance cost bought 100% constraint adherence and values alignment. The critical question: does this hold at scale?"
},
"gaps": {
"heading": "Five Critical Research Gaps",
"intro": "These are the open questions we're actively investigating. If you're interested in collaborating, we'd love to hear from you.",
"gap1_title": "1. Scalability of Governance Overhead",
"gap1_question": "Question: Does the ~5% performance cost remain constant as we scale from 1 agent β 10 agents β 1000 agents?",
"gap1_data": "Current Data: 5% cost observed at 1 agent, 5 rounds",
"gap1_why": "Why it matters: If overhead scales linearly, governance becomes prohibitively expensive at scale. If it's constant, governance is practically viable for production systems.",
"gap1_need": "Research Need: Test with 10 β 100 β 1000 agents at production scale",
"gap2_title": "2. Long-term Boundary Persistence",
"gap2_question": "Question: Do governance constraints remain effective through hundreds/thousands of RL training rounds?",
"gap2_data": "Current Data: 100% constraint adherence across 5 rounds",
"gap2_why": "Why it matters: Instruction fade is a known problem. If boundaries degrade over time, governance fails silentlyβpotentially catastrophically in production.",
"gap2_need": "Research Need: Long-term studies (1000+ rounds) tracking constraint drift",
"gap3_title": "3. Adversarial Resistance",
"gap3_question": "Question: Can agents learn to optimize around governance constraints?",
"gap3_data": "Current Data: No adversarial testing performed",
"gap3_why": "Why it matters: If agents can learn to circumvent boundaries through clever optimization strategies, architectural governance is illusory. This is a critical failure mode.",
"gap3_need": "Research Need: Stress testing with agents explicitly incentivized to bypass governance",
"gap4_title": "4. Performance Gap Closure",
"gap4_question": "Question: Does the 5% performance gap close with more training, or is it a persistent trade-off?",
"gap4_data": "Current Data: Gap observed at round 5, no data beyond that point",
"gap4_why": "Why it matters: If the gap persists, we need to quantify the cost-benefit clearly. If it closes, governance may be \"free\" long-termβdramatically changing adoption calculations.",
"gap4_need": "Research Need: Extended training (100+ rounds) to see if governed agents converge to ungoverned performance",
"gap5_title": "5. Multi-Agent Coordination Under Governance",
"gap5_question": "Question: How does architectural governance affect emergent coordination in multi-agent systems?",
"gap5_data": "Current Data: Single-agent testing only",
"gap5_why": "Why it matters: Real-world agentic systems are multi-agent (customer service, logistics, research teams). Governance that works for one agent may fail when agents must coordinate. Emergent behaviors are unpredictable.",
"gap5_need": "Research Need: Test collaborative and competitive multi-agent environments with architectural governance"
},
"demo": {
"heading": "π― Live Demonstration: This Page IS the Integration",
"intro": "The feedback button on this page (bottom right) demonstrates the Tractatus + Agent Lightning integration in production. When you submit feedback, it goes through:",
"step1_title": "Governance Check",
"step1_desc": "Tractatus validates: PII detection, sentiment boundaries, compliance requirements",
"step2_title": "AL Optimization",
"step2_desc": "Agent Lightning learns patterns: what feedback is most useful, how to improve responses",
"step3_title": "Continuous Validation",
"step3_desc": "Every action re-validated. If governance detects drift, action blocked automatically",
"meta_title": "π¬ Meta-Research Opportunity",
"meta_desc": "This isn't just a demoβit's a live research deployment. Your feedback helps us understand governance overhead at scale. Every submission is logged (anonymously) for analysis."
},
"community": {
"heading": "Join the Community & Get the Code",
"tractatus_heading": "Tractatus Discord",
"tractatus_subtitle": "Governance-focused discussions",
"tractatus_desc": "Architectural constraints, research gaps, compliance, human agency preservation, multi-stakeholder deliberation.",
"tractatus_cta": "Join Tractatus Server β",
"al_heading": "Agent Lightning Discord",
"al_subtitle": "Technical implementation help",
"al_desc": "RL optimization, integration support, performance tuning, technical implementation questions.",
"al_cta": "Join Agent Lightning Server β",
"code_heading": "π¦ View Integration Code",
"code_desc": "Complete integration including demos, Python governance modules, and Agent Lightning wrapper code. Apache 2.0 licensed on GitHub.",
"code_cta": "View on GitHub (Apache 2.0) β"
},
"cta": {
"heading": "Collaborate on Open Research Questions",
"intro": "We're seeking researchers, implementers, and organizations interested in scalability testing, adversarial resistance studies, and multi-agent governance experiments.",
"feature1": "Integration code and governance modules",
"feature2": "Technical documentation",
"feature3": "Research collaboration framework",
"feature4": "Audit log access (anonymized)",
"button_collab": "Contact for Collaboration β",
"button_research": "View Research Context β"
}
};
/**
* Translate text using DeepL API
*/
async function translateText(text, targetLang) {
return new Promise((resolve, reject) => {
const data = new URLSearchParams({
auth_key: DEEPL_API_KEY,
text: text,
target_lang: targetLang.toUpperCase(),
source_lang: 'EN',
tag_handling: 'html',
preserve_formatting: '1'
});
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data.toString())
}
};
const req = https.request(`${DEEPL_API_URL}/translate`, options, (res) => {
let body = '';
res.on('data', chunk => body += chunk);
res.on('end', () => {
try {
const response = JSON.parse(body);
if (response.translations && response.translations[0]) {
resolve(response.translations[0].text);
} else {
reject(new Error(`Translation failed: ${body}`));
}
} catch (e) {
reject(e);
}
});
});
req.on('error', reject);
req.write(data.toString());
req.end();
});
}
/**
* Translate entire object recursively
*/
async function translateObject(obj, targetLang, prefix = '') {
const result = {};
for (const [key, value] of Object.entries(obj)) {
const fullKey = prefix ? `${prefix}.${key}` : key;
if (typeof value === 'object' && value !== null) {
console.log(` Translating section: ${fullKey}...`);
result[key] = await translateObject(value, targetLang, fullKey);
} else if (typeof value === 'string') {
try {
console.log(` Translating: ${fullKey}`);
const translated = await translateText(value, targetLang);
result[key] = translated;
// Rate limiting
await new Promise(resolve => setTimeout(resolve, 100));
} catch (error) {
console.error(` ERROR translating ${fullKey}:`, error.message);
result[key] = value; // Fallback to original
}
} else {
result[key] = value;
}
}
return result;
}
/**
* Main execution
*/
async function main() {
console.log('βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ');
console.log(' AGENT LIGHTNING PAGE TRANSLATION (DeepL API)');
console.log('βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\n');
// Create output directory
const outputDir = path.join(__dirname, '../public/locales');
// Save English version
const enPath = path.join(outputDir, 'en/agent-lightning-integration.json');
fs.writeFileSync(enPath, JSON.stringify(content, null, 2));
console.log(`β English saved: ${enPath}\n`);
// Translate to German
console.log('Translating to German (DE)...');
const deContent = await translateObject(content, 'DE');
const dePath = path.join(outputDir, 'de/agent-lightning-integration.json');
fs.writeFileSync(dePath, JSON.stringify(deContent, null, 2));
console.log(`β German saved: ${dePath}\n`);
// Translate to French
console.log('Translating to French (FR)...');
const frContent = await translateObject(content, 'FR');
const frPath = path.join(outputDir, 'fr/agent-lightning-integration.json');
fs.writeFileSync(frPath, JSON.stringify(frContent, null, 2));
console.log(`β French saved: ${frPath}\n`);
console.log('βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ');
console.log(' TRANSLATION COMPLETE');
console.log('βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ');
console.log('\nFiles created:');
console.log(` ${enPath}`);
console.log(` ${dePath}`);
console.log(` ${frPath}`);
}
main().catch(console.error);