@inkeep/agents-core 0.0.0-dev-20260120230946 → 0.0.0-dev-20260121032144

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.
Files changed (56) hide show
  1. package/dist/auth/auth.d.ts +53 -53
  2. package/dist/auth/auth.js +1 -1
  3. package/dist/auth/permissions.d.ts +13 -13
  4. package/dist/context/ContextConfig.js +3 -3
  5. package/dist/data-access/index.d.ts +5 -5
  6. package/dist/data-access/index.js +5 -5
  7. package/dist/data-access/manage/dataComponents.d.ts +2 -2
  8. package/dist/data-access/manage/evalConfig.d.ts +12 -2
  9. package/dist/data-access/manage/evalConfig.js +25 -1
  10. package/dist/data-access/manage/projectFull.d.ts +0 -4
  11. package/dist/data-access/manage/projectFull.js +8 -21
  12. package/dist/data-access/manage/tools.d.ts +8 -1
  13. package/dist/data-access/manage/tools.js +9 -1
  14. package/dist/data-access/manage/triggers.d.ts +0 -4
  15. package/dist/data-access/manage/triggers.js +1 -15
  16. package/dist/data-access/runtime/conversations.d.ts +7 -7
  17. package/dist/data-access/runtime/messages.d.ts +6 -6
  18. package/dist/data-access/runtime/organizations.d.ts +10 -1
  19. package/dist/data-access/runtime/organizations.js +13 -1
  20. package/dist/data-access/runtime/tasks.d.ts +2 -2
  21. package/dist/db/manage/manage-client.d.ts +3 -1
  22. package/dist/db/manage/manage-client.js +13 -1
  23. package/dist/db/manage/manage-schema.d.ts +299 -299
  24. package/dist/db/migrations/cleanup-old-trigger-auth.d.ts +1 -0
  25. package/dist/db/migrations/cleanup-old-trigger-auth.js +68 -0
  26. package/dist/db/runtime/runtime-schema.d.ts +163 -163
  27. package/dist/dolt/branch.d.ts +4 -53
  28. package/dist/dolt/branch.js +23 -81
  29. package/dist/dolt/branches-api.js +1 -1
  30. package/dist/dolt/index.d.ts +5 -3
  31. package/dist/dolt/index.js +5 -3
  32. package/dist/dolt/migrate-all-branches.js +1 -1
  33. package/dist/dolt/{ref.d.ts → ref-helpers.d.ts} +5 -2
  34. package/dist/dolt/{ref.js → ref-helpers.js} +15 -3
  35. package/dist/dolt/ref-middleware.d.ts +82 -0
  36. package/dist/dolt/ref-middleware.js +217 -0
  37. package/dist/dolt/ref-scope.d.ts +101 -0
  38. package/dist/dolt/ref-scope.js +231 -0
  39. package/dist/env.d.ts +2 -2
  40. package/dist/env.js +1 -1
  41. package/dist/index.d.ts +12 -10
  42. package/dist/index.js +15 -13
  43. package/dist/types/entities.d.ts +3 -2
  44. package/dist/types/index.d.ts +2 -2
  45. package/dist/utils/index.d.ts +2 -2
  46. package/dist/utils/index.js +2 -2
  47. package/dist/utils/third-party-mcp-servers/composio-client.js +23 -23
  48. package/dist/utils/trigger-auth.d.ts +37 -7
  49. package/dist/utils/trigger-auth.js +72 -77
  50. package/dist/validation/dolt-schemas.d.ts +1 -1
  51. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  52. package/dist/validation/index.d.ts +2 -2
  53. package/dist/validation/index.js +2 -2
  54. package/dist/validation/schemas.d.ts +1372 -1385
  55. package/dist/validation/schemas.js +23 -28
  56. package/package.json +2 -1
@@ -1,4 +1,5 @@
1
1
  import { dataset, datasetItem, datasetRunConfig, datasetRunConfigAgentRelations, evaluationJobConfig, evaluationJobConfigEvaluatorRelations, evaluationRunConfig, evaluationRunConfigEvaluationSuiteConfigRelations, evaluationSuiteConfig, evaluationSuiteConfigEvaluatorRelations, evaluator } from "../../db/manage/manage-schema.js";
