@inkeep/agents-core 0.0.0-dev-20260403190627 → 0.0.0-dev-20260404012728

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 (47) hide show
  1. package/dist/auth/auth-schema.d.ts +108 -108
  2. package/dist/auth/auth-validation-schemas.d.ts +17 -17
  3. package/dist/auth/auth.d.ts +6 -6
  4. package/dist/auth/permissions.d.ts +13 -13
  5. package/dist/data-access/index.d.ts +2 -1
  6. package/dist/data-access/index.js +2 -1
  7. package/dist/data-access/manage/agents.d.ts +29 -29
  8. package/dist/data-access/manage/artifactComponents.d.ts +12 -12
  9. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  10. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  11. package/dist/data-access/manage/functionTools.d.ts +14 -14
  12. package/dist/data-access/manage/skills.d.ts +13 -13
  13. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
  14. package/dist/data-access/manage/subAgentRelations.d.ts +26 -26
  15. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
  16. package/dist/data-access/manage/subAgents.d.ts +15 -15
  17. package/dist/data-access/manage/tools.d.ts +27 -27
  18. package/dist/data-access/manage/tools.js +1 -1
  19. package/dist/data-access/manage/triggers.d.ts +2 -2
  20. package/dist/data-access/runtime/apiKeys.d.ts +16 -16
  21. package/dist/data-access/runtime/apps.d.ts +16 -16
  22. package/dist/data-access/runtime/conversations.d.ts +24 -24
  23. package/dist/data-access/runtime/messages.d.ts +27 -27
  24. package/dist/data-access/runtime/streamChunks.d.ts +29 -0
  25. package/dist/data-access/runtime/streamChunks.js +65 -0
  26. package/dist/data-access/runtime/tasks.d.ts +6 -6
  27. package/dist/db/manage/dolt-safe-jsonb.d.ts +12 -0
  28. package/dist/db/manage/dolt-safe-jsonb.js +61 -0
  29. package/dist/db/manage/manage-schema.d.ts +487 -487
  30. package/dist/db/manage/manage-schema.js +40 -39
  31. package/dist/db/runtime/runtime-schema.d.ts +508 -376
  32. package/dist/db/runtime/runtime-schema.js +20 -1
  33. package/dist/dolt/ref-helpers.js +15 -1
  34. package/dist/dolt/ref-scope.js +29 -1
  35. package/dist/index.d.ts +3 -2
  36. package/dist/index.js +3 -2
  37. package/dist/middleware/no-auth.d.ts +2 -2
  38. package/dist/utils/error.d.ts +51 -51
  39. package/dist/utils/service-token-auth.d.ts +3 -0
  40. package/dist/utils/service-token-auth.js +5 -2
  41. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  42. package/dist/validation/schemas/skills.d.ts +47 -47
  43. package/dist/validation/schemas.d.ts +2361 -2361
  44. package/drizzle/runtime/0031_fantastic_gorilla_man.sql +13 -0
  45. package/drizzle/runtime/meta/0031_snapshot.json +4872 -0
  46. package/drizzle/runtime/meta/_journal.json +7 -0
  47. package/package.json +1 -1
@@ -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
23
  name: string;
25
- createdAt: string;
26
- updatedAt: string;
27
24
  description: string | null;
28
25
  tenantId: string;
29
26
  projectId: string;
30
- credentialReferenceId: string | null;
27
+ id: string;
28
+ createdAt: string;
29
+ updatedAt: string;
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
81
  name: string;
83
- createdAt: string;
84
- updatedAt: string;
85
82
  description: string | null;
86
83
  tenantId: string;
87
84
  projectId: string;
88
- credentialReferenceId: string | null;
85
+ id: string;
86
+ createdAt: string;
87
+ updatedAt: string;
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;
@@ -135,38 +135,38 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
135
135
  needsApproval?: boolean;
136
136
  }> | null;
137
137
  }) => Promise<{
138
+ tenantId: string;
139
+ projectId: string;
140
+ subAgentId: string;
138
141
  id: string;
139
142
  createdAt: string;
140
143
  updatedAt: string;
141
- tenantId: string;
142
- projectId: string;
143
144
  agentId: string;
144
145
  toolId: string;
145
- subAgentId: string;
146
146
  headers: Record<string, string> | null;
147
- selectedTools: string[] | null;
148
147
  toolPolicies: Record<string, {
149
148
  needsApproval?: boolean;
150
149
  }> | null;
150
+ selectedTools: string[] | null;
151
151
  }>;
