@inkeep/agents-core 0.0.0-dev-20260120175022 → 0.0.0-dev-20260120221941

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.
Files changed (65) hide show
  1. package/dist/auth/auth-schema.d.ts +82 -82
  2. package/dist/auth/auth-validation-schemas.d.ts +146 -146
  3. package/dist/auth/auth.d.ts +53 -53
  4. package/dist/auth/permissions.d.ts +13 -13
  5. package/dist/client-exports.d.ts +6 -2
  6. package/dist/client-exports.js +2 -2
  7. package/dist/constants/otel-attributes.d.ts +3 -0
  8. package/dist/constants/otel-attributes.js +3 -0
  9. package/dist/data-access/index.d.ts +3 -1
  10. package/dist/data-access/index.js +3 -1
  11. package/dist/data-access/manage/agentFull.js +114 -0
  12. package/dist/data-access/manage/agents.d.ts +25 -25
  13. package/dist/data-access/manage/agents.js +27 -0
  14. package/dist/data-access/manage/artifactComponents.d.ts +14 -14
  15. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  16. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  17. package/dist/data-access/manage/functionTools.d.ts +14 -14
  18. package/dist/data-access/manage/projectFull.d.ts +4 -0
  19. package/dist/data-access/manage/projectFull.js +31 -8
  20. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
  21. package/dist/data-access/manage/subAgentRelations.d.ts +24 -24
  22. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
  23. package/dist/data-access/manage/subAgents.d.ts +15 -15
  24. package/dist/data-access/manage/tools.d.ts +33 -33
  25. package/dist/data-access/manage/triggers.d.ts +84 -0
  26. package/dist/data-access/manage/triggers.js +95 -0
  27. package/dist/data-access/runtime/apiKeys.d.ts +16 -16
  28. package/dist/data-access/runtime/conversations.d.ts +23 -23
  29. package/dist/data-access/runtime/evalRuns.d.ts +2 -2
  30. package/dist/data-access/runtime/evalRuns.js +11 -1
  31. package/dist/data-access/runtime/messages.d.ts +21 -21
  32. package/dist/data-access/runtime/tasks.d.ts +7 -7
  33. package/dist/data-access/runtime/triggerInvocations.d.ts +62 -0
  34. package/dist/data-access/runtime/triggerInvocations.js +54 -0
  35. package/dist/db/manage/manage-schema.d.ts +553 -288
  36. package/dist/db/manage/manage-schema.js +31 -2
  37. package/dist/db/runtime/runtime-schema.d.ts +370 -155
  38. package/dist/db/runtime/runtime-schema.js +33 -3
  39. package/dist/dolt/branch.d.ts +55 -1
  40. package/dist/dolt/branch.js +85 -1
  41. package/dist/dolt/index.d.ts +2 -2
  42. package/dist/dolt/index.js +2 -2
  43. package/dist/index.d.ts +10 -6
  44. package/dist/index.js +10 -6
  45. package/dist/types/entities.d.ts +14 -2
  46. package/dist/types/index.d.ts +2 -2
  47. package/dist/utils/index.d.ts +3 -1
  48. package/dist/utils/index.js +3 -1
  49. package/dist/utils/template-interpolation.d.ts +22 -0
  50. package/dist/utils/template-interpolation.js +62 -0
  51. package/dist/utils/trigger-auth.d.ts +32 -0
  52. package/dist/utils/trigger-auth.js +130 -0
  53. package/dist/validation/dolt-schemas.d.ts +1 -1
  54. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  55. package/dist/validation/index.d.ts +2 -2
  56. package/dist/validation/index.js +2 -2
  57. package/dist/validation/schemas.d.ts +3620 -1382
  58. package/dist/validation/schemas.js +87 -4
  59. package/drizzle/manage/0001_broken_wendell_vaughn.sql +19 -0
  60. package/drizzle/manage/meta/0001_snapshot.json +3115 -0
  61. package/drizzle/manage/meta/_journal.json +7 -0
  62. package/drizzle/runtime/0009_freezing_leo.sql +17 -0
  63. package/drizzle/runtime/meta/0009_snapshot.json +2397 -0
  64. package/drizzle/runtime/meta/_journal.json +7 -0
  65. package/package.json +1 -1
