@inkeep/agents-core 0.65.0 → 0.65.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/auth/auth-schema.d.ts +108 -108
  2. package/dist/auth/auth-validation-schemas.d.ts +154 -154
  3. package/dist/auth/permissions.d.ts +9 -9
  4. package/dist/client-exports.d.ts +3 -3
  5. package/dist/client-exports.js +3 -3
  6. package/dist/constants/otel-attributes.d.ts +1 -0
  7. package/dist/constants/otel-attributes.js +1 -0
  8. package/dist/data-access/index.d.ts +2 -1
  9. package/dist/data-access/index.js +2 -1
  10. package/dist/data-access/manage/agents.d.ts +20 -20
  11. package/dist/data-access/manage/artifactComponents.d.ts +8 -8
  12. package/dist/data-access/manage/contextConfigs.d.ts +8 -8
  13. package/dist/data-access/manage/dataComponents.d.ts +2 -2
  14. package/dist/data-access/manage/functionTools.d.ts +10 -10
  15. package/dist/data-access/manage/skills.d.ts +13 -13
  16. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
  17. package/dist/data-access/manage/subAgentRelations.d.ts +12 -12
  18. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
  19. package/dist/data-access/manage/subAgents.d.ts +12 -12
  20. package/dist/data-access/manage/tools.d.ts +24 -24
  21. package/dist/data-access/manage/triggers.d.ts +1 -1
  22. package/dist/data-access/runtime/apiKeys.d.ts +12 -12
  23. package/dist/data-access/runtime/apps.d.ts +12 -12
  24. package/dist/data-access/runtime/conversations.d.ts +16 -16
  25. package/dist/data-access/runtime/feedback.d.ts +101 -0
  26. package/dist/data-access/runtime/feedback.js +83 -0
  27. package/dist/data-access/runtime/messages.d.ts +18 -18
  28. package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +4 -4
  29. package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +1 -1
  30. package/dist/data-access/runtime/tasks.d.ts +4 -4
  31. package/dist/db/manage/dolt-safe-jsonb.d.ts +2 -2
  32. package/dist/db/manage/manage-schema.d.ts +447 -447
  33. package/dist/db/runtime/runtime-schema.d.ts +573 -395
  34. package/dist/db/runtime/runtime-schema.js +73 -2
  35. package/dist/index.d.ts +6 -5
  36. package/dist/index.js +5 -4
  37. package/dist/types/entities.d.ts +5 -2
  38. package/dist/types/index.d.ts +2 -2
  39. package/dist/utils/error.d.ts +51 -51
  40. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  41. package/dist/validation/index.d.ts +3 -3
  42. package/dist/validation/index.js +3 -3
  43. package/dist/validation/schemas/shared.d.ts +3 -1
  44. package/dist/validation/schemas/shared.js +6 -1
  45. package/dist/validation/schemas/skills.d.ts +64 -64
  46. package/dist/validation/schemas.d.ts +2734 -2306
  47. package/dist/validation/schemas.js +29 -6
  48. package/drizzle/runtime/0034_simple_sphinx.sql +17 -0
  49. package/drizzle/runtime/meta/0034_snapshot.json +5288 -0
  50. package/drizzle/runtime/meta/_journal.json +7 -0
  51. package/package.json +1 -1
@@ -9,9 +9,11 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
9
9
  scopes: AgentScopeConfig;
10
10
  subAgentId: string;
