Skip to content

Commit a509f5e

Browse files
committed
add hot reloading for local agents
1 parent 57b58e4 commit a509f5e

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

.agents/brainstormer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AgentConfig } from './types/agent-config'
1+
import type { AgentConfig } from './types/agent-config'
22

33
const config: AgentConfig = {
44
id: 'brainstormer',

npm-app/src/agents/load-agents.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ export async function loadLocalAgents({
3737
let agentConfig: any
3838
let agentModule: any
3939
try {
40-
agentModule = await import(fullPath)
40+
agentModule = await require(fullPath)
4141
} catch (error: any) {
4242
if (verbose) {
4343
console.error('Error importing agent:', error)
4444
}
4545
continue
4646
}
47+
delete require.cache[fullPath]
4748

4849
try {
4950
agentConfig = agentModule.default

npm-app/src/cli.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,7 @@ export class CLI {
552552

553553
// If a user prompt is provided, send it immediately
554554
if (userPrompt) {
555-
const { responsePromise } = await client.sendUserInput(userPrompt)
556-
await responsePromise
555+
await this.forwardUserInput(userPrompt)
557556
}
558557
}
559558

npm-app/src/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import {
5050
import { match, P } from 'ts-pattern'
5151
import { z } from 'zod'
5252

53-
import { getLoadedAgentNames } from './agents/load-agents'
53+
import { getLoadedAgentNames, loadLocalAgents } from './agents/load-agents'
5454
import { getBackgroundProcessUpdates } from './background-process-manager'
5555
import { activeBrowserRunner } from './browser-runner'
5656
import { setMessages } from './chat-storage'
@@ -976,6 +976,7 @@ export class Client {
976976
loadCodebuffConfig().maxAgentSteps
977977

978978
this.sessionState.fileContext.cwd = getWorkingDirectory()
979+
this.sessionState.fileContext.agentTemplates = await loadLocalAgents({})
979980

980981
const userInputId =
981982
`mc-input-` + Math.random().toString(36).substring(2, 15)

0 commit comments

Comments
 (0)