@@ -0,0 +1,95 @@
1
+ import { triggers } from "../../db/manage/manage-schema.js";
2
+ import { getProjectBranchName, withBranch } from "../../dolt/branch.js";
3
+ import { and, count, desc, eq } from "drizzle-orm";
4
+
5
+ //#region src/data-access/manage/triggers.ts
6
+ /**
7
+ * Get a trigger by ID (agent-scoped)
8
+ * Uses withBranch to checkout the project's main branch and query using Drizzle ORM,
9
+ * which handles column name mapping automatically.
10
+ */
11
+ const getTriggerById = (db) => async (params) => {
12
+ const { scopes, triggerId, useBranchScope = true } = params;
13
+ if (useBranchScope) {
14
+ const branchName = getProjectBranchName(scopes.tenantId, scopes.projectId);
15
+ try {
16
+ return await withBranch(db)({
17
+ branchName,
18
+ callback: async (txDb) => {
19
+ return await txDb.query.triggers.findFirst({ where: and(eq(triggers.tenantId, scopes.tenantId), eq(triggers.projectId, scopes.projectId), eq(triggers.agentId, scopes.agentId), eq(triggers.id, triggerId)) });
20
+ }
21
+ });
22
+ } catch {}
23
+ }
24
+ return await db.query.triggers.findFirst({ where: and(eq(triggers.tenantId, scopes.tenantId), eq(triggers.projectId, scopes.projectId), eq(triggers.agentId, scopes.agentId), eq(triggers.id, triggerId)) });
25
+ };
26
+ /**
27
+ * List all triggers for an agent
28
+ */
29
+ const listTriggers = (db) => async (params) => {
30
+ return await db.query.triggers.findMany({ where: and(eq(triggers.tenantId, params.scopes.tenantId), eq(triggers.projectId, params.scopes.projectId), eq(triggers.agentId, params.scopes.agentId)) });
31
+ };
32
+ /**
33
+ * List triggers for an agent with pagination
34
+ */
35
+ const listTriggersPaginated = (db) => async (params) => {
36
+ const page = params.pagination?.page || 1;
37
+ const limit = Math.min(params.pagination?.limit || 10, 100);
38
+ const offset = (page - 1) * limit;
39
+ const whereClause = and(eq(triggers.tenantId, params.scopes.tenantId), eq(triggers.projectId, params.scopes.projectId), eq(triggers.agentId, params.scopes.agentId));
40
+ const [data, totalResult] = await Promise.all([db.select().from(triggers).where(whereClause).limit(limit).offset(offset).orderBy(desc(triggers.createdAt)), db.select({ count: count() }).from(triggers).where(whereClause)]);
41
+ const total = totalResult[0]?.count || 0;
42
+ return {
43
+ data,
44
+ pagination: {
45
+ page,
46
+ limit,
47
+ total,
48
+ pages: Math.ceil(total / limit)
49
+ }
50
+ };
51
+ };
52
+ /**
53
+ * Create a new trigger (agent-scoped)
54
+ */
55
+ const createTrigger = (db) => async (params) => {
56
+ return (await db.insert(triggers).values(params).returning())[0];
57
+ };
58
+ /**
59
+ * Update a trigger (agent-scoped)
60
+ */
61
+ const updateTrigger = (db) => async (params) => {
62
+ const updateData = {
63
+ ...params.data,
64
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
65
+ };
66
+ return (await db.update(triggers).set(updateData).where(and(eq(triggers.tenantId, params.scopes.tenantId), eq(triggers.projectId, params.scopes.projectId), eq(triggers.agentId, params.scopes.agentId), eq(triggers.id, params.triggerId))).returning())[0];
67
+ };
68
+ /**
69
+ * Delete a trigger (agent-scoped)
70
+ */
71
+ const deleteTrigger = (db) => async (params) => {
72
+ await db.delete(triggers).where(and(eq(triggers.tenantId, params.scopes.tenantId), eq(triggers.projectId, params.scopes.projectId), eq(triggers.agentId, params.scopes.agentId), eq(triggers.id, params.triggerId)));
73
+ };
74
+ /**
75
+ * Upsert a trigger (create or update based on existence)
76
+ */
77
+ const upsertTrigger = (db) => async (params) => {
78
+ const { scopes, data } = params;
79
+ if (await db.query.triggers.findFirst({ where: and(eq(triggers.tenantId, scopes.tenantId), eq(triggers.projectId, scopes.projectId), eq(triggers.agentId, scopes.agentId), eq(triggers.id, data.id)) })) {
80
+ const updateData = {
81
+ ...data,
82
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
83
+ };
84
+ return (await db.update(triggers).set(updateData).where(and(eq(triggers.tenantId, scopes.tenantId), eq(triggers.projectId, scopes.projectId), eq(triggers.agentId, scopes.agentId), eq(triggers.id, data.id))).returning())[0];
85
+ }
86
+ return (await db.insert(triggers).values({
87
+ ...data,
88
+ tenantId: scopes.tenantId,
89
+ projectId: scopes.projectId,
90
+ agentId: scopes.agentId
91
+ }).returning())[0];
92
+ };
93
+
94
+ //#endregion
95
+ export { createTrigger, deleteTrigger, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
@@ -7,28 +7,28 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
7
7
  scopes: ProjectScopeConfig;
8
8
  id: string;
9
9
  }) => Promise<{
10
+ tenantId: string;
11
+ projectId: string;
10
12
  id: string;
11
- name: string | null;
12
13
  createdAt: string;
14
+ name: string | null;
13
15
  updatedAt: string;
14
- projectId: string;
15
- tenantId: string;
16
- agentId: string;
17
16
  expiresAt: string | null;
17
+ agentId: string;
18
18
  publicId: string;
19
19
  keyHash: string;
20
20
  keyPrefix: string;
21
21
  lastUsedAt: string | null;
22
22
  } | undefined>;