152
152
  declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
153
153
  scopes: AgentScopeConfig;
154
154
  subAgentId: string;
155
155
  toolId: string;
156
156
  }) => Promise<{
157
+ tenantId: string;
158
+ projectId: string;
159
+ subAgentId: string;
157
160
  id: string;
158
161
  createdAt: string;
159
162
  updatedAt: string;
160
- tenantId: string;
161
- projectId: string;
162
163
  agentId: string;
163
164
  toolId: string;
164
- subAgentId: string;
165
165
  headers: Record<string, string> | null;
166
- selectedTools: string[] | null;
167
166
  toolPolicies: Record<string, {
168
167
  needsApproval?: boolean;
169
168
  }> | 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)
@@ -182,19 +182,19 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
182
182
  }> | null;
183
183
  relationId?: string;
184
184
  }) => Promise<{
185
+ tenantId: string;
186
+ projectId: string;
187
+ subAgentId: string;
185
188
  id: string;
186
189
  createdAt: string;
187
190
  updatedAt: string;
188
- tenantId: string;
189
- projectId: string;
190
191
  agentId: string;
191
192
  toolId: string;
192
- subAgentId: string;
193
193
  headers: Record<string, string> | null;
194
- selectedTools: string[] | null;
195
194
  toolPolicies: Record<string, {
196
195
  needsApproval?: boolean;
197
196
  }> | null;
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
205
  name: string;
207
- createdAt: string;
208
- updatedAt: string;
209
206
  description: string | null;
210
207
  tenantId: string;
211
208
  projectId: string;
212
- credentialReferenceId: string | null;
209
+ id: string;
210
+ createdAt: string;
211
+ updatedAt: string;
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;
@@ -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 {
@@ -37,8 +37,8 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
37
37
  authentication: unknown;
38
38
  signingSecretCredentialReferenceId: string | null;
39
39
  signatureVerification: {
40
- algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
41
- encoding: "hex" | "base64";
40
+ algorithm: "md5" | "sha256" | "sha512" | "sha384" | "sha1";
41
+ encoding: "base64" | "hex";
42
42
  signature: {
43
43
  source: "query" | "header" | "body";
44
44
  key: string;
@@ -8,28 +8,28 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
8
8
  scopes: ProjectScopeConfig;
9
9
  id: string;
10
10
  }) => Promise<{
11
- id: string;
12
11
  name: string | null;
13
- createdAt: string;
14
- updatedAt: string;
15
- expiresAt: string | null;
16
12
  tenantId: string;
17
13
  projectId: string;
14
+ id: string;
15
+ createdAt: string;
16
+ updatedAt: string;
18
17
  agentId: string;
18
+ expiresAt: string | null;
19
19
  publicId: string;
20
20
  keyHash: string;
21
21
  keyPrefix: string;
22
22
  lastUsedAt: string | null;
23
23
  } | undefined>;
24
24
  declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
25
- id: string;
26
25
  name: string | null;
27
- createdAt: string;
28
- updatedAt: string;
29
- expiresAt: string | null;
30
26
  tenantId: string;
31
27
  projectId: string;
28
+ id: string;
29
+ createdAt: string;
30
+ updatedAt: string;
32
31
  agentId: string;
32
+ expiresAt: string | null;
33
33
  publicId: string;
34
34
  keyHash: string;
35
35
  keyPrefix: string;
@@ -39,14 +39,14 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
39
39
  scopes: ProjectScopeConfig;
40
40
  agentId?: string;
41
41
  }) => Promise<{
42
- id: string;
43
42
  name: string | null;
44
- createdAt: string;
45
- updatedAt: string;
46
- expiresAt: string | null;
47
43
  tenantId: string;
48
44
  projectId: string;
45
+ id: string;
46
+ createdAt: string;
47
+ updatedAt: string;
49
48
  agentId: string;
49
+ expiresAt: string | null;
50
50
  publicId: string;
51
51
  keyHash: string;
52
52
  keyPrefix: string;
@@ -66,14 +66,14 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
66
66
  };
67
67
  }>;
68
68
  declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
69
- id: string;
70
69
  name: string | null;
71
- createdAt: string;
72
- updatedAt: string;
73
- expiresAt: string | null;
74
70
  tenantId: string;
75
71
  projectId: string;
72
+ id: string;
73
+ createdAt: string;
74
+ updatedAt: string;
76
75
  agentId: string;