11
11
  }) => Promise<{
12
+ description: string | null;
12
13
  id: string;
14
+ tenantId: string;
15
+ createdAt: string;
13
16
  name: string;
14
- description: string | null;
15
17
  models: {
16
18
  base?: {
17
19
  model?: string | undefined;
@@ -35,20 +37,20 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
35
37
  stopWhen: {
36
38
  stepCountIs?: number | undefined;
37
39
  } | null;
38
- createdAt: string;
39
40
  updatedAt: string;
40
- tenantId: string;
41
- prompt: string | null;
42
41
  projectId: string;
42
+ prompt: string | null;
43
43
  agentId: string;
44
44
  conversationHistoryConfig: ConversationHistoryConfig | null;
45
45
  } | undefined>;
46
46
  declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
47
47
  scopes: AgentScopeConfig;
48
48
  }) => Promise<{
49
+ description: string | null;
49
50
  id: string;
51
+ tenantId: string;
52
+ createdAt: string;
50
53
  name: string;
51
- description: string | null;
52
54
  models: {
53
55
  base?: {
54
56
  model?: string | undefined;
@@ -72,11 +74,9 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
72
74
  stopWhen: {
73
75
  stepCountIs?: number | undefined;
74
76
  } | null;
75
- createdAt: string;
76
77
  updatedAt: string;
77
- tenantId: string;
78
- prompt: string | null;
79
78
  projectId: string;
79
+ prompt: string | null;
80
80
  agentId: string;
81
81
  conversationHistoryConfig: ConversationHistoryConfig | null;
82
82
  }[]>;
@@ -127,9 +127,11 @@ declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (param
127
127
  };
128
128
  }>;
129
129
  declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAgentInsert) => Promise<{
130
+ description: string | null;
130
131
  id: string;
132
+ tenantId: string;
133
+ createdAt: string;
131
134
  name: string;
132
- description: string | null;
133
135
  models: {
134
136
  base?: {
135
137
  model?: string | undefined;
@@ -153,11 +155,9 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
153
155
  stopWhen: {
154
156
  stepCountIs?: number | undefined;
155
157
  } | null;
156
- createdAt: string;
157
158
  updatedAt: string;
158
- tenantId: string;
159
- prompt: string | null;
160
159
  projectId: string;
160
+ prompt: string | null;
161
161
  agentId: string;
162
162
  conversationHistoryConfig: ConversationHistoryConfig | null;
163
163
  }>;
@@ -20,20 +20,20 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
20
20
  scopes: ProjectScopeConfig;
21
21
  toolId: string;
22
22
  }) => Promise<{
23
- id: string;
24
- name: string;
25
23
  description: string | null;
24
+ id: string;
25
+ tenantId: string;
26
26
  createdAt: string;
27
+ name: string;
27
28
  updatedAt: string;
28
- tenantId: string;
29
29
  projectId: string;
30
- credentialReferenceId: string | null;
30
+ headers: Record<string, string> | null;
31
31
  config: {
32
32
  type: "mcp";
33
33
  mcp: ToolMcpConfig;
34
34
  };
35
+ credentialReferenceId: string | null;
35
36
  credentialScope: string;
36
- headers: Record<string, string> | null;
37
37
  imageUrl: string | null;
38
38
  capabilities: ToolServerCapabilities | null;
39
39
  lastError: string | null;
@@ -78,20 +78,20 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
78
78
  };
79
79
  }>;
80
80
  declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
81
- id: string;
82
- name: string;
83
81
  description: string | null;
82
+ id: string;
83
+ tenantId: string;
84
84
  createdAt: string;
85
+ name: string;
85
86
  updatedAt: string;
86
- tenantId: string;
87
87
  projectId: string;
88
- credentialReferenceId: string | null;
88
+ headers: Record<string, string> | null;
89
89
  config: {
90
90
  type: "mcp";
91
91
  mcp: ToolMcpConfig;
92
92
  };
93
+ credentialReferenceId: string | null;
93
94
  credentialScope: string;
94
- headers: Record<string, string> | null;
95
95
  imageUrl: string | null;
96
96
  capabilities: ToolServerCapabilities | null;
97
97
  lastError: string | null;
@@ -136,18 +136,18 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
136
136
  }> | null;
137
137
  }) => Promise<{
138
138
  id: string;
139
+ tenantId: string;
139
140
  createdAt: string;
140
141
  updatedAt: string;
141
- tenantId: string;
142
142
  projectId: string;
143
143
  agentId: string;
144
144
  toolId: string;
145
- subAgentId: string;
146
145
  headers: Record<string, string> | null;
147
- selectedTools: string[] | null;
148
146
  toolPolicies: Record<string, {
149
147
  needsApproval?: boolean;
150
148
  }> | null;
149
+ subAgentId: string;
150
+ selectedTools: string[] | null;
151
151
  }>;
152
152
  declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
153
153
  scopes: AgentScopeConfig;
@@ -155,18 +155,18 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
155
155
  toolId: string;
156
156
  }) => Promise<{
157
157
  id: string;
158
+ tenantId: string;
158
159
  createdAt: string;
159
160
  updatedAt: string;
160
- tenantId: string;
161
161
  projectId: string;
162
162
  agentId: string;
163
163
  toolId: string;
164
- subAgentId: string;
165
164
  headers: Record<string, string> | null;
166
- selectedTools: string[] | null;
167
165
  toolPolicies: Record<string, {
168
166
  needsApproval?: boolean;
169
167
  }> | null;
168
+ subAgentId: string;
169
+ selectedTools: string[] | null;
170
170
  }>;
