Skip to content

Commit 4cabfad

Browse files
committed
chore: linting
1 parent 76bf76c commit 4cabfad

File tree

3 files changed

+66
-30
lines changed

3 files changed

+66
-30
lines changed

packages/agent/src/tools/interaction/agentMessage.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { z } from 'zod';
22
import { zodToJsonSchema } from 'zod-to-json-schema';
33

4-
import { backgroundToolRegistry, BackgroundToolStatus } from '../../core/backgroundTools.js';
4+
import {
5+
backgroundToolRegistry,
6+
BackgroundToolStatus,
7+
} from '../../core/backgroundTools.js';
58
import { Tool } from '../../core/types.js';
69

710
import { agentStates } from './agentStart.js';
@@ -76,11 +79,15 @@ export const agentMessageTool: Tool<Parameters, ReturnType> = {
7679
if (terminate) {
7780
agentState.aborted = true;
7881
agentState.completed = true;
79-
82+
8083
// Update background tool registry with terminated status
81-
backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.TERMINATED, {
82-
terminatedByUser: true
83-
});
84+
backgroundToolRegistry.updateToolStatus(
85+
instanceId,
86+
BackgroundToolStatus.TERMINATED,
87+
{
88+
terminatedByUser: true,
89+
},
90+
);
8491

8592
return {
8693
output: agentState.output || 'Sub-agent terminated before completion',

packages/agent/src/tools/interaction/agentStart.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { v4 as uuidv4 } from 'uuid';
22
import { z } from 'zod';
33
import { zodToJsonSchema } from 'zod-to-json-schema';
44

5-
import { backgroundToolRegistry, BackgroundToolStatus, BackgroundToolType } from '../../core/backgroundTools.js';
5+
import {
6+
backgroundToolRegistry,
7+
BackgroundToolStatus,
8+
} from '../../core/backgroundTools.js';
69
import {
710
getDefaultSystemPrompt,
811
getModel,
@@ -92,7 +95,7 @@ export const agentStartTool: Tool<Parameters, ReturnType> = {
9295
returnsJsonSchema: zodToJsonSchema(returnSchema),
9396
execute: async (params, context) => {
9497
const { logger, agentId } = context;
95-
98+
9699
// Validate parameters
97100
const {
98101
description,
@@ -102,10 +105,10 @@ export const agentStartTool: Tool<Parameters, ReturnType> = {
102105
relevantFilesDirectories,
103106
enableUserPrompt = false,
104107
} = parameterSchema.parse(params);
105-
108+
106109
// Create an instance ID
107110
const instanceId = uuidv4();
108-
111+
109112
// Register this agent with the background tool registry
110113
backgroundToolRegistry.registerAgent(agentId || 'unknown', goal);
111114
logger.verbose(`Registered agent with ID: ${instanceId}`);
@@ -154,23 +157,33 @@ export const agentStartTool: Tool<Parameters, ReturnType> = {
154157
state.completed = true;
155158
state.result = result;
156159
state.output = result.result;
157-
160+
158161
// Update background tool registry with completed status
159-
backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.COMPLETED, {
160-
result: result.result.substring(0, 100) + (result.result.length > 100 ? '...' : '')
161-
});
162+
backgroundToolRegistry.updateToolStatus(
163+
instanceId,
164+
BackgroundToolStatus.COMPLETED,
165+
{
166+
result:
167+
result.result.substring(0, 100) +
168+
(result.result.length > 100 ? '...' : ''),
169+
},
170+
);
162171
}
163172
} catch (error) {
164173
// Update agent state with the error
165174
const state = agentStates.get(instanceId);
166175
if (state && !state.aborted) {
167176
state.completed = true;
168177
state.error = error instanceof Error ? error.message : String(error);
169-
178+
170179
// Update background tool registry with error status
171-
backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.ERROR, {
172-
error: error instanceof Error ? error.message : String(error)
173-
});
180+
backgroundToolRegistry.updateToolStatus(
181+
instanceId,
182+
BackgroundToolStatus.ERROR,
183+
{
184+
error: error instanceof Error ? error.message : String(error),
185+
},
186+
);
174187
}
175188
}
176189
return true;

packages/agent/src/tools/interaction/subAgent.ts

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { z } from 'zod';
22
import { zodToJsonSchema } from 'zod-to-json-schema';
33

4-
import { backgroundToolRegistry, BackgroundToolStatus, BackgroundToolType } from '../../core/backgroundTools.js';
4+
import {
5+
backgroundToolRegistry,
6+
BackgroundToolStatus,
7+
} from '../../core/backgroundTools.js';
58
import {
69
getDefaultSystemPrompt,
710
getModel,
@@ -70,7 +73,7 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
7073
returnsJsonSchema: zodToJsonSchema(returnSchema),
7174
execute: async (params, context) => {
7275
const { logger, agentId } = context;
73-
76+
7477
// Validate parameters
7578
const {
7679
description,
@@ -79,9 +82,12 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
7982
workingDirectory,
8083
relevantFilesDirectories,
8184
} = parameterSchema.parse(params);
82-
85+
8386
// Register this sub-agent with the background tool registry
84-
const subAgentId = backgroundToolRegistry.registerAgent(agentId || 'unknown', goal);
87+
const subAgentId = backgroundToolRegistry.registerAgent(
88+
agentId || 'unknown',
89+
goal,
90+
);
8591
logger.verbose(`Registered sub-agent with ID: ${subAgentId}`);
8692

8793
// Construct a well-structured prompt
@@ -109,19 +115,29 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
109115
...context,
110116
workingDirectory: workingDirectory ?? context.workingDirectory,
111117
});
112-
118+
113119
// Update background tool registry with completed status
114-
backgroundToolRegistry.updateToolStatus(subAgentId, BackgroundToolStatus.COMPLETED, {
115-
result: result.result.substring(0, 100) + (result.result.length > 100 ? '...' : '')
116-
});
117-
120+
backgroundToolRegistry.updateToolStatus(
121+
subAgentId,
122+
BackgroundToolStatus.COMPLETED,
123+
{
124+
result:
125+
result.result.substring(0, 100) +
126+
(result.result.length > 100 ? '...' : ''),
127+
},
128+
);
129+
118130
return { response: result.result };
119131
} catch (error) {
120132
// Update background tool registry with error status
121-
backgroundToolRegistry.updateToolStatus(subAgentId, BackgroundToolStatus.ERROR, {
122-
error: error instanceof Error ? error.message : String(error)
123-
});
124-
133+
backgroundToolRegistry.updateToolStatus(
134+
subAgentId,
135+
BackgroundToolStatus.ERROR,
136+
{
137+
error: error instanceof Error ? error.message : String(error),
138+
},
139+
);
140+
125141
throw error;
126142
}
127143
},

0 commit comments

Comments
 (0)