2
+ import { datasetRun } from "../../db/runtime/runtime-schema.js";
2
3
  import { and, eq, inArray } from "drizzle-orm";
3
4
 
4
5
  //#region src/data-access/manage/evalConfig.ts
@@ -177,6 +178,26 @@ const getEvaluationRunConfigById = (db) => async (params) => {
177
178
  const listEvaluationRunConfigs = (db) => async (params) => {
178
179
  return await db.select().from(evaluationRunConfig).where(and(eq(evaluationRunConfig.tenantId, params.scopes.tenantId), eq(evaluationRunConfig.projectId, params.scopes.projectId)));
179
180
  };
181
+ const listEvaluationRunConfigsWithSuiteConfigs = (db) => async (params) => {
182
+ const rows = await db.select({
183
+ runConfig: evaluationRunConfig,
184
+ suiteConfigId: evaluationRunConfigEvaluationSuiteConfigRelations.evaluationSuiteConfigId
185
+ }).from(evaluationRunConfig).leftJoin(evaluationRunConfigEvaluationSuiteConfigRelations, and(eq(evaluationRunConfigEvaluationSuiteConfigRelations.tenantId, evaluationRunConfig.tenantId), eq(evaluationRunConfigEvaluationSuiteConfigRelations.projectId, evaluationRunConfig.projectId), eq(evaluationRunConfigEvaluationSuiteConfigRelations.evaluationRunConfigId, evaluationRunConfig.id))).where(and(eq(evaluationRunConfig.tenantId, params.scopes.tenantId), eq(evaluationRunConfig.projectId, params.scopes.projectId)));
186
+ const runConfigsById = /* @__PURE__ */ new Map();
187
+ for (const row of rows) {
188
+ const runConfig = row.runConfig;
189
+ const runConfigId = runConfig.id;
190
+ if (!runConfigsById.has(runConfigId)) {
191
+ const { tenantId: _tenantId, projectId: _projectId, ...apiRunConfig } = runConfig;
192
+ runConfigsById.set(runConfigId, {
193
+ ...apiRunConfig,
194
+ suiteConfigIds: []
195
+ });
196
+ }
197
+ if (row.suiteConfigId) runConfigsById.get(runConfigId)?.suiteConfigIds.push(row.suiteConfigId);
198
+ }
199
+ return Array.from(runConfigsById.values());
200
+ };
180
201
  const createEvaluationRunConfig = (db) => async (data) => {
181
202
  const now = (/* @__PURE__ */ new Date()).toISOString();
182
203
  const [created] = await db.insert(evaluationRunConfig).values({
@@ -246,6 +267,9 @@ const deleteEvaluationJobConfigEvaluatorRelation = (db) => async (params) => {
246
267
  const deleteEvaluationJobConfigEvaluatorRelationsByEvaluator = (db) => async (params) => {
247
268
  return (await db.delete(evaluationJobConfigEvaluatorRelations).where(and(eq(evaluationJobConfigEvaluatorRelations.tenantId, params.scopes.tenantId), eq(evaluationJobConfigEvaluatorRelations.projectId, params.scopes.projectId), eq(evaluationJobConfigEvaluatorRelations.evaluatorId, params.scopes.evaluatorId))).returning()).length;
248
269
  };
270
+ const linkDatasetRunToEvaluationJobConfig = (db) => async (params) => {
271
+ await db.update(datasetRun).set({ evaluationJobConfigId: params.evaluationJobConfigId }).where(and(eq(datasetRun.tenantId, params.scopes.tenantId), eq(datasetRun.projectId, params.scopes.projectId), eq(datasetRun.id, params.scopes.datasetRunId)));
272
+ };
249
273
 
250
274
  //#endregion
251
- export { createDataset, createDatasetItem, createDatasetItems, createDatasetRunConfig, createDatasetRunConfigAgentRelation, createEvaluationJobConfig, createEvaluationJobConfigEvaluatorRelation, createEvaluationRunConfig, createEvaluationRunConfigEvaluationSuiteConfigRelation, createEvaluationSuiteConfig, createEvaluationSuiteConfigEvaluatorRelation, createEvaluator, deleteDataset, deleteDatasetItem, deleteDatasetItemsByDataset, deleteDatasetRunConfig, deleteDatasetRunConfigAgentRelation, deleteEvaluationJobConfig, deleteEvaluationJobConfigEvaluatorRelation, deleteEvaluationJobConfigEvaluatorRelationsByEvaluator, deleteEvaluationRunConfig, deleteEvaluationRunConfigEvaluationSuiteConfigRelation, deleteEvaluationSuiteConfig, deleteEvaluationSuiteConfigEvaluatorRelation, deleteEvaluationSuiteConfigEvaluatorRelationsByEvaluator, deleteEvaluator, getDatasetById, getDatasetItemById, getDatasetRunConfigAgentRelations, getDatasetRunConfigById, getEvaluationJobConfigById, getEvaluationJobConfigEvaluatorRelations, getEvaluationRunConfigById, getEvaluationRunConfigEvaluationSuiteConfigRelations, getEvaluationSuiteConfigById, getEvaluationSuiteConfigEvaluatorRelations, getEvaluatorById, getEvaluatorsByIds, listDatasetItems, listDatasetRunConfigs, listDatasets, listEvaluationJobConfigs, listEvaluationRunConfigs, listEvaluationSuiteConfigs, listEvaluators, updateDataset, updateDatasetItem, updateDatasetRunConfig, updateEvaluationRunConfig, updateEvaluationSuiteConfig, updateEvaluator };
275
+ export { createDataset, createDatasetItem, createDatasetItems, createDatasetRunConfig, createDatasetRunConfigAgentRelation, createEvaluationJobConfig, createEvaluationJobConfigEvaluatorRelation, createEvaluationRunConfig, createEvaluationRunConfigEvaluationSuiteConfigRelation, createEvaluationSuiteConfig, createEvaluationSuiteConfigEvaluatorRelation, createEvaluator, deleteDataset, deleteDatasetItem, deleteDatasetItemsByDataset, deleteDatasetRunConfig, deleteDatasetRunConfigAgentRelation, deleteEvaluationJobConfig, deleteEvaluationJobConfigEvaluatorRelation, deleteEvaluationJobConfigEvaluatorRelationsByEvaluator, deleteEvaluationRunConfig, deleteEvaluationRunConfigEvaluationSuiteConfigRelation, deleteEvaluationSuiteConfig, deleteEvaluationSuiteConfigEvaluatorRelation, deleteEvaluationSuiteConfigEvaluatorRelationsByEvaluator, deleteEvaluator, getDatasetById, getDatasetItemById, getDatasetRunConfigAgentRelations, getDatasetRunConfigById, getEvaluationJobConfigById, getEvaluationJobConfigEvaluatorRelations, getEvaluationRunConfigById, getEvaluationRunConfigEvaluationSuiteConfigRelations, getEvaluationSuiteConfigById, getEvaluationSuiteConfigEvaluatorRelations, getEvaluatorById, getEvaluatorsByIds, linkDatasetRunToEvaluationJobConfig, listDatasetItems, listDatasetRunConfigs, listDatasets, listEvaluationJobConfigs, listEvaluationRunConfigs, listEvaluationRunConfigsWithSuiteConfigs, listEvaluationSuiteConfigs, listEvaluators, updateDataset, updateDatasetItem, updateDatasetRunConfig, updateEvaluationRunConfig, updateEvaluationSuiteConfig, updateEvaluator };
@@ -24,13 +24,9 @@ declare const updateFullProjectServerSide: (db: AgentsManageDatabaseClient, logg
24
24
  }) => Promise<FullProjectSelect>;
25
25
  declare const getFullProject: (db: AgentsManageDatabaseClient, logger?: ProjectLogger) => (params: {
26
26
  scopes: ProjectScopeConfig;
27
- /** Optional branch name to query from. If not provided, uses the project's main branch. */
28
- branchName?: string;
29
27
  }) => Promise<FullProjectSelect | null>;
30
28
  declare const getFullProjectWithRelationIds: (db: AgentsManageDatabaseClient, logger?: ProjectLogger) => (params: {
31
29
  scopes: ProjectScopeConfig;
32
- /** Optional branch name to query from. If not provided, uses the project's main branch. */
33
- branchName?: string;
34
30
  }) => Promise<FullProjectSelectWithRelationIds | null>;
35
31
  /**
36
32
  * Delete a complete project and cascade to all related entities
@@ -3,7 +3,6 @@ import { deleteExternalAgent, listExternalAgents, upsertExternalAgent } from "./
3
3
  import { deleteFunction, listFunctions, upsertFunction } from "./functions.js";
4
4
  import { deleteCredentialReference, listCredentialReferences, upsertCredentialReference } from "./credentialReferences.js";
5
5
  import { deleteTool, listTools, upsertTool } from "./tools.js";
6
- import { getProjectBranchName, withBranch } from "../../dolt/branch.js";
7
6
  import { listAgents } from "./agents.js";
8
7
  import { deleteArtifactComponent, listArtifactComponents, upsertArtifactComponent } from "./artifactComponents.js";
9
8
  import { deleteDataComponent, listDataComponents, upsertDataComponent } from "./dataComponents.js";
@@ -1091,29 +1090,17 @@ const getFullProjectInternal = (db, logger = defaultLogger) => async (params) =>
1091
1090
  }
1092
1091
  };
1093
1092
  const getFullProject = (db, logger = defaultLogger) => async (params) => {
1094
- const { scopes, branchName } = params;
1095
- const targetBranch = branchName ?? getProjectBranchName(scopes.tenantId, scopes.projectId);
1096
- return withBranch(db)({
1097
- branchName: targetBranch,
1098
- callback: async (txDb) => {
1099
- return getFullProjectInternal(txDb, logger)({
1100
- scopes,
1101
- includeRelationIds: false
1102
- });
1103
- }
1093
+ const { scopes } = params;
1094
+ return getFullProjectInternal(db, logger)({
1095
+ scopes,
1096
+ includeRelationIds: false
1104
1097
  });
1105
1098
  };
1106
1099
  const getFullProjectWithRelationIds = (db, logger = defaultLogger) => async (params) => {
1107
- const { scopes, branchName } = params;
1108
- const targetBranch = branchName ?? getProjectBranchName(scopes.tenantId, scopes.projectId);
1109
- return withBranch(db)({
1110
- branchName: targetBranch,
1111
- callback: async (txDb) => {
1112
- return getFullProjectInternal(txDb, logger)({
1113
- scopes,
1114
- includeRelationIds: true
1115
- });
1116
- }
1100
+ const { scopes } = params;
1101
+ return getFullProjectInternal(db, logger)({
1102
+ scopes,
1103
+ includeRelationIds: true
1117
1104
  });
1118
1105
  };
1119
1106
  /**
@@ -30,6 +30,13 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
30
30
  capabilities: ToolServerCapabilities | null;
31
31
  lastError: string | null;
32
32
  } | null>;
33
+ declare const getMcpToolById: (db: AgentsManageDatabaseClient) => (params: {
34
+ scopes: ProjectScopeConfig;
35
+ toolId: string;
36
+ relationshipId?: string;
37
+ credentialStoreRegistry?: CredentialStoreRegistry;
38
+ userId?: string;
39
+ }) => Promise<McpTool | null>;
33
40
  declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
34
41
  scopes: ProjectScopeConfig;
35
42
  pagination?: PaginationConfig;
@@ -202,4 +209,4 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
202
209
  lastError: string | null;
203
210
  }>;
204
211
  //#endregion
205
- export { addToolToAgent, createTool, dbResultToMcpTool, deleteTool, getToolById, listTools, removeToolFromAgent, updateTool, upsertSubAgentToolRelation, upsertTool };
212
+ export { addToolToAgent, createTool, dbResultToMcpTool, deleteTool, getMcpToolById, getToolById, listTools, removeToolFromAgent, updateTool, upsertSubAgentToolRelation, upsertTool };
@@ -240,6 +240,14 @@ const dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry, re
240
240
  const getToolById = (db) => async (params) => {
241
241
  return await db.query.tools.findFirst({ where: and(eq(tools.tenantId, params.scopes.tenantId), eq(tools.projectId, params.scopes.projectId), eq(tools.id, params.toolId)) }) ?? null;
242
242
  };
243
+ const getMcpToolById = (db) => async (params) => {
244
+ const tool = await getToolById(db)({
245
+ scopes: params.scopes,
246
+ toolId: params.toolId
247
+ });
248
+ if (!tool) return null;
249
+ return await dbResultToMcpTool(tool, db, params.credentialStoreRegistry, params.relationshipId, params.userId);
250
+ };
243
251
  const listTools = (db) => async (params) => {
244
252
  const page = params.pagination?.page || 1;
245
253
  const limit = Math.min(params.pagination?.limit || 10, 100);
@@ -343,4 +351,4 @@ const upsertTool = (db) => async (params) => {
343
351
  };
344
352
 
345
353
  //#endregion
346
- export { addToolToAgent, createTool, dbResultToMcpTool, deleteTool, getToolById, listTools, removeToolFromAgent, updateTool, upsertSubAgentToolRelation, upsertTool };
354
+ export { addToolToAgent, createTool, dbResultToMcpTool, deleteTool, getMcpToolById, getToolById, listTools, removeToolFromAgent, updateTool, upsertSubAgentToolRelation, upsertTool };
@@ -6,14 +6,10 @@ import { TriggerInsert, TriggerSelect, TriggerUpdate } from "../../types/entitie
6
6
 
7
7
  /**
8
8
  * Get a trigger by ID (agent-scoped)
9
- * Uses withBranch to checkout the project's main branch and query using Drizzle ORM,
10
- * which handles column name mapping automatically.
11
9
  */
12
10
  declare const getTriggerById: (db: AgentsManageDatabaseClient) => (params: {
13
11
  scopes: AgentScopeConfig;
14
12
  triggerId: string;
15
- /** If true, uses withBranch to read from the project branch. Default: true for non-branch-scoped clients */
16
- useBranchScope?: boolean;
17
13
  }) => Promise<TriggerSelect | undefined>;
18
14
  /**
19
15
  * List all triggers for an agent
@@ -1,26 +1,12 @@
1
1
  import { triggers } from "../../db/manage/manage-schema.js";
2
- import { getProjectBranchName, withBranch } from "../../dolt/branch.js";
3
2
  import { and, count, desc, eq } from "drizzle-orm";
4
3
 
5
4
  //#region src/data-access/manage/triggers.ts
6
5
  /**
7
6
  * Get a trigger by ID (agent-scoped)
8
- * Uses withBranch to checkout the project's main branch and query using Drizzle ORM,
9
- * which handles column name mapping automatically.
10
7
  */
11
8
  const getTriggerById = (db) => async (params) => {
12
- const { scopes, triggerId, useBranchScope = true } = params;
13
- if (useBranchScope) {
14
- const branchName = getProjectBranchName(scopes.tenantId, scopes.projectId);
15
- try {
16
- return await withBranch(db)({
17
- branchName,
18
- callback: async (txDb) => {
19
- return await txDb.query.triggers.findFirst({ where: and(eq(triggers.tenantId, scopes.tenantId), eq(triggers.projectId, scopes.projectId), eq(triggers.agentId, scopes.agentId), eq(triggers.id, triggerId)) });
20
- }
21
- });
22
- } catch {}
23
- }
9
+ const { scopes, triggerId } = params;
24
10
  return await db.query.triggers.findFirst({ where: and(eq(triggers.tenantId, scopes.tenantId), eq(triggers.projectId, scopes.projectId), eq(triggers.agentId, scopes.agentId), eq(triggers.id, triggerId)) });
25
11
  };
26
12
  /**
@@ -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: "tag" | "commit" | "branch";
28
+ type: "commit" | "tag" | "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: "tag" | "commit" | "branch";
46
+ type: "commit" | "tag" | "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: "tag" | "commit" | "branch";
72
+ type: "commit" | "tag" | "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: "tag" | "commit" | "branch";
97
+ type: "commit" | "tag" | "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: "tag" | "commit" | "branch";
110
+ type: "commit" | "tag" | "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: "tag" | "commit" | "branch";
133
+ type: "commit" | "tag" | "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: "tag" | "commit" | "branch";
165
+ type: "commit" | "tag" | "branch";
166
166
  name: string;
167
167
  hash: string;
168
168
  } | null;
@@ -18,15 +18,15 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
18
18
  content: MessageContent;
19
19
  role: string;
20
20
  conversationId: string;
21
+ taskId: string | null;
22
+ visibility: string;
21
23
  fromSubAgentId: string | null;
22
24
  toSubAgentId: string | null;
23
25
  fromExternalAgentId: string | null;
24
26
  toExternalAgentId: string | null;
25
27
  fromTeamAgentId: string | null;
26
28
  toTeamAgentId: string | null;
27
- visibility: string;
28
29
  messageType: string;
29
- taskId: string | null;
30
30
  parentMessageId: string | null;
31
31
  a2aTaskId: string | null;
32
32
  a2aSessionId: string | null;
@@ -149,15 +149,15 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageIn
149
149
  content: MessageContent;
150
150
  role: string;
151
151
  conversationId: string;
152
+ taskId: string | null;
153
+ visibility: string;
152
154
  fromSubAgentId: string | null;
153
155
  toSubAgentId: string | null;
154
156
  fromExternalAgentId: string | null;
155
157
  toExternalAgentId: string | null;
156
158
  fromTeamAgentId: string | null;
157
159
  toTeamAgentId: string | null;
158
- visibility: string;
159
160
  messageType: string;
160
- taskId: string | null;
161
161
  parentMessageId: string | null;
162
162
  a2aTaskId: string | null;
163
163
  a2aSessionId: string | null;
@@ -202,15 +202,15 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
202
202
  content: MessageContent;
203
203
  role: string;
204
204
  conversationId: string;
205
+ taskId: string | null;
206
+ visibility: string;
205
207
  fromSubAgentId: string | null;
206
208
  toSubAgentId: string | null;
207
209
  fromExternalAgentId: string | null;
208
210
  toExternalAgentId: string | null;
209
211
  fromTeamAgentId: string | null;
210
212
  toTeamAgentId: string | null;
211
- visibility: string;
212
213
  messageType: string;
213
- taskId: string | null;
214
214
  parentMessageId: string | null;
215
215
  a2aTaskId: string | null;
216
216
  a2aSessionId: string | null;
@@ -39,5 +39,14 @@ declare const addUserToOrganization: (db: AgentsRunDatabaseClient) => (data: {
39
39
  organizationId: string;
40
40
  role: string;
41
41
  }) => Promise<void>;
42
+ declare const upsertOrganization: (db: AgentsRunDatabaseClient) => (data: {
43
+ organizationId: string;
44
+ name: string;
45
+ slug: string;
46
+ logo?: string | null;
47
+ metadata?: string | null;
48
+ }) => Promise<{
49
+ created: boolean;
50
+ }>;
42
51
  //#endregion
43
- export { addUserToOrganization, getPendingInvitationsByEmail, getUserOrganizations };
52
+ export { addUserToOrganization, getPendingInvitationsByEmail, getUserOrganizations, upsertOrganization };
@@ -58,6 +58,18 @@ const addUserToOrganization = (db) => async (data) => {
58
58
  createdAt: /* @__PURE__ */ new Date()
59
59
  });
60
60
  };
61
+ const upsertOrganization = (db) => async (data) => {
62
+ if ((await db.select().from(organization).where(eq(organization.id, data.organizationId)).limit(1)).length > 0) return { created: false };
63
+ await db.insert(organization).values({
64
+ id: data.organizationId,
65
+ name: data.name,
66
+ slug: data.slug,
67
+ createdAt: /* @__PURE__ */ new Date(),
68
+ logo: data.logo ?? null,
69
+ metadata: data.metadata ?? null
70
+ });
71
+ return { created: true };
72
+ };
61
73
 
62
74
  //#endregion
63
- export { addUserToOrganization, getPendingInvitationsByEmail, getUserOrganizations };
75
+ export { addUserToOrganization, getPendingInvitationsByEmail, getUserOrganizations, upsertOrganization };
@@ -14,7 +14,7 @@ declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert)
14
14
  updatedAt: string;
