@inkeep/agents-core 0.64.10 → 0.65.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth-schema.d.ts +108 -108
- package/dist/auth/auth-validation-schemas.d.ts +154 -154
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/client-exports.d.ts +3 -3
- package/dist/client-exports.js +3 -3
- package/dist/constants/otel-attributes.d.ts +1 -0
- package/dist/constants/otel-attributes.js +1 -0
- package/dist/data-access/index.d.ts +5 -3
- package/dist/data-access/index.js +4 -2
- package/dist/data-access/manage/agents.d.ts +30 -30
- 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 +4 -4
- package/dist/data-access/manage/functionTools.d.ts +16 -16
- package/dist/data-access/manage/projectLifecycle.d.ts +6 -6
- package/dist/data-access/manage/projectLifecycle.js +42 -21
- package/dist/data-access/manage/skills.d.ts +10 -10
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +22 -22
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +18 -18
- package/dist/data-access/manage/tools.d.ts +30 -30
- 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/apps.d.ts +12 -12
- package/dist/data-access/runtime/cascade-delete.d.ts +2 -3
- package/dist/data-access/runtime/cascade-delete.js +10 -10
- package/dist/data-access/runtime/conversations.d.ts +20 -20
- package/dist/data-access/runtime/feedback.d.ts +101 -0
- package/dist/data-access/runtime/feedback.js +83 -0
- package/dist/data-access/runtime/messages.d.ts +18 -18
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +18 -10
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +67 -9
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +54 -0
- package/dist/data-access/runtime/scheduledTriggerUsers.js +62 -0
- package/dist/data-access/runtime/scheduledTriggers.d.ts +1 -0
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/db/manage/dolt-safe-jsonb.d.ts +2 -2
- package/dist/db/manage/manage-schema.d.ts +449 -449
- package/dist/db/runtime/runtime-schema.d.ts +679 -384
- package/dist/db/runtime/runtime-schema.js +108 -3
- package/dist/index.d.ts +9 -7
- package/dist/index.js +7 -5
- package/dist/types/entities.d.ts +9 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/error.d.ts +51 -51
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/index.d.ts +3 -3
- package/dist/validation/index.js +3 -3
- package/dist/validation/schemas/shared.d.ts +3 -1
- package/dist/validation/schemas/shared.js +6 -1
- package/dist/validation/schemas/skills.d.ts +39 -39
- package/dist/validation/schemas.d.ts +2477 -1955
- package/dist/validation/schemas.js +54 -10
- package/drizzle/runtime/0032_sloppy_starfox.sql +17 -0
- package/drizzle/runtime/0033_backfill-scheduled-trigger-users.sql +7 -0
- package/drizzle/runtime/0034_simple_sphinx.sql +17 -0
- package/drizzle/runtime/meta/0032_snapshot.json +5120 -0
- package/drizzle/runtime/meta/0034_snapshot.json +5288 -0
- package/drizzle/runtime/meta/_journal.json +21 -0
- package/package.json +1 -1
|
@@ -5,16 +5,16 @@ 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
|
-
tenantId: string | null;
|
|
9
|
-
projectId: string | null;
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
description: string | null;
|
|
13
8
|
type: AppType;
|
|
9
|
+
description: string | null;
|
|
10
|
+
id: string;
|
|
11
|
+
tenantId: string | null;
|
|
14
12
|
createdAt: string;
|
|
13
|
+
name: string;
|
|
15
14
|
updatedAt: string;
|
|
16
|
-
|
|
15
|
+
projectId: string | null;
|
|
17
16
|
enabled: boolean;
|
|
17
|
+
prompt: string | null;
|
|
18
18
|
config: {
|
|
19
19
|
type: "web_client";
|
|
20
20
|
webClient: {
|
|
@@ -61,16 +61,16 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
61
61
|
};
|
|
62
62
|
}>;
|
|
63
63
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
64
|
-
tenantId: string | null;
|
|
65
|
-
projectId: string | null;
|
|
66
|
-
id: string;
|
|
67
|
-
name: string;
|
|
68
|
-
description: string | null;
|
|
69
64
|
type: AppType;
|
|
65
|
+
description: string | null;
|
|
66
|
+
id: string;
|
|
67
|
+
tenantId: string | null;
|
|
70
68
|
createdAt: string;
|
|
69
|
+
name: string;
|
|
71
70
|
updatedAt: string;
|
|
72
|
-
|
|
71
|
+
projectId: string | null;
|
|
73
72
|
enabled: boolean;
|
|
73
|
+
prompt: string | null;
|
|
74
74
|
config: {
|
|
75
75
|
type: "web_client";
|
|
76
76
|
webClient: {
|
|
@@ -34,8 +34,8 @@ declare const cascadeDeleteByBranch: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
34
34
|
ref: string;
|
|
35
35
|
}) => Promise<CascadeDeleteResult>;
|
|
36
36
|
/**
|
|
37
|
-
* Delete all runtime entities for a project
|
|
38
|
-
* Used when deleting a project
|
|
37
|
+
* Delete all runtime entities for a project across all branches.
|
|
38
|
+
* Used when deleting a project entirely.
|
|
39
39
|
* PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts
|
|
40
40
|
*
|
|
41
41
|
* @param db - Runtime database client
|
|
@@ -43,7 +43,6 @@ declare const cascadeDeleteByBranch: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
43
43
|
*/
|
|
44
44
|
declare const cascadeDeleteByProject: (db: AgentsRunDatabaseClient) => (params: {
|
|
45
45
|
scopes: ProjectScopeConfig;
|
|
46
|
-
fullBranchName: string;
|
|
47
46
|
}) => Promise<CascadeDeleteResult>;
|
|
48
47
|
/**
|
|
49
48
|
* Delete all runtime entities for a specific agent on a specific branch.
|
|
@@ -40,22 +40,22 @@ const cascadeDeleteByBranch = (db) => async (params) => {
|
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
|
-
* Delete all runtime entities for a project
|
|
44
|
-
* Used when deleting a project
|
|
43
|
+
* Delete all runtime entities for a project across all branches.
|
|
44
|
+
* Used when deleting a project entirely.
|
|
45
45
|
* PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts
|
|
46
46
|
*
|
|
47
47
|
* @param db - Runtime database client
|
|
48
48
|
* @returns Function that performs the cascade delete
|
|
49
49
|
*/
|
|
50
50
|
const cascadeDeleteByProject = (db) => async (params) => {
|
|
51
|
-
const { scopes
|
|
52
|
-
const contextCacheResult = await db.delete(contextCache).where(
|
|
53
|
-
const conversationsResult = await db.delete(conversations).where(
|
|
54
|
-
const tasksResult = await db.delete(tasks).where(
|
|
55
|
-
const triggerInvocationsResult = await db.delete(triggerInvocations).where(and(eq(triggerInvocations.tenantId, scopes.tenantId), eq(triggerInvocations.projectId, scopes.projectId)
|
|
56
|
-
const scheduledTriggerInvocationsResult = await db.delete(scheduledTriggerInvocations).where(and(eq(scheduledTriggerInvocations.tenantId, scopes.tenantId), eq(scheduledTriggerInvocations.projectId, scopes.projectId)
|
|
57
|
-
const datasetRunsResult = await db.delete(datasetRun).where(and(eq(datasetRun.tenantId, scopes.tenantId), eq(datasetRun.projectId, scopes.projectId)
|
|
58
|
-
const evaluationRunsResult = await db.delete(evaluationRun).where(and(eq(evaluationRun.tenantId, scopes.tenantId), eq(evaluationRun.projectId, scopes.projectId)
|
|
51
|
+
const { scopes } = params;
|
|
52
|
+
const contextCacheResult = await db.delete(contextCache).where(projectScopedWhere(contextCache, scopes)).returning();
|
|
53
|
+
const conversationsResult = await db.delete(conversations).where(projectScopedWhere(conversations, scopes)).returning();
|
|
54
|
+
const tasksResult = await db.delete(tasks).where(projectScopedWhere(tasks, scopes)).returning();
|
|
55
|
+
const triggerInvocationsResult = await db.delete(triggerInvocations).where(and(eq(triggerInvocations.tenantId, scopes.tenantId), eq(triggerInvocations.projectId, scopes.projectId))).returning();
|
|
56
|
+
const scheduledTriggerInvocationsResult = await db.delete(scheduledTriggerInvocations).where(and(eq(scheduledTriggerInvocations.tenantId, scopes.tenantId), eq(scheduledTriggerInvocations.projectId, scopes.projectId))).returning();
|
|
57
|
+
const datasetRunsResult = await db.delete(datasetRun).where(and(eq(datasetRun.tenantId, scopes.tenantId), eq(datasetRun.projectId, scopes.projectId))).returning();
|
|
58
|
+
const evaluationRunsResult = await db.delete(evaluationRun).where(and(eq(evaluationRun.tenantId, scopes.tenantId), eq(evaluationRun.projectId, scopes.projectId))).returning();
|
|
59
59
|
const apiKeysResult = await db.delete(apiKeys).where(projectScopedWhere(apiKeys, scopes)).returning();
|
|
60
60
|
await cascadeDeleteGitHubAccessByProject(db)({
|
|
61
61
|
tenantId: scopes.tenantId,
|
|
@@ -15,20 +15,20 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
15
15
|
total: number;
|
|
16
16
|
}>;
|
|
17
17
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
18
|
-
|
|
19
|
-
projectId: string;
|
|
18
|
+
title: string | null;
|
|
20
19
|
id: string;
|
|
20
|
+
tenantId: string;
|
|
21
|
+
createdAt: string;
|
|
21
22
|
metadata: ConversationMetadata | null;
|
|
22
23
|
ref: {
|
|
23
24
|
type: "commit" | "tag" | "branch";
|
|
24
25
|
name: string;
|
|
25
26
|
hash: string;
|
|
26
27
|
} | null;
|
|
27
|
-
userId: string | null;
|
|
28
|
-
createdAt: string;
|
|
29
28
|
updatedAt: string;
|
|
30
|
-
|
|
29
|
+
projectId: string;
|
|
31
30
|
agentId: string | null;
|
|
31
|
+
userId: string | null;
|
|
32
32
|
activeSubAgentId: string;
|
|
33
33
|
lastContextResolution: string | null;
|
|
34
34
|
}>;
|
|
@@ -84,20 +84,20 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
84
84
|
scopes: ProjectScopeConfig;
|
|
85
85
|
conversationId: string;
|
|
86
86
|
}) => Promise<{
|
|
87
|
-
|
|
88
|
-
projectId: string;
|
|
87
|
+
title: string | null;
|
|
89
88
|
id: string;
|
|
89
|
+
tenantId: string;
|
|
90
|
+
createdAt: string;
|
|
90
91
|
metadata: ConversationMetadata | null;
|
|
91
92
|
ref: {
|
|
92
93
|
type: "commit" | "tag" | "branch";
|
|
93
94
|
name: string;
|
|
94
95
|
hash: string;
|
|
95
96
|
} | null;
|
|
96
|
-
userId: string | null;
|
|
97
|
-
createdAt: string;
|
|
98
97
|
updatedAt: string;
|
|
99
|
-
|
|
98
|
+
projectId: string;
|
|
100
99
|
agentId: string | null;
|
|
100
|
+
userId: string | null;
|
|
101
101
|
activeSubAgentId: string;
|
|
102
102
|
lastContextResolution: string | null;
|
|
103
103
|
} | undefined>;
|
|
@@ -120,20 +120,20 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
120
120
|
metadata?: ConversationMetadata | null | undefined;
|
|
121
121
|
contextConfigId?: string | undefined;
|
|
122
122
|
} | {
|
|
123
|
-
|
|
124
|
-
projectId: string;
|
|
123
|
+
title: string | null;
|
|
125
124
|
id: string;
|
|
125
|
+
tenantId: string;
|
|
126
|
+
createdAt: string;
|
|
126
127
|
metadata: ConversationMetadata | null;
|
|
127
128
|
ref: {
|
|
128
129
|
type: "commit" | "tag" | "branch";
|
|
129
130
|
name: string;
|
|
130
131
|
hash: string;
|
|
131
132
|
} | null;
|
|
132
|
-
userId: string | null;
|
|
133
|
-
createdAt: string;
|
|
134
133
|
updatedAt: string;
|
|
135
|
-
|
|
134
|
+
projectId: string;
|
|
136
135
|
agentId: string | null;
|
|
136
|
+
userId: string | null;
|
|
137
137
|
activeSubAgentId: string;
|
|
138
138
|
lastContextResolution: string | null;
|
|
139
139
|
}>;
|
|
@@ -152,20 +152,20 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
152
152
|
scopes: ProjectScopeConfig;
|
|
153
153
|
conversationId: string;
|
|
154
154
|
}) => Promise<{
|
|
155
|
-
|
|
156
|
-
projectId: string;
|
|
155
|
+
title: string | null;
|
|
157
156
|
id: string;
|
|
157
|
+
tenantId: string;
|
|
158
|
+
createdAt: string;
|
|
158
159
|
metadata: ConversationMetadata | null;
|
|
159
160
|
ref: {
|
|
160
161
|
type: "commit" | "tag" | "branch";
|
|
161
162
|
name: string;
|
|
162
163
|
hash: string;
|
|
163
164
|
} | null;
|
|
164
|
-
userId: string | null;
|
|
165
|
-
createdAt: string;
|
|
166
165
|
updatedAt: string;
|
|
167
|
-
|
|
166
|
+
projectId: string;
|
|
168
167
|
agentId: string | null;
|
|
168
|
+
userId: string | null;
|
|
169
169
|
activeSubAgentId: string;
|
|
170
170
|
lastContextResolution: string | null;
|
|
171
171
|
} | undefined>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
2
|
+
import { PaginationConfig } from "../../types/utility.js";
|
|
3
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
4
|
+
import "../../types/index.js";
|
|
5
|
+
import { FeedbackInsert, FeedbackUpdate } from "../../types/entities.js";
|
|
6
|
+
|
|
7
|
+
//#region src/data-access/runtime/feedback.d.ts
|
|
8
|
+
declare const getFeedbackById: (db: AgentsRunDatabaseClient) => (params: {
|
|
9
|
+
scopes: ProjectScopeConfig;
|
|
10
|
+
feedbackId: string;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
id: string;
|
|
13
|
+
conversationId: string;
|
|
14
|
+
messageId: string | null;
|
|
15
|
+
type: "positive" | "negative";
|
|
16
|
+
details: string | null;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}>;
|
|
20
|
+
declare const listFeedbackByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
21
|
+
scopes: ProjectScopeConfig;
|
|
22
|
+
conversationId: string;
|
|
23
|
+
messageId?: string;
|
|
24
|
+
pagination?: PaginationConfig;
|
|
25
|
+
}) => Promise<{
|
|
26
|
+
feedback: {
|
|
27
|
+
id: string;
|
|
28
|
+
conversationId: string;
|
|
29
|
+
messageId: string | null;
|
|
30
|
+
type: "positive" | "negative";
|
|
31
|
+
details: string | null;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
agentId: string | null;
|
|
35
|
+
}[];
|
|
36
|
+
total: number;
|
|
37
|
+
}>;
|
|
38
|
+
declare const listFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
|
+
scopes: ProjectScopeConfig;
|
|
40
|
+
conversationId?: string;
|
|
41
|
+
messageId?: string;
|
|
42
|
+
agentId?: string;
|
|
43
|
+
type?: "positive" | "negative";
|
|
44
|
+
startDate?: string;
|
|
45
|
+
endDate?: string;
|
|
46
|
+
pagination?: PaginationConfig;
|
|
47
|
+
}) => Promise<{
|
|
48
|
+
feedback: {
|
|
49
|
+
id: string;
|
|
50
|
+
conversationId: string;
|
|
51
|
+
messageId: string | null;
|
|
52
|
+
type: "positive" | "negative";
|
|
53
|
+
details: string | null;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
updatedAt: string;
|
|
56
|
+
agentId: string | null;
|
|
57
|
+
}[];
|
|
58
|
+
total: number;
|
|
59
|
+
}>;
|
|
60
|
+
declare const createFeedback: (db: AgentsRunDatabaseClient) => (params: FeedbackInsert) => Promise<{
|
|
61
|
+
type: "positive" | "negative";
|
|
62
|
+
id: string;
|
|
63
|
+
tenantId: string;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
projectId: string;
|
|
67
|
+
details: string | null;
|
|
68
|
+
conversationId: string;
|
|
69
|
+
messageId: string | null;
|
|
70
|
+
}>;
|
|
71
|
+
declare const updateFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
72
|
+
scopes: ProjectScopeConfig;
|
|
73
|
+
feedbackId: string;
|
|
74
|
+
data: FeedbackUpdate;
|
|
75
|
+
}) => Promise<{
|
|
76
|
+
createdAt: string;
|
|
77
|
+
updatedAt: string;
|
|
78
|
+
conversationId: string;
|
|
79
|
+
messageId: string | null;
|
|
80
|
+
type: "positive" | "negative";
|
|
81
|
+
details: string | null;
|
|
82
|
+
projectId: string;
|
|
83
|
+
tenantId: string;
|
|
84
|
+
id: string;
|
|
85
|
+
}>;
|
|
86
|
+
declare const deleteFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
87
|
+
scopes: ProjectScopeConfig;
|
|
88
|
+
feedbackId: string;
|
|
89
|
+
}) => Promise<{
|
|
90
|
+
type: "positive" | "negative";
|
|
91
|
+
id: string;
|
|
92
|
+
tenantId: string;
|
|
93
|
+
createdAt: string;
|
|
94
|
+
updatedAt: string;
|
|
95
|
+
projectId: string;
|
|
96
|
+
details: string | null;
|
|
97
|
+
conversationId: string;
|
|
98
|
+
messageId: string | null;
|
|
99
|
+
}>;
|
|
100
|
+
//#endregion
|
|
101
|
+
export { createFeedback, deleteFeedback, getFeedbackById, listFeedback, listFeedbackByConversation, updateFeedback };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { conversations, feedback } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { projectScopedWhere } from "../manage/scope-helpers.js";
|
|
3
|
+
import { and, count, desc, eq, gte, lte } from "drizzle-orm";
|
|
4
|
+
|
|
5
|
+
//#region src/data-access/runtime/feedback.ts
|
|
6
|
+
const getFeedbackById = (db) => async (params) => {
|
|
7
|
+
const [result] = await db.select({
|
|
8
|
+
id: feedback.id,
|
|
9
|
+
conversationId: feedback.conversationId,
|
|
10
|
+
messageId: feedback.messageId,
|
|
11
|
+
type: feedback.type,
|
|
12
|
+
details: feedback.details,
|
|
13
|
+
createdAt: feedback.createdAt,
|
|
14
|
+
updatedAt: feedback.updatedAt
|
|
15
|
+
}).from(feedback).where(and(projectScopedWhere(feedback, params.scopes), eq(feedback.id, params.feedbackId))).limit(1);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
const listFeedbackByConversation = (db) => async (params) => {
|
|
19
|
+
return listFeedback(db)({
|
|
20
|
+
scopes: params.scopes,
|
|
21
|
+
conversationId: params.conversationId,
|
|
22
|
+
messageId: params.messageId,
|
|
23
|
+
pagination: params.pagination
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const listFeedback = (db) => async (params) => {
|
|
27
|
+
const page = params.pagination?.page || 1;
|
|
28
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
29
|
+
const offset = (page - 1) * limit;
|
|
30
|
+
const conditions = [projectScopedWhere(feedback, params.scopes)];
|
|
31
|
+
if (params.conversationId) conditions.push(eq(feedback.conversationId, params.conversationId));
|
|
32
|
+
if (params.messageId) conditions.push(eq(feedback.messageId, params.messageId));
|
|
33
|
+
if (params.type) conditions.push(eq(feedback.type, params.type));
|
|
34
|
+
if (params.startDate) conditions.push(gte(feedback.createdAt, `${params.startDate}T00:00:00.000Z`));
|
|
35
|
+
if (params.endDate) conditions.push(lte(feedback.createdAt, `${params.endDate}T23:59:59.999Z`));
|
|
36
|
+
if (params.agentId) conditions.push(eq(conversations.agentId, params.agentId));
|
|
37
|
+
const whereClause = and(...conditions);
|
|
38
|
+
const conversationsJoin = [
|
|
39
|
+
eq(feedback.tenantId, conversations.tenantId),
|
|
40
|
+
eq(feedback.projectId, conversations.projectId),
|
|
41
|
+
eq(feedback.conversationId, conversations.id)
|
|
42
|
+
];
|
|
43
|
+
const countQuery = db.select({ count: count() }).from(feedback);
|
|
44
|
+
if (params.agentId) countQuery.leftJoin(conversations, and(...conversationsJoin));
|
|
45
|
+
const [items, total] = await Promise.all([db.select({
|
|
46
|
+
id: feedback.id,
|
|
47
|
+
conversationId: feedback.conversationId,
|
|
48
|
+
messageId: feedback.messageId,
|
|
49
|
+
type: feedback.type,
|
|
50
|
+
details: feedback.details,
|
|
51
|
+
createdAt: feedback.createdAt,
|
|
52
|
+
updatedAt: feedback.updatedAt,
|
|
53
|
+
agentId: conversations.agentId
|
|
54
|
+
}).from(feedback).leftJoin(conversations, and(...conversationsJoin)).where(whereClause).limit(limit).offset(offset).orderBy(desc(feedback.createdAt)), countQuery.where(whereClause)]);
|
|
55
|
+
return {
|
|
56
|
+
feedback: items,
|
|
57
|
+
total: typeof total[0]?.count === "string" ? Number.parseInt(total[0].count, 10) : total[0]?.count ?? 0
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const createFeedback = (db) => async (params) => {
|
|
61
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
62
|
+
const [created] = await db.insert(feedback).values({
|
|
63
|
+
...params,
|
|
64
|
+
createdAt: now,
|
|
65
|
+
updatedAt: now
|
|
66
|
+
}).returning();
|
|
67
|
+
return created;
|
|
68
|
+
};
|
|
69
|
+
const updateFeedback = (db) => async (params) => {
|
|
70
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
71
|
+
const [updated] = await db.update(feedback).set({
|
|
72
|
+
...params.data,
|
|
73
|
+
updatedAt: now
|
|
74
|
+
}).where(and(projectScopedWhere(feedback, params.scopes), eq(feedback.id, params.feedbackId))).returning();
|
|
75
|
+
return updated;
|
|
76
|
+
};
|
|
77
|
+
const deleteFeedback = (db) => async (params) => {
|
|
78
|
+
const [deleted] = await db.delete(feedback).where(and(projectScopedWhere(feedback, params.scopes), eq(feedback.id, params.feedbackId))).returning();
|
|
79
|
+
return deleted;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { createFeedback, deleteFeedback, getFeedbackById, listFeedback, listFeedbackByConversation, updateFeedback };
|
|
@@ -10,26 +10,26 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
scopes: ProjectScopeConfig;
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
|
-
tenantId: string;
|
|
14
|
-
projectId: string;
|
|
15
13
|
id: string;
|
|
14
|
+
tenantId: string;
|
|
15
|
+
createdAt: string;
|
|
16
16
|
metadata: MessageMetadata | null;
|
|
17
17
|
content: MessageContent;
|
|
18
|
-
createdAt: string;
|
|
19
18
|
updatedAt: string;
|
|
20
|
-
|
|
19
|
+
projectId: string;
|
|
21
20
|
role: string;
|
|
22
21
|
fromSubAgentId: string | null;
|
|
23
22
|
toSubAgentId: string | null;
|
|
24
23
|
fromExternalAgentId: string | null;
|
|
25
24
|
toExternalAgentId: string | null;
|
|
25
|
+
taskId: string | null;
|
|
26
|
+
a2aTaskId: string | null;
|
|
27
|
+
conversationId: 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: {
|
|
@@ -144,26 +144,26 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
144
144
|
scopes: ProjectScopeConfig;
|
|
145
145
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
146
146
|
}) => Promise<{
|
|
147
|
-
tenantId: string;
|
|
148
|
-
projectId: string;
|
|
149
147
|
id: string;
|
|
148
|
+
tenantId: string;
|
|
149
|
+
createdAt: string;
|
|
150
150
|
metadata: MessageMetadata | null;
|
|
151
151
|
content: MessageContent;
|
|
152
|
-
createdAt: string;
|
|
153
152
|
updatedAt: string;
|
|
154
|
-
|
|
153
|
+
projectId: string;
|
|
155
154
|
role: string;
|
|
156
155
|
fromSubAgentId: string | null;
|
|
157
156
|
toSubAgentId: string | null;
|
|
158
157
|
fromExternalAgentId: string | null;
|
|
159
158
|
toExternalAgentId: string | null;
|
|
159
|
+
taskId: string | null;
|
|
160
|
+
a2aTaskId: string | null;
|
|
161
|
+
conversationId: string;
|
|
160
162
|
fromTeamAgentId: string | null;
|
|
161
163
|
toTeamAgentId: string | null;
|
|
162
164
|
visibility: string;
|
|
163
165
|
messageType: string;
|
|
164
|
-
taskId: string | null;
|
|
165
166
|
parentMessageId: string | null;
|
|
166
|
-
a2aTaskId: string | null;
|
|
167
167
|
a2aSessionId: string | null;
|
|
168
168
|
}>;
|
|
169
169
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -197,26 +197,26 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
197
197
|
scopes: ProjectScopeConfig;
|
|
198
198
|
messageId: string;
|
|
199
199
|
}) => Promise<{
|
|
200
|
-
tenantId: string;
|
|
201
|
-
projectId: string;
|
|
202
200
|
id: string;
|
|
201
|
+
tenantId: string;
|
|
202
|
+
createdAt: string;
|
|
203
203
|
metadata: MessageMetadata | null;
|
|
204
204
|
content: MessageContent;
|
|
205
|
-
createdAt: string;
|
|
206
205
|
updatedAt: string;
|
|
207
|
-
|
|
206
|
+
projectId: string;
|
|
208
207
|
role: string;
|
|
209
208
|
fromSubAgentId: string | null;
|
|
210
209
|
toSubAgentId: string | null;
|
|
211
210
|
fromExternalAgentId: string | null;
|
|
212
211
|
toExternalAgentId: string | null;
|
|
212
|
+
taskId: string | null;
|
|
213
|
+
a2aTaskId: string | null;
|
|
214
|
+
conversationId: string;
|
|
213
215
|
fromTeamAgentId: string | null;
|
|
214
216
|
toTeamAgentId: string | null;
|
|
215
217
|
visibility: string;
|
|
216
218
|
messageType: string;
|
|
217
|
-
taskId: string | null;
|
|
218
219
|
parentMessageId: string | null;
|
|
219
|
-
a2aTaskId: string | null;
|
|
220
220
|
a2aSessionId: string | null;
|
|
221
221
|
}>;
|
|
222
222
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -2,7 +2,7 @@ import { AgentScopeConfig, ProjectScopeConfig } from "../../db/manage/scope-defi
|
|
|
2
2
|
import { PaginationConfig } from "../../types/utility.js";
|
|
3
3
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
4
4
|
import { ScheduledTriggerInvocationStatus } from "../../validation/schemas.js";
|
|
5
|
-
import { ScheduledTriggerInvocation, ScheduledTriggerInvocationInsert, ScheduledTriggerInvocationUpdate } from "../../types/entities.js";
|
|
5
|
+
import { LastRunSummary, ScheduledTriggerInvocation, ScheduledTriggerInvocationInsert, ScheduledTriggerInvocationUpdate } from "../../types/entities.js";
|
|
6
6
|
|
|
7
7
|
//#region src/data-access/runtime/scheduledTriggerInvocations.d.ts
|
|
8
8
|
/**
|
|
@@ -48,6 +48,7 @@ declare const listScheduledTriggerInvocationsPaginated: (db: AgentsRunDatabaseCl
|
|
|
48
48
|
conversationIds: string[] | null;
|
|
49
49
|
attemptNumber: number;
|
|
50
50
|
idempotencyKey: string;
|
|
51
|
+
runAsUserId: string | null;
|
|
51
52
|
createdAt: string;
|
|
52
53
|
agentId: string;
|
|
53
54
|
projectId: string;
|
|
@@ -160,9 +161,18 @@ declare const cancelPastPendingInvocationsForTrigger: (db: AgentsRunDatabaseClie
|
|
|
160
161
|
scopes: AgentScopeConfig;
|
|
161
162
|
scheduledTriggerId: string;
|
|
162
163
|
}) => Promise<number>;
|
|
164
|
+
type ScheduledTriggerRunInfo = {
|
|
165
|
+
lastRunAt: string | null;
|
|
166
|
+
lastRunStatus: 'completed' | 'failed' | null;
|
|
167
|
+
lastRunConversationIds: string[];
|
|
168
|
+
nextRunAt: string | null;
|
|
169
|
+
lastRunSummary: LastRunSummary | null;
|
|
170
|
+
};
|
|
163
171
|
/**
|
|
164
|
-
* Get run info for multiple scheduled triggers in a single query
|
|
165
|
-
*
|
|
172
|
+
* Get run info for multiple scheduled triggers in a single query.
|
|
173
|
+
* Groups invocations by (triggerId, scheduledFor) to support multi-user triggers.
|
|
174
|
+
* Excludes manual runs (manual-run-* and manual-rerun-* idempotency keys).
|
|
175
|
+
* Returns lastRunSummary with per-status counts for the most recent scheduled tick.
|
|
166
176
|
*/
|
|
167
177
|
declare const getScheduledTriggerRunInfoBatch: (db: AgentsRunDatabaseClient) => (params: {
|
|
168
178
|
scopes: Omit<AgentScopeConfig, "agentId">;
|
|
@@ -170,12 +180,7 @@ declare const getScheduledTriggerRunInfoBatch: (db: AgentsRunDatabaseClient) =>
|
|
|
170
180
|
agentId: string;
|
|
171
181
|
triggerId: string;
|
|
172
182
|
}>;
|
|
173
|
-
}) => Promise<Map<string,
|
|
174
|
-
lastRunAt: string | null;
|
|
175
|
-
lastRunStatus: "completed" | "failed" | null;
|
|
176
|
-
lastRunConversationIds: string[];
|
|
177
|
-
nextRunAt: string | null;
|
|
178
|
-
}>>;
|
|
183
|
+
}) => Promise<Map<string, ScheduledTriggerRunInfo>>;
|
|
179
184
|
/**
|
|
180
185
|
* List upcoming invocations across ALL triggers for an agent with pagination
|
|
181
186
|
* Used for the upcoming runs dashboard with full pagination support
|
|
@@ -202,6 +207,7 @@ declare const listUpcomingInvocationsForAgentPaginated: (db: AgentsRunDatabaseCl
|
|
|
202
207
|
conversationIds: string[] | null;
|
|
203
208
|
attemptNumber: number;
|
|
204
209
|
idempotencyKey: string;
|
|
210
|
+
runAsUserId: string | null;
|
|
205
211
|
createdAt: string;
|
|
206
212
|
agentId: string;
|
|
207
213
|
projectId: string;
|
|
@@ -241,6 +247,7 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
|
|
|
241
247
|
conversationIds: string[] | null;
|
|
242
248
|
attemptNumber: number;
|
|
243
249
|
idempotencyKey: string;
|
|
250
|
+
runAsUserId: string | null;
|
|
244
251
|
createdAt: string;
|
|
245
252
|
agentId: string;
|
|
246
253
|
projectId: string;
|
|
@@ -293,6 +300,7 @@ declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabase
|
|
|
293
300
|
conversationIds: string[] | null;
|
|
294
301
|
attemptNumber: number;
|
|
295
302
|
idempotencyKey: string;
|
|
303
|
+
runAsUserId: string | null;
|
|
296
304
|
createdAt: string;
|
|
297
305
|
agentId: string;
|
|
298
306
|
projectId: string;
|
|
@@ -300,4 +308,4 @@ declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabase
|
|
|
300
308
|
id: string;
|
|
301
309
|
}[]>;
|
|
302
310
|
//#endregion
|
|
303
|
-
export { addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
311
|
+
export { ScheduledTriggerRunInfo, addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
@@ -147,33 +147,91 @@ const cancelPastPendingInvocationsForTrigger = (db) => async (params) => {
|
|
|
147
147
|
}).where(and(agentScopedWhere(scheduledTriggerInvocations, params.scopes), eq(scheduledTriggerInvocations.scheduledTriggerId, params.scheduledTriggerId), inArray(scheduledTriggerInvocations.status, ["pending", "running"]), lte(scheduledTriggerInvocations.scheduledFor, now))).returning()).length;
|
|
148
148
|
};
|
|
149
149
|
/**
|
|
150
|
-
* Get run info for multiple scheduled triggers in a single query
|
|
151
|
-
*
|
|
150
|
+
* Get run info for multiple scheduled triggers in a single query.
|
|
151
|
+
* Groups invocations by (triggerId, scheduledFor) to support multi-user triggers.
|
|
152
|
+
* Excludes manual runs (manual-run-* and manual-rerun-* idempotency keys).
|
|
153
|
+
* Returns lastRunSummary with per-status counts for the most recent scheduled tick.
|
|
152
154
|
*/
|
|
153
155
|
const getScheduledTriggerRunInfoBatch = (db) => async (params) => {
|
|
154
156
|
if (params.triggerIds.length === 0) return /* @__PURE__ */ new Map();
|
|
157
|
+
const triggerIdValues = params.triggerIds.map((t) => t.triggerId);
|
|
155
158
|
const allInvocations = await db.select({
|
|
156
159
|
scheduledTriggerId: scheduledTriggerInvocations.scheduledTriggerId,
|
|
157
160
|
status: scheduledTriggerInvocations.status,
|
|
158
161
|
scheduledFor: scheduledTriggerInvocations.scheduledFor,
|
|
159
162
|
completedAt: scheduledTriggerInvocations.completedAt,
|
|
160
|
-
conversationIds: scheduledTriggerInvocations.conversationIds
|
|
161
|
-
|
|
163
|
+
conversationIds: scheduledTriggerInvocations.conversationIds,
|
|
164
|
+
idempotencyKey: scheduledTriggerInvocations.idempotencyKey
|
|
165
|
+
}).from(scheduledTriggerInvocations).where(and(projectScopedWhere(scheduledTriggerInvocations, params.scopes), inArray(scheduledTriggerInvocations.scheduledTriggerId, triggerIdValues))).orderBy(desc(scheduledTriggerInvocations.scheduledFor));
|
|
162
166
|
const result = /* @__PURE__ */ new Map();
|
|
163
167
|
for (const trigger of params.triggerIds) result.set(trigger.triggerId, {
|
|
164
168
|
lastRunAt: null,
|
|
165
169
|
lastRunStatus: null,
|
|
166
170
|
lastRunConversationIds: [],
|
|
167
|
-
nextRunAt: null
|
|
171
|
+
nextRunAt: null,
|
|
172
|
+
lastRunSummary: null
|
|
168
173
|
});
|
|
174
|
+
const isManualRun = (key) => key.startsWith("manual-run-") || key.startsWith("manual-rerun-");
|
|
175
|
+
const tickMap = /* @__PURE__ */ new Map();
|
|
169
176
|
for (const inv of allInvocations) {
|
|
170
177
|
const triggerInfo = result.get(inv.scheduledTriggerId);
|
|
171
178
|
if (!triggerInfo) continue;
|
|
172
179
|
if (inv.status === "pending" && !triggerInfo.nextRunAt) triggerInfo.nextRunAt = inv.scheduledFor;
|
|
173
|
-
if ((inv.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
if (isManualRun(inv.idempotencyKey)) continue;
|
|
181
|
+
let triggerTicks = tickMap.get(inv.scheduledTriggerId);
|
|
182
|
+
if (!triggerTicks) {
|
|
183
|
+
triggerTicks = /* @__PURE__ */ new Map();
|
|
184
|
+
tickMap.set(inv.scheduledTriggerId, triggerTicks);
|
|
185
|
+
}
|
|
186
|
+
let tickInvocations = triggerTicks.get(inv.scheduledFor);
|
|
187
|
+
if (!tickInvocations) {
|
|
188
|
+
tickInvocations = [];
|
|
189
|
+
triggerTicks.set(inv.scheduledFor, tickInvocations);
|
|
190
|
+
}
|
|
191
|
+
tickInvocations.push({
|
|
192
|
+
status: inv.status,
|
|
193
|
+
completedAt: inv.completedAt,
|
|
194
|
+
conversationIds: inv.conversationIds
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
for (const [triggerId, triggerTicks] of tickMap) {
|
|
198
|
+
const triggerInfo = result.get(triggerId);
|
|
199
|
+
if (!triggerInfo) continue;
|
|
200
|
+
let bestScheduledFor = null;
|
|
201
|
+
let bestInvocations = null;
|
|
202
|
+
for (const [scheduledFor, invocations] of triggerTicks) {
|
|
203
|
+
if (!invocations.some((i) => i.status === "completed" || i.status === "failed")) continue;
|
|
204
|
+
if (!bestScheduledFor || scheduledFor > bestScheduledFor) {
|
|
205
|
+
bestScheduledFor = scheduledFor;
|
|
206
|
+
bestInvocations = invocations;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (bestInvocations) {
|
|
210
|
+
const summary = {
|
|
211
|
+
total: bestInvocations.length,
|
|
212
|
+
completed: 0,
|
|
213
|
+
failed: 0,
|
|
214
|
+
running: 0,
|
|
215
|
+
pending: 0
|
|
216
|
+
};
|
|
217
|
+
let maxCompletedAt = null;
|
|
218
|
+
for (const inv of bestInvocations) {
|
|
219
|
+
if (inv.status === "completed") summary.completed++;
|
|
220
|
+
else if (inv.status === "failed") summary.failed++;
|
|
221
|
+
else if (inv.status === "running") summary.running++;
|
|
222
|
+
else if (inv.status === "pending") summary.pending++;
|
|
223
|
+
if (inv.completedAt && (!maxCompletedAt || inv.completedAt > maxCompletedAt)) maxCompletedAt = inv.completedAt;
|
|
224
|
+
}
|
|
225
|
+
triggerInfo.lastRunAt = maxCompletedAt;
|
|
226
|
+
triggerInfo.lastRunSummary = summary;
|
|
227
|
+
if (summary.failed > 0) triggerInfo.lastRunStatus = "failed";
|
|
228
|
+
else if (summary.completed > 0) triggerInfo.lastRunStatus = "completed";
|
|
229
|
+
const allConvIds = [];
|
|
230
|
+
for (const inv of bestInvocations) {
|
|
231
|
+
const ids = inv.conversationIds;
|
|
232
|
+
if (ids) for (const id of ids) allConvIds.push(id);
|
|
233
|
+
}
|
|
234
|
+
triggerInfo.lastRunConversationIds = allConvIds;
|
|
177
235
|
}
|
|
178
236
|
}
|
|
179
237
|
return result;
|