76
+ expiresAt: string | null;
77
77
  publicId: string;
78
78
  keyHash: string;
79
79
  keyPrefix: string;
@@ -6,15 +6,18 @@ 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
  enabled: boolean;
9
- id: string;
10
9
  name: string;
11
- createdAt: string;
12
- updatedAt: string;
13
- description: string | null;
14
10
  type: AppType;
11
+ description: string | null;
15
12
  tenantId: string | null;
16
- prompt: string | null;
17
13
  projectId: string | null;
14
+ id: string;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ lastUsedAt: string | null;
18
+ defaultProjectId: string | null;
19
+ defaultAgentId: string | null;
20
+ prompt: string | null;
18
21
  config: {
19
22
  type: "web_client";
20
23
  webClient: {
@@ -32,9 +35,6 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
32
35
  type: "api";
33
36
  api: Record<string, never>;
34
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,18 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
62
62
  }>;
63
63
  declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
64
64
  enabled: boolean;
65
- id: string;
66
65
  name: string;
67
- createdAt: string;
68
- updatedAt: string;
69
- description: string | null;
70
66
  type: AppType;
67
+ description: string | null;
71
68
  tenantId: string | null;
72
- prompt: string | null;
73
69
  projectId: string | null;
70
+ id: string;
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ lastUsedAt: string | null;
74
+ defaultProjectId: string | null;
75
+ defaultAgentId: string | null;
76
+ prompt: string | null;
74
77
  config: {
75
78
  type: "web_client";
76
79
  webClient: {
@@ -88,9 +91,6 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
88
91
  type: "api";
89
92
  api: Record<string, never>;
90
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;
19
+ tenantId: string;
20
+ projectId: string;
18
21
  id: string;
19
- createdAt: string;
20
- updatedAt: string;
21
22
  ref: {
22
23
  type: "commit" | "tag" | "branch";
23
24
  name: string;
24
25
  hash: string;
25
26
  } | null;
26
- userId: string | null;
27
+ createdAt: string;
28
+ updatedAt: string;
27
29
  metadata: ConversationMetadata | null;
28
- title: string | null;
29
- tenantId: string;
30
- projectId: string;
31
30
  agentId: string | null;
31
+ userId: string | 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;
88
+ tenantId: string;
89
+ projectId: string;
87
90
  id: string;
88
- createdAt: string;
89
- updatedAt: string;
90
91
  ref: {
91
92
  type: "commit" | "tag" | "branch";
92
93
  name: string;
93
94
  hash: string;
94
95
  } | null;
95
- userId: string | null;
96
+ createdAt: string;
97
+ updatedAt: string;
96
98
  metadata: ConversationMetadata | null;
97
- title: string | null;
98
- tenantId: string;
99
- projectId: string;
100
99
  agentId: string | null;
100
+ userId: string | 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;
124
+ tenantId: string;
125
+ projectId: string;
123
126
  id: string;
124
- createdAt: string;
125
- updatedAt: string;
126
127
  ref: {
127
128
  type: "commit" | "tag" | "branch";
128
129
  name: string;
129
130
  hash: string;
130
131
  } | null;
131
- userId: string | null;
132
+ createdAt: string;
133
+ updatedAt: string;
132
134
  metadata: ConversationMetadata | null;
133
- title: string | null;
134
- tenantId: string;
135
- projectId: string;
136
135
  agentId: string | null;
136
+ userId: 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
+ title: string | null;
156
+ tenantId: string;
157
+ projectId: string;
155
158
  id: string;
156
- createdAt: string;
157
- updatedAt: string;
158
159
  ref: {
159
160
  type: "commit" | "tag" | "branch";
160
161
  name: string;
161
162
  hash: string;
162
163
  } | null;
163
- userId: string | null;
164
+ createdAt: string;
165
+ updatedAt: string;
164
166
  metadata: ConversationMetadata | null;
165
- title: string | null;
166
- tenantId: string;
167
- projectId: string;
168
167
  agentId: string | null;
168
+ userId: string | null;
169
169
  activeSubAgentId: string;
170
170
  lastContextResolution: string | null;
171
171
  } | undefined>;
@@ -10,26 +10,26 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
10
10
  scopes: ProjectScopeConfig;
11
11
  messageId: string;
12
12
  }) => Promise<{
13
- id: string;
14
- createdAt: string;
15
- updatedAt: string;
16
- metadata: MessageMetadata | null;
17
- role: string;
13
+ content: MessageContent;
18
14
  tenantId: string;
19
15
  projectId: string;
20
- content: MessageContent;
21
- conversationId: string;
22
16
  fromSubAgentId: string | null;
23
17
  toSubAgentId: string | null;
24
18
  fromExternalAgentId: string | null;
25
19
  toExternalAgentId: string | null;
20
+ taskId: string | null;
21
+ a2aTaskId: string | null;
22
+ id: string;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ metadata: MessageMetadata | null;
26
+ role: string;
27
+ conversationId: string;
26
28
  fromTeamAgentId: string | null;
27
29
  toTeamAgentId: string | null;
28
30
  visibility: string;
29
31
  messageType: string;
30
- taskId: string | null;
31
32
  parentMessageId: string | null;
32
- a2aTaskId: string | null;
33
33
  a2aSessionId: string | null;
34
34
  } | undefined>;