171
171
  /**
172
172
  * Upsert agent-tool relation (create if it doesn't exist, update if it does)
@@ -183,18 +183,18 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
183
183
  relationId?: string;
184
184
  }) => Promise<{
185
185
  id: string;
186
+ tenantId: string;
186
187
  createdAt: string;
187
188
  updatedAt: string;
188
- tenantId: string;
189
189
  projectId: string;
190
190
  agentId: string;
191
191
  toolId: string;
192
- subAgentId: string;
193
192
  headers: Record<string, string> | null;
194
- selectedTools: string[] | null;
195
193
  toolPolicies: Record<string, {
196
194
  needsApproval?: boolean;
197
195
  }> | null;
196
+ subAgentId: string;
197
+ selectedTools: string[] | null;
198
198
  }>;
199
199
  /**
200
200
  * Upsert a tool (create if it doesn't exist, update if it does)
@@ -202,20 +202,20 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
202
202
  declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
203
203
  data: ToolInsert;
204
204
  }) => Promise<{
205
- id: string;
206
- name: string;
207
205
  description: string | null;
206
+ id: string;
207
+ tenantId: string;
208
208
  createdAt: string;
209
+ name: string;
209
210
  updatedAt: string;
210
- tenantId: string;
211
211
  projectId: string;
212
- credentialReferenceId: string | null;
212
+ headers: Record<string, string> | null;
213
213
  config: {
214
214
  type: "mcp";
215
215
  mcp: ToolMcpConfig;
216
216
  };
217
+ credentialReferenceId: string | null;
217
218
  credentialScope: string;
218
- headers: Record<string, string> | null;
219
219
  imageUrl: string | null;
220
220
  capabilities: ToolServerCapabilities | null;
221
221
  lastError: string | null;
@@ -40,7 +40,7 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
40
40
  algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
41
41
  encoding: "hex" | "base64";
42
42
  signature: {
43
- source: "header" | "query" | "body";
43
+ source: "query" | "header" | "body";
44
44
  key: string;
45
45
  prefix?: string | undefined;
46
46
  regex?: string | undefined;
@@ -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;
12
+ tenantId: string;
13
13
  createdAt: string;
14
+ name: string | null;
14
15
  updatedAt: string;
15
- tenantId: string;
16
16
  projectId: string;
17
17
  agentId: string;
18
- lastUsedAt: string | null;
19
18
  expiresAt: string | null;
20
19
  publicId: string;
21
20
  keyHash: string;
22
21
  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;
26
+ tenantId: string;
27
27
  createdAt: string;
28
+ name: string | null;
28
29
  updatedAt: string;
29
- tenantId: string;
30
30
  projectId: string;
31
31
  agentId: string;
32
- lastUsedAt: string | null;
33
32
  expiresAt: string | null;
34
33
  publicId: string;
35
34
  keyHash: string;
36
35
  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;
43
+ tenantId: string;
44
44
  createdAt: string;
45
+ name: string | null;
45
46
  updatedAt: string;
46
- tenantId: string;
47
47
  projectId: string;
48
48
  agentId: string;
49
- lastUsedAt: string | null;
50
49
  expiresAt: string | null;
51
50
  publicId: string;
52
51
  keyHash: string;
53
52
  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;
70
+ tenantId: string;
71
71
  createdAt: string;
72
+ name: string | null;
72
73
  updatedAt: string;
73
- tenantId: string;
74
74
  projectId: string;
75
75
  agentId: string;
76
- lastUsedAt: string | null;
77
76
  expiresAt: string | null;
78
77
  publicId: string;
79
78
  keyHash: string;
80
79
  keyPrefix: string;
80
+ lastUsedAt: string | null;
81
81
  }>;
82
82
  declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
83
83
  scopes: ProjectScopeConfig;
@@ -6,15 +6,15 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
6
6
  //#region src/data-access/runtime/apps.d.ts
7
7
  declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
8
8
  type: AppType;
9
- id: string;
10
- name: string;
11
9
  description: string | null;
10
+ id: string;
11
+ tenantId: string | null;
12
12
  createdAt: string;
13
+ name: string;
13
14
  updatedAt: string;
14
- tenantId: string | null;
15
+ projectId: string | null;
15
16
  enabled: boolean;
16
17
  prompt: string | null;
17
- projectId: string | null;
18
18
  config: {
19
19
  type: "web_client";
20
20
  webClient: {
@@ -32,9 +32,9 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
32
32
  type: "api";
33
33
  api: Record<string, never>;
34
34
  };
35
- defaultAgentId: string | null;
36
- defaultProjectId: string | null;
37
35
  lastUsedAt: string | null;
36
+ defaultProjectId: string | null;
37
+ defaultAgentId: string | null;
38
38
  } | undefined>;
39
39
  declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
40
40
  declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
@@ -62,15 +62,15 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
62
62
  }>;
63
63
  declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
64
64
  type: AppType;
65
- id: string;
66
- name: string;
67
65
  description: string | null;
66
+ id: string;
67
+ tenantId: string | null;
68
68
  createdAt: string;
69
+ name: string;
69
70
  updatedAt: string;
70
- tenantId: string | null;
71
+ projectId: string | null;
71
72
  enabled: boolean;
72
73
  prompt: string | null;
73
- projectId: string | null;
74
74
  config: {
75
75
  type: "web_client";
76
76
  webClient: {
@@ -88,9 +88,9 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
88
88
  type: "api";
89
89
  api: Record<string, never>;
90
90
  };
91
- defaultAgentId: string | null;
92
- defaultProjectId: string | null;
93
91
  lastUsedAt: string | null;
92
+ defaultProjectId: string | null;
93
+ defaultAgentId: string | null;
94
94
  }>;
95
95
  declare const updateAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
96
96
  scopes: TenantScopeConfig;
@@ -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
+ title: string | null;
18
19
  id: string;
20
+ tenantId: string;
21
+ createdAt: string;
22
+ metadata: ConversationMetadata | null;
19
23
  ref: {
20
24
  type: "commit" | "tag" | "branch";
21
25
  name: string;
22
26
  hash: string;
23
27
  } | null;
24
- title: string | null;
25
- createdAt: string;
26
28
  updatedAt: string;
27
- tenantId: string;
28
29
  projectId: string;
29
30
  agentId: string | null;
30
31
  userId: string | null;
31
- metadata: ConversationMetadata | null;
32
32
  activeSubAgentId: string;
33
33
  lastContextResolution: string | null;
34
34
  }>;
@@ -84,20 +84,20 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
84
84
  scopes: ProjectScopeConfig;
85
85
  conversationId: string;
86
86
  }) => Promise<{
87
+ title: string | null;
87
88
  id: string;
89
+ tenantId: string;
90
+ createdAt: string;
91
+ metadata: ConversationMetadata | null;
88
92
  ref: {
89
93
  type: "commit" | "tag" | "branch";
90
94
  name: string;
91
95
  hash: string;
92
96
  } | null;
93
- title: string | null;
94
- createdAt: string;
95
97
  updatedAt: string;
96
- tenantId: string;
97
98
  projectId: string;
98
99
  agentId: string | null;
99
100
  userId: string | null;
100
- metadata: ConversationMetadata | null;
101
101
  activeSubAgentId: string;
102
102
  lastContextResolution: string | null;
103
103
  } | undefined>;
@@ -120,20 +120,20 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
120
120
  metadata?: ConversationMetadata | null | undefined;
121
121
  contextConfigId?: string | undefined;
122
122
  } | {
123
+ title: string | null;
123
124
  id: string;
125
+ tenantId: string;
126
+ createdAt: string;
127
+ metadata: ConversationMetadata | null;
124
128
  ref: {
125
129
  type: "commit" | "tag" | "branch";
126
130
  name: string;
127
131
  hash: string;
128
132
  } | null;
129
- title: string | null;
130
- createdAt: string;
131
133
  updatedAt: string;
132
- tenantId: string;
133
134
  projectId: string;
134
135
  agentId: string | null;
135
136
  userId: string | null;
136
- metadata: ConversationMetadata | 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
+ title: string | null;
155
156
  id: string;
157
+ tenantId: string;
158
+ createdAt: string;
159
+ metadata: ConversationMetadata | null;
156
160
  ref: {
157
161
  type: "commit" | "tag" | "branch";
158
162
  name: string;
159
163
  hash: string;
160
164
  } | null;
161
- title: string | null;
162
- createdAt: string;
163
165
  updatedAt: string;
164
- tenantId: string;
165
166
  projectId: string;
166
167
  agentId: string | null;
167
168
  userId: string | null;
168
- metadata: ConversationMetadata | null;
169
169
  activeSubAgentId: string;
170
170
  lastContextResolution: string | null;
171
171
  } | undefined>;
@@ -0,0 +1,101 @@
1
+ import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
2
+ import { PaginationConfig } from "../../types/utility.js";
3
+ import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
4
+ import "../../types/index.js";
5
+ import { FeedbackInsert, FeedbackUpdate } from "../../types/entities.js";
6
+
7
+ //#region src/data-access/runtime/feedback.d.ts
8
+ declare const getFeedbackById: (db: AgentsRunDatabaseClient) => (params: {
9
+ scopes: ProjectScopeConfig;
10
+ feedbackId: string;
11
+ }) => Promise<{
12
+ id: string;
13
+ conversationId: string;
14
+ messageId: string | null;
15
+ type: "positive" | "negative";
16
+ details: string | null;
17
+ createdAt: string;
18
+ updatedAt: string;
19
+ }>;
20
+ declare const listFeedbackByConversation: (db: AgentsRunDatabaseClient) => (params: {
21
+ scopes: ProjectScopeConfig;
22
+ conversationId: string;
23
+ messageId?: string;
24
+ pagination?: PaginationConfig;
25
+ }) => Promise<{
26
+ feedback: {
27
+ id: string;
28
+ conversationId: string;
29
+ messageId: string | null;
30
+ type: "positive" | "negative";
31
+ details: string | null;
32
+ createdAt: string;
33
+ updatedAt: string;
34
+ agentId: string | null;
35
+ }[];
36
+ total: number;
37
+ }>;
38
+ declare const listFeedback: (db: AgentsRunDatabaseClient) => (params: {
39
+ scopes: ProjectScopeConfig;
40
+ conversationId?: string;
41
+ messageId?: string;
42
+ agentId?: string;
43
+ type?: "positive" | "negative";
44
+ startDate?: string;
45
+ endDate?: string;
46
+ pagination?: PaginationConfig;
47
+ }) => Promise<{
48
+ feedback: {
49
+ id: string;
50
+ conversationId: string;
51
+ messageId: string | null;
52
+ type: "positive" | "negative";
53
+ details: string | null;
54
+ createdAt: string;
55
+ updatedAt: string;
56
+ agentId: string | null;
57
+ }[];
58
+ total: number;
59
+ }>;
60
+ declare const createFeedback: (db: AgentsRunDatabaseClient) => (params: FeedbackInsert) => Promise<{
61
+ type: "positive" | "negative";
62
+ id: string;
63
+ tenantId: string;
64
+ createdAt: string;
65
+ updatedAt: string;
66
+ projectId: string;
67
+ details: string | null;
68
+ conversationId: string;
69
+ messageId: string | null;
70
+ }>;
71
+ declare const updateFeedback: (db: AgentsRunDatabaseClient) => (params: {
72
+ scopes: ProjectScopeConfig;
73
+ feedbackId: string;
74
+ data: FeedbackUpdate;
75
+ }) => Promise<{
76
+ createdAt: string;
77
+ updatedAt: string;
78
+ conversationId: string;
79
+ messageId: string | null;
80
+ type: "positive" | "negative";
81
+ details: string | null;
82
+ projectId: string;
83
+ tenantId: string;
84
+ id: string;
85
+ }>;
86
+ declare const deleteFeedback: (db: AgentsRunDatabaseClient) => (params: {
87
+ scopes: ProjectScopeConfig;
88
+ feedbackId: string;
89
+ }) => Promise<{
90
+ type: "positive" | "negative";
91
+ id: string;
92
+ tenantId: string;
93
+ createdAt: string;
94
+ updatedAt: string;
95
+ projectId: string;
96
+ details: string | null;
97
+ conversationId: string;
98
+ messageId: string | null;
99
+ }>;
100
+ //#endregion
101
+ export { createFeedback, deleteFeedback, getFeedbackById, listFeedback, listFeedbackByConversation, updateFeedback };
@@ -0,0 +1,83 @@
1
+ import { conversations, feedback } from "../../db/runtime/runtime-schema.js";
2
+ import { projectScopedWhere } from "../manage/scope-helpers.js";
3
+ import { and, count, desc, eq, gte, lte } from "drizzle-orm";
4
+
5
+ //#region src/data-access/runtime/feedback.ts
6
+ const getFeedbackById = (db) => async (params) => {
7
+ const [result] = await db.select({
8
+ id: feedback.id,
9
+ conversationId: feedback.conversationId,
10
+ messageId: feedback.messageId,
11
+ type: feedback.type,
12
+ details: feedback.details,
13
+ createdAt: feedback.createdAt,
14
+ updatedAt: feedback.updatedAt
15
+ }).from(feedback).where(and(projectScopedWhere(feedback, params.scopes), eq(feedback.id, params.feedbackId))).limit(1);
16
+ return result;
17
+ };
18
+ const listFeedbackByConversation = (db) => async (params) => {
19
+ return listFeedback(db)({
20
+ scopes: params.scopes,
21
+ conversationId: params.conversationId,
22
+ messageId: params.messageId,
23
+ pagination: params.pagination
24
+ });
25
+ };
26
+ const listFeedback = (db) => async (params) => {
27
+ const page = params.pagination?.page || 1;
28
+ const limit = Math.min(params.pagination?.limit || 10, 100);
29
+ const offset = (page - 1) * limit;
30
+ const conditions = [projectScopedWhere(feedback, params.scopes)];
31
+ if (params.conversationId) conditions.push(eq(feedback.conversationId, params.conversationId));
32
+ if (params.messageId) conditions.push(eq(feedback.messageId, params.messageId));
33
+ if (params.type) conditions.push(eq(feedback.type, params.type));
34
+ if (params.startDate) conditions.push(gte(feedback.createdAt, `${params.startDate}T00:00:00.000Z`));
35
+ if (params.endDate) conditions.push(lte(feedback.createdAt, `${params.endDate}T23:59:59.999Z`));
36
+ if (params.agentId) conditions.push(eq(conversations.agentId, params.agentId));
37
+ const whereClause = and(...conditions);
38
+ const conversationsJoin = [
39
+ eq(feedback.tenantId, conversations.tenantId),
40
+ eq(feedback.projectId, conversations.projectId),
41
+ eq(feedback.conversationId, conversations.id)
42
+ ];
43
+ const countQuery = db.select({ count: count() }).from(feedback);
44
+ if (params.agentId) countQuery.leftJoin(conversations, and(...conversationsJoin));
45
+ const [items, total] = await Promise.all([db.select({
46
+ id: feedback.id,
47
+ conversationId: feedback.conversationId,
48
+ messageId: feedback.messageId,
49
+ type: feedback.type,
50
+ details: feedback.details,
51
+ createdAt: feedback.createdAt,
52
+ updatedAt: feedback.updatedAt,
53
+ agentId: conversations.agentId
54
+ }).from(feedback).leftJoin(conversations, and(...conversationsJoin)).where(whereClause).limit(limit).offset(offset).orderBy(desc(feedback.createdAt)), countQuery.where(whereClause)]);
55
+ return {
56
+ feedback: items,
57
+ total: typeof total[0]?.count === "string" ? Number.parseInt(total[0].count, 10) : total[0]?.count ?? 0
58
+ };
59
+ };
60
+ const createFeedback = (db) => async (params) => {
61
+ const now = (/* @__PURE__ */ new Date()).toISOString();
62
+ const [created] = await db.insert(feedback).values({
63
+ ...params,
64
+ createdAt: now,
65
+ updatedAt: now
66
+ }).returning();
67
+ return created;
68
+ };
69
+ const updateFeedback = (db) => async (params) => {
70
+ const now = (/* @__PURE__ */ new Date()).toISOString();
71
+ const [updated] = await db.update(feedback).set({
72
+ ...params.data,
73
+ updatedAt: now
74
+ }).where(and(projectScopedWhere(feedback, params.scopes), eq(feedback.id, params.feedbackId))).returning();
75
+ return updated;
76
+ };
77
+ const deleteFeedback = (db) => async (params) => {
78
+ const [deleted] = await db.delete(feedback).where(and(projectScopedWhere(feedback, params.scopes), eq(feedback.id, params.feedbackId))).returning();
79
+ return deleted;
80
+ };
81
+
82
+ //#endregion
83
+ export { createFeedback, deleteFeedback, getFeedbackById, listFeedback, listFeedbackByConversation, updateFeedback };