@cognitive-engine/reasoning
v0.2.1
Published
BDI reasoning engine: beliefs, intentions, inference rules, working memory
Readme
@cognitive-engine/reasoning
BDI (Beliefs-Desires-Intentions) reasoning engine for cognitive-engine.
Install
npm install @cognitive-engine/reasoningWhat It Does
Implements a formal BDI reasoning cycle:
- Beliefs — what the agent knows (updated via perception and inference)
- Desires — goals derived from beliefs and context
- Intentions — concrete actions to take, with priority and justification
Usage
Reasoner
import { Reasoner } from '@cognitive-engine/reasoning'
const reasoner = new Reasoner(llmProvider)
const result = reasoner.reason(percept, currentBeliefs)
result.intentions
// [
// { type: 'empathize', priority: 10, reason: 'User is stressed' },
// { type: 'explore', priority: 5, reason: 'Need more context about workload' }
// ]
result.updatedBeliefs
// Beliefs updated with new evidence from perceptionWorld Model
import { WorldModel } from '@cognitive-engine/reasoning'
const world = new WorldModel()
world.addBelief({ content: 'User prefers concise answers', confidence: 0.8, source: 'observation' })
world.addBelief({ content: 'User is a senior engineer', confidence: 0.9, source: 'inference' })
const relevant = world.query('communication style')Working Memory
import { WorkingMemory } from '@cognitive-engine/reasoning'
const wm = new WorkingMemory({ capacity: 7 })
wm.add({ content: 'Current task: debug auth flow', salience: 0.9 })
wm.add({ content: 'Previous topic: deployment', salience: 0.3 })
// Low-salience items get displaced as capacity fillsStandalone Functions
import { generateIntentions, applyInferenceRules } from '@cognitive-engine/reasoning'
const intentions = generateIntentions(percept, beliefs)
const newBeliefs = applyInferenceRules(beliefs, rules)Intention Types
| Type | When |
|------|------|
| empathize | Emotional content detected |
| explore | Need more information |
| teach | User asking how/why |
| act | Clear actionable request |
| clarify | Ambiguous input |
| redirect | Off-topic or boundary issue |