23
23
  declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
24
+ tenantId: string;
25
+ projectId: string;
24
26
  id: string;
25
- name: string | null;
26
27
  createdAt: string;
28
+ name: string | null;
27
29
  updatedAt: string;
28
- projectId: string;
29
- tenantId: string;
30
- agentId: string;
31
30
  expiresAt: string | null;
31
+ agentId: string;
32
32
  publicId: string;
33
33
  keyHash: string;
34
34
  keyPrefix: string;
@@ -38,14 +38,14 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
38
38
  scopes: ProjectScopeConfig;
39
39
  agentId?: string;
40
40
  }) => Promise<{
41
+ tenantId: string;
42
+ projectId: string;
41
43
  id: string;
42
- name: string | null;
43
44
  createdAt: string;
45
+ name: string | null;
44
46
  updatedAt: string;
45
- projectId: string;
46
- tenantId: string;
47
- agentId: string;
48
47
  expiresAt: string | null;
48
+ agentId: string;
49
49
  publicId: string;
50
50
  keyHash: string;
51
51
  keyPrefix: string;
@@ -65,14 +65,14 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
65
65
  };
66
66
  }>;
67
67
  declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
68
+ tenantId: string;
69
+ projectId: string;
68
70
  id: string;
69
- name: string | null;
70
71
  createdAt: string;
72
+ name: string | null;
71
73
  updatedAt: string;
72
- projectId: string;
73
- tenantId: string;
74
- agentId: string;
75
74
  expiresAt: string | null;
75
+ agentId: string;
76
76
  publicId: string;
