@inkeep/agents-core 0.77.0 → 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 +19 -19
- package/dist/data-access/manage/artifactComponents.d.ts +6 -6
- package/dist/data-access/manage/contextConfigs.d.ts +4 -4
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +8 -8
- package/dist/data-access/manage/skills.d.ts +10 -10
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +6 -6
- package/dist/data-access/manage/subAgentRelations.d.ts +14 -14
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +6 -6
- package/dist/data-access/manage/subAgents.d.ts +9 -9
- package/dist/data-access/manage/tools.d.ts +15 -15
- package/dist/data-access/manage/triggers.d.ts +4 -4
- package/dist/data-access/runtime/apiKeys.d.ts +12 -12
- package/dist/data-access/runtime/apps.d.ts +11 -11
- package/dist/data-access/runtime/conversations.d.ts +57 -38
- 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 +7 -7
- package/dist/data-access/runtime/feedback.d.ts +4 -4
- package/dist/data-access/runtime/messages.d.ts +54 -25
- package/dist/data-access/runtime/messages.js +30 -1
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +4 -4
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +1 -1
- package/dist/data-access/runtime/tasks.d.ts +5 -5
- package/dist/db/manage/manage-schema.d.ts +383 -383
- package/dist/db/runtime/runtime-schema.d.ts +419 -419
- 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 +51 -51
- package/dist/validation/schemas.d.ts +2405 -2405
- package/package.json +1 -1
|
@@ -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";
|
|
@@ -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
|
+
agentId: string | null;
|
|
21
|
+
properties: Record<string, unknown> | null;
|
|
22
|
+
userProperties: Record<string, unknown> | null;
|
|
23
|
+
metadata: ConversationMetadata | null;
|
|
20
24
|
createdAt: string;
|
|
21
25
|
updatedAt: string;
|
|
26
|
+
projectId: string;
|
|
27
|
+
tenantId: string;
|
|
28
|
+
title: string | null;
|
|
29
|
+
userId: string | null;
|
|
30
|
+
activeSubAgentId: string;
|
|
22
31
|
ref: {
|
|
23
32
|
type: "commit" | "tag" | "branch";
|
|
24
33
|
name: string;
|
|
25
34
|
hash: string;
|
|
26
35
|
} | null;
|
|
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
|
-
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,24 +92,39 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
92
92
|
conversationId: string;
|
|
93
93
|
}) => Promise<{
|
|
94
94
|
id: string;
|
|
95
|
+
agentId: string | null;
|
|
96
|
+
properties: Record<string, unknown> | null;
|
|
97
|
+
userProperties: Record<string, unknown> | null;
|
|
98
|
+
metadata: ConversationMetadata | null;
|
|
95
99
|
createdAt: string;
|
|
96
100
|
updatedAt: string;
|
|
101
|
+
projectId: string;
|
|
102
|
+
tenantId: string;
|
|
103
|
+
title: string | null;
|
|
104
|
+
userId: string | null;
|
|
105
|
+
activeSubAgentId: string;
|
|
97
106
|
ref: {
|
|
98
107
|
type: "commit" | "tag" | "branch";
|
|
99
108
|
name: string;
|
|
100
109
|
hash: string;
|
|
101
110
|
} | null;
|
|
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
|
-
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;
|
|
@@ -132,24 +147,28 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
132
147
|
properties?: Record<string, unknown> | null | undefined;
|
|
133
148
|
} | {
|
|
134
149
|
id: string;
|
|
150
|
+
agentId: string | null;
|
|
151
|
+
properties: Record<string, unknown> | null;
|
|
152
|
+
userProperties: Record<string, unknown> | null;
|
|
153
|
+
metadata: ConversationMetadata | null;
|
|
135
154
|
createdAt: string;
|
|
136
155
|
updatedAt: string;
|
|
156
|
+
projectId: string;
|
|
157
|
+
tenantId: string;
|
|
158
|
+
title: string | null;
|
|
159
|
+
userId: string | null;
|
|
160
|
+
activeSubAgentId: string;
|
|
137
161
|
ref: {
|
|
138
162
|
type: "commit" | "tag" | "branch";
|
|
139
163
|
name: string;
|
|
140
164
|
hash: string;
|
|
141
165
|
} | null;
|
|
142
|
-
userId: string | null;
|
|
143
|
-
metadata: ConversationMetadata | null;
|
|
144
|
-
projectId: string;
|
|
145
|
-
tenantId: string;
|
|
146
|
-
properties: Record<string, unknown> | null;
|
|
147
|
-
title: string | null;
|
|
148
|
-
agentId: string | 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
|
*/
|
|
@@ -166,23 +185,23 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
166
185
|
conversationId: string;
|
|
167
186
|
}) => Promise<{
|
|
168
187
|
id: string;
|
|
188
|
+
agentId: string | null;
|
|
189
|
+
properties: Record<string, unknown> | null;
|
|
190
|
+
userProperties: Record<string, unknown> | null;
|
|
191
|
+
metadata: ConversationMetadata | null;
|
|
169
192
|
createdAt: string;
|
|
170
193
|
updatedAt: string;
|
|
194
|
+
projectId: string;
|
|
195
|
+
tenantId: string;
|
|
196
|
+
title: string | null;
|
|
197
|
+
userId: string | null;
|
|
198
|
+
activeSubAgentId: string;
|
|
171
199
|
ref: {
|
|
172
200
|
type: "commit" | "tag" | "branch";
|
|
173
201
|
name: string;
|
|
174
202
|
hash: string;
|
|
175
203
|
} | null;
|
|
176
|
-
userId: string | null;
|
|
177
|
-
metadata: ConversationMetadata | null;
|
|
178
|
-
projectId: string;
|
|
179
|
-
tenantId: string;
|
|
180
|
-
properties: Record<string, unknown> | null;
|
|
181
|
-
title: string | null;
|
|
182
|
-
agentId: string | 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 };
|
|
@@ -9,20 +9,20 @@ declare const createEvent: (db: AgentsRunDatabaseClient) => (params: EventInsert
|
|
|
9
9
|
row: {
|
|
10
10
|
type: string;
|
|
11
11
|
id: string;
|
|
12
|
-
createdAt: string;
|
|
13
|
-
updatedAt: string;
|
|
14
|
-
metadata: Record<string, unknown> | null;
|
|
15
|
-
projectId: string;
|
|
16
|
-
tenantId: string;
|
|
17
|
-
properties: Record<string, unknown> | null;
|
|
18
12
|
agentId: string | null;
|
|
19
13
|
conversationId: string | null;
|
|
20
|
-
userProperties: Record<string, unknown> | 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
|
} | {
|
|
@@ -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
|
+
conversationId: string;
|
|
76
|
+
messageId: string | null;
|
|
75
77
|
createdAt: string;
|
|
76
78
|
updatedAt: string;
|
|
77
79
|
projectId: string;
|
|
78
80
|
tenantId: string;
|
|
79
|
-
conversationId: string;
|
|
80
81
|
details: string | null;
|
|
81
|
-
messageId: 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
|
+
conversationId: string;
|
|
106
|
+
messageId: string | null;
|
|
105
107
|
createdAt: string;
|
|
106
108
|
updatedAt: string;
|
|
107
109
|
projectId: string;
|
|
108
110
|
tenantId: string;
|
|
109
|
-
conversationId: string;
|
|
110
111
|
details: string | null;
|
|
111
|
-
messageId: 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
|
+
conversationId: string;
|
|
15
|
+
properties: Record<string, unknown> | null;
|
|
16
|
+
userProperties: Record<string, unknown> | null;
|
|
17
|
+
metadata: MessageMetadata | null;
|
|
14
18
|
createdAt: string;
|
|
15
19
|
updatedAt: string;
|
|
16
|
-
metadata: MessageMetadata | null;
|
|
17
|
-
role: string;
|
|
18
|
-
content: MessageContent;
|
|
19
20
|
projectId: string;
|
|
20
21
|
tenantId: string;
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
content: MessageContent;
|
|
23
|
+
role: string;
|
|
23
24
|
fromSubAgentId: string | null;
|
|
24
25
|
toSubAgentId: string | null;
|
|
25
26
|
fromExternalAgentId: string | null;
|
|
26
27
|
toExternalAgentId: string | null;
|
|
27
|
-
taskId: string | null;
|
|
28
|
-
a2aTaskId: string | null;
|
|
29
|
-
userProperties: Record<string, unknown> | null;
|
|
30
28
|
fromTeamAgentId: string | null;
|
|
31
29
|
toTeamAgentId: string | null;
|
|
32
30
|
visibility: string;
|
|
33
31
|
messageType: string;
|
|
32
|
+
taskId: string | null;
|
|
34
33
|
parentMessageId: string | null;
|
|
34
|
+
a2aTaskId: string | null;
|
|
35
35
|
a2aSessionId: string | null;
|
|
36
36
|
} | undefined>;
|
|
37
37
|
declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -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;
|
|
@@ -155,27 +184,27 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
155
184
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
156
185
|
}) => Promise<{
|
|
157
186
|
id: string;
|
|
187
|
+
conversationId: string;
|
|
188
|
+
properties: Record<string, unknown> | null;
|
|
189
|
+
userProperties: Record<string, unknown> | null;
|
|
190
|
+
metadata: MessageMetadata | null;
|
|
158
191
|
createdAt: string;
|
|
159
192
|
updatedAt: string;
|
|
160
|
-
metadata: MessageMetadata | null;
|
|
161
|
-
role: string;
|
|
162
|
-
content: MessageContent;
|
|
163
193
|
projectId: string;
|
|
164
194
|
tenantId: string;
|
|
165
|
-
|
|
166
|
-
|
|
195
|
+
content: MessageContent;
|
|
196
|
+
role: string;
|
|
167
197
|
fromSubAgentId: string | null;
|
|
168
198
|
toSubAgentId: string | null;
|
|
169
199
|
fromExternalAgentId: string | null;
|
|
170
200
|
toExternalAgentId: string | null;
|
|
171
|
-
taskId: string | null;
|
|
172
|
-
a2aTaskId: string | null;
|
|
173
|
-
userProperties: Record<string, unknown> | null;
|
|
174
201
|
fromTeamAgentId: string | null;
|
|
175
202
|
toTeamAgentId: string | null;
|
|
176
203
|
visibility: string;
|
|
177
204
|
messageType: string;
|
|
205
|
+
taskId: string | null;
|
|
178
206
|
parentMessageId: string | null;
|
|
207
|
+
a2aTaskId: string | null;
|
|
179
208
|
a2aSessionId: string | null;
|
|
180
209
|
}>;
|
|
181
210
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -212,27 +241,27 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
212
241
|
messageId: string;
|
|
213
242
|
}) => Promise<{
|
|
214
243
|
id: string;
|
|
244
|
+
conversationId: string;
|
|
245
|
+
properties: Record<string, unknown> | null;
|
|
246
|
+
userProperties: Record<string, unknown> | null;
|
|
247
|
+
metadata: MessageMetadata | null;
|
|
215
248
|
createdAt: string;
|
|
216
249
|
updatedAt: string;
|
|
217
|
-
metadata: MessageMetadata | null;
|
|
218
|
-
role: string;
|
|
219
|
-
content: MessageContent;
|
|
220
250
|
projectId: string;
|
|
221
251
|
tenantId: string;
|
|
222
|
-
|
|
223
|
-
|
|
252
|
+
content: MessageContent;
|
|
253
|
+
role: string;
|
|
224
254
|
fromSubAgentId: string | null;
|
|
225
255
|
toSubAgentId: string | null;
|
|
226
256
|
fromExternalAgentId: string | null;
|
|
227
257
|
toExternalAgentId: string | null;
|
|
228
|
-
taskId: string | null;
|
|
229
|
-
a2aTaskId: string | null;
|
|
230
|
-
userProperties: Record<string, unknown> | null;
|
|
231
258
|
fromTeamAgentId: string | null;
|
|
232
259
|
toTeamAgentId: string | null;
|
|
233
260
|
visibility: string;
|
|
234
261
|
messageType: string;
|
|
262
|
+
taskId: string | null;
|
|
235
263
|
parentMessageId: string | null;
|
|
264
|
+
a2aTaskId: string | null;
|
|
236
265
|
a2aSessionId: string | null;
|
|
237
266
|
}>;
|
|
238
267
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -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 };
|
|
@@ -40,7 +40,7 @@ declare const listScheduledTriggerInvocationsPaginated: (db: AgentsRunDatabaseCl
|
|
|
40
40
|
name: string;
|
|
41
41
|
hash: string;
|
|
42
42
|
} | null;
|
|
43
|
-
status: "pending" | "
|
|
43
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
44
44
|
scheduledFor: string;
|
|
45
45
|
startedAt: string | null;
|
|
46
46
|
completedAt: string | null;
|
|
@@ -199,7 +199,7 @@ declare const listUpcomingInvocationsForAgentPaginated: (db: AgentsRunDatabaseCl
|
|
|
199
199
|
name: string;
|
|
200
200
|
hash: string;
|
|
201
201
|
} | null;
|
|
202
|
-
status: "pending" | "
|
|
202
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
203
203
|
scheduledFor: string;
|
|
204
204
|
startedAt: string | null;
|
|
205
205
|
completedAt: string | null;
|
|
@@ -239,7 +239,7 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
|
|
|
239
239
|
name: string;
|
|
240
240
|
hash: string;
|
|
241
241
|
} | null;
|
|
242
|
-
status: "pending" | "
|
|
242
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
243
243
|
scheduledFor: string;
|
|
244
244
|
startedAt: string | null;
|
|
245
245
|
completedAt: string | null;
|
|
@@ -292,7 +292,7 @@ declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabase
|
|
|
292
292
|
name: string;
|
|
293
293
|
hash: string;
|
|
294
294
|
} | null;
|
|
295
|
-
status: "pending" | "
|
|
295
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
296
296
|
scheduledFor: string;
|
|
297
297
|
startedAt: string | null;
|
|
298
298
|
completedAt: string | null;
|
|
@@ -16,8 +16,8 @@ declare const createScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (para
|
|
|
16
16
|
userId: string;
|
|
17
17
|
}) => Promise<{
|
|
18
18
|
createdAt: string;
|
|
19
|
-
userId: string;
|
|
20
19
|
tenantId: string;
|
|
20
|
+
userId: string;
|
|
21
21
|
scheduledTriggerId: string;
|
|
22
22
|
}>;
|
|
23
23
|
declare const deleteScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -8,19 +8,19 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
|
|
|
8
8
|
//#region src/data-access/runtime/tasks.d.ts
|
|
9
9
|
declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
|
|
10
10
|
id: string;
|
|
11
|
+
agentId: string;
|
|
12
|
+
metadata: TaskMetadataConfig | null;
|
|
11
13
|
createdAt: string;
|
|
12
14
|
updatedAt: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
subAgentId: string;
|
|
13
18
|
ref: {
|
|
14
19
|
type: "commit" | "tag" | "branch";
|
|
15
20
|
name: string;
|
|
16
21
|
hash: string;
|
|
17
22
|
} | null;
|
|
18
|
-
metadata: TaskMetadataConfig | null;
|
|
19
23
|
status: string;
|
|
20
|
-
projectId: string;
|
|
21
|
-
tenantId: string;
|
|
22
|
-
agentId: string;
|
|
23
|
-
subAgentId: string;
|
|
24
24
|
contextId: string;
|
|
25
25
|
}>;
|
|
26
26
|
declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
|