15
15
  metadata: TaskMetadataConfig | null;
16
16
  ref: {
17
- type: "tag" | "commit" | "branch";
17
+ type: "commit" | "tag" | "branch";
18
18
  name: string;
19
19
  hash: string;
20
20
  } | null;
@@ -36,7 +36,7 @@ declare const updateTask: (db: AgentsRunDatabaseClient) => (params: {
36
36
  updatedAt: string;
37
37
  contextId: string;
38
38
  ref: {
39
- type: "tag" | "commit" | "branch";
39
+ type: "commit" | "tag" | "branch";
40
40
  name: string;
41
41
  hash: string;
42
42
  } | null;
@@ -1,5 +1,6 @@
1
1
  import { manage_schema_d_exports } from "./manage-schema.js";
2
2
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
3
+ import { Pool } from "pg";
3
4
  import { PgliteDatabase } from "drizzle-orm/pglite";
4
5
 
5
6
  //#region src/db/manage/manage-client.d.ts
@@ -12,6 +13,7 @@ interface AgentsManageDatabaseConfig {
12
13
  logQuery: (query: string, params: unknown[]) => void;
13
14
  };
14
15
  }
16
+ declare function createAgentsManageDatabasePool(config: AgentsManageDatabaseConfig): Pool;
15
17
  /**
16
18
  * Creates a PostgreSQL database client with connection pooling
17
19
  */
@@ -21,4 +23,4 @@ declare function createAgentManageDatabaseConnection(config: AgentsManageDatabas
21
23
  release: () => Promise<void>;
22
24
  }>;
23
25
  //#endregion
24
- export { AgentsManageDatabaseClient, AgentsManageDatabaseConfig, createAgentManageDatabaseConnection, createAgentsManageDatabaseClient };
26
+ export { AgentsManageDatabaseClient, AgentsManageDatabaseConfig, createAgentManageDatabaseConnection, createAgentsManageDatabaseClient, createAgentsManageDatabasePool };
@@ -6,6 +6,18 @@ import { Pool } from "pg";
6
6
 
7
7
  //#region src/db/manage/manage-client.ts
8
8
  loadEnvironmentFiles();
9
+ function createAgentsManageDatabasePool(config) {
10
+ const connectionString = config.connectionString || env.INKEEP_AGENTS_MANAGE_DATABASE_URL;
11
+ if (!connectionString) throw new Error("INKEEP_AGENTS_MANAGE_DATABASE_URL environment variable is required. Please set it to your PostgreSQL connection string.");
12
+ const pool = new Pool({
13
+ connectionString,
14
+ max: config.poolSize || Number(env.POSTGRES_POOL_SIZE) || 100
15
+ });
16
+ pool.on("error", (err) => {
17
+ console.error("Unexpected PostgreSQL pool error:", err);
18
+ });
19
+ return pool;
20
+ }
9
21
  /**
10
22
  * Creates a PostgreSQL database client with connection pooling
11
23
  */
@@ -53,4 +65,4 @@ function createAgentManageDatabaseConnection(config) {
53
65
  }
54
66
 
55
67
  //#endregion
56
- export { createAgentManageDatabaseConnection, createAgentsManageDatabaseClient };
68
+ export { createAgentManageDatabaseConnection, createAgentsManageDatabaseClient, createAgentsManageDatabasePool };