% git clone https://github.com/google/A2A
Cloning into 'A2A'...
remote: Enumerating objects: 320, done.
remote: Counting objects: 100% (90/90), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 320 (delta 31), reused 29 (delta 18), pack-reused 230 (from 2)
Receiving objects: 100% (320/320), 1.86 MiB | 20.21 MiB/s, done.
Resolving deltas: 100% (73/73), done.
%
cd A2A/samples/js
% cd A2A/samples/js
js %
README.mdに記載されてい内容を確認します。マークダウンなのでブラウザからA2A/samples/jsを参照します。
% npm install genkit
npm warn deprecated @types/handlebars@4.1.0: This is a stub types definition. handlebars provides its own type definitions, so you do not need this installed.
added 401 packages, and audited 402 packages in 9s
44 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
js %
js % npm run agents:coder
> a2a-samples-js@0.1.0 agents:coder
> npx tsx src/agents/coder/index.ts
[CoderAgent] Server started on http://localhost:41241
[CoderAgent] Press Ctrl+C to stop the server
A2A Server listening on port 41241 at path /
js % npm run a2a:cli
> a2a-samples-js@0.1.0 a2a:cli
> npx tsx src/cli.ts
A2A Terminal Client
Agent URL: http://localhost:41241
Attempting to fetch agent card from: http://localhost:41241/.well-known/agent.json
✓ Agent Card Found:
Name: Coder Agent
Description: An agent that generates code based on natural language instructions and streams file outputs.
Version: 0.0.1
Starting Task ID: fe3dd9e3-0bf2-4710-b2cb-b0032fafe427
Enter messages, or use '/new' to start a new task.
Coder Agent > You:
Coder Agent > You: に"Write a python function to calculate fibonacci numbers."を入力します。
Enter messages, or use '/new' to start a new task.
Coder Agent > You: Write a python function to calculate fibonacci numbers.
Sending...
Coder Agent [11:00:50]: ⏳ Status: working
Part 1: 📝 Text: Generating code...
Coder Agent > You:
Coder Agent [11:00:55]: 📄 Artifact Received: fibonacci.py (Index: 0)
Part 1: 📝 Text: # This file contains a function to calculate Fibonacci numbers iteratively.
def fibonacci(n: int) -> int:
"""
Calculates the nth Fibonacci number iteratively.
Args:
n: The position in the Fibonacci sequence (non-negative integer).
Returns:
The nth Fibonacci number. Returns 0 for n <= 0.
"""
if n <= 0:
return 0
elif n == 1:
return 1
else:
a, b = 0, 1
# Iterate n-1 times because we already have the first number (b=1 for n=1)
for _ in range(n - 1):
a, b = b, a + b
return b
# Example usage (optional):
# print(fibonacci(0)) # Output: 0
# print(fibonacci(1)) # Output: 1
# print(fibonacci(10)) # Output: 55
# print(fibonacci(20)) # Output: 6765
Coder Agent [11:00:55]: ✅ Status: completed
Part 1: 📝 Text: Generated files: fibonacci.py
SSE stream finished for method tasks/sendSubscribe.
--- End of response for this input ---
Coder Agent > You:
% npm run agents:coder
> a2a-samples-js@0.1.0 agents:coder
> npx tsx src/agents/coder/index.ts
[CoderAgent] Server started on http://localhost:41241
[CoderAgent] Server started on http://localhost:41241
[CoderAgent] Press Ctrl+C to stop the server
A2A Server listening on port 41241 at path /
[[Task 3262b5fd-c805-faa8-e063-0200590aca0e] Created new task and history.
[CoderAgent] Emitting completed file (index 0): fib
[CoderAgent] Emitting final file (index 1): fibonacci.py
[Task 3262b5fd-c807-faa8-e063-0200590aca0e] Created new task and history.
[CoderAgent] Emitting final file (index 0): fibonacci.py
[Task 3262b5fd-c80a-faa8-e063-0200590aca0e] Created new task and history.
[CoderAgent] Emitting final file (index 0): fibonacci.py