77
77
  keyHash: string;
78
78
  keyPrefix: string;
@@ -15,20 +15,20 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
15
15
  total: number;
16
16
  }>;
17
17
  declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
18
+ tenantId: string;
19
+ projectId: string;
18
20
  id: string;
19
21
  createdAt: string;
20
22
  updatedAt: string;
21
- projectId: string;
22
- tenantId: string;
23
23
  title: string | null;
24
- userId: string | null;
25
24
  metadata: ConversationMetadata | null;
26
- agentId: string | null;
27
25
  ref: {
28
- type: "tag" | "commit" | "branch";
26
+ type: "commit" | "tag" | "branch";
29
27
  name: string;
30
28
  hash: string;
31
29
  } | null;
30
+ userId: string | null;
31
+ agentId: string | null;
32
32
  activeSubAgentId: string;
33
33
  lastContextResolution: string | null;
34
34
  }>;
@@ -43,7 +43,7 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
43
43
  agentId: string | null;
44
44
  activeSubAgentId: string;
45
45
  ref: {
46
- type: "tag" | "commit" | "branch";
46
+ type: "commit" | "tag" | "branch";
47
47
  name: string;
48
48
  hash: string;
49
49
  } | null;
@@ -69,7 +69,7 @@ declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) =>
69
69
  agentId: string | null;
70
70
  activeSubAgentId: string;
71
71
  ref: {
72
- type: "tag" | "commit" | "branch";
72
+ type: "commit" | "tag" | "branch";
73
73
  name: string;
74
74
  hash: string;
75
75
  } | null;
@@ -84,20 +84,20 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
84
84
  scopes: ProjectScopeConfig;
85
85
  conversationId: string;
86
86
  }) => Promise<{
87
+ tenantId: string;
88
+ projectId: string;
87
89
  id: string;
88
90
  createdAt: string;
89
91
  updatedAt: string;
90
- projectId: string;
91
- tenantId: string;
92
92
  title: string | null;
93
- userId: string | null;
94
93
  metadata: ConversationMetadata | null;
95
- agentId: string | null;
96
94
  ref: {
97
- type: "tag" | "commit" | "branch";
95
+ type: "commit" | "tag" | "branch";
98
96
  name: string;
99
97
  hash: string;
100
98
  } | null;
99
+ userId: string | null;
100
+ agentId: string | null;
101
101
  activeSubAgentId: string;
102
102
  lastContextResolution: string | null;
103
103
  } | undefined>;
@@ -107,7 +107,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
107
107
  tenantId: string;
108
108
  id: string;
109
109
  ref: {
110
- type: "tag" | "commit" | "branch";
110
+ type: "commit" | "tag" | "branch";
111
111
  name: string;
112
112
  hash: string;
113
113
  };
@@ -120,20 +120,20 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
120
120
  metadata?: ConversationMetadata | null | undefined;
121
121
  contextConfigId?: string | undefined;
122
122
  } | {
123
+ tenantId: string;
124
+ projectId: string;
123
125
  id: string;
124
126
  createdAt: string;
125
127
  updatedAt: string;
126
- projectId: string;
127
- tenantId: string;
128
128
  title: string | null;
129
- userId: string | null;
130
129
  metadata: ConversationMetadata | null;
131
- agentId: string | null;
132
130
  ref: {
133
- type: "tag" | "commit" | "branch";
131
+ type: "commit" | "tag" | "branch";
134
132
  name: string;
135
133
  hash: string;
136
134
  } | null;
135
+ userId: string | null;
136
+ agentId: string | null;
137
137
  activeSubAgentId: string;
138
138
  lastContextResolution: string | null;
139
139
  }>;
@@ -152,20 +152,20 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
152
152
  scopes: ProjectScopeConfig;
153
153
  conversationId: string;
