@minion-stack/db 0.4.0 → 0.7.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/dist/pg/schema/agent-groups.d.ts +169 -0
- package/dist/pg/schema/agent-groups.d.ts.map +1 -0
- package/dist/pg/schema/agent-groups.js +21 -0
- package/dist/pg/schema/agent-groups.js.map +1 -0
- package/dist/pg/schema/agent-memories.d.ts +281 -0
- package/dist/pg/schema/agent-memories.d.ts.map +1 -0
- package/dist/pg/schema/agent-memories.js +59 -0
- package/dist/pg/schema/agent-memories.js.map +1 -0
- package/dist/pg/schema/builder.d.ts +1432 -0
- package/dist/pg/schema/builder.d.ts.map +1 -0
- package/dist/pg/schema/builder.js +160 -0
- package/dist/pg/schema/builder.js.map +1 -0
- package/dist/pg/schema/channels.d.ts +441 -0
- package/dist/pg/schema/channels.d.ts.map +1 -0
- package/dist/pg/schema/channels.js +62 -0
- package/dist/pg/schema/channels.js.map +1 -0
- package/dist/pg/schema/chat-messages.d.ts +184 -0
- package/dist/pg/schema/chat-messages.d.ts.map +1 -0
- package/dist/pg/schema/chat-messages.js +26 -0
- package/dist/pg/schema/chat-messages.js.map +1 -0
- package/dist/pg/schema/device-identities.d.ts +111 -0
- package/dist/pg/schema/device-identities.d.ts.map +1 -0
- package/dist/pg/schema/device-identities.js +11 -0
- package/dist/pg/schema/device-identities.js.map +1 -0
- package/dist/pg/schema/files.d.ts +162 -0
- package/dist/pg/schema/files.d.ts.map +1 -0
- package/dist/pg/schema/files.js +15 -0
- package/dist/pg/schema/files.js.map +1 -0
- package/dist/pg/schema/index.d.ts +20 -0
- package/dist/pg/schema/index.d.ts.map +1 -1
- package/dist/pg/schema/index.js +22 -0
- package/dist/pg/schema/index.js.map +1 -1
- package/dist/pg/schema/marketplace.d.ts +459 -0
- package/dist/pg/schema/marketplace.d.ts.map +1 -0
- package/dist/pg/schema/marketplace.js +42 -0
- package/dist/pg/schema/marketplace.js.map +1 -0
- package/dist/pg/schema/messages.d.ts +391 -0
- package/dist/pg/schema/messages.d.ts.map +1 -0
- package/dist/pg/schema/messages.js +44 -0
- package/dist/pg/schema/messages.js.map +1 -0
- package/dist/pg/schema/missions.d.ts +361 -0
- package/dist/pg/schema/missions.d.ts.map +1 -0
- package/dist/pg/schema/missions.js +48 -0
- package/dist/pg/schema/missions.js.map +1 -0
- package/dist/pg/schema/personal-agents.d.ts +285 -0
- package/dist/pg/schema/personal-agents.d.ts.map +1 -0
- package/dist/pg/schema/personal-agents.js +40 -0
- package/dist/pg/schema/personal-agents.js.map +1 -0
- package/dist/pg/schema/profiles.d.ts +17 -0
- package/dist/pg/schema/profiles.d.ts.map +1 -1
- package/dist/pg/schema/profiles.js +2 -0
- package/dist/pg/schema/profiles.js.map +1 -1
- package/dist/pg/schema/server-ops.d.ts +836 -0
- package/dist/pg/schema/server-ops.d.ts.map +1 -0
- package/dist/pg/schema/server-ops.js +88 -0
- package/dist/pg/schema/server-ops.js.map +1 -0
- package/dist/pg/schema/sessions.d.ts +395 -0
- package/dist/pg/schema/sessions.d.ts.map +1 -0
- package/dist/pg/schema/sessions.js +50 -0
- package/dist/pg/schema/sessions.js.map +1 -0
- package/dist/pg/schema/settings.d.ts +111 -0
- package/dist/pg/schema/settings.d.ts.map +1 -0
- package/dist/pg/schema/settings.js +17 -0
- package/dist/pg/schema/settings.js.map +1 -0
- package/dist/pg/schema/skills.d.ts +395 -0
- package/dist/pg/schema/skills.d.ts.map +1 -0
- package/dist/pg/schema/skills.js +45 -0
- package/dist/pg/schema/skills.js.map +1 -0
- package/dist/pg/schema/user-agents.d.ts +80 -0
- package/dist/pg/schema/user-agents.d.ts.map +1 -0
- package/dist/pg/schema/user-agents.js +21 -0
- package/dist/pg/schema/user-agents.js.map +1 -0
- package/dist/pg/schema/user-identities.d.ts +1 -1
- package/dist/pg/schema/user-preferences.d.ts +97 -0
- package/dist/pg/schema/user-preferences.d.ts.map +1 -0
- package/dist/pg/schema/user-preferences.js +19 -0
- package/dist/pg/schema/user-preferences.js.map +1 -0
- package/dist/pg/schema/workshop-saves.d.ts +145 -0
- package/dist/pg/schema/workshop-saves.d.ts.map +1 -0
- package/dist/pg/schema/workshop-saves.js +13 -0
- package/dist/pg/schema/workshop-saves.js.map +1 -0
- package/dist/pg/schema/workspace-membership.d.ts +83 -0
- package/dist/pg/schema/workspace-membership.d.ts.map +1 -0
- package/dist/pg/schema/workspace-membership.js +19 -0
- package/dist/pg/schema/workspace-membership.js.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/join-requests.d.ts +188 -0
- package/dist/schema/join-requests.d.ts.map +1 -0
- package/dist/schema/join-requests.js +35 -0
- package/dist/schema/join-requests.js.map +1 -0
- package/dist/schema/personal-agents.d.ts +1 -1
- package/dist/schema/reliability-events.d.ts +1 -1
- package/dist/schema/skill-execution-stats.d.ts +1 -1
- package/package.json +1 -1
- package/src/pg/schema/agent-groups.ts +30 -0
- package/src/pg/schema/agent-memories.ts +73 -0
- package/src/pg/schema/builder.ts +205 -0
- package/src/pg/schema/channels.ts +77 -0
- package/src/pg/schema/chat-messages.ts +30 -0
- package/src/pg/schema/device-identities.ts +11 -0
- package/src/pg/schema/files.ts +19 -0
- package/src/pg/schema/index.ts +38 -0
- package/src/pg/schema/marketplace.ts +47 -0
- package/src/pg/schema/messages.ts +48 -0
- package/src/pg/schema/missions.ts +58 -0
- package/src/pg/schema/personal-agents.ts +44 -0
- package/src/pg/schema/profiles.ts +2 -0
- package/src/pg/schema/server-ops.ts +126 -0
- package/src/pg/schema/sessions.ts +60 -0
- package/src/pg/schema/settings.ts +21 -0
- package/src/pg/schema/skills.ts +65 -0
- package/src/pg/schema/user-agents.ts +25 -0
- package/src/pg/schema/user-preferences.ts +23 -0
- package/src/pg/schema/workshop-saves.ts +13 -0
- package/src/pg/schema/workspace-membership.ts +26 -0
- package/src/schema/index.ts +2 -0
- package/src/schema/join-requests.ts +42 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/** User-defined agent groupings. Mirrors Turso `agent_groups`. user_id → profile_id, tenant_id → organizations.id. */
|
|
2
|
+
export declare const agentGroups: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
3
|
+
name: "agent_groups";
|
|
4
|
+
schema: undefined;
|
|
5
|
+
columns: {
|
|
6
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
7
|
+
name: "id";
|
|
8
|
+
tableName: "agent_groups";
|
|
9
|
+
dataType: "string";
|
|
10
|
+
columnType: "PgText";
|
|
11
|
+
data: string;
|
|
12
|
+
driverParam: string;
|
|
13
|
+
notNull: true;
|
|
14
|
+
hasDefault: false;
|
|
15
|
+
isPrimaryKey: true;
|
|
16
|
+
isAutoincrement: false;
|
|
17
|
+
hasRuntimeDefault: false;
|
|
18
|
+
enumValues: [string, ...string[]];
|
|
19
|
+
baseColumn: never;
|
|
20
|
+
identity: undefined;
|
|
21
|
+
generated: undefined;
|
|
22
|
+
}, {}, {}>;
|
|
23
|
+
profileId: import("drizzle-orm/pg-core").PgColumn<{
|
|
24
|
+
name: "profile_id";
|
|
25
|
+
tableName: "agent_groups";
|
|
26
|
+
dataType: "string";
|
|
27
|
+
columnType: "PgUUID";
|
|
28
|
+
data: string;
|
|
29
|
+
driverParam: string;
|
|
30
|
+
notNull: true;
|
|
31
|
+
hasDefault: false;
|
|
32
|
+
isPrimaryKey: false;
|
|
33
|
+
isAutoincrement: false;
|
|
34
|
+
hasRuntimeDefault: false;
|
|
35
|
+
enumValues: undefined;
|
|
36
|
+
baseColumn: never;
|
|
37
|
+
identity: undefined;
|
|
38
|
+
generated: undefined;
|
|
39
|
+
}, {}, {}>;
|
|
40
|
+
tenantId: import("drizzle-orm/pg-core").PgColumn<{
|
|
41
|
+
name: "tenant_id";
|
|
42
|
+
tableName: "agent_groups";
|
|
43
|
+
dataType: "string";
|
|
44
|
+
columnType: "PgUUID";
|
|
45
|
+
data: string;
|
|
46
|
+
driverParam: string;
|
|
47
|
+
notNull: true;
|
|
48
|
+
hasDefault: false;
|
|
49
|
+
isPrimaryKey: false;
|
|
50
|
+
isAutoincrement: false;
|
|
51
|
+
hasRuntimeDefault: false;
|
|
52
|
+
enumValues: undefined;
|
|
53
|
+
baseColumn: never;
|
|
54
|
+
identity: undefined;
|
|
55
|
+
generated: undefined;
|
|
56
|
+
}, {}, {}>;
|
|
57
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
58
|
+
name: "name";
|
|
59
|
+
tableName: "agent_groups";
|
|
60
|
+
dataType: "string";
|
|
61
|
+
columnType: "PgText";
|
|
62
|
+
data: string;
|
|
63
|
+
driverParam: string;
|
|
64
|
+
notNull: true;
|
|
65
|
+
hasDefault: false;
|
|
66
|
+
isPrimaryKey: false;
|
|
67
|
+
isAutoincrement: false;
|
|
68
|
+
hasRuntimeDefault: false;
|
|
69
|
+
enumValues: [string, ...string[]];
|
|
70
|
+
baseColumn: never;
|
|
71
|
+
identity: undefined;
|
|
72
|
+
generated: undefined;
|
|
73
|
+
}, {}, {}>;
|
|
74
|
+
sortOrder: import("drizzle-orm/pg-core").PgColumn<{
|
|
75
|
+
name: "sort_order";
|
|
76
|
+
tableName: "agent_groups";
|
|
77
|
+
dataType: "number";
|
|
78
|
+
columnType: "PgInteger";
|
|
79
|
+
data: number;
|
|
80
|
+
driverParam: string | number;
|
|
81
|
+
notNull: false;
|
|
82
|
+
hasDefault: true;
|
|
83
|
+
isPrimaryKey: false;
|
|
84
|
+
isAutoincrement: false;
|
|
85
|
+
hasRuntimeDefault: false;
|
|
86
|
+
enumValues: undefined;
|
|
87
|
+
baseColumn: never;
|
|
88
|
+
identity: undefined;
|
|
89
|
+
generated: undefined;
|
|
90
|
+
}, {}, {}>;
|
|
91
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
92
|
+
name: "created_at";
|
|
93
|
+
tableName: "agent_groups";
|
|
94
|
+
dataType: "date";
|
|
95
|
+
columnType: "PgTimestamp";
|
|
96
|
+
data: Date;
|
|
97
|
+
driverParam: string;
|
|
98
|
+
notNull: true;
|
|
99
|
+
hasDefault: true;
|
|
100
|
+
isPrimaryKey: false;
|
|
101
|
+
isAutoincrement: false;
|
|
102
|
+
hasRuntimeDefault: false;
|
|
103
|
+
enumValues: undefined;
|
|
104
|
+
baseColumn: never;
|
|
105
|
+
identity: undefined;
|
|
106
|
+
generated: undefined;
|
|
107
|
+
}, {}, {}>;
|
|
108
|
+
};
|
|
109
|
+
dialect: "pg";
|
|
110
|
+
}>;
|
|
111
|
+
export declare const agentGroupMembers: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
112
|
+
name: "agent_group_members";
|
|
113
|
+
schema: undefined;
|
|
114
|
+
columns: {
|
|
115
|
+
groupId: import("drizzle-orm/pg-core").PgColumn<{
|
|
116
|
+
name: "group_id";
|
|
117
|
+
tableName: "agent_group_members";
|
|
118
|
+
dataType: "string";
|
|
119
|
+
columnType: "PgText";
|
|
120
|
+
data: string;
|
|
121
|
+
driverParam: string;
|
|
122
|
+
notNull: true;
|
|
123
|
+
hasDefault: false;
|
|
124
|
+
isPrimaryKey: false;
|
|
125
|
+
isAutoincrement: false;
|
|
126
|
+
hasRuntimeDefault: false;
|
|
127
|
+
enumValues: [string, ...string[]];
|
|
128
|
+
baseColumn: never;
|
|
129
|
+
identity: undefined;
|
|
130
|
+
generated: undefined;
|
|
131
|
+
}, {}, {}>;
|
|
132
|
+
agentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
133
|
+
name: "agent_id";
|
|
134
|
+
tableName: "agent_group_members";
|
|
135
|
+
dataType: "string";
|
|
136
|
+
columnType: "PgText";
|
|
137
|
+
data: string;
|
|
138
|
+
driverParam: string;
|
|
139
|
+
notNull: true;
|
|
140
|
+
hasDefault: false;
|
|
141
|
+
isPrimaryKey: false;
|
|
142
|
+
isAutoincrement: false;
|
|
143
|
+
hasRuntimeDefault: false;
|
|
144
|
+
enumValues: [string, ...string[]];
|
|
145
|
+
baseColumn: never;
|
|
146
|
+
identity: undefined;
|
|
147
|
+
generated: undefined;
|
|
148
|
+
}, {}, {}>;
|
|
149
|
+
sortOrder: import("drizzle-orm/pg-core").PgColumn<{
|
|
150
|
+
name: "sort_order";
|
|
151
|
+
tableName: "agent_group_members";
|
|
152
|
+
dataType: "number";
|
|
153
|
+
columnType: "PgInteger";
|
|
154
|
+
data: number;
|
|
155
|
+
driverParam: string | number;
|
|
156
|
+
notNull: false;
|
|
157
|
+
hasDefault: true;
|
|
158
|
+
isPrimaryKey: false;
|
|
159
|
+
isAutoincrement: false;
|
|
160
|
+
hasRuntimeDefault: false;
|
|
161
|
+
enumValues: undefined;
|
|
162
|
+
baseColumn: never;
|
|
163
|
+
identity: undefined;
|
|
164
|
+
generated: undefined;
|
|
165
|
+
}, {}, {}>;
|
|
166
|
+
};
|
|
167
|
+
dialect: "pg";
|
|
168
|
+
}>;
|
|
169
|
+
//# sourceMappingURL=agent-groups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-groups.d.ts","sourceRoot":"","sources":["../../../src/pg/schema/agent-groups.ts"],"names":[],"mappings":"AAGA,sHAAsH;AACtH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAavB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU7B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { pgTable, uuid, text, integer, timestamp, index, primaryKey } from 'drizzle-orm/pg-core';
|
|
2
|
+
import { profiles } from './profiles.js';
|
|
3
|
+
/** User-defined agent groupings. Mirrors Turso `agent_groups`. user_id → profile_id, tenant_id → organizations.id. */
|
|
4
|
+
export const agentGroups = pgTable('agent_groups', {
|
|
5
|
+
id: text('id').primaryKey(),
|
|
6
|
+
profileId: uuid('profile_id')
|
|
7
|
+
.notNull()
|
|
8
|
+
.references(() => profiles.id, { onDelete: 'cascade' }),
|
|
9
|
+
tenantId: uuid('tenant_id').notNull(),
|
|
10
|
+
name: text('name').notNull(),
|
|
11
|
+
sortOrder: integer('sort_order').default(0),
|
|
12
|
+
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
|
13
|
+
}, (t) => [index('idx_agent_groups_profile').on(t.profileId, t.tenantId)]);
|
|
14
|
+
export const agentGroupMembers = pgTable('agent_group_members', {
|
|
15
|
+
groupId: text('group_id')
|
|
16
|
+
.notNull()
|
|
17
|
+
.references(() => agentGroups.id, { onDelete: 'cascade' }),
|
|
18
|
+
agentId: text('agent_id').notNull(),
|
|
19
|
+
sortOrder: integer('sort_order').default(0),
|
|
20
|
+
}, (t) => [primaryKey({ columns: [t.groupId, t.agentId] })]);
|
|
21
|
+
//# sourceMappingURL=agent-groups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-groups.js","sourceRoot":"","sources":["../../../src/pg/schema/agent-groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,sHAAsH;AACtH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAChC,cAAc,EACd;IACE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE;IAC3B,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;SAC1B,OAAO,EAAE;SACT,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACzD,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE;IACrC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;CAClF,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CACvE,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CACtC,qBAAqB,EACrB;IACE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;SACtB,OAAO,EAAE;SACT,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC5D,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnC,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CAC5C,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CACzD,CAAC"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Org-scoped agent memory corpus with pgvector embeddings. This is the
|
|
3
|
+
* system-of-record home for agent memories (migrated off the gateway-local
|
|
4
|
+
* LanceDB store): semantic memory, session-memory summaries, and captured
|
|
5
|
+
* facts/preferences/decisions/entities. Both the hub (visualization) and the
|
|
6
|
+
* flow runner (RAG retrieval) read from here.
|
|
7
|
+
*
|
|
8
|
+
* Embedding dimension matches OpenAI `text-embedding-3-small` (1536). If the
|
|
9
|
+
* embedding model changes, add a new column / table rather than mixing
|
|
10
|
+
* dimensions in one column.
|
|
11
|
+
*
|
|
12
|
+
* RLS (org isolation) is added in the hand-written companion migration
|
|
13
|
+
* `<ts>_agent_memories_rls.sql` (role app_ledger + app.current_org_id GUC),
|
|
14
|
+
* mirroring `messages`. Drizzle does not manage roles/policies, the `vector`
|
|
15
|
+
* extension, or the HNSW index — those live in the companion SQL.
|
|
16
|
+
*/
|
|
17
|
+
export declare const agentMemories: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
18
|
+
name: "agent_memories";
|
|
19
|
+
schema: undefined;
|
|
20
|
+
columns: {
|
|
21
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
22
|
+
name: "id";
|
|
23
|
+
tableName: "agent_memories";
|
|
24
|
+
dataType: "string";
|
|
25
|
+
columnType: "PgUUID";
|
|
26
|
+
data: string;
|
|
27
|
+
driverParam: string;
|
|
28
|
+
notNull: true;
|
|
29
|
+
hasDefault: true;
|
|
30
|
+
isPrimaryKey: true;
|
|
31
|
+
isAutoincrement: false;
|
|
32
|
+
hasRuntimeDefault: false;
|
|
33
|
+
enumValues: undefined;
|
|
34
|
+
baseColumn: never;
|
|
35
|
+
identity: undefined;
|
|
36
|
+
generated: undefined;
|
|
37
|
+
}, {}, {}>;
|
|
38
|
+
orgId: import("drizzle-orm/pg-core").PgColumn<{
|
|
39
|
+
name: "org_id";
|
|
40
|
+
tableName: "agent_memories";
|
|
41
|
+
dataType: "string";
|
|
42
|
+
columnType: "PgText";
|
|
43
|
+
data: string;
|
|
44
|
+
driverParam: string;
|
|
45
|
+
notNull: true;
|
|
46
|
+
hasDefault: false;
|
|
47
|
+
isPrimaryKey: false;
|
|
48
|
+
isAutoincrement: false;
|
|
49
|
+
hasRuntimeDefault: false;
|
|
50
|
+
enumValues: [string, ...string[]];
|
|
51
|
+
baseColumn: never;
|
|
52
|
+
identity: undefined;
|
|
53
|
+
generated: undefined;
|
|
54
|
+
}, {}, {}>;
|
|
55
|
+
gatewayId: import("drizzle-orm/pg-core").PgColumn<{
|
|
56
|
+
name: "gateway_id";
|
|
57
|
+
tableName: "agent_memories";
|
|
58
|
+
dataType: "string";
|
|
59
|
+
columnType: "PgText";
|
|
60
|
+
data: string;
|
|
61
|
+
driverParam: string;
|
|
62
|
+
notNull: false;
|
|
63
|
+
hasDefault: false;
|
|
64
|
+
isPrimaryKey: false;
|
|
65
|
+
isAutoincrement: false;
|
|
66
|
+
hasRuntimeDefault: false;
|
|
67
|
+
enumValues: [string, ...string[]];
|
|
68
|
+
baseColumn: never;
|
|
69
|
+
identity: undefined;
|
|
70
|
+
generated: undefined;
|
|
71
|
+
}, {}, {}>;
|
|
72
|
+
agentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
73
|
+
name: "agent_id";
|
|
74
|
+
tableName: "agent_memories";
|
|
75
|
+
dataType: "string";
|
|
76
|
+
columnType: "PgText";
|
|
77
|
+
data: string;
|
|
78
|
+
driverParam: string;
|
|
79
|
+
notNull: true;
|
|
80
|
+
hasDefault: false;
|
|
81
|
+
isPrimaryKey: false;
|
|
82
|
+
isAutoincrement: false;
|
|
83
|
+
hasRuntimeDefault: false;
|
|
84
|
+
enumValues: [string, ...string[]];
|
|
85
|
+
baseColumn: never;
|
|
86
|
+
identity: undefined;
|
|
87
|
+
generated: undefined;
|
|
88
|
+
}, {}, {}>;
|
|
89
|
+
profileId: import("drizzle-orm/pg-core").PgColumn<{
|
|
90
|
+
name: "profile_id";
|
|
91
|
+
tableName: "agent_memories";
|
|
92
|
+
dataType: "string";
|
|
93
|
+
columnType: "PgUUID";
|
|
94
|
+
data: string;
|
|
95
|
+
driverParam: string;
|
|
96
|
+
notNull: false;
|
|
97
|
+
hasDefault: false;
|
|
98
|
+
isPrimaryKey: false;
|
|
99
|
+
isAutoincrement: false;
|
|
100
|
+
hasRuntimeDefault: false;
|
|
101
|
+
enumValues: undefined;
|
|
102
|
+
baseColumn: never;
|
|
103
|
+
identity: undefined;
|
|
104
|
+
generated: undefined;
|
|
105
|
+
}, {}, {}>;
|
|
106
|
+
content: import("drizzle-orm/pg-core").PgColumn<{
|
|
107
|
+
name: "content";
|
|
108
|
+
tableName: "agent_memories";
|
|
109
|
+
dataType: "string";
|
|
110
|
+
columnType: "PgText";
|
|
111
|
+
data: string;
|
|
112
|
+
driverParam: string;
|
|
113
|
+
notNull: true;
|
|
114
|
+
hasDefault: false;
|
|
115
|
+
isPrimaryKey: false;
|
|
116
|
+
isAutoincrement: false;
|
|
117
|
+
hasRuntimeDefault: false;
|
|
118
|
+
enumValues: [string, ...string[]];
|
|
119
|
+
baseColumn: never;
|
|
120
|
+
identity: undefined;
|
|
121
|
+
generated: undefined;
|
|
122
|
+
}, {}, {}>;
|
|
123
|
+
embedding: import("drizzle-orm/pg-core").PgColumn<{
|
|
124
|
+
name: "embedding";
|
|
125
|
+
tableName: "agent_memories";
|
|
126
|
+
dataType: "array";
|
|
127
|
+
columnType: "PgVector";
|
|
128
|
+
data: number[];
|
|
129
|
+
driverParam: string;
|
|
130
|
+
notNull: false;
|
|
131
|
+
hasDefault: false;
|
|
132
|
+
isPrimaryKey: false;
|
|
133
|
+
isAutoincrement: false;
|
|
134
|
+
hasRuntimeDefault: false;
|
|
135
|
+
enumValues: undefined;
|
|
136
|
+
baseColumn: never;
|
|
137
|
+
identity: undefined;
|
|
138
|
+
generated: undefined;
|
|
139
|
+
}, {}, {
|
|
140
|
+
dimensions: 1536;
|
|
141
|
+
}>;
|
|
142
|
+
category: import("drizzle-orm/pg-core").PgColumn<{
|
|
143
|
+
name: "category";
|
|
144
|
+
tableName: "agent_memories";
|
|
145
|
+
dataType: "string";
|
|
146
|
+
columnType: "PgText";
|
|
147
|
+
data: "preference" | "fact" | "decision" | "entity" | "other";
|
|
148
|
+
driverParam: string;
|
|
149
|
+
notNull: true;
|
|
150
|
+
hasDefault: true;
|
|
151
|
+
isPrimaryKey: false;
|
|
152
|
+
isAutoincrement: false;
|
|
153
|
+
hasRuntimeDefault: false;
|
|
154
|
+
enumValues: ["preference", "fact", "decision", "entity", "other"];
|
|
155
|
+
baseColumn: never;
|
|
156
|
+
identity: undefined;
|
|
157
|
+
generated: undefined;
|
|
158
|
+
}, {}, {}>;
|
|
159
|
+
importance: import("drizzle-orm/pg-core").PgColumn<{
|
|
160
|
+
name: "importance";
|
|
161
|
+
tableName: "agent_memories";
|
|
162
|
+
dataType: "number";
|
|
163
|
+
columnType: "PgReal";
|
|
164
|
+
data: number;
|
|
165
|
+
driverParam: string | number;
|
|
166
|
+
notNull: true;
|
|
167
|
+
hasDefault: true;
|
|
168
|
+
isPrimaryKey: false;
|
|
169
|
+
isAutoincrement: false;
|
|
170
|
+
hasRuntimeDefault: false;
|
|
171
|
+
enumValues: undefined;
|
|
172
|
+
baseColumn: never;
|
|
173
|
+
identity: undefined;
|
|
174
|
+
generated: undefined;
|
|
175
|
+
}, {}, {}>;
|
|
176
|
+
source: import("drizzle-orm/pg-core").PgColumn<{
|
|
177
|
+
name: "source";
|
|
178
|
+
tableName: "agent_memories";
|
|
179
|
+
dataType: "string";
|
|
180
|
+
columnType: "PgText";
|
|
181
|
+
data: string;
|
|
182
|
+
driverParam: string;
|
|
183
|
+
notNull: true;
|
|
184
|
+
hasDefault: true;
|
|
185
|
+
isPrimaryKey: false;
|
|
186
|
+
isAutoincrement: false;
|
|
187
|
+
hasRuntimeDefault: false;
|
|
188
|
+
enumValues: [string, ...string[]];
|
|
189
|
+
baseColumn: never;
|
|
190
|
+
identity: undefined;
|
|
191
|
+
generated: undefined;
|
|
192
|
+
}, {}, {}>;
|
|
193
|
+
sourceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
194
|
+
name: "source_id";
|
|
195
|
+
tableName: "agent_memories";
|
|
196
|
+
dataType: "string";
|
|
197
|
+
columnType: "PgText";
|
|
198
|
+
data: string;
|
|
199
|
+
driverParam: string;
|
|
200
|
+
notNull: false;
|
|
201
|
+
hasDefault: false;
|
|
202
|
+
isPrimaryKey: false;
|
|
203
|
+
isAutoincrement: false;
|
|
204
|
+
hasRuntimeDefault: false;
|
|
205
|
+
enumValues: [string, ...string[]];
|
|
206
|
+
baseColumn: never;
|
|
207
|
+
identity: undefined;
|
|
208
|
+
generated: undefined;
|
|
209
|
+
}, {}, {}>;
|
|
210
|
+
occurredAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
211
|
+
name: "occurred_at";
|
|
212
|
+
tableName: "agent_memories";
|
|
213
|
+
dataType: "date";
|
|
214
|
+
columnType: "PgTimestamp";
|
|
215
|
+
data: Date;
|
|
216
|
+
driverParam: string;
|
|
217
|
+
notNull: false;
|
|
218
|
+
hasDefault: false;
|
|
219
|
+
isPrimaryKey: false;
|
|
220
|
+
isAutoincrement: false;
|
|
221
|
+
hasRuntimeDefault: false;
|
|
222
|
+
enumValues: undefined;
|
|
223
|
+
baseColumn: never;
|
|
224
|
+
identity: undefined;
|
|
225
|
+
generated: undefined;
|
|
226
|
+
}, {}, {}>;
|
|
227
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
228
|
+
name: "created_at";
|
|
229
|
+
tableName: "agent_memories";
|
|
230
|
+
dataType: "date";
|
|
231
|
+
columnType: "PgTimestamp";
|
|
232
|
+
data: Date;
|
|
233
|
+
driverParam: string;
|
|
234
|
+
notNull: true;
|
|
235
|
+
hasDefault: true;
|
|
236
|
+
isPrimaryKey: false;
|
|
237
|
+
isAutoincrement: false;
|
|
238
|
+
hasRuntimeDefault: false;
|
|
239
|
+
enumValues: undefined;
|
|
240
|
+
baseColumn: never;
|
|
241
|
+
identity: undefined;
|
|
242
|
+
generated: undefined;
|
|
243
|
+
}, {}, {}>;
|
|
244
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
245
|
+
name: "updated_at";
|
|
246
|
+
tableName: "agent_memories";
|
|
247
|
+
dataType: "date";
|
|
248
|
+
columnType: "PgTimestamp";
|
|
249
|
+
data: Date;
|
|
250
|
+
driverParam: string;
|
|
251
|
+
notNull: true;
|
|
252
|
+
hasDefault: true;
|
|
253
|
+
isPrimaryKey: false;
|
|
254
|
+
isAutoincrement: false;
|
|
255
|
+
hasRuntimeDefault: false;
|
|
256
|
+
enumValues: undefined;
|
|
257
|
+
baseColumn: never;
|
|
258
|
+
identity: undefined;
|
|
259
|
+
generated: undefined;
|
|
260
|
+
}, {}, {}>;
|
|
261
|
+
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
262
|
+
name: "metadata";
|
|
263
|
+
tableName: "agent_memories";
|
|
264
|
+
dataType: "json";
|
|
265
|
+
columnType: "PgJsonb";
|
|
266
|
+
data: unknown;
|
|
267
|
+
driverParam: unknown;
|
|
268
|
+
notNull: true;
|
|
269
|
+
hasDefault: true;
|
|
270
|
+
isPrimaryKey: false;
|
|
271
|
+
isAutoincrement: false;
|
|
272
|
+
hasRuntimeDefault: false;
|
|
273
|
+
enumValues: undefined;
|
|
274
|
+
baseColumn: never;
|
|
275
|
+
identity: undefined;
|
|
276
|
+
generated: undefined;
|
|
277
|
+
}, {}, {}>;
|
|
278
|
+
};
|
|
279
|
+
dialect: "pg";
|
|
280
|
+
}>;
|
|
281
|
+
//# sourceMappingURL=agent-memories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-memories.d.ts","sourceRoot":"","sources":["../../../src/pg/schema/agent-memories.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CzB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { pgTable, uuid, text, real, timestamp, jsonb, vector, index, uniqueIndex, } from 'drizzle-orm/pg-core';
|
|
3
|
+
/**
|
|
4
|
+
* Org-scoped agent memory corpus with pgvector embeddings. This is the
|
|
5
|
+
* system-of-record home for agent memories (migrated off the gateway-local
|
|
6
|
+
* LanceDB store): semantic memory, session-memory summaries, and captured
|
|
7
|
+
* facts/preferences/decisions/entities. Both the hub (visualization) and the
|
|
8
|
+
* flow runner (RAG retrieval) read from here.
|
|
9
|
+
*
|
|
10
|
+
* Embedding dimension matches OpenAI `text-embedding-3-small` (1536). If the
|
|
11
|
+
* embedding model changes, add a new column / table rather than mixing
|
|
12
|
+
* dimensions in one column.
|
|
13
|
+
*
|
|
14
|
+
* RLS (org isolation) is added in the hand-written companion migration
|
|
15
|
+
* `<ts>_agent_memories_rls.sql` (role app_ledger + app.current_org_id GUC),
|
|
16
|
+
* mirroring `messages`. Drizzle does not manage roles/policies, the `vector`
|
|
17
|
+
* extension, or the HNSW index — those live in the companion SQL.
|
|
18
|
+
*/
|
|
19
|
+
export const agentMemories = pgTable('agent_memories', {
|
|
20
|
+
id: uuid('id').primaryKey().defaultRandom(),
|
|
21
|
+
// RLS pivot. Better Auth org id (text), matches messages.org_id convention.
|
|
22
|
+
orgId: text('org_id').notNull(),
|
|
23
|
+
// Producing gateway/server id (hub servers.id; text — not a PG uuid).
|
|
24
|
+
gatewayId: text('gateway_id'),
|
|
25
|
+
// Memory is agent-scoped; agentId is the gateway agent id (text).
|
|
26
|
+
agentId: text('agent_id').notNull(),
|
|
27
|
+
// Optional owner for personal memories (profiles.id); null = agent-global.
|
|
28
|
+
profileId: uuid('profile_id'),
|
|
29
|
+
// The memory content (what gets embedded + shown).
|
|
30
|
+
content: text('content').notNull(),
|
|
31
|
+
// OpenAI text-embedding-3-small dimension. Nullable so a row can be inserted
|
|
32
|
+
// before its embedding is computed (async backfill).
|
|
33
|
+
embedding: vector('embedding', { dimensions: 1536 }),
|
|
34
|
+
category: text('category', {
|
|
35
|
+
enum: ['preference', 'fact', 'decision', 'entity', 'other'],
|
|
36
|
+
})
|
|
37
|
+
.notNull()
|
|
38
|
+
.default('other'),
|
|
39
|
+
// 0..1 salience used for ranking + decay.
|
|
40
|
+
importance: real('importance').notNull().default(0.5),
|
|
41
|
+
// Which subsystem produced this row: lancedb | session | manual | kg | ledger.
|
|
42
|
+
source: text('source').notNull().default('manual'),
|
|
43
|
+
// Original id in the source system (e.g. LanceDB MemoryEntry.id) — enables
|
|
44
|
+
// idempotent migration + dedupe.
|
|
45
|
+
sourceId: text('source_id'),
|
|
46
|
+
occurredAt: timestamp('occurred_at', { withTimezone: true }),
|
|
47
|
+
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
|
48
|
+
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
|
49
|
+
metadata: jsonb('metadata').notNull().default({}),
|
|
50
|
+
}, (t) => ({
|
|
51
|
+
// Idempotent migration / cross-source dedupe.
|
|
52
|
+
sourceUnique: uniqueIndex('agent_memories_source_uniq')
|
|
53
|
+
.on(t.orgId, t.source, t.sourceId)
|
|
54
|
+
.where(sql `source_id is not null`),
|
|
55
|
+
orgAgentIdx: index('agent_memories_org_agent_idx').on(t.orgId, t.agentId),
|
|
56
|
+
orgCategoryIdx: index('agent_memories_org_category_idx').on(t.orgId, t.category),
|
|
57
|
+
orgTimeIdx: index('agent_memories_org_time_idx').on(t.orgId, t.createdAt),
|
|
58
|
+
}));
|
|
59
|
+
//# sourceMappingURL=agent-memories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-memories.js","sourceRoot":"","sources":["../../../src/pg/schema/agent-memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,KAAK,EACL,MAAM,EACN,KAAK,EACL,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAClC,gBAAgB,EAChB;IACE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE;IAC3C,4EAA4E;IAC5E,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;IAC/B,sEAAsE;IACtE,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;IAC7B,kEAAkE;IAClE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnC,2EAA2E;IAC3E,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;IAC7B,mDAAmD;IACnD,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;IAClC,6EAA6E;IAC7E,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACpD,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE;QACzB,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC;KAC5D,CAAC;SACC,OAAO,EAAE;SACT,OAAO,CAAC,OAAO,CAAC;IACnB,0CAA0C;IAC1C,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IACrD,+EAA+E;IAC/E,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;IAClD,2EAA2E;IAC3E,iCAAiC;IACjC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;IAC3B,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAC5D,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;IACjF,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;IACjF,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAClD,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACN,8CAA8C;IAC9C,YAAY,EAAE,WAAW,CAAC,4BAA4B,CAAC;SACpD,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC;SACjC,KAAK,CAAC,GAAG,CAAA,uBAAuB,CAAC;IACpC,WAAW,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;IACzE,cAAc,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC;IAChF,UAAU,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC;CAC1E,CAAC,CACH,CAAC"}
|