@agentforge-ai/cli 0.5.2 → 0.5.4

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.
@@ -9,6 +9,15 @@ import { api } from "./_generated/api";
9
9
  * to execute agents and manage workflows.
10
10
  */
11
11
 
12
+ // Return type for executeAgent to break circular type inference
13
+ type ExecuteAgentResult = {
14
+ success: boolean;
15
+ threadId: string;
16
+ sessionId: string;
17
+ response: string;
18
+ usage?: Record<string, unknown>;
19
+ };
20
+
12
21
  // Action: Execute agent with Mastra
13
22
  export const executeAgent = action({
14
23
  args: {
@@ -18,7 +27,7 @@ export const executeAgent = action({
18
27
  userId: v.optional(v.string()),
19
28
  stream: v.optional(v.boolean()),
20
29
  },
21
- handler: async (ctx, args) => {
30
+ handler: async (ctx, args): Promise<ExecuteAgentResult> => {
22
31
  // Get agent configuration from database
23
32
  const agent = await ctx.runQuery(api.agents.get, { id: args.agentId });
24
33
 
@@ -75,12 +84,12 @@ export const executeAgent = action({
75
84
  });
76
85
 
77
86
  // Get conversation history for context
78
- const messages = await ctx.runQuery(api.messages.list, { threadId });
87
+ const messages = await ctx.runQuery(api.messages.list, { threadId }) as Array<{ role: string; content: string }>;
79
88
 
80
89
  // Build context from message history
81
90
  const context = messages
82
91
  .slice(-10) // Last 10 messages for context
83
- .map((m: { role: string; content: string }) => `${m.role}: ${m.content}`)
92
+ .map((m) => `${m.role}: ${m.content}`)
84
93
  .join("\n");
85
94
 
86
95
  // Execute agent
@@ -90,7 +99,7 @@ export const executeAgent = action({
90
99
  });
91
100
 
92
101
  // Extract response content
93
- const responseContent = typeof result === "string"
102
+ const responseContent: string = typeof result === "string"
94
103
  ? result
95
104
  : result.text || result.content || JSON.stringify(result);
96
105
 
@@ -124,12 +133,14 @@ export const executeAgent = action({
124
133
 
125
134
  return {
126
135
  success: true,
127
- threadId,
136
+ threadId: threadId as string,
128
137
  sessionId,
129
138
  response: responseContent,
130
139
  usage: result.usage,
131
140
  };
132
- } catch (error: any) {
141
+ } catch (error: unknown) {
142
+ const errorMessage = error instanceof Error ? error.message : String(error);
143
+
133
144
  // Update session status to error
134
145
  await ctx.runMutation(api.sessions.updateStatus, {
135
146
  sessionId,
@@ -140,7 +151,7 @@ export const executeAgent = action({
140
151
  await ctx.runMutation(api.messages.add, {
141
152
  threadId,
142
153
  role: "assistant",
143
- content: `Error: ${error.message}`,
154
+ content: `Error: ${errorMessage}`,
144
155
  });
145
156
 
146
157
  throw error;
@@ -156,7 +167,7 @@ export const streamAgent = action({
156
167
  threadId: v.id("threads"),
157
168
  userId: v.optional(v.string()),
158
169
  },
159
- handler: async (ctx, args) => {
170
+ handler: async (ctx, args): Promise<{ success: boolean; message: string }> => {
160
171
  // Similar to executeAgent but with streaming support
161
172
  // This would require WebSocket or SSE implementation
162
173
  // For now, return a placeholder
@@ -174,7 +185,7 @@ export const executeWorkflow = action({
174
185
  input: v.any(),
175
186
  userId: v.optional(v.string()),
176
187
  },
177
- handler: async (ctx, args) => {
188
+ handler: async (ctx, args): Promise<{ success: boolean; message: string }> => {
178
189
  // Placeholder for workflow execution
179
190
  // This would orchestrate multiple agents in sequence or parallel
180
191
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-ai/cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "CLI tool for creating, running, and managing AgentForge projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,6 @@
22
22
  "clean": "rm -rf dist"
23
23
  },
24
24
  "dependencies": {
25
- "@agentforge-ai/cloud-client": "workspace:*",
26
25
  "commander": "^12.0.0",
27
26
  "convex": "^1.17.0",
28
27
  "chalk": "^5.3.0",
@@ -9,6 +9,15 @@ import { api } from "./_generated/api";
9
9
  * to execute agents and manage workflows.
10
10
  */
11
11
 
12
+ // Return type for executeAgent to break circular type inference
13
+ type ExecuteAgentResult = {
14
+ success: boolean;
15
+ threadId: string;
16
+ sessionId: string;
17
+ response: string;
18
+ usage?: Record<string, unknown>;
19
+ };
20
+
12
21
  // Action: Execute agent with Mastra
13
22
  export const executeAgent = action({
14
23
  args: {
@@ -18,7 +27,7 @@ export const executeAgent = action({
18
27
  userId: v.optional(v.string()),
19
28
  stream: v.optional(v.boolean()),
20
29
  },
21
- handler: async (ctx, args) => {
30
+ handler: async (ctx, args): Promise<ExecuteAgentResult> => {
22
31
  // Get agent configuration from database
23
32
  const agent = await ctx.runQuery(api.agents.get, { id: args.agentId });
24
33
 
@@ -75,12 +84,12 @@ export const executeAgent = action({
75
84
  });
76
85
 
77
86
  // Get conversation history for context
78
- const messages = await ctx.runQuery(api.messages.list, { threadId });
87
+ const messages = await ctx.runQuery(api.messages.list, { threadId }) as Array<{ role: string; content: string }>;
79
88
 
80
89
  // Build context from message history
81
90
  const context = messages
82
91
  .slice(-10) // Last 10 messages for context
83
- .map((m: { role: string; content: string }) => `${m.role}: ${m.content}`)
92
+ .map((m) => `${m.role}: ${m.content}`)
84
93
  .join("\n");
85
94
 
86
95
  // Execute agent
@@ -90,7 +99,7 @@ export const executeAgent = action({
90
99
  });
91
100
 
92
101
  // Extract response content
93
- const responseContent = typeof result === "string"
102
+ const responseContent: string = typeof result === "string"
94
103
  ? result
95
104
  : result.text || result.content || JSON.stringify(result);
96
105
 
@@ -124,12 +133,14 @@ export const executeAgent = action({
124
133
 
125
134
  return {
126
135
  success: true,
127
- threadId,
136
+ threadId: threadId as string,
128
137
  sessionId,
129
138
  response: responseContent,
130
139
  usage: result.usage,
131
140
  };
132
- } catch (error: any) {
141
+ } catch (error: unknown) {
142
+ const errorMessage = error instanceof Error ? error.message : String(error);
143
+
133
144
  // Update session status to error
134
145
  await ctx.runMutation(api.sessions.updateStatus, {
135
146
  sessionId,
@@ -140,7 +151,7 @@ export const executeAgent = action({
140
151
  await ctx.runMutation(api.messages.add, {
141
152
  threadId,
142
153
  role: "assistant",
143
- content: `Error: ${error.message}`,
154
+ content: `Error: ${errorMessage}`,
144
155
  });
145
156
 
146
157
  throw error;
@@ -156,7 +167,7 @@ export const streamAgent = action({
156
167
  threadId: v.id("threads"),
157
168
  userId: v.optional(v.string()),
158
169
  },
159
- handler: async (ctx, args) => {
170
+ handler: async (ctx, args): Promise<{ success: boolean; message: string }> => {
160
171
  // Similar to executeAgent but with streaming support
161
172
  // This would require WebSocket or SSE implementation
162
173
  // For now, return a placeholder
@@ -174,7 +185,7 @@ export const executeWorkflow = action({
174
185
  input: v.any(),
175
186
  userId: v.optional(v.string()),
176
187
  },
177
- handler: async (ctx, args) => {
188
+ handler: async (ctx, args): Promise<{ success: boolean; message: string }> => {
178
189
  // Placeholder for workflow execution
179
190
  // This would orchestrate multiple agents in sequence or parallel
180
191
  return {