@inkeep/agents-core 0.0.0-dev-20260405144921 → 0.0.0-dev-20260406151446
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-validation-schemas.d.ts +154 -154
- package/dist/client-exports.d.ts +2 -2
- package/dist/client-exports.js +2 -2
- package/dist/data-access/index.d.ts +3 -2
- package/dist/data-access/index.js +2 -1
- package/dist/data-access/manage/agents.d.ts +22 -22
- package/dist/data-access/manage/artifactComponents.d.ts +2 -2
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +4 -4
- package/dist/data-access/manage/skills.d.ts +4 -4
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgents.d.ts +6 -6
- package/dist/data-access/manage/tools.d.ts +15 -15
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +4 -4
- package/dist/data-access/runtime/apps.d.ts +2 -2
- package/dist/data-access/runtime/conversations.d.ts +4 -4
- package/dist/data-access/runtime/messages.d.ts +3 -3
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +18 -10
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +67 -9
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +54 -0
- package/dist/data-access/runtime/scheduledTriggerUsers.js +62 -0
- package/dist/data-access/runtime/scheduledTriggers.d.ts +1 -0
- package/dist/data-access/runtime/tasks.d.ts +1 -1
- package/dist/db/manage/dolt-safe-jsonb.d.ts +2 -2
- package/dist/db/manage/manage-schema.d.ts +449 -449
- package/dist/db/runtime/runtime-schema.d.ts +501 -384
- package/dist/db/runtime/runtime-schema.js +36 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.js +4 -3
- package/dist/middleware/no-auth.d.ts +2 -2
- package/dist/types/entities.d.ts +6 -2
- package/dist/types/index.d.ts +2 -2
- 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 +28 -28
- package/dist/validation/schemas.d.ts +1789 -1695
- package/dist/validation/schemas.js +26 -5
- package/drizzle/runtime/0032_sloppy_starfox.sql +17 -0
- package/drizzle/runtime/0033_backfill-scheduled-trigger-users.sql +7 -0
- package/drizzle/runtime/meta/0032_snapshot.json +5120 -0
- package/drizzle/runtime/meta/_journal.json +14 -0
- package/package.json +1 -1
|
@@ -25,14 +25,14 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
25
25
|
createdAt: string;
|
|
26
26
|
updatedAt: string;
|
|
27
27
|
description: string | null;
|
|
28
|
-
headers: Record<string, string> | null;
|
|
29
28
|
projectId: string;
|
|
30
29
|
tenantId: string;
|
|
30
|
+
headers: Record<string, string> | null;
|
|
31
|
+
credentialReferenceId: string | null;
|
|
31
32
|
config: {
|
|
32
33
|
type: "mcp";
|
|
33
34
|
mcp: ToolMcpConfig;
|
|
34
35
|
};
|
|
35
|
-
credentialReferenceId: string | null;
|
|
36
36
|
credentialScope: string;
|
|
37
37
|
imageUrl: string | null;
|
|
38
38
|
capabilities: ToolServerCapabilities | null;
|
|
@@ -83,14 +83,14 @@ declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInser
|
|
|
83
83
|
createdAt: string;
|
|
84
84
|
updatedAt: string;
|
|
85
85
|
description: string | null;
|
|
86
|
-
headers: Record<string, string> | null;
|
|
87
86
|
projectId: string;
|
|
88
87
|
tenantId: string;
|
|
88
|
+
headers: Record<string, string> | null;
|
|
89
|
+
credentialReferenceId: string | null;
|
|
89
90
|
config: {
|
|
90
91
|
type: "mcp";
|
|
91
92
|
mcp: ToolMcpConfig;
|
|
92
93
|
};
|
|
93
|
-
credentialReferenceId: string | null;
|
|
94
94
|
credentialScope: string;
|
|
95
95
|
imageUrl: string | null;
|
|
96
96
|
capabilities: ToolServerCapabilities | null;
|
|
@@ -138,16 +138,16 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
138
138
|
id: string;
|
|
139
139
|
createdAt: string;
|
|
140
140
|
updatedAt: string;
|
|
141
|
-
headers: Record<string, string> | null;
|
|
142
|
-
agentId: string;
|
|
143
141
|
projectId: string;
|
|
144
142
|
tenantId: string;
|
|
143
|
+
agentId: string;
|
|
144
|
+
headers: Record<string, string> | null;
|
|
145
145
|
subAgentId: string;
|
|
146
146
|
toolId: string;
|
|
147
|
+
selectedTools: string[] | null;
|
|
147
148
|
toolPolicies: Record<string, {
|
|
148
149
|
needsApproval?: boolean;
|
|
149
150
|
}> | null;
|
|
150
|
-
selectedTools: string[] | null;
|
|
151
151
|
}>;
|
|
152
152
|
declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
153
153
|
scopes: AgentScopeConfig;
|
|
@@ -157,16 +157,16 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
157
157
|
id: string;
|
|
158
158
|
createdAt: string;
|
|
159
159
|
updatedAt: string;
|
|
160
|
-
headers: Record<string, string> | null;
|
|
161
|
-
agentId: string;
|
|
162
160
|
projectId: string;
|
|
163
161
|
tenantId: string;
|
|
162
|
+
agentId: string;
|
|
163
|
+
headers: Record<string, string> | null;
|
|
164
164
|
subAgentId: string;
|
|
165
165
|
toolId: string;
|
|
166
|
+
selectedTools: string[] | null;
|
|
166
167
|
toolPolicies: Record<string, {
|
|
167
168
|
needsApproval?: boolean;
|
|
168
169
|
}> | null;
|
|
169
|
-
selectedTools: string[] | null;
|
|
170
170
|
}>;
|
|
171
171
|
/**
|
|
172
172
|
* Upsert agent-tool relation (create if it doesn't exist, update if it does)
|
|
@@ -185,16 +185,16 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
185
185
|
id: string;
|
|
186
186
|
createdAt: string;
|
|
187
187
|
updatedAt: string;
|
|
188
|
-
headers: Record<string, string> | null;
|
|
189
|
-
agentId: string;
|
|
190
188
|
projectId: string;
|
|
191
189
|
tenantId: string;
|
|
190
|
+
agentId: string;
|
|
191
|
+
headers: Record<string, string> | null;
|
|
192
192
|
subAgentId: string;
|
|
193
193
|
toolId: string;
|
|
194
|
+
selectedTools: string[] | null;
|
|
194
195
|
toolPolicies: Record<string, {
|
|
195
196
|
needsApproval?: boolean;
|
|
196
197
|
}> | null;
|
|
197
|
-
selectedTools: string[] | null;
|
|
198
198
|
}>;
|
|
199
199
|
/**
|
|
200
200
|
* Upsert a tool (create if it doesn't exist, update if it does)
|
|
@@ -207,14 +207,14 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
207
207
|
createdAt: string;
|
|
208
208
|
updatedAt: string;
|
|
209
209
|
description: string | null;
|
|
210
|
-
headers: Record<string, string> | null;
|
|
211
210
|
projectId: string;
|
|
212
211
|
tenantId: string;
|
|
212
|
+
headers: Record<string, string> | null;
|
|
213
|
+
credentialReferenceId: string | null;
|
|
213
214
|
config: {
|
|
214
215
|
type: "mcp";
|
|
215
216
|
mcp: ToolMcpConfig;
|
|
216
217
|
};
|
|
217
|
-
credentialReferenceId: string | null;
|
|
218
218
|
credentialScope: string;
|
|
219
219
|
imageUrl: string | null;
|
|
220
220
|
capabilities: ToolServerCapabilities | null;
|
|
@@ -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" | "body" | "header";
|
|
44
44
|
key: string;
|
|
@@ -13,9 +13,9 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
13
13
|
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
15
|
expiresAt: string | null;
|
|
16
|
-
agentId: string;
|
|
17
16
|
projectId: string;
|
|
18
17
|
tenantId: string;
|
|
18
|
+
agentId: string;
|
|
19
19
|
publicId: string;
|
|
20
20
|
keyHash: string;
|
|
21
21
|
keyPrefix: string;
|
|
@@ -27,9 +27,9 @@ declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: s
|
|
|
27
27
|
createdAt: string;
|
|
28
28
|
updatedAt: string;
|
|
29
29
|
expiresAt: string | null;
|
|
30
|
-
agentId: string;
|
|
31
30
|
projectId: string;
|
|
32
31
|
tenantId: string;
|
|
32
|
+
agentId: string;
|
|
33
33
|
publicId: string;
|
|
34
34
|
keyHash: string;
|
|
35
35
|
keyPrefix: string;
|
|
@@ -44,9 +44,9 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
44
44
|
createdAt: string;
|
|
45
45
|
updatedAt: string;
|
|
46
46
|
expiresAt: string | null;
|
|
47
|
-
agentId: string;
|
|
48
47
|
projectId: string;
|
|
49
48
|
tenantId: string;
|
|
49
|
+
agentId: string;
|
|
50
50
|
publicId: string;
|
|
51
51
|
keyHash: string;
|
|
52
52
|
keyPrefix: string;
|
|
@@ -71,9 +71,9 @@ declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInse
|
|
|
71
71
|
createdAt: string;
|
|
72
72
|
updatedAt: string;
|
|
73
73
|
expiresAt: string | null;
|
|
74
|
-
agentId: string;
|
|
75
74
|
projectId: string;
|
|
76
75
|
tenantId: string;
|
|
76
|
+
agentId: string;
|
|
77
77
|
publicId: string;
|
|
78
78
|
keyHash: string;
|
|
79
79
|
keyPrefix: string;
|
|
@@ -11,9 +11,9 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
11
11
|
createdAt: string;
|
|
12
12
|
updatedAt: string;
|
|
13
13
|
description: string | null;
|
|
14
|
-
enabled: boolean;
|
|
15
14
|
projectId: string | null;
|
|
16
15
|
tenantId: string | null;
|
|
16
|
+
enabled: boolean;
|
|
17
17
|
prompt: string | null;
|
|
18
18
|
config: {
|
|
19
19
|
type: "web_client";
|
|
@@ -67,9 +67,9 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
67
67
|
createdAt: string;
|
|
68
68
|
updatedAt: string;
|
|
69
69
|
description: string | null;
|
|
70
|
-
enabled: boolean;
|
|
71
70
|
projectId: string | null;
|
|
72
71
|
tenantId: string | null;
|
|
72
|
+
enabled: boolean;
|
|
73
73
|
prompt: string | null;
|
|
74
74
|
config: {
|
|
75
75
|
type: "web_client";
|
|
@@ -25,10 +25,10 @@ declare const createConversation: (db: AgentsRunDatabaseClient) => (params: Conv
|
|
|
25
25
|
} | null;
|
|
26
26
|
userId: string | null;
|
|
27
27
|
metadata: ConversationMetadata | null;
|
|
28
|
-
agentId: string | null;
|
|
29
28
|
projectId: string;
|
|
30
29
|
tenantId: string;
|
|
31
30
|
title: string | null;
|
|
31
|
+
agentId: string | null;
|
|
32
32
|
activeSubAgentId: string;
|
|
33
33
|
lastContextResolution: string | null;
|
|
34
34
|
}>;
|
|
@@ -94,10 +94,10 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
94
94
|
} | null;
|
|
95
95
|
userId: string | null;
|
|
96
96
|
metadata: ConversationMetadata | null;
|
|
97
|
-
agentId: string | null;
|
|
98
97
|
projectId: string;
|
|
99
98
|
tenantId: string;
|
|
100
99
|
title: string | null;
|
|
100
|
+
agentId: string | null;
|
|
101
101
|
activeSubAgentId: string;
|
|
102
102
|
lastContextResolution: string | null;
|
|
103
103
|
} | undefined>;
|
|
@@ -130,10 +130,10 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
130
130
|
} | null;
|
|
131
131
|
userId: string | null;
|
|
132
132
|
metadata: ConversationMetadata | null;
|
|
133
|
-
agentId: string | null;
|
|
134
133
|
projectId: string;
|
|
135
134
|
tenantId: string;
|
|
136
135
|
title: string | null;
|
|
136
|
+
agentId: string | null;
|
|
137
137
|
activeSubAgentId: string;
|
|
138
138
|
lastContextResolution: string | null;
|
|
139
139
|
}>;
|
|
@@ -162,10 +162,10 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
162
162
|
} | null;
|
|
163
163
|
userId: string | null;
|
|
164
164
|
metadata: ConversationMetadata | null;
|
|
165
|
-
agentId: string | null;
|
|
166
165
|
projectId: string;
|
|
167
166
|
tenantId: string;
|
|
168
167
|
title: string | null;
|
|
168
|
+
agentId: string | null;
|
|
169
169
|
activeSubAgentId: string;
|
|
170
170
|
lastContextResolution: string | null;
|
|
171
171
|
} | undefined>;
|
|
@@ -15,9 +15,9 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
15
15
|
updatedAt: string;
|
|
16
16
|
metadata: MessageMetadata | null;
|
|
17
17
|
role: string;
|
|
18
|
+
content: MessageContent;
|
|
18
19
|
projectId: string;
|
|
19
20
|
tenantId: string;
|
|
20
|
-
content: MessageContent;
|
|
21
21
|
conversationId: string;
|
|
22
22
|
fromSubAgentId: string | null;
|
|
23
23
|
toSubAgentId: string | null;
|
|
@@ -149,9 +149,9 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
149
149
|
updatedAt: string;
|
|
150
150
|
metadata: MessageMetadata | null;
|
|
151
151
|
role: string;
|
|
152
|
+
content: MessageContent;
|
|
152
153
|
projectId: string;
|
|
153
154
|
tenantId: string;
|
|
154
|
-
content: MessageContent;
|
|
155
155
|
conversationId: string;
|
|
156
156
|
fromSubAgentId: string | null;
|
|
157
157
|
toSubAgentId: string | null;
|
|
@@ -202,9 +202,9 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
202
202
|
updatedAt: string;
|
|
203
203
|
metadata: MessageMetadata | null;
|
|
204
204
|
role: string;
|
|
205
|
+
content: MessageContent;
|
|
205
206
|
projectId: string;
|
|
206
207
|
tenantId: string;
|
|
207
|
-
content: MessageContent;
|
|
208
208
|
conversationId: string;
|
|
209
209
|
fromSubAgentId: string | null;
|
|
210
210
|
toSubAgentId: string | null;
|
|
@@ -2,7 +2,7 @@ import { AgentScopeConfig, ProjectScopeConfig } from "../../db/manage/scope-defi
|
|
|
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";
|
|
5
|
-
import { ScheduledTriggerInvocation, ScheduledTriggerInvocationInsert, ScheduledTriggerInvocationUpdate } from "../../types/entities.js";
|
|
5
|
+
import { LastRunSummary, ScheduledTriggerInvocation, ScheduledTriggerInvocationInsert, ScheduledTriggerInvocationUpdate } from "../../types/entities.js";
|
|
6
6
|
|
|
7
7
|
//#region src/data-access/runtime/scheduledTriggerInvocations.d.ts
|
|
8
8
|
/**
|
|
@@ -48,6 +48,7 @@ declare const listScheduledTriggerInvocationsPaginated: (db: AgentsRunDatabaseCl
|
|
|
48
48
|
conversationIds: string[] | null;
|
|
49
49
|
attemptNumber: number;
|
|
50
50
|
idempotencyKey: string;
|
|
51
|
+
runAsUserId: string | null;
|
|
51
52
|
createdAt: string;
|
|
52
53
|
agentId: string;
|
|
53
54
|
projectId: string;
|
|
@@ -160,9 +161,18 @@ declare const cancelPastPendingInvocationsForTrigger: (db: AgentsRunDatabaseClie
|
|
|
160
161
|
scopes: AgentScopeConfig;
|
|
161
162
|
scheduledTriggerId: string;
|
|
162
163
|
}) => Promise<number>;
|
|
164
|
+
type ScheduledTriggerRunInfo = {
|
|
165
|
+
lastRunAt: string | null;
|
|
166
|
+
lastRunStatus: 'completed' | 'failed' | null;
|
|
167
|
+
lastRunConversationIds: string[];
|
|
168
|
+
nextRunAt: string | null;
|
|
169
|
+
lastRunSummary: LastRunSummary | null;
|
|
170
|
+
};
|
|
163
171
|
/**
|
|
164
|
-
* Get run info for multiple scheduled triggers in a single query
|
|
165
|
-
*
|
|
172
|
+
* Get run info for multiple scheduled triggers in a single query.
|
|
173
|
+
* Groups invocations by (triggerId, scheduledFor) to support multi-user triggers.
|
|
174
|
+
* Excludes manual runs (manual-run-* and manual-rerun-* idempotency keys).
|
|
175
|
+
* Returns lastRunSummary with per-status counts for the most recent scheduled tick.
|
|
166
176
|
*/
|
|
167
177
|
declare const getScheduledTriggerRunInfoBatch: (db: AgentsRunDatabaseClient) => (params: {
|
|
168
178
|
scopes: Omit<AgentScopeConfig, "agentId">;
|
|
@@ -170,12 +180,7 @@ declare const getScheduledTriggerRunInfoBatch: (db: AgentsRunDatabaseClient) =>
|
|
|
170
180
|
agentId: string;
|
|
171
181
|
triggerId: string;
|
|
172
182
|
}>;
|
|
173
|
-
}) => Promise<Map<string,
|
|
174
|
-
lastRunAt: string | null;
|
|
175
|
-
lastRunStatus: "completed" | "failed" | null;
|
|
176
|
-
lastRunConversationIds: string[];
|
|
177
|
-
nextRunAt: string | null;
|
|
178
|
-
}>>;
|
|
183
|
+
}) => Promise<Map<string, ScheduledTriggerRunInfo>>;
|
|
179
184
|
/**
|
|
180
185
|
* List upcoming invocations across ALL triggers for an agent with pagination
|
|
181
186
|
* Used for the upcoming runs dashboard with full pagination support
|
|
@@ -202,6 +207,7 @@ declare const listUpcomingInvocationsForAgentPaginated: (db: AgentsRunDatabaseCl
|
|
|
202
207
|
conversationIds: string[] | null;
|
|
203
208
|
attemptNumber: number;
|
|
204
209
|
idempotencyKey: string;
|
|
210
|
+
runAsUserId: string | null;
|
|
205
211
|
createdAt: string;
|
|
206
212
|
agentId: string;
|
|
207
213
|
projectId: string;
|
|
@@ -241,6 +247,7 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
|
|
|
241
247
|
conversationIds: string[] | null;
|
|
242
248
|
attemptNumber: number;
|
|
243
249
|
idempotencyKey: string;
|
|
250
|
+
runAsUserId: string | null;
|
|
244
251
|
createdAt: string;
|
|
245
252
|
agentId: string;
|
|
246
253
|
projectId: string;
|
|
@@ -293,6 +300,7 @@ declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabase
|
|
|
293
300
|
conversationIds: string[] | null;
|
|
294
301
|
attemptNumber: number;
|
|
295
302
|
idempotencyKey: string;
|
|
303
|
+
runAsUserId: string | null;
|
|
296
304
|
createdAt: string;
|
|
297
305
|
agentId: string;
|
|
298
306
|
projectId: string;
|
|
@@ -300,4 +308,4 @@ declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabase
|
|
|
300
308
|
id: string;
|
|
301
309
|
}[]>;
|
|
302
310
|
//#endregion
|
|
303
|
-
export { addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
311
|
+
export { ScheduledTriggerRunInfo, addConversationIdToInvocation, cancelPastPendingInvocationsForTrigger, cancelPendingInvocationsForTrigger, createScheduledTriggerInvocation, deletePendingInvocationsForTrigger, getScheduledTriggerInvocationById, getScheduledTriggerInvocationByIdempotencyKey, getScheduledTriggerInvocationStatusSummary, getScheduledTriggerRunInfoBatch, listPendingScheduledTriggerInvocations, listProjectScheduledTriggerInvocationsPaginated, listScheduledTriggerInvocationsByTriggerId, listScheduledTriggerInvocationsPaginated, listUpcomingInvocationsForAgentPaginated, markScheduledTriggerInvocationCancelled, markScheduledTriggerInvocationCompleted, markScheduledTriggerInvocationFailed, markScheduledTriggerInvocationRunning, resetCancelledInvocationToPending, updateScheduledTriggerInvocationStatus };
|
|
@@ -147,33 +147,91 @@ const cancelPastPendingInvocationsForTrigger = (db) => async (params) => {
|
|
|
147
147
|
}).where(and(agentScopedWhere(scheduledTriggerInvocations, params.scopes), eq(scheduledTriggerInvocations.scheduledTriggerId, params.scheduledTriggerId), inArray(scheduledTriggerInvocations.status, ["pending", "running"]), lte(scheduledTriggerInvocations.scheduledFor, now))).returning()).length;
|
|
148
148
|
};
|
|
149
149
|
/**
|
|
150
|
-
* Get run info for multiple scheduled triggers in a single query
|
|
151
|
-
*
|
|
150
|
+
* Get run info for multiple scheduled triggers in a single query.
|
|
151
|
+
* Groups invocations by (triggerId, scheduledFor) to support multi-user triggers.
|
|
152
|
+
* Excludes manual runs (manual-run-* and manual-rerun-* idempotency keys).
|
|
153
|
+
* Returns lastRunSummary with per-status counts for the most recent scheduled tick.
|
|
152
154
|
*/
|
|
153
155
|
const getScheduledTriggerRunInfoBatch = (db) => async (params) => {
|
|
154
156
|
if (params.triggerIds.length === 0) return /* @__PURE__ */ new Map();
|
|
157
|
+
const triggerIdValues = params.triggerIds.map((t) => t.triggerId);
|
|
155
158
|
const allInvocations = await db.select({
|
|
156
159
|
scheduledTriggerId: scheduledTriggerInvocations.scheduledTriggerId,
|
|
157
160
|
status: scheduledTriggerInvocations.status,
|
|
158
161
|
scheduledFor: scheduledTriggerInvocations.scheduledFor,
|
|
159
162
|
completedAt: scheduledTriggerInvocations.completedAt,
|
|
160
|
-
conversationIds: scheduledTriggerInvocations.conversationIds
|
|
161
|
-
|
|
163
|
+
conversationIds: scheduledTriggerInvocations.conversationIds,
|
|
164
|
+
idempotencyKey: scheduledTriggerInvocations.idempotencyKey
|
|
165
|
+
}).from(scheduledTriggerInvocations).where(and(projectScopedWhere(scheduledTriggerInvocations, params.scopes), inArray(scheduledTriggerInvocations.scheduledTriggerId, triggerIdValues))).orderBy(desc(scheduledTriggerInvocations.scheduledFor));
|
|
162
166
|
const result = /* @__PURE__ */ new Map();
|
|
163
167
|
for (const trigger of params.triggerIds) result.set(trigger.triggerId, {
|
|
164
168
|
lastRunAt: null,
|
|
165
169
|
lastRunStatus: null,
|
|
166
170
|
lastRunConversationIds: [],
|
|
167
|
-
nextRunAt: null
|
|
171
|
+
nextRunAt: null,
|
|
172
|
+
lastRunSummary: null
|
|
168
173
|
});
|
|
174
|
+
const isManualRun = (key) => key.startsWith("manual-run-") || key.startsWith("manual-rerun-");
|
|
175
|
+
const tickMap = /* @__PURE__ */ new Map();
|
|
169
176
|
for (const inv of allInvocations) {
|
|
170
177
|
const triggerInfo = result.get(inv.scheduledTriggerId);
|
|
171
178
|
if (!triggerInfo) continue;
|
|
172
179
|
if (inv.status === "pending" && !triggerInfo.nextRunAt) triggerInfo.nextRunAt = inv.scheduledFor;
|
|
173
|
-
if ((inv.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
if (isManualRun(inv.idempotencyKey)) continue;
|
|
181
|
+
let triggerTicks = tickMap.get(inv.scheduledTriggerId);
|
|
182
|
+
if (!triggerTicks) {
|
|
183
|
+
triggerTicks = /* @__PURE__ */ new Map();
|
|
184
|
+
tickMap.set(inv.scheduledTriggerId, triggerTicks);
|
|
185
|
+
}
|
|
186
|
+
let tickInvocations = triggerTicks.get(inv.scheduledFor);
|
|
187
|
+
if (!tickInvocations) {
|
|
188
|
+
tickInvocations = [];
|
|
189
|
+
triggerTicks.set(inv.scheduledFor, tickInvocations);
|
|
190
|
+
}
|
|
191
|
+
tickInvocations.push({
|
|
192
|
+
status: inv.status,
|
|
193
|
+
completedAt: inv.completedAt,
|
|
194
|
+
conversationIds: inv.conversationIds
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
for (const [triggerId, triggerTicks] of tickMap) {
|
|
198
|
+
const triggerInfo = result.get(triggerId);
|
|
199
|
+
if (!triggerInfo) continue;
|
|
200
|
+
let bestScheduledFor = null;
|
|
201
|
+
let bestInvocations = null;
|
|
202
|
+
for (const [scheduledFor, invocations] of triggerTicks) {
|
|
203
|
+
if (!invocations.some((i) => i.status === "completed" || i.status === "failed")) continue;
|
|
204
|
+
if (!bestScheduledFor || scheduledFor > bestScheduledFor) {
|
|
205
|
+
bestScheduledFor = scheduledFor;
|
|
206
|
+
bestInvocations = invocations;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (bestInvocations) {
|
|
210
|
+
const summary = {
|
|
211
|
+
total: bestInvocations.length,
|
|
212
|
+
completed: 0,
|
|
213
|
+
failed: 0,
|
|
214
|
+
running: 0,
|
|
215
|
+
pending: 0
|
|
216
|
+
};
|
|
217
|
+
let maxCompletedAt = null;
|
|
218
|
+
for (const inv of bestInvocations) {
|
|
219
|
+
if (inv.status === "completed") summary.completed++;
|
|
220
|
+
else if (inv.status === "failed") summary.failed++;
|
|
221
|
+
else if (inv.status === "running") summary.running++;
|
|
222
|
+
else if (inv.status === "pending") summary.pending++;
|
|
223
|
+
if (inv.completedAt && (!maxCompletedAt || inv.completedAt > maxCompletedAt)) maxCompletedAt = inv.completedAt;
|
|
224
|
+
}
|
|
225
|
+
triggerInfo.lastRunAt = maxCompletedAt;
|
|
226
|
+
triggerInfo.lastRunSummary = summary;
|
|
227
|
+
if (summary.failed > 0) triggerInfo.lastRunStatus = "failed";
|
|
228
|
+
else if (summary.completed > 0) triggerInfo.lastRunStatus = "completed";
|
|
229
|
+
const allConvIds = [];
|
|
230
|
+
for (const inv of bestInvocations) {
|
|
231
|
+
const ids = inv.conversationIds;
|
|
232
|
+
if (ids) for (const id of ids) allConvIds.push(id);
|
|
233
|
+
}
|
|
234
|
+
triggerInfo.lastRunConversationIds = allConvIds;
|
|
177
235
|
}
|
|
178
236
|
}
|
|
179
237
|
return result;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data-access/runtime/scheduledTriggerUsers.d.ts
|
|
4
|
+
declare const getScheduledTriggerUsers: (db: AgentsRunDatabaseClient) => (params: {
|
|
5
|
+
tenantId: string;
|
|
6
|
+
scheduledTriggerId: string;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
tenantId: string;
|
|
9
|
+
scheduledTriggerId: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
}[]>;
|
|
13
|
+
declare const createScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (params: {
|
|
14
|
+
tenantId: string;
|
|
15
|
+
scheduledTriggerId: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
}) => Promise<{
|
|
18
|
+
createdAt: string;
|
|
19
|
+
userId: string;
|
|
20
|
+
tenantId: string;
|
|
21
|
+
scheduledTriggerId: string;
|
|
22
|
+
}>;
|
|
23
|
+
declare const deleteScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (params: {
|
|
24
|
+
tenantId: string;
|
|
25
|
+
scheduledTriggerId: string;
|
|
26
|
+
userId: string;
|
|
27
|
+
}) => Promise<void>;
|
|
28
|
+
declare const setScheduledTriggerUsers: (db: AgentsRunDatabaseClient) => (params: {
|
|
29
|
+
tenantId: string;
|
|
30
|
+
scheduledTriggerId: string;
|
|
31
|
+
userIds: string[];
|
|
32
|
+
}) => Promise<void>;
|
|
33
|
+
declare const getScheduledTriggerUserCount: (db: AgentsRunDatabaseClient) => (params: {
|
|
34
|
+
tenantId: string;
|
|
35
|
+
scheduledTriggerId: string;
|
|
36
|
+
}) => Promise<number>;
|
|
37
|
+
declare const getTriggerIdsWithUser: (db: AgentsRunDatabaseClient) => (params: {
|
|
38
|
+
tenantId: string;
|
|
39
|
+
projectId: string;
|
|
40
|
+
userId: string;
|
|
41
|
+
}) => Promise<{
|
|
42
|
+
id: string;
|
|
43
|
+
}[]>;
|
|
44
|
+
declare const removeUserFromProjectScheduledTriggers: (db: AgentsRunDatabaseClient) => (params: {
|
|
45
|
+
tenantId: string;
|
|
46
|
+
projectId: string;
|
|
47
|
+
userId: string;
|
|
48
|
+
}) => Promise<void>;
|
|
49
|
+
declare const getScheduledTriggerUsersBatch: (db: AgentsRunDatabaseClient) => (params: {
|
|
50
|
+
tenantId: string;
|
|
51
|
+
scheduledTriggerIds: string[];
|
|
52
|
+
}) => Promise<Map<string, string[]>>;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { createScheduledTriggerUser, deleteScheduledTriggerUser, getScheduledTriggerUserCount, getScheduledTriggerUsers, getScheduledTriggerUsersBatch, getTriggerIdsWithUser, removeUserFromProjectScheduledTriggers, setScheduledTriggerUsers };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { scheduledTriggerUsers, scheduledTriggers } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { and, asc, count, eq, inArray } from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
//#region src/data-access/runtime/scheduledTriggerUsers.ts
|
|
5
|
+
const getScheduledTriggerUsers = (db) => async (params) => {
|
|
6
|
+
return await db.select().from(scheduledTriggerUsers).where(and(eq(scheduledTriggerUsers.tenantId, params.tenantId), eq(scheduledTriggerUsers.scheduledTriggerId, params.scheduledTriggerId))).orderBy(asc(scheduledTriggerUsers.createdAt));
|
|
7
|
+
};
|
|
8
|
+
const createScheduledTriggerUser = (db) => async (params) => {
|
|
9
|
+
return (await db.insert(scheduledTriggerUsers).values({
|
|
10
|
+
tenantId: params.tenantId,
|
|
11
|
+
scheduledTriggerId: params.scheduledTriggerId,
|
|
12
|
+
userId: params.userId
|
|
13
|
+
}).onConflictDoNothing().returning())[0];
|
|
14
|
+
};
|
|
15
|
+
const deleteScheduledTriggerUser = (db) => async (params) => {
|
|
16
|
+
await db.delete(scheduledTriggerUsers).where(and(eq(scheduledTriggerUsers.tenantId, params.tenantId), eq(scheduledTriggerUsers.scheduledTriggerId, params.scheduledTriggerId), eq(scheduledTriggerUsers.userId, params.userId)));
|
|
17
|
+
};
|
|
18
|
+
const setScheduledTriggerUsers = (db) => async (params) => {
|
|
19
|
+
await db.transaction(async (tx) => {
|
|
20
|
+
await tx.delete(scheduledTriggerUsers).where(and(eq(scheduledTriggerUsers.tenantId, params.tenantId), eq(scheduledTriggerUsers.scheduledTriggerId, params.scheduledTriggerId)));
|
|
21
|
+
if (params.userIds.length > 0) await tx.insert(scheduledTriggerUsers).values(params.userIds.map((userId) => ({
|
|
22
|
+
tenantId: params.tenantId,
|
|
23
|
+
scheduledTriggerId: params.scheduledTriggerId,
|
|
24
|
+
userId
|
|
25
|
+
})));
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const getScheduledTriggerUserCount = (db) => async (params) => {
|
|
29
|
+
return (await db.select({ count: count() }).from(scheduledTriggerUsers).where(and(eq(scheduledTriggerUsers.tenantId, params.tenantId), eq(scheduledTriggerUsers.scheduledTriggerId, params.scheduledTriggerId))))[0]?.count ?? 0;
|
|
30
|
+
};
|
|
31
|
+
const getTriggerIdsWithUser = (db) => async (params) => {
|
|
32
|
+
return db.select({ id: scheduledTriggers.id }).from(scheduledTriggers).innerJoin(scheduledTriggerUsers, and(eq(scheduledTriggerUsers.tenantId, scheduledTriggers.tenantId), eq(scheduledTriggerUsers.scheduledTriggerId, scheduledTriggers.id))).where(and(eq(scheduledTriggers.tenantId, params.tenantId), eq(scheduledTriggers.projectId, params.projectId), eq(scheduledTriggerUsers.userId, params.userId)));
|
|
33
|
+
};
|
|
34
|
+
const removeUserFromProjectScheduledTriggers = (db) => async (params) => {
|
|
35
|
+
await db.transaction(async (tx) => {
|
|
36
|
+
const triggerIdsWithUser = await getTriggerIdsWithUser(tx)(params);
|
|
37
|
+
if (triggerIdsWithUser.length === 0) return;
|
|
38
|
+
const triggerIds = triggerIdsWithUser.map((t) => t.id);
|
|
39
|
+
await tx.delete(scheduledTriggerUsers).where(and(eq(scheduledTriggerUsers.tenantId, params.tenantId), inArray(scheduledTriggerUsers.scheduledTriggerId, triggerIds), eq(scheduledTriggerUsers.userId, params.userId)));
|
|
40
|
+
const triggersWithRemainingUsers = await tx.select({ triggerId: scheduledTriggerUsers.scheduledTriggerId }).from(scheduledTriggerUsers).where(and(eq(scheduledTriggerUsers.tenantId, params.tenantId), inArray(scheduledTriggerUsers.scheduledTriggerId, triggerIds))).groupBy(scheduledTriggerUsers.scheduledTriggerId);
|
|
41
|
+
const triggerIdsWithRemainingUsers = new Set(triggersWithRemainingUsers.map((r) => r.triggerId));
|
|
42
|
+
const emptyTriggerIds = triggerIds.filter((id) => !triggerIdsWithRemainingUsers.has(id));
|
|
43
|
+
if (emptyTriggerIds.length > 0) await tx.update(scheduledTriggers).set({
|
|
44
|
+
enabled: false,
|
|
45
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
46
|
+
}).where(and(eq(scheduledTriggers.tenantId, params.tenantId), inArray(scheduledTriggers.id, emptyTriggerIds), eq(scheduledTriggers.enabled, true)));
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const getScheduledTriggerUsersBatch = (db) => async (params) => {
|
|
50
|
+
if (params.scheduledTriggerIds.length === 0) return /* @__PURE__ */ new Map();
|
|
51
|
+
const rows = await db.select().from(scheduledTriggerUsers).where(and(eq(scheduledTriggerUsers.tenantId, params.tenantId), inArray(scheduledTriggerUsers.scheduledTriggerId, params.scheduledTriggerIds))).orderBy(asc(scheduledTriggerUsers.createdAt));
|
|
52
|
+
const result = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const id of params.scheduledTriggerIds) result.set(id, []);
|
|
54
|
+
for (const row of rows) {
|
|
55
|
+
const users = result.get(row.scheduledTriggerId);
|
|
56
|
+
if (users) users.push(row.userId);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { createScheduledTriggerUser, deleteScheduledTriggerUser, getScheduledTriggerUserCount, getScheduledTriggerUsers, getScheduledTriggerUsersBatch, getTriggerIdsWithUser, removeUserFromProjectScheduledTriggers, setScheduledTriggerUsers };
|
|
@@ -17,9 +17,9 @@ declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert)
|
|
|
17
17
|
} | null;
|
|
18
18
|
metadata: TaskMetadataConfig | null;
|
|
19
19
|
status: string;
|
|
20
|
-
agentId: string;
|
|
21
20
|
projectId: string;
|
|
22
21
|
tenantId: string;
|
|
22
|
+
agentId: string;
|
|
23
23
|
subAgentId: string;
|
|
24
24
|
contextId: string;
|
|
25
25
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as drizzle_orm_pg_core943 from "drizzle-orm/pg-core";
|
|
2
2
|
|
|
3
3
|
//#region src/db/manage/dolt-safe-jsonb.d.ts
|
|
4
4
|
declare function encodeBackslashes(value: unknown): unknown;
|
|
@@ -7,6 +7,6 @@ declare function decodeBackslashes(value: unknown): unknown;
|
|
|
7
7
|
* Drop-in replacement for drizzle-orm's `jsonb()`.
|
|
8
8
|
* Encodes backslashes on write and decodes on read to work around the Doltgres bug.
|
|
9
9
|
*/
|
|
10
|
-
declare function jsonb(name: string): ReturnType<typeof
|
|
10
|
+
declare function jsonb(name: string): ReturnType<typeof drizzle_orm_pg_core943.jsonb>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { decodeBackslashes, encodeBackslashes, jsonb };
|