35
35
  declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
@@ -144,26 +144,26 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
144
144
  scopes: ProjectScopeConfig;
145
145
  data: Omit<MessageInsert, "tenantId" | "projectId">;
146
146
  }) => Promise<{
147
- id: string;
148
- createdAt: string;
149
- updatedAt: string;
150
- metadata: MessageMetadata | null;
151
- role: string;
147
+ content: MessageContent;
152
148
  tenantId: string;
153
149
  projectId: string;
154
- content: MessageContent;
155
- conversationId: string;
156
150
  fromSubAgentId: string | null;
157
151
  toSubAgentId: string | null;
158
152
  fromExternalAgentId: string | null;
159
153
  toExternalAgentId: string | null;
154
+ taskId: string | null;
155
+ a2aTaskId: string | null;
156
+ id: string;
157
+ createdAt: string;
158
+ updatedAt: string;
159
+ metadata: MessageMetadata | null;
160
+ role: string;
161
+ conversationId: string;
160
162
  fromTeamAgentId: string | null;
161
163
  toTeamAgentId: string | null;
162
164
  visibility: string;
163
165
  messageType: string;
164
- taskId: string | null;
165
166
  parentMessageId: string | null;
166
- a2aTaskId: string | null;
167
167
  a2aSessionId: string | null;
168
168
  }>;
169
169
  declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
@@ -197,26 +197,26 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
197
197
  scopes: ProjectScopeConfig;
198
198
  messageId: string;
199
199
  }) => Promise<{
200
- id: string;
201
- createdAt: string;
202
- updatedAt: string;
203
- metadata: MessageMetadata | null;
204
- role: string;
200
+ content: MessageContent;
205
201
  tenantId: string;
206
202
  projectId: string;
207
- content: MessageContent;
208
- conversationId: string;
209
203
  fromSubAgentId: string | null;
210
204
  toSubAgentId: string | null;
211
205
  fromExternalAgentId: string | null;
212
206
  toExternalAgentId: string | null;
207
+ taskId: string | null;
208
+ a2aTaskId: string | null;
209
+ id: string;
210
+ createdAt: string;
211
+ updatedAt: string;
212
+ metadata: MessageMetadata | null;
213
+ role: string;
214
+ conversationId: string;
213
215
  fromTeamAgentId: string | null;
214
216
  toTeamAgentId: string | null;
215
217
  visibility: string;
216
218
  messageType: string;
217
- taskId: string | null;
218
219
  parentMessageId: string | null;
219
- a2aTaskId: string | null;
220
220
  a2aSessionId: string | null;
221
221
  }>;
222
222
  declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
@@ -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 };
@@ -7,20 +7,20 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
7
7
 
8
8
  //#region src/data-access/runtime/tasks.d.ts
9
9
  declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
10
+ tenantId: string;
11
+ projectId: string;
12
+ status: string;
13
+ subAgentId: string;
10
14
  id: string;
11
- createdAt: string;
12
- updatedAt: string;
13
15
  ref: {
14
16
  type: "commit" | "tag" | "branch";
15
17
  name: string;
16
18
  hash: string;
17
19
  } | null;
20
+ createdAt: string;
21
+ updatedAt: string;
18
22
  metadata: TaskMetadataConfig | null;
19
- status: string;
20
- tenantId: string;
21
- projectId: string;
22
23
  agentId: string;
23
- subAgentId: 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_core220 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_core220.jsonb>;
11
+ //#endregion
12
+ export { decodeBackslashes, encodeBackslashes, jsonb };