@inkeep/agents-core 0.53.12 → 0.54.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/client-exports.d.ts +2 -2
- package/dist/client-exports.js +2 -2
- package/dist/data-access/index.d.ts +2 -2
- package/dist/data-access/index.js +3 -3
- package/dist/data-access/manage/agents.d.ts +36 -36
- package/dist/data-access/manage/agents.js +19 -1
- package/dist/data-access/manage/artifactComponents.d.ts +12 -12
- package/dist/data-access/manage/contextConfigs.d.ts +8 -8
- package/dist/data-access/manage/dataComponents.d.ts +6 -6
- package/dist/data-access/manage/functionTools.d.ts +14 -14
- package/dist/data-access/manage/skills.d.ts +15 -15
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +20 -20
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +24 -24
- package/dist/data-access/manage/tools.d.ts +21 -21
- package/dist/data-access/manage/tools.js +1 -1
- 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/cascade-delete.d.ts +2 -0
- package/dist/data-access/runtime/cascade-delete.js +19 -4
- package/dist/data-access/runtime/conversations.d.ts +27 -27
- package/dist/data-access/runtime/messages.d.ts +24 -24
- package/dist/data-access/runtime/tasks.d.ts +6 -6
- package/dist/data-access/runtime/workAppSlack.d.ts +8 -2
- package/dist/data-access/runtime/workAppSlack.js +63 -2
- package/dist/db/manage/manage-schema.d.ts +451 -451
- package/dist/db/runtime/runtime-schema.d.ts +352 -316
- package/dist/db/runtime/runtime-schema.js +12 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/middleware/no-auth.d.ts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/mcp-client.d.ts +2 -1
- package/dist/utils/mcp-client.js +20 -5
- 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 +1761 -673
- package/dist/validation/schemas.js +12 -2
- package/drizzle/runtime/0016_white_eddie_brock.sql +1 -0
- package/drizzle/runtime/0017_remarkable_starfox.sql +3 -0
- package/drizzle/runtime/0018_orange_union_jack.sql +6 -0
- package/drizzle/runtime/meta/0016_snapshot.json +3766 -0
- package/drizzle/runtime/meta/0017_snapshot.json +3785 -0
- package/drizzle/runtime/meta/0018_snapshot.json +3929 -0
- package/drizzle/runtime/meta/_journal.json +21 -0
- package/package.json +1 -1
|
@@ -16,20 +16,20 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
16
16
|
total: number;
|
|
17
17
|
}>;
|
|
18
18
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
19
|
+
id: string;
|
|
19
20
|
tenantId: string;
|
|
20
|
-
userId: string | null;
|
|
21
|
-
title: string | null;
|
|
22
21
|
projectId: string;
|
|
23
|
-
|
|
22
|
+
agentId: string | null;
|
|
23
|
+
title: string | null;
|
|
24
24
|
createdAt: string;
|
|
25
25
|
updatedAt: string;
|
|
26
|
+
metadata: ConversationMetadata | null;
|
|
26
27
|
ref: {
|
|
27
|
-
type: "
|
|
28
|
+
type: "tag" | "commit" | "branch";
|
|
28
29
|
name: string;
|
|
29
30
|
hash: string;
|
|
30
31
|
} | null;
|
|
31
|
-
|
|
32
|
-
agentId: string | null;
|
|
32
|
+
userId: 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: "tag" | "commit" | "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: "tag" | "commit" | "branch";
|
|
74
74
|
name: string;
|
|
75
75
|
hash: string;
|
|
76
76
|
} | null;
|
|
@@ -85,20 +85,20 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
85
85
|
scopes: ProjectScopeConfig;
|
|
86
86
|
conversationId: string;
|
|
87
87
|
}) => Promise<{
|
|
88
|
+
id: string;
|
|
88
89
|
tenantId: string;
|
|
89
|
-
userId: string | null;
|
|
90
|
-
title: string | null;
|
|
91
90
|
projectId: string;
|
|
92
|
-
|
|
91
|
+
agentId: string | null;
|
|
92
|
+
title: string | null;
|
|
93
93
|
createdAt: string;
|
|
94
94
|
updatedAt: string;
|
|
95
|
+
metadata: ConversationMetadata | null;
|
|
95
96
|
ref: {
|
|
96
|
-
type: "
|
|
97
|
+
type: "tag" | "commit" | "branch";
|
|
97
98
|
name: string;
|
|
98
99
|
hash: string;
|
|
99
100
|
} | null;
|
|
100
|
-
|
|
101
|
-
agentId: string | null;
|
|
101
|
+
userId: 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: "tag" | "commit" | "branch";
|
|
112
112
|
name: string;
|
|
113
113
|
hash: string;
|
|
114
114
|
};
|
|
@@ -121,20 +121,20 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
121
121
|
metadata?: ConversationMetadata | null | undefined;
|
|
122
122
|
contextConfigId?: string | undefined;
|
|
123
123
|
} | {
|
|
124
|
+
id: string;
|
|
124
125
|
tenantId: string;
|
|
125
|
-
userId: string | null;
|
|
126
|
-
title: string | null;
|
|
127
126
|
projectId: string;
|
|
128
|
-
|
|
127
|
+
agentId: string | null;
|
|
128
|
+
title: string | null;
|
|
129
129
|
createdAt: string;
|
|
130
130
|
updatedAt: string;
|
|
131
|
+
metadata: ConversationMetadata | null;
|
|
131
132
|
ref: {
|
|
132
|
-
type: "
|
|
133
|
+
type: "tag" | "commit" | "branch";
|
|
133
134
|
name: string;
|
|
134
135
|
hash: string;
|
|
135
136
|
} | null;
|
|
136
|
-
|
|
137
|
-
agentId: string | null;
|
|
137
|
+
userId: string | null;
|
|
138
138
|
activeSubAgentId: string;
|
|
139
139
|
lastContextResolution: string | null;
|
|
140
140
|
}>;
|
|
@@ -153,20 +153,20 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
153
153
|
scopes: ProjectScopeConfig;
|
|
154
154
|
conversationId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
|
+
id: string;
|
|
156
157
|
tenantId: string;
|
|
157
|
-
userId: string | null;
|
|
158
|
-
title: string | null;
|
|
159
158
|
projectId: string;
|
|
160
|
-
|
|
159
|
+
agentId: string | null;
|
|
160
|
+
title: string | null;
|
|
161
161
|
createdAt: string;
|
|
162
162
|
updatedAt: string;
|
|
163
|
+
metadata: ConversationMetadata | null;
|
|
163
164
|
ref: {
|
|
164
|
-
type: "
|
|
165
|
+
type: "tag" | "commit" | "branch";
|
|
165
166
|
name: string;
|
|
166
167
|
hash: string;
|
|
167
168
|
} | null;
|
|
168
|
-
|
|
169
|
-
agentId: string | null;
|
|
169
|
+
userId: string | null;
|
|
170
170
|
activeSubAgentId: string;
|
|
171
171
|
lastContextResolution: string | null;
|
|
172
172
|
} | undefined>;
|
|
@@ -10,26 +10,26 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
scopes: ProjectScopeConfig;
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
|
+
id: string;
|
|
13
14
|
tenantId: string;
|
|
14
|
-
content: MessageContent;
|
|
15
15
|
projectId: string;
|
|
16
|
-
fromSubAgentId: string | null;
|
|
17
|
-
toSubAgentId: string | null;
|
|
18
|
-
fromExternalAgentId: string | null;
|
|
19
|
-
toExternalAgentId: string | null;
|
|
20
|
-
taskId: string | null;
|
|
21
|
-
a2aTaskId: string | null;
|
|
22
|
-
id: string;
|
|
23
16
|
createdAt: string;
|
|
24
17
|
updatedAt: string;
|
|
25
18
|
metadata: MessageMetadata | null;
|
|
19
|
+
content: MessageContent;
|
|
26
20
|
role: string;
|
|
27
21
|
conversationId: string;
|
|
22
|
+
fromSubAgentId: string | null;
|
|
23
|
+
toSubAgentId: string | null;
|
|
24
|
+
fromExternalAgentId: string | null;
|
|
25
|
+
toExternalAgentId: string | null;
|
|
28
26
|
fromTeamAgentId: string | null;
|
|
29
27
|
toTeamAgentId: string | null;
|
|
30
28
|
visibility: string;
|
|
31
29
|
messageType: string;
|
|
30
|
+
taskId: string | null;
|
|
32
31
|
parentMessageId: string | null;
|
|
32
|
+
a2aTaskId: string | null;
|
|
33
33
|
a2aSessionId: string | null;
|
|
34
34
|
} | undefined>;
|
|
35
35
|
declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -141,26 +141,26 @@ declare const getVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
141
141
|
id: string;
|
|
142
142
|
}[]>;
|
|
143
143
|
declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageInsert) => Promise<{
|
|
144
|
+
id: string;
|
|
144
145
|
tenantId: string;
|
|
145
|
-
content: MessageContent;
|
|
146
146
|
projectId: string;
|
|
147
|
-
fromSubAgentId: string | null;
|
|
148
|
-
toSubAgentId: string | null;
|
|
149
|
-
fromExternalAgentId: string | null;
|
|
150
|
-
toExternalAgentId: string | null;
|
|
151
|
-
taskId: string | null;
|
|
152
|
-
a2aTaskId: string | null;
|
|
153
|
-
id: string;
|
|
154
147
|
createdAt: string;
|
|
155
148
|
updatedAt: string;
|
|
156
149
|
metadata: MessageMetadata | null;
|
|
150
|
+
content: MessageContent;
|
|
157
151
|
role: string;
|
|
158
152
|
conversationId: string;
|
|
153
|
+
fromSubAgentId: string | null;
|
|
154
|
+
toSubAgentId: string | null;
|
|
155
|
+
fromExternalAgentId: string | null;
|
|
156
|
+
toExternalAgentId: string | null;
|
|
159
157
|
fromTeamAgentId: string | null;
|
|
160
158
|
toTeamAgentId: string | null;
|
|
161
159
|
visibility: string;
|
|
162
160
|
messageType: string;
|
|
161
|
+
taskId: string | null;
|
|
163
162
|
parentMessageId: string | null;
|
|
163
|
+
a2aTaskId: string | null;
|
|
164
164
|
a2aSessionId: string | null;
|
|
165
165
|
}>;
|
|
166
166
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -194,26 +194,26 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
194
194
|
scopes: ProjectScopeConfig;
|
|
195
195
|
messageId: string;
|
|
196
196
|
}) => Promise<{
|
|
197
|
+
id: string;
|
|
197
198
|
tenantId: string;
|
|
198
|
-
content: MessageContent;
|
|
199
199
|
projectId: string;
|
|
200
|
-
fromSubAgentId: string | null;
|
|
201
|
-
toSubAgentId: string | null;
|
|
202
|
-
fromExternalAgentId: string | null;
|
|
203
|
-
toExternalAgentId: string | null;
|
|
204
|
-
taskId: string | null;
|
|
205
|
-
a2aTaskId: string | null;
|
|
206
|
-
id: string;
|
|
207
200
|
createdAt: string;
|
|
208
201
|
updatedAt: string;
|
|
209
202
|
metadata: MessageMetadata | null;
|
|
203
|
+
content: MessageContent;
|
|
210
204
|
role: string;
|
|
211
205
|
conversationId: string;
|
|
206
|
+
fromSubAgentId: string | null;
|
|
207
|
+
toSubAgentId: string | null;
|
|
208
|
+
fromExternalAgentId: string | null;
|
|
209
|
+
toExternalAgentId: string | null;
|
|
212
210
|
fromTeamAgentId: string | null;
|
|
213
211
|
toTeamAgentId: string | null;
|
|
214
212
|
visibility: string;
|
|
215
213
|
messageType: string;
|
|
214
|
+
taskId: string | null;
|
|
216
215
|
parentMessageId: string | null;
|
|
216
|
+
a2aTaskId: string | null;
|
|
217
217
|
a2aSessionId: string | null;
|
|
218
218
|
}>;
|
|
219
219
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -6,20 +6,20 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
|
|
|
6
6
|
|
|
7
7
|
//#region src/data-access/runtime/tasks.d.ts
|
|
8
8
|
declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
|
|
9
|
+
id: string;
|
|
9
10
|
tenantId: string;
|
|
10
11
|
projectId: string;
|
|
11
|
-
|
|
12
|
-
id: string;
|
|
12
|
+
agentId: string;
|
|
13
13
|
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
|
+
metadata: TaskMetadataConfig | null;
|
|
15
16
|
ref: {
|
|
16
|
-
type: "
|
|
17
|
+
type: "tag" | "commit" | "branch";
|
|
17
18
|
name: string;
|
|
18
19
|
hash: string;
|
|
19
20
|
} | null;
|
|
20
|
-
metadata: TaskMetadataConfig | null;
|
|
21
21
|
status: string;
|
|
22
|
-
|
|
22
|
+
subAgentId: string;
|
|
23
23
|
contextId: string;
|
|
24
24
|
}>;
|
|
25
25
|
declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -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: "tag" | "commit" | "branch";
|
|
40
40
|
name: string;
|
|
41
41
|
hash: string;
|
|
42
42
|
} | null;
|
|
@@ -25,7 +25,7 @@ declare const findWorkAppSlackWorkspaceBySlackTeamId: (db: AgentsRunDatabaseClie
|
|
|
25
25
|
*/
|
|
26
26
|
declare const findWorkAppSlackWorkspaceByNangoConnectionId: (db: AgentsRunDatabaseClient) => (nangoConnectionId: string) => Promise<WorkAppSlackWorkspaceSelect | null>;
|
|
27
27
|
declare const listWorkAppSlackWorkspacesByTenant: (db: AgentsRunDatabaseClient) => (tenantId: string) => Promise<WorkAppSlackWorkspaceSelect[]>;
|
|
28
|
-
declare const updateWorkAppSlackWorkspace: (db: AgentsRunDatabaseClient) => (id: string, data: Partial<Pick<WorkAppSlackWorkspaceInsert, "status" | "slackTeamName" | "shouldAllowJoinFromWorkspace">>) => Promise<WorkAppSlackWorkspaceSelect | null>;
|
|
28
|
+
declare const updateWorkAppSlackWorkspace: (db: AgentsRunDatabaseClient) => (id: string, data: Partial<Pick<WorkAppSlackWorkspaceInsert, "status" | "slackTeamName" | "shouldAllowJoinFromWorkspace" | "defaultAgentId" | "defaultProjectId" | "defaultGrantAccessToMembers">>) => Promise<WorkAppSlackWorkspaceSelect | null>;
|
|
29
29
|
declare const deleteWorkAppSlackWorkspace: (db: AgentsRunDatabaseClient) => (id: string) => Promise<boolean>;
|
|
30
30
|
declare const deleteWorkAppSlackWorkspaceByNangoConnectionId: (db: AgentsRunDatabaseClient) => (nangoConnectionId: string) => Promise<boolean>;
|
|
31
31
|
declare const findWorkAppSlackUserMapping: (db: AgentsRunDatabaseClient) => (tenantId: string, slackUserId: string, slackTeamId: string, clientId?: string) => Promise<WorkAppSlackUserMappingSelect | null>;
|
|
@@ -51,5 +51,11 @@ declare const listWorkAppSlackChannelAgentConfigsByTeam: (db: AgentsRunDatabaseC
|
|
|
51
51
|
declare const upsertWorkAppSlackChannelAgentConfig: (db: AgentsRunDatabaseClient) => (data: Omit<WorkAppSlackChannelAgentConfigInsert, "id" | "createdAt" | "updatedAt">) => Promise<WorkAppSlackChannelAgentConfigSelect>;
|
|
52
52
|
declare const deleteWorkAppSlackChannelAgentConfig: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string, slackChannelId: string) => Promise<boolean>;
|
|
53
53
|
declare const deleteAllWorkAppSlackChannelAgentConfigsByTeam: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string) => Promise<number>;
|
|
54
|
+
declare const deleteWorkAppSlackChannelAgentConfigsByAgent: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string, agentId: string) => Promise<number>;
|
|
55
|
+
declare const deleteWorkAppSlackChannelAgentConfigsByProject: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string) => Promise<number>;
|
|
56
|
+
declare const clearWorkspaceDefaultsByAgent: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string, agentId: string) => Promise<number>;
|
|
57
|
+
declare const clearWorkspaceDefaultsByProject: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string) => Promise<number>;
|
|
58
|
+
declare function clearDevConfigWorkspaceDefaultsByAgent(projectId: string, agentId: string): void;
|
|
59
|
+
declare function clearDevConfigWorkspaceDefaultsByProject(projectId: string): void;
|
|
54
60
|
//#endregion
|
|
55
|
-
export { WorkAppSlackChannelAgentConfigInsert, WorkAppSlackChannelAgentConfigSelect, WorkAppSlackUserMappingInsert, WorkAppSlackUserMappingSelect, WorkAppSlackWorkspaceInsert, WorkAppSlackWorkspaceSelect, createWorkAppSlackChannelAgentConfig, createWorkAppSlackUserMapping, createWorkAppSlackWorkspace, deleteAllWorkAppSlackChannelAgentConfigsByTeam, deleteAllWorkAppSlackUserMappingsByTeam, deleteWorkAppSlackChannelAgentConfig, deleteWorkAppSlackUserMapping, deleteWorkAppSlackWorkspace, deleteWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackChannelAgentConfig, findWorkAppSlackUserMapping, findWorkAppSlackUserMappingByInkeepUserId, findWorkAppSlackUserMappingBySlackUser, findWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackWorkspaceBySlackTeamId, findWorkAppSlackWorkspaceByTeamId, listWorkAppSlackChannelAgentConfigsByTeam, listWorkAppSlackUserMappingsByTeam, listWorkAppSlackWorkspacesByTenant, updateWorkAppSlackWorkspace, upsertWorkAppSlackChannelAgentConfig };
|
|
61
|
+
export { WorkAppSlackChannelAgentConfigInsert, WorkAppSlackChannelAgentConfigSelect, WorkAppSlackUserMappingInsert, WorkAppSlackUserMappingSelect, WorkAppSlackWorkspaceInsert, WorkAppSlackWorkspaceSelect, clearDevConfigWorkspaceDefaultsByAgent, clearDevConfigWorkspaceDefaultsByProject, clearWorkspaceDefaultsByAgent, clearWorkspaceDefaultsByProject, createWorkAppSlackChannelAgentConfig, createWorkAppSlackUserMapping, createWorkAppSlackWorkspace, deleteAllWorkAppSlackChannelAgentConfigsByTeam, deleteAllWorkAppSlackUserMappingsByTeam, deleteWorkAppSlackChannelAgentConfig, deleteWorkAppSlackChannelAgentConfigsByAgent, deleteWorkAppSlackChannelAgentConfigsByProject, deleteWorkAppSlackUserMapping, deleteWorkAppSlackWorkspace, deleteWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackChannelAgentConfig, findWorkAppSlackUserMapping, findWorkAppSlackUserMappingByInkeepUserId, findWorkAppSlackUserMappingBySlackUser, findWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackWorkspaceBySlackTeamId, findWorkAppSlackWorkspaceByTeamId, listWorkAppSlackChannelAgentConfigsByTeam, listWorkAppSlackUserMappingsByTeam, listWorkAppSlackWorkspacesByTenant, updateWorkAppSlackWorkspace, upsertWorkAppSlackChannelAgentConfig };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { workAppSlackChannelAgentConfigs, workAppSlackUserMappings, workAppSlackWorkspaces } from "../../db/runtime/runtime-schema.js";
|
|
2
2
|
import { and, eq } from "drizzle-orm";
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
3
5
|
import { nanoid } from "nanoid";
|
|
4
6
|
|
|
5
7
|
//#region src/data-access/runtime/workAppSlack.ts
|
|
@@ -125,7 +127,6 @@ const upsertWorkAppSlackChannelAgentConfig = (db) => async (data) => {
|
|
|
125
127
|
set: {
|
|
126
128
|
projectId: data.projectId,
|
|
127
129
|
agentId: data.agentId,
|
|
128
|
-
agentName: data.agentName,
|
|
129
130
|
slackChannelName: data.slackChannelName,
|
|
130
131
|
slackChannelType: data.slackChannelType,
|
|
131
132
|
enabled: data.enabled,
|
|
@@ -142,6 +143,66 @@ const deleteWorkAppSlackChannelAgentConfig = (db) => async (tenantId, slackTeamI
|
|
|
142
143
|
const deleteAllWorkAppSlackChannelAgentConfigsByTeam = (db) => async (tenantId, slackTeamId) => {
|
|
143
144
|
return (await db.delete(workAppSlackChannelAgentConfigs).where(and(eq(workAppSlackChannelAgentConfigs.tenantId, tenantId), eq(workAppSlackChannelAgentConfigs.slackTeamId, slackTeamId))).returning()).length;
|
|
144
145
|
};
|
|
146
|
+
const deleteWorkAppSlackChannelAgentConfigsByAgent = (db) => async (tenantId, projectId, agentId) => {
|
|
147
|
+
return (await db.delete(workAppSlackChannelAgentConfigs).where(and(eq(workAppSlackChannelAgentConfigs.tenantId, tenantId), eq(workAppSlackChannelAgentConfigs.projectId, projectId), eq(workAppSlackChannelAgentConfigs.agentId, agentId))).returning()).length;
|
|
148
|
+
};
|
|
149
|
+
const deleteWorkAppSlackChannelAgentConfigsByProject = (db) => async (tenantId, projectId) => {
|
|
150
|
+
return (await db.delete(workAppSlackChannelAgentConfigs).where(and(eq(workAppSlackChannelAgentConfigs.tenantId, tenantId), eq(workAppSlackChannelAgentConfigs.projectId, projectId))).returning()).length;
|
|
151
|
+
};
|
|
152
|
+
const clearWorkspaceDefaultsByAgent = (db) => async (tenantId, projectId, agentId) => {
|
|
153
|
+
return (await db.update(workAppSlackWorkspaces).set({
|
|
154
|
+
defaultAgentId: null,
|
|
155
|
+
defaultProjectId: null,
|
|
156
|
+
defaultGrantAccessToMembers: null,
|
|
157
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
158
|
+
}).where(and(eq(workAppSlackWorkspaces.tenantId, tenantId), eq(workAppSlackWorkspaces.defaultProjectId, projectId), eq(workAppSlackWorkspaces.defaultAgentId, agentId))).returning()).length;
|
|
159
|
+
};
|
|
160
|
+
const clearWorkspaceDefaultsByProject = (db) => async (tenantId, projectId) => {
|
|
161
|
+
return (await db.update(workAppSlackWorkspaces).set({
|
|
162
|
+
defaultAgentId: null,
|
|
163
|
+
defaultProjectId: null,
|
|
164
|
+
defaultGrantAccessToMembers: null,
|
|
165
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
166
|
+
}).where(and(eq(workAppSlackWorkspaces.tenantId, tenantId), eq(workAppSlackWorkspaces.defaultProjectId, projectId))).returning()).length;
|
|
167
|
+
};
|
|
168
|
+
const DEV_CONFIG_FILENAME = ".slack-dev.json";
|
|
169
|
+
function findSlackDevConfigPath() {
|
|
170
|
+
if (process.env.ENVIRONMENT !== "development") return null;
|
|
171
|
+
let dir = process.cwd();
|
|
172
|
+
while (true) {
|
|
173
|
+
const candidate = join(dir, DEV_CONFIG_FILENAME);
|
|
174
|
+
if (existsSync(candidate)) return candidate;
|
|
175
|
+
const parent = dirname(dir);
|
|
176
|
+
if (parent === dir) break;
|
|
177
|
+
dir = parent;
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
function clearDevConfigWorkspaceDefaultsByAgent(projectId, agentId) {
|
|
182
|
+
const configPath = findSlackDevConfigPath();
|
|
183
|
+
if (!configPath) return;
|
|
184
|
+
try {
|
|
185
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
186
|
+
if (!config?.metadata?.default_agent) return;
|
|
187
|
+
const defaultAgent = JSON.parse(config.metadata.default_agent);
|
|
188
|
+
if (defaultAgent.agentId === agentId && defaultAgent.projectId === projectId) {
|
|
189
|
+
config.metadata.default_agent = "";
|
|
190
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
191
|
+
}
|
|
192
|
+
} catch {}
|
|
193
|
+
}
|
|
194
|
+
function clearDevConfigWorkspaceDefaultsByProject(projectId) {
|
|
195
|
+
const configPath = findSlackDevConfigPath();
|
|
196
|
+
if (!configPath) return;
|
|
197
|
+
try {
|
|
198
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
199
|
+
if (!config?.metadata?.default_agent) return;
|
|
200
|
+
if (JSON.parse(config.metadata.default_agent).projectId === projectId) {
|
|
201
|
+
config.metadata.default_agent = "";
|
|
202
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
203
|
+
}
|
|
204
|
+
} catch {}
|
|
205
|
+
}
|
|
145
206
|
|
|
146
207
|
//#endregion
|
|
147
|
-
export { createWorkAppSlackChannelAgentConfig, createWorkAppSlackUserMapping, createWorkAppSlackWorkspace, deleteAllWorkAppSlackChannelAgentConfigsByTeam, deleteAllWorkAppSlackUserMappingsByTeam, deleteWorkAppSlackChannelAgentConfig, deleteWorkAppSlackUserMapping, deleteWorkAppSlackWorkspace, deleteWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackChannelAgentConfig, findWorkAppSlackUserMapping, findWorkAppSlackUserMappingByInkeepUserId, findWorkAppSlackUserMappingBySlackUser, findWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackWorkspaceBySlackTeamId, findWorkAppSlackWorkspaceByTeamId, listWorkAppSlackChannelAgentConfigsByTeam, listWorkAppSlackUserMappingsByTeam, listWorkAppSlackWorkspacesByTenant, updateWorkAppSlackWorkspace, upsertWorkAppSlackChannelAgentConfig };
|
|
208
|
+
export { clearDevConfigWorkspaceDefaultsByAgent, clearDevConfigWorkspaceDefaultsByProject, clearWorkspaceDefaultsByAgent, clearWorkspaceDefaultsByProject, createWorkAppSlackChannelAgentConfig, createWorkAppSlackUserMapping, createWorkAppSlackWorkspace, deleteAllWorkAppSlackChannelAgentConfigsByTeam, deleteAllWorkAppSlackUserMappingsByTeam, deleteWorkAppSlackChannelAgentConfig, deleteWorkAppSlackChannelAgentConfigsByAgent, deleteWorkAppSlackChannelAgentConfigsByProject, deleteWorkAppSlackUserMapping, deleteWorkAppSlackWorkspace, deleteWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackChannelAgentConfig, findWorkAppSlackUserMapping, findWorkAppSlackUserMappingByInkeepUserId, findWorkAppSlackUserMappingBySlackUser, findWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackWorkspaceBySlackTeamId, findWorkAppSlackWorkspaceByTeamId, listWorkAppSlackChannelAgentConfigsByTeam, listWorkAppSlackUserMappingsByTeam, listWorkAppSlackWorkspacesByTenant, updateWorkAppSlackWorkspace, upsertWorkAppSlackChannelAgentConfig };
|