forked from TrafficGuard/typedai
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcode.ts
More file actions
55 lines (46 loc) · 1.96 KB
/
code.ts
File metadata and controls
55 lines (46 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import '#fastify/trace-init/trace-init'; // leave an empty line next so this doesn't get sorted from the first line
import type { RunWorkflowConfig } from '#agent/autonomous/runAgentTypes';
import { runWorkflowAgent } from '#agent/workflow/workflowAgentRunner';
import { initApplicationContext } from '#app/applicationContext';
import { shutdownTrace } from '#fastify/trace-init/trace-init';
import { GitLab } from '#functions/scm/gitlab';
import { defaultLLMs } from '#llm/services/defaultLlms';
import type { AgentLLMs } from '#shared/agent/agent.model';
import { contentText, messageText } from '#shared/llm/llm.model';
import { CodeEditingAgent } from '#swe/codeEditingAgent';
import { beep } from '#utils/beep';
import { parseProcessArgs, saveAgentId } from './cli';
import { parsePromptWithImages } from './promptParser';
async function main() {
await initApplicationContext();
const agentLlms: AgentLLMs = defaultLLMs();
const { initialPrompt: rawPrompt, resumeAgentId } = parseProcessArgs();
const { textPrompt, userContent } = await parsePromptWithImages(rawPrompt);
console.log(`Prompt: ${textPrompt}`); // Log the text part
const config: RunWorkflowConfig = {
agentName: 'cli-code',
subtype: 'code',
llms: agentLlms,
functions: [GitLab], //FileSystem,
initialPrompt: textPrompt, // Use the parsed text prompt for config/logging if needed elsewhere
resumeAgentId,
humanInLoop: {
budget: 2,
},
};
const agentId = await runWorkflowAgent(config, async () => {
// Pass the full UserContent (text + images) to the agent
await new CodeEditingAgent().implementUserRequirements(contentText(userContent));
// await (agentContext().functions.getFunctionInstanceMap().Agent as Agent).saveMemory('memKey', 'content');
// return llms().easy.generateText('What colour is the sky. Respond in one word.');
});
if (agentId) {
saveAgentId('code', agentId);
}
await beep();
await shutdownTrace();
}
main().then(
() => console.log('done'),
(e) => console.error(e),
);