-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic.ts
More file actions
32 lines (29 loc) · 983 Bytes
/
basic.ts
File metadata and controls
32 lines (29 loc) · 983 Bytes
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
import { Agent, BashTool, FileReadTool } from "@avasis-ai/synthcode";
import { AnthropicProvider } from "@avasis-ai/synthcode/llm";
const agent = new Agent({
model: new AnthropicProvider({
apiKey: process.env.ANTHROPIC_API_KEY!,
model: "claude-sonnet-4-20250514",
}),
tools: [new BashTool(), new FileReadTool()],
systemPrompt: "You are a helpful coding assistant. Be concise.",
});
console.log("Synth Basic Agent\n");
for await (const event of agent.run("What files are in the current directory?")) {
switch (event.type) {
case "text":
process.stdout.write(event.text);
break;
case "tool_use":
console.log(`\n [${event.name}] ${JSON.stringify(event.input)}`);
break;
case "tool_result":
if (event.isError) {
console.log(`\n [ERROR] ${event.output}`);
}
break;
case "done":
console.log(`\n\n---\nTokens: ${event.usage.inputTokens} in, ${event.usage.outputTokens} out`);
break;
}
}