- protocol.py: pydantic models for all AICC message types (envelope, session_init, tool_call, tool_result, event, error, heartbeat) - bridge.py: Bridge with @bridge.tool registration, capability checks, session management, serve_forever - client.py: AICCClient with single background reader (safe on concurrent transports like WebSocket), call_tool, events, manifest - tool.py: @tool decorator with schema generation from type hints - schema.py: JSON Schema generation (str/int/float/bool, list, dict, Optional, pydantic models) - transport: Transport protocol, InProcessTransport, WebSocket client+server - tests: 12 passing (integration, schema, websocket roundtrip) - examples: bridge_minimal.py + agent_minimal.py (verified end-to-end)
31 lines
894 B
Python
31 lines
894 B
Python
"""Minimal AICC agent connecting to the bridge example.
|
|
|
|
Run bridge_minimal.py first, then:
|
|
python examples/agent_minimal.py
|
|
"""
|
|
|
|
import asyncio
|
|
|
|
from aicc import AICCClient
|
|
from aicc.transport import WebSocketClientTransport
|
|
|
|
|
|
async def main() -> None:
|
|
async with AICCClient(WebSocketClientTransport("ws://127.0.0.1:8765")) as client:
|
|
manifest = await client.handshake()
|
|
print(f"Connected to world: {manifest.world.name} ({manifest.world.kind})")
|
|
print(f"Tools: {[t.id for t in manifest.tools]}")
|
|
|
|
res = await client.call_tool("proprioception", {})
|
|
print(f"proprioception -> {res.output}")
|
|
|
|
res = await client.call_tool("move", {"forward": 2.5})
|
|
print(f"move -> {res.output}")
|
|
|
|
res = await client.call_tool("turn", {"yaw": -45})
|
|
print(f"turn -> {res.output}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|