suemo 0.0.3 → 0.0.5
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 +10 -2
- package/package.json +1 -1
- package/src/cli/commands/believe.ts +19 -5
- package/src/cli/commands/consolidate.ts +18 -3
- package/src/cli/commands/doctor.ts +25 -3
- package/src/cli/commands/export-import.ts +26 -4
- package/src/cli/commands/goal.ts +54 -11
- package/src/cli/commands/health.ts +77 -9
- package/src/cli/commands/init.ts +35 -4
- package/src/cli/commands/observe.ts +16 -3
- package/src/cli/commands/query.ts +17 -6
- package/src/cli/commands/recall.ts +19 -3
- package/src/cli/commands/serve.ts +164 -4
- package/src/cli/commands/sync.ts +22 -3
- package/src/cli/commands/timeline.ts +17 -6
- package/src/cli/commands/wander.ts +17 -6
- package/src/cli/shared.ts +78 -2
- package/src/cognitive/consolidate.ts +8 -17
- package/src/cognitive/contradiction.ts +5 -11
- package/src/cognitive/health.ts +13 -13
- package/src/config.ts +4 -4
- package/src/db/client.ts +3 -3
- package/src/db/preflight.ts +8 -8
- package/src/db/schema.surql +1 -1
- package/src/db/schema.ts +56 -8
- package/src/embedding/index.ts +2 -2
- package/src/logger.ts +23 -1
- package/src/mcp/server.ts +12 -11
- package/src/mcp/stdio.ts +24 -6
- package/src/memory/episode.ts +6 -0
- package/src/memory/read.ts +62 -43
- package/src/memory/write.ts +12 -14
- package/src/types.ts +1 -1
package/src/memory/write.ts
CHANGED
|
@@ -31,35 +31,30 @@ export async function observe(
|
|
|
31
31
|
|
|
32
32
|
// 2. Dedup probe: ANN search for cosine similarity > 0.97
|
|
33
33
|
// For non-surreal providers, we pass the pre-computed vector as $qvec.
|
|
34
|
-
|
|
34
|
+
const usesSurrealEmbedding = config.embedding.provider === 'surrealml'
|
|
35
|
+
if (!usesSurrealEmbedding && !embeddingParam) {
|
|
35
36
|
throw new Error(`Missing embedding vector for provider: ${config.embedding.provider}`)
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
const dedupVecClause =
|
|
39
|
+
const dedupVecClause = usesSurrealEmbedding
|
|
39
40
|
? 'fn::embed($content)'
|
|
40
41
|
: '$qvec'
|
|
41
|
-
const dedupParams =
|
|
42
|
+
const dedupParams = usesSurrealEmbedding
|
|
42
43
|
? { content: input.content }
|
|
43
44
|
: { qvec: embeddingParam }
|
|
44
45
|
log.debug('observe dedup probe', {
|
|
45
46
|
provider: config.embedding.provider,
|
|
46
|
-
queryMode:
|
|
47
|
+
queryMode: usesSurrealEmbedding ? 'fn::embed($content)' : '$qvec',
|
|
47
48
|
})
|
|
48
49
|
|
|
49
|
-
const dedupResult = await db.query<[
|
|
50
|
+
const dedupResult = await db.query<unknown[]>(
|
|
50
51
|
`
|
|
51
52
|
LET $vec = ${dedupVecClause};
|
|
52
|
-
LET $cand = (
|
|
53
|
-
SELECT id, embedding
|
|
54
|
-
FROM memory
|
|
55
|
-
WHERE (valid_until = NONE OR valid_until > time::now())
|
|
56
|
-
AND embedding <|1, 20|> $vec
|
|
57
|
-
);
|
|
58
|
-
|
|
59
53
|
SELECT id, score
|
|
60
54
|
FROM (
|
|
61
55
|
SELECT id, vector::similarity::cosine(embedding, $vec) AS score
|
|
62
|
-
FROM
|
|
56
|
+
FROM memory
|
|
57
|
+
WHERE (valid_until = NONE OR valid_until > time::now())
|
|
63
58
|
)
|
|
64
59
|
ORDER BY score DESC
|
|
65
60
|
LIMIT 1
|
|
@@ -67,7 +62,10 @@ export async function observe(
|
|
|
67
62
|
dedupParams,
|
|
68
63
|
)
|
|
69
64
|
|
|
70
|
-
const
|
|
65
|
+
const dedupRows = dedupResult.at(-1)
|
|
66
|
+
const topHit = Array.isArray(dedupRows)
|
|
67
|
+
? (dedupRows[0] as { id: string; score: number } | undefined)
|
|
68
|
+
: undefined
|
|
71
69
|
if (topHit && topHit.score > 0.97) {
|
|
72
70
|
log.debug('Near-duplicate detected — merging tags, updating updated_at', {
|
|
73
71
|
existingId: topHit.id,
|
package/src/types.ts
CHANGED
|
@@ -125,7 +125,7 @@ export const QueryInputSchema = z.object({
|
|
|
125
125
|
topK: z.number().int().min(1).max(50).default(5).optional(),
|
|
126
126
|
activeOnly: z.boolean().default(true).optional(),
|
|
127
127
|
strategies: z
|
|
128
|
-
.array(z.enum(['vector', 'bm25', 'graph'
|
|
128
|
+
.array(z.enum(['vector', 'bm25', 'graph']))
|
|
129
129
|
.default(['vector', 'bm25', 'graph'])
|
|
130
130
|
.optional(),
|
|
131
131
|
})
|