@inkeep/agents-core 0.64.2 → 0.64.7

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 (58) 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/init.js +2 -2
  4. package/dist/auth/permissions.d.ts +9 -9
  5. package/dist/constants/otel-attributes.d.ts +5 -0
  6. package/dist/constants/otel-attributes.js +7 -2
  7. package/dist/constants/signoz-queries.d.ts +1 -0
  8. package/dist/constants/signoz-queries.js +2 -1
  9. package/dist/data-access/index.d.ts +2 -1
  10. package/dist/data-access/index.js +2 -1
  11. package/dist/data-access/manage/agents.d.ts +11 -11
  12. package/dist/data-access/manage/artifactComponents.d.ts +2 -2
  13. package/dist/data-access/manage/functionTools.d.ts +4 -4
  14. package/dist/data-access/manage/skills.d.ts +7 -7
  15. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
  16. package/dist/data-access/manage/subAgentRelations.d.ts +6 -6
  17. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +6 -6
  18. package/dist/data-access/manage/subAgents.d.ts +9 -9
  19. package/dist/data-access/manage/tools.d.ts +18 -18
  20. package/dist/data-access/manage/tools.js +1 -1
  21. package/dist/data-access/manage/triggers.d.ts +2 -2
  22. package/dist/data-access/runtime/apiKeys.d.ts +4 -4
  23. package/dist/data-access/runtime/apps.d.ts +4 -4
  24. package/dist/data-access/runtime/conversations.d.ts +16 -16
  25. package/dist/data-access/runtime/messages.d.ts +9 -9
  26. package/dist/data-access/runtime/streamChunks.d.ts +29 -0
  27. package/dist/data-access/runtime/streamChunks.js +65 -0
  28. package/dist/data-access/runtime/tasks.d.ts +4 -4
  29. package/dist/db/manage/dolt-safe-jsonb.d.ts +12 -0
  30. package/dist/db/manage/dolt-safe-jsonb.js +61 -0
  31. package/dist/db/manage/manage-schema.d.ts +487 -487
  32. package/dist/db/manage/manage-schema.js +40 -39
  33. package/dist/db/runtime/runtime-schema.d.ts +508 -376
  34. package/dist/db/runtime/runtime-schema.js +20 -1
  35. package/dist/dolt/ref-helpers.js +15 -1
  36. package/dist/dolt/ref-scope.js +29 -1
  37. package/dist/index.d.ts +5 -4
  38. package/dist/index.js +5 -4
  39. package/dist/setup/setup.d.ts +3 -1
  40. package/dist/setup/setup.js +14 -10
  41. package/dist/utils/index.d.ts +3 -3
  42. package/dist/utils/index.js +3 -3
  43. package/dist/utils/jwt-helpers.d.ts +2 -3
  44. package/dist/utils/jwt-helpers.js +2 -3
  45. package/dist/utils/retry-client.d.ts +8 -0
  46. package/dist/utils/retry-client.js +29 -0
  47. package/dist/utils/service-token-auth.d.ts +3 -0
  48. package/dist/utils/service-token-auth.js +5 -2
  49. package/dist/utils/temp-jwt.d.ts +1 -6
  50. package/dist/utils/temp-jwt.js +1 -12
  51. package/dist/utils/work-app-mcp.js +1 -2
  52. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  53. package/dist/validation/schemas/skills.d.ts +35 -35
  54. package/dist/validation/schemas.d.ts +2012 -2012
  55. package/drizzle/runtime/0031_fantastic_gorilla_man.sql +13 -0
  56. package/drizzle/runtime/meta/0031_snapshot.json +4872 -0
  57. package/drizzle/runtime/meta/_journal.json +7 -0
  58. package/package.json +6 -2
@@ -12,10 +12,10 @@ declare const getSubAgentTeamAgentRelationById: (db: AgentsManageDatabaseClient)
12
12
  id: string;
13
13
  createdAt: string;
14
14
  updatedAt: string;
15
- headers: Record<string, string> | null;
16
15
  tenantId: string;
17
16
  projectId: string;
18
17
  agentId: string;
18
+ headers: Record<string, string> | null;
19
19
  subAgentId: string;
20
20
  targetAgentId: string;
21
21
  } | undefined>;
@@ -47,10 +47,10 @@ declare const getSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) =>
47
47
  id: string;
48
48
  createdAt: string;
49
49
  updatedAt: string;
50
- headers: Record<string, string> | null;
51
50
  tenantId: string;
52
51
  projectId: string;
