MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / _serve

Function _serve

src/entrypoints/agent_server_cli.py:189–218  ·  view source on GitHub ↗
(args, workspace: str, agent_config: AgentServerConfig)

Source from the content-addressed store, hash-verified

187
188
189async def _serve(args, workspace: str, agent_config: AgentServerConfig) -> int:
190 index_path = Path.home() / ".clawcodex" / "server-sessions.json"
191 index_path.parent.mkdir(parents=True, exist_ok=True)
192
193 server_config = ServerConfig(
194 host=args.host,
195 port=args.port,
196 auth_token=args.token or "",
197 workspace=workspace,
198 )
199 manager = SessionManager(workspace=workspace, index_path=index_path)
200 spawn = make_spawn_agent(agent_config)
201 server = DirectConnectServer(config=server_config, manager=manager, spawn_agent=spawn)
202
203 await server.start()
204 http_port = server.bound_http_port
205 base = f"{args.host}:{http_port}"
206 print(f"agent-server: protocol v{PROTOCOL_VERSION}")
207 print(f"agent-server: workspace {workspace}")
208 print(f"agent-server: listening on http://{base} (POST /sessions)")
209 print(f"agent-server: connect a TUI with cc://{base}")
210 if args.token:
211 print("agent-server: POST /sessions requires Authorization: Bearer <token>")
212 print("agent-server: Ctrl-C to stop")
213
214 try:
215 await server.serve_forever()
216 finally:
217 await server.stop()
218 return 0
219
220
221__all__ = ["run_agent_server_subcommand"]

Callers 1

Calls 7

startMethod · 0.95
serve_foreverMethod · 0.95
stopMethod · 0.95
ServerConfigClass · 0.90
SessionManagerClass · 0.90
make_spawn_agentFunction · 0.90
DirectConnectServerClass · 0.90

Tested by

no test coverage detected