Created by diktatcart
Krumbs — Asignar Archivo a Caja de Coordenadas
1. Selecciona el archivo de código:
Archivo seleccionado: services/ml_analyzer.py
2. Destino: Coordenada de la Caja en la Matriz 8×7:
Fila (V): Columna (F):
Krumbs IDE — [editor.py]
IdeaVim Engine:
-- NORMAL --
1
:
Ln: 1, Col: 1 | UTF-8 | [NORMAL]
Ready
Krumbs — Integrar Código a Caja
Nombre del archivo de código:
Selecciona la coordenada de la Caja destino (Matriz 8×7):
Fila (V): Columna (F):
Krumbs — Registro de Distribución y Ubicación de Archivos en Cajas
🔍 Buscar:
Archivo de Código Ubicación / Caja Destino Lenguaje Función API Acciones
Total Archivos: 6 | Cajas con Código: 1/56
Ready · Mapeo Activo en Memoria 💾
Archivos: 6
BLOG
ADMIN
TOOL 3
GITHUB
DYNAMO
Strix
STRIX
GRID 8x7
GIT VAULT
TYPESCRIPT
VISION
RUST
PYTHON
OCTAVE

' + String(title).replace(/' + (note.html || '') + ''; } else if (kind === 'md') { ext = 'md'; mime = 'text/markdown;charset=utf-8'; body = '# ' + title + '\n\n' + notepadHtmlToMarkdown(note.html || ''); } else { const editor = document.getElementById('notepadEditor'); body = (editor ? editor.innerText : '') || ''; } const blob = new Blob([body], { type: mime }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = notepadSafeName(title, ext); document.body.appendChild(a); a.click(); a.remove(); setTimeout(() => URL.revokeObjectURL(url), 1200); notepadSetStatusRight('descargado · .' + ext); } function notepadFindNext() { const input = document.getElementById('notepadFindInput'); const editor = document.getElementById('notepadEditor'); if (!input || !editor) return; const q = String(input.value || ''); if (!q) return; const text = editor.innerText || ''; const from = notepadState.findIndex || 0; let idx = text.toLowerCase().indexOf(q.toLowerCase(), from); if (idx < 0 && from > 0) idx = text.toLowerCase().indexOf(q.toLowerCase(), 0); if (idx < 0) { notepadSetStatusRight('sin coincidencias'); return; } notepadState.findIndex = idx + q.length; try { const sel = window.getSelection(); const range = document.createRange(); // fallback highlight via window.find when available if (window.find) { sel.removeAllRanges(); window.find(q, false, false, true, false, false, false); } } catch (e) {} notepadSetStatusRight('encontrado'); } let notepadOpenBusy = false; async function toggleNotepadEditor(force) { const overlay = document.getElementById('notepadOverlay'); const btn = document.getElementById('notepadOpenBtn'); if (!overlay) return; const currentlyOpen = overlay.classList.contains('open'); const open = typeof force === 'boolean' ? force : !currentlyOpen; overlay.classList.toggle('open', open); overlay.setAttribute('aria-hidden', open ? 'false' : 'true'); if (btn) btn.setAttribute('aria-expanded', open ? 'true' : 'false'); if (open) { if (!notepadState.notes.length) notepadLoadStore(); notepadSelect(notepadState.activeId || (notepadState.notes[0] && notepadState.notes[0].id), true); const editor = document.getElementById('notepadEditor'); setTimeout(() => { try { editor && editor.focus(); } catch (e) {} }, 30); try { consumeTokens('notepad', 'bloc de notas'); } catch (e) {} } else { notepadFlushActiveFromDom(); notepadPersist(true); } } /* ===== Chat IA (inserta contenido puro en la selección) ===== */ let notepadAiProviders = []; let notepadAiBusy = false; function notepadAiHeaders() { const headers = { 'Content-Type': 'application/json' }; try { const tok = (typeof window.l8GetAuthToken === 'function') ? window.l8GetAuthToken() : ''; if (tok) headers['Authorization'] = 'Bearer ' + tok; } catch (e) {} try { const guest = localStorage.getItem('l8_tokens_guest') || ''; if (guest) headers['X-L8-Tokens-Guest'] = guest; } catch (e) {} return headers; } function notepadAiSelectedProvider() { const sel = document.getElementById('notepadAiModel'); return sel ? sel.value : 'gpt-5.6'; } function notepadAiSetConnStatus(text, kind) { const el = document.getElementById('notepadAiConnStatus'); if (!el) return; el.textContent = text || ''; el.classList.toggle('err', kind === 'err'); el.classList.toggle('ok', kind === 'ok'); } function notepadAiSetRunStatus(text, kind) { const el = document.getElementById('notepadAiRunStatus'); if (!el) return; el.textContent = text || ''; el.classList.toggle('err', kind === 'err'); el.classList.toggle('ok', kind === 'ok'); } function notepadAiUpdateConnUi() { const id = notepadAiSelectedProvider(); const row = notepadAiProviders.find((p) => p.id === id); const loginBox = document.getElementById('notepadAiLoginBox'); if (!row) { notepadAiSetConnStatus('modelo no disponible', 'err'); return; } if (row.connected) { notepadAiSetConnStatus(row.label + ' · conectado' + (row.oauth_ready ? ' (OAuth)' : ''), 'ok'); if (loginBox) loginBox.classList.remove('open'); } else if (row.oauth_ready) { notepadAiSetConnStatus(row.label + ' · inicia sesión OAuth', 'err'); } else if (row.configured) { notepadAiSetConnStatus(row.label + ' · usa token / API key', 'err'); if (loginBox) loginBox.classList.add('open'); } else { notepadAiSetConnStatus(row.label + ' · configura OAuth en el servidor o pega token', 'err'); if (loginBox) loginBox.classList.add('open'); } } async function notepadAiRefreshStatus() { try { const res = await fetch('/api/ai/status', { headers: notepadAiHeaders() }); const data = await res.json(); if (data && data.ok && Array.isArray(data.providers)) { notepadAiProviders = data.providers; notepadAiUpdateConnUi(); return data; } } catch (e) {} notepadAiSetConnStatus('no se pudo leer estado IA', 'err'); return null; } function toggleNotepadAiPanel(force) { const panel = document.getElementById('notepadAiPanel'); const btn = document.getElementById('notepadAiToggleBtn'); if (!panel) return; const open = typeof force === 'boolean' ? force : !panel.classList.contains('open'); panel.classList.toggle('open', open); if (btn) { btn.classList.toggle('active', open); btn.setAttribute('aria-expanded', open ? 'true' : 'false'); } if (open) notepadAiRefreshStatus(); } function notepadGetSelectionContext() { const editor = document.getElementById('notepadEditor'); if (!editor) return ''; try { const sel = window.getSelection(); if (sel && sel.rangeCount && editor.contains(sel.anchorNode)) { const selected = String(sel.toString() || ''); if (selected.trim()) return selected; } } catch (e) {} const text = editor.innerText || ''; return text.slice(0, 1200); } function notepadInsertAtSelection(content) { const editor = document.getElementById('notepadEditor'); if (!editor) return false; editor.focus(); const text = String(content || ''); let ok = false; try { ok = document.execCommand('insertText', false, text); } catch (e) { ok = false; } if (!ok) { try { const sel = window.getSelection(); if (sel && sel.rangeCount && editor.contains(sel.anchorNode)) { const range = sel.getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(text)); range.collapse(false); sel.removeAllRanges(); sel.addRange(range); ok = true; } else { editor.appendChild(document.createTextNode(text)); ok = true; } } catch (e) { editor.textContent = (editor.textContent || '') + text; ok = true; } } notepadMarkDirty(); notepadUpdateCounts(); return ok; } async function notepadAiStartOauth() { const provider = notepadAiSelectedProvider(); notepadAiSetRunStatus('abriendo OAuth…'); try { const res = await fetch('/api/ai/oauth/start', { method: 'POST', headers: notepadAiHeaders(), body: JSON.stringify({ provider: provider }) }); const data = await res.json(); if (data && data.ok && data.authorize_url) { const w = window.open(data.authorize_url, 'l8-ai-oauth', 'width=560,height=720'); if (!w) { notepadAiSetRunStatus('permite ventanas emergentes para OAuth', 'err'); const box = document.getElementById('notepadAiLoginBox'); if (box) box.classList.add('open'); return; } notepadAiSetRunStatus('completa el inicio de sesión en la ventana OAuth…'); return; } if (data && data.allow_token_login) { const box = document.getElementById('notepadAiLoginBox'); if (box) box.classList.add('open'); } notepadAiSetRunStatus((data && data.error) || 'OAuth no disponible', 'err'); } catch (e) { notepadAiSetRunStatus(e.message || String(e), 'err'); } } async function notepadAiSaveToken() { const provider = notepadAiSelectedProvider(); const input = document.getElementById('notepadAiTokenInput'); const token = input ? input.value.trim() : ''; if (!token) { notepadAiSetRunStatus('pega un access token o API key', 'err'); return; } try { const res = await fetch('/api/ai/login', { method: 'POST', headers: notepadAiHeaders(), body: JSON.stringify({ provider: provider, token: token, kind: /^sk-|^AIza|^sk-ant-|^manus/i.test(token) ? 'api_key' : 'access_token' }) }); const data = await res.json(); if (data && data.ok) { if (input) input.value = ''; await notepadAiRefreshStatus(); notepadAiSetRunStatus('sesión guardada en servidor', 'ok'); } else { notepadAiSetRunStatus((data && data.error) || 'no se pudo guardar', 'err'); } } catch (e) { notepadAiSetRunStatus(e.message || String(e), 'err'); } } async function notepadAiLogout() { const provider = notepadAiSelectedProvider(); try { await fetch('/api/ai/logout', { method: 'POST', headers: notepadAiHeaders(), body: JSON.stringify({ provider: provider }) }); await notepadAiRefreshStatus(); notepadAiSetRunStatus('sesión cerrada', 'ok'); } catch (e) { notepadAiSetRunStatus(e.message || String(e), 'err'); } } async function notepadAiSend() { if (notepadAiBusy) return; const promptEl = document.getElementById('notepadAiPrompt'); const prompt = promptEl ? promptEl.value.trim() : ''; if (!prompt) { notepadAiSetRunStatus('escribe qué contenido quieres insertar', 'err'); return; } const provider = notepadAiSelectedProvider(); notepadAiBusy = true; const sendBtn = document.getElementById('notepadAiSendBtn'); if (sendBtn) sendBtn.disabled = true; notepadAiSetRunStatus('generando con ' + provider + '…'); try { const res = await fetch('/api/ai/chat', { method: 'POST', headers: notepadAiHeaders(), body: JSON.stringify({ provider: provider, prompt: prompt, context: notepadGetSelectionContext() }) }); const data = await res.json(); if (data && data.ok && typeof data.content === 'string') { notepadInsertAtSelection(data.content); if (promptEl) promptEl.value = ''; notepadAiSetRunStatus('insertado · ' + (data.label || provider), 'ok'); } else { if (data && data.code === 'not_authenticated') { const box = document.getElementById('notepadAiLoginBox'); if (box) box.classList.add('open'); } notepadAiSetRunStatus((data && data.error) || 'falló la generación', 'err'); } } catch (e) { notepadAiSetRunStatus(e.message || String(e), 'err'); } finally { notepadAiBusy = false; if (sendBtn) sendBtn.disabled = false; } } function initNotepadAiChat() { const model = document.getElementById('notepadAiModel'); const oauthBtn = document.getElementById('notepadAiOauthBtn'); const logoutBtn = document.getElementById('notepadAiLogoutBtn'); const tokenBtn = document.getElementById('notepadAiTokenBtn'); const sendBtn = document.getElementById('notepadAiSendBtn'); const prompt = document.getElementById('notepadAiPrompt'); if (model) model.addEventListener('change', () => notepadAiUpdateConnUi()); if (oauthBtn) oauthBtn.addEventListener('click', () => notepadAiStartOauth()); if (logoutBtn) logoutBtn.addEventListener('click', () => notepadAiLogout()); if (tokenBtn) tokenBtn.addEventListener('click', () => notepadAiSaveToken()); if (sendBtn) sendBtn.addEventListener('click', () => notepadAiSend()); if (prompt) { prompt.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); notepadAiSend(); } }); } window.addEventListener('message', (ev) => { const data = ev && ev.data; if (!data || data.type !== 'l8-ai-oauth') return; notepadAiRefreshStatus(); notepadAiSetRunStatus(data.ok ? 'OAuth completado' : 'OAuth falló', data.ok ? 'ok' : 'err'); }); } let notepadOcgBusy = false; let notepadOcgLoadPromise = null; let notepadOcgCatalogReady = false; function notepadOcgSetStatus(text, kind) { const el = document.getElementById('notepadOcgStatus'); if (!el) return; el.textContent = text || ''; el.classList.toggle('err', kind === 'err'); el.classList.toggle('ok', kind === 'ok'); } function notepadOcgLoadScript(src) { return new Promise((resolve, reject) => { const existing = document.querySelector('script[data-ocg-src="' + src + '"]'); if (existing) { if (existing.getAttribute('data-loaded') === '1') { resolve(); return; } existing.addEventListener('load', () => resolve(), { once: true }); existing.addEventListener('error', () => reject(new Error('No se pudo cargar ' + src)), { once: true }); return; } const s = document.createElement('script'); s.src = src; s.async = false; s.setAttribute('data-ocg-src', src); s.onload = () => { s.setAttribute('data-loaded', '1'); resolve(); }; s.onerror = () => reject(new Error('No se pudo cargar ' + src)); document.head.appendChild(s); }); } function notepadOcgEnsureLoaded() { if (window.OCG_GEN && window.OCG_CATALOG) { return Promise.resolve(); } if (notepadOcgLoadPromise) return notepadOcgLoadPromise; notepadOcgLoadPromise = notepadOcgLoadScript('/opencryptg/data/catalog.js?v=ocg-10100-1') .then(() => notepadOcgLoadScript('/opencryptg/data/generators.js?v=ocg-10100-1')) .then(() => { if (!window.OCG_GEN || !window.OCG_CATALOG) { throw new Error('Inventario OpenCriptG no disponible'); } }) .catch((err) => { notepadOcgLoadPromise = null; throw err; }); return notepadOcgLoadPromise; } function notepadOcgTypeLabel(type) { if (!type) return ''; const variant = type.hashcodVariant ? (type.hashcodVariant + ' · ') : ''; return variant + (type.originalLabel || type.label || type.id); } function notepadOcgPopulateCategories() { const catSel = document.getElementById('notepadOcgCategory'); if (!catSel || !window.OCG_CATALOG) return; const prev = catSel.value; catSel.innerHTML = ''; const all = document.createElement('option'); all.value = '__all__'; all.textContent = 'Todas las categorías (10.100)'; catSel.appendChild(all); (window.OCG_CATALOG || []).forEach((cat) => { const opt = document.createElement('option'); opt.value = cat.id; const n = (cat.types || []).length; opt.textContent = (cat.label || cat.id) + ' (' + n + ')'; catSel.appendChild(opt); }); if (prev && [...catSel.options].some((o) => o.value === prev)) { catSel.value = prev; } } function notepadOcgFilteredTypes() { const catSel = document.getElementById('notepadOcgCategory'); const filterEl = document.getElementById('notepadOcgFilter'); const catId = catSel ? catSel.value : '__all__'; const q = (filterEl ? filterEl.value : '').trim().toLowerCase(); const out = []; (window.OCG_CATALOG || []).forEach((cat) => { if (catId !== '__all__' && cat.id !== catId) return; (cat.types || []).forEach((type) => { const hay = [ type.id, type.label, type.originalLabel, type.hashcodVariant, type.badge, type.engine, cat.label ].join(' ').toLowerCase(); if (q && hay.indexOf(q) === -1) return; out.push({ cat: cat, type: type }); }); }); return out; } function notepadOcgPopulateTypes() { const typeSel = document.getElementById('notepadOcgType'); if (!typeSel) return; const prev = typeSel.value; const rows = notepadOcgFilteredTypes(); const maxOpts = 800; typeSel.innerHTML = ''; const shown = rows.slice(0, maxOpts); shown.forEach((row) => { const opt = document.createElement('option'); opt.value = row.type.id; opt.textContent = notepadOcgTypeLabel(row.type); opt.title = (row.cat.label || '') + ' · ' + (row.type.engine || ''); typeSel.appendChild(opt); }); if (!shown.length) { const opt = document.createElement('option'); opt.value = ''; opt.textContent = 'Sin coincidencias'; typeSel.appendChild(opt); } else if (prev && [...typeSel.options].some((o) => o.value === prev)) { typeSel.value = prev; } const extra = rows.length > maxOpts ? (' · mostrando ' + maxOpts + ' de ' + rows.length) : ''; notepadOcgSetStatus('inventario OpenCriptG · ' + rows.length + ' tipos filtrados' + extra + ' · códigos únicos'); } async function toggleNotepadOcgPanel(force) { const panel = document.getElementById('notepadOcgPanel'); const btn = document.getElementById('notepadOcgToggleBtn'); if (!panel) return; const open = typeof force === 'boolean' ? force : !panel.classList.contains('open'); panel.classList.toggle('open', open); if (btn) { btn.classList.toggle('active', open); btn.setAttribute('aria-expanded', open ? 'true' : 'false'); } if (open) { toggleNotepadAiPanel(false); notepadOcgSetStatus('cargando inventario OpenCriptG (10.100)…'); try { await notepadOcgEnsureLoaded(); if (!notepadOcgCatalogReady) { notepadOcgPopulateCategories(); notepadOcgCatalogReady = true; } notepadOcgPopulateTypes(); try { const res = await fetch('/api/opencrypt/status'); const data = await res.json(); if (data && data.ok) { notepadOcgSetStatus( 'inventario 10.100 tipos · ledger únicos: ' + (data.ledger_count || 0), 'ok' ); } } catch (e) {} } catch (e) { notepadOcgSetStatus(e.message || String(e), 'err'); } } } async function notepadOcgClaim(codes) { const res = await fetch('/api/opencrypt/claim', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ codes: codes }) }); const data = await res.json(); if (!data || !data.ok) { throw new Error((data && data.error) || 'No se pudo registrar unicidad'); } return data; } async function notepadOcgGenerateUnique(typeId, label, qty) { const accepted = []; const maxAttempts = Math.max(20, qty * 8); let attempts = 0; while (accepted.length < qty && attempts < maxAttempts) { const batch = []; const need = qty - accepted.length; for (let i = 0; i < need; i++) { attempts++; const raw = await window.OCG_GEN.generate(typeId); const code = String(raw == null ? '' : raw); if (!code) continue; batch.push({ type_id: typeId, label: label, code: code }); } if (!batch.length) continue; const claim = await notepadOcgClaim(batch); (claim.accepted || []).forEach((row) => accepted.push(row)); } if (accepted.length < qty) { throw new Error('No se pudieron obtener ' + qty + ' códigos únicos (colisiones o generador)'); } return accepted; } async function notepadOcgGenerateAndInsert() { if (notepadOcgBusy) return; const typeSel = document.getElementById('notepadOcgType'); const qtyEl = document.getElementById('notepadOcgQty'); const typeId = typeSel ? typeSel.value : ''; let qty = qtyEl ? parseInt(qtyEl.value, 10) : 1; if (!typeId) { notepadOcgSetStatus('elige un tipo del inventario', 'err'); return; } if (!Number.isFinite(qty) || qty < 1) qty = 1; if (qty > 25) qty = 25; if (qtyEl) qtyEl.value = String(qty); notepadOcgBusy = true; const btn = document.getElementById('notepadOcgGenerateBtn'); if (btn) btn.disabled = true; notepadOcgSetStatus('generando códigos únicos…'); try { await notepadOcgEnsureLoaded(); let label = typeId; const opt = typeSel && typeSel.selectedOptions && typeSel.selectedOptions[0]; if (opt) label = opt.textContent || typeId; const rows = await notepadOcgGenerateUnique(typeId, label, qty); const block = rows.map((row, idx) => { const head = '[' + (idx + 1) + '/' + rows.length + '] ' + (row.label || row.type_id); return head + '\n' + row.code; }).join('\n\n'); notepadInsertAtSelection(block + (block.endsWith('\n') ? '' : '\n')); notepadOcgSetStatus( 'insertados ' + rows.length + ' código(s) únicos · ledger ' + (rows[0] ? '' : '') + 'ok', 'ok' ); try { const st = await fetch('/api/opencrypt/status').then((r) => r.json()); if (st && st.ok) { notepadOcgSetStatus( 'insertados ' + rows.length + ' · ledger únicos: ' + (st.ledger_count || 0), 'ok' ); } } catch (e) {} } catch (e) { notepadOcgSetStatus(e.message || String(e), 'err'); } finally { notepadOcgBusy = false; if (btn) btn.disabled = false; } } function initNotepadOcgTool() { const cat = document.getElementById('notepadOcgCategory'); const filter = document.getElementById('notepadOcgFilter'); const genBtn = document.getElementById('notepadOcgGenerateBtn'); if (cat) cat.addEventListener('change', () => notepadOcgPopulateTypes()); if (filter) { let t = null; filter.addEventListener('input', () => { clearTimeout(t); t = setTimeout(() => notepadOcgPopulateTypes(), 120); }); } if (genBtn) genBtn.addEventListener('click', () => notepadOcgGenerateAndInsert()); } function initNotepadEditor() { if (window.__l8NotepadReady) return; const overlay = document.getElementById('notepadOverlay'); const editor = document.getElementById('notepadEditor'); const title = document.getElementById('notepadTitle'); const closeBtn = document.getElementById('notepadCloseBtn'); if (!overlay || !editor) return; window.__l8NotepadReady = true; notepadLoadStore(); initNotepadAiChat(); initNotepadOcgTool(); if (closeBtn) closeBtn.addEventListener('click', () => toggleNotepadEditor(false)); overlay.addEventListener('click', (e) => { if (e.target === overlay) toggleNotepadEditor(false); }); document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && overlay.classList.contains('open')) { toggleNotepadEditor(false); } }); editor.addEventListener('input', () => notepadMarkDirty()); if (title) { title.addEventListener('input', () => { const note = notepadActive(); if (note) note.title = title.value; notepadMarkDirty(); notepadRenderList(); }); } overlay.querySelectorAll('[data-cmd]').forEach((btn) => { btn.addEventListener('click', () => { notepadExec(btn.getAttribute('data-cmd'), btn.getAttribute('data-value')); }); }); overlay.querySelectorAll('[data-action]').forEach((btn) => { btn.addEventListener('click', async () => { const action = btn.getAttribute('data-action'); if (action === 'new') notepadCreate(); else if (action === 'delete') notepadDeleteActive(); else if (action === 'ai-toggle') { toggleNotepadOcgPanel(false); toggleNotepadAiPanel(); } else if (action === 'ocg-toggle') toggleNotepadOcgPanel(); else if (action === 'save') { notepadFlushActiveFromDom(); notepadRenderList(); notepadPersist(true); } else if (action === 'copy') { try { await navigator.clipboard.writeText(editor.innerText || ''); notepadSetStatusRight('copiado'); } catch (e) { notepadSetStatusRight('no se pudo copiar'); } } else if (action === 'download-md') notepadDownload('md'); else if (action === 'download-html') notepadDownload('html'); else if (action === 'download-txt') notepadDownload('txt'); else if (action === 'find') { const bar = document.getElementById('notepadFindBar'); if (bar) { bar.classList.add('open'); const input = document.getElementById('notepadFindInput'); if (input) input.focus(); } } else if (action === 'find-next') notepadFindNext(); else if (action === 'find-close') { const bar = document.getElementById('notepadFindBar'); if (bar) bar.classList.remove('open'); } }); }); const findInput = document.getElementById('notepadFindInput'); if (findInput) { findInput.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); notepadFindNext(); } }); } } document.addEventListener('DOMContentLoaded', initNotepadEditor); /* ===== Toolkit tool: Ingeniería (agency-agents/engineering) ===== */ const TOOLKIT_ENGINEERING_BASE = l8Asset('toolkit/agency-agents/engineering'); let toolkitEngineeringIndex = null; let toolkitEngineeringMarkedReady = null; let toolkitEngineeringActiveId = ''; function toolkitEngineeringIconHtml() { return ""; } function toolkitEnsureMarked() { if (window.marked && typeof window.marked.parse === 'function') { return Promise.resolve(window.marked); } if (toolkitEngineeringMarkedReady) return toolkitEngineeringMarkedReady; toolkitEngineeringMarkedReady = new Promise((resolve, reject) => { const s = document.createElement('script'); s.src = l8Asset('toolkit/vendor/marked.min.js?v=15.0.7'); s.async = true; s.onload = () => { if (window.marked && typeof window.marked.parse === 'function') resolve(window.marked); else reject(new Error('marked no disponible')); }; s.onerror = () => reject(new Error('No se pudo cargar el render markdown')); document.head.appendChild(s); }).catch((err) => { toolkitEngineeringMarkedReady = null; throw err; }); return toolkitEngineeringMarkedReady; } window.toolkitEnsureMarked = toolkitEnsureMarked; function toolkitStripFrontmatter(md) { const text = String(md || ''); if (!text.startsWith('---')) return { meta: {}, body: text }; const end = text.indexOf('\n---', 3); if (end === -1) return { meta: {}, body: text }; const fm = text.slice(3, end); const body = text.slice(end + 4).replace(/^\s+/, ''); const meta = {}; fm.split(/\r?\n/).forEach((line) => { const i = line.indexOf(':'); if (i === -1) return; const k = line.slice(0, i).trim(); const v = line.slice(i + 1).trim().replace(/^["']|["']$/g, ''); if (k) meta[k] = v; }); return { meta: meta, body: body }; } async function toolkitLoadEngineeringIndex() { if (toolkitEngineeringIndex) return toolkitEngineeringIndex; const res = await fetch(TOOLKIT_ENGINEERING_BASE + '/index.json'); if (!res.ok) throw new Error('No se pudo cargar el índice de ingeniería'); toolkitEngineeringIndex = await res.json(); return toolkitEngineeringIndex; } function toolkitRenderEngineeringList(filter) { const list = document.getElementById('toolkitEngineeringList'); if (!list || !toolkitEngineeringIndex) return; const q = String(filter || '').trim().toLowerCase(); const agents = Array.isArray(toolkitEngineeringIndex.agents) ? toolkitEngineeringIndex.agents : []; const filtered = agents.filter((a) => { if (!q) return true; const hay = [a.title, a.description, a.file, a.id, a.vibe].join(' ').toLowerCase(); return hay.indexOf(q) !== -1; }); let html = ''; if (!filtered.length) { html += '
Sin coincidencias.
'; } else { filtered.forEach((a) => { const active = a.id === toolkitEngineeringActiveId ? ' active' : ''; html += ''; }); } list.innerHTML = html; const filterEl = document.getElementById('toolkitEngineeringFilter'); if (filterEl) { filterEl.addEventListener('input', () => toolkitRenderEngineeringList(filterEl.value)); try { filterEl.focus(); const len = filterEl.value.length; filterEl.setSelectionRange(len, len); } catch (e) {} } list.querySelectorAll('[data-agent]').forEach((btn) => { btn.addEventListener('click', () => { toolkitOpenEngineeringAgent(btn.getAttribute('data-agent')); }); }); } async function toolkitOpenEngineeringAgent(agentId) { const view = document.getElementById('toolkitEngineeringView'); const sub = document.getElementById('toolkitEngineeringSub'); if (!view) return; const agents = (toolkitEngineeringIndex && toolkitEngineeringIndex.agents) || []; const agent = agents.find((a) => a.id === agentId) || agents.find((a) => a.file === agentId); if (!agent) { view.innerHTML = '
Agente no encontrado.
'; return; } toolkitEngineeringActiveId = agent.id; toolkitRenderEngineeringList((document.getElementById('toolkitEngineeringFilter') || {}).value || ''); view.innerHTML = '
Cargando markdown…
'; if (sub) { sub.textContent = 'Engineering · ' + (agent.title || agent.id) + ' · vista markdown'; } try { const [mdRes, markedLib] = await Promise.all([ fetch(TOOLKIT_ENGINEERING_BASE + '/' + encodeURIComponent(agent.file)), toolkitEnsureMarked() ]); if (!mdRes.ok) throw new Error('No se pudo leer ' + agent.file); const raw = await mdRes.text(); const parsed = toolkitStripFrontmatter(raw); const metaBits = []; if (parsed.meta.name || agent.title) metaBits.push('Agente · ' + String(parsed.meta.name || agent.title).replace(/'); if (parsed.meta.vibe || agent.vibe) metaBits.push('Vibe · ' + String(parsed.meta.vibe || agent.vibe).replace(/'); metaBits.push('Fuente · agency-agents/engineering'); const html = markedLib.parse(parsed.body || raw, { async: false }); view.innerHTML = '
' + metaBits.join('') + '
' + html + '
'; toolkitLogUse('platform', 'engineering', 'Ingeniería · ' + (agent.title || agent.id)); toolkitCurateFile('platform', { name: agent.file, kind: 'md', meta: { agentId: agent.id, title: agent.title } }); } catch (e) { view.innerHTML = '
' + String(e.message || e).replace(/'; } } async function openToolkitEngineering() { const overlay = document.getElementById('toolkitEngineeringOverlay'); if (!overlay) return; overlay.classList.add('open'); overlay.setAttribute('aria-hidden', 'false'); const view = document.getElementById('toolkitEngineeringView'); if (view) view.innerHTML = '
Cargando foro de ingeniería…
'; try { await toolkitEnsureMarked(); const index = await toolkitLoadEngineeringIndex(); const sub = document.getElementById('toolkitEngineeringSub'); if (sub) { sub.textContent = 'Agency Agents · Engineering · ' + (index.count || 0) + ' agentes · vista markdown'; } toolkitRenderEngineeringList(''); if (!toolkitEngineeringActiveId && index.agents && index.agents[0]) { await toolkitOpenEngineeringAgent(index.agents[0].id); } else if (toolkitEngineeringActiveId) { await toolkitOpenEngineeringAgent(toolkitEngineeringActiveId); } else if (view) { view.innerHTML = '
Elige un agente del foro para verlo en markdown.
'; } toolkitLogUse('platform', 'engineering', 'Abrir Ingeniería'); } catch (e) { if (view) view.innerHTML = '
' + String(e.message || e).replace(/'; } } function closeToolkitEngineering() { const overlay = document.getElementById('toolkitEngineeringOverlay'); if (!overlay) return; overlay.classList.remove('open'); overlay.setAttribute('aria-hidden', 'true'); } function initToolkitEngineering() { const overlay = document.getElementById('toolkitEngineeringOverlay'); const closeBtn = document.getElementById('toolkitEngineeringCloseBtn'); if (closeBtn) closeBtn.addEventListener('click', () => closeToolkitEngineering()); if (overlay) { overlay.addEventListener('click', (e) => { if (e.target === overlay) closeToolkitEngineering(); }); } document.addEventListener('keydown', (e) => { if (e.key !== 'Escape') return; if (overlay && overlay.classList.contains('open')) { closeToolkitEngineering(); e.stopPropagation(); } }, true); } /* ===== Toolkit (fichas) ===== */ const TOOLKIT_STORE_KEY = 'l8_toolkit_v1'; const TOOLKIT_SLOT_COUNT = 6; /** Plantillas de fichas. tools[] se irá llenando cuando indiques las herramientas. */ function toolkitBuiltinEngineeringTool() { return { id: 'engineering', title: 'Ingeniería', iconHtml: toolkitEngineeringIconHtml(), onClick: function () { openToolkitEngineering(); } }; } function toolkitBuiltinPdfMdTool() { return { id: 'pdf-md', title: 'PDF → Markdown', iconHtml: (typeof toolkitPdfIconHtml === 'function' ? toolkitPdfIconHtml() : ''), onClick: function () { if (typeof openToolkitPdfMd === 'function') openToolkitPdfMd(); } }; } const TOOLKIT_FICHAS_DEFAULT = [ { id: 'platform', title: 'l8 codespace', icon: l8Asset('favicon.svg?v=3'), tools: [toolkitBuiltinEngineeringTool(), toolkitBuiltinPdfMdTool()] }, { id: 'workspace', title: 'workspace', icon: l8Asset('favicon.svg?v=3'), tools: [toolkitBuiltinEngineeringTool(), toolkitBuiltinPdfMdTool()] } ]; let toolkitFichas = TOOLKIT_FICHAS_DEFAULT.map((f) => Object.assign({}, f, { tools: (f.tools || []).slice() })); let toolkitStore = { history: {}, files: {}, removedIds: [] }; function toolkitNow() { return new Date().toISOString(); } function toolkitFormatWhen(iso) { if (!iso) return '—'; try { const d = new Date(iso); if (Number.isNaN(d.getTime())) return String(iso); const pad = (n) => String(n).padStart(2, '0'); return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()); } catch (e) { return String(iso); } } function toolkitEnsureEngineeringTool(ficha) { const tools = Array.isArray(ficha.tools) ? ficha.tools.slice() : []; const byId = {}; tools.forEach((t) => { if (t && t.id) byId[t.id] = t; }); byId.engineering = toolkitBuiltinEngineeringTool(); byId['pdf-md'] = toolkitBuiltinPdfMdTool(); const ordered = []; ['engineering', 'pdf-md'].forEach((id) => { if (byId[id]) { ordered.push(byId[id]); delete byId[id]; } }); Object.keys(byId).forEach((id) => ordered.push(byId[id])); return Object.assign({}, ficha, { tools: ordered }); } function toolkitRebuildFichas() { const removed = new Set( Array.isArray(toolkitStore.removedIds) ? toolkitStore.removedIds.map(String) : [] ); toolkitFichas = TOOLKIT_FICHAS_DEFAULT .filter((f) => !removed.has(String(f.id))) .map((f) => toolkitEnsureEngineeringTool(Object.assign({}, f, { tools: (f.tools || []).slice() }))); // Si se borró la ficha platform (donde nació Ingeniería), restaurarla // para que la herramienta no desaparezca del toolkit. if (!toolkitFichas.some((f) => f.id === 'platform')) { const platform = TOOLKIT_FICHAS_DEFAULT.find((f) => f.id === 'platform'); if (platform) { toolkitFichas.unshift(toolkitEnsureEngineeringTool(Object.assign({}, platform, { tools: (platform.tools || []).slice() }))); toolkitStore.removedIds = (toolkitStore.removedIds || []).filter((id) => String(id) !== 'platform'); toolkitPersist(); } } if (!toolkitFichas.length) { const platform = TOOLKIT_FICHAS_DEFAULT[0]; toolkitFichas = [toolkitEnsureEngineeringTool(Object.assign({}, platform, { tools: (platform.tools || []).slice() }))]; toolkitStore.removedIds = []; toolkitPersist(); } if (window.l8Toolkit) window.l8Toolkit.fichas = toolkitFichas; } function toolkitLoadStore() { try { const raw = localStorage.getItem(TOOLKIT_STORE_KEY); if (!raw) { toolkitStore = { history: {}, files: {}, removedIds: [] }; toolkitRebuildFichas(); return; } const data = JSON.parse(raw); toolkitStore = { history: (data && typeof data.history === 'object' && data.history) ? data.history : {}, files: (data && typeof data.files === 'object' && data.files) ? data.files : {}, removedIds: Array.isArray(data && data.removedIds) ? data.removedIds.map(String) : [] }; } catch (e) { toolkitStore = { history: {}, files: {}, removedIds: [] }; } toolkitRebuildFichas(); } function toolkitPersist() { try { localStorage.setItem(TOOLKIT_STORE_KEY, JSON.stringify(toolkitStore)); } catch (e) {} } function toolkitFileIconSvg(kind) { const k = String(kind || '').toLowerCase(); if (k === 'md' || k === 'markdown') { return ''; } if (k === 'html' || k === 'htm') { return ''; } if (k === 'zip' || k === 'pack') { return ''; } if (k === 'json' || k === 'js' || k === 'ts' || k === 'code') { return ''; } return ''; } function toolkitTrashSvg() { return ''; } function toolkitLogUse(fichaId, toolId, label) { const fid = String(fichaId || (toolkitFichas[0] && toolkitFichas[0].id) || 'platform'); if (!toolkitStore.history[fid]) toolkitStore.history[fid] = []; toolkitStore.history[fid].unshift({ id: 'h_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6), toolId: String(toolId || 'toolkit'), label: String(label || toolId || 'Uso'), at: toolkitNow() }); if (toolkitStore.history[fid].length > 80) { toolkitStore.history[fid] = toolkitStore.history[fid].slice(0, 80); } toolkitPersist(); const board = document.getElementById('toolkitBoard'); if (board && document.getElementById('toolkitOverlay') && document.getElementById('toolkitOverlay').classList.contains('open')) { toolkitRenderBoard(); } } window.toolkitLogUse = toolkitLogUse; function toolkitCurateFile(fichaId, file) { const fid = String(fichaId || (toolkitFichas[0] && toolkitFichas[0].id) || 'platform'); if (!file || !file.name) return false; if (!toolkitStore.files[fid]) toolkitStore.files[fid] = []; toolkitStore.files[fid].unshift({ id: 'f_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6), name: String(file.name).slice(0, 120), kind: String(file.kind || file.ext || 'txt').slice(0, 24), at: toolkitNow(), meta: file.meta || null }); if (toolkitStore.files[fid].length > 60) { toolkitStore.files[fid] = toolkitStore.files[fid].slice(0, 60); } toolkitPersist(); if (document.getElementById('toolkitOverlay') && document.getElementById('toolkitOverlay').classList.contains('open')) { toolkitRenderBoard(); } return true; } window.toolkitCurateFile = toolkitCurateFile; function toolkitRemoveFicha(fichaId) { const fid = String(fichaId || ''); if (!fid) return false; const exists = toolkitFichas.some((f) => f.id === fid); if (!exists) return false; if (!Array.isArray(toolkitStore.removedIds)) toolkitStore.removedIds = []; if (toolkitStore.removedIds.indexOf(fid) === -1) toolkitStore.removedIds.push(fid); if (toolkitStore.history && toolkitStore.history[fid]) delete toolkitStore.history[fid]; if (toolkitStore.files && toolkitStore.files[fid]) delete toolkitStore.files[fid]; toolkitPersist(); toolkitRebuildFichas(); toolkitRenderBoard(); return true; } function toolkitRenderFicha(ficha) { const history = toolkitStore.history[ficha.id] || []; const files = toolkitStore.files[ficha.id] || []; const tools = Array.isArray(ficha.tools) ? ficha.tools : []; let historyHtml; if (!history.length) { historyHtml = '
Sin usos aún. El historial aparecerá aquí con fecha al usar las herramientas de esta ficha.
'; } else { historyHtml = '
    ' + history.slice(0, 24).map((row) => { return '
  • ' + String(row.label || row.toolId || 'Uso').replace(/' + toolkitFormatWhen(row.at) + '
  • '; }).join('') + '
'; } let filesHtml; if (!files.length) { filesHtml = '
Sin archivos curados. Aquí se listarán con el icono del tipo de archivo.
'; } else { filesHtml = '
' + files.slice(0, 24).map((file) => { return '
' + '' + toolkitFileIconSvg(file.kind) + '' + '' + String(file.name).replace(/
'; }).join('') + '
'; } let toolsHtml = ''; tools.forEach((tool) => { const title = String(tool.title || tool.id || 'Herramienta').replace(/"/g, '"'); const icon = tool.iconHtml ? tool.iconHtml : (tool.icon ? '' : ''); toolsHtml += ''; }); const emptySlots = Math.max(0, TOOLKIT_SLOT_COUNT - tools.length); for (let i = 0; i < emptySlots; i++) { toolsHtml += ''; } if (!tools.length && !emptySlots) { toolsHtml += 'Sin herramientas en esta ficha.'; } const deleteBtn = ''; return ( '
' + deleteBtn + '
' + '' + '
' + String(ficha.title || ficha.id).replace(/' + '
' + '
' + '
Historial de uso
' + '
' + historyHtml + '
' + '
' + '
Archivos curados
' + '
' + filesHtml + '
' + '
' + toolsHtml + '
' + '
' ); } function toolkitRenderBoard() { const board = document.getElementById('toolkitBoard'); if (!board) return; if (!toolkitFichas.length) { board.innerHTML = '
No hay tablillas. Las nuevas fichas aparecerán aquí cuando las agregues.
'; return; } board.innerHTML = toolkitFichas.map(toolkitRenderFicha).join(''); board.querySelectorAll('.toolkit-tool-btn').forEach((btn) => { btn.addEventListener('click', () => { const fichaId = btn.getAttribute('data-ficha'); const toolId = btn.getAttribute('data-tool'); const ficha = toolkitFichas.find((f) => f.id === fichaId); const tool = ficha && (ficha.tools || []).find((t) => t.id === toolId); toolkitLogUse(fichaId, toolId, (tool && (tool.title || tool.id)) || toolId); if (tool && typeof tool.onClick === 'function') { try { tool.onClick(); } catch (e) {} } }); }); board.querySelectorAll('[data-ficha-delete]').forEach((btn) => { btn.addEventListener('click', (e) => { e.preventDefault(); e.stopPropagation(); const fichaId = btn.getAttribute('data-ficha-delete'); const ficha = toolkitFichas.find((f) => f.id === fichaId); const name = (ficha && ficha.title) || fichaId || 'tablilla'; if (!window.confirm('¿Eliminar la tablilla «' + name + '»?')) return; toolkitRemoveFicha(fichaId); }); }); } let toolkitOpenBusy = false; function toggleToolkit() {} window.toggleToolkit = toggleToolkit; document.addEventListener('DOMContentLoaded', initToolkitEngineering); document.addEventListener('DOMContentLoaded', function () { if (typeof initToolkitPdfMd === 'function') initToolkitPdfMd(); }); connectSSE();
ICAI-v3 SPHINCS+ Authorized (SLH-DSA-256s) 2026-08-20 1 lecturas

Publicación PUB-008 · Diktatcart Platform Core

D
Diktatcart
admin@hashcod.io · +1 800 HASHCOD
Tokens & Costo 200,000 $0.00015 / token ($30.00)
ICAI & NSPA Mensual ICAI-v3 100.0% SLA Uptime
CORS & HASNA 371 Yes (Permissive) ● Color #E63333
Tiempo & Prueba 15 mins Git SHA-256 Verified
Responsable & Manager DKT-500 Manager ID: MGR-03
module.py
# Python platform module...