154
154
  }) => Promise<{
155
+ tenantId: string;
156
+ projectId: string;
155
157
  id: string;
156
158
  createdAt: string;
157
159
  updatedAt: string;
158
- projectId: string;
159
- tenantId: string;
160
160
  title: string | null;
161
- userId: string | null;
162
161
  metadata: ConversationMetadata | null;
163
- agentId: string | null;
164
162
  ref: {
165
- type: "tag" | "commit" | "branch";
163
+ type: "commit" | "tag" | "branch";
166
164
  name: string;
167
165
  hash: string;
168
166
  } | null;
167
+ userId: string | null;
168
+ agentId: string | null;
169
169
  activeSubAgentId: string;
170
170
  lastContextResolution: string | null;
171
171
  } | undefined>;
@@ -1,4 +1,4 @@
1
- import { EvaluationJobFilterCriteria, ProjectScopeConfig } from "../../types/utility.js";
1
+ import { EvaluationJobFilterCriteria, Filter, ProjectScopeConfig } from "../../types/utility.js";
2
2
  import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
3
3
  import { ConversationSelect, DatasetRunConversationRelationInsert, DatasetRunConversationRelationSelect, DatasetRunInsert, DatasetRunSelect, EvaluationResultInsert, EvaluationResultSelect, EvaluationResultUpdate, EvaluationRunInsert, EvaluationRunSelect, EvaluationRunUpdate } from "../../types/entities.js";
4
4
 
@@ -114,7 +114,7 @@ declare const deleteEvaluationResultsByRun: (db: AgentsRunDatabaseClient) => (pa
114
114
  */
115
115
  declare const filterConversationsForJob: (db: AgentsRunDatabaseClient) => (params: {
116
116
  scopes: ProjectScopeConfig;
117
- jobFilters: EvaluationJobFilterCriteria | null | undefined;
117
+ jobFilters: Filter<EvaluationJobFilterCriteria> | null | undefined;
118
118
  }) => Promise<ConversationSelect[]>;
119
119
  //#endregion
120
120
  export { createDatasetRun, createDatasetRunConversationRelation, createDatasetRunConversationRelations, createEvaluationResult, createEvaluationResults, createEvaluationRun, deleteDatasetRun, deleteDatasetRunConversationRelation, deleteDatasetRunConversationRelationsByRun, deleteEvaluationResult, deleteEvaluationResultsByRun, deleteEvaluationRun, filterConversationsForJob, getDatasetRunById, getDatasetRunConversationRelationByConversation, getDatasetRunConversationRelations, getEvaluationResultById, getEvaluationRunById, getEvaluationRunByJobConfigId, listDatasetRuns, listDatasetRunsByConfig, listEvaluationResults, listEvaluationResultsByConversation, listEvaluationResultsByRun, listEvaluationRuns, listEvaluationRunsByJobConfigId, updateEvaluationResult, updateEvaluationRun };
@@ -126,10 +126,20 @@ const deleteEvaluationResultsByRun = (db) => async (params) => {
126
126
  return (await db.delete(evaluationResult).where(and(eq(evaluationResult.tenantId, params.scopes.tenantId), eq(evaluationResult.projectId, params.scopes.projectId), eq(evaluationResult.evaluationRunId, params.scopes.evaluationRunId))).returning()).length;
127
127
  };
128
128
  /**
129
+ * Helper to extract plain filter criteria from a Filter wrapper.
130
+ * Currently only handles plain objects - and/or combinators are not yet supported.
131
+ */
132
+ function extractPlainFilterCriteria(filter) {
133
+ if (!filter) return null;
134
+ if ("and" in filter || "or" in filter) return null;
135
+ return filter;
136
+ }
137
+ /**
129
138
  * Filter conversations based on evaluation job filter criteria
130
139
  */
131
140
  const filterConversationsForJob = (db) => async (params) => {
132
- const { scopes, jobFilters } = params;
141
+ const { scopes, jobFilters: rawJobFilters } = params;
142
+ const jobFilters = extractPlainFilterCriteria(rawJobFilters);
133
143
  const { tenantId, projectId } = scopes;
134
144
  const whereConditions = [eq(conversations.tenantId, tenantId), eq(conversations.projectId, projectId)];
135
145
  if (jobFilters?.conversationIds && Array.isArray(jobFilters.conversationIds) && jobFilters.conversationIds.length > 0) whereConditions.push(inArray(conversations.id, jobFilters.conversationIds));
@@ -9,26 +9,26 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
9
9
  scopes: ProjectScopeConfig;
10
10
  messageId: string;
11
11
  }) => Promise<{
12
+ tenantId: string;
13
+ projectId: string;
12
14
  id: string;
13
15
  createdAt: string;
14
16
  updatedAt: string;
15
- projectId: string;
16
- tenantId: string;
17
17
  metadata: MessageMetadata | null;
18
18
  content: MessageContent;
19
- role: string;
20
- taskId: string | null;
21
- visibility: string;
22
- conversationId: string;
23
19
  fromSubAgentId: string | null;
24
20
  toSubAgentId: string | null;
25
21
  fromExternalAgentId: string | null;
26
22
  toExternalAgentId: string | null;
23
+ taskId: string | null;
24
+ a2aTaskId: string | null;
25
+ role: string;
26
+ conversationId: string;
27
27
  fromTeamAgentId: string | null;
28
28
  toTeamAgentId: string | null;
29
+ visibility: string;
29
30
  messageType: string;
30
31
  parentMessageId: string | null;
31
- a2aTaskId: string | null;
32
32
  a2aSessionId: string | null;
33
33
  } | undefined>;
