@steno-ai/engine 0.1.0 → 0.1.1
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/README.md +122 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# @steno-ai/engine
|
|
2
|
+
|
|
3
|
+
The core memory engine for Steno. Handles extraction, retrieval, knowledge graphs, salience scoring, contradiction detection, and more.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @steno-ai/engine
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Conversation / Raw Text
|
|
15
|
+
|
|
|
16
|
+
v
|
|
17
|
+
┌─────────────────────────────────────────┐
|
|
18
|
+
│ Extraction Pipeline │
|
|
19
|
+
│ heuristic -> LLM -> dedup -> contradict │
|
|
20
|
+
│ -> entity extraction -> embed -> store │
|
|
21
|
+
└─────────────────────────────────────────┘
|
|
22
|
+
|
|
|
23
|
+
v
|
|
24
|
+
┌─────────────────────────────────────────┐
|
|
25
|
+
│ Storage (Facts + Graph) │
|
|
26
|
+
│ facts, entities, edges, embeddings │
|
|
27
|
+
└─────────────────────────────────────────┘
|
|
28
|
+
|
|
|
29
|
+
v
|
|
30
|
+
┌─────────────────────────────────────────┐
|
|
31
|
+
│ 6-Signal Retrieval │
|
|
32
|
+
│ vector + keyword + graph + temporal │
|
|
33
|
+
│ + salience decay + trigger matching │
|
|
34
|
+
│ -> fusion ranking -> reranking │
|
|
35
|
+
└─────────────────────────────────────────┘
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### Extraction Pipeline
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { runExtractionPipeline } from '@steno-ai/engine';
|
|
44
|
+
|
|
45
|
+
const result = await runExtractionPipeline(
|
|
46
|
+
{
|
|
47
|
+
storage, // StorageAdapter (sqlite, supabase)
|
|
48
|
+
embedding, // EmbeddingAdapter (openai, openai-compat)
|
|
49
|
+
cheapLLM, // LLMAdapter for fast extraction
|
|
50
|
+
smartLLM, // LLMAdapter for complex extraction (optional)
|
|
51
|
+
embeddingModel: 'text-embedding-3-small',
|
|
52
|
+
embeddingDim: 1536,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
tenantId: 'tenant_1',
|
|
56
|
+
scope: 'user',
|
|
57
|
+
scopeId: 'user_123',
|
|
58
|
+
sourceType: 'conversation',
|
|
59
|
+
data: [
|
|
60
|
+
{ role: 'user', content: 'I just moved to San Francisco' },
|
|
61
|
+
{ role: 'assistant', content: 'Welcome to SF!' },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
console.log(result.facts); // extracted memory facts
|
|
67
|
+
console.log(result.entities); // knowledge graph entities
|
|
68
|
+
console.log(result.edges); // entity relationships
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Search (6-Signal Retrieval)
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { search } from '@steno-ai/engine';
|
|
75
|
+
|
|
76
|
+
const results = await search(
|
|
77
|
+
{
|
|
78
|
+
storage,
|
|
79
|
+
embedding,
|
|
80
|
+
cache, // optional CacheAdapter
|
|
81
|
+
rerank: true, // embedding-based reranking
|
|
82
|
+
salienceHalfLifeDays: 30, // decay curve
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
tenantId: 'tenant_1',
|
|
86
|
+
scope: 'user',
|
|
87
|
+
scopeId: 'user_123',
|
|
88
|
+
query: 'where does the user live?',
|
|
89
|
+
limit: 10,
|
|
90
|
+
includeGraph: true,
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
for (const r of results.results) {
|
|
95
|
+
console.log(r.content, r.score);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Adapter Interfaces
|
|
100
|
+
|
|
101
|
+
The engine defines these interfaces -- bring your own implementations or use the official adapters:
|
|
102
|
+
|
|
103
|
+
| Interface | Official Adapters |
|
|
104
|
+
|-----------|-------------------|
|
|
105
|
+
| `StorageAdapter` | `@steno-ai/sqlite-adapter`, `@steno-ai/supabase-adapter` |
|
|
106
|
+
| `LLMAdapter` | `@steno-ai/openai-adapter`, `@steno-ai/openai-compat-adapter` |
|
|
107
|
+
| `EmbeddingAdapter` | `@steno-ai/openai-adapter`, `@steno-ai/openai-compat-adapter` |
|
|
108
|
+
| `CacheAdapter` | `@steno-ai/cache-adapter` |
|
|
109
|
+
|
|
110
|
+
## Key Modules
|
|
111
|
+
|
|
112
|
+
- **extraction/** -- Heuristic + LLM fact extraction, deduplication, contradiction detection, entity extraction
|
|
113
|
+
- **retrieval/** -- Vector search, keyword search, graph traversal, salience scoring, fusion ranking, reranking
|
|
114
|
+
- **salience/** -- Time-decay scoring, feedback boosting
|
|
115
|
+
- **sessions/** -- Session lifecycle management
|
|
116
|
+
- **feedback/** -- Feedback tracking and fact score adjustment
|
|
117
|
+
- **profiles/** -- User profile aggregation
|
|
118
|
+
- **scratchpad/** -- Working memory / scratchpad updates
|
|
119
|
+
|
|
120
|
+
## Part of [Steno](https://github.com/SankrityaT/steno-ai)
|
|
121
|
+
|
|
122
|
+
The memory layer for AI agents.
|