53
52
  agentId: string;
53
+ headers: Record<string, string> | null;
54
54
  subAgentId: string;
55
55
  targetAgentId: string;
56
56
  }[]>;
@@ -60,10 +60,10 @@ declare const getSubAgentTeamAgentRelationsByAgent: (db: AgentsManageDatabaseCli
60
60
  id: string;
61
61
  createdAt: string;
62
62
  updatedAt: string;
63
- headers: Record<string, string> | null;
64
63
  tenantId: string;
65
64
  projectId: string;
66
65
  agentId: string;
66
+ headers: Record<string, string> | null;
67
67
  subAgentId: string;
68
68
  targetAgentId: string;
69
69
  }[]>;
@@ -225,10 +225,10 @@ declare const createSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
225
225
  id: string;
226
226
  createdAt: string;
227
227
  updatedAt: string;
228
- headers: Record<string, string> | null;
229
228
  tenantId: string;
230
229
  projectId: string;
231
230
  agentId: string;
231
+ headers: Record<string, string> | null;
232
232
  subAgentId: string;
233
233
  targetAgentId: string;
234
234
  }>;
@@ -242,10 +242,10 @@ declare const getSubAgentTeamAgentRelationByParams: (db: AgentsManageDatabaseCli
242
242
  id: string;
243
243
  createdAt: string;
244
244
  updatedAt: string;
245
- headers: Record<string, string> | null;
246
245
  tenantId: string;
247
246
  projectId: string;
248
247
  agentId: string;
248
+ headers: Record<string, string> | null;
249
249
  subAgentId: string;
250
250
  targetAgentId: string;
251
251
  } | undefined>;
@@ -263,10 +263,10 @@ declare const upsertSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
263
263
  id: string;
264
264
  createdAt: string;
265
265
  updatedAt: string;
266
- headers: Record<string, string> | null;
267
266
  tenantId: string;
268
267
  projectId: string;
269
268
  agentId: string;
269
+ headers: Record<string, string> | null;
270
270
  subAgentId: string;
271
271
  targetAgentId: string;
272
272
  }>;