34
34
  declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
@@ -140,26 +140,26 @@ declare const getVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
140
140
  id: string;
141
141
  }[]>;
142
142
  declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageInsert) => Promise<{
143
+ tenantId: string;
144
+ projectId: string;
143
145
  id: string;
144
146
  createdAt: string;
145
147
  updatedAt: string;
146
- projectId: string;
147
- tenantId: string;
148
148
  metadata: MessageMetadata | null;
149
149
  content: MessageContent;
150
- role: string;
151
- taskId: string | null;
152
- visibility: string;
153
- conversationId: string;
154
150
  fromSubAgentId: string | null;
155
151
  toSubAgentId: string | null;
156
152
  fromExternalAgentId: string | null;
157
153
  toExternalAgentId: string | null;
154
+ taskId: string | null;
155
+ a2aTaskId: string | null;
156
+ role: string;
157
+ conversationId: string;
158
158
  fromTeamAgentId: string | null;
159
159
  toTeamAgentId: string | null;
160
+ visibility: string;
160
161
  messageType: string;
161
162
  parentMessageId: string | null;
162
- a2aTaskId: string | null;
163
163
  a2aSessionId: string | null;
164
164
  }>;
165
165
  declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
@@ -193,26 +193,26 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
193
193
  scopes: ProjectScopeConfig;
194
194
  messageId: string;
195
195
  }) => Promise<{
196
+ tenantId: string;
197
+ projectId: string;
196
198
  id: string;
197
199
  createdAt: string;
198
200
  updatedAt: string;
199
- projectId: string;
200
- tenantId: string;
201
201
  metadata: MessageMetadata | null;
202
202
  content: MessageContent;
203
- role: string;
204
- taskId: string | null;
205
- visibility: string;
206
- conversationId: string;
207
203
  fromSubAgentId: string | null;
208
204
  toSubAgentId: string | null;
209
205
  fromExternalAgentId: string | null;
210
206
  toExternalAgentId: string | null;
207
+ taskId: string | null;
208
+ a2aTaskId: string | null;
209
+ role: string;
210
+ conversationId: string;
211
211
  fromTeamAgentId: string | null;
212
212
  toTeamAgentId: string | null;
213
+ visibility: string;
213
214
  messageType: string;
214
215
  parentMessageId: string | null;
215
- a2aTaskId: string | null;
216
216
  a2aSessionId: string | null;
217
217
  }>;
