Accept scalar Scattermind build order sections

This commit is contained in:
OpenClaw Bot
2026-05-27 20:44:53 +02:00
parent ce3885d406
commit 77b5395962
3 changed files with 47 additions and 3 deletions
+15 -1
View File
@@ -1159,8 +1159,22 @@ function normalizeOptionIds(options = []) {
});
}
function candidateItems(value) {
if (Array.isArray(value)) return value;
if (typeof value === 'string' || typeof value === 'number') return cleanFlexibleTextList(value, 8, 260);
const item = objectFrom(value);
if (!Object.keys(item).length) return [];
const hasCandidateShape = Boolean(
item.id || item.title || item.name || item.action || item.move || item.step || item.task || item.instruction ||
item.nextMove || item.next_move || item.nextStep || item.next_step || item.text || item.content || item.summary
);
return hasCandidateShape ? [item] : [];
}
function compactCandidateGroup(group = []) {
return group.filter(entry => Array.isArray(entry?.items) && entry.items.length > 0);
return group
.map(entry => ({ ...entry, items: candidateItems(entry?.items) }))
.filter(entry => entry.items.length > 0);
}
function buildOrderSectionGroup(buildOrder = {}, baseSection = 'buildOrder') {