@inkeep/agents-core 0.58.13 → 0.58.14
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 +107 -107
- package/dist/auth/auth-validation-schemas.d.ts +152 -152
- package/dist/auth/auth.d.ts +9 -9
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/data-access/index.d.ts +3 -1
- package/dist/data-access/index.js +3 -1
- package/dist/data-access/manage/agents.d.ts +26 -26
- package/dist/data-access/manage/artifactComponents.d.ts +12 -12
- package/dist/data-access/manage/audit-queries.d.ts +29 -0
- package/dist/data-access/manage/audit-queries.js +29 -0
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +6 -6
- package/dist/data-access/manage/functionTools.d.ts +16 -16
- package/dist/data-access/manage/skills.d.ts +14 -14
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +28 -28
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgents.d.ts +18 -18
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/apps.d.ts +8 -8
- package/dist/data-access/runtime/audit-queries.d.ts +41 -0
- package/dist/data-access/runtime/audit-queries.js +37 -0
- package/dist/data-access/runtime/conversations.d.ts +31 -31
- package/dist/data-access/runtime/messages.d.ts +12 -12
- package/dist/data-access/runtime/tasks.d.ts +9 -9
- package/dist/data-reconciliation/audit.d.ts +6 -0
- package/dist/data-reconciliation/audit.js +37 -0
- package/dist/data-reconciliation/index.d.ts +4 -0
- package/dist/data-reconciliation/index.js +5 -0
- package/dist/data-reconciliation/reconcile.d.ts +6 -0
- package/dist/data-reconciliation/reconcile.js +58 -0
- package/dist/data-reconciliation/types.d.ts +116 -0
- package/dist/data-reconciliation/types.js +7 -0
- package/dist/db/manage/manage-schema.d.ts +453 -453
- package/dist/db/runtime/runtime-schema.d.ts +6 -6
- package/dist/index.d.ts +7 -1
- package/dist/index.js +6 -1
- package/dist/setup/setup.d.ts +1 -0
- package/dist/setup/setup.js +25 -8
- package/dist/utils/error.d.ts +51 -51
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas.d.ts +2014 -2017
- package/dist/validation/schemas.js +5 -1
- package/package.json +1 -1
|
@@ -10,30 +10,30 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
12
|
name: string | null;
|
|
13
|
-
tenantId: string;
|
|
14
|
-
projectId: string;
|
|
15
|
-
agentId: string;
|
|
16
13
|
createdAt: string;
|
|
17
14
|
updatedAt: string;
|
|
15
|
+
expiresAt: string | null;
|
|
16
|
+
projectId: string;
|
|
17
|
+
tenantId: string;
|
|
18
|
+
agentId: string;
|
|
18
19
|
publicId: string;
|
|
19
20
|
keyHash: string;
|
|
20
21
|
keyPrefix: string;
|
|
21
22
|
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
|
name: string | null;
|
|
27
|
-
tenantId: string;
|
|
28
|
-
projectId: string;
|
|
29
|
-
agentId: string;
|
|
30
27
|
createdAt: string;
|
|
31
28
|
updatedAt: string;
|
|
29
|
+
expiresAt: string | null;
|
|
30
|
+
projectId: string;
|
|
31
|
+
tenantId: string;
|
|
32
|
+
agentId: string;
|
|
32
33
|
publicId: string;
|
|
33
34
|
keyHash: string;
|
|
34
35
|
keyPrefix: string;
|
|
35
36
|
lastUsedAt: string | null;
|
|
36
|
-
expiresAt: string | null;
|
|
37
37
|
} | undefined>;
|
|
38
38
|
declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
@@ -41,16 +41,16 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
41
41
|
}) => Promise<{
|
|
42
42
|
id: string;
|
|
43
43
|
name: string | null;
|
|
44
|
-
tenantId: string;
|
|
45
|
-
projectId: string;
|
|
46
|
-
agentId: string;
|
|
47
44
|
createdAt: string;
|
|
48
45
|
updatedAt: string;
|
|
46
|
+
expiresAt: string | null;
|
|
47
|
+
projectId: string;
|
|
48
|
+
tenantId: string;
|
|
49
|
+
agentId: string;
|
|
49
50
|
publicId: string;
|
|
50
51
|
keyHash: string;
|
|
51
52
|
keyPrefix: string;
|
|
52
53
|
lastUsedAt: string | null;
|
|
53
|
-
expiresAt: string | null;
|
|
54
54
|
}[]>;
|
|
55
55
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
@@ -68,16 +68,16 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
69
|
id: string;
|
|
70
70
|
name: string | null;
|
|
71
|
-
tenantId: string;
|
|
72
|
-
projectId: string;
|
|
73
|
-
agentId: string;
|
|
74
71
|
createdAt: string;
|
|
75
72
|
updatedAt: string;
|
|
73
|
+
expiresAt: string | null;
|
|
74
|
+
projectId: string;
|
|
75
|
+
tenantId: string;
|
|
76
|
+
agentId: string;
|
|
76
77
|
publicId: string;
|
|
77
78
|
keyHash: string;
|
|
78
79
|
keyPrefix: string;
|
|
79
80
|
lastUsedAt: string | null;
|
|
80
|
-
expiresAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -5,14 +5,14 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
5
5
|
|
|
6
6
|
//#region src/data-access/runtime/apps.d.ts
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
|
+
type: AppType;
|
|
8
9
|
id: string;
|
|
9
10
|
name: string;
|
|
10
|
-
description: string | null;
|
|
11
|
-
tenantId: string | null;
|
|
12
|
-
projectId: string | null;
|
|
13
|
-
type: AppType;
|
|
14
11
|
createdAt: string;
|
|
15
12
|
updatedAt: string;
|
|
13
|
+
description: string | null;
|
|
14
|
+
projectId: string | null;
|
|
15
|
+
tenantId: string | null;
|
|
16
16
|
enabled: boolean;
|
|
17
17
|
config: {
|
|
18
18
|
type: "web_client";
|
|
@@ -48,14 +48,14 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
48
48
|
};
|
|
49
49
|
}>;
|
|
50
50
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
51
|
+
type: AppType;
|
|
51
52
|
id: string;
|
|
52
53
|
name: string;
|
|
53
|
-
description: string | null;
|
|
54
|
-
tenantId: string | null;
|
|
55
|
-
projectId: string | null;
|
|
56
|
-
type: AppType;
|
|
57
54
|
createdAt: string;
|
|
58
55
|
updatedAt: string;
|
|
56
|
+
description: string | null;
|
|
57
|
+
projectId: string | null;
|
|
58
|
+
tenantId: string | null;
|
|
59
59
|
enabled: boolean;
|
|
60
60
|
config: {
|
|
61
61
|
type: "web_client";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
2
|
+
import "../../types/utility.js";
|
|
3
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
4
|
+
|
|
5
|
+
//#region src/data-access/runtime/audit-queries.d.ts
|
|
6
|
+
declare const listGitHubToolAccessByProject: (db: AgentsRunDatabaseClient) => (params: {
|
|
7
|
+
scopes: ProjectScopeConfig;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
id: string;
|
|
10
|
+
toolId: string;
|
|
11
|
+
}[]>;
|
|
12
|
+
declare const listGitHubToolAccessModeByProject: (db: AgentsRunDatabaseClient) => (params: {
|
|
13
|
+
scopes: ProjectScopeConfig;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
toolId: string;
|
|
16
|
+
}[]>;
|
|
17
|
+
declare const listSlackToolAccessConfigByProject: (db: AgentsRunDatabaseClient) => (params: {
|
|
18
|
+
scopes: ProjectScopeConfig;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
toolId: string;
|
|
21
|
+
}[]>;
|
|
22
|
+
declare const listContextCacheByProject: (db: AgentsRunDatabaseClient) => (params: {
|
|
23
|
+
scopes: ProjectScopeConfig;
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
id: string;
|
|
26
|
+
contextConfigId: string;
|
|
27
|
+
}[]>;
|
|
28
|
+
declare const listApiKeysByProject: (db: AgentsRunDatabaseClient) => (params: {
|
|
29
|
+
scopes: ProjectScopeConfig;
|
|
30
|
+
}) => Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
agentId: string;
|
|
33
|
+
}[]>;
|
|
34
|
+
declare const listSlackChannelAgentConfigsByProject: (db: AgentsRunDatabaseClient) => (params: {
|
|
35
|
+
scopes: ProjectScopeConfig;
|
|
36
|
+
}) => Promise<{
|
|
37
|
+
id: string;
|
|
38
|
+
agentId: string;
|
|
39
|
+
}[]>;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { listApiKeysByProject, listContextCacheByProject, listGitHubToolAccessByProject, listGitHubToolAccessModeByProject, listSlackChannelAgentConfigsByProject, listSlackToolAccessConfigByProject };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { apiKeys, contextCache, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppSlackChannelAgentConfigs, workAppSlackMcpToolAccessConfig } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { and, eq } from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
//#region src/data-access/runtime/audit-queries.ts
|
|
5
|
+
const listGitHubToolAccessByProject = (db) => async (params) => {
|
|
6
|
+
return db.select({
|
|
7
|
+
id: workAppGitHubMcpToolRepositoryAccess.id,
|
|
8
|
+
toolId: workAppGitHubMcpToolRepositoryAccess.toolId
|
|
9
|
+
}).from(workAppGitHubMcpToolRepositoryAccess).where(and(eq(workAppGitHubMcpToolRepositoryAccess.tenantId, params.scopes.tenantId), eq(workAppGitHubMcpToolRepositoryAccess.projectId, params.scopes.projectId)));
|
|
10
|
+
};
|
|
11
|
+
const listGitHubToolAccessModeByProject = (db) => async (params) => {
|
|
12
|
+
return db.select({ toolId: workAppGitHubMcpToolAccessMode.toolId }).from(workAppGitHubMcpToolAccessMode).where(and(eq(workAppGitHubMcpToolAccessMode.tenantId, params.scopes.tenantId), eq(workAppGitHubMcpToolAccessMode.projectId, params.scopes.projectId)));
|
|
13
|
+
};
|
|
14
|
+
const listSlackToolAccessConfigByProject = (db) => async (params) => {
|
|
15
|
+
return db.select({ toolId: workAppSlackMcpToolAccessConfig.toolId }).from(workAppSlackMcpToolAccessConfig).where(and(eq(workAppSlackMcpToolAccessConfig.tenantId, params.scopes.tenantId), eq(workAppSlackMcpToolAccessConfig.projectId, params.scopes.projectId)));
|
|
16
|
+
};
|
|
17
|
+
const listContextCacheByProject = (db) => async (params) => {
|
|
18
|
+
return db.select({
|
|
19
|
+
id: contextCache.id,
|
|
20
|
+
contextConfigId: contextCache.contextConfigId
|
|
21
|
+
}).from(contextCache).where(and(eq(contextCache.tenantId, params.scopes.tenantId), eq(contextCache.projectId, params.scopes.projectId)));
|
|
22
|
+
};
|
|
23
|
+
const listApiKeysByProject = (db) => async (params) => {
|
|
24
|
+
return db.select({
|
|
25
|
+
id: apiKeys.id,
|
|
26
|
+
agentId: apiKeys.agentId
|
|
27
|
+
}).from(apiKeys).where(and(eq(apiKeys.tenantId, params.scopes.tenantId), eq(apiKeys.projectId, params.scopes.projectId)));
|
|
28
|
+
};
|
|
29
|
+
const listSlackChannelAgentConfigsByProject = (db) => async (params) => {
|
|
30
|
+
return db.select({
|
|
31
|
+
id: workAppSlackChannelAgentConfigs.id,
|
|
32
|
+
agentId: workAppSlackChannelAgentConfigs.agentId
|
|
33
|
+
}).from(workAppSlackChannelAgentConfigs).where(and(eq(workAppSlackChannelAgentConfigs.tenantId, params.scopes.tenantId), eq(workAppSlackChannelAgentConfigs.projectId, params.scopes.projectId)));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { listApiKeysByProject, listContextCacheByProject, listGitHubToolAccessByProject, listGitHubToolAccessModeByProject, listSlackChannelAgentConfigsByProject, listSlackToolAccessConfigByProject };
|
|
@@ -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;
|
|
21
|
-
projectId: string;
|
|
22
|
-
agentId: string | null;
|
|
23
|
-
title: string | null;
|
|
24
20
|
createdAt: string;
|
|
25
21
|
updatedAt: string;
|
|
26
|
-
metadata: ConversationMetadata | null;
|
|
27
|
-
userId: string | null;
|
|
28
22
|
ref: {
|
|
29
|
-
type: "
|
|
23
|
+
type: "tag" | "commit" | "branch";
|
|
30
24
|
name: string;
|
|
31
25
|
hash: string;
|
|
32
26
|
} | null;
|
|
27
|
+
userId: string | null;
|
|
28
|
+
metadata: ConversationMetadata | null;
|
|
29
|
+
title: string | null;
|
|
30
|
+
projectId: string;
|
|
31
|
+
tenantId: string;
|
|
32
|
+
agentId: 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;
|
|
@@ -86,19 +86,19 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
86
86
|
conversationId: string;
|
|
87
87
|
}) => Promise<{
|
|
88
88
|
id: string;
|
|
89
|
-
tenantId: string;
|
|
90
|
-
projectId: string;
|
|
91
|
-
agentId: string | null;
|
|
92
|
-
title: string | null;
|
|
93
89
|
createdAt: string;
|
|
94
90
|
updatedAt: string;
|
|
95
|
-
metadata: ConversationMetadata | null;
|
|
96
|
-
userId: string | null;
|
|
97
91
|
ref: {
|
|
98
|
-
type: "
|
|
92
|
+
type: "tag" | "commit" | "branch";
|
|
99
93
|
name: string;
|
|
100
94
|
hash: string;
|
|
101
95
|
} | null;
|
|
96
|
+
userId: string | null;
|
|
97
|
+
metadata: ConversationMetadata | null;
|
|
98
|
+
title: string | null;
|
|
99
|
+
projectId: string;
|
|
100
|
+
tenantId: string;
|
|
101
|
+
agentId: 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
|
};
|
|
@@ -122,19 +122,19 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
122
122
|
contextConfigId?: string | undefined;
|
|
123
123
|
} | {
|
|
124
124
|
id: string;
|
|
125
|
-
tenantId: string;
|
|
126
|
-
projectId: string;
|
|
127
|
-
agentId: string | null;
|
|
128
|
-
title: string | null;
|
|
129
125
|
createdAt: string;
|
|
130
126
|
updatedAt: string;
|
|
131
|
-
metadata: ConversationMetadata | null;
|
|
132
|
-
userId: string | null;
|
|
133
127
|
ref: {
|
|
134
|
-
type: "
|
|
128
|
+
type: "tag" | "commit" | "branch";
|
|
135
129
|
name: string;
|
|
136
130
|
hash: string;
|
|
137
131
|
} | null;
|
|
132
|
+
userId: string | null;
|
|
133
|
+
metadata: ConversationMetadata | null;
|
|
134
|
+
title: string | null;
|
|
135
|
+
projectId: string;
|
|
136
|
+
tenantId: string;
|
|
137
|
+
agentId: 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;
|
|
158
|
-
projectId: string;
|
|
159
|
-
agentId: string | null;
|
|
160
|
-
title: string | null;
|
|
161
157
|
createdAt: string;
|
|
162
158
|
updatedAt: string;
|
|
163
|
-
metadata: ConversationMetadata | null;
|
|
164
|
-
userId: string | null;
|
|
165
159
|
ref: {
|
|
166
|
-
type: "
|
|
160
|
+
type: "tag" | "commit" | "branch";
|
|
167
161
|
name: string;
|
|
168
162
|
hash: string;
|
|
169
163
|
} | null;
|
|
164
|
+
userId: string | null;
|
|
165
|
+
metadata: ConversationMetadata | null;
|
|
166
|
+
title: string | null;
|
|
167
|
+
projectId: string;
|
|
168
|
+
tenantId: string;
|
|
169
|
+
agentId: string | null;
|
|
170
170
|
activeSubAgentId: string;
|
|
171
171
|
lastContextResolution: string | null;
|
|
172
172
|
} | undefined>;
|
|
@@ -11,20 +11,20 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
13
|
id: string;
|
|
14
|
-
tenantId: string;
|
|
15
|
-
projectId: string;
|
|
16
14
|
createdAt: string;
|
|
17
15
|
updatedAt: string;
|
|
18
16
|
metadata: MessageMetadata | null;
|
|
19
|
-
|
|
17
|
+
role: string;
|
|
20
18
|
fromSubAgentId: string | null;
|
|
21
19
|
toSubAgentId: string | null;
|
|
22
20
|
fromExternalAgentId: string | null;
|
|
23
21
|
toExternalAgentId: string | null;
|
|
24
22
|
taskId: string | null;
|
|
25
23
|
a2aTaskId: string | null;
|
|
24
|
+
projectId: string;
|
|
25
|
+
tenantId: string;
|
|
26
|
+
content: MessageContent;
|
|
26
27
|
conversationId: string;
|
|
27
|
-
role: string;
|
|
28
28
|
fromTeamAgentId: string | null;
|
|
29
29
|
toTeamAgentId: string | null;
|
|
30
30
|
visibility: string;
|
|
@@ -142,20 +142,20 @@ 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;
|
|
146
|
-
projectId: string;
|
|
147
145
|
createdAt: string;
|
|
148
146
|
updatedAt: string;
|
|
149
147
|
metadata: MessageMetadata | null;
|
|
150
|
-
|
|
148
|
+
role: string;
|
|
151
149
|
fromSubAgentId: string | null;
|
|
152
150
|
toSubAgentId: string | null;
|
|
153
151
|
fromExternalAgentId: string | null;
|
|
154
152
|
toExternalAgentId: string | null;
|
|
155
153
|
taskId: string | null;
|
|
156
154
|
a2aTaskId: string | null;
|
|
155
|
+
projectId: string;
|
|
156
|
+
tenantId: string;
|
|
157
|
+
content: MessageContent;
|
|
157
158
|
conversationId: string;
|
|
158
|
-
role: string;
|
|
159
159
|
fromTeamAgentId: string | null;
|
|
160
160
|
toTeamAgentId: string | null;
|
|
161
161
|
visibility: string;
|
|
@@ -195,20 +195,20 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
195
195
|
messageId: string;
|
|
196
196
|
}) => Promise<{
|
|
197
197
|
id: string;
|
|
198
|
-
tenantId: string;
|
|
199
|
-
projectId: string;
|
|
200
198
|
createdAt: string;
|
|
201
199
|
updatedAt: string;
|
|
202
200
|
metadata: MessageMetadata | null;
|
|
203
|
-
|
|
201
|
+
role: string;
|
|
204
202
|
fromSubAgentId: string | null;
|
|
205
203
|
toSubAgentId: string | null;
|
|
206
204
|
fromExternalAgentId: string | null;
|
|
207
205
|
toExternalAgentId: string | null;
|
|
208
206
|
taskId: string | null;
|
|
209
207
|
a2aTaskId: string | null;
|
|
208
|
+
projectId: string;
|
|
209
|
+
tenantId: string;
|
|
210
|
+
content: MessageContent;
|
|
210
211
|
conversationId: string;
|
|
211
|
-
role: string;
|
|
212
212
|
fromTeamAgentId: string | null;
|
|
213
213
|
toTeamAgentId: string | null;
|
|
214
214
|
visibility: string;
|
|
@@ -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;
|
|
11
|
-
projectId: string;
|
|
12
|
-
agentId: string;
|
|
13
10
|
createdAt: string;
|
|
14
11
|
updatedAt: string;
|
|
15
|
-
metadata: TaskMetadataConfig | null;
|
|
16
|
-
subAgentId: string;
|
|
17
|
-
status: string;
|
|
18
|
-
contextId: string;
|
|
19
12
|
ref: {
|
|
20
|
-
type: "
|
|
13
|
+
type: "tag" | "commit" | "branch";
|
|
21
14
|
name: string;
|
|
22
15
|
hash: string;
|
|
23
16
|
} | null;
|
|
17
|
+
metadata: TaskMetadataConfig | null;
|
|
18
|
+
status: string;
|
|
19
|
+
subAgentId: string;
|
|
20
|
+
projectId: string;
|
|
21
|
+
tenantId: string;
|
|
22
|
+
agentId: string;
|
|
23
|
+
contextId: string;
|
|
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: "tag" | "commit" | "branch";
|
|
40
40
|
name: string;
|
|
41
41
|
hash: string;
|
|
42
42
|
} | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/data-reconciliation/audit.ts
|
|
2
|
+
async function audit(registry, ctx) {
|
|
3
|
+
const report = {
|
|
4
|
+
entries: [],
|
|
5
|
+
checkedEntities: [],
|
|
6
|
+
skippedEntities: []
|
|
7
|
+
};
|
|
8
|
+
for (const [table, handlers] of Object.entries(registry)) {
|
|
9
|
+
if (!handlers?.check) {
|
|
10
|
+
report.skippedEntities.push(table);
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
report.checkedEntities.push(table);
|
|
14
|
+
try {
|
|
15
|
+
const result = await handlers.check(ctx);
|
|
16
|
+
report.entries.push({
|
|
17
|
+
table,
|
|
18
|
+
result
|
|
19
|
+
});
|
|
20
|
+
} catch (error) {
|
|
21
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
22
|
+
ctx.logger.warn({
|
|
23
|
+
table,
|
|
24
|
+
error: errorMessage
|
|
25
|
+
}, `Audit check failed for entity: ${table}`);
|
|
26
|
+
report.entries.push({
|
|
27
|
+
table,
|
|
28
|
+
result: null,
|
|
29
|
+
error: error instanceof Error ? error.message : String(error)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return report;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { audit };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AppliedEffect, AuditContext, AuditReport, EntityAuditEntry, EntityDiff, EntityEffectHandlers, EntityEffectRegistry, EntityOperation, EntityRowByTable, FailedEffect, OrphanedRuntimeRowsResult, ReconcileContext, ReconcileResult, ScheduledTriggerAuditResult, SkippedDiff, defineHandlers } from "./types.js";
|
|
2
|
+
import { audit } from "./audit.js";
|
|
3
|
+
import { reconcile } from "./reconcile.js";
|
|
4
|
+
export { AppliedEffect, AuditContext, AuditReport, EntityAuditEntry, EntityDiff, EntityEffectHandlers, EntityEffectRegistry, EntityOperation, EntityRowByTable, FailedEffect, OrphanedRuntimeRowsResult, ReconcileContext, ReconcileResult, ScheduledTriggerAuditResult, SkippedDiff, audit, defineHandlers, reconcile };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EntityDiff, EntityEffectRegistry, ReconcileContext, ReconcileResult } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data-reconciliation/reconcile.d.ts
|
|
4
|
+
declare function reconcile(registry: EntityEffectRegistry, diffs: EntityDiff[], ctx: ReconcileContext): Promise<ReconcileResult>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { reconcile };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/data-reconciliation/reconcile.ts
|
|
2
|
+
async function reconcile(registry, diffs, ctx) {
|
|
3
|
+
const result = {
|
|
4
|
+
applied: [],
|
|
5
|
+
skipped: [],
|
|
6
|
+
failed: []
|
|
7
|
+
};
|
|
8
|
+
const operations = diffs.map(async (diff) => {
|
|
9
|
+
const handlers = registry[diff.table];
|
|
10
|
+
if (!handlers) {
|
|
11
|
+
result.skipped.push({
|
|
12
|
+
table: diff.table,
|
|
13
|
+
operation: diff.operation,
|
|
14
|
+
primaryKey: diff.primaryKey,
|
|
15
|
+
reason: "no registry entry"
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
if (diff.operation === "insert" && handlers.onCreated && diff.after) await handlers.onCreated(diff.after, ctx);
|
|
21
|
+
else if (diff.operation === "update" && handlers.onUpdated && diff.before && diff.after) await handlers.onUpdated(diff.before, diff.after, ctx);
|
|
22
|
+
else if (diff.operation === "delete" && handlers.onDeleted && diff.before) await handlers.onDeleted(diff.before, ctx);
|
|
23
|
+
else {
|
|
24
|
+
result.skipped.push({
|
|
25
|
+
table: diff.table,
|
|
26
|
+
operation: diff.operation,
|
|
27
|
+
primaryKey: diff.primaryKey,
|
|
28
|
+
reason: `no handler for ${diff.operation}`
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
result.applied.push({
|
|
33
|
+
table: diff.table,
|
|
34
|
+
operation: diff.operation,
|
|
35
|
+
primaryKey: diff.primaryKey
|
|
36
|
+
});
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
39
|
+
ctx.logger.error({
|
|
40
|
+
table: diff.table,
|
|
41
|
+
operation: diff.operation,
|
|
42
|
+
primaryKey: diff.primaryKey,
|
|
43
|
+
error: errorMessage
|
|
44
|
+
}, `Reconcile effect failed for ${diff.table}.${diff.operation}`);
|
|
45
|
+
result.failed.push({
|
|
46
|
+
table: diff.table,
|
|
47
|
+
operation: diff.operation,
|
|
48
|
+
primaryKey: diff.primaryKey,
|
|
49
|
+
error: errorMessage
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
await Promise.allSettled(operations);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { reconcile };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { PinoLogger } from "../utils/logger.js";
|
|
2
|
+
import { AgentsManageDatabaseClient } from "../db/manage/manage-client.js";
|
|
3
|
+
import { AgentsRunDatabaseClient } from "../db/runtime/runtime-client.js";
|
|
4
|
+
import { ScheduledTrigger } from "../validation/schemas.js";
|
|
5
|
+
import { AgentSelect, ContextConfigSelect, SubAgentSelect, ToolSelect } from "../types/entities.js";
|
|
6
|
+
|
|
7
|
+
//#region src/data-reconciliation/types.d.ts
|
|
8
|
+
type EntityRowByTable = {
|
|
9
|
+
scheduled_triggers: ScheduledTrigger;
|
|
10
|
+
tools: ToolSelect;
|
|
11
|
+
context_configs: ContextConfigSelect;
|
|
12
|
+
agent: AgentSelect;
|
|
13
|
+
sub_agents: SubAgentSelect;
|
|
14
|
+
};
|
|
15
|
+
type EntityOperation = 'insert' | 'update' | 'delete';
|
|
16
|
+
type EntityDiff<TTable extends keyof EntityRowByTable = keyof EntityRowByTable> = {
|
|
17
|
+
table: TTable;
|
|
18
|
+
operation: 'insert';
|
|
19
|
+
primaryKey: Record<string, string>;
|
|
20
|
+
before: null;
|
|
21
|
+
after: EntityRowByTable[TTable];
|
|
22
|
+
} | {
|
|
23
|
+
table: TTable;
|
|
24
|
+
operation: 'update';
|
|
25
|
+
primaryKey: Record<string, string>;
|
|
26
|
+
before: EntityRowByTable[TTable];
|
|
27
|
+
after: EntityRowByTable[TTable];
|
|
28
|
+
} | {
|
|
29
|
+
table: TTable;
|
|
30
|
+
operation: 'delete';
|
|
31
|
+
primaryKey: Record<string, string>;
|
|
32
|
+
before: EntityRowByTable[TTable];
|
|
33
|
+
after: null;
|
|
34
|
+
};
|
|
35
|
+
type EntityEffectHandlers<TTable extends keyof EntityRowByTable> = {
|
|
36
|
+
onCreated?: (after: EntityRowByTable[TTable], ctx: ReconcileContext) => Promise<void>;
|
|
37
|
+
onUpdated?: (before: EntityRowByTable[TTable], after: EntityRowByTable[TTable], ctx: ReconcileContext) => Promise<void>;
|
|
38
|
+
onDeleted?: (before: EntityRowByTable[TTable], ctx: ReconcileContext) => Promise<void>;
|
|
39
|
+
check?: (ctx: AuditContext) => Promise<unknown>;
|
|
40
|
+
};
|
|
41
|
+
type EntityEffectRegistry = { [K in keyof EntityRowByTable]?: EntityEffectHandlers<K> };
|
|
42
|
+
declare function defineHandlers<TTable extends keyof EntityRowByTable>(_table: TTable, handlers: EntityEffectHandlers<TTable>): EntityEffectHandlers<TTable>;
|
|
43
|
+
type ReconcileContext = {
|
|
44
|
+
manageDb: AgentsManageDatabaseClient;
|
|
45
|
+
runDb: AgentsRunDatabaseClient;
|
|
46
|
+
scopes: {
|
|
47
|
+
tenantId: string;
|
|
48
|
+
projectId: string;
|
|
49
|
+
};
|
|
50
|
+
fullBranchName: string;
|
|
51
|
+
logger: PinoLogger;
|
|
52
|
+
};
|
|
53
|
+
type AuditContext = ReconcileContext;
|
|
54
|
+
type AppliedEffect = {
|
|
55
|
+
table: string;
|
|
56
|
+
operation: EntityOperation;
|
|
57
|
+
primaryKey: Record<string, string>;
|
|
58
|
+
};
|
|
59
|
+
type FailedEffect = AppliedEffect & {
|
|
60
|
+
error: string;
|
|
61
|
+
};
|
|
62
|
+
type SkippedDiff = {
|
|
63
|
+
table: string;
|
|
64
|
+
operation: EntityOperation;
|
|
65
|
+
primaryKey: Record<string, string>;
|
|
66
|
+
reason: string;
|
|
67
|
+
};
|
|
68
|
+
type ReconcileResult = {
|
|
69
|
+
applied: AppliedEffect[];
|
|
70
|
+
skipped: SkippedDiff[];
|
|
71
|
+
failed: FailedEffect[];
|
|
72
|
+
};
|
|
73
|
+
type EntityAuditEntry<TResult = unknown> = {
|
|
74
|
+
table: string;
|
|
75
|
+
result: TResult;
|
|
76
|
+
error?: string;
|
|
77
|
+
};
|
|
78
|
+
type AuditReport = {
|
|
79
|
+
entries: EntityAuditEntry[];
|
|
80
|
+
checkedEntities: string[];
|
|
81
|
+
skippedEntities: string[];
|
|
82
|
+
};
|
|
83
|
+
type ScheduledTriggerAuditResult = {
|
|
84
|
+
missingWorkflows: Array<{
|
|
85
|
+
triggerId: string;
|
|
86
|
+
triggerName: string;
|
|
87
|
+
}>;
|
|
88
|
+
orphanedWorkflows: Array<{
|
|
89
|
+
workflowRunId: string;
|
|
90
|
+
scheduledTriggerId: string;
|
|
91
|
+
}>;
|
|
92
|
+
staleWorkflows: Array<{
|
|
93
|
+
triggerId: string;
|
|
94
|
+
triggerName: string;
|
|
95
|
+
workflowId: string;
|
|
96
|
+
}>;
|
|
97
|
+
deadWorkflows: Array<{
|
|
98
|
+
triggerId: string;
|
|
99
|
+
triggerName: string;
|
|
100
|
+
workflowRunId: string;
|
|
101
|
+
runStatus: string;
|
|
102
|
+
}>;
|
|
103
|
+
verificationFailures: Array<{
|
|
104
|
+
workflowRunId: string;
|
|
105
|
+
error: string;
|
|
106
|
+
}>;
|
|
107
|
+
};
|
|
108
|
+
type OrphanedRuntimeRowsResult = {
|
|
109
|
+
orphanedRows: Array<{
|
|
110
|
+
table: string;
|
|
111
|
+
id: string;
|
|
112
|
+
referencedEntityId: string;
|
|
113
|
+
}>;
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
export { AppliedEffect, AuditContext, AuditReport, EntityAuditEntry, EntityDiff, EntityEffectHandlers, EntityEffectRegistry, EntityOperation, EntityRowByTable, FailedEffect, OrphanedRuntimeRowsResult, ReconcileContext, ReconcileResult, ScheduledTriggerAuditResult, SkippedDiff, defineHandlers };
|