@inkeep/agents-core 0.58.8 → 0.58.9

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 (31) hide show
  1. package/dist/auth/auth-schema.d.ts +85 -85
  2. package/dist/auth/auth-validation-schemas.d.ts +152 -152
  3. package/dist/auth/auth.d.ts +9 -9
  4. package/dist/auth/permissions.d.ts +9 -9
  5. package/dist/client-exports.d.ts +2 -2
  6. package/dist/data-access/manage/agents.d.ts +40 -40
  7. package/dist/data-access/manage/artifactComponents.d.ts +12 -12
  8. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  9. package/dist/data-access/manage/credentialReferences.d.ts +3 -1
  10. package/dist/data-access/manage/credentialReferences.js +25 -4
  11. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  12. package/dist/data-access/manage/functionTools.d.ts +18 -18
  13. package/dist/data-access/manage/skills.d.ts +14 -14
  14. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
  15. package/dist/data-access/manage/subAgentRelations.d.ts +28 -28
  16. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
  17. package/dist/data-access/manage/subAgents.d.ts +24 -24
  18. package/dist/data-access/manage/tools.d.ts +24 -24
  19. package/dist/data-access/manage/triggers.d.ts +2 -2
  20. package/dist/data-access/runtime/apiKeys.d.ts +16 -16
  21. package/dist/data-access/runtime/apps.d.ts +8 -8
  22. package/dist/data-access/runtime/conversations.d.ts +24 -24
  23. package/dist/data-access/runtime/messages.d.ts +18 -18
  24. package/dist/data-access/runtime/tasks.d.ts +7 -7
  25. package/dist/db/manage/manage-schema.d.ts +453 -453
  26. package/dist/db/runtime/runtime-schema.d.ts +324 -324
  27. package/dist/middleware/no-auth.d.ts +2 -2
  28. package/dist/utils/error.d.ts +51 -51
  29. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  30. package/dist/validation/schemas.d.ts +2176 -2176
  31. package/package.json +1 -1
@@ -1273,25 +1273,25 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1273
1273
  ac: better_auth_plugins0.AccessControl;
1274
1274
  roles: {
1275
1275
  member: {
1276
- authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
1277
- actions: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>[key];
1276
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1277
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1278
1278
  connector: "OR" | "AND";
1279
1279
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1280
- statements: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>;
1280
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1281
1281
  };
1282
1282
  admin: {
1283
- authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
1284
- actions: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>[key];
1283
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1284
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1285
1285
  connector: "OR" | "AND";
1286
1286
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1287
- statements: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>;
1287
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1288
1288
  };
1289
1289
  owner: {
1290
- authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
1291
- actions: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>[key];
1290
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1291
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1292
1292
  connector: "OR" | "AND";
1293
1293
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1294
- statements: better_auth_plugins0.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins0.Statements>;
1294
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1295
1295
  };
1296
1296
  };
1297
1297
  creatorRole: "admin";
@@ -5,25 +5,25 @@ import { organizationClient } from "better-auth/client/plugins";
5
5
  //#region src/auth/permissions.d.ts
6
6
  declare const ac: AccessControl;
7
7
  declare const memberRole: {
8
- authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>[key] | {
9
- actions: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>[key];
8
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key] | {
9
+ actions: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key];
10
10
  connector: "OR" | "AND";
11
11
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins35.AuthorizeResponse;
12
- statements: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>;
12
+ statements: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>;
13
13
  };
14
14
  declare const adminRole: {
15
- authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>[key] | {
16
- actions: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>[key];
15
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key] | {
16
+ actions: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key];
17
17
  connector: "OR" | "AND";
18
18
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins35.AuthorizeResponse;
19
- statements: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>;
19
+ statements: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>;
20
20
  };
21
21
  declare const ownerRole: {
22
- authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>[key] | {
23
- actions: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>[key];
22
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key] | {
23
+ actions: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key];
24
24
  connector: "OR" | "AND";
25
25
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins35.AuthorizeResponse;
26
- statements: better_auth_plugins35.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins35.Statements>;
26
+ statements: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>;
27
27
  };
28
28
  //#endregion
29
29
  export { ac, adminRole, memberRole, organizationClient, ownerRole };
@@ -19,6 +19,8 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
19
19
  subAgents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
