@inkeep/agents-core 0.78.2 → 0.78.4
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-schema.d.ts +227 -227
- package/dist/auth/auth-validation-schemas.d.ts +154 -154
- package/dist/auth/auth.d.ts +9 -9
- 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/data-access/index.d.ts +5 -5
- package/dist/data-access/index.js +5 -5
- package/dist/data-access/manage/agents.d.ts +16 -16
- package/dist/data-access/manage/artifactComponents.d.ts +10 -10
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +4 -4
- package/dist/data-access/manage/evalConfig.d.ts +19 -2
- package/dist/data-access/manage/evalConfig.js +20 -2
- package/dist/data-access/manage/functionTools.d.ts +14 -14
- package/dist/data-access/manage/skills.d.ts +14 -14
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +28 -28
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgents.d.ts +12 -12
- package/dist/data-access/manage/tools.d.ts +27 -27
- package/dist/data-access/manage/triggers.d.ts +4 -4
- package/dist/data-access/manage/webhookDestinations.d.ts +15 -3
- package/dist/data-access/manage/webhookDestinations.js +26 -8
- package/dist/data-access/runtime/apiKeys.d.ts +20 -20
- package/dist/data-access/runtime/apps.d.ts +17 -17
- package/dist/data-access/runtime/conversations.d.ts +28 -28
- package/dist/data-access/runtime/events.d.ts +5 -5
- package/dist/data-access/runtime/feedback.d.ts +4 -4
- package/dist/data-access/runtime/messages.d.ts +15 -15
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +35 -3
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +16 -3
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +2 -2
- package/dist/data-access/runtime/scheduledTriggers.d.ts +28 -6
- package/dist/data-access/runtime/scheduledTriggers.js +34 -7
- package/dist/data-access/runtime/tasks.d.ts +6 -6
- package/dist/db/manage/manage-schema.d.ts +787 -486
- package/dist/db/manage/manage-schema.js +120 -2
- package/dist/db/runtime/runtime-schema.d.ts +474 -455
- package/dist/db/runtime/runtime-schema.js +3 -1
- package/dist/evaluation/pass-criteria-evaluator.js +69 -29
- package/dist/index.d.ts +9 -9
- package/dist/index.js +8 -8
- package/dist/types/entities.d.ts +5 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +2 -2
- package/dist/types/utility.d.ts +13 -5
- package/dist/types/utility.js +2 -1
- package/dist/utils/error.d.ts +51 -51
- 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 +54 -54
- package/dist/validation/schemas.d.ts +2731 -2387
- package/dist/validation/schemas.js +64 -10
- package/drizzle/manage/0022_last_nemesis.sql +15 -0
- package/drizzle/manage/0023_flimsy_patriot.sql +13 -0
- package/drizzle/manage/meta/0022_snapshot.json +4216 -0
- package/drizzle/manage/meta/0023_snapshot.json +4317 -0
- package/drizzle/manage/meta/_journal.json +14 -0
- package/drizzle/runtime/0043_normal_beyonder.sql +2 -0
- package/drizzle/runtime/meta/0043_snapshot.json +6304 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +1 -1
|
@@ -37,8 +37,8 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
|
|
|
37
37
|
authentication: unknown;
|
|
38
38
|
signingSecretCredentialReferenceId: string | null;
|
|
39
39
|
signatureVerification: {
|
|
40
|
-
algorithm: "
|
|
41
|
-
encoding: "
|
|
40
|
+
algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
|
|
41
|
+
encoding: "hex" | "base64";
|
|
42
42
|
signature: {
|
|
43
43
|
source: "query" | "header" | "body";
|
|
44
44
|
key: string;
|
|
@@ -131,10 +131,10 @@ declare const createTriggerUser: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
131
131
|
triggerId: string;
|
|
132
132
|
userId: string;
|
|
133
133
|
}) => Promise<{
|
|
134
|
-
createdAt: string;
|
|
135
|
-
projectId: string;
|
|
136
134
|
tenantId: string;
|
|
135
|
+
createdAt: string;
|
|
137
136
|
agentId: string;
|
|
137
|
+
projectId: string;
|
|
138
138
|
userId: string;
|
|
139
139
|
triggerId: string;
|
|
140
140
|
}>;
|
|
@@ -33,13 +33,16 @@ declare const listWebhookDestinationsPaginated: (db: AgentsManageDatabaseClient)
|
|
|
33
33
|
pages: number;
|
|
34
34
|
};
|
|
35
35
|
}>;
|
|
36
|
-
type
|
|
36
|
+
type WebhookDestinationWithScoping = WebhookDestinationSelect & {
|
|
37
37
|
agentIds: string[];
|
|
38
|
+
evaluatorIds: string[];
|
|
38
39
|
};
|
|
40
|
+
/** @deprecated Use {@link WebhookDestinationWithScoping} instead. */
|
|
41
|
+
type WebhookDestinationWithAgents = WebhookDestinationWithScoping;
|
|
39
42
|
declare const listEnabledWebhookDestinations: (db: AgentsManageDatabaseClient) => (params: {
|
|
40
43
|
scopes: ProjectScopeConfig;
|
|
41
44
|
agentId: string;
|
|
42
|
-
}) => Promise<
|
|
45
|
+
}) => Promise<WebhookDestinationWithScoping[]>;
|
|
43
46
|
declare const createWebhookDestination: (db: AgentsManageDatabaseClient) => (params: WebhookDestinationInsert) => Promise<WebhookDestinationSelect>;
|
|
44
47
|
declare const updateWebhookDestination: (db: AgentsManageDatabaseClient) => (params: {
|
|
45
48
|
scopes: ProjectScopeConfig;
|
|
@@ -59,5 +62,14 @@ declare const setWebhookDestinationAgentIds: (db: AgentsManageDatabaseClient) =>
|
|
|
59
62
|
webhookDestinationId: string;
|
|
60
63
|
agentIds: string[];
|
|
61
64
|
}) => Promise<void>;
|
|
65
|
+
declare const getWebhookDestinationEvaluatorIds: (db: AgentsManageDatabaseClient) => (params: {
|
|
66
|
+
scopes: ProjectScopeConfig;
|
|
67
|
+
webhookDestinationId: string;
|
|
68
|
+
}) => Promise<string[]>;
|
|
69
|
+
declare const setWebhookDestinationEvaluatorIds: (db: AgentsManageDatabaseClient) => (params: {
|
|
70
|
+
scopes: ProjectScopeConfig;
|
|
71
|
+
webhookDestinationId: string;
|
|
72
|
+
evaluatorIds: string[];
|
|
73
|
+
}) => Promise<void>;
|
|
62
74
|
//#endregion
|
|
63
|
-
export { WebhookDestinationWithAgents, createWebhookDestination, deleteWebhookDestination, getWebhookDestinationAgentIds, getWebhookDestinationById, listEnabledWebhookDestinations, listWebhookDestinationsPaginated, setWebhookDestinationAgentIds, updateWebhookDestination };
|
|
75
|
+
export { WebhookDestinationWithAgents, WebhookDestinationWithScoping, createWebhookDestination, deleteWebhookDestination, getWebhookDestinationAgentIds, getWebhookDestinationById, getWebhookDestinationEvaluatorIds, listEnabledWebhookDestinations, listWebhookDestinationsPaginated, setWebhookDestinationAgentIds, setWebhookDestinationEvaluatorIds, updateWebhookDestination };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { webhookDestinationAgents, webhookDestinations } from "../../db/manage/manage-schema.js";
|
|
1
|
+
import { webhookDestinationAgents, webhookDestinationEvaluators, webhookDestinations } from "../../db/manage/manage-schema.js";
|
|
2
2
|
import { generateId } from "../../utils/conversations.js";
|
|
3
3
|
import { projectScopedWhere } from "./scope-helpers.js";
|
|
4
4
|
import { and, count, desc, eq, inArray } from "drizzle-orm";
|
|
@@ -65,22 +65,26 @@ const listEnabledWebhookDestinations = (db) => async (params) => {
|
|
|
65
65
|
const { scopes, agentId } = params;
|
|
66
66
|
const rows = await db.select({
|
|
67
67
|
dest: webhookDestinations,
|
|
68
|
-
scopedAgentId: webhookDestinationAgents.agentId
|
|
69
|
-
|
|
68
|
+
scopedAgentId: webhookDestinationAgents.agentId,
|
|
69
|
+
scopedEvaluatorId: webhookDestinationEvaluators.evaluatorId
|
|
70
|
+
}).from(webhookDestinations).leftJoin(webhookDestinationAgents, and(eq(webhookDestinationAgents.tenantId, webhookDestinations.tenantId), eq(webhookDestinationAgents.projectId, webhookDestinations.projectId), eq(webhookDestinationAgents.webhookDestinationId, webhookDestinations.id))).leftJoin(webhookDestinationEvaluators, and(eq(webhookDestinationEvaluators.tenantId, webhookDestinations.tenantId), eq(webhookDestinationEvaluators.projectId, webhookDestinations.projectId), eq(webhookDestinationEvaluators.webhookDestinationId, webhookDestinations.id))).where(and(projectScopedWhere(webhookDestinations, scopes), eq(webhookDestinations.enabled, true)));
|
|
70
71
|
if (rows.length === 0) return [];
|
|
71
72
|
const destMap = /* @__PURE__ */ new Map();
|
|
72
73
|
for (const row of rows) {
|
|
73
74
|
const existing = destMap.get(row.dest.id);
|
|
74
75
|
if (existing) {
|
|
75
|
-
if (row.scopedAgentId) existing.agentIds.
|
|
76
|
+
if (row.scopedAgentId) existing.agentIds.add(row.scopedAgentId);
|
|
77
|
+
if (row.scopedEvaluatorId) existing.evaluatorIds.add(row.scopedEvaluatorId);
|
|
76
78
|
} else destMap.set(row.dest.id, {
|
|
77
79
|
dest: row.dest,
|
|
78
|
-
agentIds: row.scopedAgentId ? [row.scopedAgentId] : []
|
|
80
|
+
agentIds: new Set(row.scopedAgentId ? [row.scopedAgentId] : []),
|
|
81
|
+
evaluatorIds: new Set(row.scopedEvaluatorId ? [row.scopedEvaluatorId] : [])
|
|
79
82
|
});
|
|
80
83
|
}
|
|
81
|
-
return Array.from(destMap.values()).filter(({ agentIds }) => agentIds.
|
|
84
|
+
return Array.from(destMap.values()).filter(({ agentIds }) => agentIds.size === 0 || agentIds.has(agentId)).map(({ dest, agentIds, evaluatorIds }) => ({
|
|
82
85
|
...dest,
|
|
83
|
-
agentIds
|
|
86
|
+
agentIds: Array.from(agentIds),
|
|
87
|
+
evaluatorIds: Array.from(evaluatorIds)
|
|
84
88
|
}));
|
|
85
89
|
};
|
|
86
90
|
const createWebhookDestination = (db) => async (params) => {
|
|
@@ -110,6 +114,20 @@ const setWebhookDestinationAgentIds = (db) => async (params) => {
|
|
|
110
114
|
agentId
|
|
111
115
|
})));
|
|
112
116
|
};
|
|
117
|
+
const getWebhookDestinationEvaluatorIds = (db) => async (params) => {
|
|
118
|
+
return (await db.select({ evaluatorId: webhookDestinationEvaluators.evaluatorId }).from(webhookDestinationEvaluators).where(and(eq(webhookDestinationEvaluators.tenantId, params.scopes.tenantId), eq(webhookDestinationEvaluators.projectId, params.scopes.projectId), eq(webhookDestinationEvaluators.webhookDestinationId, params.webhookDestinationId)))).map((r) => r.evaluatorId);
|
|
119
|
+
};
|
|
120
|
+
const setWebhookDestinationEvaluatorIds = (db) => async (params) => {
|
|
121
|
+
const { scopes, webhookDestinationId, evaluatorIds } = params;
|
|
122
|
+
await db.delete(webhookDestinationEvaluators).where(and(eq(webhookDestinationEvaluators.tenantId, scopes.tenantId), eq(webhookDestinationEvaluators.projectId, scopes.projectId), eq(webhookDestinationEvaluators.webhookDestinationId, webhookDestinationId)));
|
|
123
|
+
if (evaluatorIds.length > 0) await db.insert(webhookDestinationEvaluators).values(evaluatorIds.map((evaluatorId) => ({
|
|
124
|
+
id: generateId(),
|
|
125
|
+
tenantId: scopes.tenantId,
|
|
126
|
+
projectId: scopes.projectId,
|
|
127
|
+
webhookDestinationId,
|
|
128
|
+
evaluatorId
|
|
129
|
+
})));
|
|
130
|
+
};
|
|
113
131
|
|
|
114
132
|
//#endregion
|
|
115
|
-
export { createWebhookDestination, deleteWebhookDestination, getWebhookDestinationAgentIds, getWebhookDestinationById, listEnabledWebhookDestinations, listWebhookDestinationsPaginated, setWebhookDestinationAgentIds, updateWebhookDestination };
|
|
133
|
+
export { createWebhookDestination, deleteWebhookDestination, getWebhookDestinationAgentIds, getWebhookDestinationById, getWebhookDestinationEvaluatorIds, listEnabledWebhookDestinations, listWebhookDestinationsPaginated, setWebhookDestinationAgentIds, setWebhookDestinationEvaluatorIds, updateWebhookDestination };
|
|
@@ -9,48 +9,48 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
|
-
name: string | null;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
updatedAt: string;
|
|
15
|
-
projectId: string;
|
|
16
12
|
tenantId: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
name: string | null;
|
|
17
15
|
agentId: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
updatedAt: string;
|
|
18
18
|
expiresAt: string | null;
|
|
19
|
+
lastUsedAt: string | null;
|
|
19
20
|
publicId: string;
|
|
20
21
|
keyHash: string;
|
|
21
22
|
keyPrefix: string;
|
|
22
|
-
lastUsedAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
25
|
id: string;
|
|
26
|
-
name: string | null;
|
|
27
|
-
createdAt: string;
|
|
28
|
-
updatedAt: string;
|
|
29
|
-
projectId: string;
|
|
30
26
|
tenantId: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
name: string | null;
|
|
31
29
|
agentId: string;
|
|
30
|
+
projectId: string;
|
|
31
|
+
updatedAt: string;
|
|
32
32
|
expiresAt: string | null;
|
|
33
|
+
lastUsedAt: string | null;
|
|
33
34
|
publicId: string;
|
|
34
35
|
keyHash: string;
|
|
35
36
|
keyPrefix: string;
|
|
36
|
-
lastUsedAt: 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
42
|
id: string;
|
|
43
|
-
name: string | null;
|
|
44
|
-
createdAt: string;
|
|
45
|
-
updatedAt: string;
|
|
46
|
-
projectId: string;
|
|
47
43
|
tenantId: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
name: string | null;
|
|
48
46
|
agentId: string;
|
|
47
|
+
projectId: string;
|
|
48
|
+
updatedAt: string;
|
|
49
49
|
expiresAt: string | null;
|
|
50
|
+
lastUsedAt: string | null;
|
|
50
51
|
publicId: string;
|
|
51
52
|
keyHash: string;
|
|
52
53
|
keyPrefix: string;
|
|
53
|
-
lastUsedAt: string | null;
|
|
54
54
|
}[]>;
|
|
55
55
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
@@ -67,17 +67,17 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
69
|
id: string;
|
|
70
|
-
name: string | null;
|
|
71
|
-
createdAt: string;
|
|
72
|
-
updatedAt: string;
|
|
73
|
-
projectId: string;
|
|
74
70
|
tenantId: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
name: string | null;
|
|
75
73
|
agentId: string;
|
|
74
|
+
projectId: string;
|
|
75
|
+
updatedAt: string;
|
|
76
76
|
expiresAt: string | null;
|
|
77
|
+
lastUsedAt: string | null;
|
|
77
78
|
publicId: string;
|
|
78
79
|
keyHash: string;
|
|
79
80
|
keyPrefix: string;
|
|
80
|
-
lastUsedAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -7,14 +7,13 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
8
|
type: AppType;
|
|
9
9
|
id: string;
|
|
10
|
+
tenantId: string | null;
|
|
11
|
+
createdAt: string;
|
|
10
12
|
name: string;
|
|
11
13
|
description: string | null;
|
|
12
|
-
enabled: boolean;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
updatedAt: string;
|
|
15
14
|
projectId: string | null;
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
enabled: boolean;
|
|
18
17
|
config: {
|
|
19
18
|
type: "web_client";
|
|
20
19
|
webClient: {
|
|
@@ -22,7 +21,7 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
22
21
|
publicKeys: {
|
|
23
22
|
kid: string;
|
|
24
23
|
publicKey: string;
|
|
25
|
-
algorithm: "
|
|
24
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
26
25
|
addedAt: string;
|
|
27
26
|
}[];
|
|
28
27
|
allowAnonymous: boolean;
|
|
@@ -45,9 +44,10 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
45
44
|
}[] | undefined;
|
|
46
45
|
};
|
|
47
46
|
};
|
|
48
|
-
|
|
49
|
-
defaultProjectId: string | null;
|
|
47
|
+
prompt: string | null;
|
|
50
48
|
defaultAgentId: string | null;
|
|
49
|
+
defaultProjectId: string | null;
|
|
50
|
+
lastUsedAt: string | null;
|
|
51
51
|
} | undefined>;
|
|
52
52
|
declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
|
|
53
53
|
declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -76,14 +76,13 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
76
76
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
77
77
|
type: AppType;
|
|
78
78
|
id: string;
|
|
79
|
+
tenantId: string | null;
|
|
80
|
+
createdAt: string;
|
|
79
81
|
name: string;
|
|
80
82
|
description: string | null;
|
|
81
|
-
enabled: boolean;
|
|
82
|
-
createdAt: string;
|
|
83
|
-
updatedAt: string;
|
|
84
83
|
projectId: string | null;
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
updatedAt: string;
|
|
85
|
+
enabled: boolean;
|
|
87
86
|
config: {
|
|
88
87
|
type: "web_client";
|
|
89
88
|
webClient: {
|
|
@@ -91,7 +90,7 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
91
90
|
publicKeys: {
|
|
92
91
|
kid: string;
|
|
93
92
|
publicKey: string;
|
|
94
|
-
algorithm: "
|
|
93
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
95
94
|
addedAt: string;
|
|
96
95
|
}[];
|
|
97
96
|
allowAnonymous: boolean;
|
|
@@ -114,9 +113,10 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
114
113
|
}[] | undefined;
|
|
115
114
|
};
|
|
116
115
|
};
|
|
117
|
-
|
|
118
|
-
defaultProjectId: string | null;
|
|
116
|
+
prompt: string | null;
|
|
119
117
|
defaultAgentId: string | null;
|
|
118
|
+
defaultProjectId: string | null;
|
|
119
|
+
lastUsedAt: string | null;
|
|
120
120
|
}>;
|
|
121
121
|
declare const updateAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
122
122
|
scopes: TenantScopeConfig;
|
|
@@ -174,7 +174,7 @@ declare const updateApp: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
174
174
|
publicKeys: {
|
|
175
175
|
kid: string;
|
|
176
176
|
publicKey: string;
|
|
177
|
-
algorithm: "
|
|
177
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
178
178
|
addedAt: string;
|
|
179
179
|
}[];
|
|
180
180
|
allowAnonymous: boolean;
|
|
@@ -17,23 +17,23 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
17
17
|
}>;
|
|
18
18
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
19
19
|
id: string;
|
|
20
|
-
createdAt: string;
|
|
21
|
-
updatedAt: string;
|
|
22
|
-
projectId: string;
|
|
23
20
|
tenantId: string;
|
|
24
|
-
|
|
25
|
-
title: string | null;
|
|
21
|
+
createdAt: string;
|
|
26
22
|
metadata: ConversationMetadata | null;
|
|
27
|
-
|
|
23
|
+
title: string | null;
|
|
24
|
+
properties: Record<string, unknown> | null;
|
|
28
25
|
ref: {
|
|
29
26
|
type: "commit" | "tag" | "branch";
|
|
30
27
|
name: string;
|
|
31
28
|
hash: string;
|
|
32
29
|
} | null;
|
|
30
|
+
agentId: string | null;
|
|
31
|
+
projectId: string;
|
|
32
|
+
updatedAt: string;
|
|
33
33
|
userId: string | null;
|
|
34
|
-
userProperties: Record<string, unknown> | null;
|
|
35
34
|
activeSubAgentId: string;
|
|
36
35
|
lastContextResolution: string | null;
|
|
36
|
+
userProperties: Record<string, unknown> | null;
|
|
37
37
|
}>;
|
|
38
38
|
declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
@@ -92,23 +92,23 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
92
92
|
conversationId: string;
|
|
93
93
|
}) => Promise<{
|
|
94
94
|
id: string;
|
|
95
|
-
createdAt: string;
|
|
96
|
-
updatedAt: string;
|
|
97
|
-
projectId: string;
|
|
98
95
|
tenantId: string;
|
|
99
|
-
|
|
100
|
-
title: string | null;
|
|
96
|
+
createdAt: string;
|
|
101
97
|
metadata: ConversationMetadata | null;
|
|
102
|
-
|
|
98
|
+
title: string | null;
|
|
99
|
+
properties: Record<string, unknown> | null;
|
|
103
100
|
ref: {
|
|
104
101
|
type: "commit" | "tag" | "branch";
|
|
105
102
|
name: string;
|
|
106
103
|
hash: string;
|
|
107
104
|
} | null;
|
|
105
|
+
agentId: string | null;
|
|
106
|
+
projectId: string;
|
|
107
|
+
updatedAt: string;
|
|
108
108
|
userId: string | null;
|
|
109
|
-
userProperties: Record<string, unknown> | null;
|
|
110
109
|
activeSubAgentId: string;
|
|
111
110
|
lastContextResolution: string | null;
|
|
111
|
+
userProperties: Record<string, unknown> | null;
|
|
112
112
|
} | undefined>;
|
|
113
113
|
/**
|
|
114
114
|
* Batch-fetch conversations by id within a project scope.
|
|
@@ -147,23 +147,23 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
147
147
|
properties?: Record<string, unknown> | null | undefined;
|
|
148
148
|
} | {
|
|
149
149
|
id: string;
|
|
150
|
-
createdAt: string;
|
|
151
|
-
updatedAt: string;
|
|
152
|
-
projectId: string;
|
|
153
150
|
tenantId: string;
|
|
154
|
-
|
|
155
|
-
title: string | null;
|
|
151
|
+
createdAt: string;
|
|
156
152
|
metadata: ConversationMetadata | null;
|
|
157
|
-
|
|
153
|
+
title: string | null;
|
|
154
|
+
properties: Record<string, unknown> | null;
|
|
158
155
|
ref: {
|
|
159
156
|
type: "commit" | "tag" | "branch";
|
|
160
157
|
name: string;
|
|
161
158
|
hash: string;
|
|
162
159
|
} | null;
|
|
160
|
+
agentId: string | null;
|
|
161
|
+
projectId: string;
|
|
162
|
+
updatedAt: string;
|
|
163
163
|
userId: string | null;
|
|
164
|
-
userProperties: Record<string, unknown> | null;
|
|
165
164
|
activeSubAgentId: string;
|
|
166
165
|
lastContextResolution: string | null;
|
|
166
|
+
userProperties: Record<string, unknown> | null;
|
|
167
167
|
}>;
|
|
168
168
|
/**
|
|
169
169
|
* Extract text content from message content object
|
|
@@ -185,23 +185,23 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
185
185
|
conversationId: string;
|
|
186
186
|
}) => Promise<{
|
|
187
187
|
id: string;
|
|
188
|
-
createdAt: string;
|
|
189
|
-
updatedAt: string;
|
|
190
|
-
projectId: string;
|
|
191
188
|
tenantId: string;
|
|
192
|
-
|
|
193
|
-
title: string | null;
|
|
189
|
+
createdAt: string;
|
|
194
190
|
metadata: ConversationMetadata | null;
|
|
195
|
-
|
|
191
|
+
title: string | null;
|
|
192
|
+
properties: Record<string, unknown> | null;
|
|
196
193
|
ref: {
|
|
197
194
|
type: "commit" | "tag" | "branch";
|
|
198
195
|
name: string;
|
|
199
196
|
hash: string;
|
|
200
197
|
} | null;
|
|
198
|
+
agentId: string | null;
|
|
199
|
+
projectId: string;
|
|
200
|
+
updatedAt: string;
|
|
201
201
|
userId: string | null;
|
|
202
|
-
userProperties: Record<string, unknown> | null;
|
|
203
202
|
activeSubAgentId: string;
|
|
204
203
|
lastContextResolution: string | null;
|
|
204
|
+
userProperties: Record<string, unknown> | null;
|
|
205
205
|
} | undefined>;
|
|
206
206
|
/**
|
|
207
207
|
* Set active agent for a conversation (upsert operation)
|
|
@@ -9,16 +9,16 @@ declare const createEvent: (db: AgentsRunDatabaseClient) => (params: EventInsert
|
|
|
9
9
|
row: {
|
|
10
10
|
type: string;
|
|
11
11
|
id: string;
|
|
12
|
-
createdAt: string;
|
|
13
|
-
updatedAt: string;
|
|
14
|
-
projectId: string;
|
|
15
12
|
tenantId: string;
|
|
16
|
-
|
|
13
|
+
createdAt: string;
|
|
17
14
|
metadata: Record<string, unknown> | null;
|
|
15
|
+
properties: Record<string, unknown> | null;
|
|
18
16
|
agentId: string | null;
|
|
17
|
+
projectId: string;
|
|
18
|
+
updatedAt: string;
|
|
19
19
|
conversationId: string | null;
|
|
20
|
-
messageId: string | null;
|
|
21
20
|
userProperties: Record<string, unknown> | null;
|
|
21
|
+
messageId: string | null;
|
|
22
22
|
serverMetadata: {
|
|
23
23
|
[k: string]: unknown;
|
|
24
24
|
authMethod?: string;
|
|
@@ -72,10 +72,10 @@ declare const getFeedbackByIds: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
72
72
|
declare const createFeedback: (db: AgentsRunDatabaseClient) => (params: FeedbackInsert) => Promise<{
|
|
73
73
|
type: "positive" | "negative";
|
|
74
74
|
id: string;
|
|
75
|
+
tenantId: string;
|
|
75
76
|
createdAt: string;
|
|
76
|
-
updatedAt: string;
|
|
77
77
|
projectId: string;
|
|
78
|
-
|
|
78
|
+
updatedAt: string;
|
|
79
79
|
conversationId: string;
|
|
80
80
|
messageId: string | null;
|
|
81
81
|
details: string | null;
|
|
@@ -102,10 +102,10 @@ declare const deleteFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
102
102
|
}) => Promise<{
|
|
103
103
|
type: "positive" | "negative";
|
|
104
104
|
id: string;
|
|
105
|
+
tenantId: string;
|
|
105
106
|
createdAt: string;
|
|
106
|
-
updatedAt: string;
|
|
107
107
|
projectId: string;
|
|
108
|
-
|
|
108
|
+
updatedAt: string;
|
|
109
109
|
conversationId: string;
|
|
110
110
|
messageId: string | null;
|
|
111
111
|
details: string | null;
|
|
@@ -11,16 +11,16 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
13
|
id: string;
|
|
14
|
-
createdAt: string;
|
|
15
|
-
updatedAt: string;
|
|
16
|
-
projectId: string;
|
|
17
14
|
tenantId: string;
|
|
18
|
-
|
|
15
|
+
createdAt: string;
|
|
19
16
|
metadata: MessageMetadata | null;
|
|
17
|
+
properties: Record<string, unknown> | null;
|
|
20
18
|
content: MessageContent;
|
|
21
|
-
|
|
19
|
+
projectId: string;
|
|
20
|
+
updatedAt: string;
|
|
22
21
|
conversationId: string;
|
|
23
22
|
userProperties: Record<string, unknown> | null;
|
|
23
|
+
role: string;
|
|
24
24
|
fromSubAgentId: string | null;
|
|
25
25
|
toSubAgentId: string | null;
|
|
26
26
|
fromExternalAgentId: string | null;
|
|
@@ -184,16 +184,16 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
184
184
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
185
185
|
}) => Promise<{
|
|
186
186
|
id: string;
|
|
187
|
-
createdAt: string;
|
|
188
|
-
updatedAt: string;
|
|
189
|
-
projectId: string;
|
|
190
187
|
tenantId: string;
|
|
191
|
-
|
|
188
|
+
createdAt: string;
|
|
192
189
|
metadata: MessageMetadata | null;
|
|
190
|
+
properties: Record<string, unknown> | null;
|
|
193
191
|
content: MessageContent;
|
|
194
|
-
|
|
192
|
+
projectId: string;
|
|
193
|
+
updatedAt: string;
|
|
195
194
|
conversationId: string;
|
|
196
195
|
userProperties: Record<string, unknown> | null;
|
|
196
|
+
role: string;
|
|
197
197
|
fromSubAgentId: string | null;
|
|
198
198
|
toSubAgentId: string | null;
|
|
199
199
|
fromExternalAgentId: string | null;
|
|
@@ -241,16 +241,16 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
241
241
|
messageId: string;
|
|
242
242
|
}) => Promise<{
|
|
243
243
|
id: string;
|
|
244
|
-
createdAt: string;
|
|
245
|
-
updatedAt: string;
|
|
246
|
-
projectId: string;
|
|
247
244
|
tenantId: string;
|
|
248
|
-
|
|
245
|
+
createdAt: string;
|
|
249
246
|
metadata: MessageMetadata | null;
|
|
247
|
+
properties: Record<string, unknown> | null;
|
|
250
248
|
content: MessageContent;
|
|
251
|
-
|
|
249
|
+
projectId: string;
|
|
250
|
+
updatedAt: string;
|
|
252
251
|
conversationId: string;
|
|
253
252
|
userProperties: Record<string, unknown> | null;
|
|
253
|
+
role: string;
|
|
254
254
|
fromSubAgentId: string | null;
|
|
255
255
|
toSubAgentId: string | null;
|
|
256
256
|
fromExternalAgentId: string | null;
|
|
@@ -150,7 +150,7 @@ declare const markScheduledTriggerInvocationCancelled: (db: AgentsRunDatabaseCli
|
|
|
150
150
|
* Used when a trigger is deleted
|
|
151
151
|
*/
|
|
152
152
|
declare const cancelPendingInvocationsForTrigger: (db: AgentsRunDatabaseClient) => (params: {
|
|
153
|
-
scopes:
|
|
153
|
+
scopes: ProjectScopeConfig;
|
|
154
154
|
scheduledTriggerId: string;
|
|
155
155
|
}) => Promise<number>;
|
|
156
156
|
/**
|
|
@@ -158,7 +158,7 @@ declare const cancelPendingInvocationsForTrigger: (db: AgentsRunDatabaseClient)
|
|
|
158
158
|
* Used when a trigger is disabled - keeps future invocations pending
|
|
159
159
|
*/
|
|
160
160
|
declare const cancelPastPendingInvocationsForTrigger: (db: AgentsRunDatabaseClient) => (params: {
|
|
161
|
-
scopes:
|
|
161
|
+
scopes: ProjectScopeConfig;
|
|
162
162
|
scheduledTriggerId: string;
|
|
163
163
|
}) => Promise<number>;
|
|
164
164
|
type ScheduledTriggerRunInfo = {
|
|
@@ -307,5 +307,37 @@ declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabase
|
|
|
307
307
|
tenantId: string;
|
|
308
308
|
id: string;
|
|
309
309
|
}[]>;
|
|
310
|
+
declare const listScheduledTriggerInvocationsByDatasetRunId: (db: AgentsRunDatabaseClient) => (params: {
|
|
311
|
+
scopes: ProjectScopeConfig;
|
|
312
|
+
datasetRunId: string;
|
|
313
|
+
filters?: {
|
|
314
|
+
status?: string;
|
|
315
|
+
};
|
|
316
|
+
}) => Promise<{
|
|
317
|
+
scheduledTriggerId: string;
|
|
318
|
+
ref: {
|
|
319
|
+
type: "commit" | "tag" | "branch";
|
|
320
|
+
name: string;
|
|
321
|
+
hash: string;
|
|
322
|
+
} | null;
|
|
323
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
324
|
+
scheduledFor: string;
|
|
325
|
+
startedAt: string | null;
|
|
326
|
+
completedAt: string | null;
|
|
327
|
+
resolvedPayload: Record<string, unknown> | null;
|
|
328
|
+
conversationIds: string[] | null;
|
|
329
|
+
attemptNumber: number;
|
|
330
|
+
idempotencyKey: string;
|
|
331
|
+
runAsUserId: string | null;
|
|
332
|
+
createdAt: string;
|
|
333
|
+
agentId: string;
|
|
334
|
+
projectId: string;
|
|
335
|
+
tenantId: string;
|
|
336
|
+
id: string;
|
|
337
|
+
}[]>;
|
|
338
|
+
declare const getLastRunAtForTrigger: (db: AgentsRunDatabaseClient) => (params: {
|
|
339
|
+
scopes: ProjectScopeConfig;
|
|
340
|
+
scheduledTriggerId: string;
|
|
341
|
+
}) => Promise<string | null>;
|
|
310
342
|
//#endregion
|
|
311
|
-
export { ScheduledTriggerRunInfo, addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
343
|
+
export { ScheduledTriggerRunInfo, addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getLastRunAtForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByDatasetRunId, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
@@ -133,7 +133,7 @@ const cancelPendingInvocationsForTrigger = (db) => async (params) => {
|
|
|
133
133
|
return (await db.update(scheduledTriggerInvocations).set({
|
|
134
134
|
status: "cancelled",
|
|
135
135
|
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
136
|
-
}).where(and(
|
|
136
|
+
}).where(and(projectScopedWhere(scheduledTriggerInvocations, params.scopes), eq(scheduledTriggerInvocations.scheduledTriggerId, params.scheduledTriggerId), inArray(scheduledTriggerInvocations.status, ["pending", "running"]))).returning()).length;
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
139
|
* Cancel only PAST pending invocations for a trigger (scheduledFor <= now)
|
|
@@ -144,7 +144,7 @@ const cancelPastPendingInvocationsForTrigger = (db) => async (params) => {
|
|
|
144
144
|
return (await db.update(scheduledTriggerInvocations).set({
|
|
145
145
|
status: "cancelled",
|
|
146
146
|
completedAt: now
|
|
147
|
-
}).where(and(
|
|
147
|
+
}).where(and(projectScopedWhere(scheduledTriggerInvocations, params.scopes), eq(scheduledTriggerInvocations.scheduledTriggerId, params.scheduledTriggerId), inArray(scheduledTriggerInvocations.status, ["pending", "running"]), lte(scheduledTriggerInvocations.scheduledFor, now))).returning()).length;
|
|
148
148
|
};
|
|
149
149
|
/**
|
|
150
150
|
* Get run info for multiple scheduled triggers in a single query.
|
|
@@ -314,6 +314,19 @@ const listScheduledTriggerInvocationsByTriggerId = (db) => async (params) => {
|
|
|
314
314
|
if (params.filters?.status) conditions.push(eq(scheduledTriggerInvocations.status, params.filters.status));
|
|
315
315
|
return await db.select().from(scheduledTriggerInvocations).where(and(...conditions)).orderBy(asc(scheduledTriggerInvocations.createdAt));
|
|
316
316
|
};
|
|
317
|
+
const listScheduledTriggerInvocationsByDatasetRunId = (db) => async (params) => {
|
|
318
|
+
const conditions = [
|
|
319
|
+
eq(scheduledTriggerInvocations.tenantId, params.scopes.tenantId),
|
|
320
|
+
eq(scheduledTriggerInvocations.projectId, params.scopes.projectId),
|
|
321
|
+
sql`${scheduledTriggerInvocations.resolvedPayload}->>'datasetRunId' = ${params.datasetRunId}`
|
|
322
|
+
];
|
|
323
|
+
if (params.filters?.status) conditions.push(eq(scheduledTriggerInvocations.status, params.filters.status));
|
|
324
|
+
return await db.select().from(scheduledTriggerInvocations).where(and(...conditions)).orderBy(asc(scheduledTriggerInvocations.createdAt));
|
|
325
|
+
};
|
|
326
|
+
const getLastRunAtForTrigger = (db) => async (params) => {
|
|
327
|
+
const [row] = await db.select({ completedAt: scheduledTriggerInvocations.completedAt }).from(scheduledTriggerInvocations).where(and(eq(scheduledTriggerInvocations.tenantId, params.scopes.tenantId), eq(scheduledTriggerInvocations.projectId, params.scopes.projectId), eq(scheduledTriggerInvocations.scheduledTriggerId, params.scheduledTriggerId), inArray(scheduledTriggerInvocations.status, ["completed", "failed"]))).orderBy(desc(scheduledTriggerInvocations.completedAt)).limit(1);
|
|
328
|
+
return row?.completedAt ?? null;
|
|
329
|
+
};
|
|
317
330
|
|
|
318
331
|
//#endregion
|
|
319
|
-
export { addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
332
|
+
export { addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getLastRunAtForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByDatasetRunId, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
@@ -15,10 +15,10 @@ declare const createScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (para
|
|
|
15
15
|
scheduledTriggerId: string;
|
|
16
16
|
userId: string;
|
|
17
17
|
}) => Promise<{
|
|
18
|
-
createdAt: string;
|
|
19
18
|
tenantId: string;
|
|
20
|
-
|
|
19
|
+
createdAt: string;
|
|
21
20
|
scheduledTriggerId: string;
|
|
21
|
+
userId: string;
|
|
22
22
|
}>;
|
|
23
23
|
declare const deleteScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (params: {
|
|
24
24
|
tenantId: string;
|