@@ -11,8 +11,6 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
11
11
  }) => Promise<{
12
12
  id: string;
13
13
  name: string;
14
- createdAt: string;
15
- updatedAt: string;
16
14
  description: string | null;
17
15
  models: {
18
16
  base?: {
@@ -37,10 +35,12 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
37
35
  stopWhen: {
38
36
  stepCountIs?: number | undefined;
39
37
  } | null;
38
+ createdAt: string;
39
+ updatedAt: string;
40
40
  tenantId: string;
41
41
  projectId: string;
42
- agentId: string;
43
42
  prompt: string | null;
43
+ agentId: string;
44
44
  conversationHistoryConfig: ConversationHistoryConfig | null;
45
45
  } | undefined>;
46
46
  declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
@@ -48,8 +48,6 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
48
48
  }) => Promise<{
49
49
  id: string;
50
50
  name: string;
51
- createdAt: string;
52
- updatedAt: string;
53
51
  description: string | null;
54
52
  models: {
55
53
  base?: {
@@ -74,10 +72,12 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
74
72
  stopWhen: {
75
73
  stepCountIs?: number | undefined;
76
74
  } | null;
75
+ createdAt: string;
76
+ updatedAt: string;
77
77
  tenantId: string;
78
78
  projectId: string;
79
- agentId: string;
80
79
  prompt: string | null;
80
+ agentId: string;
81
81
  conversationHistoryConfig: ConversationHistoryConfig | null;
82
82
  }[]>;
83
83
  declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
@@ -129,8 +129,6 @@ declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (param
129
129
  declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAgentInsert) => Promise<{
130
130
  id: string;
131
131
  name: string;
132
- createdAt: string;
133
- updatedAt: string;
134
132
  description: string | null;
135
133
  models: {
136
134
  base?: {
@@ -155,10 +153,12 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
155
153
  stopWhen: {
156
154
  stepCountIs?: number | undefined;
157
155
  } | null;
156
+ createdAt: string;
157
+ updatedAt: string;
158
158
  tenantId: string;
159
159
  projectId: string;
160
- agentId: string;
161
160
  prompt: string | null;
161
+ agentId: string;
162
162
  conversationHistoryConfig: ConversationHistoryConfig | null;
163
163
  }>;
164
164
  declare const updateSubAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -22,17 +22,17 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
22
22
  }) => Promise<{
23
23
  id: string;
24
24
  name: string;
25
+ description: string | null;
25
26
  createdAt: string;
26
27
  updatedAt: string;
27
- headers: Record<string, string> | null;
28
- description: string | null;
29
28
  tenantId: string;
30
29
  projectId: string;
31
- credentialReferenceId: string | null;
30
+ headers: Record<string, string> | null;
32
31
  config: {
33
32
  type: "mcp";
34
33
  mcp: ToolMcpConfig;
35
34
  };
35
+ credentialReferenceId: string | null;
36
36
  credentialScope: string;
37
37
  imageUrl: string | null;
38
38
  capabilities: ToolServerCapabilities | null;
@@ -80,17 +80,17 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
80
80
  declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
81
81
  id: string;
82
82
  name: string;
83
+ description: string | null;
83
84
  createdAt: string;
84
85
  updatedAt: string;
85
- headers: Record<string, string> | null;
86
- description: string | null;
87
86
  tenantId: string;
88
87
  projectId: string;
89
- credentialReferenceId: string | null;
88
+ headers: Record<string, string> | null;
90
89
  config: {
91
90
  type: "mcp";
92
91
  mcp: ToolMcpConfig;
93
92
  };
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
141
  tenantId: string;
143
142
  projectId: string;
144
143
  agentId: string;
145
- subAgentId: string;
146
144
  toolId: string;
147
- selectedTools: string[] | null;
145
+ headers: Record<string, 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;
@@ -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
160
  tenantId: string;
162
161
  projectId: string;
163
162
  agentId: string;
164
- subAgentId: string;
165
163
  toolId: string;
166
- selectedTools: string[] | null;
164
+ headers: Record<string, 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)
@@ -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
188
  tenantId: string;
190
189
  projectId: string;
191
190
  agentId: string;
192
- subAgentId: string;
193
191
  toolId: string;
194
- selectedTools: string[] | null;
192
+ headers: Record<string, 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)
@@ -204,17 +204,17 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
204
204
  }) => Promise<{
205
205
  id: string;
206
206
  name: string;
207
+ description: string | null;
207
208
  createdAt: string;
208
209
  updatedAt: string;
209
- headers: Record<string, string> | null;
210
- description: string | null;
211
210
  tenantId: string;
212
211
  projectId: string;
213
- credentialReferenceId: string | null;
212
+ headers: Record<string, string> | null;
214
213
  config: {
215
214
  type: "mcp";
216
215
  mcp: ToolMcpConfig;
217
216
  };
217
+ credentialReferenceId: string | null;
218
218
  credentialScope: string;
219
219
  imageUrl: string | null;
220
220
  capabilities: ToolServerCapabilities | null;
@@ -174,7 +174,7 @@ const discoverToolsFromServer = async (tool, credentialReference, credentialStor
174
174
  });
175
175
  await client.connect();
176
176
  const serverTools = await client.tools();
177
- const serverInstructions = client.getInstructions()?.replace(/\u0000/g, "");
177
+ const serverInstructions = client.getInstructions() ?? void 0;
178
178
  await client.disconnect();
179
179
  const toolOverrides = tool.config.mcp.toolOverrides;
