@inkeep/agents-core 0.63.2 → 0.64.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/api-client/eval-api-client.d.ts +2 -12
- package/dist/api-client/eval-api-client.js +0 -15
- package/dist/api-client/index.d.ts +2 -2
- package/dist/auth/auth-schema.d.ts +86 -86
- package/dist/auth/auth-validation-schemas.d.ts +154 -154
- package/dist/auth/auth.d.ts +6 -6
- package/dist/auth/auth.js +28 -9
- package/dist/auth/entitlement-constants.d.ts +11 -0
- package/dist/auth/entitlement-constants.js +10 -0
- package/dist/auth/entitlement-lock.d.ts +6 -0
- package/dist/auth/entitlement-lock.js +13 -0
- package/dist/auth/entitlements.d.ts +11 -0
- package/dist/auth/entitlements.js +55 -0
- package/dist/auth/init.js +2 -4
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/client-exports.d.ts +6 -4
- package/dist/client-exports.js +4 -2
- package/dist/constants/models.d.ts +2 -1
- package/dist/constants/models.js +6 -1
- package/dist/constants/otel-attributes.d.ts +2 -0
- package/dist/constants/otel-attributes.js +2 -0
- package/dist/data-access/index.d.ts +5 -4
- package/dist/data-access/index.js +4 -3
- package/dist/data-access/manage/agents.d.ts +83 -41
- package/dist/data-access/manage/artifactComponents.d.ts +8 -8
- package/dist/data-access/manage/contextConfigs.d.ts +8 -8
- package/dist/data-access/manage/dataComponents.d.ts +4 -4
- package/dist/data-access/manage/evalConfig.d.ts +49 -3
- package/dist/data-access/manage/evalConfig.js +61 -3
- package/dist/data-access/manage/functionTools.d.ts +12 -12
- package/dist/data-access/manage/projectLifecycle.d.ts +1 -1
- package/dist/data-access/manage/skills.d.ts +11 -11
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +26 -20
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +30 -18
- package/dist/data-access/manage/subAgents.d.ts +51 -15
- package/dist/data-access/manage/tools.d.ts +18 -18
- package/dist/data-access/manage/tools.js +41 -4
- package/dist/data-access/runtime/apiKeys.d.ts +12 -12
- package/dist/data-access/runtime/apps.d.ts +32 -41
- package/dist/data-access/runtime/cascade-delete.d.ts +1 -1
- package/dist/data-access/runtime/conversations.d.ts +21 -21
- package/dist/data-access/runtime/entitlements.d.ts +13 -0
- package/dist/data-access/runtime/entitlements.js +33 -0
- package/dist/data-access/runtime/ledgerArtifacts.d.ts +1 -1
- package/dist/data-access/runtime/messages.d.ts +25 -25
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +50 -5
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +34 -1
- package/dist/data-access/runtime/tasks.d.ts +5 -5
- package/dist/data-access/runtime/workflowExecutions.d.ts +1 -1
- package/dist/data-reconciliation/types.d.ts +1 -1
- package/dist/db/clean.d.ts +1 -1
- package/dist/db/manage/manage-schema.d.ts +674 -596
- package/dist/db/manage/manage-schema.js +154 -134
- package/dist/db/runtime/runtime-schema.d.ts +501 -394
- package/dist/db/runtime/runtime-schema.js +20 -3
- package/dist/dolt/backfill-skill-files.d.ts +41 -0
- package/dist/dolt/backfill-skill-files.js +209 -0
- package/dist/dolt/run-sql-file-on-all-branches.d.ts +29 -0
- package/dist/dolt/run-sql-file-on-all-branches.js +177 -0
- package/dist/index.d.ts +20 -16
- package/dist/index.js +12 -8
- package/dist/middleware/create-protected-route.d.ts +3 -0
- package/dist/middleware/create-protected-route.js +7 -2
- package/dist/middleware/entitlement-meta.d.ts +9 -0
- package/dist/middleware/entitlement-meta.js +11 -0
- package/dist/middleware/index.d.ts +2 -1
- package/dist/middleware/index.js +2 -1
- package/dist/types/entities.d.ts +8 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +5 -6
- package/dist/utils/error.d.ts +54 -51
- package/dist/utils/error.js +3 -0
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/mcp-client.d.ts +1 -1
- package/dist/utils/mcp-client.js +1 -1
- package/dist/utils/model-factory.js +24 -9
- package/dist/utils/usage-cost-middleware.d.ts +2 -1
- package/dist/utils/usage-cost-middleware.js +22 -5
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/schemas/skills.d.ts +45 -45
- package/dist/validation/schemas.d.ts +3829 -2894
- package/dist/validation/schemas.js +22 -24
- package/drizzle/manage/0016_complex_klaw.sql +2 -0
- package/drizzle/manage/0017_brief_doctor_strange.sql +29 -0
- package/drizzle/manage/meta/0016_snapshot.json +3530 -0
- package/drizzle/manage/meta/0017_snapshot.json +3748 -0
- package/drizzle/manage/meta/_journal.json +14 -0
- package/drizzle/runtime/0029_burly_satana.sql +13 -0
- package/drizzle/runtime/0030_set-allow-anonymous-for-existing-apps.sql +56 -0
- package/drizzle/runtime/meta/0029_snapshot.json +4756 -0
- package/drizzle/runtime/meta/_journal.json +14 -0
- package/package.json +3 -1
- /package/drizzle/runtime/meta/{0023_snapshot.json → 0025_snapshot.json} +0 -0
|
@@ -20,13 +20,13 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
20
20
|
scopes: ProjectScopeConfig;
|
|
21
21
|
toolId: string;
|
|
22
22
|
}) => Promise<{
|
|
23
|
+
tenantId: string;
|
|
24
|
+
projectId: string;
|
|
23
25
|
id: string;
|
|
24
26
|
name: string;
|
|
25
27
|
description: string | null;
|
|
26
28
|
createdAt: string;
|
|
27
29
|
updatedAt: string;
|
|
28
|
-
projectId: string;
|
|
29
|
-
tenantId: string;
|
|
30
30
|
headers: Record<string, string> | null;
|
|
31
31
|
config: {
|
|
32
32
|
type: "mcp";
|
|
@@ -78,13 +78,13 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
78
78
|
};
|
|
79
79
|
}>;
|
|
80
80
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
81
|
+
tenantId: string;
|
|
82
|
+
projectId: string;
|
|
81
83
|
id: string;
|
|
82
84
|
name: string;
|
|
83
85
|
description: string | null;
|
|
84
86
|
createdAt: string;
|
|
85
87
|
updatedAt: string;
|
|
86
|
-
projectId: string;
|
|
87
|
-
tenantId: string;
|
|
88
88
|
headers: Record<string, string> | null;
|
|
89
89
|
config: {
|
|
90
90
|
type: "mcp";
|
|
@@ -135,18 +135,18 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
135
135
|
needsApproval?: boolean;
|
|
136
136
|
}> | null;
|
|
137
137
|
}) => Promise<{
|
|
138
|
+
tenantId: string;
|
|
139
|
+
projectId: string;
|
|
138
140
|
id: string;
|
|
139
141
|
createdAt: string;
|
|
140
142
|
updatedAt: string;
|
|
141
|
-
projectId: string;
|
|
142
|
-
tenantId: string;
|
|
143
143
|
agentId: string;
|
|
144
|
-
subAgentId: string;
|
|
145
|
-
headers: Record<string, string> | null;
|
|
146
144
|
toolId: string;
|
|
145
|
+
headers: Record<string, string> | null;
|
|
147
146
|
toolPolicies: Record<string, {
|
|
148
147
|
needsApproval?: boolean;
|
|
149
148
|
}> | null;
|
|
149
|
+
subAgentId: string;
|
|
150
150
|
selectedTools: string[] | null;
|
|
151
151
|
}>;
|
|
152
152
|
declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -154,18 +154,18 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
154
154
|
subAgentId: string;
|
|
155
155
|
toolId: string;
|
|
156
156
|
}) => Promise<{
|
|
157
|
+
tenantId: string;
|
|
158
|
+
projectId: string;
|
|
157
159
|
id: string;
|
|
158
160
|
createdAt: string;
|
|
159
161
|
updatedAt: string;
|
|
160
|
-
projectId: string;
|
|
161
|
-
tenantId: string;
|
|
162
162
|
agentId: string;
|
|
163
|
-
subAgentId: string;
|
|
164
|
-
headers: Record<string, string> | null;
|
|
165
163
|
toolId: string;
|
|
164
|
+
headers: Record<string, string> | null;
|
|
166
165
|
toolPolicies: Record<string, {
|
|
167
166
|
needsApproval?: boolean;
|
|
168
167
|
}> | null;
|
|
168
|
+
subAgentId: string;
|
|
169
169
|
selectedTools: string[] | null;
|
|
170
170
|
}>;
|
|
171
171
|
/**
|
|
@@ -182,18 +182,18 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
182
182
|
}> | null;
|
|
183
183
|
relationId?: string;
|
|
184
184
|
}) => Promise<{
|
|
185
|
+
tenantId: string;
|
|
186
|
+
projectId: string;
|
|
185
187
|
id: string;
|
|
186
188
|
createdAt: string;
|
|
187
189
|
updatedAt: string;
|
|
188
|
-
projectId: string;
|
|
189
|
-
tenantId: string;
|
|
190
190
|
agentId: string;
|
|
191
|
-
subAgentId: string;
|
|
192
|
-
headers: Record<string, string> | null;
|
|
193
191
|
toolId: string;
|
|
192
|
+
headers: Record<string, string> | null;
|
|
194
193
|
toolPolicies: Record<string, {
|
|
195
194
|
needsApproval?: boolean;
|
|
196
195
|
}> | null;
|
|
196
|
+
subAgentId: string;
|
|
197
197
|
selectedTools: string[] | null;
|
|
198
198
|
}>;
|
|
199
199
|
/**
|
|
@@ -202,13 +202,13 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
202
202
|
declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
203
203
|
data: ToolInsert;
|
|
204
204
|
}) => Promise<{
|
|
205
|
+
tenantId: string;
|
|
206
|
+
projectId: string;
|
|
205
207
|
id: string;
|
|
206
208
|
name: string;
|
|
207
209
|
description: string | null;
|
|
208
210
|
createdAt: string;
|
|
209
211
|
updatedAt: string;
|
|
210
|
-
projectId: string;
|
|
211
|
-
tenantId: string;
|
|
212
212
|
headers: Record<string, string> | null;
|
|
213
213
|
config: {
|
|
214
214
|
type: "mcp";
|
|
@@ -23,20 +23,45 @@ import "../../utils/index.js";
|
|
|
23
23
|
import { isGithubWorkAppTool } from "../runtime/github-work-app-installations.js";
|
|
24
24
|
import { getCredentialReference, getUserScopedCredentialReference } from "./credentialReferences.js";
|
|
25
25
|
import { and, count, desc, eq } from "drizzle-orm";
|
|
26
|
+
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
27
|
+
import { StreamableHTTPError } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
26
28
|
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
27
29
|
|
|
28
30
|
//#region src/data-access/manage/tools.ts
|
|
29
31
|
/**
|
|
30
|
-
* Check if an error is a timeout/connection error.
|
|
32
|
+
* Check if an error is a timeout/connection error (transient, not auth-related).
|
|
31
33
|
* Uses MCP SDK ErrorCode for proper type safety.
|
|
32
34
|
*/
|
|
33
35
|
function isTimeoutOrConnectionError(error) {
|
|
34
|
-
if (error instanceof McpError) return error.code === ErrorCode.RequestTimeout || error.code === ErrorCode.ConnectionClosed;
|
|
36
|
+
if (error instanceof McpError) return error.code === ErrorCode.RequestTimeout || error.code === ErrorCode.ConnectionClosed || error.code === ErrorCode.InternalError;
|
|
37
|
+
if (error instanceof StreamableHTTPError) return error.code !== void 0 && error.code >= 500;
|
|
35
38
|
if (error instanceof Error) {
|
|
36
39
|
const message = error.message.toLowerCase();
|
|
37
40
|
const cause = error.cause;
|
|
38
|
-
if (message.includes("timed out") || message.includes("timeout")) return true;
|
|
39
|
-
if (cause?.code
|
|
41
|
+
if (message.includes("timed out") || message.includes("timeout") || message.includes("fetch failed")) return true;
|
|
42
|
+
if (cause?.code && [
|
|
43
|
+
"ETIMEDOUT",
|
|
44
|
+
"ECONNABORTED",
|
|
45
|
+
"ECONNRESET",
|
|
46
|
+
"ECONNREFUSED",
|
|
47
|
+
"ENOTFOUND",
|
|
48
|
+
"EHOSTUNREACH",
|
|
49
|
+
"ENETUNREACH",
|
|
50
|
+
"EPIPE"
|
|
51
|
+
].includes(cause.code)) return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if an error indicates the credential is invalid/expired/revoked.
|
|
57
|
+
* These errors mean the user genuinely needs to re-authenticate.
|
|
58
|
+
*/
|
|
59
|
+
function isAuthenticationError(error) {
|
|
60
|
+
if (error instanceof UnauthorizedError) return true;
|
|
61
|
+
if (error instanceof StreamableHTTPError) return error.code === 401 || error.code === 403;
|
|
62
|
+
if (error instanceof Error) {
|
|
63
|
+
const message = error.message.toLowerCase();
|
|
64
|
+
if (message.includes("unauthorized") || message.includes("forbidden") || message.includes("invalid_token") || message.includes("token expired") || message.includes("invalid_grant")) return true;
|
|
40
65
|
}
|
|
41
66
|
return false;
|
|
42
67
|
}
|
|
@@ -243,6 +268,18 @@ const dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry, re
|
|
|
243
268
|
if (isTimeoutOrConnectionError(error)) {
|
|
244
269
|
status = "unavailable";
|
|
245
270
|
lastErrorComputed = `Connection failed - the MCP server may be slow or temporarily unreachable.${error instanceof McpError ? ` (MCP error ${error.code})` : ""} ${errorMessage}`;
|
|
271
|
+
} else if (isAuthenticationError(error)) {
|
|
272
|
+
status = "needs_auth";
|
|
273
|
+
lastErrorComputed = `Authentication required - OAuth login needed. ${errorMessage}`;
|
|
274
|
+
} else if (credentialReference) {
|
|
275
|
+
logger.warn({
|
|
276
|
+
toolId: dbResult.id,
|
|
277
|
+
credentialId: credentialReference.id,
|
|
278
|
+
errorCode: error instanceof McpError ? error.code : void 0,
|
|
279
|
+
errorMessage
|
|
280
|
+
}, "MCP server discovery failed with existing credential — treating as transient");
|
|
281
|
+
status = "unavailable";
|
|
282
|
+
lastErrorComputed = `Server temporarily unavailable. ${errorMessage}`;
|
|
246
283
|
} else {
|
|
247
284
|
const toolNeedsAuth = await detectAuthenticationRequired({
|
|
248
285
|
serverUrl: mcpServerUrl,
|
|
@@ -8,49 +8,49 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
8
8
|
scopes: ProjectScopeConfig;
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
|
+
tenantId: string;
|
|
12
|
+
projectId: string;
|
|
11
13
|
id: string;
|
|
12
14
|
name: string | null;
|
|
13
15
|
createdAt: string;
|
|
14
16
|
updatedAt: string;
|
|
15
|
-
projectId: string;
|
|
16
|
-
tenantId: string;
|
|
17
17
|
agentId: 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
|
+
tenantId: string;
|
|
26
|
+
projectId: string;
|
|
25
27
|
id: string;
|
|
26
28
|
name: string | null;
|
|
27
29
|
createdAt: string;
|
|
28
30
|
updatedAt: string;
|
|
29
|
-
projectId: string;
|
|
30
|
-
tenantId: string;
|
|
31
31
|
agentId: 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;
|
|
40
40
|
agentId?: string;
|
|
41
41
|
}) => Promise<{
|
|
42
|
+
tenantId: string;
|
|
43
|
+
projectId: string;
|
|
42
44
|
id: string;
|
|
43
45
|
name: string | null;
|
|
44
46
|
createdAt: string;
|
|
45
47
|
updatedAt: string;
|
|
46
|
-
projectId: string;
|
|
47
|
-
tenantId: string;
|
|
48
48
|
agentId: 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;
|
|
@@ -66,18 +66,18 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
66
66
|
};
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
|
+
tenantId: string;
|
|
70
|
+
projectId: string;
|
|
69
71
|
id: string;
|
|
70
72
|
name: string | null;
|
|
71
73
|
createdAt: string;
|
|
72
74
|
updatedAt: string;
|
|
73
|
-
projectId: string;
|
|
74
|
-
tenantId: string;
|
|
75
75
|
agentId: 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;
|
|
@@ -6,30 +6,27 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
6
6
|
//#region src/data-access/runtime/apps.d.ts
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
8
|
type: AppType;
|
|
9
|
+
tenantId: string | null;
|
|
10
|
+
projectId: string | null;
|
|
9
11
|
id: string;
|
|
10
12
|
name: string;
|
|
11
13
|
description: string | null;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
prompt: string | null;
|
|
12
16
|
createdAt: string;
|
|
13
17
|
updatedAt: string;
|
|
14
|
-
projectId: string | null;
|
|
15
|
-
tenantId: string | null;
|
|
16
|
-
prompt: string | null;
|
|
17
|
-
enabled: boolean;
|
|
18
18
|
config: {
|
|
19
19
|
type: "web_client";
|
|
20
20
|
webClient: {
|
|
21
21
|
allowedDomains: string[];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
validateScopeClaims?: boolean | undefined;
|
|
31
|
-
allowAnonymous?: boolean | undefined;
|
|
32
|
-
} | undefined;
|
|
22
|
+
publicKeys: {
|
|
23
|
+
kid: string;
|
|
24
|
+
publicKey: string;
|
|
25
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
26
|
+
addedAt: string;
|
|
27
|
+
}[];
|
|
28
|
+
allowAnonymous: boolean;
|
|
29
|
+
audience?: string | undefined;
|
|
33
30
|
};
|
|
34
31
|
} | {
|
|
35
32
|
type: "api";
|
|
@@ -65,30 +62,27 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
65
62
|
}>;
|
|
66
63
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
67
64
|
type: AppType;
|
|
65
|
+
tenantId: string | null;
|
|
66
|
+
projectId: string | null;
|
|
68
67
|
id: string;
|
|
69
68
|
name: string;
|
|
70
69
|
description: string | null;
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
prompt: string | null;
|
|
71
72
|
createdAt: string;
|
|
72
73
|
updatedAt: string;
|
|
73
|
-
projectId: string | null;
|
|
74
|
-
tenantId: string | null;
|
|
75
|
-
prompt: string | null;
|
|
76
|
-
enabled: boolean;
|
|
77
74
|
config: {
|
|
78
75
|
type: "web_client";
|
|
79
76
|
webClient: {
|
|
80
77
|
allowedDomains: string[];
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
validateScopeClaims?: boolean | undefined;
|
|
90
|
-
allowAnonymous?: boolean | undefined;
|
|
91
|
-
} | undefined;
|
|
78
|
+
publicKeys: {
|
|
79
|
+
kid: string;
|
|
80
|
+
publicKey: string;
|
|
81
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
82
|
+
addedAt: string;
|
|
83
|
+
}[];
|
|
84
|
+
allowAnonymous: boolean;
|
|
85
|
+
audience?: string | undefined;
|
|
92
86
|
};
|
|
93
87
|
} | {
|
|
94
88
|
type: "api";
|
|
@@ -151,17 +145,14 @@ declare const updateApp: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
151
145
|
type: "web_client";
|
|
152
146
|
webClient: {
|
|
153
147
|
allowedDomains: string[];
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
validateScopeClaims?: boolean | undefined;
|
|
163
|
-
allowAnonymous?: boolean | undefined;
|
|
164
|
-
} | undefined;
|
|
148
|
+
publicKeys: {
|
|
149
|
+
kid: string;
|
|
150
|
+
publicKey: string;
|
|
151
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
152
|
+
addedAt: string;
|
|
153
|
+
}[];
|
|
154
|
+
allowAnonymous: boolean;
|
|
155
|
+
audience?: string | undefined;
|
|
165
156
|
};
|
|
166
157
|
} | {
|
|
167
158
|
type: "api";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentScopeConfig, ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
2
|
-
import "../../types/index.js";
|
|
3
2
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
3
|
+
import "../../types/index.js";
|
|
4
4
|
|
|
5
5
|
//#region src/data-access/runtime/cascade-delete.d.ts
|
|
6
6
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ResolvedRef } from "../../validation/dolt-schemas.js";
|
|
2
2
|
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
3
3
|
import { ConversationHistoryConfig, ConversationMetadata, PaginationConfig } from "../../types/utility.js";
|
|
4
|
-
import "../../types/index.js";
|
|
5
4
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
5
|
+
import "../../types/index.js";
|
|
6
6
|
import { ConversationInsert, ConversationSelect, ConversationUpdate, MessageSelect } from "../../types/entities.js";
|
|
7
7
|
|
|
8
8
|
//#region src/data-access/runtime/conversations.d.ts
|
|
@@ -15,15 +15,15 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
15
15
|
total: number;
|
|
16
16
|
}>;
|
|
17
17
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
18
|
+
tenantId: string;
|
|
19
|
+
userId: string | null;
|
|
20
|
+
projectId: string;
|
|
18
21
|
id: string;
|
|
19
|
-
|
|
22
|
+
title: string | null;
|
|
20
23
|
createdAt: string;
|
|
21
24
|
updatedAt: string;
|
|
22
|
-
|
|
23
|
-
tenantId: string;
|
|
24
|
-
title: string | null;
|
|
25
|
+
metadata: ConversationMetadata | null;
|
|
25
26
|
agentId: string | null;
|
|
26
|
-
userId: string | null;
|
|
27
27
|
ref: {
|
|
28
28
|
type: "commit" | "tag" | "branch";
|
|
29
29
|
name: string;
|
|
@@ -84,15 +84,15 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
84
84
|
scopes: ProjectScopeConfig;
|
|
85
85
|
conversationId: string;
|
|
86
86
|
}) => Promise<{
|
|
87
|
+
tenantId: string;
|
|
88
|
+
userId: string | null;
|
|
89
|
+
projectId: string;
|
|
87
90
|
id: string;
|
|
88
|
-
|
|
91
|
+
title: string | null;
|
|
89
92
|
createdAt: string;
|
|
90
93
|
updatedAt: string;
|
|
91
|
-
|
|
92
|
-
tenantId: string;
|
|
93
|
-
title: string | null;
|
|
94
|
+
metadata: ConversationMetadata | null;
|
|
94
95
|
agentId: string | null;
|
|
95
|
-
userId: string | null;
|
|
96
96
|
ref: {
|
|
97
97
|
type: "commit" | "tag" | "branch";
|
|
98
98
|
name: string;
|
|
@@ -120,15 +120,15 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
120
120
|
metadata?: ConversationMetadata | null | undefined;
|
|
121
121
|
contextConfigId?: string | undefined;
|
|
122
122
|
} | {
|
|
123
|
+
tenantId: string;
|
|
124
|
+
userId: string | null;
|
|
125
|
+
projectId: string;
|
|
123
126
|
id: string;
|
|
124
|
-
|
|
127
|
+
title: string | null;
|
|
125
128
|
createdAt: string;
|
|
126
129
|
updatedAt: string;
|
|
127
|
-
|
|
128
|
-
tenantId: string;
|
|
129
|
-
title: string | null;
|
|
130
|
+
metadata: ConversationMetadata | null;
|
|
130
131
|
agentId: string | null;
|
|
131
|
-
userId: string | null;
|
|
132
132
|
ref: {
|
|
133
133
|
type: "commit" | "tag" | "branch";
|
|
134
134
|
name: string;
|
|
@@ -152,15 +152,15 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
152
152
|
scopes: ProjectScopeConfig;
|
|
153
153
|
conversationId: string;
|
|
154
154
|
}) => Promise<{
|
|
155
|
+
tenantId: string;
|
|
156
|
+
userId: string | null;
|
|
157
|
+
projectId: string;
|
|
155
158
|
id: string;
|
|
156
|
-
|
|
159
|
+
title: string | null;
|
|
157
160
|
createdAt: string;
|
|
158
161
|
updatedAt: string;
|
|
159
|
-
|
|
160
|
-
tenantId: string;
|
|
161
|
-
title: string | null;
|
|
162
|
+
metadata: ConversationMetadata | null;
|
|
162
163
|
agentId: string | null;
|
|
163
|
-
userId: string | null;
|
|
164
164
|
ref: {
|
|
165
165
|
type: "commit" | "tag" | "branch";
|
|
166
166
|
name: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data-access/runtime/entitlements.d.ts
|
|
4
|
+
declare const listOrgEntitlements: (db: AgentsRunDatabaseClient) => (orgId: string) => Promise<Array<{
|
|
5
|
+
resourceType: string;
|
|
6
|
+
maxValue: number;
|
|
7
|
+
}>>;
|
|
8
|
+
declare function dalResolveEntitlement(db: AgentsRunDatabaseClient, orgId: string, resourceType: string): Promise<number | null>;
|
|
9
|
+
declare function dalGetServiceAccountUserId(db: AgentsRunDatabaseClient, orgId: string): Promise<string | null>;
|
|
10
|
+
declare function dalCountMembersByRoleBucket(db: AgentsRunDatabaseClient, orgId: string, isAdminBucket: boolean, serviceAccountUserId: string | null): Promise<number>;
|
|
11
|
+
declare function dalSumSeatEntitlements(db: AgentsRunDatabaseClient, orgId: string): Promise<number | null>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { dalCountMembersByRoleBucket, dalGetServiceAccountUserId, dalResolveEntitlement, dalSumSeatEntitlements, listOrgEntitlements };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { member, organization } from "../../auth/auth-schema.js";
|
|
2
|
+
import { orgEntitlement } from "../../db/runtime/runtime-schema.js";
|
|
3
|
+
import { and, eq, like, or, sql } from "drizzle-orm";
|
|
4
|
+
|
|
5
|
+
//#region src/data-access/runtime/entitlements.ts
|
|
6
|
+
const listOrgEntitlements = (db) => async (orgId) => {
|
|
7
|
+
return await db.select({
|
|
8
|
+
resourceType: orgEntitlement.resourceType,
|
|
9
|
+
maxValue: orgEntitlement.maxValue
|
|
10
|
+
}).from(orgEntitlement).where(eq(orgEntitlement.organizationId, orgId));
|
|
11
|
+
};
|
|
12
|
+
async function dalResolveEntitlement(db, orgId, resourceType) {
|
|
13
|
+
const rows = await db.select({ maxValue: orgEntitlement.maxValue }).from(orgEntitlement).where(and(eq(orgEntitlement.organizationId, orgId), eq(orgEntitlement.resourceType, resourceType)));
|
|
14
|
+
if (rows.length === 0) return null;
|
|
15
|
+
return rows[0].maxValue;
|
|
16
|
+
}
|
|
17
|
+
async function dalGetServiceAccountUserId(db, orgId) {
|
|
18
|
+
return (await db.select({ serviceAccountUserId: organization.serviceAccountUserId }).from(organization).where(eq(organization.id, orgId)))[0]?.serviceAccountUserId ?? null;
|
|
19
|
+
}
|
|
20
|
+
async function dalCountMembersByRoleBucket(db, orgId, isAdminBucket, serviceAccountUserId) {
|
|
21
|
+
const memberCondition = isAdminBucket ? or(eq(member.role, "owner"), eq(member.role, "admin")) : eq(member.role, "member");
|
|
22
|
+
const memberWhere = serviceAccountUserId ? and(eq(member.organizationId, orgId), memberCondition, sql`${member.userId} != ${serviceAccountUserId}`) : and(eq(member.organizationId, orgId), memberCondition);
|
|
23
|
+
const [result] = await db.select({ count: sql`count(*)::int` }).from(member).where(memberWhere);
|
|
24
|
+
return result?.count ?? 0;
|
|
25
|
+
}
|
|
26
|
+
async function dalSumSeatEntitlements(db, orgId) {
|
|
27
|
+
const rows = await db.select({ maxValue: orgEntitlement.maxValue }).from(orgEntitlement).where(and(eq(orgEntitlement.organizationId, orgId), like(orgEntitlement.resourceType, "seat:%")));
|
|
28
|
+
if (rows.length === 0) return null;
|
|
29
|
+
return rows.reduce((sum, r) => sum + r.maxValue, 0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { dalCountMembersByRoleBucket, dalGetServiceAccountUserId, dalResolveEntitlement, dalSumSeatEntitlements, listOrgEntitlements };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Artifact, Part } from "../../types/a2a.js";
|
|
2
2
|
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
3
|
-
import "../../types/index.js";
|
|
4
3
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
4
|
+
import "../../types/index.js";
|
|
5
5
|
import { LedgerArtifactSelect } from "../../types/entities.js";
|
|
6
6
|
|
|
7
7
|
//#region src/data-access/runtime/ledgerArtifacts.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
2
2
|
import { MessageContent, MessageMetadata, MessageVisibility, PaginationConfig } from "../../types/utility.js";
|
|
3
|
-
import "../../types/index.js";
|
|
4
3
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
4
|
+
import "../../types/index.js";
|
|
5
5
|
import "../../index.js";
|
|
6
6
|
import { MessageInsert, MessageUpdate } from "../../types/entities.js";
|
|
7
7
|
|
|
@@ -10,26 +10,26 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
scopes: ProjectScopeConfig;
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
|
+
tenantId: string;
|
|
14
|
+
projectId: string;
|
|
13
15
|
id: string;
|
|
14
|
-
content: MessageContent;
|
|
15
|
-
metadata: MessageMetadata | null;
|
|
16
16
|
createdAt: string;
|
|
17
17
|
updatedAt: string;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
metadata: MessageMetadata | null;
|
|
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: {
|
|
@@ -144,26 +144,26 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
144
144
|
scopes: ProjectScopeConfig;
|
|
145
145
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
146
146
|
}) => Promise<{
|
|
147
|
+
tenantId: string;
|
|
148
|
+
projectId: string;
|
|
147
149
|
id: string;
|
|
148
|
-
content: MessageContent;
|
|
149
|
-
metadata: MessageMetadata | null;
|
|
150
150
|
createdAt: string;
|
|
151
151
|
updatedAt: string;
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
metadata: MessageMetadata | null;
|
|
153
|
+
content: MessageContent;
|
|
154
|
+
role: string;
|
|
155
|
+
conversationId: string;
|
|
154
156
|
fromSubAgentId: string | null;
|
|
155
157
|
toSubAgentId: string | null;
|
|
156
158
|
fromExternalAgentId: string | null;
|
|
157
159
|
toExternalAgentId: string | null;
|
|
158
|
-
taskId: string | null;
|
|
159
|
-
a2aTaskId: string | null;
|
|
160
|
-
conversationId: string;
|
|
161
|
-
role: string;
|
|
162
160
|
fromTeamAgentId: string | null;
|
|
163
161
|
toTeamAgentId: string | null;
|
|
164
162
|
visibility: string;
|
|
165
163
|
messageType: string;
|
|
164
|
+
taskId: string | null;
|
|
166
165
|
parentMessageId: string | null;
|
|
166
|
+
a2aTaskId: string | null;
|
|
167
167
|
a2aSessionId: string | null;
|
|
168
168
|
}>;
|
|
169
169
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -197,26 +197,26 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
197
197
|
scopes: ProjectScopeConfig;
|
|
198
198
|
messageId: string;
|
|
199
199
|
}) => Promise<{
|
|
200
|
+
tenantId: string;
|
|
201
|
+
projectId: string;
|
|
200
202
|
id: string;
|
|
201
|
-
content: MessageContent;
|
|
202
|
-
metadata: MessageMetadata | null;
|
|
203
203
|
createdAt: string;
|
|
204
204
|
updatedAt: string;
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
metadata: MessageMetadata | null;
|
|
206
|
+
content: MessageContent;
|
|
207
|
+
role: string;
|
|
208
|
+
conversationId: string;
|
|
207
209
|
fromSubAgentId: string | null;
|
|
208
210
|
toSubAgentId: string | null;
|
|
209
211
|
fromExternalAgentId: string | null;
|
|
210
212
|
toExternalAgentId: string | null;
|
|
211
|
-
taskId: string | null;
|
|
212
|
-
a2aTaskId: string | null;
|
|
213
|
-
conversationId: string;
|
|
214
|
-
role: string;
|
|
215
213
|
fromTeamAgentId: string | null;
|
|
216
214
|
toTeamAgentId: string | null;
|
|
217
215
|
visibility: string;
|
|
218
216
|
messageType: string;
|
|
217
|
+
taskId: string | null;
|
|
219
218
|
parentMessageId: string | null;
|
|
219
|
+
a2aTaskId: string | null;
|
|
220
220
|
a2aSessionId: string | null;
|
|
221
221
|
}>;
|
|
222
222
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|