@capybara-hq/plugin-memory 0.0.0-stage → 0.1.0-rc.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/icon.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#3D3D3A" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><title>Memory</title><style>@media (prefers-color-scheme:dark){svg{stroke:#D6D5D0}}</style><circle cx="12" cy="5" r="2"/><circle cx="5" cy="17" r="2"/><circle cx="19" cy="17" r="2"/><circle cx="12" cy="13" r="1.6"/><path d="M12 7v4.4M10.7 14.1l-4.2 1.9M13.3 14.1l4.2 1.9M7 17h10"/></svg>
@@ -0,0 +1,89 @@
1
+ -- Runs with search_path "plugin_memory, public": table names carry no schema prefix.
2
+ -- Ids from the kernel (org, agent, account, conversation) are stored as text.
3
+
4
+ -- One memory of one (agent, member) pair in an org. Every query filters org_id, agent_id and
5
+ -- account_id. `tokens` is the plugin's own word segmentation (Intl.Segmenter) as a 'simple'
6
+ -- tsvector; `embedding` is added below, its type depends on pgvector.
7
+ CREATE TABLE IF NOT EXISTS memories (
8
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
9
+ org_id text NOT NULL,
10
+ agent_id text NOT NULL,
11
+ account_id text NOT NULL,
12
+ path text NOT NULL,
13
+ type text NOT NULL CHECK (type IN ('user', 'feedback', 'project', 'reference')),
14
+ description text NOT NULL,
15
+ body text NOT NULL,
16
+ tokens tsvector NOT NULL DEFAULT ''::tsvector,
17
+ embedding_model text,
18
+ recall_count integer NOT NULL DEFAULT 0,
19
+ last_recalled_at timestamptz,
20
+ created_at timestamptz NOT NULL DEFAULT now(),
21
+ updated_at timestamptz NOT NULL DEFAULT now(),
22
+ created_in text
23
+ );
24
+
25
+ -- One path per owner; its (org_id, agent_id, account_id) prefix serves the per-owner reads.
26
+ CREATE UNIQUE INDEX IF NOT EXISTS memories_owner_path ON memories (org_id, agent_id, account_id, path);
27
+ -- A member leaving the org removes their memories with every agent.
28
+ CREATE INDEX IF NOT EXISTS memories_org_account ON memories (org_id, account_id);
29
+ CREATE INDEX IF NOT EXISTS memories_tokens ON memories USING gin (tokens);
30
+
31
+ -- The embedding column: pgvector's `vector` when the type resolves from this search_path (the
32
+ -- kernel installs pgvector into `public` when the server offers it), else `real[]` with cosine
33
+ -- computed in the plugin. pgvector installed in another schema counts as absent. No fixed
34
+ -- dimension: orgs may map different embedding models, and search is per owner (at most 1,000
35
+ -- rows), so no ANN index is needed. The type cannot be chosen by a plain statement, hence the DO
36
+ -- block; deployers see it as a `dynamic_sql` warning at review (README, "Database").
37
+ -- capybara:allow-destructive not destructive: the DO block only adds the embedding column, typed vector when pgvector is visible and real[] otherwise
38
+ DO $$
39
+ BEGIN
40
+ IF to_regtype('vector') IS NOT NULL THEN
41
+ ALTER TABLE memories ADD COLUMN IF NOT EXISTS embedding vector;
42
+ ELSE
43
+ ALTER TABLE memories ADD COLUMN IF NOT EXISTS embedding real[];
44
+ END IF;
45
+ END
46
+ $$;
47
+
48
+ -- `[[…]]` links of a memory, parsed on every write: a path or a bare name, resolved when read,
49
+ -- so a link to a memory written later becomes live.
50
+ CREATE TABLE IF NOT EXISTS memory_links (
51
+ memory_id uuid NOT NULL REFERENCES memories (id) ON DELETE CASCADE,
52
+ to_path text NOT NULL,
53
+ PRIMARY KEY (memory_id, to_path)
54
+ );
55
+
56
+ -- Semantic neighbours (top cosine matches among the owner's memories), for the memory page.
57
+ CREATE TABLE IF NOT EXISTS memory_neighbors (
58
+ memory_id uuid NOT NULL REFERENCES memories (id) ON DELETE CASCADE,
59
+ neighbor_id uuid NOT NULL REFERENCES memories (id) ON DELETE CASCADE,
60
+ score real NOT NULL,
61
+ PRIMARY KEY (memory_id, neighbor_id)
62
+ );
63
+ CREATE INDEX IF NOT EXISTS memory_neighbors_neighbor ON memory_neighbors (neighbor_id);
64
+
65
+ -- Display names of the agents and members the plugin has seen (upserted from each context
66
+ -- request), so the memory page can name them without a kernel lookup.
67
+ CREATE TABLE IF NOT EXISTS owners (
68
+ org_id text NOT NULL,
69
+ agent_id text NOT NULL,
70
+ account_id text NOT NULL,
71
+ agent_name text NOT NULL,
72
+ owner_name text NOT NULL,
73
+ seen_at timestamptz NOT NULL DEFAULT now(),
74
+ PRIMARY KEY (org_id, agent_id, account_id)
75
+ );
76
+ CREATE INDEX IF NOT EXISTS owners_org_account ON owners (org_id, account_id);
77
+
78
+ -- One row per admin view of, or delete in, another member's memories (audit only).
79
+ CREATE TABLE IF NOT EXISTS admin_access_log (
80
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
81
+ org_id text NOT NULL,
82
+ admin_account_id text NOT NULL,
83
+ owner_account_id text NOT NULL,
84
+ agent_id text NOT NULL,
85
+ action text NOT NULL CHECK (action IN ('view', 'delete')),
86
+ memory_path text,
87
+ at timestamptz NOT NULL DEFAULT now()
88
+ );
89
+ CREATE INDEX IF NOT EXISTS admin_access_log_org ON admin_access_log (org_id, at);
package/package.json CHANGED
@@ -1,6 +1,21 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-memory",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-rc.1",
4
+ "type": "module",
5
+ "license": "Apache-2.0",
6
+ "description": "Memory for agents: each agent remembers each member across conversations, with an index at run start, memory tools, hybrid search and a memory page",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/capybara-hq/plugins.git",
10
+ "directory": "plugins/memory"
11
+ },
12
+ "homepage": "https://github.com/capybara-hq/plugins/tree/main/plugins/memory#readme",
13
+ "main": "./dist/index.mjs",
14
+ "exports": {
15
+ ".": "./dist/index.mjs"
16
+ },
17
+ "peerDependencies": {
18
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.19",
19
+ "zod": "^4.0.0"
20
+ }
21
+ }