180
180
  return {
@@ -40,13 +40,13 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
40
40
  algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
41
41
  encoding: "hex" | "base64";
42
42
  signature: {
43
- source: "query" | "body" | "header";
43
+ source: "query" | "header" | "body";
44
44
  key: string;
45
45
  prefix?: string | undefined;
46
46
  regex?: string | undefined;
47
47
  };
48
48
  signedComponents: {
49
- source: "literal" | "body" | "header";
49
+ source: "literal" | "header" | "body";
50
50
  required: boolean;
51
51
  key?: string | undefined;
52
52
  value?: string | undefined;
@@ -12,10 +12,10 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
12
12
  name: string | null;
13
13
  createdAt: string;
14
14
  updatedAt: string;
15
- expiresAt: string | null;
16
15
  tenantId: string;
17
16
  projectId: string;
18
17
  agentId: string;
18
+ expiresAt: string | null;
19
19
  publicId: string;
20
20
  keyHash: string;
21
21
  keyPrefix: string;
@@ -26,10 +26,10 @@ declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: s
26
26
  name: string | null;
27
27
  createdAt: string;
28
28
  updatedAt: string;
29
- expiresAt: string | null;
30
29
  tenantId: string;
31
30
  projectId: string;
32
31
  agentId: string;
32
+ expiresAt: string | null;
33
33
  publicId: string;
34
34
  keyHash: string;
35
35
  keyPrefix: string;
@@ -43,10 +43,10 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
43
43
  name: string | null;
44
44
  createdAt: string;
45
45
  updatedAt: string;
46
- expiresAt: string | null;
47
46
  tenantId: string;
48
47
  projectId: string;
49
48
  agentId: string;
49
+ expiresAt: string | null;
50
50
  publicId: string;
51
51
  keyHash: string;
52
52
  keyPrefix: string;
@@ -70,10 +70,10 @@ declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInse
70
70
  name: string | null;
71
71
  createdAt: string;
72
72
  updatedAt: string;
73
- expiresAt: string | null;
74
73
  tenantId: string;
75
74
  projectId: string;
76
75
  agentId: string;
76
+ expiresAt: string | null;
77
77
  publicId: string;
78
78
  keyHash: string;
79
79
  keyPrefix: string;
@@ -8,12 +8,12 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
8
8
  type: AppType;
9
9
  id: string;
10
10
  name: string;
11
+ description: string | null;
11
12
  createdAt: string;
12
13
  updatedAt: string;
13
- description: string | null;
14
- enabled: boolean;
15
14
  tenantId: string | null;
16
15
  projectId: string | null;
16
+ enabled: boolean;
17
17
  prompt: string | null;
18
18
  config: {
19
19
  type: "web_client";
@@ -64,12 +64,12 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
64
64
  type: AppType;
65
65
  id: string;
66
66
  name: string;
67
+ description: string | null;
67
68
  createdAt: string;
68
69
  updatedAt: string;
69
- description: string | null;
70
- enabled: boolean;
71
70
  tenantId: string | null;
72
71
  projectId: string | null;
72
+ enabled: boolean;
73
73
  prompt: string | null;
74
74
  config: {
75
75
  type: "web_client";
@@ -16,19 +16,19 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
16
16
  }>;
17
17
  declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
18
18
  id: string;
19
- createdAt: string;
20
- updatedAt: string;
21
19
  ref: {
22
20
  type: "commit" | "tag" | "branch";
23
21
  name: string;
24
22
  hash: string;
25
23
  } | null;
26
- userId: string | null;
27
- metadata: ConversationMetadata | null;
28
24
  title: string | null;
25
+ createdAt: string;
26
+ updatedAt: string;
29
27
  tenantId: string;
30
28
  projectId: string;
29
+ metadata: ConversationMetadata | null;
31
30
  agentId: string | null;
31
+ userId: string | null;
32
32
  activeSubAgentId: string;
33
33
  lastContextResolution: string | null;
34
34
  }>;
@@ -85,19 +85,19 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
85
85
  conversationId: string;
86
86
  }) => Promise<{
87
87
  id: string;
88
- createdAt: string;
89
- updatedAt: string;
90
88
  ref: {
91
89
  type: "commit" | "tag" | "branch";
92
90
  name: string;
93
91
  hash: string;
94
92
  } | null;
95
- userId: string | null;
96
- metadata: ConversationMetadata | null;
97
93
  title: string | null;
94
+ createdAt: string;
95
+ updatedAt: string;
98
96
  tenantId: string;
99
97
  projectId: string;
98
+ metadata: ConversationMetadata | null;
100
99
  agentId: string | null;
100
+ userId: string | null;
101
101
  activeSubAgentId: string;
102
102
  lastContextResolution: string | null;
103
103
  } | undefined>;
@@ -121,19 +121,19 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
121
121
  contextConfigId?: string | undefined;
122
122
  } | {
123
123
  id: string;
124
- createdAt: string;
125
- updatedAt: string;
126
124
  ref: {
127
125
  type: "commit" | "tag" | "branch";
128
126
  name: string;
129
127
  hash: string;
130
128
  } | null;
131
- userId: string | null;
132
- metadata: ConversationMetadata | null;
133
129
  title: string | null;
130
+ createdAt: string;
131
+ updatedAt: string;
134
132
  tenantId: string;
135
133
  projectId: string;
134
+ metadata: ConversationMetadata | null;
136
135
  agentId: string | null;
136
+ userId: string | null;
137
137
  activeSubAgentId: string;
138
138
  lastContextResolution: string | null;
139
139
  }>;
@@ -153,19 +153,19 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
153
153
  conversationId: string;