20
20
  id: z.ZodString;
21
21
  name: z.ZodString;
22
+ createdAt: z.ZodOptional<z.ZodString>;
23
+ updatedAt: z.ZodOptional<z.ZodString>;
22
24
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
25
  conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
24
26
  models: z.ZodOptional<z.ZodObject<{
@@ -35,8 +37,6 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
35
37
  providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
36
38
  }, z.core.$strip>>;
37
39
  }, z.core.$strip>>;
38
- createdAt: z.ZodOptional<z.ZodString>;
39
- updatedAt: z.ZodOptional<z.ZodString>;
40
40
  type: z.ZodLiteral<"internal">;
41
41
  canUse: z.ZodArray<z.ZodObject<{
42
42
  agentToolRelationId: z.ZodOptional<z.ZodString>;
@@ -11,10 +11,12 @@ declare const getAgentById: (db: AgentsManageDatabaseClient) => (params: {
11
11
  }) => Promise<{
12
12
  id: string;
13
13
  name: string;
14
+ createdAt: string;
15
+ updatedAt: string;
14
16
  description: string | null;
15
- defaultSubAgentId: string | null;
16
- tenantId: string;
17
- projectId: string;
17
+ stopWhen: {
18
+ transferCountIs?: number | undefined;
19
+ } | null;
18
20
  prompt: string | null;
19
21
  models: {
20
22
  base?: {
@@ -30,11 +32,9 @@ declare const getAgentById: (db: AgentsManageDatabaseClient) => (params: {
30
32
  providerOptions?: Record<string, any> | undefined;
31
33
  } | undefined;
32
34
  } | null;
33
- stopWhen: {
34
- transferCountIs?: number | undefined;
35
- } | null;
36
- createdAt: string;
37
- updatedAt: string;
35
+ projectId: string;
36
+ tenantId: string;
37
+ defaultSubAgentId: string | null;
38
38
  contextConfigId: string | null;
39
39
  statusUpdates: {
40
40
  enabled?: boolean | undefined;
@@ -57,10 +57,12 @@ declare const getAgentWithDefaultSubAgent: (db: AgentsManageDatabaseClient) => (
57
57
  }) => Promise<{
58
58
  id: string;
59
59
  name: string;
60
+ createdAt: string;
61
+ updatedAt: string;
60
62
  description: string | null;
61
- defaultSubAgentId: string | null;
62
- tenantId: string;
63
- projectId: string;
63
+ stopWhen: {
64
+ transferCountIs?: number | undefined;
65
+ } | null;
64
66
  prompt: string | null;
65
67
  models: {
66
68
  base?: {
@@ -76,11 +78,9 @@ declare const getAgentWithDefaultSubAgent: (db: AgentsManageDatabaseClient) => (
76
78
  providerOptions?: Record<string, any> | undefined;
77
79
  } | undefined;
78
80
  } | null;
79
- stopWhen: {
80
- transferCountIs?: number | undefined;
81
- } | null;
82
- createdAt: string;
83
- updatedAt: string;
81
+ projectId: string;
82
+ tenantId: string;
83
+ defaultSubAgentId: string | null;
84
84
  contextConfigId: string | null;
85
85
  statusUpdates: {
86
86
  enabled?: boolean | undefined;
@@ -100,10 +100,12 @@ declare const getAgentWithDefaultSubAgent: (db: AgentsManageDatabaseClient) => (
100
100
  defaultSubAgent: {
101
101
  id: string;
102
102
  name: string;
103
+ createdAt: string;
104
+ updatedAt: string;
103
105
  description: string | null;
104
- tenantId: string;
105
- projectId: string;
106
- agentId: string;
106
+ stopWhen: {
107
+ stepCountIs?: number | undefined;
108
+ } | null;
107
109
  prompt: string | null;
108
110
  conversationHistoryConfig: ConversationHistoryConfig | null;
109
111
  models: {
@@ -120,11 +122,9 @@ declare const getAgentWithDefaultSubAgent: (db: AgentsManageDatabaseClient) => (
120
122
  providerOptions?: Record<string, any> | undefined;
121
123
  } | undefined;
122
124
  } | null;
123
- stopWhen: {
124
- stepCountIs?: number | undefined;
125
- } | null;
126
- createdAt: string;
127
- updatedAt: string;
125
+ agentId: string;
126
+ projectId: string;
127
+ tenantId: string;
128
128
  } | null;
129
129
  } | null>;
130
130
  declare const listAgents: (db: AgentsManageDatabaseClient) => (params: {
@@ -132,10 +132,12 @@ declare const listAgents: (db: AgentsManageDatabaseClient) => (params: {
132
132
  }) => Promise<{
133
133
  id: string;
134
134
  name: string;
135
+ createdAt: string;
136
+ updatedAt: string;
135
137
  description: string | null;
136
- defaultSubAgentId: string | null;
137
- tenantId: string;
138
- projectId: string;
138
+ stopWhen: {
139
+ transferCountIs?: number | undefined;
140
+ } | null;
139
141
  prompt: string | null;
140
142
  models: {
141
143
  base?: {
@@ -151,11 +153,9 @@ declare const listAgents: (db: AgentsManageDatabaseClient) => (params: {
151
153
  providerOptions?: Record<string, any> | undefined;
152
154
  } | undefined;
153
155
  } | null;
154
- stopWhen: {
155
- transferCountIs?: number | undefined;
156
- } | null;
157
- createdAt: string;
158
- updatedAt: string;
156
+ projectId: string;
157
+ tenantId: string;
158
+ defaultSubAgentId: string | null;
159
159
  contextConfigId: string | null;
160
160
  statusUpdates: {
161
161
  enabled?: boolean | undefined;
@@ -248,10 +248,12 @@ declare function listAgentsAcrossProjectMainBranches(db: AgentsManageDatabaseCli
248
248
  declare const createAgent: (db: AgentsManageDatabaseClient) => (data: AgentInsert) => Promise<{
249
249
  id: string;
250
250
  name: string;
251
+ createdAt: string;
252
+ updatedAt: string;
251
253
  description: string | null;
252
- defaultSubAgentId: string | null;
253
- tenantId: string;
254
- projectId: string;
254
+ stopWhen: {
255
+ transferCountIs?: number | undefined;
256
+ } | null;
255
257
  prompt: string | null;
256
258
  models: {
257
259
  base?: {
@@ -267,11 +269,9 @@ declare const createAgent: (db: AgentsManageDatabaseClient) => (data: AgentInser
267
269
  providerOptions?: Record<string, any> | undefined;
268
270
  } | undefined;
269
271
  } | null;
270
- stopWhen: {
271
- transferCountIs?: number | undefined;
272
- } | null;
273
- createdAt: string;
274
- updatedAt: string;
272
+ projectId: string;
273
+ tenantId: string;
274
+ defaultSubAgentId: string | null;
275
275
  contextConfigId: string | null;
276
276
  statusUpdates: {
277
277
  enabled?: boolean | undefined;
@@ -11,11 +11,11 @@ declare const getArtifactComponentById: (db: AgentsManageDatabaseClient) => (par
11
11
  }) => Promise<{
12
12
  id: string;
13
13
  name: string;
14
- description: string | null;
15
- tenantId: string;
16
- projectId: string;
17
14
  createdAt: string;
18
15
  updatedAt: string;
16
+ description: string | null;
17
+ projectId: string;
18
+ tenantId: string;
19
19
  props: {
20
20
  [x: string]: unknown;
21
21
  type: "object";
@@ -67,11 +67,11 @@ declare const listArtifactComponentsPaginated: (db: AgentsManageDatabaseClient)
67
67
  declare const createArtifactComponent: (db: AgentsManageDatabaseClient) => (params: ArtifactComponentInsert) => Promise<{
68
68
  id: string;
69
69
  name: string;
70
- description: string | null;
71
- tenantId: string;
72
- projectId: string;
73
70
  createdAt: string;
74
71
  updatedAt: string;
72
+ description: string | null;
73
+ projectId: string;
74
+ tenantId: string;
75
75
  props: {
76
76
  [x: string]: unknown;
77
77
  type: "object";
@@ -142,10 +142,10 @@ declare const associateArtifactComponentWithAgent: (db: AgentsManageDatabaseClie
142
142
  artifactComponentId: string;
143
143
  }) => Promise<{
144
144
  id: string;
145
- tenantId: string;
146
- projectId: string;
147
- agentId: string;
148
145
  createdAt: string;
146
+ agentId: string;
147
+ projectId: string;
148
+ tenantId: string;
149
149
  subAgentId: string;
150
150
  artifactComponentId: string;
151
151
  }>;
@@ -185,10 +185,10 @@ declare const upsertAgentArtifactComponentRelation: (db: AgentsManageDatabaseCli
185
185
  artifactComponentId: string;
186
186
  }) => Promise<{
187
187
  id: string;
188
- tenantId: string;
189
- projectId: string;
190
- agentId: string;
191
188
  createdAt: string;
189
+ agentId: string;
190
+ projectId: string;
191
+ tenantId: string;
192
192
  subAgentId: string;
193
193
  artifactComponentId: string;
194
194
  } | null>;
@@ -10,11 +10,11 @@ declare const getContextConfigById: (db: AgentsManageDatabaseClient) => (params:
10
10
  id: string;
11
11
  }) => Promise<{
12
12
  id: string;
13
- tenantId: string;
14
- projectId: string;
15
- agentId: string;
16
13
  createdAt: string;
17
14
  updatedAt: string;
15
+ agentId: string;
16
+ projectId: string;
17
+ tenantId: string;
18
18
  headersSchema: unknown;
19
19
  contextVariables: Record<string, ContextFetchDefinition> | null;
20
20
  } | undefined>;
@@ -22,11 +22,11 @@ declare const listContextConfigs: (db: AgentsManageDatabaseClient) => (params: {
22
22
  scopes: AgentScopeConfig;
23
23
  }) => Promise<{
24
24
  id: string;
25
- tenantId: string;
26
- projectId: string;
27
- agentId: string;
28
25
  createdAt: string;
29
26
  updatedAt: string;
27
+ agentId: string;
28
+ projectId: string;
29
+ tenantId: string;
30
30
  headersSchema: unknown;
31
31
  contextVariables: Record<string, ContextFetchDefinition> | null;
32
32
  }[]>;
@@ -44,11 +44,11 @@ declare const listContextConfigsPaginated: (db: AgentsManageDatabaseClient) => (
44
44
  }>;
45
45
  declare const createContextConfig: (db: AgentsManageDatabaseClient) => (params: ContextConfigInsert) => Promise<{
46
46
  id: string;
47
- tenantId: string;
48
- projectId: string;
49
- agentId: string;
50
47
  createdAt: string;
51
48
  updatedAt: string;
49
+ agentId: string;
50
+ projectId: string;
51
+ tenantId: string;
52
52
  headersSchema: unknown;
53
53
  contextVariables: Record<string, ContextFetchDefinition> | null;
54
54
  }>;
@@ -84,11 +84,11 @@ declare const upsertContextConfig: (db: AgentsManageDatabaseClient) => (params:
84
84
  data: ContextConfigInsert;
85
85
  }) => Promise<{
86
86
  id: string;
87
- tenantId: string;
88
- projectId: string;
89
- agentId: string;
90
87
  createdAt: string;
91
88
  updatedAt: string;
89
+ agentId: string;
90
+ projectId: string;
91
+ tenantId: string;
92
92
  headersSchema: unknown;
93
93
  contextVariables: Record<string, ContextFetchDefinition> | null;
94
94
  }>;
@@ -92,7 +92,9 @@ declare const countCredentialReferences: (db: AgentsManageDatabaseClient) => (pa
92
92
  scopes: ProjectScopeConfig;
93
93
  }) => Promise<number>;
94
94
  /**
95
- * Upsert a credential reference (create if it doesn't exist, update if it does)
95
+ * Upsert a credential reference (create if it doesn't exist, update if it does).
96
+ * For user-scoped credentials (toolId + userId set), uses an atomic INSERT ... ON CONFLICT
97
+ * on the (toolId, userId) unique constraint to avoid TOCTOU races.
96
98
  */
97
99
  declare const upsertCredentialReference: (db: AgentsManageDatabaseClient) => (params: {
98
100
  data: CredentialReferenceInsert;
@@ -119,20 +119,24 @@ const countCredentialReferences = (db) => async (params) => {
119
119
  return typeof total === "string" ? Number.parseInt(total, 10) : total;
120
120
  };
121
121
  /**
122
- * Upsert a credential reference (create if it doesn't exist, update if it does)
122
+ * Upsert a credential reference (create if it doesn't exist, update if it does).
123
+ * For user-scoped credentials (toolId + userId set), uses an atomic INSERT ... ON CONFLICT
124
+ * on the (toolId, userId) unique constraint to avoid TOCTOU races.
123
125
  */
124
126
  const upsertCredentialReference = (db) => async (params) => {
125
127
  const scopes = {
126
128
  tenantId: params.data.tenantId,
127
129
  projectId: params.data.projectId
128
130
  };
129
- if (await getCredentialReference(db)({
131
+ const now = (/* @__PURE__ */ new Date()).toISOString();
132
+ const existingById = await getCredentialReference(db)({
130
133
  scopes,
131
134
  id: params.data.id
132
- })) {
135
+ });
136
+ if (existingById) {
133
137
  const updated = await updateCredentialReference(db)({
134
138
  scopes,
135
- id: params.data.id,
139
+ id: existingById.id,
136
140
  data: {
137
141
  name: params.data.name,
138
142
  type: params.data.type,
@@ -143,6 +147,23 @@ const upsertCredentialReference = (db) => async (params) => {
143
147
  if (!updated) throw new Error("Failed to update credential reference - no rows affected");
144
148
  return updated;
145
149
  }
150
+ if (params.data.toolId && params.data.userId) {
151
+ const [result] = await db.insert(credentialReferences).values({
152
+ ...params.data,
153
+ createdAt: now,
154
+ updatedAt: now
155
+ }).onConflictDoUpdate({
156
+ target: [credentialReferences.toolId, credentialReferences.userId],
157
+ set: {
158
+ name: params.data.name,
159
+ type: params.data.type,
160
+ credentialStoreId: params.data.credentialStoreId,
161
+ retrievalParams: params.data.retrievalParams,
162
+ updatedAt: now
163
+ }
164
+ }).returning();
165
+ return result;
166
+ }
146
167
  return await createCredentialReference(db)(params.data);
147
168
  };
148
169
 
@@ -66,10 +66,10 @@ declare const associateDataComponentWithAgent: (db: AgentsManageDatabaseClient)
66
66
  dataComponentId: string;
67
67
  }) => Promise<{
68
68
  id: string;
69
- tenantId: string;
70
- projectId: string;
71
- agentId: string;
72
69
  createdAt: string;
70
+ agentId: string;
71
+ projectId: string;
72
+ tenantId: string;
73
73
  subAgentId: string;
74
74
  dataComponentId: string;
75
75
  }>;
@@ -108,10 +108,10 @@ declare const upsertAgentDataComponentRelation: (db: AgentsManageDatabaseClient)
108
108
  dataComponentId: string;
109
109
  }) => Promise<{
110
110
  id: string;
111
- tenantId: string;
112
- projectId: string;
113
- agentId: string;
114
111
  createdAt: string;
112
+ agentId: string;
113
+ projectId: string;
114
+ tenantId: string;
115
115
  subAgentId: string;
116
116
  dataComponentId: string;
117
117
  } | null>;
@@ -55,12 +55,12 @@ declare const createFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
55
55
  }) => Promise<{
56
56
  id: string;
57
57
  name: string;
58
- description: string | null;
59
- tenantId: string;
60
- projectId: string;
61
- agentId: string;
62
58
  createdAt: string;
63
59
  updatedAt: string;
60
+ description: string | null;
61
+ agentId: string;
62
+ projectId: string;
63
+ tenantId: string;
64
64
  functionId: string;
65
65
  }>;
66
66
  /**
@@ -97,12 +97,12 @@ declare const upsertFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
97
97
  }) => Promise<{
98
98
  id: string;
99
99
  name: string;
100
- description: string | null;
101
- tenantId: string;
102
- projectId: string;
103
- agentId: string;
104
100
  createdAt: string;
105
101
  updatedAt: string;
102
+ description: string | null;
103
+ agentId: string;
104
+ projectId: string;
105
+ tenantId: string;
106
106
  functionId: string;
107
107
  }>;
108
108
  declare const getFunctionToolsForSubAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -162,16 +162,16 @@ declare const addFunctionToolToSubAgent: (db: AgentsManageDatabaseClient) => (pa
162
162
  }> | null;
163
163
  }) => Promise<{
164
164
  id: string;
165
- tenantId: string;
166
- projectId: string;
167
- agentId: string;
168
165
  createdAt: string;
169
166
  updatedAt: string;
167
+ agentId: string;
168
+ projectId: string;
169
+ tenantId: string;
170
+ subAgentId: string;
171
+ functionToolId: string;
170
172
  toolPolicies: Record<string, {
171
173
  needsApproval?: boolean;
172
174
  }> | null;
173
- subAgentId: string;
174
- functionToolId: string;
175
175
  }>;
176
176
  /**
177
177
  * Update an agent-function tool relation
@@ -227,16 +227,16 @@ declare const associateFunctionToolWithSubAgent: (db: AgentsManageDatabaseClient
227
227
  }> | null;
228
228
  }) => Promise<{
229
229
  id: string;
230
- tenantId: string;
231
- projectId: string;
232
- agentId: string;
233
230
  createdAt: string;
234
231
  updatedAt: string;
232
+ agentId: string;
233
+ projectId: string;
234
+ tenantId: string;
235
+ subAgentId: string;
236
+ functionToolId: string;
235
237
  toolPolicies: Record<string, {
236
238
  needsApproval?: boolean;
237
239
  }> | null;
238
- subAgentId: string;
239
- functionToolId: string;
240
240
  }>;
241
241
  //#endregion
242
242
  export { addFunctionToolToSubAgent, associateFunctionToolWithSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, getSubAgentsUsingFunctionTool, isFunctionToolAssociatedWithSubAgent, listFunctionTools, removeFunctionToolFromSubAgent, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
@@ -10,12 +10,12 @@ declare const getSkillById: (db: AgentsManageDatabaseClient) => (params: {
10
10
  }) => Promise<{
11
11
  id: string;
12
12
  name: string;
13
- description: string;
14
- tenantId: string;
15
- projectId: string;
16
13
  createdAt: string;
17
14
  updatedAt: string;
18
15
  metadata: Record<string, string> | null;
16
+ description: string;
17
+ projectId: string;
18
+ tenantId: string;
19
19
  content: string;
20
20
  } | null>;
21
21
  declare const listSkills: (db: AgentsManageDatabaseClient) => (params: {
@@ -43,23 +43,23 @@ declare const listSkills: (db: AgentsManageDatabaseClient) => (params: {
43
43
  declare const createSkill: (db: AgentsManageDatabaseClient) => (data: SkillInsert) => Promise<{
44
44
  id: string;
45
45
  name: string;
46
- description: string;
47
- tenantId: string;
48
- projectId: string;
49
46
  createdAt: string;
50
47
  updatedAt: string;
51
48
  metadata: Record<string, string> | null;
49
+ description: string;
50
+ projectId: string;
51
+ tenantId: string;
52
52
  content: string;
53
53
  }>;
54
54
  declare const upsertSkill: (db: AgentsManageDatabaseClient) => (data: SkillInsert) => Promise<{
55
55
  id: string;
56
56
  name: string;
57
- description: string;
58
- tenantId: string;
59
- projectId: string;
60
57
  createdAt: string;
61
58
  updatedAt: string;
62
59
  metadata: Record<string, string> | null;
60
+ description: string;
61
+ projectId: string;
62
+ tenantId: string;
63
63
  content: string;
64
64
  }>;
65
65
  declare const updateSkill: (db: AgentsManageDatabaseClient) => (params: {
@@ -92,15 +92,15 @@ declare const upsertSubAgentSkill: (db: AgentsManageDatabaseClient) => (params:
92
92
  alwaysLoaded?: boolean;
93
93
  }) => Promise<{
94
94
  id: string;
95
- tenantId: string;
96
- projectId: string;
97
- agentId: string;
98
95
  createdAt: string;
99
96
  updatedAt: string;
100
- index: number;
101
- alwaysLoaded: boolean;
97
+ agentId: string;
98
+ projectId: string;
99
+ tenantId: string;
102
100
  subAgentId: string;
103
101
  skillId: string;
102
+ index: number;
103
+ alwaysLoaded: boolean;
104
104
  }>;
105
105
  declare const deleteSubAgentSkill: (db: AgentsManageDatabaseClient) => (params: {
106
106
  scopes: AgentScopeConfig;