@inkeep/agents-core 0.58.21 → 0.59.1
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-config-utils.d.ts +49 -0
- package/dist/auth/auth-config-utils.js +133 -0
- package/dist/auth/auth-schema.d.ts +102 -85
- package/dist/auth/auth-schema.js +1 -0
- package/dist/auth/auth-types.d.ts +170 -0
- package/dist/auth/auth-types.js +53 -0
- package/dist/auth/auth-validation-schemas.d.ts +169 -135
- package/dist/auth/auth.d.ts +43 -1286
- package/dist/auth/auth.js +61 -70
- package/dist/auth/email-send-status-store.js +15 -3
- package/dist/auth/init.js +2 -1
- package/dist/auth/password-reset-link-store.js +8 -1
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/client-exports.d.ts +2 -2
- package/dist/client-exports.js +2 -2
- package/dist/constants/{allowed-image-formats.d.ts → allowed-file-formats.d.ts} +4 -3
- package/dist/constants/{allowed-image-formats.js → allowed-file-formats.js} +13 -10
- package/dist/credential-stores/composio-store.d.ts +28 -0
- package/dist/credential-stores/composio-store.js +53 -0
- package/dist/credential-stores/default-constants.d.ts +2 -1
- package/dist/credential-stores/default-constants.js +2 -1
- package/dist/credential-stores/defaults.js +3 -1
- package/dist/credential-stores/index.d.ts +3 -2
- package/dist/credential-stores/index.js +3 -2
- package/dist/data-access/index.d.ts +5 -4
- package/dist/data-access/index.js +4 -4
- package/dist/data-access/manage/agents.d.ts +30 -30
- package/dist/data-access/manage/artifactComponents.d.ts +10 -10
- package/dist/data-access/manage/contextConfigs.d.ts +8 -8
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +14 -14
- package/dist/data-access/manage/skills.d.ts +19 -19
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +22 -22
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +18 -18
- package/dist/data-access/manage/tools.d.ts +30 -30
- package/dist/data-access/manage/tools.js +17 -5
- package/dist/data-access/manage/triggers.d.ts +1 -1
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/apps.d.ts +12 -12
- package/dist/data-access/runtime/auth.d.ts +9 -9
- package/dist/data-access/runtime/auth.js +19 -21
- package/dist/data-access/runtime/conversations.d.ts +24 -24
- package/dist/data-access/runtime/messages.d.ts +12 -12
- package/dist/data-access/runtime/organizations.d.ts +28 -4
- package/dist/data-access/runtime/organizations.js +131 -9
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +10 -1
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +13 -1
- package/dist/data-access/runtime/tasks.d.ts +5 -5
- package/dist/db/manage/manage-schema.d.ts +359 -359
- package/dist/db/runtime/runtime-schema.d.ts +298 -298
- package/dist/index.d.ts +8 -6
- package/dist/index.js +8 -7
- package/dist/types/utility.d.ts +1 -0
- package/dist/types/utility.js +2 -1
- package/dist/utils/credential-store-utils.js +1 -0
- package/dist/utils/error.d.ts +51 -48
- package/dist/utils/error.js +3 -0
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +4 -4
- package/dist/utils/third-party-mcp-servers/composio-client.d.ts +20 -4
- package/dist/utils/third-party-mcp-servers/composio-client.js +51 -25
- package/dist/utils/third-party-mcp-servers/index.d.ts +2 -2
- package/dist/utils/third-party-mcp-servers/index.js +2 -2
- package/dist/utils/third-party-mcp-servers/third-party-check.d.ts +3 -4
- package/dist/utils/third-party-mcp-servers/third-party-check.js +1 -2
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas.d.ts +2026 -2005
- package/dist/validation/schemas.js +3 -1
- package/drizzle/runtime/0023_lazy_energizer.sql +1 -0
- package/drizzle/runtime/0024_moaning_kingpin.sql +1 -0
- package/drizzle/runtime/meta/0024_snapshot.json +4270 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +11 -6
|
@@ -20,14 +20,14 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
20
20
|
scopes: ProjectScopeConfig;
|
|
21
21
|
toolId: string;
|
|
22
22
|
}) => Promise<{
|
|
23
|
-
|
|
23
|
+
headers: Record<string, string> | null;
|
|
24
24
|
name: string;
|
|
25
|
-
|
|
26
|
-
tenantId: string;
|
|
27
|
-
projectId: string;
|
|
25
|
+
id: string;
|
|
28
26
|
createdAt: string;
|
|
29
27
|
updatedAt: string;
|
|
30
|
-
|
|
28
|
+
tenantId: string;
|
|
29
|
+
projectId: string;
|
|
30
|
+
description: string | null;
|
|
31
31
|
config: {
|
|
32
32
|
type: "mcp";
|
|
33
33
|
mcp: ToolMcpConfig;
|
|
@@ -78,14 +78,14 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
78
78
|
};
|
|
79
79
|
}>;
|
|
80
80
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
81
|
-
|
|
81
|
+
headers: Record<string, string> | null;
|
|
82
82
|
name: string;
|
|
83
|
-
|
|
84
|
-
tenantId: string;
|
|
85
|
-
projectId: string;
|
|
83
|
+
id: string;
|
|
86
84
|
createdAt: string;
|
|
87
85
|
updatedAt: string;
|
|
88
|
-
|
|
86
|
+
tenantId: string;
|
|
87
|
+
projectId: string;
|
|
88
|
+
description: string | null;
|
|
89
89
|
config: {
|
|
90
90
|
type: "mcp";
|
|
91
91
|
mcp: ToolMcpConfig;
|
|
@@ -135,38 +135,38 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
135
135
|
needsApproval?: boolean;
|
|
136
136
|
}> | null;
|
|
137
137
|
}) => Promise<{
|
|
138
|
+
headers: Record<string, string> | null;
|
|
138
139
|
id: string;
|
|
140
|
+
createdAt: string;
|
|
141
|
+
updatedAt: string;
|
|
139
142
|
tenantId: string;
|
|
140
143
|
projectId: string;
|
|
141
144
|
agentId: string;
|
|
142
|
-
|
|
143
|
-
updatedAt: string;
|
|
145
|
+
subAgentId: string;
|
|
144
146
|
toolId: string;
|
|
145
|
-
|
|
147
|
+
selectedTools: string[] | null;
|
|
146
148
|
toolPolicies: Record<string, {
|
|
147
149
|
needsApproval?: boolean;
|
|
148
150
|
}> | null;
|
|
149
|
-
subAgentId: string;
|
|
150
|
-
selectedTools: string[] | null;
|
|
151
151
|
}>;
|
|
152
152
|
declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
153
153
|
scopes: AgentScopeConfig;
|
|
154
154
|
subAgentId: string;
|
|
155
155
|
toolId: string;
|
|
156
156
|
}) => Promise<{
|
|
157
|
+
headers: Record<string, string> | null;
|
|
157
158
|
id: string;
|
|
159
|
+
createdAt: string;
|
|
160
|
+
updatedAt: string;
|
|
158
161
|
tenantId: string;
|
|
159
162
|
projectId: string;
|
|
160
163
|
agentId: string;
|
|
161
|
-
|
|
162
|
-
updatedAt: string;
|
|
164
|
+
subAgentId: string;
|
|
163
165
|
toolId: string;
|
|
164
|
-
|
|
166
|
+
selectedTools: string[] | null;
|
|
165
167
|
toolPolicies: Record<string, {
|
|
166
168
|
needsApproval?: boolean;
|
|
167
169
|
}> | null;
|
|
168
|
-
subAgentId: string;
|
|
169
|
-
selectedTools: string[] | null;
|
|
170
170
|
}>;
|
|
171
171
|
/**
|
|
172
172
|
* Upsert agent-tool relation (create if it doesn't exist, update if it does)
|
|
@@ -182,19 +182,19 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
182
182
|
}> | null;
|
|
183
183
|
relationId?: string;
|
|
184
184
|
}) => Promise<{
|
|
185
|
+
headers: Record<string, string> | null;
|
|
185
186
|
id: string;
|
|
187
|
+
createdAt: string;
|
|
188
|
+
updatedAt: string;
|
|
186
189
|
tenantId: string;
|
|
187
190
|
projectId: string;
|
|
188
191
|
agentId: string;
|
|
189
|
-
|
|
190
|
-
updatedAt: string;
|
|
192
|
+
subAgentId: string;
|
|
191
193
|
toolId: string;
|
|
192
|
-
|
|
194
|
+
selectedTools: string[] | null;
|
|
193
195
|
toolPolicies: Record<string, {
|
|
194
196
|
needsApproval?: boolean;
|
|
195
197
|
}> | null;
|
|
196
|
-
subAgentId: string;
|
|
197
|
-
selectedTools: string[] | null;
|
|
198
198
|
}>;
|
|
199
199
|
/**
|
|
200
200
|
* Upsert a tool (create if it doesn't exist, update if it does)
|
|
@@ -202,14 +202,14 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
202
202
|
declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
203
203
|
data: ToolInsert;
|
|
204
204
|
}) => Promise<{
|
|
205
|
-
|
|
205
|
+
headers: Record<string, string> | null;
|
|
206
206
|
name: string;
|
|
207
|
-
|
|
208
|
-
tenantId: string;
|
|
209
|
-
projectId: string;
|
|
207
|
+
id: string;
|
|
210
208
|
createdAt: string;
|
|
211
209
|
updatedAt: string;
|
|
212
|
-
|
|
210
|
+
tenantId: string;
|
|
211
|
+
projectId: string;
|
|
212
|
+
description: string | null;
|
|
213
213
|
config: {
|
|
214
214
|
type: "mcp";
|
|
215
215
|
mcp: ToolMcpConfig;
|
|
@@ -3,6 +3,8 @@ import { CredentialStoreType, MCPServerType, MCPTransportType } from "../../type
|
|
|
3
3
|
import { detectAuthenticationRequired } from "../../utils/auth-detection.js";
|
|
4
4
|
import { env } from "../../env.js";
|
|
5
5
|
import { getLogger } from "../../utils/logger.js";
|
|
6
|
+
import { configureComposioMCPServer } from "../../utils/third-party-mcp-servers/composio-client.js";
|
|
7
|
+
import { isThirdPartyMCPServerAuthenticated } from "../../utils/third-party-mcp-servers/third-party-check.js";
|
|
6
8
|
import { getCredentialStoreLookupKeyFromRetrievalParams } from "../../utils/credential-store-utils.js";
|
|
7
9
|
import { CredentialStuffer } from "../../credential-stuffer/CredentialStuffer.js";
|
|
8
10
|
import "../../credential-stuffer/index.js";
|
|
@@ -16,8 +18,6 @@ import { updateAgentToolRelation } from "./subAgentRelations.js";
|
|
|
16
18
|
import { isSerializationError } from "../../retry/retryable-errors.js";
|
|
17
19
|
import { toISODateString } from "../../utils/date.js";
|
|
18
20
|
import { McpClient } from "../../utils/mcp-client.js";
|
|
19
|
-
import { configureComposioMCPServer } from "../../utils/third-party-mcp-servers/composio-client.js";
|
|
20
|
-
import { isThirdPartyMCPServerAuthenticated } from "../../utils/third-party-mcp-servers/third-party-check.js";
|
|
21
21
|
import { TRUSTED_WORK_APP_MCP_PATHS, isTrustedWorkAppMcpUrl } from "../../utils/work-app-mcp.js";
|
|
22
22
|
import "../../utils/index.js";
|
|
23
23
|
import { isGithubWorkAppTool } from "../runtime/github-work-app-installations.js";
|
|
@@ -122,7 +122,12 @@ const discoverToolsFromServer = async (tool, credentialReference, credentialStor
|
|
|
122
122
|
reconnectionOptions: tool.config.mcp.transport?.reconnectionOptions,
|
|
123
123
|
sessionId: tool.config.mcp.transport?.sessionId
|
|
124
124
|
};
|
|
125
|
-
|
|
125
|
+
const composioConnectedAccountId = credentialReference?.retrievalParams?.connectedAccountId;
|
|
126
|
+
if (composioConnectedAccountId) configureComposioMCPServer(serverConfig, tool.tenantId, tool.projectId, tool.credentialScope === "user" ? "user" : "project", userId, composioConnectedAccountId);
|
|
127
|
+
else if (serverConfig.url?.toString().includes("composio.dev")) logger.warn({
|
|
128
|
+
toolName: tool.name,
|
|
129
|
+
toolId: tool.id
|
|
130
|
+
}, "Composio tool missing connectedAccountId — skipping auth injection to prevent credential leakage");
|
|
126
131
|
const urlString = String(serverConfig.url);
|
|
127
132
|
if (isGithubWorkAppTool(tool) && isTrustedWorkAppMcpUrl(urlString, TRUSTED_WORK_APP_MCP_PATHS.github, env.INKEEP_AGENTS_API_URL)) serverConfig.headers = {
|
|
128
133
|
...serverConfig.headers,
|
|
@@ -248,11 +253,18 @@ const dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry, re
|
|
|
248
253
|
lastErrorComputed = toolNeedsAuth ? `Authentication required - OAuth login needed. ${errorMessage}` : errorMessage;
|
|
249
254
|
}
|
|
250
255
|
}
|
|
251
|
-
if (dbResult.config.mcp.server.url.includes("composio.dev")) {
|
|
256
|
+
if (dbResult.config.mcp.server.url.includes("composio.dev")) if (!!!credentialReference?.retrievalParams?.connectedAccountId) {
|
|
257
|
+
status = "needs_auth";
|
|
258
|
+
lastErrorComputed = "Third-party authentication required. Connect your account to pin a specific credential.";
|
|
259
|
+
} else {
|
|
252
260
|
const credentialScope = dbResult.credentialScope || "project";
|
|
253
|
-
|
|
261
|
+
const authResult = await isThirdPartyMCPServerAuthenticated(dbResult.tenantId, dbResult.projectId, mcpServerUrl, credentialScope, userId);
|
|
262
|
+
if (!authResult.authenticated && !authResult.error) {
|
|
254
263
|
status = "needs_auth";
|
|
255
264
|
lastErrorComputed = "Third-party authentication required. Try authenticating again.";
|
|
265
|
+
} else if (authResult.error) {
|
|
266
|
+
status = "unavailable";
|
|
267
|
+
lastErrorComputed = "Could not verify third-party authentication status. The service may be temporarily unavailable.";
|
|
256
268
|
}
|
|
257
269
|
}
|
|
258
270
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -40,7 +40,7 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
|
|
|
40
40
|
algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
|
|
41
41
|
encoding: "hex" | "base64";
|
|
42
42
|
signature: {
|
|
43
|
-
source: "
|
|
43
|
+
source: "body" | "query" | "header";
|
|
44
44
|
key: string;
|
|
45
45
|
prefix?: string | undefined;
|
|
46
46
|
regex?: string | undefined;
|
|
@@ -8,28 +8,28 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
8
8
|
scopes: ProjectScopeConfig;
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
|
-
id: string;
|
|
12
11
|
name: string | null;
|
|
12
|
+
id: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
expiresAt: string | null;
|
|
15
|
+
updatedAt: string;
|
|
13
16
|
tenantId: string;
|
|
14
17
|
projectId: string;
|
|
15
18
|
agentId: string;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
updatedAt: string;
|
|
18
|
-
expiresAt: string | null;
|
|
19
19
|
publicId: string;
|
|
20
20
|
keyHash: string;
|
|
21
21
|
keyPrefix: string;
|
|
22
22
|
lastUsedAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
|
-
id: string;
|
|
26
25
|
name: string | null;
|
|
26
|
+
id: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
expiresAt: string | null;
|
|
29
|
+
updatedAt: string;
|
|
27
30
|
tenantId: string;
|
|
28
31
|
projectId: string;
|
|
29
32
|
agentId: string;
|
|
30
|
-
createdAt: string;
|
|
31
|
-
updatedAt: string;
|
|
32
|
-
expiresAt: string | null;
|
|
33
33
|
publicId: string;
|
|
34
34
|
keyHash: string;
|
|
35
35
|
keyPrefix: string;
|
|
@@ -39,14 +39,14 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
40
40
|
agentId?: string;
|
|
41
41
|
}) => Promise<{
|
|
42
|
-
id: string;
|
|
43
42
|
name: string | null;
|
|
43
|
+
id: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
expiresAt: string | null;
|
|
46
|
+
updatedAt: string;
|
|
44
47
|
tenantId: string;
|
|
45
48
|
projectId: string;
|
|
46
49
|
agentId: string;
|
|
47
|
-
createdAt: string;
|
|
48
|
-
updatedAt: string;
|
|
49
|
-
expiresAt: string | null;
|
|
50
50
|
publicId: string;
|
|
51
51
|
keyHash: string;
|
|
52
52
|
keyPrefix: string;
|
|
@@ -66,14 +66,14 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
66
66
|
};
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
|
-
id: string;
|
|
70
69
|
name: string | null;
|
|
70
|
+
id: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
expiresAt: string | null;
|
|
73
|
+
updatedAt: string;
|
|
71
74
|
tenantId: string;
|
|
72
75
|
projectId: string;
|
|
73
76
|
agentId: string;
|
|
74
|
-
createdAt: string;
|
|
75
|
-
updatedAt: string;
|
|
76
|
-
expiresAt: string | null;
|
|
77
77
|
publicId: string;
|
|
78
78
|
keyHash: string;
|
|
79
79
|
keyPrefix: string;
|
|
@@ -5,15 +5,15 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
5
5
|
|
|
6
6
|
//#region src/data-access/runtime/apps.d.ts
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
|
-
|
|
9
|
-
name: string;
|
|
10
|
-
description: string | null;
|
|
11
|
-
tenantId: string | null;
|
|
12
|
-
projectId: string | null;
|
|
8
|
+
enabled: boolean;
|
|
13
9
|
type: AppType;
|
|
10
|
+
name: string;
|
|
11
|
+
id: string;
|
|
14
12
|
createdAt: string;
|
|
15
13
|
updatedAt: string;
|
|
16
|
-
|
|
14
|
+
tenantId: string | null;
|
|
15
|
+
projectId: string | null;
|
|
16
|
+
description: string | null;
|
|
17
17
|
config: {
|
|
18
18
|
type: "web_client";
|
|
19
19
|
webClient: {
|
|
@@ -52,15 +52,15 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
52
52
|
};
|
|
53
53
|
}>;
|
|
54
54
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
55
|
-
|
|
56
|
-
name: string;
|
|
57
|
-
description: string | null;
|
|
58
|
-
tenantId: string | null;
|
|
59
|
-
projectId: string | null;
|
|
55
|
+
enabled: boolean;
|
|
60
56
|
type: AppType;
|
|
57
|
+
name: string;
|
|
58
|
+
id: string;
|
|
61
59
|
createdAt: string;
|
|
62
60
|
updatedAt: string;
|
|
63
|
-
|
|
61
|
+
tenantId: string | null;
|
|
62
|
+
projectId: string | null;
|
|
63
|
+
description: string | null;
|
|
64
64
|
config: {
|
|
65
65
|
type: "web_client";
|
|
66
66
|
webClient: {
|
|
@@ -5,14 +5,14 @@ declare const getInitialOrganization: (db: AgentsRunDatabaseClient) => (userId:
|
|
|
5
5
|
id: string;
|
|
6
6
|
} | null>;
|
|
7
7
|
declare const queryHasCredentialAccount: (db: AgentsRunDatabaseClient) => (userId: string) => Promise<boolean>;
|
|
8
|
-
|
|
9
|
-
providerId: string;
|
|
8
|
+
declare const querySsoProviderIssuers: (db: AgentsRunDatabaseClient) => () => Promise<{
|
|
10
9
|
issuer: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
declare const
|
|
10
|
+
}[]>;
|
|
11
|
+
declare const querySsoProviderIds: (db: AgentsRunDatabaseClient) => () => Promise<string[]>;
|
|
12
|
+
declare const queryOrgAllowedAuthMethods: (db: AgentsRunDatabaseClient) => (orgId: string) => Promise<{
|
|
13
|
+
allowedAuthMethods: string | null;
|
|
14
|
+
} | undefined>;
|
|
15
|
+
declare const queryMemberExists: (db: AgentsRunDatabaseClient) => (userId: string, organizationId: string) => Promise<boolean>;
|
|
16
|
+
declare const queryPendingInvitationExists: (db: AgentsRunDatabaseClient) => (email: string, organizationId: string) => Promise<boolean>;
|
|
17
17
|
//#endregion
|
|
18
|
-
export {
|
|
18
|
+
export { getInitialOrganization, queryHasCredentialAccount, queryMemberExists, queryOrgAllowedAuthMethods, queryPendingInvitationExists, querySsoProviderIds, querySsoProviderIssuers };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { account, member, ssoProvider } from "../../auth/auth-schema.js";
|
|
2
|
-
import { generateId } from "../../utils/conversations.js";
|
|
3
|
-
import "../../utils/index.js";
|
|
1
|
+
import { account, invitation, member, organization, ssoProvider } from "../../auth/auth-schema.js";
|
|
4
2
|
import { and, eq } from "drizzle-orm";
|
|
5
3
|
|
|
6
4
|
//#region src/data-access/runtime/auth.ts
|
|
@@ -12,24 +10,24 @@ const queryHasCredentialAccount = (db) => async (userId) => {
|
|
|
12
10
|
const [row] = await db.select({ id: account.id }).from(account).where(and(eq(account.userId, userId), eq(account.providerId, "credential"))).limit(1);
|
|
13
11
|
return !!row;
|
|
14
12
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
const querySsoProviderIssuers = (db) => async () => {
|
|
14
|
+
return db.select({ issuer: ssoProvider.issuer }).from(ssoProvider);
|
|
15
|
+
};
|
|
16
|
+
const querySsoProviderIds = (db) => async () => {
|
|
17
|
+
return (await db.select({ providerId: ssoProvider.providerId }).from(ssoProvider)).map((r) => r.providerId);
|
|
18
|
+
};
|
|
19
|
+
const queryOrgAllowedAuthMethods = (db) => async (orgId) => {
|
|
20
|
+
const [org] = await db.select({ allowedAuthMethods: organization.allowedAuthMethods }).from(organization).where(eq(organization.id, orgId)).limit(1);
|
|
21
|
+
return org;
|
|
22
|
+
};
|
|
23
|
+
const queryMemberExists = (db) => async (userId, organizationId) => {
|
|
24
|
+
const [row] = await db.select({ id: member.id }).from(member).where(and(eq(member.userId, userId), eq(member.organizationId, organizationId))).limit(1);
|
|
25
|
+
return !!row;
|
|
26
|
+
};
|
|
27
|
+
const queryPendingInvitationExists = (db) => async (email, organizationId) => {
|
|
28
|
+
const [row] = await db.select({ id: invitation.id }).from(invitation).where(and(eq(invitation.email, email), eq(invitation.organizationId, organizationId), eq(invitation.status, "pending"))).limit(1);
|
|
29
|
+
return !!row;
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
//#endregion
|
|
35
|
-
export { getInitialOrganization, queryHasCredentialAccount,
|
|
33
|
+
export { getInitialOrganization, queryHasCredentialAccount, queryMemberExists, queryOrgAllowedAuthMethods, queryPendingInvitationExists, querySsoProviderIds, querySsoProviderIssuers };
|
|
@@ -16,20 +16,20 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
16
16
|
total: number;
|
|
17
17
|
}>;
|
|
18
18
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
19
|
+
metadata: ConversationMetadata | null;
|
|
20
|
+
userId: string | null;
|
|
19
21
|
id: string;
|
|
20
|
-
tenantId: string;
|
|
21
|
-
projectId: string;
|
|
22
|
-
agentId: string | null;
|
|
23
|
-
title: string | null;
|
|
24
22
|
createdAt: string;
|
|
25
23
|
updatedAt: string;
|
|
26
|
-
metadata: ConversationMetadata | null;
|
|
27
24
|
ref: {
|
|
28
25
|
type: "commit" | "tag" | "branch";
|
|
29
26
|
name: string;
|
|
30
27
|
hash: string;
|
|
31
28
|
} | null;
|
|
32
|
-
|
|
29
|
+
tenantId: string;
|
|
30
|
+
projectId: string;
|
|
31
|
+
agentId: string | null;
|
|
32
|
+
title: string | null;
|
|
33
33
|
activeSubAgentId: string;
|
|
34
34
|
lastContextResolution: string | null;
|
|
35
35
|
}>;
|
|
@@ -85,20 +85,20 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
85
85
|
scopes: ProjectScopeConfig;
|
|
86
86
|
conversationId: string;
|
|
87
87
|
}) => Promise<{
|
|
88
|
+
metadata: ConversationMetadata | null;
|
|
89
|
+
userId: string | null;
|
|
88
90
|
id: string;
|
|
89
|
-
tenantId: string;
|
|
90
|
-
projectId: string;
|
|
91
|
-
agentId: string | null;
|
|
92
|
-
title: string | null;
|
|
93
91
|
createdAt: string;
|
|
94
92
|
updatedAt: string;
|
|
95
|
-
metadata: ConversationMetadata | null;
|
|
96
93
|
ref: {
|
|
97
94
|
type: "commit" | "tag" | "branch";
|
|
98
95
|
name: string;
|
|
99
96
|
hash: string;
|
|
100
97
|
} | null;
|
|
101
|
-
|
|
98
|
+
tenantId: string;
|
|
99
|
+
projectId: string;
|
|
100
|
+
agentId: string | null;
|
|
101
|
+
title: string | null;
|
|
102
102
|
activeSubAgentId: string;
|
|
103
103
|
lastContextResolution: string | null;
|
|
104
104
|
} | undefined>;
|
|
@@ -121,20 +121,20 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
121
121
|
metadata?: ConversationMetadata | null | undefined;
|
|
122
122
|
contextConfigId?: string | undefined;
|
|
123
123
|
} | {
|
|
124
|
+
metadata: ConversationMetadata | null;
|
|
125
|
+
userId: string | null;
|
|
124
126
|
id: string;
|
|
125
|
-
tenantId: string;
|
|
126
|
-
projectId: string;
|
|
127
|
-
agentId: string | null;
|
|
128
|
-
title: string | null;
|
|
129
127
|
createdAt: string;
|
|
130
128
|
updatedAt: string;
|
|
131
|
-
metadata: ConversationMetadata | null;
|
|
132
129
|
ref: {
|
|
133
130
|
type: "commit" | "tag" | "branch";
|
|
134
131
|
name: string;
|
|
135
132
|
hash: string;
|
|
136
133
|
} | null;
|
|
137
|
-
|
|
134
|
+
tenantId: string;
|
|
135
|
+
projectId: string;
|
|
136
|
+
agentId: string | null;
|
|
137
|
+
title: string | null;
|
|
138
138
|
activeSubAgentId: string;
|
|
139
139
|
lastContextResolution: string | null;
|
|
140
140
|
}>;
|
|
@@ -153,20 +153,20 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
153
153
|
scopes: ProjectScopeConfig;
|
|
154
154
|
conversationId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
|
+
metadata: ConversationMetadata | null;
|
|
157
|
+
userId: string | null;
|
|
156
158
|
id: string;
|
|
157
|
-
tenantId: string;
|
|
158
|
-
projectId: string;
|
|
159
|
-
agentId: string | null;
|
|
160
|
-
title: string | null;
|
|
161
159
|
createdAt: string;
|
|
162
160
|
updatedAt: string;
|
|
163
|
-
metadata: ConversationMetadata | null;
|
|
164
161
|
ref: {
|
|
165
162
|
type: "commit" | "tag" | "branch";
|
|
166
163
|
name: string;
|
|
167
164
|
hash: string;
|
|
168
165
|
} | null;
|
|
169
|
-
|
|
166
|
+
tenantId: string;
|
|
167
|
+
projectId: string;
|
|
168
|
+
agentId: string | null;
|
|
169
|
+
title: string | null;
|
|
170
170
|
activeSubAgentId: string;
|
|
171
171
|
lastContextResolution: string | null;
|
|
172
172
|
} | undefined>;
|
|
@@ -10,14 +10,14 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
scopes: ProjectScopeConfig;
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
|
+
metadata: MessageMetadata | null;
|
|
14
|
+
role: string;
|
|
13
15
|
id: string;
|
|
14
|
-
tenantId: string;
|
|
15
|
-
projectId: string;
|
|
16
16
|
createdAt: string;
|
|
17
17
|
updatedAt: string;
|
|
18
|
-
|
|
18
|
+
tenantId: string;
|
|
19
|
+
projectId: string;
|
|
19
20
|
content: MessageContent;
|
|
20
|
-
role: string;
|
|
21
21
|
conversationId: string;
|
|
22
22
|
fromSubAgentId: string | null;
|
|
23
23
|
toSubAgentId: string | null;
|
|
@@ -144,14 +144,14 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
144
144
|
scopes: ProjectScopeConfig;
|
|
145
145
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
146
146
|
}) => Promise<{
|
|
147
|
+
metadata: MessageMetadata | null;
|
|
148
|
+
role: string;
|
|
147
149
|
id: string;
|
|
148
|
-
tenantId: string;
|
|
149
|
-
projectId: string;
|
|
150
150
|
createdAt: string;
|
|
151
151
|
updatedAt: string;
|
|
152
|
-
|
|
152
|
+
tenantId: string;
|
|
153
|
+
projectId: string;
|
|
153
154
|
content: MessageContent;
|
|
154
|
-
role: string;
|
|
155
155
|
conversationId: string;
|
|
156
156
|
fromSubAgentId: string | null;
|
|
157
157
|
toSubAgentId: string | null;
|
|
@@ -197,14 +197,14 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
197
197
|
scopes: ProjectScopeConfig;
|
|
198
198
|
messageId: string;
|
|
199
199
|
}) => Promise<{
|
|
200
|
+
metadata: MessageMetadata | null;
|
|
201
|
+
role: string;
|
|
200
202
|
id: string;
|
|
201
|
-
tenantId: string;
|
|
202
|
-
projectId: string;
|
|
203
203
|
createdAt: string;
|
|
204
204
|
updatedAt: string;
|
|
205
|
-
|
|
205
|
+
tenantId: string;
|
|
206
|
+
projectId: string;
|
|
206
207
|
content: MessageContent;
|
|
207
|
-
role: string;
|
|
208
208
|
conversationId: string;
|
|
209
209
|
fromSubAgentId: string | null;
|
|
210
210
|
toSubAgentId: string | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
2
|
+
import { AllowedAuthMethod, MethodOption, OrgAuthInfo } from "../../auth/auth-types.js";
|
|
2
3
|
import { UserOrganization } from "../../auth/auth-validation-schemas.js";
|
|
3
4
|
|
|
4
5
|
//#region src/data-access/runtime/organizations.d.ts
|
|
@@ -39,6 +40,7 @@ declare const addUserToOrganization: (db: AgentsRunDatabaseClient) => (data: {
|
|
|
39
40
|
userId: string;
|
|
40
41
|
organizationId: string;
|
|
41
42
|
role: string;
|
|
43
|
+
isServiceAccount?: boolean;
|
|
42
44
|
}) => Promise<void>;
|
|
43
45
|
declare const upsertOrganization: (db: AgentsRunDatabaseClient) => (data: {
|
|
44
46
|
organizationId: string;
|
|
@@ -55,19 +57,41 @@ interface UserProviderInfo {
|
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
59
|
* Get authentication providers for a list of users.
|
|
58
|
-
* Returns which providers each user has linked (e.g., 'credential', 'google'
|
|
60
|
+
* Returns which providers each user has linked (e.g., 'credential', 'google').
|
|
59
61
|
*/
|
|
60
62
|
declare const getUserProvidersFromDb: (db: AgentsRunDatabaseClient) => (userIds: string[]) => Promise<UserProviderInfo[]>;
|
|
63
|
+
declare const getAllowedAuthMethods: (db: AgentsRunDatabaseClient) => (organizationId: string) => Promise<AllowedAuthMethod[]>;
|
|
61
64
|
/**
|
|
62
|
-
* Create an invitation directly in db
|
|
63
|
-
*
|
|
65
|
+
* Create an invitation directly in db.
|
|
66
|
+
* Accepts an optional explicit authMethod; defaults to email-password.
|
|
64
67
|
*/
|
|
65
68
|
declare const createInvitationInDb: (db: AgentsRunDatabaseClient) => (data: {
|
|
66
69
|
organizationId: string;
|
|
67
70
|
email: string;
|
|
71
|
+
authMethod?: string;
|
|
68
72
|
}) => Promise<{
|
|
69
73
|
id: string;
|
|
70
74
|
authMethod: string;
|
|
71
75
|
}>;
|
|
76
|
+
interface SSOProviderLookupResult {
|
|
77
|
+
providerId: string;
|
|
78
|
+
issuer: string;
|
|
79
|
+
domain: string;
|
|
80
|
+
organizationId: string | null;
|
|
81
|
+
providerType: 'oidc' | 'saml';
|
|
82
|
+
}
|
|
83
|
+
declare const getSSOProvidersByDomain: (db: AgentsRunDatabaseClient) => (domain: string) => Promise<SSOProviderLookupResult[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Filters org-allowed auth methods by email domain.
|
|
86
|
+
* SSO providers are only included if their domain matches the user's email domain.
|
|
87
|
+
* Non-SSO methods (email-password, google) pass through unfiltered.
|
|
88
|
+
*/
|
|
89
|
+
declare const getFilteredAuthMethodsForEmail: (db: AgentsRunDatabaseClient) => (organizationId: string, email: string) => Promise<MethodOption[]>;
|
|
90
|
+
declare function allowedMethodsToMethodOptions(methods: AllowedAuthMethod[], ssoProviders: SSOProviderLookupResult[]): MethodOption[];
|
|
91
|
+
/**
|
|
92
|
+
* Main auth-lookup query for the login flow.
|
|
93
|
+
* Returns org-grouped methods based on SSO domain match and/or user org membership.
|
|
94
|
+
*/
|
|
95
|
+
declare const getAuthLookupForEmail: (db: AgentsRunDatabaseClient) => (email: string) => Promise<OrgAuthInfo[]>;
|
|
72
96
|
//#endregion
|
|
73
|
-
export { UserProviderInfo, addUserToOrganization, createInvitationInDb, getPendingInvitationsByEmail, getUserOrganizationsFromDb, getUserProvidersFromDb, upsertOrganization };
|
|
97
|
+
export { type MethodOption, type OrgAuthInfo, SSOProviderLookupResult, UserProviderInfo, addUserToOrganization, allowedMethodsToMethodOptions, createInvitationInDb, getAllowedAuthMethods, getAuthLookupForEmail, getFilteredAuthMethodsForEmail, getPendingInvitationsByEmail, getSSOProvidersByDomain, getUserOrganizationsFromDb, getUserProvidersFromDb, upsertOrganization };
|