154
154
  }) => Promise<{
155
155
  id: string;
156
- createdAt: string;
157
- updatedAt: string;
158
156
  ref: {
159
157
  type: "commit" | "tag" | "branch";
160
158
  name: string;
161
159
  hash: string;
162
160
  } | null;
163
- userId: string | null;
164
- metadata: ConversationMetadata | null;
165
161
  title: string | null;
162
+ createdAt: string;
163
+ updatedAt: string;
166
164
  tenantId: string;
167
165
  projectId: string;
166
+ metadata: ConversationMetadata | null;
168
167
  agentId: string | null;
168
+ userId: string | null;
169
169
  activeSubAgentId: string;
170
170
  lastContextResolution: string | null;
171
171
  } | undefined>;
@@ -13,11 +13,11 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
13
13
  id: string;
14
14
  createdAt: string;
15
15
  updatedAt: string;
16
- metadata: MessageMetadata | null;
17
- role: string;
18
16
  tenantId: string;
19
- content: MessageContent;
20
17
  projectId: string;
18
+ metadata: MessageMetadata | null;
19
+ content: MessageContent;
20
+ role: string;
21
21
  conversationId: string;
22
22
  fromSubAgentId: string | null;
23
23
  toSubAgentId: string | null;
@@ -147,11 +147,11 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
147
147
  id: string;
148
148
  createdAt: string;
149
149
  updatedAt: string;
150
- metadata: MessageMetadata | null;
151
- role: string;
152
150
  tenantId: string;
153
- content: MessageContent;
154
151
  projectId: string;
152
+ metadata: MessageMetadata | null;
153
+ content: MessageContent;
154
+ role: string;
155
155
  conversationId: string;
156
156
  fromSubAgentId: string | null;
157
157
  toSubAgentId: string | null;
@@ -200,11 +200,11 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
200
200
  id: string;
201
201
  createdAt: string;
202
202
  updatedAt: string;
203
- metadata: MessageMetadata | null;
204
- role: string;
205
203
  tenantId: string;
206
- content: MessageContent;
207
204
  projectId: string;
205
+ metadata: MessageMetadata | null;
206
+ content: MessageContent;
207
+ role: string;
208
208
  conversationId: string;
209
209
  fromSubAgentId: string | null;
210
210
  toSubAgentId: string | null;
