Skip to content

Commit ce2a3be

Browse files
authored
Merge pull request #221 from drivecore/default-github-mode-on
Default GitHub mode on
2 parents 792c58f + 4cabfad commit ce2a3be

18 files changed

+99
-63
lines changed

packages/agent/src/core/toolAgent.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const toolContext: ToolContext = {
1414
userSession: false,
1515
pageFilter: 'simple',
1616
tokenTracker: new TokenTracker(),
17-
githubMode: false,
17+
githubMode: true,
1818
};
1919

2020
// Mock tool for testing

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/agentTools.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const mockContext: ToolContext = {
2323
headless: true,
2424
userSession: false,
2525
pageFilter: 'none',
26-
githubMode: false,
26+
githubMode: true,
2727
};
2828

2929
describe('Agent Tools', () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const mockContext: ToolContext = {
2727
headless: true,
2828
userSession: false,
2929
pageFilter: 'none',
30-
githubMode: false,
30+
githubMode: true,
3131
};
3232

3333
describe('subAgentTool', () => {

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
},

packages/agent/src/tools/interaction/userPrompt.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const mockContext: ToolContext = {
1919
headless: true,
2020
userSession: false,
2121
pageFilter: 'none',
22-
githubMode: false,
22+
githubMode: true,
2323
};
2424

2525
describe('userPromptTool', () => {

packages/agent/src/tools/io/textEditor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const toolContext: ToolContext = {
1919
userSession: false,
2020
pageFilter: 'simple',
2121
tokenTracker: new TokenTracker(),
22-
githubMode: false,
22+
githubMode: true,
2323
};
2424

2525
describe('textEditor', () => {

packages/agent/src/tools/system/respawn.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const toolContext: ToolContext = {
1313
userSession: false,
1414
pageFilter: 'simple',
1515
tokenTracker: new TokenTracker(),
16-
githubMode: false,
16+
githubMode: true,
1717
};
1818
describe('respawnTool', () => {
1919
it('should have correct name and description', () => {

packages/agent/src/tools/system/shellExecute.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const toolContext: ToolContext = {
1313
userSession: false,
1414
pageFilter: 'simple',
1515
tokenTracker: new TokenTracker(),
16-
githubMode: false,
16+
githubMode: true,
1717
};
1818

1919
describe('shellExecute', () => {

0 commit comments

Comments
 (0)