diff --git a/packages/agent/src/core/toolAgent.test.ts b/packages/agent/src/core/toolAgent.test.ts index 91226dc..857d168 100644 --- a/packages/agent/src/core/toolAgent.test.ts +++ b/packages/agent/src/core/toolAgent.test.ts @@ -14,7 +14,7 @@ const toolContext: ToolContext = { userSession: false, pageFilter: 'simple', tokenTracker: new TokenTracker(), - githubMode: false, + githubMode: true, }; // Mock tool for testing diff --git a/packages/agent/src/tools/interaction/agentMessage.ts b/packages/agent/src/tools/interaction/agentMessage.ts index 89f4dce..91e0afd 100644 --- a/packages/agent/src/tools/interaction/agentMessage.ts +++ b/packages/agent/src/tools/interaction/agentMessage.ts @@ -1,7 +1,10 @@ import { z } from 'zod'; import { zodToJsonSchema } from 'zod-to-json-schema'; -import { backgroundToolRegistry, BackgroundToolStatus } from '../../core/backgroundTools.js'; +import { + backgroundToolRegistry, + BackgroundToolStatus, +} from '../../core/backgroundTools.js'; import { Tool } from '../../core/types.js'; import { agentStates } from './agentStart.js'; @@ -76,11 +79,15 @@ export const agentMessageTool: Tool = { if (terminate) { agentState.aborted = true; agentState.completed = true; - + // Update background tool registry with terminated status - backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.TERMINATED, { - terminatedByUser: true - }); + backgroundToolRegistry.updateToolStatus( + instanceId, + BackgroundToolStatus.TERMINATED, + { + terminatedByUser: true, + }, + ); return { output: agentState.output || 'Sub-agent terminated before completion', diff --git a/packages/agent/src/tools/interaction/agentStart.ts b/packages/agent/src/tools/interaction/agentStart.ts index 3e80509..e03fff5 100644 --- a/packages/agent/src/tools/interaction/agentStart.ts +++ b/packages/agent/src/tools/interaction/agentStart.ts @@ -2,7 +2,10 @@ import { v4 as uuidv4 } from 'uuid'; import { z } from 'zod'; import { zodToJsonSchema } from 'zod-to-json-schema'; -import { backgroundToolRegistry, BackgroundToolStatus, BackgroundToolType } from '../../core/backgroundTools.js'; +import { + backgroundToolRegistry, + BackgroundToolStatus, +} from '../../core/backgroundTools.js'; import { getDefaultSystemPrompt, getModel, @@ -92,7 +95,7 @@ export const agentStartTool: Tool = { returnsJsonSchema: zodToJsonSchema(returnSchema), execute: async (params, context) => { const { logger, agentId } = context; - + // Validate parameters const { description, @@ -102,10 +105,10 @@ export const agentStartTool: Tool = { relevantFilesDirectories, enableUserPrompt = false, } = parameterSchema.parse(params); - + // Create an instance ID const instanceId = uuidv4(); - + // Register this agent with the background tool registry backgroundToolRegistry.registerAgent(agentId || 'unknown', goal); logger.verbose(`Registered agent with ID: ${instanceId}`); @@ -154,11 +157,17 @@ export const agentStartTool: Tool = { state.completed = true; state.result = result; state.output = result.result; - + // Update background tool registry with completed status - backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.COMPLETED, { - result: result.result.substring(0, 100) + (result.result.length > 100 ? '...' : '') - }); + backgroundToolRegistry.updateToolStatus( + instanceId, + BackgroundToolStatus.COMPLETED, + { + result: + result.result.substring(0, 100) + + (result.result.length > 100 ? '...' : ''), + }, + ); } } catch (error) { // Update agent state with the error @@ -166,11 +175,15 @@ export const agentStartTool: Tool = { if (state && !state.aborted) { state.completed = true; state.error = error instanceof Error ? error.message : String(error); - + // Update background tool registry with error status - backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.ERROR, { - error: error instanceof Error ? error.message : String(error) - }); + backgroundToolRegistry.updateToolStatus( + instanceId, + BackgroundToolStatus.ERROR, + { + error: error instanceof Error ? error.message : String(error), + }, + ); } } return true; diff --git a/packages/agent/src/tools/interaction/agentTools.test.ts b/packages/agent/src/tools/interaction/agentTools.test.ts index 9bb6043..afc8677 100644 --- a/packages/agent/src/tools/interaction/agentTools.test.ts +++ b/packages/agent/src/tools/interaction/agentTools.test.ts @@ -23,7 +23,7 @@ const mockContext: ToolContext = { headless: true, userSession: false, pageFilter: 'none', - githubMode: false, + githubMode: true, }; describe('Agent Tools', () => { diff --git a/packages/agent/src/tools/interaction/subAgent.test.ts b/packages/agent/src/tools/interaction/subAgent.test.ts index a1648c3..986feaf 100644 --- a/packages/agent/src/tools/interaction/subAgent.test.ts +++ b/packages/agent/src/tools/interaction/subAgent.test.ts @@ -27,7 +27,7 @@ const mockContext: ToolContext = { headless: true, userSession: false, pageFilter: 'none', - githubMode: false, + githubMode: true, }; describe('subAgentTool', () => { diff --git a/packages/agent/src/tools/interaction/subAgent.ts b/packages/agent/src/tools/interaction/subAgent.ts index c36b933..47478a0 100644 --- a/packages/agent/src/tools/interaction/subAgent.ts +++ b/packages/agent/src/tools/interaction/subAgent.ts @@ -1,7 +1,10 @@ import { z } from 'zod'; import { zodToJsonSchema } from 'zod-to-json-schema'; -import { backgroundToolRegistry, BackgroundToolStatus, BackgroundToolType } from '../../core/backgroundTools.js'; +import { + backgroundToolRegistry, + BackgroundToolStatus, +} from '../../core/backgroundTools.js'; import { getDefaultSystemPrompt, getModel, @@ -70,7 +73,7 @@ export const subAgentTool: Tool = { returnsJsonSchema: zodToJsonSchema(returnSchema), execute: async (params, context) => { const { logger, agentId } = context; - + // Validate parameters const { description, @@ -79,9 +82,12 @@ export const subAgentTool: Tool = { workingDirectory, relevantFilesDirectories, } = parameterSchema.parse(params); - + // Register this sub-agent with the background tool registry - const subAgentId = backgroundToolRegistry.registerAgent(agentId || 'unknown', goal); + const subAgentId = backgroundToolRegistry.registerAgent( + agentId || 'unknown', + goal, + ); logger.verbose(`Registered sub-agent with ID: ${subAgentId}`); // Construct a well-structured prompt @@ -109,19 +115,29 @@ export const subAgentTool: Tool = { ...context, workingDirectory: workingDirectory ?? context.workingDirectory, }); - + // Update background tool registry with completed status - backgroundToolRegistry.updateToolStatus(subAgentId, BackgroundToolStatus.COMPLETED, { - result: result.result.substring(0, 100) + (result.result.length > 100 ? '...' : '') - }); - + backgroundToolRegistry.updateToolStatus( + subAgentId, + BackgroundToolStatus.COMPLETED, + { + result: + result.result.substring(0, 100) + + (result.result.length > 100 ? '...' : ''), + }, + ); + return { response: result.result }; } catch (error) { // Update background tool registry with error status - backgroundToolRegistry.updateToolStatus(subAgentId, BackgroundToolStatus.ERROR, { - error: error instanceof Error ? error.message : String(error) - }); - + backgroundToolRegistry.updateToolStatus( + subAgentId, + BackgroundToolStatus.ERROR, + { + error: error instanceof Error ? error.message : String(error), + }, + ); + throw error; } }, diff --git a/packages/agent/src/tools/interaction/userPrompt.test.ts b/packages/agent/src/tools/interaction/userPrompt.test.ts index 4d700dd..e693a3c 100644 --- a/packages/agent/src/tools/interaction/userPrompt.test.ts +++ b/packages/agent/src/tools/interaction/userPrompt.test.ts @@ -19,7 +19,7 @@ const mockContext: ToolContext = { headless: true, userSession: false, pageFilter: 'none', - githubMode: false, + githubMode: true, }; describe('userPromptTool', () => { diff --git a/packages/agent/src/tools/io/textEditor.test.ts b/packages/agent/src/tools/io/textEditor.test.ts index 0ebe83d..c8e4ef7 100644 --- a/packages/agent/src/tools/io/textEditor.test.ts +++ b/packages/agent/src/tools/io/textEditor.test.ts @@ -19,7 +19,7 @@ const toolContext: ToolContext = { userSession: false, pageFilter: 'simple', tokenTracker: new TokenTracker(), - githubMode: false, + githubMode: true, }; describe('textEditor', () => { diff --git a/packages/agent/src/tools/system/respawn.test.ts b/packages/agent/src/tools/system/respawn.test.ts index ed968b4..dd5e4ca 100644 --- a/packages/agent/src/tools/system/respawn.test.ts +++ b/packages/agent/src/tools/system/respawn.test.ts @@ -13,7 +13,7 @@ const toolContext: ToolContext = { userSession: false, pageFilter: 'simple', tokenTracker: new TokenTracker(), - githubMode: false, + githubMode: true, }; describe('respawnTool', () => { it('should have correct name and description', () => { diff --git a/packages/agent/src/tools/system/shellExecute.test.ts b/packages/agent/src/tools/system/shellExecute.test.ts index 16715a7..b2b9a4a 100644 --- a/packages/agent/src/tools/system/shellExecute.test.ts +++ b/packages/agent/src/tools/system/shellExecute.test.ts @@ -13,7 +13,7 @@ const toolContext: ToolContext = { userSession: false, pageFilter: 'simple', tokenTracker: new TokenTracker(), - githubMode: false, + githubMode: true, }; describe('shellExecute', () => { diff --git a/packages/agent/src/tools/system/shellMessage.test.ts b/packages/agent/src/tools/system/shellMessage.test.ts index 24b1061..fc605d5 100644 --- a/packages/agent/src/tools/system/shellMessage.test.ts +++ b/packages/agent/src/tools/system/shellMessage.test.ts @@ -15,7 +15,7 @@ const toolContext: ToolContext = { userSession: false, pageFilter: 'simple', tokenTracker: new TokenTracker(), - githubMode: false, + githubMode: true, }; // Helper function to get instanceId from shellStart result diff --git a/packages/agent/src/tools/system/shellStart.test.ts b/packages/agent/src/tools/system/shellStart.test.ts index 1abad12..6d9843a 100644 --- a/packages/agent/src/tools/system/shellStart.test.ts +++ b/packages/agent/src/tools/system/shellStart.test.ts @@ -14,7 +14,7 @@ const toolContext: ToolContext = { userSession: false, pageFilter: 'simple', tokenTracker: new TokenTracker(), - githubMode: false, + githubMode: true, }; describe('shellStartTool', () => { beforeEach(() => { diff --git a/packages/agent/src/tools/system/sleep.test.ts b/packages/agent/src/tools/system/sleep.test.ts index 8243769..8561726 100644 --- a/packages/agent/src/tools/system/sleep.test.ts +++ b/packages/agent/src/tools/system/sleep.test.ts @@ -13,7 +13,7 @@ const toolContext: ToolContext = { userSession: false, pageFilter: 'simple', tokenTracker: new TokenTracker(), - githubMode: false, + githubMode: true, }; describe('sleep tool', () => { diff --git a/packages/cli/src/settings/config.ts b/packages/cli/src/settings/config.ts index bbe90e3..677fee0 100644 --- a/packages/cli/src/settings/config.ts +++ b/packages/cli/src/settings/config.ts @@ -43,7 +43,7 @@ const projectConfigFile = (): string => getProjectConfigFile(); // Default configuration const defaultConfig = { // Add default configuration values here - githubMode: false, + githubMode: true, headless: true, userSession: false, pageFilter: 'none' as 'simple' | 'none' | 'readability', diff --git a/packages/cli/tests/commands/config.test.ts b/packages/cli/tests/commands/config.test.ts index 9b27d2e..6bf692f 100644 --- a/packages/cli/tests/commands/config.test.ts +++ b/packages/cli/tests/commands/config.test.ts @@ -69,18 +69,18 @@ describe('Config Command', () => { warn: vi.fn(), }; vi.mocked(Logger).mockImplementation(() => mockLogger as unknown as Logger); - vi.mocked(getConfig).mockReturnValue({ githubMode: false }); + vi.mocked(getConfig).mockReturnValue({ githubMode: true }); vi.mocked(getDefaultConfig).mockReturnValue({ - githubMode: false, + githubMode: true, customPrompt: '', }); vi.mocked(updateConfig).mockImplementation((config) => ({ - githubMode: false, + githubMode: true, ...config, })); vi.mocked(getConfigAtLevel).mockReturnValue({}); - vi.mocked(clearConfigKey).mockImplementation(() => ({ githubMode: false })); - vi.mocked(clearConfigKey).mockImplementation(() => ({ githubMode: false })); + vi.mocked(clearConfigKey).mockImplementation(() => ({ githubMode: true })); + vi.mocked(clearConfigKey).mockImplementation(() => ({ githubMode: true })); }); afterEach(() => { @@ -107,13 +107,13 @@ describe('Config Command', () => { it('should filter out invalid config keys in list command', async () => { // Mock getConfig to return config with invalid keys vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, invalidKey: 'some value', } as any); // Mock getDefaultConfig to return only valid keys vi.mocked(getDefaultConfig).mockReturnValue({ - githubMode: false, + githubMode: true, }); await command.handler!({ @@ -249,13 +249,13 @@ describe('Config Command', () => { it('should clear a configuration value', async () => { // Mock getConfig to include the key we want to clear vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, customPrompt: 'custom value', }); // Mock getDefaultConfig to include the key we want to clear vi.mocked(getDefaultConfig).mockReturnValue({ - githubMode: false, + githubMode: true, customPrompt: '', }); @@ -333,7 +333,7 @@ describe('Config Command', () => { it('should handle non-existent key for clear command', async () => { vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, }); await command.handler!({ @@ -370,13 +370,13 @@ describe('Config Command', () => { it('should list all configuration values with default indicators', async () => { // Mock getConfig to return a mix of default and custom values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, // default value + githubMode: true, // default value customPrompt: 'custom value', // custom value }); // Mock getDefaultConfig to return the default values vi.mocked(getDefaultConfig).mockReturnValue({ - githubMode: false, + githubMode: true, customPrompt: '', }); diff --git a/packages/cli/tests/settings/config-defaults.test.ts b/packages/cli/tests/settings/config-defaults.test.ts index d70bc72..ef03e63 100644 --- a/packages/cli/tests/settings/config-defaults.test.ts +++ b/packages/cli/tests/settings/config-defaults.test.ts @@ -54,7 +54,7 @@ describe('Config Defaults for CLI Options', () => { it('should use config values for headless, userSession, and pageFilter when not provided in args', async () => { // Setup mock config with default values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, headless: true, userSession: false, pageFilter: 'none', @@ -96,7 +96,7 @@ describe('Config Defaults for CLI Options', () => { it('should use command line args for headless, userSession, and pageFilter when provided', async () => { // Setup mock config with default values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, headless: true, // Default is true userSession: false, // Default is false pageFilter: 'none', // Default is none @@ -132,7 +132,7 @@ describe('Config Defaults for CLI Options', () => { it('should test the actual toolAgent call with config defaults', async () => { // Setup mock config with default values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, headless: true, userSession: false, pageFilter: 'none', @@ -180,7 +180,7 @@ describe('Config Defaults for CLI Options', () => { it('should test the actual toolAgent call with command line args', async () => { // Setup mock config with default values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, headless: true, // Default is true userSession: false, // Default is false pageFilter: 'none', // Default is none diff --git a/packages/cli/tests/settings/config.test.ts b/packages/cli/tests/settings/config.test.ts index 450db5b..2567a56 100644 --- a/packages/cli/tests/settings/config.test.ts +++ b/packages/cli/tests/settings/config.test.ts @@ -61,7 +61,7 @@ describe('Config', () => { describe('updateConfig', () => { it('should update config and write to file', () => { - const currentConfig = { githubMode: false }; + const currentConfig = { githubMode: true }; const newConfig = { githubMode: true }; vi.mocked(fs.existsSync).mockReturnValue(true); vi.mocked(fs.readFileSync).mockReturnValue(JSON.stringify(currentConfig)); @@ -77,7 +77,7 @@ describe('Config', () => { }); it('should merge partial config with existing config', () => { - const currentConfig = { githubMode: false, existingSetting: 'value' }; + const currentConfig = { githubMode: true, existingSetting: 'value' }; const partialConfig = { githubMode: true }; vi.mocked(fs.existsSync).mockReturnValue(true); vi.mocked(fs.readFileSync).mockReturnValue(JSON.stringify(currentConfig)); diff --git a/packages/cli/tests/settings/configDefaults.test.ts b/packages/cli/tests/settings/configDefaults.test.ts index c85a504..8a3ea4e 100644 --- a/packages/cli/tests/settings/configDefaults.test.ts +++ b/packages/cli/tests/settings/configDefaults.test.ts @@ -54,7 +54,7 @@ describe('Config Defaults for CLI Options', () => { it('should use config values for headless, userSession, and pageFilter when not provided in args', async () => { // Setup mock config with default values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, headless: true, userSession: false, pageFilter: 'none', @@ -90,7 +90,7 @@ describe('Config Defaults for CLI Options', () => { it('should use command line args for headless, userSession, and pageFilter when provided', async () => { // Setup mock config with default values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, headless: true, // Default is true userSession: false, // Default is false pageFilter: 'none', // Default is none @@ -126,7 +126,7 @@ describe('Config Defaults for CLI Options', () => { it('should test the actual toolAgent call with config defaults', async () => { // Setup mock config with default values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, headless: true, userSession: false, pageFilter: 'none', @@ -174,7 +174,7 @@ describe('Config Defaults for CLI Options', () => { it('should test the actual toolAgent call with command line args', async () => { // Setup mock config with default values vi.mocked(getConfig).mockReturnValue({ - githubMode: false, + githubMode: true, headless: true, // Default is true userSession: false, // Default is false pageFilter: 'none', // Default is none