Skip to content

Commit b99e353

Browse files
committed
Refactor agent.js to use named function and add error handling with process exit
1 parent 6de18af commit b99e353

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

examples/mcp/agent.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Exemplo de agente integrado ao MCP server de weather
22
const { Agent, Runner } = require('../../src');
33

4-
(async () => {
4+
async function main() {
55
// URL do MCP server (ajuste conforme necessário)
66
const mcpWeatherUrl = 'http://localhost:3001/sse';
77

@@ -24,4 +24,12 @@ const { Agent, Runner } = require('../../src');
2424
// Executa o agente, que decide qual ferramenta usar
2525
const result = await Runner.run(agent, input);
2626
console.log('Saída final do agente:', result.finalOutput);
27-
})();
27+
28+
process.exit(0);
29+
}
30+
31+
// Executar o exemplo
32+
main().catch(err => {
33+
console.error(err);
34+
process.exit(1);
35+
});

0 commit comments

Comments
 (0)