@@ -0,0 +1,29 @@
1
+ import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
2
+
3
+ //#region src/data-access/runtime/streamChunks.d.ts
4
+ interface ConversationScope {
5
+ tenantId: string;
6
+ projectId: string;
7
+ conversationId: string;
8
+ }
9
+ declare const insertStreamChunks: (db: AgentsRunDatabaseClient) => (params: ConversationScope & {
10
+ chunks: {
11
+ idx: number;
12
+ data: string;
13
+ }[];
14
+ }) => Promise<void>;
15
+ declare const markStreamComplete: (db: AgentsRunDatabaseClient) => (params: ConversationScope & {
16
+ finalIdx: number;
17
+ }) => Promise<void>;
18
+ declare const getStreamChunks: (db: AgentsRunDatabaseClient) => (params: ConversationScope & {
19
+ afterIdx?: number;
20
+ limit?: number;
21
+ }) => Promise<{
22
+ idx: number;
23
+ data: string;
24
+ isFinal: boolean;
25
+ }[]>;
26
+ declare const deleteStreamChunks: (db: AgentsRunDatabaseClient) => (params: ConversationScope) => Promise<void>;
27
+ declare const cleanupExpiredStreamChunks: (db: AgentsRunDatabaseClient) => (olderThanMinutes?: number, batchSize?: number) => Promise<void>;
28
+ //#endregion
29
+ export { cleanupExpiredStreamChunks, deleteStreamChunks, getStreamChunks, insertStreamChunks, markStreamComplete };
@@ -0,0 +1,65 @@
1
+ import { streamChunks } from "../../db/runtime/runtime-schema.js";
2
+ import { and, eq, gt, sql } from "drizzle-orm";
3
+
4
+ //#region src/data-access/runtime/streamChunks.ts
5
+ const DEFAULT_CHUNK_BATCH_LIMIT = 500;
6
+ const DEFAULT_CLEANUP_AGE_MINUTES = 60;
7
+ const DEFAULT_CLEANUP_BATCH_SIZE = 1e3;
8
+ const scopeConditions = (scope) => [
9
+ eq(streamChunks.tenantId, scope.tenantId),
10
+ eq(streamChunks.projectId, scope.projectId),
11
+ eq(streamChunks.conversationId, scope.conversationId)
12
+ ];
13
+ const insertStreamChunks = (db) => async (params) => {
14
+ if (params.chunks.length === 0) return;
15
+ await db.insert(streamChunks).values(params.chunks.map((chunk) => ({
16
+ tenantId: params.tenantId,
17
+ projectId: params.projectId,
18
+ conversationId: params.conversationId,
19
+ idx: chunk.idx,
20
+ data: chunk.data,
21
+ isFinal: false
22
+ })));
23
+ };
24
+ const markStreamComplete = (db) => async (params) => {
25
+ await db.insert(streamChunks).values({
26
+ tenantId: params.tenantId,
27
+ projectId: params.projectId,
28
+ conversationId: params.conversationId,
29
+ idx: params.finalIdx,
30
+ data: "",
31
+ isFinal: true
32
+ });
33
+ };
34
+ const getStreamChunks = (db) => async (params) => {
35
+ const conditions = scopeConditions(params);
36
+ if (params.afterIdx !== void 0) conditions.push(gt(streamChunks.idx, params.afterIdx));
37
+ return db.select({
38
+ idx: streamChunks.idx,
39
+ data: streamChunks.data,
40
+ isFinal: streamChunks.isFinal
41
+ }).from(streamChunks).where(and(...conditions)).orderBy(streamChunks.idx).limit(params.limit ?? DEFAULT_CHUNK_BATCH_LIMIT);
42
+ };
43
+ const deleteStreamChunks = (db) => async (params) => {
44
+ await db.delete(streamChunks).where(and(...scopeConditions(params)));
45
+ };
46
+ const cleanupExpiredStreamChunks = (db) => async (olderThanMinutes = DEFAULT_CLEANUP_AGE_MINUTES, batchSize = DEFAULT_CLEANUP_BATCH_SIZE) => {
47
+ const cutoff = sql`now() - make_interval(mins => ${olderThanMinutes})`;
48
+ let deleted;
49
+ do {
50
+ const batch = await db.select({
51
+ tenantId: streamChunks.tenantId,
52
+ projectId: streamChunks.projectId,
53
+ conversationId: streamChunks.conversationId,
54
+ idx: streamChunks.idx
55
+ }).from(streamChunks).where(sql`${streamChunks.createdAt} < ${cutoff}`).limit(batchSize);
56
+ deleted = batch.length;
57
+ if (deleted > 0) {
58
+ const pks = batch.map((row) => sql`(${row.tenantId}, ${row.projectId}, ${row.conversationId}, ${row.idx})`);
59
+ await db.delete(streamChunks).where(sql`(${streamChunks.tenantId}, ${streamChunks.projectId}, ${streamChunks.conversationId}, ${streamChunks.idx}) IN (${sql.join(pks, sql`, `)})`);
60
+ }
61
+ } while (deleted >= batchSize);
62
+ };
63
+
64
+ //#endregion
65
+ export { cleanupExpiredStreamChunks, deleteStreamChunks, getStreamChunks, insertStreamChunks, markStreamComplete };
@@ -8,19 +8,19 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
8
8
  //#region src/data-access/runtime/tasks.d.ts
9
9
  declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
10
10
  id: string;
11
- createdAt: string;
12
- updatedAt: string;
13
11
  ref: {
14
12
  type: "commit" | "tag" | "branch";
15
13
  name: string;
16
14
  hash: string;
17
15
  } | null;
18
- metadata: TaskMetadataConfig | null;
19
- status: string;
16
+ createdAt: string;
17
+ updatedAt: string;
20
18
  tenantId: string;
21
19
  projectId: string;
20
+ metadata: TaskMetadataConfig | null;
22
21
  agentId: string;
23
22
  subAgentId: string;
23
+ status: string;
24
24
  contextId: string;
25
25
  }>;
26
26
  declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
@@ -0,0 +1,12 @@
1
+ import * as drizzle_orm_pg_core15 from "drizzle-orm/pg-core";
2
+
3
+ //#region src/db/manage/dolt-safe-jsonb.d.ts
4
+ declare function encodeBackslashes(value: unknown): unknown;
5
+ declare function decodeBackslashes(value: unknown): unknown;
6
+ /**
7
+ * Drop-in replacement for drizzle-orm's `jsonb()`.
8
+ * Encodes backslashes on write and decodes on read to work around the Doltgres bug.
9
+ */
10
+ declare function jsonb(name: string): ReturnType<typeof drizzle_orm_pg_core15.jsonb>;
11
+ //#endregion
12
+ export { decodeBackslashes, encodeBackslashes, jsonb };