@inkeep/agents-core 0.77.1 → 0.78.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/constants/models.d.ts +3 -0
- package/dist/constants/models.js +3 -0
- package/dist/constants/otel-attributes.d.ts +1 -0
- package/dist/constants/otel-attributes.js +1 -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 +42 -42
- package/dist/data-access/manage/artifactComponents.d.ts +16 -16
- package/dist/data-access/manage/contextConfigs.d.ts +20 -20
- package/dist/data-access/manage/dataComponents.d.ts +8 -8
- package/dist/data-access/manage/functionTools.d.ts +20 -20
- package/dist/data-access/manage/skills.d.ts +17 -17
- 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 +18 -18
- package/dist/data-access/manage/tools.d.ts +30 -30
- package/dist/data-access/manage/triggers.d.ts +5 -5
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/apps.d.ts +8 -8
- package/dist/data-access/runtime/conversations.d.ts +45 -26
- 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 +5 -5
- package/dist/data-access/runtime/feedback.d.ts +4 -4
- package/dist/data-access/runtime/messages.d.ts +45 -16
- 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 +6 -6
- package/dist/db/manage/manage-schema.d.ts +383 -383
- package/dist/db/runtime/runtime-schema.d.ts +405 -405
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/utils/cache-debug-walk.d.ts +4 -9
- package/dist/utils/cache-debug-walk.js +4 -23
- package/dist/utils/cache-state.d.ts +1 -5
- package/dist/utils/cache-state.js +3 -4
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/usage-cost-middleware.d.ts +7 -1
- package/dist/utils/usage-cost-middleware.js +21 -2
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas/skills.d.ts +63 -63
- package/dist/validation/schemas.d.ts +2244 -2244
- package/package.json +1 -1
|
@@ -20,13 +20,13 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
20
20
|
scopes: ProjectScopeConfig;
|
|
21
21
|
toolId: string;
|
|
22
22
|
}) => Promise<{
|
|
23
|
-
description: string | null;
|
|
24
|
-
tenantId: string;
|
|
25
|
-
projectId: string;
|
|
26
23
|
id: string;
|
|
27
|
-
name: string;
|
|
28
24
|
createdAt: string;
|
|
25
|
+
name: string;
|
|
29
26
|
updatedAt: string;
|
|
27
|
+
projectId: string;
|
|
28
|
+
tenantId: string;
|
|
29
|
+
description: string | null;
|
|
30
30
|
headers: Record<string, string> | null;
|
|
31
31
|
config: {
|
|
32
32
|
type: "mcp";
|
|
@@ -78,13 +78,13 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
78
78
|
};
|
|
79
79
|
}>;
|
|
80
80
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
81
|
-
description: string | null;
|
|
82
|
-
tenantId: string;
|
|
83
|
-
projectId: string;
|
|
84
81
|
id: string;
|
|
85
|
-
name: string;
|
|
86
82
|
createdAt: string;
|
|
83
|
+
name: string;
|
|
87
84
|
updatedAt: string;
|
|
85
|
+
projectId: string;
|
|
86
|
+
tenantId: string;
|
|
87
|
+
description: string | null;
|
|
88
88
|
headers: Record<string, string> | null;
|
|
89
89
|
config: {
|
|
90
90
|
type: "mcp";
|
|
@@ -135,38 +135,38 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
135
135
|
needsApproval?: boolean;
|
|
136
136
|
}> | null;
|
|
137
137
|
}) => Promise<{
|
|
138
|
-
tenantId: string;
|
|
139
|
-
projectId: string;
|
|
140
|
-
agentId: string;
|
|
141
|
-
subAgentId: string;
|
|
142
|
-
toolId: string;
|
|
143
138
|
id: string;
|
|
144
139
|
createdAt: string;
|
|
145
140
|
updatedAt: string;
|
|
141
|
+
agentId: string;
|
|
142
|
+
projectId: string;
|
|
143
|
+
tenantId: string;
|
|
144
|
+
subAgentId: string;
|
|
145
|
+
toolId: string;
|
|
146
146
|
headers: Record<string, string> | null;
|
|
147
|
+
selectedTools: string[] | null;
|
|
147
148
|
toolPolicies: Record<string, {
|
|
148
149
|
needsApproval?: boolean;
|
|
149
150
|
}> | null;
|
|
150
|
-
selectedTools: string[] | null;
|
|
151
151
|
}>;
|
|
152
152
|
declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
153
153
|
scopes: AgentScopeConfig;
|
|
154
154
|
subAgentId: string;
|
|
155
155
|
toolId: string;
|
|
156
156
|
}) => Promise<{
|
|
157
|
-
tenantId: string;
|
|
158
|
-
projectId: string;
|
|
159
|
-
agentId: string;
|
|
160
|
-
subAgentId: string;
|
|
161
|
-
toolId: string;
|
|
162
157
|
id: string;
|
|
163
158
|
createdAt: string;
|
|
164
159
|
updatedAt: string;
|
|
160
|
+
agentId: string;
|
|
161
|
+
projectId: string;
|
|
162
|
+
tenantId: string;
|
|
163
|
+
subAgentId: string;
|
|
164
|
+
toolId: string;
|
|
165
165
|
headers: Record<string, string> | null;
|
|
166
|
+
selectedTools: string[] | null;
|
|
166
167
|
toolPolicies: Record<string, {
|
|
167
168
|
needsApproval?: boolean;
|
|
168
169
|
}> | null;
|
|
169
|
-
selectedTools: string[] | null;
|
|
170
170
|
}>;
|
|
171
171
|
/**
|
|
172
172
|
* Upsert agent-tool relation (create if it doesn't exist, update if it does)
|
|
@@ -182,19 +182,19 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
182
182
|
}> | null;
|
|
183
183
|
relationId?: string;
|
|
184
184
|
}) => Promise<{
|
|
185
|
-
tenantId: string;
|
|
186
|
-
projectId: string;
|
|
187
|
-
agentId: string;
|
|
188
|
-
subAgentId: string;
|
|
189
|
-
toolId: string;
|
|
190
185
|
id: string;
|
|
191
186
|
createdAt: string;
|
|
192
187
|
updatedAt: string;
|
|
188
|
+
agentId: string;
|
|
189
|
+
projectId: string;
|
|
190
|
+
tenantId: string;
|
|
191
|
+
subAgentId: string;
|
|
192
|
+
toolId: string;
|
|
193
193
|
headers: Record<string, string> | null;
|
|
194
|
+
selectedTools: string[] | null;
|
|
194
195
|
toolPolicies: Record<string, {
|
|
195
196
|
needsApproval?: boolean;
|
|
196
197
|
}> | null;
|
|
197
|
-
selectedTools: string[] | null;
|
|
198
198
|
}>;
|
|
199
199
|
/**
|
|
200
200
|
* Upsert a tool (create if it doesn't exist, update if it does)
|
|
@@ -202,13 +202,13 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
202
202
|
declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
203
203
|
data: ToolInsert;
|
|
204
204
|
}) => Promise<{
|
|
205
|
-
description: string | null;
|
|
206
|
-
tenantId: string;
|
|
207
|
-
projectId: string;
|
|
208
205
|
id: string;
|
|
209
|
-
name: string;
|
|
210
206
|
createdAt: string;
|
|
207
|
+
name: string;
|
|
211
208
|
updatedAt: string;
|
|
209
|
+
projectId: string;
|
|
210
|
+
tenantId: string;
|
|
211
|
+
description: string | null;
|
|
212
212
|
headers: Record<string, string> | null;
|
|
213
213
|
config: {
|
|
214
214
|
type: "mcp";
|
|
@@ -37,8 +37,8 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
|
|
|
37
37
|
authentication: unknown;
|
|
38
38
|
signingSecretCredentialReferenceId: string | null;
|
|
39
39
|
signatureVerification: {
|
|
40
|
-
algorithm: "
|
|
41
|
-
encoding: "
|
|
40
|
+
algorithm: "md5" | "sha256" | "sha512" | "sha384" | "sha1";
|
|
41
|
+
encoding: "base64" | "hex";
|
|
42
42
|
signature: {
|
|
43
43
|
source: "query" | "body" | "header";
|
|
44
44
|
key: string;
|
|
@@ -131,10 +131,10 @@ declare const createTriggerUser: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
131
131
|
triggerId: string;
|
|
132
132
|
userId: string;
|
|
133
133
|
}) => Promise<{
|
|
134
|
-
tenantId: string;
|
|
135
|
-
projectId: string;
|
|
136
|
-
agentId: string;
|
|
137
134
|
createdAt: string;
|
|
135
|
+
agentId: string;
|
|
136
|
+
projectId: string;
|
|
137
|
+
tenantId: string;
|
|
138
138
|
userId: string;
|
|
139
139
|
triggerId: string;
|
|
140
140
|
}>;
|
|
@@ -8,13 +8,13 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
8
8
|
scopes: ProjectScopeConfig;
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
|
-
tenantId: string;
|
|
12
|
-
projectId: string;
|
|
13
|
-
agentId: string;
|
|
14
11
|
id: string;
|
|
15
|
-
name: string | null;
|
|
16
12
|
createdAt: string;
|
|
13
|
+
name: string | null;
|
|
17
14
|
updatedAt: string;
|
|
15
|
+
agentId: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
tenantId: string;
|
|
18
18
|
expiresAt: string | null;
|
|
19
19
|
publicId: string;
|
|
20
20
|
keyHash: string;
|
|
@@ -22,13 +22,13 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
22
22
|
lastUsedAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
|
-
tenantId: string;
|
|
26
|
-
projectId: string;
|
|
27
|
-
agentId: string;
|
|
28
25
|
id: string;
|
|
29
|
-
name: string | null;
|
|
30
26
|
createdAt: string;
|
|
27
|
+
name: string | null;
|
|
31
28
|
updatedAt: string;
|
|
29
|
+
agentId: string;
|
|
30
|
+
projectId: string;
|
|
31
|
+
tenantId: string;
|
|
32
32
|
expiresAt: string | null;
|
|
33
33
|
publicId: string;
|
|
34
34
|
keyHash: string;
|
|
@@ -39,13 +39,13 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
40
40
|
agentId?: string;
|
|
41
41
|
}) => Promise<{
|
|
42
|
-
tenantId: string;
|
|
43
|
-
projectId: string;
|
|
44
|
-
agentId: string;
|
|
45
42
|
id: string;
|
|
46
|
-
name: string | null;
|
|
47
43
|
createdAt: string;
|
|
44
|
+
name: string | null;
|
|
48
45
|
updatedAt: string;
|
|
46
|
+
agentId: string;
|
|
47
|
+
projectId: string;
|
|
48
|
+
tenantId: string;
|
|
49
49
|
expiresAt: string | null;
|
|
50
50
|
publicId: string;
|
|
51
51
|
keyHash: string;
|
|
@@ -66,13 +66,13 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
66
66
|
};
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
|
-
tenantId: string;
|
|
70
|
-
projectId: string;
|
|
71
|
-
agentId: string;
|
|
72
69
|
id: string;
|
|
73
|
-
name: string | null;
|
|
74
70
|
createdAt: string;
|
|
71
|
+
name: string | null;
|
|
75
72
|
updatedAt: string;
|
|
73
|
+
agentId: string;
|
|
74
|
+
projectId: string;
|
|
75
|
+
tenantId: string;
|
|
76
76
|
expiresAt: string | null;
|
|
77
77
|
publicId: string;
|
|
78
78
|
keyHash: string;
|
|
@@ -6,13 +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
|
-
description: string | null;
|
|
10
|
-
tenantId: string | null;
|
|
11
|
-
projectId: string | null;
|
|
12
9
|
id: string;
|
|
13
|
-
name: string;
|
|
14
10
|
createdAt: string;
|
|
11
|
+
name: string;
|
|
15
12
|
updatedAt: string;
|
|
13
|
+
projectId: string | null;
|
|
14
|
+
tenantId: string | null;
|
|
15
|
+
description: string | null;
|
|
16
16
|
enabled: boolean;
|
|
17
17
|
prompt: string | null;
|
|
18
18
|
lastUsedAt: string | null;
|
|
@@ -75,13 +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
|
-
description: string | null;
|
|
79
|
-
tenantId: string | null;
|
|
80
|
-
projectId: string | null;
|
|
81
78
|
id: string;
|
|
82
|
-
name: string;
|
|
83
79
|
createdAt: string;
|
|
80
|
+
name: string;
|
|
84
81
|
updatedAt: string;
|
|
82
|
+
projectId: string | null;
|
|
83
|
+
tenantId: string | null;
|
|
84
|
+
description: string | null;
|
|
85
85
|
enabled: boolean;
|
|
86
86
|
prompt: string | null;
|
|
87
87
|
lastUsedAt: string | null;
|
|
@@ -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,15 +16,15 @@ 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;
|
|
25
|
-
metadata: ConversationMetadata | null;
|
|
26
20
|
createdAt: string;
|
|
27
21
|
updatedAt: string;
|
|
22
|
+
agentId: string | null;
|
|
23
|
+
projectId: string;
|
|
24
|
+
tenantId: string;
|
|
25
|
+
properties: Record<string, unknown> | null;
|
|
26
|
+
title: string | null;
|
|
27
|
+
metadata: ConversationMetadata | null;
|
|
28
28
|
userId: string | null;
|
|
29
29
|
ref: {
|
|
30
30
|
type: "commit" | "tag" | "branch";
|
|
@@ -91,15 +91,15 @@ 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;
|
|
100
|
-
metadata: ConversationMetadata | null;
|
|
101
95
|
createdAt: string;
|
|
102
96
|
updatedAt: string;
|
|
97
|
+
agentId: string | null;
|
|
98
|
+
projectId: string;
|
|
99
|
+
tenantId: string;
|
|
100
|
+
properties: Record<string, unknown> | null;
|
|
101
|
+
title: string | null;
|
|
102
|
+
metadata: ConversationMetadata | null;
|
|
103
103
|
userId: string | null;
|
|
104
104
|
ref: {
|
|
105
105
|
type: "commit" | "tag" | "branch";
|
|
@@ -110,6 +110,21 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
110
110
|
lastContextResolution: string | null;
|
|
111
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,15 +146,15 @@ 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;
|
|
140
|
-
metadata: ConversationMetadata | null;
|
|
141
150
|
createdAt: string;
|
|
142
151
|
updatedAt: string;
|
|
152
|
+
agentId: string | null;
|
|
153
|
+
projectId: string;
|
|
154
|
+
tenantId: string;
|
|
155
|
+
properties: Record<string, unknown> | null;
|
|
156
|
+
title: string | null;
|
|
157
|
+
metadata: ConversationMetadata | null;
|
|
143
158
|
userId: string | null;
|
|
144
159
|
ref: {
|
|
145
160
|
type: "commit" | "tag" | "branch";
|
|
@@ -150,6 +165,10 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
150
165
|
lastContextResolution: string | null;
|
|
151
166
|
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,15 +184,15 @@ 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;
|
|
174
|
-
metadata: ConversationMetadata | null;
|
|
175
188
|
createdAt: string;
|
|
176
189
|
updatedAt: string;
|
|
190
|
+
agentId: string | null;
|
|
191
|
+
projectId: string;
|
|
192
|
+
tenantId: string;
|
|
193
|
+
properties: Record<string, unknown> | null;
|
|
194
|
+
title: string | null;
|
|
195
|
+
metadata: ConversationMetadata | null;
|
|
177
196
|
userId: string | null;
|
|
178
197
|
ref: {
|
|
179
198
|
type: "commit" | "tag" | "branch";
|
|
@@ -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,14 +8,14 @@ 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
|
-
metadata: Record<string, unknown> | null;
|
|
17
12
|
createdAt: string;
|
|
18
13
|
updatedAt: string;
|
|
14
|
+
agentId: string | null;
|
|
15
|
+
projectId: string;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
properties: Record<string, unknown> | null;
|
|
18
|
+
metadata: Record<string, unknown> | null;
|
|
19
19
|
userProperties: Record<string, unknown> | null;
|
|
20
20
|
conversationId: string | null;
|
|
21
21
|
messageId: string | null;
|
|
@@ -71,11 +71,11 @@ 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
75
|
createdAt: string;
|
|
78
76
|
updatedAt: string;
|
|
77
|
+
projectId: string;
|
|
78
|
+
tenantId: string;
|
|
79
79
|
conversationId: string;
|
|
80
80
|
messageId: string | null;
|
|
81
81
|
details: string | null;
|
|
@@ -101,11 +101,11 @@ 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
105
|
createdAt: string;
|
|
108
106
|
updatedAt: string;
|
|
107
|
+
projectId: string;
|
|
108
|
+
tenantId: string;
|
|
109
109
|
conversationId: string;
|
|
110
110
|
messageId: string | null;
|
|
111
111
|
details: string | null;
|
|
@@ -10,14 +10,14 @@ 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
|
-
content: MessageContent;
|
|
18
|
-
metadata: MessageMetadata | null;
|
|
19
14
|
createdAt: string;
|
|
20
15
|
updatedAt: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
tenantId: string;
|
|
18
|
+
properties: Record<string, unknown> | null;
|
|
19
|
+
metadata: MessageMetadata | null;
|
|
20
|
+
content: MessageContent;
|
|
21
21
|
role: string;
|
|
22
22
|
userProperties: Record<string, unknown> | null;
|
|
23
23
|
conversationId: string;
|
|
@@ -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,14 +183,14 @@ 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
|
-
content: MessageContent;
|
|
162
|
-
metadata: MessageMetadata | null;
|
|
163
187
|
createdAt: string;
|
|
164
188
|
updatedAt: string;
|
|
189
|
+
projectId: string;
|
|
190
|
+
tenantId: string;
|
|
191
|
+
properties: Record<string, unknown> | null;
|
|
192
|
+
metadata: MessageMetadata | null;
|
|
193
|
+
content: MessageContent;
|
|
165
194
|
role: string;
|
|
166
195
|
userProperties: Record<string, unknown> | null;
|
|
167
196
|
conversationId: string;
|
|
@@ -211,14 +240,14 @@ 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
|
-
content: MessageContent;
|
|
219
|
-
metadata: MessageMetadata | null;
|
|
220
244
|
createdAt: string;
|
|
221
245
|
updatedAt: string;
|
|
246
|
+
projectId: string;
|
|
247
|
+
tenantId: string;
|
|
248
|
+
properties: Record<string, unknown> | null;
|
|
249
|
+
metadata: MessageMetadata | null;
|
|
250
|
+
content: MessageContent;
|
|
222
251
|
role: string;
|
|
223
252
|
userProperties: Record<string, unknown> | null;
|
|
224
253
|
conversationId: string;
|
|
@@ -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
|
}>;
|