From c2224711303e530dbe6ee9bc8597ed2cfb06fc23 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Fri, 9 Jan 2026 22:35:10 +0000 Subject: [PATCH] Introduce AutoMetabuilder core components and workflow packages: - Implement core components: CLI argument parsing, environment loading, GitHub service creation, and logging configuration. - Add support for OpenAI client setup and model resolution. - Develop SDLC context loader from GitHub and repository files. - Implement workflow context and engine builders. - Introduce major workflow packages: `game_tick_loop` and `contextual_iterative_loop`. - Update localization files with new package descriptions and labels. - Streamline web navigation by loading items from a dedicated JSON file. --- .../static/js/workflow/workflow_builder.js | 1 + .../static/js/workflow/workflow_palette.js | 64 +++++++++---------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/autometabuilder/web/static/js/workflow/workflow_builder.js b/src/autometabuilder/web/static/js/workflow/workflow_builder.js index a3873ba..68d29a4 100644 --- a/src/autometabuilder/web/static/js/workflow/workflow_builder.js +++ b/src/autometabuilder/web/static/js/workflow/workflow_builder.js @@ -10,6 +10,7 @@ window.AMBWorkflowState?.setPlugins?.(pluginDefinitions); window.AMBWorkflowState?.loadFromTextarea?.(); rerender(); + window.AMBWorkflowPalette?.init?.(); }, toggleRaw() { diff --git a/src/autometabuilder/web/static/js/workflow/workflow_palette.js b/src/autometabuilder/web/static/js/workflow/workflow_palette.js index bb846ce..ef69674 100644 --- a/src/autometabuilder/web/static/js/workflow/workflow_palette.js +++ b/src/autometabuilder/web/static/js/workflow/workflow_palette.js @@ -1,52 +1,53 @@ -/** - * AutoMetabuilder - Workflow Palette - */ (() => { const state = { container: null, searchInput: null, list: null, - filter: '' + filter: '', + ready: false, + loading: false }; - const getGroupKey = (type) => (type || '').split('.')[0] || 'other'; - - const buildEntries = (definitions, t) => Object.entries(definitions || {}).map(([key, def]) => { - const label = t?.(def.label || '', def.label || key) || key; - return { - key, - label, - group: getGroupKey(key), - search: `${key} ${label}`.toLowerCase() - }; - }); - + const buildEntries = (definitions, t) => Object.entries(definitions || {}).map(([key, def]) => ({ key, label: t?.(def.label || '', def.label || key) || key, group: getGroupKey(key), search: `${key} ${t?.(def.label || '', def.label || key) || key}`.toLowerCase() })); + const loadDefinitions = async () => { + if (state.loading) return; + state.loading = true; + try { + const response = await fetch('/api/workflow/plugins', { credentials: 'include', headers: window.AMBContext?.authHeaders || {} }); + if (response.ok) { + window.AMBWorkflowState?.setPlugins?.(await response.json()); + } + } catch (error) { + console.error('Workflow palette fetch failed', error); + } + state.loading = false; + render(); + }; const render = () => { const { t, escapeHtml } = window.AMBWorkflowUtils || {}; const definitions = window.AMBWorkflowState?.state?.pluginDefinitions || {}; if (!state.list) return; + if (!Object.keys(definitions).length) { + if (!state.loading) { + loadDefinitions(); + } + const loadingText = t?.('ui.workflow.palette.loading', 'Loading nodes...'); + state.list.innerHTML = `

${escapeHtml ? escapeHtml(loadingText) : loadingText}

`; + return; + } const term = state.filter.toLowerCase(); const entries = buildEntries(definitions, t).filter(entry => !term || entry.search.includes(term)); if (!entries.length) { state.list.innerHTML = `

${escapeHtml ? escapeHtml(t?.('ui.workflow.palette.empty', 'No matching nodes.')) : t?.('ui.workflow.palette.empty', 'No matching nodes.')}

`; return; } - const grouped = entries.reduce((acc, entry) => { const group = entry.group || 'other'; acc[group] = acc[group] || []; acc[group].push(entry); return acc; }, {}); - - const groupNames = Object.keys(grouped).sort((a, b) => { - const aOther = a === 'other'; - const bOther = b === 'other'; - if (aOther && !bOther) return 1; - if (!aOther && bOther) return -1; - return a.localeCompare(b); - }); - + const groupNames = Object.keys(grouped).sort((a, b) => (a === 'other') - (b === 'other') || a.localeCompare(b)); const groupsHtml = groupNames.map(group => { const groupLabelKey = `ui.workflow.palette.group.${group}`; const groupLabel = t?.(groupLabelKey, group) || group; @@ -67,21 +68,21 @@ `; }).join(''); - state.list.innerHTML = groupsHtml; }; - const init = () => { + if (state.ready) { + render(); + return; + } state.container = document.getElementById('workflow-palette'); state.searchInput = document.getElementById('workflow-palette-search'); state.list = document.getElementById('workflow-palette-list'); if (!state.container || !state.searchInput || !state.list) return; - state.searchInput.addEventListener('input', (event) => { state.filter = event.target.value || ''; render(); }); - state.list.addEventListener('click', (event) => { const target = event.target.closest('.amb-workflow-palette-item'); if (!target) return; @@ -91,9 +92,8 @@ window.AMBWorkflowMutations?.addNode(workflowState.workflow.nodes, workflowState.pluginDefinitions, nodeType); window.AMBWorkflowCanvasRenderer?.render?.(); }); - + state.ready = true; render(); }; - window.AMBWorkflowPalette = { init, render }; })();