@agentforge-ai/cli 0.5.0 → 0.5.2
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/default/agentforge.config.ts +78 -0
- package/dist/default/convex/agents.ts +16 -16
- package/dist/default/convex/apiKeys.ts +7 -7
- package/dist/default/convex/cronJobs.ts +12 -12
- package/dist/default/convex/files.ts +7 -7
- package/dist/default/convex/folders.ts +11 -11
- package/dist/default/convex/heartbeat.ts +20 -20
- package/dist/default/convex/mastraIntegration.ts +3 -2
- package/dist/default/convex/mcpConnections.ts +5 -5
- package/dist/default/convex/messages.ts +4 -4
- package/dist/default/convex/projects.ts +10 -10
- package/dist/default/convex/schema.ts +150 -83
- package/dist/default/convex/sessions.ts +12 -12
- package/dist/default/convex/settings.ts +3 -3
- package/dist/default/convex/skills.ts +8 -8
- package/dist/default/convex/threads.ts +9 -9
- package/dist/default/convex/usage.ts +16 -16
- package/dist/default/convex/vault.ts +50 -33
- package/dist/default/package.json +1 -0
- package/dist/default/tsconfig.json +1 -0
- package/dist/index.js +691 -84
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/templates/default/agentforge.config.ts +78 -0
- package/templates/default/convex/agents.ts +16 -16
- package/templates/default/convex/apiKeys.ts +7 -7
- package/templates/default/convex/cronJobs.ts +12 -12
- package/templates/default/convex/files.ts +7 -7
- package/templates/default/convex/folders.ts +11 -11
- package/templates/default/convex/heartbeat.ts +20 -20
- package/templates/default/convex/mastraIntegration.ts +3 -2
- package/templates/default/convex/mcpConnections.ts +5 -5
- package/templates/default/convex/messages.ts +4 -4
- package/templates/default/convex/projects.ts +10 -10
- package/templates/default/convex/schema.ts +150 -83
- package/templates/default/convex/sessions.ts +12 -12
- package/templates/default/convex/settings.ts +3 -3
- package/templates/default/convex/skills.ts +8 -8
- package/templates/default/convex/threads.ts +9 -9
- package/templates/default/convex/usage.ts +16 -16
- package/templates/default/convex/vault.ts +50 -33
- package/templates/default/package.json +1 -0
- package/templates/default/tsconfig.json +1 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example AgentForge Configuration File
|
|
3
|
+
*
|
|
4
|
+
* This file defines your agents and their configurations.
|
|
5
|
+
* The CLI uses this to deploy to AgentForge Cloud.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
name: 'my-agent-project',
|
|
10
|
+
version: '1.0.0',
|
|
11
|
+
|
|
12
|
+
agents: [
|
|
13
|
+
{
|
|
14
|
+
id: 'support-agent',
|
|
15
|
+
name: 'Customer Support Agent',
|
|
16
|
+
model: 'gpt-4o',
|
|
17
|
+
instructions: `You are a helpful customer support agent.
|
|
18
|
+
|
|
19
|
+
Be polite, professional, and try to resolve customer issues quickly.
|
|
20
|
+
If you don't know the answer, escalate to a human agent.`,
|
|
21
|
+
tools: [
|
|
22
|
+
{
|
|
23
|
+
name: 'searchKnowledgeBase',
|
|
24
|
+
description: 'Search the knowledge base for articles',
|
|
25
|
+
parameters: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
query: { type: 'string' },
|
|
29
|
+
},
|
|
30
|
+
required: ['query'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'createTicket',
|
|
35
|
+
description: 'Create a support ticket',
|
|
36
|
+
parameters: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
subject: { type: 'string' },
|
|
40
|
+
description: { type: 'string' },
|
|
41
|
+
priority: { type: 'string', enum: ['low', 'medium', 'high'] },
|
|
42
|
+
},
|
|
43
|
+
required: ['subject', 'description'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'code-assistant',
|
|
50
|
+
name: 'Code Assistant',
|
|
51
|
+
model: 'anthropic/claude-3-opus',
|
|
52
|
+
instructions: `You are an expert programming assistant.
|
|
53
|
+
|
|
54
|
+
Help users write clean, efficient, and well-documented code.
|
|
55
|
+
Explain your reasoning and provide examples when helpful.`,
|
|
56
|
+
tools: [
|
|
57
|
+
{
|
|
58
|
+
name: 'runCode',
|
|
59
|
+
description: 'Execute code in a sandboxed environment',
|
|
60
|
+
parameters: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
language: { type: 'string', enum: ['javascript', 'python', 'typescript'] },
|
|
64
|
+
code: { type: 'string' },
|
|
65
|
+
},
|
|
66
|
+
required: ['language', 'code'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
|
|
73
|
+
// Optional: Environment variables available to all agents
|
|
74
|
+
env: {
|
|
75
|
+
SUPPORT_EMAIL: 'support@example.com',
|
|
76
|
+
COMPANY_NAME: 'Acme Inc',
|
|
77
|
+
},
|
|
78
|
+
};
|
|
@@ -11,10 +11,10 @@ export const list = query({
|
|
|
11
11
|
if (args.userId) {
|
|
12
12
|
return await ctx.db
|
|
13
13
|
.query("agents")
|
|
14
|
-
.withIndex("byUserId", (q) => q.eq("userId", args.userId))
|
|
15
|
-
.
|
|
14
|
+
.withIndex("byUserId", (q) => q.eq("userId", args.userId!))
|
|
15
|
+
.collect();
|
|
16
16
|
}
|
|
17
|
-
return await ctx.db.query("agents").
|
|
17
|
+
return await ctx.db.query("agents").collect();
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
|
|
@@ -24,7 +24,7 @@ export const get = query({
|
|
|
24
24
|
handler: async (ctx, args) => {
|
|
25
25
|
return await ctx.db
|
|
26
26
|
.query("agents")
|
|
27
|
-
.withIndex("byAgentId", (q) => q.eq("id", args.id))
|
|
27
|
+
.withIndex("byAgentId", (q) => q.eq("id", args.id!))
|
|
28
28
|
.first();
|
|
29
29
|
},
|
|
30
30
|
});
|
|
@@ -35,11 +35,11 @@ export const listActive = query({
|
|
|
35
35
|
userId: v.optional(v.string()),
|
|
36
36
|
},
|
|
37
37
|
handler: async (ctx, args) => {
|
|
38
|
-
|
|
38
|
+
const activeQuery = ctx.db
|
|
39
39
|
.query("agents")
|
|
40
40
|
.withIndex("byIsActive", (q) => q.eq("isActive", true));
|
|
41
41
|
|
|
42
|
-
const agents = await
|
|
42
|
+
const agents = await activeQuery.collect();
|
|
43
43
|
|
|
44
44
|
if (args.userId) {
|
|
45
45
|
return agents.filter((agent) => agent.userId === args.userId);
|
|
@@ -117,7 +117,7 @@ export const remove = mutation({
|
|
|
117
117
|
handler: async (ctx, args) => {
|
|
118
118
|
const agent = await ctx.db
|
|
119
119
|
.query("agents")
|
|
120
|
-
.withIndex("byAgentId", (q) => q.eq("id", args.id))
|
|
120
|
+
.withIndex("byAgentId", (q) => q.eq("id", args.id!))
|
|
121
121
|
.first();
|
|
122
122
|
|
|
123
123
|
if (!agent) {
|
|
@@ -135,7 +135,7 @@ export const toggleActive = mutation({
|
|
|
135
135
|
handler: async (ctx, args) => {
|
|
136
136
|
const agent = await ctx.db
|
|
137
137
|
.query("agents")
|
|
138
|
-
.withIndex("byAgentId", (q) => q.eq("id", args.id))
|
|
138
|
+
.withIndex("byAgentId", (q) => q.eq("id", args.id!))
|
|
139
139
|
.first();
|
|
140
140
|
|
|
141
141
|
if (!agent) {
|
|
@@ -159,7 +159,7 @@ export const run = action({
|
|
|
159
159
|
threadId: v.optional(v.id("threads")),
|
|
160
160
|
userId: v.optional(v.string()),
|
|
161
161
|
},
|
|
162
|
-
handler: async (ctx, args) => {
|
|
162
|
+
handler: async (ctx, args): Promise<{ threadId: string; message: string; agentId: string }> => {
|
|
163
163
|
// Get agent configuration
|
|
164
164
|
const agent = await ctx.runQuery(api.agents.get, { id: args.agentId });
|
|
165
165
|
|
|
@@ -186,19 +186,19 @@ export const run = action({
|
|
|
186
186
|
// TODO: Integrate with Mastra to run the agent
|
|
187
187
|
// This will be implemented in the Mastra integration phase
|
|
188
188
|
// For now, return a placeholder response
|
|
189
|
-
const
|
|
190
|
-
threadId,
|
|
191
|
-
message: "Agent execution will be implemented with Mastra integration",
|
|
192
|
-
agentId: args.agentId,
|
|
193
|
-
};
|
|
189
|
+
const responseMessage = "Agent execution will be implemented with Mastra integration";
|
|
194
190
|
|
|
195
191
|
// Add assistant message placeholder
|
|
196
192
|
await ctx.runMutation(api.messages.add, {
|
|
197
193
|
threadId,
|
|
198
194
|
role: "assistant",
|
|
199
|
-
content:
|
|
195
|
+
content: responseMessage,
|
|
200
196
|
});
|
|
201
197
|
|
|
202
|
-
return
|
|
198
|
+
return {
|
|
199
|
+
threadId: threadId as string,
|
|
200
|
+
message: responseMessage,
|
|
201
|
+
agentId: args.agentId,
|
|
202
|
+
};
|
|
203
203
|
},
|
|
204
204
|
});
|
|
@@ -11,8 +11,8 @@ export const list = query({
|
|
|
11
11
|
if (args.provider) {
|
|
12
12
|
const keys = await ctx.db
|
|
13
13
|
.query("apiKeys")
|
|
14
|
-
.withIndex("byProvider", (q) => q.eq("provider", args.provider))
|
|
15
|
-
.
|
|
14
|
+
.withIndex("byProvider", (q) => q.eq("provider", args.provider!))
|
|
15
|
+
.collect();
|
|
16
16
|
|
|
17
17
|
if (args.userId) {
|
|
18
18
|
return keys.filter((k) => k.userId === args.userId);
|
|
@@ -23,11 +23,11 @@ export const list = query({
|
|
|
23
23
|
if (args.userId) {
|
|
24
24
|
return await ctx.db
|
|
25
25
|
.query("apiKeys")
|
|
26
|
-
.withIndex("byUserId", (q) => q.eq("userId", args.userId))
|
|
27
|
-
.
|
|
26
|
+
.withIndex("byUserId", (q) => q.eq("userId", args.userId!))
|
|
27
|
+
.collect();
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
return await ctx.db.query("apiKeys").
|
|
30
|
+
return await ctx.db.query("apiKeys").collect();
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -48,8 +48,8 @@ export const getActiveForProvider = query({
|
|
|
48
48
|
handler: async (ctx, args) => {
|
|
49
49
|
const keys = await ctx.db
|
|
50
50
|
.query("apiKeys")
|
|
51
|
-
.withIndex("byProvider", (q) => q.eq("provider", args.provider))
|
|
52
|
-
.
|
|
51
|
+
.withIndex("byProvider", (q) => q.eq("provider", args.provider!))
|
|
52
|
+
.collect();
|
|
53
53
|
|
|
54
54
|
const activeKeys = keys.filter((k) => k.isActive);
|
|
55
55
|
|
|
@@ -12,8 +12,8 @@ export const list = query({
|
|
|
12
12
|
if (args.isEnabled !== undefined) {
|
|
13
13
|
const jobs = await ctx.db
|
|
14
14
|
.query("cronJobs")
|
|
15
|
-
.withIndex("byIsEnabled", (q) => q.eq("isEnabled", args.isEnabled))
|
|
16
|
-
.
|
|
15
|
+
.withIndex("byIsEnabled", (q) => q.eq("isEnabled", args.isEnabled!))
|
|
16
|
+
.collect();
|
|
17
17
|
|
|
18
18
|
if (args.userId) {
|
|
19
19
|
return jobs.filter((j) => j.userId === args.userId);
|
|
@@ -27,18 +27,18 @@ export const list = query({
|
|
|
27
27
|
if (args.agentId) {
|
|
28
28
|
return await ctx.db
|
|
29
29
|
.query("cronJobs")
|
|
30
|
-
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId))
|
|
31
|
-
.
|
|
30
|
+
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId!))
|
|
31
|
+
.collect();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (args.userId) {
|
|
35
35
|
return await ctx.db
|
|
36
36
|
.query("cronJobs")
|
|
37
|
-
.withIndex("byUserId", (q) => q.eq("userId", args.userId))
|
|
38
|
-
.
|
|
37
|
+
.withIndex("byUserId", (q) => q.eq("userId", args.userId!))
|
|
38
|
+
.collect();
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
return await ctx.db.query("cronJobs").
|
|
41
|
+
return await ctx.db.query("cronJobs").collect();
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -58,7 +58,7 @@ export const getDueJobs = query({
|
|
|
58
58
|
const jobs = await ctx.db
|
|
59
59
|
.query("cronJobs")
|
|
60
60
|
.withIndex("byNextRun")
|
|
61
|
-
.
|
|
61
|
+
.collect();
|
|
62
62
|
|
|
63
63
|
return jobs.filter((j) => j.isEnabled && j.nextRun && j.nextRun <= now);
|
|
64
64
|
},
|
|
@@ -162,8 +162,8 @@ export const remove = mutation({
|
|
|
162
162
|
// Delete all run history
|
|
163
163
|
const runs = await ctx.db
|
|
164
164
|
.query("cronJobRuns")
|
|
165
|
-
.withIndex("byCronJobId", (q) => q.eq("cronJobId", args.id))
|
|
166
|
-
.
|
|
165
|
+
.withIndex("byCronJobId", (q) => q.eq("cronJobId", args.id!))
|
|
166
|
+
.collect();
|
|
167
167
|
|
|
168
168
|
for (const run of runs) {
|
|
169
169
|
await ctx.db.delete(run._id);
|
|
@@ -209,8 +209,8 @@ export const getRunHistory = query({
|
|
|
209
209
|
handler: async (ctx, args) => {
|
|
210
210
|
const runs = await ctx.db
|
|
211
211
|
.query("cronJobRuns")
|
|
212
|
-
.withIndex("byCronJobId", (q) => q.eq("cronJobId", args.cronJobId))
|
|
213
|
-
.
|
|
212
|
+
.withIndex("byCronJobId", (q) => q.eq("cronJobId", args.cronJobId!))
|
|
213
|
+
.collect();
|
|
214
214
|
|
|
215
215
|
// Sort by startedAt descending
|
|
216
216
|
runs.sort((a, b) => b.startedAt - a.startedAt);
|
|
@@ -12,25 +12,25 @@ export const list = query({
|
|
|
12
12
|
if (args.folderId) {
|
|
13
13
|
return await ctx.db
|
|
14
14
|
.query("files")
|
|
15
|
-
.withIndex("byFolderId", (q) => q.eq("folderId", args.folderId))
|
|
16
|
-
.
|
|
15
|
+
.withIndex("byFolderId", (q) => q.eq("folderId", args.folderId!))
|
|
16
|
+
.collect();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if (args.projectId) {
|
|
20
20
|
return await ctx.db
|
|
21
21
|
.query("files")
|
|
22
|
-
.withIndex("byProjectId", (q) => q.eq("projectId", args.projectId))
|
|
23
|
-
.
|
|
22
|
+
.withIndex("byProjectId", (q) => q.eq("projectId", args.projectId!))
|
|
23
|
+
.collect();
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (args.userId) {
|
|
27
27
|
return await ctx.db
|
|
28
28
|
.query("files")
|
|
29
|
-
.withIndex("byUserId", (q) => q.eq("userId", args.userId))
|
|
30
|
-
.
|
|
29
|
+
.withIndex("byUserId", (q) => q.eq("userId", args.userId!))
|
|
30
|
+
.collect();
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
return await ctx.db.query("files").
|
|
33
|
+
return await ctx.db.query("files").collect();
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -12,25 +12,25 @@ export const list = query({
|
|
|
12
12
|
if (args.projectId) {
|
|
13
13
|
return await ctx.db
|
|
14
14
|
.query("folders")
|
|
15
|
-
.withIndex("byProjectId", (q) => q.eq("projectId", args.projectId))
|
|
16
|
-
.
|
|
15
|
+
.withIndex("byProjectId", (q) => q.eq("projectId", args.projectId!))
|
|
16
|
+
.collect();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if (args.parentId) {
|
|
20
20
|
return await ctx.db
|
|
21
21
|
.query("folders")
|
|
22
|
-
.withIndex("byParentId", (q) => q.eq("parentId", args.parentId))
|
|
23
|
-
.
|
|
22
|
+
.withIndex("byParentId", (q) => q.eq("parentId", args.parentId!))
|
|
23
|
+
.collect();
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (args.userId) {
|
|
27
27
|
return await ctx.db
|
|
28
28
|
.query("folders")
|
|
29
|
-
.withIndex("byUserId", (q) => q.eq("userId", args.userId))
|
|
30
|
-
.
|
|
29
|
+
.withIndex("byUserId", (q) => q.eq("userId", args.userId!))
|
|
30
|
+
.collect();
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
return await ctx.db.query("folders").
|
|
33
|
+
return await ctx.db.query("folders").collect();
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -85,8 +85,8 @@ export const remove = mutation({
|
|
|
85
85
|
// Delete all files in the folder
|
|
86
86
|
const files = await ctx.db
|
|
87
87
|
.query("files")
|
|
88
|
-
.withIndex("byFolderId", (q) => q.eq("folderId", args.id))
|
|
89
|
-
.
|
|
88
|
+
.withIndex("byFolderId", (q) => q.eq("folderId", args.id!))
|
|
89
|
+
.collect();
|
|
90
90
|
|
|
91
91
|
for (const file of files) {
|
|
92
92
|
await ctx.db.delete(file._id);
|
|
@@ -95,8 +95,8 @@ export const remove = mutation({
|
|
|
95
95
|
// Delete all subfolders recursively
|
|
96
96
|
const subfolders = await ctx.db
|
|
97
97
|
.query("folders")
|
|
98
|
-
.withIndex("byParentId", (q) => q.eq("parentId", args.id))
|
|
99
|
-
.
|
|
98
|
+
.withIndex("byParentId", (q) => q.eq("parentId", args.id!))
|
|
99
|
+
.collect();
|
|
100
100
|
|
|
101
101
|
for (const subfolder of subfolders) {
|
|
102
102
|
// Recursive delete (will be called via mutation)
|
|
@@ -37,8 +37,8 @@ export const get = query({
|
|
|
37
37
|
handler: async (ctx, args) => {
|
|
38
38
|
const heartbeats = await ctx.db
|
|
39
39
|
.query("heartbeats")
|
|
40
|
-
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId))
|
|
41
|
-
.
|
|
40
|
+
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId!))
|
|
41
|
+
.collect();
|
|
42
42
|
|
|
43
43
|
if (args.threadId) {
|
|
44
44
|
return heartbeats.find((h) => h.threadId === args.threadId);
|
|
@@ -57,14 +57,14 @@ export const listActive = query({
|
|
|
57
57
|
const heartbeats = await ctx.db
|
|
58
58
|
.query("heartbeats")
|
|
59
59
|
.withIndex("byStatus", (q) => q.eq("status", "active"))
|
|
60
|
-
.
|
|
60
|
+
.collect();
|
|
61
61
|
|
|
62
62
|
if (args.userId) {
|
|
63
63
|
// Filter by userId if provided
|
|
64
64
|
const userAgents = await ctx.db
|
|
65
65
|
.query("agents")
|
|
66
|
-
.withIndex("byUserId", (q) => q.eq("userId", args.userId))
|
|
67
|
-
.
|
|
66
|
+
.withIndex("byUserId", (q) => q.eq("userId", args.userId!))
|
|
67
|
+
.collect();
|
|
68
68
|
|
|
69
69
|
const userAgentIds = new Set(userAgents.map((a) => a.id));
|
|
70
70
|
return heartbeats.filter((h) => userAgentIds.has(h.agentId));
|
|
@@ -82,7 +82,7 @@ export const getDueForCheck = query({
|
|
|
82
82
|
const heartbeats = await ctx.db
|
|
83
83
|
.query("heartbeats")
|
|
84
84
|
.withIndex("byNextCheck")
|
|
85
|
-
.
|
|
85
|
+
.collect();
|
|
86
86
|
|
|
87
87
|
return heartbeats.filter((h) => h.nextCheck <= now && h.status === "active");
|
|
88
88
|
},
|
|
@@ -107,10 +107,10 @@ export const upsert = mutation({
|
|
|
107
107
|
// Check if heartbeat exists
|
|
108
108
|
const existing = await ctx.db
|
|
109
109
|
.query("heartbeats")
|
|
110
|
-
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId))
|
|
110
|
+
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId!))
|
|
111
111
|
.filter((q) =>
|
|
112
112
|
args.threadId
|
|
113
|
-
? q.eq(q.field("threadId"), args.threadId)
|
|
113
|
+
? q.eq(q.field("threadId"), args.threadId!)
|
|
114
114
|
: q.eq(q.field("threadId"), undefined)
|
|
115
115
|
)
|
|
116
116
|
.first();
|
|
@@ -146,10 +146,10 @@ export const updateStatus = mutation({
|
|
|
146
146
|
handler: async (ctx, args) => {
|
|
147
147
|
const heartbeat = await ctx.db
|
|
148
148
|
.query("heartbeats")
|
|
149
|
-
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId))
|
|
149
|
+
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId!))
|
|
150
150
|
.filter((q) =>
|
|
151
151
|
args.threadId
|
|
152
|
-
? q.eq(q.field("threadId"), args.threadId)
|
|
152
|
+
? q.eq(q.field("threadId"), args.threadId!)
|
|
153
153
|
: q.eq(q.field("threadId"), undefined)
|
|
154
154
|
)
|
|
155
155
|
.first();
|
|
@@ -178,10 +178,10 @@ export const addPendingTask = mutation({
|
|
|
178
178
|
handler: async (ctx, args) => {
|
|
179
179
|
const heartbeat = await ctx.db
|
|
180
180
|
.query("heartbeats")
|
|
181
|
-
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId))
|
|
181
|
+
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId!))
|
|
182
182
|
.filter((q) =>
|
|
183
183
|
args.threadId
|
|
184
|
-
? q.eq(q.field("threadId"), args.threadId)
|
|
184
|
+
? q.eq(q.field("threadId"), args.threadId!)
|
|
185
185
|
: q.eq(q.field("threadId"), undefined)
|
|
186
186
|
)
|
|
187
187
|
.first();
|
|
@@ -210,10 +210,10 @@ export const removePendingTask = mutation({
|
|
|
210
210
|
handler: async (ctx, args) => {
|
|
211
211
|
const heartbeat = await ctx.db
|
|
212
212
|
.query("heartbeats")
|
|
213
|
-
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId))
|
|
213
|
+
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId!))
|
|
214
214
|
.filter((q) =>
|
|
215
215
|
args.threadId
|
|
216
|
-
? q.eq(q.field("threadId"), args.threadId)
|
|
216
|
+
? q.eq(q.field("threadId"), args.threadId!)
|
|
217
217
|
: q.eq(q.field("threadId"), undefined)
|
|
218
218
|
)
|
|
219
219
|
.first();
|
|
@@ -242,10 +242,10 @@ export const updateContext = mutation({
|
|
|
242
242
|
handler: async (ctx, args) => {
|
|
243
243
|
const heartbeat = await ctx.db
|
|
244
244
|
.query("heartbeats")
|
|
245
|
-
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId))
|
|
245
|
+
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId!))
|
|
246
246
|
.filter((q) =>
|
|
247
247
|
args.threadId
|
|
248
|
-
? q.eq(q.field("threadId"), args.threadId)
|
|
248
|
+
? q.eq(q.field("threadId"), args.threadId!)
|
|
249
249
|
: q.eq(q.field("threadId"), undefined)
|
|
250
250
|
)
|
|
251
251
|
.first();
|
|
@@ -310,12 +310,12 @@ export const processCheck = action({
|
|
|
310
310
|
agentId: v.string(),
|
|
311
311
|
threadId: v.optional(v.id("threads")),
|
|
312
312
|
},
|
|
313
|
-
handler: async (ctx, args) => {
|
|
313
|
+
handler: async (ctx, args): Promise<{ success: boolean; message?: string; pendingTasks?: number; status?: string }> => {
|
|
314
314
|
// Get heartbeat
|
|
315
315
|
const heartbeat = await ctx.runQuery(api.heartbeat.get, {
|
|
316
316
|
agentId: args.agentId,
|
|
317
317
|
threadId: args.threadId,
|
|
318
|
-
});
|
|
318
|
+
}) as { status: string; pendingTasks: string[]; currentTask?: string } | null;
|
|
319
319
|
|
|
320
320
|
if (!heartbeat) {
|
|
321
321
|
return { success: false, message: "Heartbeat not found" };
|
|
@@ -353,10 +353,10 @@ export const remove = mutation({
|
|
|
353
353
|
handler: async (ctx, args) => {
|
|
354
354
|
const heartbeat = await ctx.db
|
|
355
355
|
.query("heartbeats")
|
|
356
|
-
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId))
|
|
356
|
+
.withIndex("byAgentId", (q) => q.eq("agentId", args.agentId!))
|
|
357
357
|
.filter((q) =>
|
|
358
358
|
args.threadId
|
|
359
|
-
? q.eq(q.field("threadId"), args.threadId)
|
|
359
|
+
? q.eq(q.field("threadId"), args.threadId!)
|
|
360
360
|
: q.eq(q.field("threadId"), undefined)
|
|
361
361
|
)
|
|
362
362
|
.first();
|
|
@@ -54,6 +54,7 @@ export const executeAgent = action({
|
|
|
54
54
|
|
|
55
55
|
try {
|
|
56
56
|
// Import Mastra dynamically (Node.js runtime)
|
|
57
|
+
// @ts-expect-error - Mastra is installed at runtime in the user's project
|
|
57
58
|
const { Agent } = await import("@mastra/core/agent");
|
|
58
59
|
|
|
59
60
|
// Format model string for Mastra
|
|
@@ -79,11 +80,11 @@ export const executeAgent = action({
|
|
|
79
80
|
// Build context from message history
|
|
80
81
|
const context = messages
|
|
81
82
|
.slice(-10) // Last 10 messages for context
|
|
82
|
-
.map((m) => `${m.role}: ${m.content}`)
|
|
83
|
+
.map((m: { role: string; content: string }) => `${m.role}: ${m.content}`)
|
|
83
84
|
.join("\n");
|
|
84
85
|
|
|
85
86
|
// Execute agent
|
|
86
|
-
const result = await mastraAgent.generate(args.prompt, {
|
|
87
|
+
const result: any = await mastraAgent.generate(args.prompt, {
|
|
87
88
|
...(args.stream && { stream: args.stream }),
|
|
88
89
|
context: context || undefined,
|
|
89
90
|
});
|
|
@@ -11,8 +11,8 @@ export const list = query({
|
|
|
11
11
|
if (args.isEnabled !== undefined) {
|
|
12
12
|
const connections = await ctx.db
|
|
13
13
|
.query("mcpConnections")
|
|
14
|
-
.withIndex("byIsEnabled", (q) => q.eq("isEnabled", args.isEnabled))
|
|
15
|
-
.
|
|
14
|
+
.withIndex("byIsEnabled", (q) => q.eq("isEnabled", args.isEnabled!))
|
|
15
|
+
.collect();
|
|
16
16
|
|
|
17
17
|
if (args.userId) {
|
|
18
18
|
return connections.filter((c) => c.userId === args.userId);
|
|
@@ -23,11 +23,11 @@ export const list = query({
|
|
|
23
23
|
if (args.userId) {
|
|
24
24
|
return await ctx.db
|
|
25
25
|
.query("mcpConnections")
|
|
26
|
-
.withIndex("byUserId", (q) => q.eq("userId", args.userId))
|
|
27
|
-
.
|
|
26
|
+
.withIndex("byUserId", (q) => q.eq("userId", args.userId!))
|
|
27
|
+
.collect();
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
return await ctx.db.query("mcpConnections").
|
|
30
|
+
return await ctx.db.query("mcpConnections").collect();
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -57,8 +57,8 @@ export const list = query({
|
|
|
57
57
|
handler: async (ctx, args) => {
|
|
58
58
|
const messages = await ctx.db
|
|
59
59
|
.query("messages")
|
|
60
|
-
.withIndex("
|
|
61
|
-
.
|
|
60
|
+
.withIndex("byThread", (q) => q.eq("threadId", args.threadId!))
|
|
61
|
+
.collect();
|
|
62
62
|
return messages;
|
|
63
63
|
},
|
|
64
64
|
});
|
|
@@ -78,8 +78,8 @@ export const clearThread = mutation({
|
|
|
78
78
|
handler: async (ctx, args) => {
|
|
79
79
|
const messages = await ctx.db
|
|
80
80
|
.query("messages")
|
|
81
|
-
.withIndex("
|
|
82
|
-
.
|
|
81
|
+
.withIndex("byThread", (q) => q.eq("threadId", args.threadId!))
|
|
82
|
+
.collect();
|
|
83
83
|
|
|
84
84
|
for (const message of messages) {
|
|
85
85
|
await ctx.db.delete(message._id);
|
|
@@ -10,11 +10,11 @@ export const list = query({
|
|
|
10
10
|
if (args.userId) {
|
|
11
11
|
return await ctx.db
|
|
12
12
|
.query("projects")
|
|
13
|
-
.withIndex("byUserId", (q) => q.eq("userId", args.userId))
|
|
14
|
-
.
|
|
13
|
+
.withIndex("byUserId", (q) => q.eq("userId", args.userId!))
|
|
14
|
+
.collect();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
return await ctx.db.query("projects").
|
|
17
|
+
return await ctx.db.query("projects").collect();
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
|
|
@@ -70,15 +70,15 @@ export const remove = mutation({
|
|
|
70
70
|
// Delete all threads in the project
|
|
71
71
|
const threads = await ctx.db
|
|
72
72
|
.query("threads")
|
|
73
|
-
.withIndex("byProjectId", (q) => q.eq("projectId", args.id))
|
|
74
|
-
.
|
|
73
|
+
.withIndex("byProjectId", (q) => q.eq("projectId", args.id!))
|
|
74
|
+
.collect();
|
|
75
75
|
|
|
76
76
|
for (const thread of threads) {
|
|
77
77
|
// Delete messages in thread
|
|
78
78
|
const messages = await ctx.db
|
|
79
79
|
.query("messages")
|
|
80
80
|
.withIndex("byThread", (q) => q.eq("threadId", thread._id))
|
|
81
|
-
.
|
|
81
|
+
.collect();
|
|
82
82
|
|
|
83
83
|
for (const message of messages) {
|
|
84
84
|
await ctx.db.delete(message._id);
|
|
@@ -90,8 +90,8 @@ export const remove = mutation({
|
|
|
90
90
|
// Delete all files in the project
|
|
91
91
|
const files = await ctx.db
|
|
92
92
|
.query("files")
|
|
93
|
-
.withIndex("byProjectId", (q) => q.eq("projectId", args.id))
|
|
94
|
-
.
|
|
93
|
+
.withIndex("byProjectId", (q) => q.eq("projectId", args.id!))
|
|
94
|
+
.collect();
|
|
95
95
|
|
|
96
96
|
for (const file of files) {
|
|
97
97
|
await ctx.db.delete(file._id);
|
|
@@ -100,8 +100,8 @@ export const remove = mutation({
|
|
|
100
100
|
// Delete all folders in the project
|
|
101
101
|
const folders = await ctx.db
|
|
102
102
|
.query("folders")
|
|
103
|
-
.withIndex("byProjectId", (q) => q.eq("projectId", args.id))
|
|
104
|
-
.
|
|
103
|
+
.withIndex("byProjectId", (q) => q.eq("projectId", args.id!))
|
|
104
|
+
.collect();
|
|
105
105
|
|
|
106
106
|
for (const folder of folders) {
|
|
107
107
|
await ctx.db.delete(folder._id);
|