-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UI and logging updates * Add agent force stop route * Add Groq Llama 3.3 70b * Improve repo summary index generation * Add Jira.createIssue * Default the setTracer checkForcedStoppedFunc for tests * Add Google Cloud security command center function * Add Gemini Flash 2.0 support
- Loading branch information
1 parent
a33d39d
commit 6848b70
Showing
31 changed files
with
907 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Backend code standards | ||
|
||
## Test code standards | ||
|
||
Unit test files should be in the same directory as the source file. | ||
|
||
Any usage of chai-as-promised should use async/await | ||
``` | ||
it('should work well with async/await', async () => { | ||
(await Promise.resolve(42)).should.equal(42) | ||
await Promise.reject(new Error()).should.be.rejectedWith(Error); | ||
}); | ||
``` | ||
|
||
## Tool/function classes | ||
|
||
Function classes with the @funcClass(__filename) must only have the default constructor. | ||
|
||
Always use the Filesystem class in src/functions/storage/filesystem.ts to read/search/write to the local filesystem. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { agentContext, agentContextStorage } from '#agent/agentContextLocalStorage'; | ||
import { isExecuting } from '#agent/agentContextTypes'; | ||
import { currentUser } from '#user/userService/userContext'; | ||
import { appContext } from '../applicationContext'; | ||
|
||
const agentsToStop = new Set<string>(); | ||
|
||
/** | ||
* Terminates the execution of an agent as soon as possible. | ||
* @param agentId | ||
*/ | ||
export async function forceStopAgent(agentId: string): Promise<void> { | ||
const agent = await appContext().agentStateService.load(agentId); | ||
if (!agent) throw new Error(`No agent with id ${agentId}`); | ||
if (!isExecuting(agent)) throw new Error(`Agent ${agentId} is not in an executing state`); | ||
if (agent.user.id !== currentUser().id) throw new Error('Cannot stop an agent owned by another user'); | ||
|
||
agentsToStop.add(agent.agentId); | ||
|
||
// Reload the agent every 5 seconds for up to a minute and see if it's not in an executing state | ||
return new Promise((resolve, reject) => { | ||
const startTime = Date.now(); | ||
const interval = setInterval(async () => { | ||
const updatedAgent = await appContext().agentStateService.load(agentId); | ||
// Agent should be in an error state if the checkForceStopped() function has been called in its execution | ||
if (!isExecuting(updatedAgent)) { | ||
clearInterval(interval); | ||
agentsToStop.delete(agent.agentId); | ||
resolve(); | ||
} else if (Date.now() - startTime >= 60000) { | ||
// 1 minute timeout | ||
clearInterval(interval); | ||
agentsToStop.delete(agent.agentId); | ||
reject(new Error(`Agent ${agentId} did not stop executing within 1 minute`)); | ||
} | ||
}, 5000); | ||
}); | ||
} | ||
|
||
/** | ||
* Checks if the current agent should be force stopped | ||
*/ | ||
export function checkForceStopped(): void { | ||
const agent = agentContext(); | ||
if (!agent) return; | ||
const agentId = typeof agent === 'string' ? agent : agent.agentId; | ||
|
||
if (agentsToStop.has(agentId)) { | ||
agentsToStop.delete(agentId); | ||
throw new Error(`Agent ${agentId} has been force stopped by user ${currentUser().id}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.