@inkeep/agents-core 0.63.3 → 0.64.2
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 +137 -137
- 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 +65 -23
- package/dist/data-access/manage/artifactComponents.d.ts +6 -6
- package/dist/data-access/manage/contextConfigs.d.ts +4 -4
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- 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 +6 -6
- package/dist/data-access/manage/projectLifecycle.d.ts +1 -1
- package/dist/data-access/manage/skills.d.ts +9 -9
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -12
- package/dist/data-access/manage/subAgentRelations.d.ts +22 -16
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -12
- package/dist/data-access/manage/subAgents.d.ts +45 -9
- package/dist/data-access/manage/tools.d.ts +18 -18
- package/dist/data-access/manage/tools.js +41 -4
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +8 -8
- package/dist/data-access/runtime/apps.d.ts +38 -47
- package/dist/data-access/runtime/cascade-delete.d.ts +1 -1
- package/dist/data-access/runtime/conversations.d.ts +17 -17
- 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 +13 -13
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +47 -2
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +34 -1
- package/dist/data-access/runtime/tasks.d.ts +6 -6
- 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 +766 -688
- package/dist/db/manage/manage-schema.js +154 -134
- package/dist/db/runtime/runtime-schema.d.ts +499 -392
- 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 +6 -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 +43 -43
- package/dist/validation/schemas.d.ts +2376 -1441
- 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
|
@@ -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,
|
|
@@ -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" | "
|
|
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" | "
|
|
49
|
+
source: "literal" | "body" | "header";
|
|
50
50
|
required: boolean;
|
|
51
51
|
key?: string | undefined;
|
|
52
52
|
value?: string | undefined;
|
|
@@ -12,9 +12,9 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
12
12
|
name: string | null;
|
|
13
13
|
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
|
-
projectId: string;
|
|
16
|
-
tenantId: string;
|
|
17
15
|
expiresAt: string | null;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
projectId: string;
|
|
18
18
|
agentId: string;
|
|
19
19
|
publicId: string;
|
|
20
20
|
keyHash: string;
|
|
@@ -26,9 +26,9 @@ declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: s
|
|
|
26
26
|
name: string | null;
|
|
27
27
|
createdAt: string;
|
|
28
28
|
updatedAt: string;
|
|
29
|
-
projectId: string;
|
|
30
|
-
tenantId: string;
|
|
31
29
|
expiresAt: string | null;
|
|
30
|
+
tenantId: string;
|
|
31
|
+
projectId: string;
|
|
32
32
|
agentId: string;
|
|
33
33
|
publicId: string;
|
|
34
34
|
keyHash: string;
|
|
@@ -43,9 +43,9 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
43
43
|
name: string | null;
|
|
44
44
|
createdAt: string;
|
|
45
45
|
updatedAt: string;
|
|
46
|
-
projectId: string;
|
|
47
|
-
tenantId: string;
|
|
48
46
|
expiresAt: string | null;
|
|
47
|
+
tenantId: string;
|
|
48
|
+
projectId: string;
|
|
49
49
|
agentId: string;
|
|
50
50
|
publicId: string;
|
|
51
51
|
keyHash: string;
|
|
@@ -70,9 +70,9 @@ declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInse
|
|
|
70
70
|
name: string | null;
|
|
71
71
|
createdAt: string;
|
|
72
72
|
updatedAt: string;
|
|
73
|
-
projectId: string;
|
|
74
|
-
tenantId: string;
|
|
75
73
|
expiresAt: string | null;
|
|
74
|
+
tenantId: string;
|
|
75
|
+
projectId: string;
|
|
76
76
|
agentId: string;
|
|
77
77
|
publicId: string;
|
|
78
78
|
keyHash: string;
|
|
@@ -5,39 +5,36 @@ 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
|
+
type: AppType;
|
|
8
9
|
id: string;
|
|
9
10
|
name: string;
|
|
10
|
-
description: string | null;
|
|
11
11
|
createdAt: string;
|
|
12
12
|
updatedAt: string;
|
|
13
|
-
|
|
13
|
+
description: string | null;
|
|
14
|
+
enabled: boolean;
|
|
14
15
|
tenantId: string | null;
|
|
15
|
-
|
|
16
|
-
lastUsedAt: string | null;
|
|
17
|
-
defaultProjectId: string | null;
|
|
18
|
-
defaultAgentId: string | null;
|
|
16
|
+
projectId: string | null;
|
|
19
17
|
prompt: string | null;
|
|
20
|
-
enabled: boolean;
|
|
21
18
|
config: {
|
|
22
19
|
type: "web_client";
|
|
23
20
|
webClient: {
|
|
24
21
|
allowedDomains: string[];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
validateScopeClaims?: boolean | undefined;
|
|
34
|
-
allowAnonymous?: boolean | undefined;
|
|
35
|
-
} | 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;
|
|
36
30
|
};
|
|
37
31
|
} | {
|
|
38
32
|
type: "api";
|
|
39
33
|
api: Record<string, never>;
|
|
40
34
|
};
|
|
35
|
+
lastUsedAt: string | null;
|
|
36
|
+
defaultProjectId: string | null;
|
|
37
|
+
defaultAgentId: string | null;
|
|
41
38
|
} | undefined>;
|
|
42
39
|
declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
|
|
43
40
|
declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -64,39 +61,36 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
64
61
|
};
|
|
65
62
|
}>;
|
|
66
63
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
64
|
+
type: AppType;
|
|
67
65
|
id: string;
|
|
68
66
|
name: string;
|
|
69
|
-
description: string | null;
|
|
70
67
|
createdAt: string;
|
|
71
68
|
updatedAt: string;
|
|
72
|
-
|
|
69
|
+
description: string | null;
|
|
70
|
+
enabled: boolean;
|
|
73
71
|
tenantId: string | null;
|
|
74
|
-
|
|
75
|
-
lastUsedAt: string | null;
|
|
76
|
-
defaultProjectId: string | null;
|
|
77
|
-
defaultAgentId: string | null;
|
|
72
|
+
projectId: string | null;
|
|
78
73
|
prompt: string | null;
|
|
79
|
-
enabled: boolean;
|
|
80
74
|
config: {
|
|
81
75
|
type: "web_client";
|
|
82
76
|
webClient: {
|
|
83
77
|
allowedDomains: string[];
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
validateScopeClaims?: boolean | undefined;
|
|
93
|
-
allowAnonymous?: boolean | undefined;
|
|
94
|
-
} | 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;
|
|
95
86
|
};
|
|
96
87
|
} | {
|
|
97
88
|
type: "api";
|
|
98
89
|
api: Record<string, never>;
|
|
99
90
|
};
|
|
91
|
+
lastUsedAt: string | null;
|
|
92
|
+
defaultProjectId: string | null;
|
|
93
|
+
defaultAgentId: string | null;
|
|
100
94
|
}>;
|
|
101
95
|
declare const updateAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
102
96
|
scopes: TenantScopeConfig;
|
|
@@ -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
|
|
@@ -16,18 +16,18 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
16
16
|
}>;
|
|
17
17
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
18
18
|
id: string;
|
|
19
|
-
metadata: ConversationMetadata | null;
|
|
20
19
|
createdAt: string;
|
|
21
20
|
updatedAt: string;
|
|
22
|
-
projectId: string;
|
|
23
|
-
tenantId: string;
|
|
24
|
-
title: string | null;
|
|
25
21
|
ref: {
|
|
26
22
|
type: "commit" | "tag" | "branch";
|
|
27
23
|
name: string;
|
|
28
24
|
hash: string;
|
|
29
25
|
} | null;
|
|
30
26
|
userId: string | null;
|
|
27
|
+
metadata: ConversationMetadata | null;
|
|
28
|
+
title: string | null;
|
|
29
|
+
tenantId: string;
|
|
30
|
+
projectId: string;
|
|
31
31
|
agentId: string | null;
|
|
32
32
|
activeSubAgentId: string;
|
|
33
33
|
lastContextResolution: string | null;
|
|
@@ -85,18 +85,18 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
85
85
|
conversationId: string;
|
|
86
86
|
}) => Promise<{
|
|
87
87
|
id: string;
|
|
88
|
-
metadata: ConversationMetadata | null;
|
|
89
88
|
createdAt: string;
|
|
90
89
|
updatedAt: string;
|
|
91
|
-
projectId: string;
|
|
92
|
-
tenantId: string;
|
|
93
|
-
title: string | null;
|
|
94
90
|
ref: {
|
|
95
91
|
type: "commit" | "tag" | "branch";
|
|
96
92
|
name: string;
|
|
97
93
|
hash: string;
|
|
98
94
|
} | null;
|
|
99
95
|
userId: string | null;
|
|
96
|
+
metadata: ConversationMetadata | null;
|
|
97
|
+
title: string | null;
|
|
98
|
+
tenantId: string;
|
|
99
|
+
projectId: string;
|
|
100
100
|
agentId: string | null;
|
|
101
101
|
activeSubAgentId: string;
|
|
102
102
|
lastContextResolution: string | null;
|
|
@@ -121,18 +121,18 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
121
121
|
contextConfigId?: string | undefined;
|
|
122
122
|
} | {
|
|
123
123
|
id: string;
|
|
124
|
-
metadata: ConversationMetadata | null;
|
|
125
124
|
createdAt: string;
|
|
126
125
|
updatedAt: string;
|
|
127
|
-
projectId: string;
|
|
128
|
-
tenantId: string;
|
|
129
|
-
title: string | null;
|
|
130
126
|
ref: {
|
|
131
127
|
type: "commit" | "tag" | "branch";
|
|
132
128
|
name: string;
|
|
133
129
|
hash: string;
|
|
134
130
|
} | null;
|
|
135
131
|
userId: string | null;
|
|
132
|
+
metadata: ConversationMetadata | null;
|
|
133
|
+
title: string | null;
|
|
134
|
+
tenantId: string;
|
|
135
|
+
projectId: string;
|
|
136
136
|
agentId: string | null;
|
|
137
137
|
activeSubAgentId: string;
|
|
138
138
|
lastContextResolution: string | null;
|
|
@@ -153,18 +153,18 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
153
153
|
conversationId: string;
|
|
154
154
|
}) => Promise<{
|
|
155
155
|
id: string;
|
|
156
|
-
metadata: ConversationMetadata | null;
|
|
157
156
|
createdAt: string;
|
|
158
157
|
updatedAt: string;
|
|
159
|
-
projectId: string;
|
|
160
|
-
tenantId: string;
|
|
161
|
-
title: string | null;
|
|
162
158
|
ref: {
|
|
163
159
|
type: "commit" | "tag" | "branch";
|
|
164
160
|
name: string;
|
|
165
161
|
hash: string;
|
|
166
162
|
} | null;
|
|
167
163
|
userId: string | null;
|
|
164
|
+
metadata: ConversationMetadata | null;
|
|
165
|
+
title: string | null;
|
|
166
|
+
tenantId: string;
|
|
167
|
+
projectId: string;
|
|
168
168
|
agentId: string | null;
|
|
169
169
|
activeSubAgentId: string;
|
|
170
170
|
lastContextResolution: string | null;
|
|
@@ -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
|
|
|
@@ -11,13 +11,13 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
13
|
id: string;
|
|
14
|
-
content: MessageContent;
|
|
15
|
-
metadata: MessageMetadata | null;
|
|
16
14
|
createdAt: string;
|
|
17
15
|
updatedAt: string;
|
|
18
|
-
|
|
19
|
-
tenantId: string;
|
|
16
|
+
metadata: MessageMetadata | null;
|
|
20
17
|
role: string;
|
|
18
|
+
tenantId: string;
|
|
19
|
+
content: MessageContent;
|
|
20
|
+
projectId: string;
|
|
21
21
|
conversationId: string;
|
|
22
22
|
fromSubAgentId: string | null;
|
|
23
23
|
toSubAgentId: string | null;
|
|
@@ -145,13 +145,13 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
145
145
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
146
146
|
}) => Promise<{
|
|
147
147
|
id: string;
|
|
148
|
-
content: MessageContent;
|
|
149
|
-
metadata: MessageMetadata | null;
|
|
150
148
|
createdAt: string;
|
|
151
149
|
updatedAt: string;
|
|
152
|
-
|
|
153
|
-
tenantId: string;
|
|
150
|
+
metadata: MessageMetadata | null;
|
|
154
151
|
role: string;
|
|
152
|
+
tenantId: string;
|
|
153
|
+
content: MessageContent;
|
|
154
|
+
projectId: string;
|
|
155
155
|
conversationId: string;
|
|
156
156
|
fromSubAgentId: string | null;
|
|
157
157
|
toSubAgentId: string | null;
|
|
@@ -198,13 +198,13 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
198
198
|
messageId: string;
|
|
199
199
|
}) => Promise<{
|
|
200
200
|
id: string;
|
|
201
|
-
content: MessageContent;
|
|
202
|
-
metadata: MessageMetadata | null;
|
|
203
201
|
createdAt: string;
|
|
204
202
|
updatedAt: string;
|
|
205
|
-
|
|
206
|
-
tenantId: string;
|
|
203
|
+
metadata: MessageMetadata | null;
|
|
207
204
|
role: string;
|
|
205
|
+
tenantId: string;
|
|
206
|
+
content: MessageContent;
|
|
207
|
+
projectId: string;
|
|
208
208
|
conversationId: string;
|
|
209
209
|
fromSubAgentId: string | null;
|
|
210
210
|
toSubAgentId: string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
1
|
+
import { AgentScopeConfig, ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
2
2
|
import { PaginationConfig } from "../../types/utility.js";
|
|
3
3
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
4
4
|
import { ScheduledTriggerInvocationStatus } from "../../validation/schemas.js";
|
|
@@ -254,5 +254,50 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
|
|
|
254
254
|
pages: number;
|
|
255
255
|
};
|
|
256
256
|
}>;
|
|
257
|
+
/**
|
|
258
|
+
* Get status summary for all invocations with a given scheduledTriggerId.
|
|
259
|
+
* Used for dataset run status aggregation where scheduledTriggerId = datasetRunId.
|
|
260
|
+
*/
|
|
261
|
+
declare const getScheduledTriggerInvocationStatusSummary: (db: AgentsRunDatabaseClient) => (params: {
|
|
262
|
+
scopes: ProjectScopeConfig;
|
|
263
|
+
scheduledTriggerId: string;
|
|
264
|
+
}) => Promise<{
|
|
265
|
+
pending: number;
|
|
266
|
+
running: number;
|
|
267
|
+
completed: number;
|
|
268
|
+
failed: number;
|
|
269
|
+
cancelled: number;
|
|
270
|
+
}>;
|
|
271
|
+
/**
|
|
272
|
+
* List invocations by scheduledTriggerId without agentId filter (project-scoped).
|
|
273
|
+
* Used for dataset run items listing where scheduledTriggerId = datasetRunId.
|
|
274
|
+
*/
|
|
275
|
+
declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabaseClient) => (params: {
|
|
276
|
+
scopes: ProjectScopeConfig;
|
|
277
|
+
scheduledTriggerId: string;
|
|
278
|
+
filters?: {
|
|
279
|
+
status?: string;
|
|
280
|
+
};
|
|
281
|
+
}) => Promise<{
|
|
282
|
+
scheduledTriggerId: string;
|
|
283
|
+
ref: {
|
|
284
|
+
type: "commit" | "tag" | "branch";
|
|
285
|
+
name: string;
|
|
286
|
+
hash: string;
|
|
287
|
+
} | null;
|
|
288
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
289
|
+
scheduledFor: string;
|
|
290
|
+
startedAt: string | null;
|
|
291
|
+
completedAt: string | null;
|
|
292
|
+
resolvedPayload: Record<string, unknown> | null;
|
|
293
|
+
conversationIds: string[] | null;
|
|
294
|
+
attemptNumber: number;
|
|
295
|
+
idempotencyKey: string;
|
|
296
|
+
createdAt: string;
|
|
297
|
+
agentId: string;
|
|
298
|
+
projectId: string;
|
|
299
|
+
tenantId: string;
|
|
300
|
+
id: string;
|
|
301
|
+
}[]>;
|
|
257
302
|
//#endregion
|
|
258
|
-
export { addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
303
|
+
export { addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
@@ -223,6 +223,39 @@ const listProjectScheduledTriggerInvocationsPaginated = (db) => async (params) =
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* Get status summary for all invocations with a given scheduledTriggerId.
|
|
228
|
+
* Used for dataset run status aggregation where scheduledTriggerId = datasetRunId.
|
|
229
|
+
*/
|
|
230
|
+
const getScheduledTriggerInvocationStatusSummary = (db) => async (params) => {
|
|
231
|
+
return (await db.select({
|
|
232
|
+
status: scheduledTriggerInvocations.status,
|
|
233
|
+
cnt: count()
|
|
234
|
+
}).from(scheduledTriggerInvocations).where(and(eq(scheduledTriggerInvocations.tenantId, params.scopes.tenantId), eq(scheduledTriggerInvocations.projectId, params.scopes.projectId), eq(scheduledTriggerInvocations.scheduledTriggerId, params.scheduledTriggerId))).groupBy(scheduledTriggerInvocations.status)).reduce((acc, { status, cnt }) => {
|
|
235
|
+
const key = status;
|
|
236
|
+
if (key in acc) acc[key] += Number(cnt);
|
|
237
|
+
return acc;
|
|
238
|
+
}, {
|
|
239
|
+
pending: 0,
|
|
240
|
+
running: 0,
|
|
241
|
+
completed: 0,
|
|
242
|
+
failed: 0,
|
|
243
|
+
cancelled: 0
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* List invocations by scheduledTriggerId without agentId filter (project-scoped).
|
|
248
|
+
* Used for dataset run items listing where scheduledTriggerId = datasetRunId.
|
|
249
|
+
*/
|
|
250
|
+
const listScheduledTriggerInvocationsByTriggerId = (db) => async (params) => {
|
|
251
|
+
const conditions = [
|
|
252
|
+
eq(scheduledTriggerInvocations.tenantId, params.scopes.tenantId),
|
|
253
|
+
eq(scheduledTriggerInvocations.projectId, params.scopes.projectId),
|
|
254
|
+
eq(scheduledTriggerInvocations.scheduledTriggerId, params.scheduledTriggerId)
|
|
255
|
+
];
|
|
256
|
+
if (params.filters?.status) conditions.push(eq(scheduledTriggerInvocations.status, params.filters.status));
|
|
257
|
+
return await db.select().from(scheduledTriggerInvocations).where(and(...conditions)).orderBy(asc(scheduledTriggerInvocations.createdAt));
|
|
258
|
+
};
|
|
226
259
|
|
|
227
260
|
//#endregion
|
|
228
|
-
export { addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
261
|
+
export { addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
2
2
|
import { TaskMetadataConfig } 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 { TaskInsert, TaskSelect } from "../../types/entities.js";
|
|
7
7
|
|
|
8
8
|
//#region src/data-access/runtime/tasks.d.ts
|
|
9
9
|
declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
|
|
10
10
|
id: string;
|
|
11
|
-
metadata: TaskMetadataConfig | null;
|
|
12
11
|
createdAt: string;
|
|
13
12
|
updatedAt: string;
|
|
14
|
-
projectId: string;
|
|
15
|
-
tenantId: string;
|
|
16
|
-
status: string;
|
|
17
13
|
ref: {
|
|
18
14
|
type: "commit" | "tag" | "branch";
|
|
19
15
|
name: string;
|
|
20
16
|
hash: string;
|
|
21
17
|
} | null;
|
|
18
|
+
metadata: TaskMetadataConfig | null;
|
|
19
|
+
status: string;
|
|
20
|
+
tenantId: string;
|
|
21
|
+
projectId: string;
|
|
22
22
|
agentId: string;
|
|
23
|
-
contextId: string;
|
|
24
23
|
subAgentId: string;
|
|
24
|
+
contextId: string;
|
|
25
25
|
}>;
|
|
26
26
|
declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
27
27
|
id: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../../types/index.js";
|
|
2
1
|
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
3
|
import { WorkflowExecutionInsert, WorkflowExecutionSelect } from "../../types/entities.js";
|
|
4
4
|
|
|
5
5
|
//#region src/data-access/runtime/workflowExecutions.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AgentsRunDatabaseClient } from "../db/runtime/runtime-client.js";
|
|
1
2
|
import { PinoLogger } from "../utils/logger.js";
|
|
2
3
|
import { AgentsManageDatabaseClient } from "../db/manage/manage-client.js";
|
|
3
|
-
import { AgentsRunDatabaseClient } from "../db/runtime/runtime-client.js";
|
|
4
4
|
import { AgentSelect, ContextConfigSelect, SubAgentSelect, ToolSelect } from "../types/entities.js";
|
|
5
5
|
|
|
6
6
|
//#region src/data-reconciliation/types.d.ts
|
package/dist/db/clean.d.ts
CHANGED