@inkeep/agents-core 0.78.4 → 0.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth-schema.d.ts +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 +12 -12
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +26 -26
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +12 -12
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/triggers.d.ts +4 -4
- package/dist/data-access/manage/webhookDestinations.d.ts +2 -1
- 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 +5 -5
- package/dist/data-access/runtime/feedback.d.ts +8 -8
- package/dist/data-access/runtime/messages.d.ts +27 -27
- package/dist/data-access/runtime/organizations.d.ts +4 -3
- package/dist/data-access/runtime/organizations.js +5 -4
- 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 +6 -6
- package/dist/db/manage/manage-schema.d.ts +525 -506
- package/dist/db/manage/manage-schema.js +2 -1
- 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 +46 -45
- package/dist/validation/schemas.d.ts +2314 -2241
- package/dist/validation/schemas.js +6 -2
- package/drizzle/manage/0024_blue_junta.sql +2 -0
- package/drizzle/manage/meta/0024_snapshot.json +4323 -0
- package/drizzle/manage/meta/_journal.json +7 -0
- 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;
|
|
15
|
+
projectId: string;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
agentId: string;
|
|
18
18
|
expiresAt: string | null;
|
|
19
|
-
lastUsedAt: string | null;
|
|
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;
|
|
29
|
+
projectId: string;
|
|
30
|
+
tenantId: string;
|
|
31
|
+
agentId: string;
|
|
32
32
|
expiresAt: string | null;
|
|
33
|
-
lastUsedAt: string | null;
|
|
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;
|
|
46
|
+
projectId: string;
|
|
47
|
+
tenantId: string;
|
|
48
|
+
agentId: string;
|
|
49
49
|
expiresAt: string | null;
|
|
50
|
-
lastUsedAt: string | null;
|
|
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;
|
|
73
|
+
projectId: string;
|
|
74
|
+
tenantId: string;
|
|
75
|
+
agentId: string;
|
|
76
76
|
expiresAt: string | null;
|
|
77
|
-
lastUsedAt: string | null;
|
|
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;
|
|
@@ -5,15 +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
|
-
type: AppType;
|
|
9
8
|
id: string;
|
|
10
|
-
tenantId: string | null;
|
|
11
|
-
createdAt: string;
|
|
12
9
|
name: string;
|
|
13
10
|
description: string | null;
|
|
14
|
-
|
|
11
|
+
createdAt: string;
|
|
15
12
|
updatedAt: string;
|
|
13
|
+
projectId: string | null;
|
|
14
|
+
tenantId: string | null;
|
|
15
|
+
type: AppType;
|
|
16
16
|
enabled: boolean;
|
|
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: {
|
|
@@ -74,15 +74,16 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
74
74
|
};
|
|
75
75
|
}>;
|
|
76
76
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
77
|
-
type: AppType;
|
|
78
77
|
id: string;
|
|
79
|
-
tenantId: string | null;
|
|
80
|
-
createdAt: string;
|
|
81
78
|
name: string;
|
|
82
79
|
description: string | null;
|
|
83
|
-
|
|
80
|
+
createdAt: string;
|
|
84
81
|
updatedAt: string;
|
|
82
|
+
projectId: string | null;
|
|
83
|
+
tenantId: string | null;
|
|
84
|
+
type: AppType;
|
|
85
85
|
enabled: boolean;
|
|
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
|
-
createdAt: string;
|
|
22
20
|
metadata: ConversationMetadata | null;
|
|
23
|
-
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
projectId: string;
|
|
24
|
+
tenantId: string;
|
|
24
25
|
properties: Record<string, unknown> | null;
|
|
26
|
+
title: string | null;
|
|
27
|
+
agentId: string | null;
|
|
28
|
+
userId: string | null;
|
|
25
29
|
ref: {
|
|
26
30
|
type: "commit" | "tag" | "branch";
|
|
27
31
|
name: string;
|
|
28
32
|
hash: string;
|
|
29
33
|
} | null;
|
|
30
|
-
|
|
31
|
-
projectId: string;
|
|
32
|
-
updatedAt: string;
|
|
33
|
-
userId: 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
|
-
createdAt: string;
|
|
97
95
|
metadata: ConversationMetadata | null;
|
|
98
|
-
|
|
96
|
+
createdAt: string;
|
|
97
|
+
updatedAt: string;
|
|
98
|
+
projectId: string;
|
|
99
|
+
tenantId: string;
|
|
99
100
|
properties: Record<string, unknown> | null;
|
|
101
|
+
title: string | null;
|
|
102
|
+
agentId: string | null;
|
|
103
|
+
userId: string | null;
|
|
100
104
|
ref: {
|
|
101
105
|
type: "commit" | "tag" | "branch";
|
|
102
106
|
name: string;
|
|
103
107
|
hash: string;
|
|
104
108
|
} | null;
|
|
105
|
-
|
|
106
|
-
projectId: string;
|
|
107
|
-
updatedAt: string;
|
|
108
|
-
userId: 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
|
-
createdAt: string;
|
|
152
150
|
metadata: ConversationMetadata | null;
|
|
153
|
-
|
|
151
|
+
createdAt: string;
|
|
152
|
+
updatedAt: string;
|
|
153
|
+
projectId: string;
|
|
154
|
+
tenantId: string;
|
|
154
155
|
properties: Record<string, unknown> | null;
|
|
156
|
+
title: string | null;
|
|
157
|
+
agentId: string | null;
|
|
158
|
+
userId: string | null;
|
|
155
159
|
ref: {
|
|
156
160
|
type: "commit" | "tag" | "branch";
|
|
157
161
|
name: string;
|
|
158
162
|
hash: string;
|
|
159
163
|
} | null;
|
|
160
|
-
|
|
161
|
-
projectId: string;
|
|
162
|
-
updatedAt: string;
|
|
163
|
-
userId: 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
|
-
createdAt: string;
|
|
190
188
|
metadata: ConversationMetadata | null;
|
|
191
|
-
|
|
189
|
+
createdAt: string;
|
|
190
|
+
updatedAt: string;
|
|
191
|
+
projectId: string;
|
|
192
|
+
tenantId: string;
|
|
192
193
|
properties: Record<string, unknown> | null;
|
|
194
|
+
title: string | null;
|
|
195
|
+
agentId: string | null;
|
|
196
|
+
userId: string | null;
|
|
193
197
|
ref: {
|
|
194
198
|
type: "commit" | "tag" | "branch";
|
|
195
199
|
name: string;
|
|
196
200
|
hash: string;
|
|
197
201
|
} | null;
|
|
198
|
-
|
|
199
|
-
projectId: string;
|
|
200
|
-
updatedAt: string;
|
|
201
|
-
userId: 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 };
|
|
@@ -7,15 +7,15 @@ import { EventInsert } from "../../types/entities.js";
|
|
|
7
7
|
//#region src/data-access/runtime/events.d.ts
|
|
8
8
|
declare const createEvent: (db: AgentsRunDatabaseClient) => (params: EventInsert) => Promise<{
|
|
9
9
|
row: {
|
|
10
|
-
type: string;
|
|
11
10
|
id: string;
|
|
12
|
-
tenantId: string;
|
|
13
|
-
createdAt: string;
|
|
14
11
|
metadata: Record<string, unknown> | null;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
projectId: string;
|
|
15
|
+
tenantId: string;
|
|
16
|
+
type: 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;
|
|
@@ -70,15 +70,15 @@ declare const getFeedbackByIds: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
70
70
|
agentId: string | null;
|
|
71
71
|
}[]>;
|
|
72
72
|
declare const createFeedback: (db: AgentsRunDatabaseClient) => (params: FeedbackInsert) => Promise<{
|
|
73
|
-
type: "positive" | "negative";
|
|
74
73
|
id: string;
|
|
75
|
-
tenantId: string;
|
|
76
74
|
createdAt: string;
|
|
77
|
-
projectId: string;
|
|
78
75
|
updatedAt: string;
|
|
76
|
+
projectId: string;
|
|
77
|
+
tenantId: string;
|
|
78
|
+
type: "positive" | "negative";
|
|
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: {
|
|
@@ -100,15 +100,15 @@ declare const deleteFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
100
100
|
scopes: ProjectScopeConfig;
|
|
101
101
|
feedbackId: string;
|
|
102
102
|
}) => Promise<{
|
|
103
|
-
type: "positive" | "negative";
|
|
104
103
|
id: string;
|
|
105
|
-
tenantId: string;
|
|
106
104
|
createdAt: string;
|
|
107
|
-
projectId: string;
|
|
108
105
|
updatedAt: string;
|
|
106
|
+
projectId: string;
|
|
107
|
+
tenantId: string;
|
|
108
|
+
type: "positive" | "negative";
|
|
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 };
|