@arephan/clawdbot-memory-supabase 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/migrations/001_initial.sql +153 -0
- package/migrations/002_vector_search.sql +219 -0
- package/migrations/003_entity_relationships.sql +143 -0
- package/migrations/004_cron_runs.sql +33 -0
- package/migrations/005_search_memories_alias.sql +47 -0
- package/package.json +34 -0
- package/plugin/clawdbot.plugin.json +42 -0
- package/plugin/index.ts +650 -0
- package/plugin/package-lock.json +597 -0
- package/plugin/package.json +10 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
-- Cron job execution history
|
|
2
|
+
CREATE TABLE IF NOT EXISTS cron_runs (
|
|
3
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
4
|
+
job_id TEXT NOT NULL,
|
|
5
|
+
job_name TEXT NOT NULL,
|
|
6
|
+
started_at TIMESTAMPTZ DEFAULT NOW(),
|
|
7
|
+
ended_at TIMESTAMPTZ,
|
|
8
|
+
status TEXT CHECK (status IN ('running', 'ok', 'error', 'timeout')),
|
|
9
|
+
duration_ms INT,
|
|
10
|
+
result TEXT,
|
|
11
|
+
metadata JSONB DEFAULT '{}'
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE INDEX IF NOT EXISTS cron_runs_job_id_idx ON cron_runs(job_id);
|
|
15
|
+
CREATE INDEX IF NOT EXISTS cron_runs_started_at_idx ON cron_runs(started_at DESC);
|
|
16
|
+
CREATE INDEX IF NOT EXISTS cron_runs_status_idx ON cron_runs(status);
|
|
17
|
+
|
|
18
|
+
-- Cron job definitions (mirror of Clawdbot crons)
|
|
19
|
+
CREATE TABLE IF NOT EXISTS cron_jobs (
|
|
20
|
+
id TEXT PRIMARY KEY,
|
|
21
|
+
name TEXT NOT NULL,
|
|
22
|
+
description TEXT,
|
|
23
|
+
schedule TEXT NOT NULL,
|
|
24
|
+
enabled BOOLEAN DEFAULT true,
|
|
25
|
+
last_run_at TIMESTAMPTZ,
|
|
26
|
+
next_run_at TIMESTAMPTZ,
|
|
27
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
28
|
+
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
|
29
|
+
metadata JSONB DEFAULT '{}'
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
CREATE INDEX IF NOT EXISTS cron_jobs_enabled_idx ON cron_jobs(enabled);
|
|
33
|
+
CREATE INDEX IF NOT EXISTS cron_jobs_next_run_idx ON cron_jobs(next_run_at);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
-- OpenClaw Memory - search_memories alias for plugin compatibility
|
|
2
|
+
-- This function wraps match_memories with the signature the plugin expects
|
|
3
|
+
|
|
4
|
+
CREATE OR REPLACE FUNCTION search_memories(
|
|
5
|
+
query_embedding TEXT, -- JSON string of embedding array
|
|
6
|
+
match_threshold FLOAT DEFAULT 0.5,
|
|
7
|
+
match_count INT DEFAULT 5,
|
|
8
|
+
p_agent_id TEXT DEFAULT NULL
|
|
9
|
+
)
|
|
10
|
+
RETURNS TABLE (
|
|
11
|
+
id UUID,
|
|
12
|
+
content TEXT,
|
|
13
|
+
category TEXT,
|
|
14
|
+
importance FLOAT,
|
|
15
|
+
similarity FLOAT
|
|
16
|
+
)
|
|
17
|
+
LANGUAGE plpgsql
|
|
18
|
+
AS $$
|
|
19
|
+
DECLARE
|
|
20
|
+
embedding_array FLOAT[];
|
|
21
|
+
embedding_vector VECTOR(1536);
|
|
22
|
+
BEGIN
|
|
23
|
+
-- Parse JSON array to float array, then to vector
|
|
24
|
+
SELECT ARRAY(SELECT json_array_elements_text(query_embedding::json)::float)
|
|
25
|
+
INTO embedding_array;
|
|
26
|
+
|
|
27
|
+
embedding_vector := embedding_array::vector(1536);
|
|
28
|
+
|
|
29
|
+
RETURN QUERY
|
|
30
|
+
SELECT
|
|
31
|
+
m.id,
|
|
32
|
+
m.content,
|
|
33
|
+
m.category,
|
|
34
|
+
m.importance,
|
|
35
|
+
1 - (m.embedding <=> embedding_vector) AS similarity
|
|
36
|
+
FROM memories m
|
|
37
|
+
WHERE
|
|
38
|
+
(p_agent_id IS NULL OR m.agent_id = p_agent_id)
|
|
39
|
+
AND (m.expires_at IS NULL OR m.expires_at > NOW())
|
|
40
|
+
AND m.embedding IS NOT NULL
|
|
41
|
+
AND 1 - (m.embedding <=> embedding_vector) > match_threshold
|
|
42
|
+
ORDER BY m.embedding <=> embedding_vector
|
|
43
|
+
LIMIT match_count;
|
|
44
|
+
END;
|
|
45
|
+
$$;
|
|
46
|
+
|
|
47
|
+
COMMENT ON FUNCTION search_memories IS 'Plugin-compatible wrapper for semantic memory search';
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arephan/clawdbot-memory-supabase",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Clawdbot plugin for complete conversation logging to Supabase/PostgreSQL. Never forget anything.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "plugin/index.ts",
|
|
7
|
+
"clawdbot": {
|
|
8
|
+
"extensions": ["plugin/index.ts"]
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"clawdbot",
|
|
12
|
+
"clawdbot-plugin",
|
|
13
|
+
"supabase",
|
|
14
|
+
"memory",
|
|
15
|
+
"conversation-logging",
|
|
16
|
+
"postgresql",
|
|
17
|
+
"ai-assistant"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/Arephan/clawdbot-memory-supabase"
|
|
22
|
+
},
|
|
23
|
+
"author": "Arephan",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@supabase/supabase-js": "^2.39.0"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"plugin/",
|
|
30
|
+
"migrations/",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "memory-supabase",
|
|
3
|
+
"kind": "memory",
|
|
4
|
+
"uiHints": {
|
|
5
|
+
"supabase.url": {
|
|
6
|
+
"label": "Supabase URL",
|
|
7
|
+
"placeholder": "http://127.0.0.1:54321",
|
|
8
|
+
"help": "Supabase project URL (local or cloud)"
|
|
9
|
+
},
|
|
10
|
+
"supabase.anonKey": {
|
|
11
|
+
"label": "Supabase Key",
|
|
12
|
+
"sensitive": true,
|
|
13
|
+
"placeholder": "sb_secret_...",
|
|
14
|
+
"help": "Supabase service/anon key"
|
|
15
|
+
},
|
|
16
|
+
"agentId": {
|
|
17
|
+
"label": "Agent ID",
|
|
18
|
+
"placeholder": "hans-assistant",
|
|
19
|
+
"help": "Identifier for this agent (for multi-agent setups)"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"configSchema": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"additionalProperties": false,
|
|
25
|
+
"properties": {
|
|
26
|
+
"supabase": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"properties": {
|
|
30
|
+
"url": { "type": "string" },
|
|
31
|
+
"anonKey": { "type": "string" }
|
|
32
|
+
},
|
|
33
|
+
"required": ["url", "anonKey"]
|
|
34
|
+
},
|
|
35
|
+
"agentId": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"default": "hans-assistant"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": ["supabase"]
|
|
41
|
+
}
|
|
42
|
+
}
|