openrecall 0.1.0
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/LICENSE +21 -0
- package/README.md +145 -0
- package/package.json +51 -0
- package/src/agent.ts +268 -0
- package/src/client.ts +16 -0
- package/src/config.ts +79 -0
- package/src/db.ts +93 -0
- package/src/extract.ts +142 -0
- package/src/index.ts +262 -0
- package/src/maintenance.ts +134 -0
- package/src/memory.ts +604 -0
- package/src/migrations/001_initial.ts +73 -0
- package/src/migrations/002_tags.ts +20 -0
- package/src/migrations/003_decay.ts +15 -0
- package/src/migrations/004_links.ts +23 -0
- package/src/migrations/005_metadata.ts +17 -0
- package/src/migrations/index.ts +16 -0
- package/src/tools.ts +658 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite"
|
|
2
|
+
|
|
3
|
+
export const version = 4
|
|
4
|
+
export const description = "Add memory relationships/linking"
|
|
5
|
+
|
|
6
|
+
export function up(db: Database) {
|
|
7
|
+
db.run(`
|
|
8
|
+
CREATE TABLE IF NOT EXISTS memory_links (
|
|
9
|
+
source_id TEXT NOT NULL REFERENCES memory(id) ON DELETE CASCADE,
|
|
10
|
+
target_id TEXT NOT NULL REFERENCES memory(id) ON DELETE CASCADE,
|
|
11
|
+
relationship TEXT NOT NULL CHECK(relationship IN ('related','supersedes','contradicts','extends')),
|
|
12
|
+
PRIMARY KEY (source_id, target_id)
|
|
13
|
+
)
|
|
14
|
+
`)
|
|
15
|
+
db.run(`CREATE INDEX IF NOT EXISTS idx_links_target ON memory_links(target_id)`)
|
|
16
|
+
db.run(`CREATE INDEX IF NOT EXISTS idx_links_relationship ON memory_links(relationship)`)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function down(db: Database) {
|
|
20
|
+
db.run("DROP INDEX IF EXISTS idx_links_relationship")
|
|
21
|
+
db.run("DROP INDEX IF EXISTS idx_links_target")
|
|
22
|
+
db.run("DROP TABLE IF EXISTS memory_links")
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite"
|
|
2
|
+
|
|
3
|
+
export const version = 5
|
|
4
|
+
export const description = "Add metadata table for maintenance tracking"
|
|
5
|
+
|
|
6
|
+
export function up(db: Database) {
|
|
7
|
+
db.run(`
|
|
8
|
+
CREATE TABLE IF NOT EXISTS metadata (
|
|
9
|
+
key TEXT PRIMARY KEY,
|
|
10
|
+
value TEXT NOT NULL
|
|
11
|
+
)
|
|
12
|
+
`)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function down(db: Database) {
|
|
16
|
+
db.run("DROP TABLE IF EXISTS metadata")
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite"
|
|
2
|
+
import * as m001 from "./001_initial"
|
|
3
|
+
import * as m002 from "./002_tags"
|
|
4
|
+
import * as m003 from "./003_decay"
|
|
5
|
+
import * as m004 from "./004_links"
|
|
6
|
+
import * as m005 from "./005_metadata"
|
|
7
|
+
|
|
8
|
+
export interface Migration {
|
|
9
|
+
version: number
|
|
10
|
+
description: string
|
|
11
|
+
up: (db: Database) => void
|
|
12
|
+
down?: (db: Database) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Register all migrations in order
|
|
16
|
+
export const migrations: Migration[] = [m001, m002, m003, m004, m005]
|