@inkeep/agents-core 0.0.0-dev-20260118170655 → 0.0.0-dev-20260119170007
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 +82 -82
- package/dist/auth/auth-validation-schemas.d.ts +146 -146
- package/dist/auth/auth.d.ts +78 -18
- package/dist/auth/auth.js +46 -0
- package/dist/auth/authz/client.d.ts +81 -0
- package/dist/auth/authz/client.js +189 -0
- package/dist/auth/authz/config.d.ts +76 -0
- package/dist/auth/authz/config.js +76 -0
- package/dist/auth/authz/index.d.ts +5 -0
- package/dist/auth/authz/index.js +6 -0
- package/dist/auth/authz/permissions.d.ts +57 -0
- package/dist/auth/authz/permissions.js +83 -0
- package/dist/auth/authz/sync.d.ts +85 -0
- package/dist/auth/authz/sync.js +237 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/permissions.js +2 -181
- package/dist/client-exports.d.ts +1 -0
- package/dist/data-access/manage/agentFull.js +51 -2
- package/dist/data-access/manage/projectLifecycle.d.ts +1 -0
- package/dist/data-access/manage/projectLifecycle.js +3 -2
- package/dist/data-access/manage/projects.d.ts +4 -0
- package/dist/data-access/manage/projects.js +11 -4
- package/dist/data-access/runtime/conversations.d.ts +7 -7
- package/dist/data-access/runtime/messages.d.ts +9 -9
- package/dist/data-access/runtime/projects.d.ts +2 -0
- package/dist/data-access/runtime/projects.js +16 -2
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/db/manage/manage-schema.d.ts +360 -360
- package/dist/db/runtime/runtime-schema.d.ts +169 -169
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas.d.ts +1180 -1180
- package/package.json +6 -1
package/dist/auth/permissions.js
CHANGED
|
@@ -10,138 +10,19 @@ const statement = {
|
|
|
10
10
|
"read",
|
|
11
11
|
"update",
|
|
12
12
|
"delete"
|
|
13
|
-
],
|
|
14
|
-
agent: [
|
|
15
|
-
"create",
|
|
16
|
-
"read",
|
|
17
|
-
"update",
|
|
18
|
-
"delete"
|
|
19
|
-
],
|
|
20
|
-
sub_agent: [
|
|
21
|
-
"create",
|
|
22
|
-
"read",
|
|
23
|
-
"update",
|
|
24
|
-
"delete"
|
|
25
|
-
],
|
|
26
|
-
tool: [
|
|
27
|
-
"create",
|
|
28
|
-
"read",
|
|
29
|
-
"update",
|
|
30
|
-
"delete"
|
|
31
|
-
],
|
|
32
|
-
api_key: [
|
|
33
|
-
"create",
|
|
34
|
-
"read",
|
|
35
|
-
"update",
|
|
36
|
-
"delete"
|
|
37
|
-
],
|
|
38
|
-
credential: [
|
|
39
|
-
"create",
|
|
40
|
-
"read",
|
|
41
|
-
"update",
|
|
42
|
-
"delete"
|
|
43
|
-
],
|
|
44
|
-
data_component: [
|
|
45
|
-
"create",
|
|
46
|
-
"read",
|
|
47
|
-
"update",
|
|
48
|
-
"delete"
|
|
49
|
-
],
|
|
50
|
-
artifact_component: [
|
|
51
|
-
"create",
|
|
52
|
-
"read",
|
|
53
|
-
"update",
|
|
54
|
-
"delete"
|
|
55
|
-
],
|
|
56
|
-
external_agent: [
|
|
57
|
-
"create",
|
|
58
|
-
"read",
|
|
59
|
-
"update",
|
|
60
|
-
"delete"
|
|
61
|
-
],
|
|
62
|
-
function: [
|
|
63
|
-
"create",
|
|
64
|
-
"read",
|
|
65
|
-
"update",
|
|
66
|
-
"delete"
|
|
67
|
-
],
|
|
68
|
-
context_config: [
|
|
69
|
-
"create",
|
|
70
|
-
"read",
|
|
71
|
-
"update",
|
|
72
|
-
"delete"
|
|
73
13
|
]
|
|
74
14
|
};
|
|
75
15
|
const ac = createAccessControl(statement);
|
|
76
16
|
const memberRole = ac.newRole({
|
|
77
17
|
project: ["read"],
|
|
78
|
-
agent: ["read"],
|
|
79
|
-
sub_agent: ["read"],
|
|
80
|
-
tool: ["read"],
|
|
81
|
-
api_key: ["read"],
|
|
82
|
-
credential: ["read"],
|
|
83
|
-
data_component: ["read"],
|
|
84
|
-
artifact_component: ["read"],
|
|
85
|
-
external_agent: ["read"],
|
|
86
|
-
function: ["read"],
|
|
87
|
-
context_config: ["read"],
|
|
88
18
|
...memberAc.statements
|
|
89
19
|
});
|
|
90
20
|
const adminRole = ac.newRole({
|
|
91
21
|
project: [
|
|
92
22
|
"create",
|
|
93
23
|
"read",
|
|
94
|
-
"update"
|
|
95
|
-
|
|
96
|
-
agent: [
|
|
97
|
-
"create",
|
|
98
|
-
"read",
|
|
99
|
-
"update"
|
|
100
|
-
],
|
|
101
|
-
sub_agent: [
|
|
102
|
-
"create",
|
|
103
|
-
"read",
|
|
104
|
-
"update"
|
|
105
|
-
],
|
|
106
|
-
tool: [
|
|
107
|
-
"create",
|
|
108
|
-
"read",
|
|
109
|
-
"update"
|
|
110
|
-
],
|
|
111
|
-
api_key: [
|
|
112
|
-
"create",
|
|
113
|
-
"read",
|
|
114
|
-
"update"
|
|
115
|
-
],
|
|
116
|
-
credential: [
|
|
117
|
-
"create",
|
|
118
|
-
"read",
|
|
119
|
-
"update"
|
|
120
|
-
],
|
|
121
|
-
data_component: [
|
|
122
|
-
"create",
|
|
123
|
-
"read",
|
|
124
|
-
"update"
|
|
125
|
-
],
|
|
126
|
-
artifact_component: [
|
|
127
|
-
"create",
|
|
128
|
-
"read",
|
|
129
|
-
"update"
|
|
130
|
-
],
|
|
131
|
-
external_agent: [
|
|
132
|
-
"create",
|
|
133
|
-
"read",
|
|
134
|
-
"update"
|
|
135
|
-
],
|
|
136
|
-
function: [
|
|
137
|
-
"create",
|
|
138
|
-
"read",
|
|
139
|
-
"update"
|
|
140
|
-
],
|
|
141
|
-
context_config: [
|
|
142
|
-
"create",
|
|
143
|
-
"read",
|
|
144
|
-
"update"
|
|
24
|
+
"update",
|
|
25
|
+
"delete"
|
|
145
26
|
],
|
|
146
27
|
...adminAc.statements
|
|
147
28
|
});
|
|
@@ -152,66 +33,6 @@ const ownerRole = ac.newRole({
|
|
|
152
33
|
"update",
|
|
153
34
|
"delete"
|
|
154
35
|
],
|
|
155
|
-
agent: [
|
|
156
|
-
"create",
|
|
157
|
-
"read",
|
|
158
|
-
"update",
|
|
159
|
-
"delete"
|
|
160
|
-
],
|
|
161
|
-
sub_agent: [
|
|
162
|
-
"create",
|
|
163
|
-
"read",
|
|
164
|
-
"update",
|
|
165
|
-
"delete"
|
|
166
|
-
],
|
|
167
|
-
tool: [
|
|
168
|
-
"create",
|
|
169
|
-
"read",
|
|
170
|
-
"update",
|
|
171
|
-
"delete"
|
|
172
|
-
],
|
|
173
|
-
api_key: [
|
|
174
|
-
"create",
|
|
175
|
-
"read",
|
|
176
|
-
"update",
|
|
177
|
-
"delete"
|
|
178
|
-
],
|
|
179
|
-
credential: [
|
|
180
|
-
"create",
|
|
181
|
-
"read",
|
|
182
|
-
"update",
|
|
183
|
-
"delete"
|
|
184
|
-
],
|
|
185
|
-
data_component: [
|
|
186
|
-
"create",
|
|
187
|
-
"read",
|
|
188
|
-
"update",
|
|
189
|
-
"delete"
|
|
190
|
-
],
|
|
191
|
-
artifact_component: [
|
|
192
|
-
"create",
|
|
193
|
-
"read",
|
|
194
|
-
"update",
|
|
195
|
-
"delete"
|
|
196
|
-
],
|
|
197
|
-
external_agent: [
|
|
198
|
-
"create",
|
|
199
|
-
"read",
|
|
200
|
-
"update",
|
|
201
|
-
"delete"
|
|
202
|
-
],
|
|
203
|
-
function: [
|
|
204
|
-
"create",
|
|
205
|
-
"read",
|
|
206
|
-
"update",
|
|
207
|
-
"delete"
|
|
208
|
-
],
|
|
209
|
-
context_config: [
|
|
210
|
-
"create",
|
|
211
|
-
"read",
|
|
212
|
-
"update",
|
|
213
|
-
"delete"
|
|
214
|
-
],
|
|
215
36
|
...ownerAc.statements
|
|
216
37
|
});
|
|
217
38
|
|
package/dist/client-exports.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import "./types/index.js";
|
|
|
6
6
|
import { DEFAULT_NANGO_STORE_ID } from "./credential-stores/default-constants.js";
|
|
7
7
|
import { detectAuthenticationRequired } from "./utils/auth-detection.js";
|
|
8
8
|
import { validatePropsAsJsonSchema } from "./validation/props-validation.js";
|
|
9
|
+
import "./index.js";
|
|
9
10
|
import { AgentStopWhen, AgentStopWhenSchema, ApiKeyApiUpdateSchema, FullAgentAgentInsertSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettings, ModelSettingsSchema, StopWhen, StopWhenSchema, SubAgentStopWhen, SubAgentStopWhenSchema } from "./validation/schemas.js";
|
|
10
11
|
import { z } from "@hono/zod-openapi";
|
|
11
12
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { projects, subAgentToolRelations, subAgents } from "../../db/manage/manage-schema.js";
|
|
1
|
+
import { projects, subAgentFunctionToolRelations, subAgentToolRelations, subAgents } from "../../db/manage/manage-schema.js";
|
|
2
2
|
import { generateId } from "../../utils/conversations.js";
|
|
3
3
|
import { validateAgentStructure, validateAndTypeAgentData } from "../../validation/agentFull.js";
|
|
4
4
|
import { upsertContextConfig } from "./contextConfigs.js";
|
|
5
5
|
import { upsertFunction } from "./functions.js";
|
|
6
|
-
import { upsertFunctionTool, upsertSubAgentFunctionToolRelation } from "./functionTools.js";
|
|
6
|
+
import { deleteFunctionTool, listFunctionTools, upsertFunctionTool, upsertSubAgentFunctionToolRelation } from "./functionTools.js";
|
|
7
7
|
import { deleteSubAgentExternalAgentRelation, getSubAgentExternalAgentRelationsByAgent, upsertSubAgentExternalAgentRelation } from "./subAgentExternalAgentRelations.js";
|
|
8
8
|
import { createSubAgentRelation, deleteAgentRelationsByAgent, deleteAgentToolRelationByAgent, upsertSubAgentRelation } from "./subAgentRelations.js";
|
|
9
9
|
import { deleteSubAgent, listSubAgents, upsertSubAgent } from "./subAgents.js";
|
|
@@ -735,6 +735,37 @@ const updateFullAgentServerSide = (db, logger = defaultLogger) => async (scopes,
|
|
|
735
735
|
functionToolCount: Object.keys(typedAgentDefinition.functionTools).length
|
|
736
736
|
}, "All function tools updated successfully");
|
|
737
737
|
}
|
|
738
|
+
const incomingFunctionToolIds = new Set(typedAgentDefinition.functionTools ? Object.keys(typedAgentDefinition.functionTools) : []);
|
|
739
|
+
const existingFunctionTools = await listFunctionTools(db)({
|
|
740
|
+
scopes: {
|
|
741
|
+
tenantId,
|
|
742
|
+
projectId,
|
|
743
|
+
agentId: finalAgentId
|
|
744
|
+
},
|
|
745
|
+
pagination: {
|
|
746
|
+
page: 1,
|
|
747
|
+
limit: 1e3
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
let deletedFunctionToolCount = 0;
|
|
751
|
+
for (const functionTool of existingFunctionTools.data) if (!incomingFunctionToolIds.has(functionTool.id)) try {
|
|
752
|
+
await deleteFunctionTool(db)({
|
|
753
|
+
scopes: {
|
|
754
|
+
tenantId,
|
|
755
|
+
projectId,
|
|
756
|
+
agentId: finalAgentId
|
|
757
|
+
},
|
|
758
|
+
functionToolId: functionTool.id
|
|
759
|
+
});
|
|
760
|
+
deletedFunctionToolCount++;
|
|
761
|
+
logger.info({ functionToolId: functionTool.id }, "Deleted orphaned function tool");
|
|
762
|
+
} catch (error) {
|
|
763
|
+
logger.error({
|
|
764
|
+
functionToolId: functionTool.id,
|
|
765
|
+
error
|
|
766
|
+
}, "Failed to delete orphaned function tool");
|
|
767
|
+
}
|
|
768
|
+
if (deletedFunctionToolCount > 0) logger.info({ deletedFunctionToolCount }, "Deleted orphaned function tools from agent");
|
|
738
769
|
const subAgentPromises = Object.entries(typedAgentDefinition.subAgents).map(async ([subAgentId, agentData$1]) => {
|
|
739
770
|
const subAgent = agentData$1;
|
|
740
771
|
let existingSubAgent = null;
|
|
@@ -910,6 +941,24 @@ const updateFullAgentServerSide = (db, logger = defaultLogger) => async (scopes,
|
|
|
910
941
|
error
|
|
911
942
|
}, "Failed to delete orphaned agent-tool relations");
|
|
912
943
|
}
|
|
944
|
+
const incomingFunctionToolRelationIds = /* @__PURE__ */ new Set();
|
|
945
|
+
for (const [_subAgentId, agentData$1] of Object.entries(typedAgentDefinition.subAgents)) if (agentData$1.canUse && Array.isArray(agentData$1.canUse)) {
|
|
946
|
+
for (const canUseItem of agentData$1.canUse) if (typedAgentDefinition.functionTools && canUseItem.toolId in typedAgentDefinition.functionTools && canUseItem.agentToolRelationId) incomingFunctionToolRelationIds.add(canUseItem.agentToolRelationId);
|
|
947
|
+
}
|
|
948
|
+
for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) try {
|
|
949
|
+
let deletedFunctionToolRelationCount = 0;
|
|
950
|
+
if (incomingFunctionToolRelationIds.size === 0) deletedFunctionToolRelationCount = (await db.delete(subAgentFunctionToolRelations).where(and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, finalAgentId), eq(subAgentFunctionToolRelations.subAgentId, subAgentId))).returning()).length;
|
|
951
|
+
else deletedFunctionToolRelationCount = (await db.delete(subAgentFunctionToolRelations).where(and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, finalAgentId), eq(subAgentFunctionToolRelations.subAgentId, subAgentId), not(inArray(subAgentFunctionToolRelations.id, Array.from(incomingFunctionToolRelationIds))))).returning()).length;
|
|
952
|
+
if (deletedFunctionToolRelationCount > 0) logger.info({
|
|
953
|
+
subAgentId,
|
|
954
|
+
deletedCount: deletedFunctionToolRelationCount
|
|
955
|
+
}, "Deleted orphaned sub-agent-function tool relations");
|
|
956
|
+
} catch (error) {
|
|
957
|
+
logger.error({
|
|
958
|
+
subAgentId,
|
|
959
|
+
error
|
|
960
|
+
}, "Failed to delete orphaned sub-agent-function tool relations");
|
|
961
|
+
}
|
|
913
962
|
const subAgentToolPromises = [];
|
|
914
963
|
for (const [subAgentId, agentData$1] of Object.entries(typedAgentDefinition.subAgents)) if (agentData$1.canUse && Array.isArray(agentData$1.canUse)) for (const canUseItem of agentData$1.canUse) subAgentToolPromises.push((async () => {
|
|
915
964
|
try {
|
|
@@ -103,6 +103,7 @@ interface ListProjectsWithMetadataResult {
|
|
|
103
103
|
declare const listProjectsWithMetadataPaginated: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: {
|
|
104
104
|
tenantId: string;
|
|
105
105
|
pagination?: PaginationConfig;
|
|
106
|
+
projectIds?: string[];
|
|
106
107
|
}) => Promise<ListProjectsWithMetadataResult>;
|
|
107
108
|
/**
|
|
108
109
|
* Get a single project with metadata from both runtime and config DBs
|
|
@@ -177,10 +177,11 @@ async function getProjectMetadataFromBranch(configDb, branchName, tenantId, proj
|
|
|
177
177
|
* @param configDb - Config database client (Doltgres)
|
|
178
178
|
*/
|
|
179
179
|
const listProjectsWithMetadataPaginated = (runDb, configDb) => async (params) => {
|
|
180
|
-
const { tenantId, pagination } = params;
|
|
180
|
+
const { tenantId, pagination, projectIds } = params;
|
|
181
181
|
const projectMetadataResult = await listProjectsMetadataPaginated(runDb)({
|
|
182
182
|
tenantId,
|
|
183
|
-
pagination
|
|
183
|
+
pagination,
|
|
184
|
+
projectIds
|
|
184
185
|
});
|
|
185
186
|
return {
|
|
186
187
|
data: await Promise.all(projectMetadataResult.data.map(async (projectMetadata) => {
|
|
@@ -6,16 +6,20 @@ import { ProjectInsert, ProjectSelect, ProjectUpdate } from "../../types/entitie
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* List all unique project IDs within a tenant by scanning all resource tables
|
|
9
|
+
* @param projectIds - Optional array of project IDs to filter by. If undefined, returns all projects.
|
|
9
10
|
*/
|
|
10
11
|
declare const listProjects: (db: AgentsManageDatabaseClient) => (params: {
|
|
11
12
|
tenantId: string;
|
|
13
|
+
projectIds?: string[];
|
|
12
14
|
}) => Promise<ProjectInfo[]>;
|
|
13
15
|
/**
|
|
14
16
|
* List all unique project IDs within a tenant with pagination
|
|
17
|
+
* Optionally filter by a list of project IDs (for access control)
|
|
15
18
|
*/
|
|
16
19
|
declare const listProjectsPaginated: (db: AgentsManageDatabaseClient) => (params: {
|
|
17
20
|
tenantId: string;
|
|
18
21
|
pagination?: PaginationConfig;
|
|
22
|
+
projectIds?: string[];
|
|
19
23
|
}) => Promise<{
|
|
20
24
|
data: ProjectSelect[];
|
|
21
25
|
pagination: PaginationResult;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { agents, artifactComponents, contextConfigs, credentialReferences, dataComponents, externalAgents, projects, subAgentArtifactComponents, subAgentDataComponents, subAgentRelations, subAgentToolRelations, subAgents, tools } from "../../db/manage/manage-schema.js";
|
|
2
|
-
import { and, count, desc, eq } from "drizzle-orm";
|
|
2
|
+
import { and, count, desc, eq, inArray } from "drizzle-orm";
|
|
3
3
|
|
|
4
4
|
//#region src/data-access/manage/projects.ts
|
|
5
5
|
/**
|
|
6
6
|
* List all unique project IDs within a tenant by scanning all resource tables
|
|
7
|
+
* @param projectIds - Optional array of project IDs to filter by. If undefined, returns all projects.
|
|
7
8
|
*/
|
|
8
9
|
const listProjects = (db) => async (params) => {
|
|
9
|
-
|
|
10
|
+
if (params.projectIds !== void 0 && params.projectIds.length === 0) return [];
|
|
11
|
+
const whereClause = params.projectIds ? and(eq(projects.tenantId, params.tenantId), inArray(projects.id, params.projectIds)) : eq(projects.tenantId, params.tenantId);
|
|
12
|
+
const projectsFromTable = await db.select({ projectId: projects.id }).from(projects).where(whereClause);
|
|
10
13
|
if (projectsFromTable.length > 0) return projectsFromTable.map((p) => ({ projectId: p.projectId }));
|
|
11
14
|
const projectIdSets = await Promise.all([
|
|
12
15
|
db.selectDistinct({ projectId: subAgents.projectId }).from(subAgents).where(eq(subAgents.tenantId, params.tenantId)),
|
|
@@ -25,19 +28,23 @@ const listProjects = (db) => async (params) => {
|
|
|
25
28
|
const allProjectIds = /* @__PURE__ */ new Set();
|
|
26
29
|
projectIdSets.forEach((results) => {
|
|
27
30
|
results.forEach((row) => {
|
|
28
|
-
if (row.projectId)
|
|
31
|
+
if (row.projectId) {
|
|
32
|
+
if (!params.projectIds || params.projectIds.includes(row.projectId)) allProjectIds.add(row.projectId);
|
|
33
|
+
}
|
|
29
34
|
});
|
|
30
35
|
});
|
|
31
36
|
return Array.from(allProjectIds).sort().map((projectId) => ({ projectId }));
|
|
32
37
|
};
|
|
33
38
|
/**
|
|
34
39
|
* List all unique project IDs within a tenant with pagination
|
|
40
|
+
* Optionally filter by a list of project IDs (for access control)
|
|
35
41
|
*/
|
|
36
42
|
const listProjectsPaginated = (db) => async (params) => {
|
|
37
43
|
const page = params.pagination?.page || 1;
|
|
38
44
|
const limit = params.pagination?.limit || 10;
|
|
39
45
|
const offset = (page - 1) * limit;
|
|
40
|
-
const
|
|
46
|
+
const whereClause = params.projectIds ? and(eq(projects.tenantId, params.tenantId), inArray(projects.id, params.projectIds)) : eq(projects.tenantId, params.tenantId);
|
|
47
|
+
const [data, totalResult] = await Promise.all([db.select().from(projects).where(whereClause).limit(limit).offset(offset).orderBy(desc(projects.createdAt)), db.select({ count: count() }).from(projects).where(whereClause)]);
|
|
41
48
|
const total = totalResult[0]?.count || 0;
|
|
42
49
|
return {
|
|
43
50
|
data,
|
|
@@ -25,7 +25,7 @@ declare const createConversation: (db: AgentsRunDatabaseClient) => (params: Conv
|
|
|
25
25
|
userId: string | null;
|
|
26
26
|
metadata: ConversationMetadata | null;
|
|
27
27
|
ref: {
|
|
28
|
-
type: "
|
|
28
|
+
type: "tag" | "commit" | "branch";
|
|
29
29
|
name: string;
|
|
30
30
|
hash: string;
|
|
31
31
|
} | null;
|
|
@@ -43,7 +43,7 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
43
43
|
agentId: string | null;
|
|
44
44
|
activeSubAgentId: string;
|
|
45
45
|
ref: {
|
|
46
|
-
type: "
|
|
46
|
+
type: "tag" | "commit" | "branch";
|
|
47
47
|
name: string;
|
|
48
48
|
hash: string;
|
|
49
49
|
} | null;
|
|
@@ -69,7 +69,7 @@ declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) =>
|
|
|
69
69
|
agentId: string | null;
|
|
70
70
|
activeSubAgentId: string;
|
|
71
71
|
ref: {
|
|
72
|
-
type: "
|
|
72
|
+
type: "tag" | "commit" | "branch";
|
|
73
73
|
name: string;
|
|
74
74
|
hash: string;
|
|
75
75
|
} | null;
|
|
@@ -94,7 +94,7 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
94
94
|
userId: string | null;
|
|
95
95
|
metadata: ConversationMetadata | null;
|
|
96
96
|
ref: {
|
|
97
|
-
type: "
|
|
97
|
+
type: "tag" | "commit" | "branch";
|
|
98
98
|
name: string;
|
|
99
99
|
hash: string;
|
|
100
100
|
} | null;
|
|
@@ -107,7 +107,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
107
107
|
tenantId: string;
|
|
108
108
|
id: string;
|
|
109
109
|
ref: {
|
|
110
|
-
type: "
|
|
110
|
+
type: "tag" | "commit" | "branch";
|
|
111
111
|
name: string;
|
|
112
112
|
hash: string;
|
|
113
113
|
};
|
|
@@ -130,7 +130,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
130
130
|
userId: string | null;
|
|
131
131
|
metadata: ConversationMetadata | null;
|
|
132
132
|
ref: {
|
|
133
|
-
type: "
|
|
133
|
+
type: "tag" | "commit" | "branch";
|
|
134
134
|
name: string;
|
|
135
135
|
hash: string;
|
|
136
136
|
} | null;
|
|
@@ -162,7 +162,7 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
162
162
|
userId: string | null;
|
|
163
163
|
metadata: ConversationMetadata | null;
|
|
164
164
|
ref: {
|
|
165
|
-
type: "
|
|
165
|
+
type: "tag" | "commit" | "branch";
|
|
166
166
|
name: string;
|
|
167
167
|
hash: string;
|
|
168
168
|
} | null;
|
|
@@ -16,19 +16,19 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
16
16
|
updatedAt: string;
|
|
17
17
|
metadata: MessageMetadata | null;
|
|
18
18
|
content: MessageContent;
|
|
19
|
-
conversationId: string;
|
|
20
19
|
role: string;
|
|
21
20
|
fromSubAgentId: string | null;
|
|
22
21
|
toSubAgentId: string | null;
|
|
23
22
|
fromExternalAgentId: string | null;
|
|
24
23
|
toExternalAgentId: string | null;
|
|
24
|
+
taskId: string | null;
|
|
25
|
+
a2aTaskId: string | null;
|
|
26
|
+
conversationId: string;
|
|
25
27
|
fromTeamAgentId: string | null;
|
|
26
28
|
toTeamAgentId: string | null;
|
|
27
29
|
visibility: string;
|
|
28
30
|
messageType: string;
|
|
29
|
-
taskId: string | null;
|
|
30
31
|
parentMessageId: string | null;
|
|
31
|
-
a2aTaskId: string | null;
|
|
32
32
|
a2aSessionId: string | null;
|
|
33
33
|
} | undefined>;
|
|
34
34
|
declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -147,19 +147,19 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageIn
|
|
|
147
147
|
updatedAt: string;
|
|
148
148
|
metadata: MessageMetadata | null;
|
|
149
149
|
content: MessageContent;
|
|
150
|
-
conversationId: string;
|
|
151
150
|
role: string;
|
|
152
151
|
fromSubAgentId: string | null;
|
|
153
152
|
toSubAgentId: string | null;
|
|
154
153
|
fromExternalAgentId: string | null;
|
|
155
154
|
toExternalAgentId: string | null;
|
|
155
|
+
taskId: string | null;
|
|
156
|
+
a2aTaskId: string | null;
|
|
157
|
+
conversationId: string;
|
|
156
158
|
fromTeamAgentId: string | null;
|
|
157
159
|
toTeamAgentId: string | null;
|
|
158
160
|
visibility: string;
|
|
159
161
|
messageType: string;
|
|
160
|
-
taskId: string | null;
|
|
161
162
|
parentMessageId: string | null;
|
|
162
|
-
a2aTaskId: string | null;
|
|
163
163
|
a2aSessionId: string | null;
|
|
164
164
|
}>;
|
|
165
165
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -200,19 +200,19 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
200
200
|
updatedAt: string;
|
|
201
201
|
metadata: MessageMetadata | null;
|
|
202
202
|
content: MessageContent;
|
|
203
|
-
conversationId: string;
|
|
204
203
|
role: string;
|
|
205
204
|
fromSubAgentId: string | null;
|
|
206
205
|
toSubAgentId: string | null;
|
|
207
206
|
fromExternalAgentId: string | null;
|
|
208
207
|
toExternalAgentId: string | null;
|
|
208
|
+
taskId: string | null;
|
|
209
|
+
a2aTaskId: string | null;
|
|
210
|
+
conversationId: string;
|
|
209
211
|
fromTeamAgentId: string | null;
|
|
210
212
|
toTeamAgentId: string | null;
|
|
211
213
|
visibility: string;
|
|
212
214
|
messageType: string;
|
|
213
|
-
taskId: string | null;
|
|
214
215
|
parentMessageId: string | null;
|
|
215
|
-
a2aTaskId: string | null;
|
|
216
216
|
a2aSessionId: string | null;
|
|
217
217
|
}>;
|
|
218
218
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -27,10 +27,12 @@ declare const listProjectsMetadata: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
27
27
|
}) => Promise<ProjectMetadataSelect[]>;
|
|
28
28
|
/**
|
|
29
29
|
* List runtimeProjects with pagination from the runtime DB
|
|
30
|
+
* @param projectIds - Optional array of project IDs to filter by. If undefined, returns all projects.
|
|
30
31
|
*/
|
|
31
32
|
declare const listProjectsMetadataPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
32
33
|
tenantId: string;
|
|
33
34
|
pagination?: PaginationConfig;
|
|
35
|
+
projectIds?: string[];
|
|
34
36
|
}) => Promise<ProjectMetadataPaginatedResult>;
|
|
35
37
|
/**
|
|
36
38
|
* Create a project in the runtime DB
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { projectMetadata } from "../../db/runtime/runtime-schema.js";
|
|
2
|
-
import { and, count, desc, eq } from "drizzle-orm";
|
|
2
|
+
import { and, count, desc, eq, inArray } from "drizzle-orm";
|
|
3
3
|
|
|
4
4
|
//#region src/data-access/runtime/projects.ts
|
|
5
5
|
/**
|
|
@@ -19,12 +19,26 @@ const listProjectsMetadata = (db) => async (params) => {
|
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* List runtimeProjects with pagination from the runtime DB
|
|
22
|
+
* @param projectIds - Optional array of project IDs to filter by. If undefined, returns all projects.
|
|
22
23
|
*/
|
|
23
24
|
const listProjectsMetadataPaginated = (db) => async (params) => {
|
|
24
25
|
const page = params.pagination?.page || 1;
|
|
25
26
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
26
27
|
const offset = (page - 1) * limit;
|
|
27
|
-
const
|
|
28
|
+
const conditions = [eq(projectMetadata.tenantId, params.tenantId)];
|
|
29
|
+
if (params.projectIds !== void 0) {
|
|
30
|
+
if (params.projectIds.length === 0) return {
|
|
31
|
+
data: [],
|
|
32
|
+
pagination: {
|
|
33
|
+
page,
|
|
34
|
+
limit,
|
|
35
|
+
total: 0,
|
|
36
|
+
pages: 0
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
conditions.push(inArray(projectMetadata.id, params.projectIds));
|
|
40
|
+
}
|
|
41
|
+
const whereClause = and(...conditions);
|
|
28
42
|
const [data, totalResult] = await Promise.all([db.select().from(projectMetadata).where(whereClause).limit(limit).offset(offset).orderBy(desc(projectMetadata.createdAt)), db.select({ count: count() }).from(projectMetadata).where(whereClause)]);
|
|
29
43
|
const total = totalResult[0]?.count || 0;
|
|
30
44
|
const totalNumber = typeof total === "string" ? Number.parseInt(total, 10) : total;
|
|
@@ -13,14 +13,14 @@ declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert)
|
|
|
13
13
|
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
15
|
metadata: TaskMetadataConfig | null;
|
|
16
|
-
|
|
16
|
+
status: string;
|
|
17
17
|
ref: {
|
|
18
|
-
type: "
|
|
18
|
+
type: "tag" | "commit" | "branch";
|
|
19
19
|
name: string;
|
|
20
20
|
hash: string;
|
|
21
21
|
} | null;
|
|
22
|
-
status: string;
|
|
23
22
|
subAgentId: string;
|
|
23
|
+
contextId: string;
|
|
24
24
|
}>;
|
|
25
25
|
declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
26
26
|
id: string;
|
|
@@ -36,7 +36,7 @@ declare const updateTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
36
36
|
updatedAt: string;
|
|
37
37
|
contextId: string;
|
|
38
38
|
ref: {
|
|
39
|
-
type: "
|
|
39
|
+
type: "tag" | "commit" | "branch";
|
|
40
40
|
name: string;
|
|
41
41
|
hash: string;
|
|
42
42
|
} | null;
|