@inkeep/agents-core 0.58.8 → 0.58.10

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.
@@ -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" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
1277
+ actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
1284
+ actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
1291
+ actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins35.Statements>[key] | {
9
+ actions: better_auth_plugins35.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins35.Statements>[key] | {
16
+ actions: better_auth_plugins35.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins35.Statements>[key] | {
23
+ actions: better_auth_plugins35.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", 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" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins35.Statements>;
27
27
  };
28
28
  //#endregion
29
29
  export { ac, adminRole, memberRole, organizationClient, ownerRole };
@@ -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
 
@@ -40,13 +40,13 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
40
40
  algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
41
41
  encoding: "hex" | "base64";
42
42
  signature: {
43
- source: "query" | "header" | "body";
43
+ source: "query" | "body" | "header";
44
44
  key: string;
45
45
  prefix?: string | undefined;
46
46
  regex?: string | undefined;
47
47
  };
48
48
  signedComponents: {
49
- source: "literal" | "header" | "body";
49
+ source: "literal" | "body" | "header";
50
50
  required: boolean;
51
51
  key?: string | undefined;
52
52
  value?: string | undefined;
@@ -15,11 +15,11 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
15
15
  agentId: string;
16
16
  createdAt: string;
17
17
  updatedAt: string;
18
+ expiresAt: string | null;
18
19
  publicId: string;
19
20
  keyHash: string;
20
21
  keyPrefix: string;
21
22
  lastUsedAt: string | null;
22
- expiresAt: string | null;
23
23
  } | undefined>;
24
24
  declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
25
25
  id: string;
@@ -29,11 +29,11 @@ declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: s
29
29
  agentId: string;
30
30
  createdAt: string;
31
31
  updatedAt: string;
32
+ expiresAt: string | null;
32
33
  publicId: string;
33
34
  keyHash: string;
34
35
  keyPrefix: string;
35
36
  lastUsedAt: string | null;
36
- expiresAt: string | null;
37
37
  } | undefined>;
38
38
  declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
39
39
  scopes: ProjectScopeConfig;
@@ -46,11 +46,11 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
46
46
  agentId: string;
47
47
  createdAt: string;
48
48
  updatedAt: string;
49
+ expiresAt: string | null;
49
50
  publicId: string;
50
51
  keyHash: string;
51
52
  keyPrefix: string;
52
53
  lastUsedAt: string | null;
53
- expiresAt: string | null;
54
54
  }[]>;
55
55
  declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
56
56
  scopes: ProjectScopeConfig;
@@ -73,11 +73,11 @@ declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInse
73
73
  agentId: string;
74
74
  createdAt: string;
75
75
  updatedAt: string;
76
+ expiresAt: string | null;
76
77
  publicId: string;
77
78
  keyHash: string;
78
79
  keyPrefix: string;
79
80
  lastUsedAt: string | null;
80
- expiresAt: string | null;
81
81
  }>;
82
82
  declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
83
83
  scopes: ProjectScopeConfig;
@@ -26,7 +26,7 @@ declare const createConversation: (db: AgentsRunDatabaseClient) => (params: Conv
26
26
  metadata: ConversationMetadata | null;
27
27
  userId: string | null;
28
28
  ref: {
29
- type: "commit" | "tag" | "branch";
29
+ type: "tag" | "commit" | "branch";
30
30
  name: string;
31
31
  hash: string;
32
32
  } | null;
@@ -44,7 +44,7 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
44
44
  agentId: string | null;
45
45
  activeSubAgentId: string;
46
46
  ref: {
47
- type: "commit" | "tag" | "branch";
47
+ type: "tag" | "commit" | "branch";
48
48
  name: string;
49
49
  hash: string;
50
50
  } | null;
@@ -70,7 +70,7 @@ declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) =>
70
70
  agentId: string | null;
71
71
  activeSubAgentId: string;
72
72
  ref: {
73
- type: "commit" | "tag" | "branch";
73
+ type: "tag" | "commit" | "branch";
74
74
  name: string;
75
75
  hash: string;
76
76
  } | null;
@@ -95,7 +95,7 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
95
95
  metadata: ConversationMetadata | null;
96
96
  userId: string | null;
97
97
  ref: {
98
- type: "commit" | "tag" | "branch";
98
+ type: "tag" | "commit" | "branch";
99
99
  name: string;
100
100
  hash: string;
101
101
  } | null;
@@ -108,7 +108,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
108
108
  tenantId: string;
109
109
  id: string;
110
110
  ref: {
111
- type: "commit" | "tag" | "branch";
111
+ type: "tag" | "commit" | "branch";
112
112
  name: string;
113
113
  hash: string;
114
114
  };
@@ -131,7 +131,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
131
131
  metadata: ConversationMetadata | null;
132
132
  userId: string | null;
133
133
  ref: {
134
- type: "commit" | "tag" | "branch";
134
+ type: "tag" | "commit" | "branch";
135
135
  name: string;
136
136
  hash: string;
137
137
  } | null;