218
218
  declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
@@ -6,21 +6,21 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
6
6
 
7
7
  //#region src/data-access/runtime/tasks.d.ts
8
8
  declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
9
+ tenantId: string;
10
+ projectId: string;
9
11
  id: string;
10
12
  createdAt: string;
11
13
  updatedAt: string;
12
- projectId: string;
13
- tenantId: string;
14
14
  metadata: TaskMetadataConfig | null;
15
- agentId: string;
15
+ subAgentId: string;
16
16
  ref: {
17
- type: "tag" | "commit" | "branch";
17
+ type: "commit" | "tag" | "branch";
18
18
  name: string;
19
19
  hash: string;
20
20
  } | null;
21
21
  status: string;
22
+ agentId: string;
22
23
  contextId: string;
23
- subAgentId: string;
24
24
  }>;
25
25
  declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
26
26
  id: string;
@@ -36,14 +36,14 @@ declare const updateTask: (db: AgentsRunDatabaseClient) => (params: {
36
36
  updatedAt: string;
37
37
  contextId: string;
38
38
  ref: {
39
- type: "tag" | "commit" | "branch";
39
+ type: "commit" | "tag" | "branch";
40
40
  name: string;
41
41
  hash: string;
42
42
  } | null;
43
43
  status: string;
44
44
  metadata: TaskMetadataConfig | null;
45
- agentId: string;
46
45
  subAgentId: string;
46
+ agentId: string;
47
47
  projectId: string;
48
48
  tenantId: string;
49
49
  id: string;
@@ -0,0 +1,62 @@
1
+ import { AgentScopeConfig, PaginationConfig } from "../../types/utility.js";
2
+ import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
3
+ import { TriggerInvocationInsert, TriggerInvocationSelect, TriggerInvocationUpdate } from "../../types/entities.js";
4
+
5
+ //#region src/data-access/runtime/triggerInvocations.d.ts
6
+
7
+ /**
8
+ * Get a trigger invocation by ID (agent-scoped)
9
+ */
10
+ declare const getTriggerInvocationById: (db: AgentsRunDatabaseClient) => (params: {
11
+ scopes: AgentScopeConfig;
12
+ triggerId: string;
13
+ invocationId: string;
14
+ }) => Promise<TriggerInvocationSelect | undefined>;
15
+ /**
16
+ * List trigger invocations with optional filtering (agent-scoped)
17
+ */
18
+ declare const listTriggerInvocationsPaginated: (db: AgentsRunDatabaseClient) => (params: {
19
+ scopes: AgentScopeConfig;
20
+ triggerId: string;
21
+ pagination?: PaginationConfig;
22
+ filters?: {
23
+ status?: "pending" | "success" | "failed";
24
+ from?: string;
25
+ to?: string;
26
+ };
27
+ }) => Promise<{
28
+ data: {
29
+ triggerId: string;
30
+ conversationId: string | null;
31
+ status: string;
32
+ requestPayload: unknown;
33
+ transformedPayload: unknown;
34
+ errorMessage: string | null;
35
+ createdAt: string;
36
+ agentId: string;
37
+ projectId: string;
38
+ tenantId: string;
39
+ id: string;
40
+ }[];
41
+ pagination: {
42
+ page: number;
43
+ limit: number;
44
+ total: number;
45
+ pages: number;
46
+ };
47
+ }>;
48
+ /**
49
+ * Create a new trigger invocation (agent-scoped)
50
+ */
51
+ declare const createTriggerInvocation: (db: AgentsRunDatabaseClient) => (params: TriggerInvocationInsert) => Promise<TriggerInvocationSelect>;
52
+ /**
53
+ * Update trigger invocation status (agent-scoped)
54
+ */
55
+ declare const updateTriggerInvocationStatus: (db: AgentsRunDatabaseClient) => (params: {
56
+ scopes: AgentScopeConfig;
57
+ triggerId: string;
58
+ invocationId: string;
59
+ data: TriggerInvocationUpdate;
60
+ }) => Promise<TriggerInvocationSelect>;
61
+ //#endregion
62
+ export { createTriggerInvocation, getTriggerInvocationById, listTriggerInvocationsPaginated, updateTriggerInvocationStatus };
@@ -0,0 +1,54 @@
1
+ import { triggerInvocations } from "../../db/runtime/runtime-schema.js";
2
+ import { and, count, desc, eq, gte, lte } from "drizzle-orm";
3
+
4
+ //#region src/data-access/runtime/triggerInvocations.ts
5
+ /**
6
+ * Get a trigger invocation by ID (agent-scoped)
7
+ */
8
+ const getTriggerInvocationById = (db) => async (params) => {
9
+ return await db.query.triggerInvocations.findFirst({ where: and(eq(triggerInvocations.tenantId, params.scopes.tenantId), eq(triggerInvocations.projectId, params.scopes.projectId), eq(triggerInvocations.agentId, params.scopes.agentId), eq(triggerInvocations.triggerId, params.triggerId), eq(triggerInvocations.id, params.invocationId)) });
10
+ };
11
+ /**
12
+ * List trigger invocations with optional filtering (agent-scoped)
13
+ */
14
+ const listTriggerInvocationsPaginated = (db) => async (params) => {
15
+ const page = params.pagination?.page || 1;
16
+ const limit = Math.min(params.pagination?.limit || 10, 100);
17
+ const offset = (page - 1) * limit;
18
+ const conditions = [
19
+ eq(triggerInvocations.tenantId, params.scopes.tenantId),
20
+ eq(triggerInvocations.projectId, params.scopes.projectId),
21
+ eq(triggerInvocations.agentId, params.scopes.agentId),
22
+ eq(triggerInvocations.triggerId, params.triggerId)
23
+ ];
24
+ if (params.filters?.status) conditions.push(eq(triggerInvocations.status, params.filters.status));
25
+ if (params.filters?.from) conditions.push(gte(triggerInvocations.createdAt, params.filters.from));
26
+ if (params.filters?.to) conditions.push(lte(triggerInvocations.createdAt, params.filters.to));
27
+ const whereClause = and(...conditions);
28
+ const [data, totalResult] = await Promise.all([db.select().from(triggerInvocations).where(whereClause).limit(limit).offset(offset).orderBy(desc(triggerInvocations.createdAt)), db.select({ count: count() }).from(triggerInvocations).where(whereClause)]);
29
+ const total = totalResult[0]?.count || 0;
30
+ return {
31
+ data,
32
+ pagination: {
33
+ page,
34
+ limit,
35
+ total,
36
+ pages: Math.ceil(total / limit)
37
+ }
38
+ };
39
+ };
40
+ /**
41
+ * Create a new trigger invocation (agent-scoped)
42
+ */
43
+ const createTriggerInvocation = (db) => async (params) => {
44
+ return (await db.insert(triggerInvocations).values(params).returning())[0];
45
+ };
46
+ /**
47
+ * Update trigger invocation status (agent-scoped)
48
+ */
49
+ const updateTriggerInvocationStatus = (db) => async (params) => {
50
+ return (await db.update(triggerInvocations).set(params.data).where(and(eq(triggerInvocations.tenantId, params.scopes.tenantId), eq(triggerInvocations.projectId, params.scopes.projectId), eq(triggerInvocations.agentId, params.scopes.agentId), eq(triggerInvocations.triggerId, params.triggerId), eq(triggerInvocations.id, params.invocationId))).returning())[0];
51
+ };
52
+
53
+ //#endregion
54
+ export { createTriggerInvocation, getTriggerInvocationById, listTriggerInvocationsPaginated, updateTriggerInvocationStatus };