@inkeep/agents-core 0.0.0-dev-20260403194639 → 0.0.0-dev-20260404213053
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth-schema.d.ts +86 -86
- package/dist/auth/auth-validation-schemas.d.ts +154 -154
- package/dist/auth/auth.d.ts +6 -6
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/data-access/index.d.ts +2 -1
- package/dist/data-access/index.js +2 -1
- package/dist/data-access/manage/agents.d.ts +32 -32
- package/dist/data-access/manage/artifactComponents.d.ts +14 -14
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +4 -4
- package/dist/data-access/manage/functionTools.d.ts +10 -10
- package/dist/data-access/manage/skills.d.ts +8 -8
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +12 -12
- package/dist/data-access/manage/tools.d.ts +18 -18
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +12 -12
- package/dist/data-access/runtime/apps.d.ts +8 -8
- package/dist/data-access/runtime/conversations.d.ts +24 -24
- package/dist/data-access/runtime/messages.d.ts +24 -24
- package/dist/data-access/runtime/streamChunks.d.ts +29 -0
- package/dist/data-access/runtime/streamChunks.js +65 -0
- package/dist/data-access/runtime/tasks.d.ts +5 -5
- package/dist/db/manage/dolt-safe-jsonb.d.ts +2 -2
- package/dist/db/manage/manage-schema.d.ts +449 -449
- package/dist/db/runtime/runtime-schema.d.ts +508 -376
- package/dist/db/runtime/runtime-schema.js +20 -1
- package/dist/dolt/ref-helpers.js +15 -1
- package/dist/dolt/ref-scope.js +29 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/utils/error.d.ts +51 -51
- package/dist/utils/service-token-auth.d.ts +3 -0
- package/dist/utils/service-token-auth.js +5 -2
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas/skills.d.ts +34 -34
- package/dist/validation/schemas.d.ts +2150 -2150
- package/drizzle/runtime/0031_fantastic_gorilla_man.sql +13 -0
- package/drizzle/runtime/meta/0031_snapshot.json +4872 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +1 -1
|
@@ -8,49 +8,49 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
8
8
|
scopes: ProjectScopeConfig;
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
|
-
name: string | null;
|
|
12
11
|
id: string;
|
|
12
|
+
name: string | null;
|
|
13
13
|
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
|
+
expiresAt: string | null;
|
|
16
|
+
agentId: string;
|
|
15
17
|
projectId: string;
|
|
16
18
|
tenantId: string;
|
|
17
|
-
agentId: string;
|
|
18
19
|
publicId: string;
|
|
19
20
|
keyHash: string;
|
|
20
21
|
keyPrefix: string;
|
|
21
22
|
lastUsedAt: string | null;
|
|
22
|
-
expiresAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
|
-
name: string | null;
|
|
26
25
|
id: string;
|
|
26
|
+
name: string | null;
|
|
27
27
|
createdAt: string;
|
|
28
28
|
updatedAt: string;
|
|
29
|
+
expiresAt: string | null;
|
|
30
|
+
agentId: string;
|
|
29
31
|
projectId: string;
|
|
30
32
|
tenantId: string;
|
|
31
|
-
agentId: string;
|
|
32
33
|
publicId: string;
|
|
33
34
|
keyHash: string;
|
|
34
35
|
keyPrefix: string;
|
|
35
36
|
lastUsedAt: string | null;
|
|
36
|
-
expiresAt: 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
|
-
name: string | null;
|
|
43
42
|
id: string;
|
|
43
|
+
name: string | null;
|
|
44
44
|
createdAt: string;
|
|
45
45
|
updatedAt: string;
|
|
46
|
+
expiresAt: string | null;
|
|
47
|
+
agentId: string;
|
|
46
48
|
projectId: string;
|
|
47
49
|
tenantId: string;
|
|
48
|
-
agentId: string;
|
|
49
50
|
publicId: string;
|
|
50
51
|
keyHash: string;
|
|
51
52
|
keyPrefix: string;
|
|
52
53
|
lastUsedAt: string | null;
|
|
53
|
-
expiresAt: string | null;
|
|
54
54
|
}[]>;
|
|
55
55
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
@@ -66,18 +66,18 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
66
66
|
};
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
|
-
name: string | null;
|
|
70
69
|
id: string;
|
|
70
|
+
name: string | null;
|
|
71
71
|
createdAt: string;
|
|
72
72
|
updatedAt: string;
|
|
73
|
+
expiresAt: string | null;
|
|
74
|
+
agentId: string;
|
|
73
75
|
projectId: string;
|
|
74
76
|
tenantId: string;
|
|
75
|
-
agentId: string;
|
|
76
77
|
publicId: string;
|
|
77
78
|
keyHash: string;
|
|
78
79
|
keyPrefix: string;
|
|
79
80
|
lastUsedAt: string | null;
|
|
80
|
-
expiresAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -5,16 +5,16 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
5
5
|
|
|
6
6
|
//#region src/data-access/runtime/apps.d.ts
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
|
-
type: AppType;
|
|
9
|
-
name: string;
|
|
10
|
-
description: string | null;
|
|
11
8
|
id: string;
|
|
9
|
+
name: string;
|
|
12
10
|
createdAt: string;
|
|
13
11
|
updatedAt: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
type: AppType;
|
|
14
15
|
projectId: string | null;
|
|
15
16
|
tenantId: string | null;
|
|
16
17
|
prompt: string | null;
|
|
17
|
-
enabled: boolean;
|
|
18
18
|
config: {
|
|
19
19
|
type: "web_client";
|
|
20
20
|
webClient: {
|
|
@@ -61,16 +61,16 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
61
61
|
};
|
|
62
62
|
}>;
|
|
63
63
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
64
|
-
type: AppType;
|
|
65
|
-
name: string;
|
|
66
|
-
description: string | null;
|
|
67
64
|
id: string;
|
|
65
|
+
name: string;
|
|
68
66
|
createdAt: string;
|
|
69
67
|
updatedAt: string;
|
|
68
|
+
description: string | null;
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
type: AppType;
|
|
70
71
|
projectId: string | null;
|
|
71
72
|
tenantId: string | null;
|
|
72
73
|
prompt: string | null;
|
|
73
|
-
enabled: boolean;
|
|
74
74
|
config: {
|
|
75
75
|
type: "web_client";
|
|
76
76
|
webClient: {
|
|
@@ -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
18
|
id: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
20
21
|
ref: {
|
|
21
22
|
type: "commit" | "tag" | "branch";
|
|
22
23
|
name: string;
|
|
23
24
|
hash: string;
|
|
24
25
|
} | null;
|
|
25
|
-
|
|
26
|
-
updatedAt: string;
|
|
27
|
-
projectId: string;
|
|
28
|
-
tenantId: string;
|
|
26
|
+
userId: string | null;
|
|
29
27
|
metadata: ConversationMetadata | null;
|
|
30
28
|
agentId: string | null;
|
|
31
|
-
|
|
29
|
+
projectId: string;
|
|
30
|
+
tenantId: string;
|
|
31
|
+
title: 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
87
|
id: string;
|
|
88
|
+
createdAt: string;
|
|
89
|
+
updatedAt: string;
|
|
89
90
|
ref: {
|
|
90
91
|
type: "commit" | "tag" | "branch";
|
|
91
92
|
name: string;
|
|
92
93
|
hash: string;
|
|
93
94
|
} | null;
|
|
94
|
-
|
|
95
|
-
updatedAt: string;
|
|
96
|
-
projectId: string;
|
|
97
|
-
tenantId: string;
|
|
95
|
+
userId: string | null;
|
|
98
96
|
metadata: ConversationMetadata | null;
|
|
99
97
|
agentId: string | null;
|
|
100
|
-
|
|
98
|
+
projectId: string;
|
|
99
|
+
tenantId: string;
|
|
100
|
+
title: 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
123
|
id: string;
|
|
124
|
+
createdAt: string;
|
|
125
|
+
updatedAt: string;
|
|
125
126
|
ref: {
|
|
126
127
|
type: "commit" | "tag" | "branch";
|
|
127
128
|
name: string;
|
|
128
129
|
hash: string;
|
|
129
130
|
} | null;
|
|
130
|
-
|
|
131
|
-
updatedAt: string;
|
|
132
|
-
projectId: string;
|
|
133
|
-
tenantId: string;
|
|
131
|
+
userId: string | null;
|
|
134
132
|
metadata: ConversationMetadata | null;
|
|
135
133
|
agentId: string | null;
|
|
136
|
-
|
|
134
|
+
projectId: string;
|
|
135
|
+
tenantId: string;
|
|
136
|
+
title: 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
155
|
id: string;
|
|
156
|
+
createdAt: string;
|
|
157
|
+
updatedAt: string;
|
|
157
158
|
ref: {
|
|
158
159
|
type: "commit" | "tag" | "branch";
|
|
159
160
|
name: string;
|
|
160
161
|
hash: string;
|
|
161
162
|
} | null;
|
|
162
|
-
|
|
163
|
-
updatedAt: string;
|
|
164
|
-
projectId: string;
|
|
165
|
-
tenantId: string;
|
|
163
|
+
userId: string | null;
|
|
166
164
|
metadata: ConversationMetadata | null;
|
|
167
165
|
agentId: string | null;
|
|
168
|
-
|
|
166
|
+
projectId: string;
|
|
167
|
+
tenantId: string;
|
|
168
|
+
title: 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
|
-
fromSubAgentId: string | null;
|
|
14
|
-
toSubAgentId: string | null;
|
|
15
|
-
fromExternalAgentId: string | null;
|
|
16
|
-
toExternalAgentId: string | null;
|
|
17
|
-
taskId: string | null;
|
|
18
|
-
a2aTaskId: string | null;
|
|
19
13
|
id: string;
|
|
20
14
|
createdAt: string;
|
|
21
15
|
updatedAt: string;
|
|
16
|
+
metadata: MessageMetadata | null;
|
|
17
|
+
role: string;
|
|
22
18
|
projectId: string;
|
|
23
19
|
tenantId: string;
|
|
24
|
-
metadata: MessageMetadata | null;
|
|
25
20
|
content: MessageContent;
|
|
26
21
|
conversationId: string;
|
|
27
|
-
|
|
22
|
+
fromSubAgentId: string | null;
|
|
23
|
+
toSubAgentId: string | null;
|
|
24
|
+
fromExternalAgentId: string | null;
|
|
25
|
+
toExternalAgentId: string | null;
|
|
28
26
|
fromTeamAgentId: string | null;
|
|
29
27
|
toTeamAgentId: string | null;
|
|
30
28
|
visibility: string;
|
|
31
29
|
messageType: string;
|
|
30
|
+
taskId: string | null;
|
|
32
31
|
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
|
-
fromSubAgentId: string | null;
|
|
148
|
-
toSubAgentId: string | null;
|
|
149
|
-
fromExternalAgentId: string | null;
|
|
150
|
-
toExternalAgentId: string | null;
|
|
151
|
-
taskId: string | null;
|
|
152
|
-
a2aTaskId: string | null;
|
|
153
147
|
id: string;
|
|
154
148
|
createdAt: string;
|
|
155
149
|
updatedAt: string;
|
|
150
|
+
metadata: MessageMetadata | null;
|
|
151
|
+
role: string;
|
|
156
152
|
projectId: string;
|
|
157
153
|
tenantId: string;
|
|
158
|
-
metadata: MessageMetadata | null;
|
|
159
154
|
content: MessageContent;
|
|
160
155
|
conversationId: string;
|
|
161
|
-
|
|
156
|
+
fromSubAgentId: string | null;
|
|
157
|
+
toSubAgentId: string | null;
|
|
158
|
+
fromExternalAgentId: string | null;
|
|
159
|
+
toExternalAgentId: string | null;
|
|
162
160
|
fromTeamAgentId: string | null;
|
|
163
161
|
toTeamAgentId: string | null;
|
|
164
162
|
visibility: string;
|
|
165
163
|
messageType: string;
|
|
164
|
+
taskId: string | null;
|
|
166
165
|
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
|
-
fromSubAgentId: string | null;
|
|
201
|
-
toSubAgentId: string | null;
|
|
202
|
-
fromExternalAgentId: string | null;
|
|
203
|
-
toExternalAgentId: string | null;
|
|
204
|
-
taskId: string | null;
|
|
205
|
-
a2aTaskId: string | null;
|
|
206
200
|
id: string;
|
|
207
201
|
createdAt: string;
|
|
208
202
|
updatedAt: string;
|
|
203
|
+
metadata: MessageMetadata | null;
|
|
204
|
+
role: string;
|
|
209
205
|
projectId: string;
|
|
210
206
|
tenantId: string;
|
|
211
|
-
metadata: MessageMetadata | null;
|
|
212
207
|
content: MessageContent;
|
|
213
208
|
conversationId: string;
|
|
214
|
-
|
|
209
|
+
fromSubAgentId: string | null;
|
|
210
|
+
toSubAgentId: string | null;
|
|
211
|
+
fromExternalAgentId: string | null;
|
|
212
|
+
toExternalAgentId: string | null;
|
|
215
213
|
fromTeamAgentId: string | null;
|
|
216
214
|
toTeamAgentId: string | null;
|
|
217
215
|
visibility: string;
|
|
218
216
|
messageType: string;
|
|
217
|
+
taskId: string | null;
|
|
219
218
|
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,21 +7,21 @@ 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
|
-
subAgentId: string;
|
|
11
10
|
id: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
12
13
|
ref: {
|
|
13
14
|
type: "commit" | "tag" | "branch";
|
|
14
15
|
name: string;
|
|
15
16
|
hash: string;
|
|
16
17
|
} | null;
|
|
17
|
-
createdAt: string;
|
|
18
|
-
updatedAt: string;
|
|
19
|
-
projectId: string;
|
|
20
|
-
tenantId: string;
|
|
21
18
|
metadata: TaskMetadataConfig | null;
|
|
22
19
|
status: string;
|
|
23
20
|
agentId: string;
|
|
21
|
+
projectId: string;
|
|
22
|
+
tenantId: string;
|
|
24
23
|
contextId: string;
|
|
24
|
+
subAgentId: string;
|
|
25
25
|
}>;
|
|
26
26
|
declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
27
27
|
id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as drizzle_orm_pg_core1809 from "drizzle-orm/pg-core";
|
|
2
2
|
|
|
3
3
|
//#region src/db/manage/dolt-safe-jsonb.d.ts
|
|
4
4
|
declare function encodeBackslashes(value: unknown): unknown;
|
|
@@ -7,6 +7,6 @@ declare function decodeBackslashes(value: unknown): unknown;
|
|
|
7
7
|
* Drop-in replacement for drizzle-orm's `jsonb()`.
|
|
8
8
|
* Encodes backslashes on write and decodes on read to work around the Doltgres bug.
|
|
9
9
|
*/
|
|
10
|
-
declare function jsonb(name: string): ReturnType<typeof
|
|
10
|
+
declare function jsonb(name: string): ReturnType<typeof drizzle_orm_pg_core1809.jsonb>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { decodeBackslashes, encodeBackslashes, jsonb };
|