@@ -163,7 +163,7 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
163
163
  metadata: ConversationMetadata | null;
164
164
  userId: string | null;
165
165
  ref: {
166
- type: "commit" | "tag" | "branch";
166
+ type: "tag" | "commit" | "branch";
167
167
  name: string;
168
168
  hash: string;
169
169
  } | null;
@@ -17,19 +17,19 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
17
17
  updatedAt: string;
18
18
  metadata: MessageMetadata | null;
19
19
  content: MessageContent;
20
+ role: string;
21
+ conversationId: string;
20
22
  fromSubAgentId: string | null;
21
23
  toSubAgentId: string | null;
22
24
  fromExternalAgentId: string | null;
23
25
  toExternalAgentId: string | null;
24
- taskId: string | null;
25
- a2aTaskId: string | null;
26
- conversationId: string;
27
- role: string;
28
26
  fromTeamAgentId: string | null;
29
27
  toTeamAgentId: string | null;
30
28
  visibility: string;
31
29
  messageType: string;
30
+ taskId: string | null;
32
31
  parentMessageId: string | null;
32
+ a2aTaskId: string | null;
33
33
  a2aSessionId: string | null;
34
34
  } | undefined>;
35
35
  declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
@@ -148,19 +148,19 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageIn
148
148
  updatedAt: string;
149
149
  metadata: MessageMetadata | null;
150
150
  content: MessageContent;
151
+ role: string;
152
+ conversationId: string;
151
153
  fromSubAgentId: string | null;
152
154
  toSubAgentId: string | null;
153
155
  fromExternalAgentId: string | null;
154
156
  toExternalAgentId: string | null;
155
- taskId: string | null;
156
- a2aTaskId: string | null;
157
- conversationId: string;
158
- role: string;
159
157
  fromTeamAgentId: string | null;
160
158
  toTeamAgentId: string | null;
161
159
  visibility: string;
162
160
  messageType: string;
161
+ taskId: string | null;
163
162
  parentMessageId: string | null;
163
+ a2aTaskId: string | null;
164
164
  a2aSessionId: string | null;
165
165
  }>;
166
166
  declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
@@ -201,19 +201,19 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
201
201
  updatedAt: string;
202
202
  metadata: MessageMetadata | null;
203
203
  content: MessageContent;
204
+ role: string;
205
+ conversationId: string;
204
206
  fromSubAgentId: string | null;
205
207
  toSubAgentId: string | null;
206
208
  fromExternalAgentId: string | null;
207
209
  toExternalAgentId: string | null;
208
- taskId: string | null;
209
- a2aTaskId: string | null;
210
- conversationId: string;
211
- role: string;
212
210
  fromTeamAgentId: string | null;
213
211
  toTeamAgentId: string | null;
214
212
  visibility: string;
215
213
  messageType: string;
214
+ taskId: string | null;
216
215
  parentMessageId: string | null;
216
+ a2aTaskId: string | null;
217
217
  a2aSessionId: string | null;
218
218
  }>;
219
219
  declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
@@ -34,7 +34,7 @@ declare const listScheduledTriggerInvocationsPaginated: (db: AgentsRunDatabaseCl
34
34
  }) => Promise<{
35
35
  data: {
36
36
  scheduledTriggerId: string;
37
- status: "pending" | "failed" | "running" | "completed" | "cancelled";
37
+ status: "pending" | "running" | "completed" | "failed" | "cancelled";
38
38
  scheduledFor: string;
39
39
  startedAt: string | null;
40
40
  completedAt: string | null;
@@ -174,7 +174,7 @@ declare const listUpcomingInvocationsForAgentPaginated: (db: AgentsRunDatabaseCl
174
174
  }) => Promise<{
175
175
  data: {
176
176
  scheduledTriggerId: string;
177
- status: "pending" | "failed" | "running" | "completed" | "cancelled";
177
+ status: "pending" | "running" | "completed" | "failed" | "cancelled";
178
178
  scheduledFor: string;
179
179
  startedAt: string | null;
180
180
  completedAt: string | null;
@@ -208,7 +208,7 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
208
208
  }) => Promise<{
209
209
  data: {
210
210
  scheduledTriggerId: string;
211
- status: "pending" | "failed" | "running" | "completed" | "cancelled";
211
+ status: "pending" | "running" | "completed" | "failed" | "cancelled";
212
212
  scheduledFor: string;
213
213
  startedAt: string | null;
214
214
  completedAt: string | null;
@@ -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
- subAgentId: string;
17
16
  status: string;
18
- contextId: string;
17
+ subAgentId: string;
19
18
  ref: {
20
- type: "commit" | "tag" | "branch";
19
+ type: "tag" | "commit" | "branch";
21
20
  name: string;
22
21
  hash: string;
23
22
  } | null;
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: "commit" | "tag" | "branch";
39
+ type: "tag" | "commit" | "branch";
40
40
  name: string;
41
41
  hash: string;
42
42
  } | null;