@inkeep/agents-core 0.0.0-dev-20260122001454 → 0.0.0-dev-20260122003353

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.
@@ -69,8 +69,8 @@ declare const associateDataComponentWithAgent: (db: AgentsManageDatabaseClient)
69
69
  id: string;
70
70
  agentId: string;
71
71
  createdAt: string;
72
- subAgentId: string;
73
72
  dataComponentId: string;
73
+ subAgentId: string;
74
74
  }>;
75
75
  /**
76
76
  * Remove association between data component and agent
@@ -111,8 +111,8 @@ declare const upsertAgentDataComponentRelation: (db: AgentsManageDatabaseClient)
111
111
  id: string;
112
112
  agentId: string;
113
113
  createdAt: string;
114
- subAgentId: string;
115
114
  dataComponentId: string;
115
+ subAgentId: string;
116
116
  } | null>;
117
117
  /**
118
118
  * Count data components for a tenant/project
@@ -112,17 +112,19 @@ declare const getFunctionToolsForSubAgent: (db: AgentsManageDatabaseClient) => (
112
112
  agentId: string;
113
113
  };
114
114
  subAgentId: string;
115
+ pagination?: PaginationConfig;
115
116
  }) => Promise<{
116
117
  data: {
117
- createdAt: string;
118
- updatedAt: string;
118
+ id: string;
119
119
  name: string;
120
120
  description: string | null;
121
121
  functionId: string;
122
- agentId: string;
123
- projectId: string;
122
+ createdAt: string;
123
+ updatedAt: string;
124
124
  tenantId: string;
125
- id: string;
125
+ projectId: string;
126
+ agentId: string;
127
+ relationshipId: string;
126
128
  }[];
127
129
  pagination: {
128
130
  page: number;
@@ -96,32 +96,40 @@ const upsertFunctionTool = (db) => async (params) => {
96
96
  };
97
97
  const getFunctionToolsForSubAgent = (db) => {
98
98
  return async (params) => {
99
- const { scopes, subAgentId } = params;
100
- const { tenantId, projectId, agentId } = scopes;
99
+ const page = params.pagination?.page || 1;
100
+ const limit = Math.min(params.pagination?.limit || 1e3, 1e3);
101
+ const offset = (page - 1) * limit;
102
+ const { tenantId, projectId, agentId } = params.scopes;
101
103
  try {
102
- const functionToolsList = await listFunctionTools(db)({
103
- scopes: {
104
- tenantId,
105
- projectId,
106
- agentId
107
- },
104
+ const whereClause = and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId), eq(subAgentFunctionToolRelations.subAgentId, params.subAgentId));
105
+ const [data, totalResult] = await Promise.all([db.select({
106
+ id: functionTools.id,
107
+ name: functionTools.name,
108
+ description: functionTools.description,
109
+ functionId: functionTools.functionId,
110
+ createdAt: functionTools.createdAt,
111
+ updatedAt: functionTools.updatedAt,
112
+ tenantId: functionTools.tenantId,
113
+ projectId: functionTools.projectId,
114
+ agentId: functionTools.agentId,
115
+ relationshipId: subAgentFunctionToolRelations.id
116
+ }).from(subAgentFunctionToolRelations).innerJoin(functionTools, and(eq(subAgentFunctionToolRelations.functionToolId, functionTools.id), eq(subAgentFunctionToolRelations.tenantId, functionTools.tenantId), eq(subAgentFunctionToolRelations.projectId, functionTools.projectId), eq(subAgentFunctionToolRelations.agentId, functionTools.agentId))).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentFunctionToolRelations.createdAt)), db.select({ count: count() }).from(subAgentFunctionToolRelations).where(whereClause)]);
117
+ const total = totalResult[0]?.count || 0;
118
+ return {
119
+ data,
108
120
  pagination: {
109
- page: 1,
110
- limit: 1e3
121
+ page,
122
+ limit,
123
+ total,
124
+ pages: Math.ceil(total / limit)
111
125
  }
112
- });
113
- const relations$1 = await db.select().from(subAgentFunctionToolRelations).where(and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId), eq(subAgentFunctionToolRelations.subAgentId, subAgentId)));
114
- const relatedFunctionToolIds = new Set(relations$1.map((r) => r.functionToolId));
115
- return {
116
- data: functionToolsList.data.filter((ft) => relatedFunctionToolIds.has(ft.id)),
117
- pagination: functionToolsList.pagination
118
126
  };
119
127
  } catch (error) {
120
128
  logger.error({
121
129
  tenantId,
122
130
  projectId,
123
131
  agentId,
124
- subAgentId,
132
+ subAgentId: params.subAgentId,
125
133
  error
126
134
  }, "Failed to get function tools for agent");
127
135
  throw error;
@@ -19,8 +19,8 @@ declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert)
19
19
  hash: string;
20
20
  } | null;
21
21
  status: string;
22
- contextId: string;
23
22
  subAgentId: string;
23
+ contextId: string;
24
24
  }>;
25
25
  declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
26
26
  id: string;