@inkeep/agents-core 0.77.1 → 0.78.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 +163 -163
- package/dist/auth/auth-validation-schemas.d.ts +154 -154
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/constants/models.d.ts +3 -0
- package/dist/constants/models.js +3 -0
- package/dist/data-access/index.d.ts +4 -4
- package/dist/data-access/index.js +4 -4
- package/dist/data-access/manage/agents.d.ts +16 -16
- package/dist/data-access/manage/artifactComponents.d.ts +14 -14
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +8 -8
- package/dist/data-access/manage/functionTools.d.ts +18 -18
- package/dist/data-access/manage/skills.d.ts +13 -13
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +30 -30
- 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 +30 -30
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/apps.d.ts +19 -19
- package/dist/data-access/runtime/conversations.d.ts +49 -30
- package/dist/data-access/runtime/conversations.js +16 -1
- package/dist/data-access/runtime/evalRuns.d.ts +5 -1
- package/dist/data-access/runtime/evalRuns.js +4 -1
- package/dist/data-access/runtime/events.d.ts +8 -8
- package/dist/data-access/runtime/feedback.d.ts +8 -8
- package/dist/data-access/runtime/messages.d.ts +48 -19
- package/dist/data-access/runtime/messages.js +30 -1
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +1 -1
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/db/manage/manage-schema.d.ts +379 -379
- package/dist/db/runtime/runtime-schema.d.ts +417 -417
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas/skills.d.ts +47 -47
- package/dist/validation/schemas.d.ts +2173 -2173
- package/package.json +1 -1
|
@@ -6,18 +6,13 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
6
6
|
//#region src/data-access/runtime/apps.d.ts
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
8
|
type: AppType;
|
|
9
|
+
name: string;
|
|
9
10
|
description: string | null;
|
|
10
|
-
tenantId: string | null;
|
|
11
|
-
projectId: string | null;
|
|
12
11
|
id: string;
|
|
13
|
-
name: string;
|
|
14
12
|
createdAt: string;
|
|
15
13
|
updatedAt: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
lastUsedAt: string | null;
|
|
19
|
-
defaultProjectId: string | null;
|
|
20
|
-
defaultAgentId: string | null;
|
|
14
|
+
projectId: string | null;
|
|
15
|
+
tenantId: string | null;
|
|
21
16
|
config: {
|
|
22
17
|
type: "web_client";
|
|
23
18
|
webClient: {
|
|
@@ -25,7 +20,7 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
25
20
|
publicKeys: {
|
|
26
21
|
kid: string;
|
|
27
22
|
publicKey: string;
|
|
28
|
-
algorithm: "
|
|
23
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
29
24
|
addedAt: string;
|
|
30
25
|
}[];
|
|
31
26
|
allowAnonymous: boolean;
|
|
@@ -48,6 +43,11 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
48
43
|
}[] | undefined;
|
|
49
44
|
};
|
|
50
45
|
};
|
|
46
|
+
prompt: string | null;
|
|
47
|
+
lastUsedAt: string | null;
|
|
48
|
+
defaultProjectId: string | null;
|
|
49
|
+
defaultAgentId: string | null;
|
|
50
|
+
enabled: boolean;
|
|
51
51
|
} | undefined>;
|
|
52
52
|
declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
|
|
53
53
|
declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -75,18 +75,13 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
75
75
|
}>;
|
|
76
76
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
77
77
|
type: AppType;
|
|
78
|
+
name: string;
|
|
78
79
|
description: string | null;
|
|
79
|
-
tenantId: string | null;
|
|
80
|
-
projectId: string | null;
|
|
81
80
|
id: string;
|
|
82
|
-
name: string;
|
|
83
81
|
createdAt: string;
|
|
84
82
|
updatedAt: string;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
lastUsedAt: string | null;
|
|
88
|
-
defaultProjectId: string | null;
|
|
89
|
-
defaultAgentId: string | null;
|
|
83
|
+
projectId: string | null;
|
|
84
|
+
tenantId: string | null;
|
|
90
85
|
config: {
|
|
91
86
|
type: "web_client";
|
|
92
87
|
webClient: {
|
|
@@ -94,7 +89,7 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
94
89
|
publicKeys: {
|
|
95
90
|
kid: string;
|
|
96
91
|
publicKey: string;
|
|
97
|
-
algorithm: "
|
|
92
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
98
93
|
addedAt: string;
|
|
99
94
|
}[];
|
|
100
95
|
allowAnonymous: boolean;
|
|
@@ -117,6 +112,11 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
117
112
|
}[] | undefined;
|
|
118
113
|
};
|
|
119
114
|
};
|
|
115
|
+
prompt: string | null;
|
|
116
|
+
lastUsedAt: string | null;
|
|
117
|
+
defaultProjectId: string | null;
|
|
118
|
+
defaultAgentId: string | null;
|
|
119
|
+
enabled: boolean;
|
|
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: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
178
178
|
addedAt: string;
|
|
179
179
|
}[];
|
|
180
180
|
allowAnonymous: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedRef } from "../../validation/dolt-schemas.js";
|
|
2
2
|
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
3
|
-
import { ConversationHistoryConfig, ConversationMetadata, PaginationConfig } from "../../types/utility.js";
|
|
3
|
+
import { ConversationHistoryConfig, ConversationMetadata, MessageContent, PaginationConfig } from "../../types/utility.js";
|
|
4
4
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
5
5
|
import "../../types/index.js";
|
|
6
6
|
import { ConversationInsert, ConversationSelect, ConversationUpdate, MessageSelect } from "../../types/entities.js";
|
|
@@ -16,24 +16,24 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
16
16
|
total: number;
|
|
17
17
|
}>;
|
|
18
18
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
19
|
-
properties: Record<string, unknown> | null;
|
|
20
|
-
title: string | null;
|
|
21
|
-
tenantId: string;
|
|
22
|
-
projectId: string;
|
|
23
|
-
agentId: string | null;
|
|
24
19
|
id: string;
|
|
20
|
+
agentId: string | null;
|
|
21
|
+
properties: Record<string, unknown> | null;
|
|
22
|
+
userProperties: Record<string, unknown> | null;
|
|
25
23
|
metadata: ConversationMetadata | null;
|
|
26
24
|
createdAt: string;
|
|
27
25
|
updatedAt: string;
|
|
26
|
+
projectId: string;
|
|
27
|
+
tenantId: string;
|
|
28
|
+
title: string | null;
|
|
28
29
|
userId: string | null;
|
|
30
|
+
activeSubAgentId: string;
|
|
29
31
|
ref: {
|
|
30
32
|
type: "commit" | "tag" | "branch";
|
|
31
33
|
name: string;
|
|
32
34
|
hash: string;
|
|
33
35
|
} | null;
|
|
34
|
-
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;
|
|
@@ -91,25 +91,40 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
91
91
|
scopes: ProjectScopeConfig;
|
|
92
92
|
conversationId: string;
|
|
93
93
|
}) => Promise<{
|
|
94
|
-
properties: Record<string, unknown> | null;
|
|
95
|
-
title: string | null;
|
|
96
|
-
tenantId: string;
|
|
97
|
-
projectId: string;
|
|
98
|
-
agentId: string | null;
|
|
99
94
|
id: string;
|
|
95
|
+
agentId: string | null;
|
|
96
|
+
properties: Record<string, unknown> | null;
|
|
97
|
+
userProperties: Record<string, unknown> | null;
|
|
100
98
|
metadata: ConversationMetadata | null;
|
|
101
99
|
createdAt: string;
|
|
102
100
|
updatedAt: string;
|
|
101
|
+
projectId: string;
|
|
102
|
+
tenantId: string;
|
|
103
|
+
title: string | null;
|
|
103
104
|
userId: string | null;
|
|
105
|
+
activeSubAgentId: string;
|
|
104
106
|
ref: {
|
|
105
107
|
type: "commit" | "tag" | "branch";
|
|
106
108
|
name: string;
|
|
107
109
|
hash: string;
|
|
108
110
|
} | null;
|
|
109
|
-
activeSubAgentId: string;
|
|
110
111
|
lastContextResolution: string | null;
|
|
111
|
-
userProperties: Record<string, unknown> | null;
|
|
112
112
|
} | undefined>;
|
|
113
|
+
/**
|
|
114
|
+
* Batch-fetch conversations by id within a project scope.
|
|
115
|
+
*
|
|
116
|
+
* Set-based alternative to calling {@link getConversation} once per id, so callers
|
|
117
|
+
* enriching many results (e.g. evaluation results) issue a single query instead of
|
|
118
|
+
* fanning out one connection acquisition per conversation.
|
|
119
|
+
*/
|
|
120
|
+
declare const getConversationsByIds: (db: AgentsRunDatabaseClient) => (params: {
|
|
121
|
+
scopes: ProjectScopeConfig;
|
|
122
|
+
conversationIds: string[];
|
|
123
|
+
}) => Promise<{
|
|
124
|
+
id: string;
|
|
125
|
+
agentId: string | null;
|
|
126
|
+
createdAt: string;
|
|
127
|
+
}[]>;
|
|
113
128
|
declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input: ConversationInsert) => Promise<{
|
|
114
129
|
activeSubAgentId: string;
|
|
115
130
|
projectId: string;
|
|
@@ -131,25 +146,29 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
131
146
|
userProperties?: Record<string, unknown> | null | undefined;
|
|
132
147
|
properties?: Record<string, unknown> | null | undefined;
|
|
133
148
|
} | {
|
|
134
|
-
properties: Record<string, unknown> | null;
|
|
135
|
-
title: string | null;
|
|
136
|
-
tenantId: string;
|
|
137
|
-
projectId: string;
|
|
138
|
-
agentId: string | null;
|
|
139
149
|
id: string;
|
|
150
|
+
agentId: string | null;
|
|
151
|
+
properties: Record<string, unknown> | null;
|
|
152
|
+
userProperties: Record<string, unknown> | null;
|
|
140
153
|
metadata: ConversationMetadata | null;
|
|
141
154
|
createdAt: string;
|
|
142
155
|
updatedAt: string;
|
|
156
|
+
projectId: string;
|
|
157
|
+
tenantId: string;
|
|
158
|
+
title: string | null;
|
|
143
159
|
userId: string | null;
|
|
160
|
+
activeSubAgentId: string;
|
|
144
161
|
ref: {
|
|
145
162
|
type: "commit" | "tag" | "branch";
|
|
146
163
|
name: string;
|
|
147
164
|
hash: string;
|
|
148
165
|
} | null;
|
|
149
|
-
activeSubAgentId: string;
|
|
150
166
|
lastContextResolution: string | null;
|
|
151
|
-
userProperties: Record<string, unknown> | null;
|
|
152
167
|
}>;
|
|
168
|
+
/**
|
|
169
|
+
* Extract text content from message content object
|
|
170
|
+
*/
|
|
171
|
+
declare function extractMessageText(content: MessageContent): string;
|
|
153
172
|
/**
|
|
154
173
|
* Get conversation history with filtering and context management
|
|
155
174
|
*/
|
|
@@ -165,24 +184,24 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
165
184
|
scopes: ProjectScopeConfig;
|
|
166
185
|
conversationId: string;
|
|
167
186
|
}) => Promise<{
|
|
168
|
-
properties: Record<string, unknown> | null;
|
|
169
|
-
title: string | null;
|
|
170
|
-
tenantId: string;
|
|
171
|
-
projectId: string;
|
|
172
|
-
agentId: string | null;
|
|
173
187
|
id: string;
|
|
188
|
+
agentId: string | null;
|
|
189
|
+
properties: Record<string, unknown> | null;
|
|
190
|
+
userProperties: Record<string, unknown> | null;
|
|
174
191
|
metadata: ConversationMetadata | null;
|
|
175
192
|
createdAt: string;
|
|
176
193
|
updatedAt: string;
|
|
194
|
+
projectId: string;
|
|
195
|
+
tenantId: string;
|
|
196
|
+
title: string | null;
|
|
177
197
|
userId: string | null;
|
|
198
|
+
activeSubAgentId: string;
|
|
178
199
|
ref: {
|
|
179
200
|
type: "commit" | "tag" | "branch";
|
|
180
201
|
name: string;
|
|
181
202
|
hash: string;
|
|
182
203
|
} | null;
|
|
183
|
-
activeSubAgentId: string;
|
|
184
204
|
lastContextResolution: string | null;
|
|
185
|
-
userProperties: Record<string, unknown> | null;
|
|
186
205
|
} | undefined>;
|
|
187
206
|
/**
|
|
188
207
|
* Set active agent for a conversation (upsert operation)
|
|
@@ -212,4 +231,4 @@ declare const setActiveAgentForThread: (db: AgentsRunDatabaseClient) => ({
|
|
|
212
231
|
ref: ResolvedRef;
|
|
213
232
|
}) => Promise<void>;
|
|
214
233
|
//#endregion
|
|
215
|
-
export { createConversation, createOrGetConversation, deleteConversation, getActiveAgentForConversation, getConversation, getConversationHistory, listConversations, setActiveAgentForConversation, setActiveAgentForThread, updateConversation, updateConversationActiveSubAgent };
|
|
234
|
+
export { createConversation, createOrGetConversation, deleteConversation, extractMessageText, getActiveAgentForConversation, getConversation, getConversationHistory, getConversationsByIds, listConversations, setActiveAgentForConversation, setActiveAgentForThread, updateConversation, updateConversationActiveSubAgent };
|
|
@@ -74,6 +74,21 @@ const updateConversationActiveSubAgent = (db) => async (params) => {
|
|
|
74
74
|
const getConversation = (db) => async (params) => {
|
|
75
75
|
return await db.query.conversations.findFirst({ where: and(projectScopedWhere(conversations, params.scopes), eq(conversations.id, params.conversationId)) });
|
|
76
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Batch-fetch conversations by id within a project scope.
|
|
79
|
+
*
|
|
80
|
+
* Set-based alternative to calling {@link getConversation} once per id, so callers
|
|
81
|
+
* enriching many results (e.g. evaluation results) issue a single query instead of
|
|
82
|
+
* fanning out one connection acquisition per conversation.
|
|
83
|
+
*/
|
|
84
|
+
const getConversationsByIds = (db) => async (params) => {
|
|
85
|
+
if (params.conversationIds.length === 0) return [];
|
|
86
|
+
return await db.select({
|
|
87
|
+
id: conversations.id,
|
|
88
|
+
agentId: conversations.agentId,
|
|
89
|
+
createdAt: conversations.createdAt
|
|
90
|
+
}).from(conversations).where(and(projectScopedWhere(conversations, params.scopes), inArray(conversations.id, params.conversationIds)));
|
|
91
|
+
};
|
|
77
92
|
const createOrGetConversation = (db) => async (input) => {
|
|
78
93
|
const conversationId = input.id || getConversationId();
|
|
79
94
|
if (input.id) {
|
|
@@ -242,4 +257,4 @@ const setActiveAgentForThread = (db) => async ({ scopes, threadId, subAgentId, a
|
|
|
242
257
|
};
|
|
243
258
|
|
|
244
259
|
//#endregion
|
|
245
|
-
export { createConversation, createOrGetConversation, deleteConversation, getActiveAgentForConversation, getConversation, getConversationHistory, listConversations, setActiveAgentForConversation, setActiveAgentForThread, updateConversation, updateConversationActiveSubAgent };
|
|
260
|
+
export { createConversation, createOrGetConversation, deleteConversation, extractMessageText, getActiveAgentForConversation, getConversation, getConversationHistory, getConversationsByIds, listConversations, setActiveAgentForConversation, setActiveAgentForThread, updateConversation, updateConversationActiveSubAgent };
|
|
@@ -58,6 +58,10 @@ declare const listEvaluationRunsByJobConfigId: (db: AgentsRunDatabaseClient) =>
|
|
|
58
58
|
scopes: ProjectScopeConfig;
|
|
59
59
|
evaluationJobConfigId: string;
|
|
60
60
|
}) => Promise<EvaluationRunSelect[]>;
|
|
61
|
+
declare const listEvaluationRunsByRunConfigId: (db: AgentsRunDatabaseClient) => (params: {
|
|
62
|
+
scopes: ProjectScopeConfig;
|
|
63
|
+
evaluationRunConfigId: string;
|
|
64
|
+
}) => Promise<EvaluationRunSelect[]>;
|
|
61
65
|
declare const getEvaluationRunByJobConfigId: (db: AgentsRunDatabaseClient) => (params: {
|
|
62
66
|
scopes: ProjectScopeConfig;
|
|
63
67
|
evaluationJobConfigId: string;
|
|
@@ -118,4 +122,4 @@ declare const filterConversationsForJob: (db: AgentsRunDatabaseClient) => (param
|
|
|
118
122
|
jobFilters: Filter<EvaluationJobFilterCriteria> | null | undefined;
|
|
119
123
|
}) => Promise<ConversationSelect[]>;
|
|
120
124
|
//#endregion
|
|
121
|
-
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, updateEvaluationResult, updateEvaluationRun };
|
|
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, listEvaluationRunsByRunConfigId, updateEvaluationResult, updateEvaluationRun };
|
|
@@ -63,6 +63,9 @@ const listEvaluationRuns = (db) => async (params) => {
|
|
|
63
63
|
const listEvaluationRunsByJobConfigId = (db) => async (params) => {
|
|
64
64
|
return await db.select().from(evaluationRun).where(and(projectScopedWhere(evaluationRun, params.scopes), eq(evaluationRun.evaluationJobConfigId, params.evaluationJobConfigId)));
|
|
65
65
|
};
|
|
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
|
+
};
|
|
66
69
|
const getEvaluationRunByJobConfigId = (db) => async (params) => {
|
|
67
70
|
return (await db.select().from(evaluationRun).where(and(projectScopedWhere(evaluationRun, params.scopes), eq(evaluationRun.evaluationJobConfigId, params.evaluationJobConfigId))).limit(1))[0] ?? null;
|
|
68
71
|
};
|
|
@@ -166,4 +169,4 @@ const filterConversationsForJob = (db) => async (params) => {
|
|
|
166
169
|
};
|
|
167
170
|
|
|
168
171
|
//#endregion
|
|
169
|
-
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, updateEvaluationResult, updateEvaluationRun };
|
|
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, listEvaluationRunsByRunConfigId, updateEvaluationResult, updateEvaluationRun };
|
|
@@ -8,21 +8,21 @@ import { EventInsert } from "../../types/entities.js";
|
|
|
8
8
|
declare const createEvent: (db: AgentsRunDatabaseClient) => (params: EventInsert) => Promise<{
|
|
9
9
|
row: {
|
|
10
10
|
type: string;
|
|
11
|
-
properties: Record<string, unknown> | null;
|
|
12
|
-
tenantId: string;
|
|
13
|
-
projectId: string;
|
|
14
|
-
agentId: string | null;
|
|
15
11
|
id: string;
|
|
16
|
-
|
|
17
|
-
createdAt: string;
|
|
18
|
-
updatedAt: string;
|
|
19
|
-
userProperties: Record<string, unknown> | null;
|
|
12
|
+
agentId: string | null;
|
|
20
13
|
conversationId: string | null;
|
|
21
14
|
messageId: string | null;
|
|
15
|
+
properties: Record<string, unknown> | null;
|
|
16
|
+
userProperties: Record<string, unknown> | null;
|
|
17
|
+
metadata: Record<string, unknown> | null;
|
|
22
18
|
serverMetadata: {
|
|
23
19
|
[k: string]: unknown;
|
|
24
20
|
authMethod?: string;
|
|
25
21
|
} | null;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
projectId: string;
|
|
25
|
+
tenantId: string;
|
|
26
26
|
};
|
|
27
27
|
conflict: false;
|
|
28
28
|
} | {
|
|
@@ -71,13 +71,13 @@ declare const getFeedbackByIds: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
71
71
|
}[]>;
|
|
72
72
|
declare const createFeedback: (db: AgentsRunDatabaseClient) => (params: FeedbackInsert) => Promise<{
|
|
73
73
|
type: "positive" | "negative";
|
|
74
|
-
tenantId: string;
|
|
75
|
-
projectId: string;
|
|
76
74
|
id: string;
|
|
77
|
-
createdAt: string;
|
|
78
|
-
updatedAt: string;
|
|
79
75
|
conversationId: string;
|
|
80
76
|
messageId: string | null;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
projectId: string;
|
|
80
|
+
tenantId: string;
|
|
81
81
|
details: string | null;
|
|
82
82
|
}>;
|
|
83
83
|
declare const createFeedbackBulk: (db: AgentsRunDatabaseClient) => (items: FeedbackInsert[]) => Promise<(typeof feedback.$inferSelect)[]>;
|
|
@@ -101,13 +101,13 @@ declare const deleteFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
101
101
|
feedbackId: string;
|
|
102
102
|
}) => Promise<{
|
|
103
103
|
type: "positive" | "negative";
|
|
104
|
-
tenantId: string;
|
|
105
|
-
projectId: string;
|
|
106
104
|
id: string;
|
|
107
|
-
createdAt: string;
|
|
108
|
-
updatedAt: string;
|
|
109
105
|
conversationId: string;
|
|
110
106
|
messageId: string | null;
|
|
107
|
+
createdAt: string;
|
|
108
|
+
updatedAt: string;
|
|
109
|
+
projectId: string;
|
|
110
|
+
tenantId: string;
|
|
111
111
|
details: string | null;
|
|
112
112
|
}>;
|
|
113
113
|
//#endregion
|
|
@@ -10,17 +10,17 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
scopes: ProjectScopeConfig;
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
|
-
properties: Record<string, unknown> | null;
|
|
14
|
-
tenantId: string;
|
|
15
|
-
projectId: string;
|
|
16
13
|
id: string;
|
|
17
|
-
|
|
14
|
+
conversationId: string;
|
|
15
|
+
properties: Record<string, unknown> | null;
|
|
16
|
+
userProperties: Record<string, unknown> | null;
|
|
18
17
|
metadata: MessageMetadata | null;
|
|
19
18
|
createdAt: string;
|
|
20
19
|
updatedAt: string;
|
|
20
|
+
projectId: string;
|
|
21
|
+
tenantId: string;
|
|
22
|
+
content: MessageContent;
|
|
21
23
|
role: string;
|
|
22
|
-
userProperties: Record<string, unknown> | null;
|
|
23
|
-
conversationId: string;
|
|
24
24
|
fromSubAgentId: string | null;
|
|
25
25
|
toSubAgentId: string | null;
|
|
26
26
|
fromExternalAgentId: string | null;
|
|
@@ -91,6 +91,35 @@ declare const getMessagesByConversation: (db: AgentsRunDatabaseClient) => (param
|
|
|
91
91
|
tenantId: string;
|
|
92
92
|
id: string;
|
|
93
93
|
}[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Batch-fetch the earliest `user` message for each of the given conversations in a single
|
|
96
|
+
* query (Postgres `DISTINCT ON`), returning one row per conversation.
|
|
97
|
+
*
|
|
98
|
+
* Set-based alternative to calling {@link getMessagesByConversation} once per conversation
|
|
99
|
+
* and reducing in JS, which fanned out two connection acquisitions per conversation and
|
|
100
|
+
* exhausted the runtime DB pool when enriching large evaluation-result sets.
|
|
101
|
+
*/
|
|
102
|
+
declare const getFirstUserMessageByConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
103
|
+
scopes: ProjectScopeConfig;
|
|
104
|
+
conversationIds: string[];
|
|
105
|
+
}) => Promise<{
|
|
106
|
+
conversationId: string;
|
|
107
|
+
content: MessageContent;
|
|
108
|
+
}[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Batch-fetch the latest assistant/agent message for each of the given conversations in a
|
|
111
|
+
* single query (Postgres `DISTINCT ON`), returning one row per conversation.
|
|
112
|
+
*
|
|
113
|
+
* Set-based alternative to the per-conversation lookup used when enriching dataset-run items
|
|
114
|
+
* with their agent output.
|
|
115
|
+
*/
|
|
116
|
+
declare const getLastAssistantMessageByConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
117
|
+
scopes: ProjectScopeConfig;
|
|
118
|
+
conversationIds: string[];
|
|
119
|
+
}) => Promise<{
|
|
120
|
+
conversationId: string;
|
|
121
|
+
content: MessageContent;
|
|
122
|
+
}[]>;
|
|
94
123
|
declare const getMessagesByTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
95
124
|
scopes: ProjectScopeConfig;
|
|
96
125
|
taskId: string;
|
|
@@ -154,17 +183,17 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
154
183
|
scopes: ProjectScopeConfig;
|
|
155
184
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
156
185
|
}) => Promise<{
|
|
157
|
-
properties: Record<string, unknown> | null;
|
|
158
|
-
tenantId: string;
|
|
159
|
-
projectId: string;
|
|
160
186
|
id: string;
|
|
161
|
-
|
|
187
|
+
conversationId: string;
|
|
188
|
+
properties: Record<string, unknown> | null;
|
|
189
|
+
userProperties: Record<string, unknown> | null;
|
|
162
190
|
metadata: MessageMetadata | null;
|
|
163
191
|
createdAt: string;
|
|
164
192
|
updatedAt: string;
|
|
193
|
+
projectId: string;
|
|
194
|
+
tenantId: string;
|
|
195
|
+
content: MessageContent;
|
|
165
196
|
role: string;
|
|
166
|
-
userProperties: Record<string, unknown> | null;
|
|
167
|
-
conversationId: string;
|
|
168
197
|
fromSubAgentId: string | null;
|
|
169
198
|
toSubAgentId: string | null;
|
|
170
199
|
fromExternalAgentId: string | null;
|
|
@@ -211,17 +240,17 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
211
240
|
scopes: ProjectScopeConfig;
|
|
212
241
|
messageId: string;
|
|
213
242
|
}) => Promise<{
|
|
214
|
-
properties: Record<string, unknown> | null;
|
|
215
|
-
tenantId: string;
|
|
216
|
-
projectId: string;
|
|
217
243
|
id: string;
|
|
218
|
-
|
|
244
|
+
conversationId: string;
|
|
245
|
+
properties: Record<string, unknown> | null;
|
|
246
|
+
userProperties: Record<string, unknown> | null;
|
|
219
247
|
metadata: MessageMetadata | null;
|
|
220
248
|
createdAt: string;
|
|
221
249
|
updatedAt: string;
|
|
250
|
+
projectId: string;
|
|
251
|
+
tenantId: string;
|
|
252
|
+
content: MessageContent;
|
|
222
253
|
role: string;
|
|
223
|
-
userProperties: Record<string, unknown> | null;
|
|
224
|
-
conversationId: string;
|
|
225
254
|
fromSubAgentId: string | null;
|
|
226
255
|
toSubAgentId: string | null;
|
|
227
256
|
fromExternalAgentId: string | null;
|
|
@@ -245,4 +274,4 @@ declare const countVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
245
274
|
visibility?: MessageVisibility[];
|
|
246
275
|
}) => Promise<number>;
|
|
247
276
|
//#endregion
|
|
248
|
-
export { countMessagesByConversation, countVisibleMessages, createMessage, deleteMessage, getMessageById, getMessagesByConversation, getMessagesByTask, getVisibleMessages, listMessages, updateMessage };
|
|
277
|
+
export { countMessagesByConversation, countVisibleMessages, createMessage, deleteMessage, getFirstUserMessageByConversations, getLastAssistantMessageByConversations, getMessageById, getMessagesByConversation, getMessagesByTask, getVisibleMessages, listMessages, updateMessage };
|
|
@@ -18,6 +18,35 @@ const getMessagesByConversation = (db) => async (params) => {
|
|
|
18
18
|
const offset = (page - 1) * limit;
|
|
19
19
|
return await db.select().from(messages).where(and(projectScopedWhere(messages, params.scopes), eq(messages.conversationId, params.conversationId))).limit(limit).offset(offset).orderBy(desc(messages.createdAt));
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Batch-fetch the earliest `user` message for each of the given conversations in a single
|
|
23
|
+
* query (Postgres `DISTINCT ON`), returning one row per conversation.
|
|
24
|
+
*
|
|
25
|
+
* Set-based alternative to calling {@link getMessagesByConversation} once per conversation
|
|
26
|
+
* and reducing in JS, which fanned out two connection acquisitions per conversation and
|
|
27
|
+
* exhausted the runtime DB pool when enriching large evaluation-result sets.
|
|
28
|
+
*/
|
|
29
|
+
const getFirstUserMessageByConversations = (db) => async (params) => {
|
|
30
|
+
if (params.conversationIds.length === 0) return [];
|
|
31
|
+
return await db.selectDistinctOn([messages.conversationId], {
|
|
32
|
+
conversationId: messages.conversationId,
|
|
33
|
+
content: messages.content
|
|
34
|
+
}).from(messages).where(and(projectScopedWhere(messages, params.scopes), inArray(messages.conversationId, params.conversationIds), eq(messages.role, "user"))).orderBy(messages.conversationId, asc(messages.createdAt), asc(messages.id));
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Batch-fetch the latest assistant/agent message for each of the given conversations in a
|
|
38
|
+
* single query (Postgres `DISTINCT ON`), returning one row per conversation.
|
|
39
|
+
*
|
|
40
|
+
* Set-based alternative to the per-conversation lookup used when enriching dataset-run items
|
|
41
|
+
* with their agent output.
|
|
42
|
+
*/
|
|
43
|
+
const getLastAssistantMessageByConversations = (db) => async (params) => {
|
|
44
|
+
if (params.conversationIds.length === 0) return [];
|
|
45
|
+
return await db.selectDistinctOn([messages.conversationId], {
|
|
46
|
+
conversationId: messages.conversationId,
|
|
47
|
+
content: messages.content
|
|
48
|
+
}).from(messages).where(and(projectScopedWhere(messages, params.scopes), inArray(messages.conversationId, params.conversationIds), inArray(messages.role, ["assistant", "agent"]))).orderBy(messages.conversationId, desc(messages.createdAt), desc(messages.id));
|
|
49
|
+
};
|
|
21
50
|
const getMessagesByTask = (db) => async (params) => {
|
|
22
51
|
const page = params.pagination?.page || 1;
|
|
23
52
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
@@ -66,4 +95,4 @@ const countVisibleMessages = (db) => async (params) => {
|
|
|
66
95
|
};
|
|
67
96
|
|
|
68
97
|
//#endregion
|
|
69
|
-
export { countMessagesByConversation, countVisibleMessages, createMessage, deleteMessage, getMessageById, getMessagesByConversation, getMessagesByTask, getVisibleMessages, listMessages, updateMessage };
|
|
98
|
+
export { countMessagesByConversation, countVisibleMessages, createMessage, deleteMessage, getFirstUserMessageByConversations, getLastAssistantMessageByConversations, getMessageById, getMessagesByConversation, getMessagesByTask, getVisibleMessages, listMessages, updateMessage };
|
|
@@ -15,8 +15,8 @@ declare const createScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (para
|
|
|
15
15
|
scheduledTriggerId: string;
|
|
16
16
|
userId: string;
|
|
17
17
|
}) => Promise<{
|
|
18
|
-
tenantId: string;
|
|
19
18
|
createdAt: string;
|
|
19
|
+
tenantId: string;
|
|
20
20
|
userId: string;
|
|
21
21
|
scheduledTriggerId: string;
|
|
22
22
|
}>;
|
|
@@ -7,14 +7,14 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
|
|
|
7
7
|
|
|
8
8
|
//#region src/data-access/runtime/tasks.d.ts
|
|
9
9
|
declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
|
|
10
|
-
tenantId: string;
|
|
11
|
-
projectId: string;
|
|
12
|
-
agentId: string;
|
|
13
|
-
subAgentId: string;
|
|
14
10
|
id: string;
|
|
11
|
+
agentId: string;
|
|
15
12
|
metadata: TaskMetadataConfig | null;
|
|
16
13
|
createdAt: string;
|
|
17
14
|
updatedAt: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
subAgentId: string;
|
|
18
18
|
ref: {
|
|
19
19
|
type: "commit" | "tag" | "branch";
|
|
20
20
|
name: string;
|