@inkeep/agents-core 0.56.1 → 0.57.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/auth/auth-schema.d.ts +85 -85
- package/dist/auth/auth-validation-schemas.d.ts +152 -152
- package/dist/auth/auth.d.ts +9 -9
- package/dist/auth/auth.js +6 -0
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/client-exports.d.ts +4 -4
- package/dist/client-exports.js +2 -2
- package/dist/data-access/index.d.ts +2 -1
- package/dist/data-access/index.js +2 -1
- package/dist/data-access/manage/agents.d.ts +31 -31
- package/dist/data-access/manage/artifactComponents.d.ts +8 -8
- package/dist/data-access/manage/contextConfigs.d.ts +4 -4
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +8 -8
- package/dist/data-access/manage/skills.d.ts +14 -14
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +6 -6
- package/dist/data-access/manage/subAgentRelations.d.ts +8 -8
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +6 -6
- package/dist/data-access/manage/subAgents.d.ts +21 -21
- package/dist/data-access/manage/tools.d.ts +12 -12
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +12 -12
- package/dist/data-access/runtime/conversations.d.ts +31 -31
- package/dist/data-access/runtime/messages.d.ts +21 -21
- package/dist/data-access/runtime/tasks.d.ts +9 -9
- package/dist/data-access/runtime/userProfiles.d.ts +14 -0
- package/dist/data-access/runtime/userProfiles.js +45 -0
- package/dist/db/manage/manage-schema.d.ts +453 -453
- package/dist/db/runtime/runtime-schema.d.ts +416 -302
- package/dist/db/runtime/runtime-schema.js +14 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -3
- package/dist/types/entities.d.ts +7 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/error.d.ts +51 -51
- package/dist/utils/model-factory.d.ts +10 -2
- package/dist/utils/model-factory.js +21 -13
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/schemas.d.ts +2218 -1973
- package/dist/validation/schemas.js +16 -2
- package/drizzle/runtime/0019_easy_bedlam.sql +24 -0
- package/drizzle/runtime/meta/0019_snapshot.json +4003 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +1 -1
|
@@ -20,11 +20,11 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
20
20
|
toolId: string;
|
|
21
21
|
}) => Promise<{
|
|
22
22
|
id: string;
|
|
23
|
-
|
|
23
|
+
tenantId: string;
|
|
24
24
|
createdAt: string;
|
|
25
|
-
|
|
25
|
+
name: string;
|
|
26
26
|
description: string | null;
|
|
27
|
-
|
|
27
|
+
updatedAt: string;
|
|
28
28
|
projectId: string;
|
|
29
29
|
headers: Record<string, string> | null;
|
|
30
30
|
config: {
|
|
@@ -78,11 +78,11 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
78
78
|
}>;
|
|
79
79
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
80
80
|
id: string;
|
|
81
|
-
|
|
81
|
+
tenantId: string;
|
|
82
82
|
createdAt: string;
|
|
83
|
-
|
|
83
|
+
name: string;
|
|
84
84
|
description: string | null;
|
|
85
|
-
|
|
85
|
+
updatedAt: string;
|
|
86
86
|
projectId: string;
|
|
87
87
|
headers: Record<string, string> | null;
|
|
88
88
|
config: {
|
|
@@ -135,9 +135,9 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
135
135
|
}> | null;
|
|
136
136
|
}) => Promise<{
|
|
137
137
|
id: string;
|
|
138
|
+
tenantId: string;
|
|
138
139
|
createdAt: string;
|
|
139
140
|
updatedAt: string;
|
|
140
|
-
tenantId: string;
|
|
141
141
|
projectId: string;
|
|
142
142
|
agentId: string;
|
|
143
143
|
toolId: string;
|
|
@@ -154,9 +154,9 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
154
154
|
toolId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
156
|
id: string;
|
|
157
|
+
tenantId: string;
|
|
157
158
|
createdAt: string;
|
|
158
159
|
updatedAt: string;
|
|
159
|
-
tenantId: string;
|
|
160
160
|
projectId: string;
|
|
161
161
|
agentId: string;
|
|
162
162
|
toolId: string;
|
|
@@ -182,9 +182,9 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
182
182
|
relationId?: string;
|
|
183
183
|
}) => Promise<{
|
|
184
184
|
id: string;
|
|
185
|
+
tenantId: string;
|
|
185
186
|
createdAt: string;
|
|
186
187
|
updatedAt: string;
|
|
187
|
-
tenantId: string;
|
|
188
188
|
projectId: string;
|
|
189
189
|
agentId: string;
|
|
190
190
|
toolId: string;
|
|
@@ -202,11 +202,11 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
202
202
|
data: ToolInsert;
|
|
203
203
|
}) => Promise<{
|
|
204
204
|
id: string;
|
|
205
|
-
|
|
205
|
+
tenantId: string;
|
|
206
206
|
createdAt: string;
|
|
207
|
-
|
|
207
|
+
name: string;
|
|
208
208
|
description: string | null;
|
|
209
|
-
|
|
209
|
+
updatedAt: string;
|
|
210
210
|
projectId: string;
|
|
211
211
|
headers: Record<string, string> | null;
|
|
212
212
|
config: {
|
|
@@ -40,13 +40,13 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
|
|
|
40
40
|
algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
|
|
41
41
|
encoding: "hex" | "base64";
|
|
42
42
|
signature: {
|
|
43
|
-
source: "query" | "
|
|
43
|
+
source: "query" | "header" | "body";
|
|
44
44
|
key: string;
|
|
45
45
|
prefix?: string | undefined;
|
|
46
46
|
regex?: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
signedComponents: {
|
|
49
|
-
source: "literal" | "
|
|
49
|
+
source: "literal" | "header" | "body";
|
|
50
50
|
required: boolean;
|
|
51
51
|
key?: string | undefined;
|
|
52
52
|
value?: string | undefined;
|
|
@@ -9,48 +9,48 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
|
-
|
|
12
|
+
tenantId: string;
|
|
13
13
|
createdAt: string;
|
|
14
|
+
name: string | null;
|
|
14
15
|
updatedAt: string;
|
|
15
|
-
expiresAt: string | null;
|
|
16
|
-
tenantId: string;
|
|
17
16
|
projectId: string;
|
|
18
17
|
agentId: string;
|
|
19
18
|
publicId: string;
|
|
20
19
|
keyHash: string;
|
|
21
20
|
keyPrefix: string;
|
|
22
21
|
lastUsedAt: string | null;
|
|
22
|
+
expiresAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
25
|
id: string;
|
|
26
|
-
|
|
26
|
+
tenantId: string;
|
|
27
27
|
createdAt: string;
|
|
28
|
+
name: string | null;
|
|
28
29
|
updatedAt: string;
|
|
29
|
-
expiresAt: string | null;
|
|
30
|
-
tenantId: string;
|
|
31
30
|
projectId: string;
|
|
32
31
|
agentId: string;
|
|
33
32
|
publicId: string;
|
|
34
33
|
keyHash: string;
|
|
35
34
|
keyPrefix: string;
|
|
36
35
|
lastUsedAt: string | null;
|
|
36
|
+
expiresAt: string | null;
|
|
37
37
|
} | undefined>;
|
|
38
38
|
declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
40
40
|
agentId?: string;
|
|
41
41
|
}) => Promise<{
|
|
42
42
|
id: string;
|
|
43
|
-
|
|
43
|
+
tenantId: string;
|
|
44
44
|
createdAt: string;
|
|
45
|
+
name: string | null;
|
|
45
46
|
updatedAt: string;
|
|
46
|
-
expiresAt: string | null;
|
|
47
|
-
tenantId: string;
|
|
48
47
|
projectId: string;
|
|
49
48
|
agentId: string;
|
|
50
49
|
publicId: string;
|
|
51
50
|
keyHash: string;
|
|
52
51
|
keyPrefix: string;
|
|
53
52
|
lastUsedAt: string | null;
|
|
53
|
+
expiresAt: string | null;
|
|
54
54
|
}[]>;
|
|
55
55
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
@@ -67,17 +67,17 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
69
|
id: string;
|
|
70
|
-
|
|
70
|
+
tenantId: string;
|
|
71
71
|
createdAt: string;
|
|
72
|
+
name: string | null;
|
|
72
73
|
updatedAt: string;
|
|
73
|
-
expiresAt: string | null;
|
|
74
|
-
tenantId: string;
|
|
75
74
|
projectId: string;
|
|
76
75
|
agentId: string;
|
|
77
76
|
publicId: string;
|
|
78
77
|
keyHash: string;
|
|
79
78
|
keyPrefix: string;
|
|
80
79
|
lastUsedAt: string | null;
|
|
80
|
+
expiresAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -17,19 +17,19 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
17
17
|
}>;
|
|
18
18
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
19
19
|
id: string;
|
|
20
|
+
tenantId: string;
|
|
20
21
|
createdAt: string;
|
|
22
|
+
metadata: ConversationMetadata | null;
|
|
23
|
+
title: string | null;
|
|
21
24
|
updatedAt: string;
|
|
25
|
+
projectId: string;
|
|
26
|
+
agentId: string | null;
|
|
27
|
+
userId: string | null;
|
|
22
28
|
ref: {
|
|
23
|
-
type: "
|
|
29
|
+
type: "commit" | "tag" | "branch";
|
|
24
30
|
name: string;
|
|
25
31
|
hash: string;
|
|
26
32
|
} | null;
|
|
27
|
-
userId: string | null;
|
|
28
|
-
metadata: ConversationMetadata | null;
|
|
29
|
-
tenantId: string;
|
|
30
|
-
projectId: string;
|
|
31
|
-
agentId: string | null;
|
|
32
|
-
title: string | null;
|
|
33
33
|
activeSubAgentId: string;
|
|
34
34
|
lastContextResolution: string | null;
|
|
35
35
|
}>;
|
|
@@ -44,7 +44,7 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
44
44
|
agentId: string | null;
|
|
45
45
|
activeSubAgentId: string;
|
|
46
46
|
ref: {
|
|
47
|
-
type: "
|
|
47
|
+
type: "commit" | "tag" | "branch";
|
|
48
48
|
name: string;
|
|
49
49
|
hash: string;
|
|
50
50
|
} | null;
|
|
@@ -70,7 +70,7 @@ declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) =>
|
|
|
70
70
|
agentId: string | null;
|
|
71
71
|
activeSubAgentId: string;
|
|
72
72
|
ref: {
|
|
73
|
-
type: "
|
|
73
|
+
type: "commit" | "tag" | "branch";
|
|
74
74
|
name: string;
|
|
75
75
|
hash: string;
|
|
76
76
|
} | null;
|
|
@@ -86,19 +86,19 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
86
86
|
conversationId: string;
|
|
87
87
|
}) => Promise<{
|
|
88
88
|
id: string;
|
|
89
|
+
tenantId: string;
|
|
89
90
|
createdAt: string;
|
|
91
|
+
metadata: ConversationMetadata | null;
|
|
92
|
+
title: string | null;
|
|
90
93
|
updatedAt: string;
|
|
94
|
+
projectId: string;
|
|
95
|
+
agentId: string | null;
|
|
96
|
+
userId: string | null;
|
|
91
97
|
ref: {
|
|
92
|
-
type: "
|
|
98
|
+
type: "commit" | "tag" | "branch";
|
|
93
99
|
name: string;
|
|
94
100
|
hash: string;
|
|
95
101
|
} | null;
|
|
96
|
-
userId: string | null;
|
|
97
|
-
metadata: ConversationMetadata | null;
|
|
98
|
-
tenantId: string;
|
|
99
|
-
projectId: string;
|
|
100
|
-
agentId: string | null;
|
|
101
|
-
title: string | null;
|
|
102
102
|
activeSubAgentId: string;
|
|
103
103
|
lastContextResolution: string | null;
|
|
104
104
|
} | undefined>;
|
|
@@ -108,7 +108,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
108
108
|
tenantId: string;
|
|
109
109
|
id: string;
|
|
110
110
|
ref: {
|
|
111
|
-
type: "
|
|
111
|
+
type: "commit" | "tag" | "branch";
|
|
112
112
|
name: string;
|
|
113
113
|
hash: string;
|
|
114
114
|
};
|
|
@@ -122,19 +122,19 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
122
122
|
contextConfigId?: string | undefined;
|
|
123
123
|
} | {
|
|
124
124
|
id: string;
|
|
125
|
+
tenantId: string;
|
|
125
126
|
createdAt: string;
|
|
127
|
+
metadata: ConversationMetadata | null;
|
|
128
|
+
title: string | null;
|
|
126
129
|
updatedAt: string;
|
|
130
|
+
projectId: string;
|
|
131
|
+
agentId: string | null;
|
|
132
|
+
userId: string | null;
|
|
127
133
|
ref: {
|
|
128
|
-
type: "
|
|
134
|
+
type: "commit" | "tag" | "branch";
|
|
129
135
|
name: string;
|
|
130
136
|
hash: string;
|
|
131
137
|
} | null;
|
|
132
|
-
userId: string | null;
|
|
133
|
-
metadata: ConversationMetadata | null;
|
|
134
|
-
tenantId: string;
|
|
135
|
-
projectId: string;
|
|
136
|
-
agentId: string | null;
|
|
137
|
-
title: string | null;
|
|
138
138
|
activeSubAgentId: string;
|
|
139
139
|
lastContextResolution: string | null;
|
|
140
140
|
}>;
|
|
@@ -154,19 +154,19 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
154
154
|
conversationId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
156
|
id: string;
|
|
157
|
+
tenantId: string;
|
|
157
158
|
createdAt: string;
|
|
159
|
+
metadata: ConversationMetadata | null;
|
|
160
|
+
title: string | null;
|
|
158
161
|
updatedAt: string;
|
|
162
|
+
projectId: string;
|
|
163
|
+
agentId: string | null;
|
|
164
|
+
userId: string | null;
|
|
159
165
|
ref: {
|
|
160
|
-
type: "
|
|
166
|
+
type: "commit" | "tag" | "branch";
|
|
161
167
|
name: string;
|
|
162
168
|
hash: string;
|
|
163
169
|
} | null;
|
|
164
|
-
userId: string | null;
|
|
165
|
-
metadata: ConversationMetadata | null;
|
|
166
|
-
tenantId: string;
|
|
167
|
-
projectId: string;
|
|
168
|
-
agentId: string | null;
|
|
169
|
-
title: string | null;
|
|
170
170
|
activeSubAgentId: string;
|
|
171
171
|
lastContextResolution: string | null;
|
|
172
172
|
} | undefined>;
|
|
@@ -11,25 +11,25 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
13
|
id: string;
|
|
14
|
+
tenantId: string;
|
|
14
15
|
createdAt: string;
|
|
15
|
-
updatedAt: string;
|
|
16
16
|
metadata: MessageMetadata | null;
|
|
17
|
-
role: string;
|
|
18
|
-
tenantId: string;
|
|
19
|
-
projectId: string;
|
|
20
17
|
content: MessageContent;
|
|
21
|
-
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
projectId: string;
|
|
22
20
|
fromSubAgentId: string | null;
|
|
23
21
|
toSubAgentId: string | null;
|
|
24
22
|
fromExternalAgentId: string | null;
|
|
25
23
|
toExternalAgentId: string | null;
|
|
24
|
+
taskId: string | null;
|
|
25
|
+
a2aTaskId: string | null;
|
|
26
|
+
conversationId: string;
|
|
27
|
+
role: string;
|
|
26
28
|
fromTeamAgentId: string | null;
|
|
27
29
|
toTeamAgentId: string | null;
|
|
28
30
|
visibility: string;
|
|
29
31
|
messageType: string;
|
|
30
|
-
taskId: string | null;
|
|
31
32
|
parentMessageId: string | null;
|
|
32
|
-
a2aTaskId: string | null;
|
|
33
33
|
a2aSessionId: string | null;
|
|
34
34
|
} | undefined>;
|
|
35
35
|
declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -142,25 +142,25 @@ declare const getVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
142
142
|
}[]>;
|
|
143
143
|
declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageInsert) => Promise<{
|
|
144
144
|
id: string;
|
|
145
|
+
tenantId: string;
|
|
145
146
|
createdAt: string;
|
|
146
|
-
updatedAt: string;
|
|
147
147
|
metadata: MessageMetadata | null;
|
|
148
|
-
role: string;
|
|
149
|
-
tenantId: string;
|
|
150
|
-
projectId: string;
|
|
151
148
|
content: MessageContent;
|
|
152
|
-
|
|
149
|
+
updatedAt: string;
|
|
150
|
+
projectId: string;
|
|
153
151
|
fromSubAgentId: string | null;
|
|
154
152
|
toSubAgentId: string | null;
|
|
155
153
|
fromExternalAgentId: string | null;
|
|
156
154
|
toExternalAgentId: string | null;
|
|
155
|
+
taskId: string | null;
|
|
156
|
+
a2aTaskId: string | null;
|
|
157
|
+
conversationId: string;
|
|
158
|
+
role: string;
|
|
157
159
|
fromTeamAgentId: string | null;
|
|
158
160
|
toTeamAgentId: string | null;
|
|
159
161
|
visibility: string;
|
|
160
162
|
messageType: string;
|
|
161
|
-
taskId: string | null;
|
|
162
163
|
parentMessageId: string | null;
|
|
163
|
-
a2aTaskId: string | null;
|
|
164
164
|
a2aSessionId: string | null;
|
|
165
165
|
}>;
|
|
166
166
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -195,25 +195,25 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
195
195
|
messageId: string;
|
|
196
196
|
}) => Promise<{
|
|
197
197
|
id: string;
|
|
198
|
+
tenantId: string;
|
|
198
199
|
createdAt: string;
|
|
199
|
-
updatedAt: string;
|
|
200
200
|
metadata: MessageMetadata | null;
|
|
201
|
-
role: string;
|
|
202
|
-
tenantId: string;
|
|
203
|
-
projectId: string;
|
|
204
201
|
content: MessageContent;
|
|
205
|
-
|
|
202
|
+
updatedAt: string;
|
|
203
|
+
projectId: string;
|
|
206
204
|
fromSubAgentId: string | null;
|
|
207
205
|
toSubAgentId: string | null;
|
|
208
206
|
fromExternalAgentId: string | null;
|
|
209
207
|
toExternalAgentId: string | null;
|
|
208
|
+
taskId: string | null;
|
|
209
|
+
a2aTaskId: string | null;
|
|
210
|
+
conversationId: string;
|
|
211
|
+
role: string;
|
|
210
212
|
fromTeamAgentId: string | null;
|
|
211
213
|
toTeamAgentId: string | null;
|
|
212
214
|
visibility: string;
|
|
213
215
|
messageType: string;
|
|
214
|
-
taskId: string | null;
|
|
215
216
|
parentMessageId: string | null;
|
|
216
|
-
a2aTaskId: string | null;
|
|
217
217
|
a2aSessionId: string | null;
|
|
218
218
|
}>;
|
|
219
219
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -7,20 +7,20 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
|
|
|
7
7
|
//#region src/data-access/runtime/tasks.d.ts
|
|
8
8
|
declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
|
|
9
9
|
id: string;
|
|
10
|
+
tenantId: string;
|
|
10
11
|
createdAt: string;
|
|
11
|
-
updatedAt: string;
|
|
12
|
-
ref: {
|
|
13
|
-
type: "tag" | "commit" | "branch";
|
|
14
|
-
name: string;
|
|
15
|
-
hash: string;
|
|
16
|
-
} | null;
|
|
17
12
|
metadata: TaskMetadataConfig | null;
|
|
18
|
-
|
|
19
|
-
tenantId: string;
|
|
13
|
+
updatedAt: string;
|
|
20
14
|
projectId: string;
|
|
21
15
|
agentId: string;
|
|
22
16
|
subAgentId: string;
|
|
17
|
+
status: string;
|
|
23
18
|
contextId: string;
|
|
19
|
+
ref: {
|
|
20
|
+
type: "commit" | "tag" | "branch";
|
|
21
|
+
name: string;
|
|
22
|
+
hash: string;
|
|
23
|
+
} | null;
|
|
24
24
|
}>;
|
|
25
25
|
declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
26
26
|
id: string;
|
|
@@ -36,7 +36,7 @@ declare const updateTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
36
36
|
updatedAt: string;
|
|
37
37
|
contextId: string;
|
|
38
38
|
ref: {
|
|
39
|
-
type: "
|
|
39
|
+
type: "commit" | "tag" | "branch";
|
|
40
40
|
name: string;
|
|
41
41
|
hash: string;
|
|
42
42
|
} | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { userProfile } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
3
|
+
|
|
4
|
+
//#region src/data-access/runtime/userProfiles.d.ts
|
|
5
|
+
type UserProfile = typeof userProfile.$inferSelect;
|
|
6
|
+
type UpsertUserProfileData = {
|
|
7
|
+
timezone?: string | null;
|
|
8
|
+
attributes?: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
declare const getUserProfile: (db: AgentsRunDatabaseClient) => (userId: string) => Promise<UserProfile | null>;
|
|
11
|
+
declare const createUserProfileIfNotExists: (db: AgentsRunDatabaseClient) => (userId: string) => Promise<void>;
|
|
12
|
+
declare const upsertUserProfile: (db: AgentsRunDatabaseClient) => (userId: string, data: UpsertUserProfileData) => Promise<UserProfile>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { UpsertUserProfileData, UserProfile, createUserProfileIfNotExists, getUserProfile, upsertUserProfile };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { userProfile } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { generateId } from "../../utils/conversations.js";
|
|
3
|
+
import "../../utils/index.js";
|
|
4
|
+
import { eq } from "drizzle-orm";
|
|
5
|
+
|
|
6
|
+
//#region src/data-access/runtime/userProfiles.ts
|
|
7
|
+
const getUserProfile = (db) => async (userId) => {
|
|
8
|
+
return (await db.select().from(userProfile).where(eq(userProfile.userId, userId)).limit(1))[0] ?? null;
|
|
9
|
+
};
|
|
10
|
+
const createUserProfileIfNotExists = (db) => async (userId) => {
|
|
11
|
+
const id = generateId();
|
|
12
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
13
|
+
await db.insert(userProfile).values({
|
|
14
|
+
id,
|
|
15
|
+
userId,
|
|
16
|
+
timezone: null,
|
|
17
|
+
attributes: {},
|
|
18
|
+
createdAt: now,
|
|
19
|
+
updatedAt: now
|
|
20
|
+
}).onConflictDoNothing();
|
|
21
|
+
};
|
|
22
|
+
const upsertUserProfile = (db) => async (userId, data) => {
|
|
23
|
+
const id = generateId();
|
|
24
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
25
|
+
const result = await db.insert(userProfile).values({
|
|
26
|
+
id,
|
|
27
|
+
userId,
|
|
28
|
+
timezone: data.timezone ?? null,
|
|
29
|
+
attributes: data.attributes ?? {},
|
|
30
|
+
createdAt: now,
|
|
31
|
+
updatedAt: now
|
|
32
|
+
}).onConflictDoUpdate({
|
|
33
|
+
target: userProfile.userId,
|
|
34
|
+
set: {
|
|
35
|
+
...data.timezone !== void 0 && { timezone: data.timezone },
|
|
36
|
+
...data.attributes !== void 0 && { attributes: data.attributes },
|
|
37
|
+
updatedAt: now
|
|
38
|
+
}
|
|
39
|
+
}).returning();
|
|
40
|
+
if (!result[0]) throw new Error(`Failed to upsert user profile for userId: ${userId}`);
|
|
41
|
+
return result[0];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { createUserProfileIfNotExists, getUserProfile, upsertUserProfile };
|