mio-agent-runtime 0.5.0 → 0.5.2
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.
package/package.json
CHANGED
|
@@ -2001,22 +2001,57 @@ function recordTaskOutcome(args = {}) {
|
|
|
2001
2001
|
|
|
2002
2002
|
async function handleIdeaGenerate(args = {}) {
|
|
2003
2003
|
const { goal, context = '', constraints = [], numIdeas = 3 } = args
|
|
2004
|
+
// Memory-grounding: reuse related prior decisions/problems from Mio so ideas
|
|
2005
|
+
// are informed by the Agent Control Plane's accumulated experience.
|
|
2006
|
+
let related = []
|
|
2007
|
+
try {
|
|
2008
|
+
const mem = await queryMemory({ query: goal, limit: 3 })
|
|
2009
|
+
if (mem && Array.isArray(mem.results)) related = mem.results
|
|
2010
|
+
} catch (e) {
|
|
2011
|
+
related = []
|
|
2012
|
+
}
|
|
2013
|
+
const relatedIds = related.map((r) => r.id).filter(Boolean)
|
|
2014
|
+
const grounding = related
|
|
2015
|
+
.filter((r) => r && (r.content || r.kind))
|
|
2016
|
+
.map((r) => '- [' + (r.kind || 'note') + '] ' + String(r.content || '').slice(0, 240))
|
|
2017
|
+
.join('\n')
|
|
2018
|
+
|
|
2019
|
+
// Generation strategies give diversity without exposing the mechanism to callers.
|
|
2020
|
+
const strategies = [
|
|
2021
|
+
'SCAMPER',
|
|
2022
|
+
'Analogy',
|
|
2023
|
+
'First-Principles',
|
|
2024
|
+
'Random-Stimulus',
|
|
2025
|
+
'Constraint-Inversion'
|
|
2026
|
+
]
|
|
2027
|
+
|
|
2004
2028
|
const ideas = []
|
|
2005
2029
|
for (let i = 0; i < numIdeas; i++) {
|
|
2030
|
+
const strategy = strategies[i % strategies.length]
|
|
2031
|
+
const blocks = [
|
|
2032
|
+
'Goal: ' + goal,
|
|
2033
|
+
'Strategy: ' + strategy,
|
|
2034
|
+
context ? 'Context: ' + context : '',
|
|
2035
|
+
constraints.length ? 'Constraints: ' + constraints.join(', ') : '',
|
|
2036
|
+
related.length
|
|
2037
|
+
? 'Related Mio memory:\n' + grounding
|
|
2038
|
+
: 'No related Mio memory found yet; record outcomes to grow the experience base.',
|
|
2039
|
+
'Suggestion: Consider prototyping the idea and measuring its impact against prior decisions.'
|
|
2040
|
+
].filter(Boolean)
|
|
2006
2041
|
ideas.push({
|
|
2007
2042
|
id: 'idea_' + Date.now() + '_' + i,
|
|
2008
|
-
title: 'Idea #' + (i + 1) + ': ' + goal,
|
|
2009
|
-
description:
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
].filter(Boolean).join('\n\n')
|
|
2043
|
+
title: 'Idea #' + (i + 1) + ' (' + strategy + '): ' + goal,
|
|
2044
|
+
description: blocks.join('\n\n'),
|
|
2045
|
+
provenance: {
|
|
2046
|
+
strategy: strategy,
|
|
2047
|
+
relatedMemoryIds: relatedIds
|
|
2048
|
+
}
|
|
2015
2049
|
})
|
|
2016
2050
|
}
|
|
2017
2051
|
return {
|
|
2018
2052
|
ideas: ideas,
|
|
2019
|
-
generatedAt: new Date().toISOString()
|
|
2053
|
+
generatedAt: new Date().toISOString(),
|
|
2054
|
+
groundedWith: related.length
|
|
2020
2055
|
}
|
|
2021
2056
|
}
|
|
2022
2057
|
|