Skip to main content

API Reference

Cognitive architecture primitives built on flow-state-dev. Provides attention, memory, and identity domains for agentic workflows.

Import: Use subpath exports. @thought-fabric/core/attention, @thought-fabric/core/memory, @thought-fabric/core/identity.


attention

Relevance and salience for what the agent attends to.

filterRelevance(config)

Handler block factory. Deterministic keyword-based relevance filtering. No LLM. Fast. Removes or annotates items below a threshold using keyword overlap heuristics.

import { filterRelevance } from "@thought-fabric/core/attention";

const block = filterRelevance({ name: "filter", criteria: { ... } });

Returns a BlockDefinition (handler). Use as a step in a sequencer or as a tool.

scoreSalience(config)

Generator block factory. LLM-based salience scoring along configurable dimensions (goal relevance, recency, novelty, emotional weight).

import { scoreSalience } from "@thought-fabric/core/attention";

const block = scoreSalience({
name: "salience",
dimensions: { ... },
weights: { ... },
model: "gpt-5-mini",
});

Returns a BlockDefinition (generator). Output schema: scores, composite, ranking, itemScores.


memory

Working memory: observe, remember, tick, snapshot.

Blocks

FunctionKindPurpose
workingMemoryCapture(config?)sequencerBundled: observe → remember → tick. Primary entry point.
workingMemoryObserve(config?)generatorLLM extraction. Output: observations array.
workingMemoryRemember(config?)handlerPersist observations into the resource.
workingMemoryTick(config?)handlerAdvance decay clock, recompute salience.
workingMemorySnapshot()handlerRead current entries and turn counter.
workingMemoryAdd(config?)handlerManual entry. No LLM extraction.

Resource

  • workingMemoryResourcedefineResource() for working memory. Use in flow sessionResources.
  • workingMemoryResources — Pre-keyed { workingMemory: workingMemoryResource }.

Context

  • workingMemoryContextFormatter — Context slot for generators. Assign to context: [workingMemoryContextFormatter].

Helpers (verb-first naming)

FunctionPurpose
addAdd entry with auto-eviction at capacity
evictRemove entry by ID
pin / unpinToggle pinned status
refreshUpdate lastAccessedAtTurn
advanceTick decay, recompute salience for all entries
itemsRead entries sorted by salience
formatForContextFormat entries for LLM context

Pure math (no side effects)

  • computeDecay(elapsed, strategy, rate) — Decay factor. Strategies: power-law, exponential, none.
  • computeSalience(entry, currentTurn, decay)importance × decay(elapsed).

identity (placeholders)

Wave 2 placeholders. Not yet implemented.

  • perspective(config) — Perspective block.
  • constitution(config) — Constitution block.

Usage

import { workingMemoryCapture } from "@thought-fabric/core/memory";
import { filterRelevance, scoreSalience } from "@thought-fabric/core/attention";

const pipeline = sequencer({ name: "pipeline", inputSchema: chatInput })
.work((input) => input.message, workingMemoryCapture({ model: "gpt-5-mini" }))
.then(chat);

const filter = filterRelevance({ name: "filter" });
const salience = scoreSalience({ name: "rank" });

See Memory for a full guide.