@inkeep/agents-core 0.78.4 → 0.78.5
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 +227 -227
- package/dist/auth/auth-validation-schemas.d.ts +154 -154
- package/dist/auth/auth.d.ts +9 -9
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/data-access/index.d.ts +2 -2
- package/dist/data-access/index.js +2 -2
- package/dist/data-access/manage/agents.d.ts +16 -16
- package/dist/data-access/manage/artifactComponents.d.ts +10 -10
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- 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/skills.d.ts +10 -10
- 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 +12 -12
- package/dist/data-access/manage/tools.d.ts +27 -27
- package/dist/data-access/manage/triggers.d.ts +5 -5
- package/dist/data-access/runtime/apiKeys.d.ts +20 -20
- package/dist/data-access/runtime/apps.d.ts +17 -17
- package/dist/data-access/runtime/conversations.d.ts +32 -32
- package/dist/data-access/runtime/evalRuns.d.ts +47 -6
- package/dist/data-access/runtime/evalRuns.js +96 -6
- package/dist/data-access/runtime/events.d.ts +3 -3
- package/dist/data-access/runtime/feedback.d.ts +6 -6
- package/dist/data-access/runtime/messages.d.ts +24 -24
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +5 -5
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +2 -2
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/db/manage/manage-schema.d.ts +505 -505
- package/dist/db/runtime/runtime-schema.d.ts +452 -452
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/utils/error.d.ts +51 -51
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas/shared.d.ts +1 -0
- package/dist/validation/schemas/shared.js +2 -1
- package/dist/validation/schemas/skills.d.ts +28 -27
- package/dist/validation/schemas.d.ts +2352 -2324
- package/package.json +1 -1
|
@@ -9,48 +9,48 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
|
-
tenantId: string;
|
|
13
|
-
createdAt: string;
|
|
14
12
|
name: string | null;
|
|
15
|
-
|
|
16
|
-
projectId: string;
|
|
13
|
+
createdAt: string;
|
|
17
14
|
updatedAt: string;
|
|
18
15
|
expiresAt: string | null;
|
|
19
|
-
|
|
16
|
+
projectId: string;
|
|
17
|
+
tenantId: string;
|
|
18
|
+
agentId: string;
|
|
20
19
|
publicId: string;
|
|
21
20
|
keyHash: string;
|
|
22
21
|
keyPrefix: string;
|
|
22
|
+
lastUsedAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
25
|
id: string;
|
|
26
|
-
tenantId: string;
|
|
27
|
-
createdAt: string;
|
|
28
26
|
name: string | null;
|
|
29
|
-
|
|
30
|
-
projectId: string;
|
|
27
|
+
createdAt: string;
|
|
31
28
|
updatedAt: string;
|
|
32
29
|
expiresAt: string | null;
|
|
33
|
-
|
|
30
|
+
projectId: string;
|
|
31
|
+
tenantId: string;
|
|
32
|
+
agentId: string;
|
|
34
33
|
publicId: string;
|
|
35
34
|
keyHash: string;
|
|
36
35
|
keyPrefix: string;
|
|
36
|
+
lastUsedAt: string | null;
|
|
37
37
|
} | undefined>;
|
|
38
38
|
declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
40
40
|
agentId?: string;
|
|
41
41
|
}) => Promise<{
|
|
42
42
|
id: string;
|
|
43
|
-
tenantId: string;
|
|
44
|
-
createdAt: string;
|
|
45
43
|
name: string | null;
|
|
46
|
-
|
|
47
|
-
projectId: string;
|
|
44
|
+
createdAt: string;
|
|
48
45
|
updatedAt: string;
|
|
49
46
|
expiresAt: string | null;
|
|
50
|
-
|
|
47
|
+
projectId: string;
|
|
48
|
+
tenantId: string;
|
|
49
|
+
agentId: string;
|
|
51
50
|
publicId: string;
|
|
52
51
|
keyHash: string;
|
|
53
52
|
keyPrefix: string;
|
|
53
|
+
lastUsedAt: string | null;
|
|
54
54
|
}[]>;
|
|
55
55
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
@@ -67,17 +67,17 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
69
|
id: string;
|
|
70
|
-
tenantId: string;
|
|
71
|
-
createdAt: string;
|
|
72
70
|
name: string | null;
|
|
73
|
-
|
|
74
|
-
projectId: string;
|
|
71
|
+
createdAt: string;
|
|
75
72
|
updatedAt: string;
|
|
76
73
|
expiresAt: string | null;
|
|
77
|
-
|
|
74
|
+
projectId: string;
|
|
75
|
+
tenantId: string;
|
|
76
|
+
agentId: string;
|
|
78
77
|
publicId: string;
|
|
79
78
|
keyHash: string;
|
|
80
79
|
keyPrefix: string;
|
|
80
|
+
lastUsedAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -7,13 +7,14 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
8
|
type: AppType;
|
|
9
9
|
id: string;
|
|
10
|
-
tenantId: string | null;
|
|
11
|
-
createdAt: string;
|
|
12
10
|
name: string;
|
|
13
|
-
|
|
14
|
-
projectId: string | null;
|
|
11
|
+
createdAt: string;
|
|
15
12
|
updatedAt: string;
|
|
13
|
+
description: string | null;
|
|
16
14
|
enabled: boolean;
|
|
15
|
+
projectId: string | null;
|
|
16
|
+
tenantId: string | null;
|
|
17
|
+
prompt: string | null;
|
|
17
18
|
config: {
|
|
18
19
|
type: "web_client";
|
|
19
20
|
webClient: {
|
|
@@ -21,7 +22,7 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
21
22
|
publicKeys: {
|
|
22
23
|
kid: string;
|
|
23
24
|
publicKey: string;
|
|
24
|
-
algorithm: "
|
|
25
|
+
algorithm: "EdDSA" | "ES256" | "ES512" | "RS256" | "RS384" | "RS512" | "ES384";
|
|
25
26
|
addedAt: string;
|
|
26
27
|
}[];
|
|
27
28
|
allowAnonymous: boolean;
|
|
@@ -44,10 +45,9 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
44
45
|
}[] | undefined;
|
|
45
46
|
};
|
|
46
47
|
};
|
|
47
|
-
prompt: string | null;
|
|
48
|
-
defaultAgentId: string | null;
|
|
49
|
-
defaultProjectId: string | null;
|
|
50
48
|
lastUsedAt: string | null;
|
|
49
|
+
defaultProjectId: string | null;
|
|
50
|
+
defaultAgentId: string | null;
|
|
51
51
|
} | undefined>;
|
|
52
52
|
declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
|
|
53
53
|
declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -76,13 +76,14 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
76
76
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
77
77
|
type: AppType;
|
|
78
78
|
id: string;
|
|
79
|
-
tenantId: string | null;
|
|
80
|
-
createdAt: string;
|
|
81
79
|
name: string;
|
|
82
|
-
|
|
83
|
-
projectId: string | null;
|
|
80
|
+
createdAt: string;
|
|
84
81
|
updatedAt: string;
|
|
82
|
+
description: string | null;
|
|
85
83
|
enabled: boolean;
|
|
84
|
+
projectId: string | null;
|
|
85
|
+
tenantId: string | null;
|
|
86
|
+
prompt: string | null;
|
|
86
87
|
config: {
|
|
87
88
|
type: "web_client";
|
|
88
89
|
webClient: {
|
|
@@ -90,7 +91,7 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
90
91
|
publicKeys: {
|
|
91
92
|
kid: string;
|
|
92
93
|
publicKey: string;
|
|
93
|
-
algorithm: "
|
|
94
|
+
algorithm: "EdDSA" | "ES256" | "ES512" | "RS256" | "RS384" | "RS512" | "ES384";
|
|
94
95
|
addedAt: string;
|
|
95
96
|
}[];
|
|
96
97
|
allowAnonymous: boolean;
|
|
@@ -113,10 +114,9 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
113
114
|
}[] | undefined;
|
|
114
115
|
};
|
|
115
116
|
};
|
|
116
|
-
prompt: string | null;
|
|
117
|
-
defaultAgentId: string | null;
|
|
118
|
-
defaultProjectId: string | null;
|
|
119
117
|
lastUsedAt: string | null;
|
|
118
|
+
defaultProjectId: string | null;
|
|
119
|
+
defaultAgentId: string | null;
|
|
120
120
|
}>;
|
|
121
121
|
declare const updateAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
122
122
|
scopes: TenantScopeConfig;
|
|
@@ -174,7 +174,7 @@ declare const updateApp: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
174
174
|
publicKeys: {
|
|
175
175
|
kid: string;
|
|
176
176
|
publicKey: string;
|
|
177
|
-
algorithm: "
|
|
177
|
+
algorithm: "EdDSA" | "ES256" | "ES512" | "RS256" | "RS384" | "RS512" | "ES384";
|
|
178
178
|
addedAt: string;
|
|
179
179
|
}[];
|
|
180
180
|
allowAnonymous: boolean;
|
|
@@ -17,23 +17,23 @@ 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
20
|
createdAt: string;
|
|
22
|
-
|
|
23
|
-
title: string | null;
|
|
24
|
-
properties: Record<string, unknown> | null;
|
|
21
|
+
updatedAt: string;
|
|
25
22
|
ref: {
|
|
26
23
|
type: "commit" | "tag" | "branch";
|
|
27
24
|
name: string;
|
|
28
25
|
hash: string;
|
|
29
26
|
} | null;
|
|
30
|
-
agentId: string | null;
|
|
31
|
-
projectId: string;
|
|
32
|
-
updatedAt: string;
|
|
33
27
|
userId: string | null;
|
|
28
|
+
metadata: ConversationMetadata | null;
|
|
29
|
+
projectId: string;
|
|
30
|
+
tenantId: string;
|
|
31
|
+
properties: Record<string, unknown> | null;
|
|
32
|
+
title: string | null;
|
|
33
|
+
agentId: string | null;
|
|
34
|
+
userProperties: Record<string, unknown> | null;
|
|
34
35
|
activeSubAgentId: string;
|
|
35
36
|
lastContextResolution: string | null;
|
|
36
|
-
userProperties: Record<string, unknown> | null;
|
|
37
37
|
}>;
|
|
38
38
|
declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
@@ -92,23 +92,23 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
92
92
|
conversationId: string;
|
|
93
93
|
}) => Promise<{
|
|
94
94
|
id: string;
|
|
95
|
-
tenantId: string;
|
|
96
95
|
createdAt: string;
|
|
97
|
-
|
|
98
|
-
title: string | null;
|
|
99
|
-
properties: Record<string, unknown> | null;
|
|
96
|
+
updatedAt: string;
|
|
100
97
|
ref: {
|
|
101
98
|
type: "commit" | "tag" | "branch";
|
|
102
99
|
name: string;
|
|
103
100
|
hash: string;
|
|
104
101
|
} | null;
|
|
105
|
-
agentId: string | null;
|
|
106
|
-
projectId: string;
|
|
107
|
-
updatedAt: string;
|
|
108
102
|
userId: string | null;
|
|
103
|
+
metadata: ConversationMetadata | null;
|
|
104
|
+
projectId: string;
|
|
105
|
+
tenantId: string;
|
|
106
|
+
properties: Record<string, unknown> | null;
|
|
107
|
+
title: string | null;
|
|
108
|
+
agentId: string | null;
|
|
109
|
+
userProperties: Record<string, unknown> | null;
|
|
109
110
|
activeSubAgentId: string;
|
|
110
111
|
lastContextResolution: string | null;
|
|
111
|
-
userProperties: Record<string, unknown> | null;
|
|
112
112
|
} | undefined>;
|
|
113
113
|
/**
|
|
114
114
|
* Batch-fetch conversations by id within a project scope.
|
|
@@ -147,23 +147,23 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
147
147
|
properties?: Record<string, unknown> | null | undefined;
|
|
148
148
|
} | {
|
|
149
149
|
id: string;
|
|
150
|
-
tenantId: string;
|
|
151
150
|
createdAt: string;
|
|
152
|
-
|
|
153
|
-
title: string | null;
|
|
154
|
-
properties: Record<string, unknown> | null;
|
|
151
|
+
updatedAt: string;
|
|
155
152
|
ref: {
|
|
156
153
|
type: "commit" | "tag" | "branch";
|
|
157
154
|
name: string;
|
|
158
155
|
hash: string;
|
|
159
156
|
} | null;
|
|
160
|
-
agentId: string | null;
|
|
161
|
-
projectId: string;
|
|
162
|
-
updatedAt: string;
|
|
163
157
|
userId: string | null;
|
|
158
|
+
metadata: ConversationMetadata | null;
|
|
159
|
+
projectId: string;
|
|
160
|
+
tenantId: string;
|
|
161
|
+
properties: Record<string, unknown> | null;
|
|
162
|
+
title: string | null;
|
|
163
|
+
agentId: string | null;
|
|
164
|
+
userProperties: Record<string, unknown> | null;
|
|
164
165
|
activeSubAgentId: string;
|
|
165
166
|
lastContextResolution: string | null;
|
|
166
|
-
userProperties: Record<string, unknown> | null;
|
|
167
167
|
}>;
|
|
168
168
|
/**
|
|
169
169
|
* Extract text content from message content object
|
|
@@ -185,23 +185,23 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
185
185
|
conversationId: string;
|
|
186
186
|
}) => Promise<{
|
|
187
187
|
id: string;
|
|
188
|
-
tenantId: string;
|
|
189
188
|
createdAt: string;
|
|
190
|
-
|
|
191
|
-
title: string | null;
|
|
192
|
-
properties: Record<string, unknown> | null;
|
|
189
|
+
updatedAt: string;
|
|
193
190
|
ref: {
|
|
194
191
|
type: "commit" | "tag" | "branch";
|
|
195
192
|
name: string;
|
|
196
193
|
hash: string;
|
|
197
194
|
} | null;
|
|
198
|
-
agentId: string | null;
|
|
199
|
-
projectId: string;
|
|
200
|
-
updatedAt: string;
|
|
201
195
|
userId: string | null;
|
|
196
|
+
metadata: ConversationMetadata | null;
|
|
197
|
+
projectId: string;
|
|
198
|
+
tenantId: string;
|
|
199
|
+
properties: Record<string, unknown> | null;
|
|
200
|
+
title: string | null;
|
|
201
|
+
agentId: string | null;
|
|
202
|
+
userProperties: Record<string, unknown> | null;
|
|
202
203
|
activeSubAgentId: string;
|
|
203
204
|
lastContextResolution: string | null;
|
|
204
|
-
userProperties: Record<string, unknown> | null;
|
|
205
205
|
} | undefined>;
|
|
206
206
|
/**
|
|
207
207
|
* Set active agent for a conversation (upsert operation)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
2
|
-
import { EvaluationJobFilterCriteria, Filter } from "../../types/utility.js";
|
|
2
|
+
import { EvaluationJobFilterCriteria, Filter, MessageContent } from "../../types/utility.js";
|
|
3
3
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
4
4
|
import { ConversationSelect, DatasetRunConversationRelationInsert, DatasetRunConversationRelationSelect, DatasetRunInsert, DatasetRunSelect, EvaluationResultInsert, EvaluationResultSelect, EvaluationResultUpdate, EvaluationRunInsert, EvaluationRunSelect, EvaluationRunUpdate } from "../../types/entities.js";
|
|
5
5
|
|
|
@@ -12,6 +12,10 @@ declare const getDatasetRunById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
12
12
|
declare const listDatasetRuns: (db: AgentsRunDatabaseClient) => (params: {
|
|
13
13
|
scopes: ProjectScopeConfig;
|
|
14
14
|
}) => Promise<DatasetRunSelect[]>;
|
|
15
|
+
declare const getDatasetRunsByIds: (db: AgentsRunDatabaseClient) => (params: {
|
|
16
|
+
scopes: ProjectScopeConfig;
|
|
17
|
+
datasetRunIds: string[];
|
|
18
|
+
}) => Promise<DatasetRunSelect[]>;
|
|
15
19
|
declare const listDatasetRunsByConfig: (db: AgentsRunDatabaseClient) => (params: {
|
|
16
20
|
scopes: ProjectScopeConfig & {
|
|
17
21
|
datasetRunConfigId: string;
|
|
@@ -58,10 +62,6 @@ declare const listEvaluationRunsByJobConfigId: (db: AgentsRunDatabaseClient) =>
|
|
|
58
62
|
scopes: ProjectScopeConfig;
|
|
59
63
|
evaluationJobConfigId: string;
|
|
60
64
|
}) => Promise<EvaluationRunSelect[]>;
|
|
61
|
-
declare const listEvaluationRunsByRunConfigId: (db: AgentsRunDatabaseClient) => (params: {
|
|
62
|
-
scopes: ProjectScopeConfig;
|
|
63
|
-
evaluationRunConfigId: string;
|
|
64
|
-
}) => Promise<EvaluationRunSelect[]>;
|
|
65
65
|
declare const getEvaluationRunByJobConfigId: (db: AgentsRunDatabaseClient) => (params: {
|
|
66
66
|
scopes: ProjectScopeConfig;
|
|
67
67
|
evaluationJobConfigId: string;
|
|
@@ -91,6 +91,47 @@ declare const listEvaluationResultsByRun: (db: AgentsRunDatabaseClient) => (para
|
|
|
91
91
|
evaluationRunId: string;
|
|
92
92
|
};
|
|
93
93
|
}) => Promise<EvaluationResultSelect[]>;
|
|
94
|
+
interface EvalResultsFilter {
|
|
95
|
+
evaluatorId?: string;
|
|
96
|
+
agentId?: string;
|
|
97
|
+
}
|
|
98
|
+
interface EvalResultsPagination {
|
|
99
|
+
page: number;
|
|
100
|
+
limit: number;
|
|
101
|
+
}
|
|
102
|
+
interface EnrichedEvaluationResult {
|
|
103
|
+
id: string;
|
|
104
|
+
tenantId: string;
|
|
105
|
+
projectId: string;
|
|
106
|
+
conversationId: string;
|
|
107
|
+
evaluatorId: string;
|
|
108
|
+
evaluationRunId: string | null;
|
|
109
|
+
output: MessageContent | null;
|
|
110
|
+
createdAt: string;
|
|
111
|
+
updatedAt: string;
|
|
112
|
+
input: string | null;
|
|
113
|
+
agentId: string | null;
|
|
114
|
+
conversationCreatedAt: string | null;
|
|
115
|
+
}
|
|
116
|
+
interface PaginatedEvalResults {
|
|
117
|
+
data: EnrichedEvaluationResult[];
|
|
118
|
+
pagination: {
|
|
119
|
+
page: number;
|
|
120
|
+
limit: number;
|
|
121
|
+
total: number;
|
|
122
|
+
pages: number;
|
|
123
|
+
completedCount: number;
|
|
124
|
+
};
|
|
125
|
+
distinctAgentIds: string[];
|
|
126
|
+
distinctOutputKeys: string[];
|
|
127
|
+
}
|
|
128
|
+
declare const listEvaluationResultsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
129
|
+
scopes: ProjectScopeConfig;
|
|
130
|
+
evaluationRunConfigId?: string;
|
|
131
|
+
evaluationJobConfigId?: string;
|
|
132
|
+
filters?: EvalResultsFilter;
|
|
133
|
+
pagination?: EvalResultsPagination;
|
|
134
|
+
}) => Promise<PaginatedEvalResults>;
|
|
94
135
|
declare const listEvaluationResultsByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
95
136
|
scopes: ProjectScopeConfig & {
|
|
96
137
|
conversationId: string;
|
|
@@ -122,4 +163,4 @@ declare const filterConversationsForJob: (db: AgentsRunDatabaseClient) => (param
|
|
|
122
163
|
jobFilters: Filter<EvaluationJobFilterCriteria> | null | undefined;
|
|
123
164
|
}) => Promise<ConversationSelect[]>;
|
|
124
165
|
//#endregion
|
|
125
|
-
export { createDatasetRun, createDatasetRunConversationRelation, createDatasetRunConversationRelations, createEvaluationResult, createEvaluationResults, createEvaluationRun, deleteDatasetRun, deleteDatasetRunConversationRelation, deleteDatasetRunConversationRelationsByRun, deleteEvaluationResult, deleteEvaluationResultsByRun, deleteEvaluationRun, filterConversationsForJob, getDatasetRunById, getDatasetRunConversationRelationByConversation, getDatasetRunConversationRelations, getEvaluationResultById, getEvaluationRunById, getEvaluationRunByJobConfigId, listDatasetRuns, listDatasetRunsByConfig, listEvaluationResults, listEvaluationResultsByConversation, listEvaluationResultsByRun, listEvaluationRuns, listEvaluationRunsByJobConfigId,
|
|
166
|
+
export { EnrichedEvaluationResult, EvalResultsFilter, EvalResultsPagination, PaginatedEvalResults, createDatasetRun, createDatasetRunConversationRelation, createDatasetRunConversationRelations, createEvaluationResult, createEvaluationResults, createEvaluationRun, deleteDatasetRun, deleteDatasetRunConversationRelation, deleteDatasetRunConversationRelationsByRun, deleteEvaluationResult, deleteEvaluationResultsByRun, deleteEvaluationRun, filterConversationsForJob, getDatasetRunById, getDatasetRunConversationRelationByConversation, getDatasetRunConversationRelations, getDatasetRunsByIds, getEvaluationResultById, getEvaluationRunById, getEvaluationRunByJobConfigId, listDatasetRuns, listDatasetRunsByConfig, listEvaluationResults, listEvaluationResultsByConversation, listEvaluationResultsByRun, listEvaluationResultsPaginated, listEvaluationRuns, listEvaluationRunsByJobConfigId, updateEvaluationResult, updateEvaluationRun };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { conversations, datasetRun, datasetRunConversationRelations, evaluationResult, evaluationRun } from "../../db/runtime/runtime-schema.js";
|
|
1
|
+
import { conversations, datasetRun, datasetRunConversationRelations, evaluationResult, evaluationRun, messages } from "../../db/runtime/runtime-schema.js";
|
|
2
2
|
import { projectScopedWhere } from "../manage/scope-helpers.js";
|
|
3
|
-
import { and, desc, eq, gte, inArray, lte } from "drizzle-orm";
|
|
3
|
+
import { and, asc, count, desc, eq, gte, inArray, lte, sql } from "drizzle-orm";
|
|
4
4
|
|
|
5
5
|
//#region src/data-access/runtime/evalRuns.ts
|
|
6
6
|
const getDatasetRunById = (db) => async (params) => {
|
|
@@ -9,6 +9,10 @@ const getDatasetRunById = (db) => async (params) => {
|
|
|
9
9
|
const listDatasetRuns = (db) => async (params) => {
|
|
10
10
|
return await db.select().from(datasetRun).where(projectScopedWhere(datasetRun, params.scopes)).orderBy(desc(datasetRun.createdAt));
|
|
11
11
|
};
|
|
12
|
+
const getDatasetRunsByIds = (db) => async (params) => {
|
|
13
|
+
if (params.datasetRunIds.length === 0) return [];
|
|
14
|
+
return await db.select().from(datasetRun).where(and(projectScopedWhere(datasetRun, params.scopes), inArray(datasetRun.id, params.datasetRunIds)));
|
|
15
|
+
};
|
|
12
16
|
const listDatasetRunsByConfig = (db) => async (params) => {
|
|
13
17
|
return await db.select().from(datasetRun).where(and(projectScopedWhere(datasetRun, params.scopes), eq(datasetRun.datasetRunConfigId, params.scopes.datasetRunConfigId))).orderBy(desc(datasetRun.createdAt));
|
|
14
18
|
};
|
|
@@ -63,9 +67,6 @@ const listEvaluationRuns = (db) => async (params) => {
|
|
|
63
67
|
const listEvaluationRunsByJobConfigId = (db) => async (params) => {
|
|
64
68
|
return await db.select().from(evaluationRun).where(and(projectScopedWhere(evaluationRun, params.scopes), eq(evaluationRun.evaluationJobConfigId, params.evaluationJobConfigId)));
|
|
65
69
|
};
|
|
66
|
-
const listEvaluationRunsByRunConfigId = (db) => async (params) => {
|
|
67
|
-
return await db.select().from(evaluationRun).where(and(projectScopedWhere(evaluationRun, params.scopes), eq(evaluationRun.evaluationRunConfigId, params.evaluationRunConfigId)));
|
|
68
|
-
};
|
|
69
70
|
const getEvaluationRunByJobConfigId = (db) => async (params) => {
|
|
70
71
|
return (await db.select().from(evaluationRun).where(and(projectScopedWhere(evaluationRun, params.scopes), eq(evaluationRun.evaluationJobConfigId, params.evaluationJobConfigId))).limit(1))[0] ?? null;
|
|
71
72
|
};
|
|
@@ -96,6 +97,95 @@ const listEvaluationResults = (db) => async (params) => {
|
|
|
96
97
|
const listEvaluationResultsByRun = (db) => async (params) => {
|
|
97
98
|
return await db.query.evaluationResult.findMany({ where: and(projectScopedWhere(evaluationResult, params.scopes), eq(evaluationResult.evaluationRunId, params.scopes.evaluationRunId)) });
|
|
98
99
|
};
|
|
100
|
+
const EVAL_RESULTS_MAX_ROWS = 2e4;
|
|
101
|
+
function buildFirstUserMessageSubquery(db) {
|
|
102
|
+
return db.selectDistinctOn([messages.conversationId], {
|
|
103
|
+
conversationId: messages.conversationId,
|
|
104
|
+
content: messages.content
|
|
105
|
+
}).from(messages).where(eq(messages.role, "user")).orderBy(messages.conversationId, asc(messages.createdAt), asc(messages.id)).as("first_msg");
|
|
106
|
+
}
|
|
107
|
+
function buildEvalResultsBaseQuery(db, params) {
|
|
108
|
+
const runWhereConditions = [projectScopedWhere(evaluationRun, params.scopes)];
|
|
109
|
+
if (params.evaluationRunConfigId) runWhereConditions.push(eq(evaluationRun.evaluationRunConfigId, params.evaluationRunConfigId));
|
|
110
|
+
if (params.evaluationJobConfigId) runWhereConditions.push(eq(evaluationRun.evaluationJobConfigId, params.evaluationJobConfigId));
|
|
111
|
+
const runIdSubquery = db.select({ id: evaluationRun.id }).from(evaluationRun).where(and(...runWhereConditions));
|
|
112
|
+
const whereConditions = [projectScopedWhere(evaluationResult, params.scopes), inArray(evaluationResult.evaluationRunId, runIdSubquery)];
|
|
113
|
+
if (params.filters?.evaluatorId) whereConditions.push(eq(evaluationResult.evaluatorId, params.filters.evaluatorId));
|
|
114
|
+
if (params.filters?.agentId) whereConditions.push(eq(conversations.agentId, params.filters.agentId));
|
|
115
|
+
return { whereConditions };
|
|
116
|
+
}
|
|
117
|
+
const listEvaluationResultsPaginated = (db) => async (params) => {
|
|
118
|
+
const page = params.pagination?.page ?? 1;
|
|
119
|
+
const limit = Math.min(params.pagination?.limit ?? 50, EVAL_RESULTS_MAX_ROWS);
|
|
120
|
+
const offset = (page - 1) * limit;
|
|
121
|
+
const { whereConditions } = buildEvalResultsBaseQuery(db, {
|
|
122
|
+
scopes: params.scopes,
|
|
123
|
+
evaluationRunConfigId: params.evaluationRunConfigId,
|
|
124
|
+
evaluationJobConfigId: params.evaluationJobConfigId,
|
|
125
|
+
filters: params.filters
|
|
126
|
+
});
|
|
127
|
+
const conversationsJoin = and(eq(evaluationResult.conversationId, conversations.id), eq(evaluationResult.tenantId, conversations.tenantId), eq(evaluationResult.projectId, conversations.projectId));
|
|
128
|
+
const firstMsg = buildFirstUserMessageSubquery(db);
|
|
129
|
+
const [countResult, rows, agentIdRows, outputKeyRows] = await Promise.all([
|
|
130
|
+
db.select({
|
|
131
|
+
total: count(),
|
|
132
|
+
completedCount: count(evaluationResult.output)
|
|
133
|
+
}).from(evaluationResult).leftJoin(conversations, conversationsJoin).where(and(...whereConditions)),
|
|
134
|
+
db.select({
|
|
135
|
+
id: evaluationResult.id,
|
|
136
|
+
tenantId: evaluationResult.tenantId,
|
|
137
|
+
projectId: evaluationResult.projectId,
|
|
138
|
+
conversationId: evaluationResult.conversationId,
|
|
139
|
+
evaluatorId: evaluationResult.evaluatorId,
|
|
140
|
+
evaluationRunId: evaluationResult.evaluationRunId,
|
|
141
|
+
output: evaluationResult.output,
|
|
142
|
+
createdAt: evaluationResult.createdAt,
|
|
143
|
+
updatedAt: evaluationResult.updatedAt,
|
|
144
|
+
agentId: conversations.agentId,
|
|
145
|
+
conversationCreatedAt: conversations.createdAt,
|
|
146
|
+
firstMsgContent: firstMsg.content
|
|
147
|
+
}).from(evaluationResult).leftJoin(conversations, conversationsJoin).leftJoin(firstMsg, eq(evaluationResult.conversationId, firstMsg.conversationId)).where(and(...whereConditions)).orderBy(desc(evaluationResult.createdAt)).limit(limit).offset(offset),
|
|
148
|
+
db.selectDistinct({ agentId: conversations.agentId }).from(evaluationResult).leftJoin(conversations, conversationsJoin).where(and(...whereConditions)),
|
|
149
|
+
db.select({ key: sql`jsonb_object_keys(${evaluationResult.output}->'output')` }).from(evaluationResult).leftJoin(conversations, conversationsJoin).where(and(...whereConditions, sql`jsonb_typeof(${evaluationResult.output}->'output') = 'object'`)).groupBy(sql`jsonb_object_keys(${evaluationResult.output}->'output')`)
|
|
150
|
+
]);
|
|
151
|
+
const total = countResult[0]?.total ?? 0;
|
|
152
|
+
const completedCount = countResult[0]?.completedCount ?? 0;
|
|
153
|
+
const distinctAgentIds = agentIdRows.map((r) => r.agentId).filter((id) => id != null).sort();
|
|
154
|
+
const distinctOutputKeys = outputKeyRows.map((r) => `output.${r.key}`).sort();
|
|
155
|
+
return {
|
|
156
|
+
data: rows.map((row) => {
|
|
157
|
+
let input = null;
|
|
158
|
+
if (row.firstMsgContent) {
|
|
159
|
+
const content = row.firstMsgContent;
|
|
160
|
+
if (content.text) input = content.text;
|
|
161
|
+
else if (content.parts) input = content.parts.filter((part) => part.kind === "text" && part.text).map((part) => part.text).join(" ") || null;
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
id: row.id,
|
|
165
|
+
tenantId: row.tenantId,
|
|
166
|
+
projectId: row.projectId,
|
|
167
|
+
conversationId: row.conversationId,
|
|
168
|
+
evaluatorId: row.evaluatorId,
|
|
169
|
+
evaluationRunId: row.evaluationRunId,
|
|
170
|
+
output: row.output,
|
|
171
|
+
createdAt: row.createdAt,
|
|
172
|
+
updatedAt: row.updatedAt,
|
|
173
|
+
input,
|
|
174
|
+
agentId: row.agentId ?? null,
|
|
175
|
+
conversationCreatedAt: row.conversationCreatedAt ?? null
|
|
176
|
+
};
|
|
177
|
+
}),
|
|
178
|
+
pagination: {
|
|
179
|
+
page,
|
|
180
|
+
limit,
|
|
181
|
+
total,
|
|
182
|
+
pages: Math.ceil(total / limit),
|
|
183
|
+
completedCount
|
|
184
|
+
},
|
|
185
|
+
distinctAgentIds,
|
|
186
|
+
distinctOutputKeys
|
|
187
|
+
};
|
|
188
|
+
};
|
|
99
189
|
const listEvaluationResultsByConversation = (db) => async (params) => {
|
|
100
190
|
return await db.query.evaluationResult.findMany({ where: and(projectScopedWhere(evaluationResult, params.scopes), eq(evaluationResult.conversationId, params.scopes.conversationId)) });
|
|
101
191
|
};
|
|
@@ -169,4 +259,4 @@ const filterConversationsForJob = (db) => async (params) => {
|
|
|
169
259
|
};
|
|
170
260
|
|
|
171
261
|
//#endregion
|
|
172
|
-
export { createDatasetRun, createDatasetRunConversationRelation, createDatasetRunConversationRelations, createEvaluationResult, createEvaluationResults, createEvaluationRun, deleteDatasetRun, deleteDatasetRunConversationRelation, deleteDatasetRunConversationRelationsByRun, deleteEvaluationResult, deleteEvaluationResultsByRun, deleteEvaluationRun, filterConversationsForJob, getDatasetRunById, getDatasetRunConversationRelationByConversation, getDatasetRunConversationRelations, getEvaluationResultById, getEvaluationRunById, getEvaluationRunByJobConfigId, listDatasetRuns, listDatasetRunsByConfig, listEvaluationResults, listEvaluationResultsByConversation, listEvaluationResultsByRun, listEvaluationRuns, listEvaluationRunsByJobConfigId,
|
|
262
|
+
export { createDatasetRun, createDatasetRunConversationRelation, createDatasetRunConversationRelations, createEvaluationResult, createEvaluationResults, createEvaluationRun, deleteDatasetRun, deleteDatasetRunConversationRelation, deleteDatasetRunConversationRelationsByRun, deleteEvaluationResult, deleteEvaluationResultsByRun, deleteEvaluationRun, filterConversationsForJob, getDatasetRunById, getDatasetRunConversationRelationByConversation, getDatasetRunConversationRelations, getDatasetRunsByIds, getEvaluationResultById, getEvaluationRunById, getEvaluationRunByJobConfigId, listDatasetRuns, listDatasetRunsByConfig, listEvaluationResults, listEvaluationResultsByConversation, listEvaluationResultsByRun, listEvaluationResultsPaginated, listEvaluationRuns, listEvaluationRunsByJobConfigId, updateEvaluationResult, updateEvaluationRun };
|
|
@@ -9,13 +9,13 @@ declare const createEvent: (db: AgentsRunDatabaseClient) => (params: EventInsert
|
|
|
9
9
|
row: {
|
|
10
10
|
type: string;
|
|
11
11
|
id: string;
|
|
12
|
-
tenantId: string;
|
|
13
12
|
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
14
|
metadata: Record<string, unknown> | null;
|
|
15
|
+
projectId: string;
|
|
16
|
+
tenantId: string;
|
|
15
17
|
properties: Record<string, unknown> | null;
|
|
16
18
|
agentId: string | null;
|
|
17
|
-
projectId: string;
|
|
18
|
-
updatedAt: string;
|
|
19
19
|
conversationId: string | null;
|
|
20
20
|
userProperties: Record<string, unknown> | null;
|
|
21
21
|
messageId: string | null;
|
|
@@ -72,13 +72,13 @@ declare const getFeedbackByIds: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
72
72
|
declare const createFeedback: (db: AgentsRunDatabaseClient) => (params: FeedbackInsert) => Promise<{
|
|
73
73
|
type: "positive" | "negative";
|
|
74
74
|
id: string;
|
|
75
|
-
tenantId: string;
|
|
76
75
|
createdAt: string;
|
|
77
|
-
projectId: string;
|
|
78
76
|
updatedAt: string;
|
|
77
|
+
projectId: string;
|
|
78
|
+
tenantId: string;
|
|
79
|
+
details: string | null;
|
|
79
80
|
conversationId: string;
|
|
80
81
|
messageId: string | null;
|
|
81
|
-
details: string | null;
|
|
82
82
|
}>;
|
|
83
83
|
declare const createFeedbackBulk: (db: AgentsRunDatabaseClient) => (items: FeedbackInsert[]) => Promise<(typeof feedback.$inferSelect)[]>;
|
|
84
84
|
declare const updateFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -102,13 +102,13 @@ declare const deleteFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
102
102
|
}) => Promise<{
|
|
103
103
|
type: "positive" | "negative";
|
|
104
104
|
id: string;
|
|
105
|
-
tenantId: string;
|
|
106
105
|
createdAt: string;
|
|
107
|
-
projectId: string;
|
|
108
106
|
updatedAt: string;
|
|
107
|
+
projectId: string;
|
|
108
|
+
tenantId: string;
|
|
109
|
+
details: string | null;
|
|
109
110
|
conversationId: string;
|
|
110
111
|
messageId: string | null;
|
|
111
|
-
details: string | null;
|
|
112
112
|
}>;
|
|
113
113
|
//#endregion
|
|
114
114
|
export { createFeedback, createFeedbackBulk, deleteFeedback, getFeedbackById, getFeedbackByIds, listFeedback, listFeedbackByConversation, updateFeedback };
|
|
@@ -11,27 +11,27 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
13
|
id: string;
|
|
14
|
-
tenantId: string;
|
|
15
14
|
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
16
|
metadata: MessageMetadata | null;
|
|
17
|
-
|
|
17
|
+
role: string;
|
|
18
18
|
content: MessageContent;
|
|
19
19
|
projectId: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
userProperties: Record<string, unknown> | null;
|
|
23
|
-
role: string;
|
|
20
|
+
tenantId: string;
|
|
21
|
+
properties: Record<string, unknown> | null;
|
|
24
22
|
fromSubAgentId: string | null;
|
|
25
23
|
toSubAgentId: string | null;
|
|
26
24
|
fromExternalAgentId: string | null;
|
|
27
25
|
toExternalAgentId: string | null;
|
|
26
|
+
taskId: string | null;
|
|
27
|
+
a2aTaskId: string | null;
|
|
28
|
+
conversationId: string;
|
|
29
|
+
userProperties: Record<string, unknown> | null;
|
|
28
30
|
fromTeamAgentId: string | null;
|
|
29
31
|
toTeamAgentId: string | null;
|
|
30
32
|
visibility: string;
|
|
31
33
|
messageType: string;
|
|
32
|
-
taskId: string | null;
|
|
33
34
|
parentMessageId: string | null;
|
|
34
|
-
a2aTaskId: string | null;
|
|
35
35
|
a2aSessionId: string | null;
|
|
36
36
|
} | undefined>;
|
|
37
37
|
declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -184,27 +184,27 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
184
184
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
185
185
|
}) => Promise<{
|
|
186
186
|
id: string;
|
|
187
|
-
tenantId: string;
|
|
188
187
|
createdAt: string;
|
|
188
|
+
updatedAt: string;
|
|
189
189
|
metadata: MessageMetadata | null;
|
|
190
|
-
|
|
190
|
+
role: string;
|
|
191
191
|
content: MessageContent;
|
|
192
192
|
projectId: string;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
userProperties: Record<string, unknown> | null;
|
|
196
|
-
role: string;
|
|
193
|
+
tenantId: string;
|
|
194
|
+
properties: Record<string, unknown> | null;
|
|
197
195
|
fromSubAgentId: string | null;
|
|
198
196
|
toSubAgentId: string | null;
|
|
199
197
|
fromExternalAgentId: string | null;
|
|
200
198
|
toExternalAgentId: string | null;
|
|
199
|
+
taskId: string | null;
|
|
200
|
+
a2aTaskId: string | null;
|
|
201
|
+
conversationId: string;
|
|
202
|
+
userProperties: Record<string, unknown> | null;
|
|
201
203
|
fromTeamAgentId: string | null;
|
|
202
204
|
toTeamAgentId: string | null;
|
|
203
205
|
visibility: string;
|
|
204
206
|
messageType: string;
|
|
205
|
-
taskId: string | null;
|
|
206
207
|
parentMessageId: string | null;
|
|
207
|
-
a2aTaskId: string | null;
|
|
208
208
|
a2aSessionId: string | null;
|
|
209
209
|
}>;
|
|
210
210
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -241,27 +241,27 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
241
241
|
messageId: string;
|
|
242
242
|
}) => Promise<{
|
|
243
243
|
id: string;
|
|
244
|
-
tenantId: string;
|
|
245
244
|
createdAt: string;
|
|
245
|
+
updatedAt: string;
|
|
246
246
|
metadata: MessageMetadata | null;
|
|
247
|
-
|
|
247
|
+
role: string;
|
|
248
248
|
content: MessageContent;
|
|
249
249
|
projectId: string;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
userProperties: Record<string, unknown> | null;
|
|
253
|
-
role: string;
|
|
250
|
+
tenantId: string;
|
|
251
|
+
properties: Record<string, unknown> | null;
|
|
254
252
|
fromSubAgentId: string | null;
|
|
255
253
|
toSubAgentId: string | null;
|
|
256
254
|
fromExternalAgentId: string | null;
|
|
257
255
|
toExternalAgentId: string | null;
|
|
256
|
+
taskId: string | null;
|
|
257
|
+
a2aTaskId: string | null;
|
|
258
|
+
conversationId: string;
|
|
259
|
+
userProperties: Record<string, unknown> | null;
|
|
258
260
|
fromTeamAgentId: string | null;
|
|
259
261
|
toTeamAgentId: string | null;
|
|
260
262
|
visibility: string;
|
|
261
263
|
messageType: string;
|
|
262
|
-
taskId: string | null;
|
|
263
264
|
parentMessageId: string | null;
|
|
264
|
-
a2aTaskId: string | null;
|
|
265
265
|
a2aSessionId: string | null;
|
|
266
266
|
}>;
|
|
267
267
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|