gitoriaLog in with ident

antcolony

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit7f9660ee7f9660eeState of 2026-09-27, before the move to gitoriamre7f9660ee/lib/AgentServer.hl

1.0 KB

  1. // AgentServer.hl — the scheduler's door for its agents (mission 035, antcolony#14): a tiny HTTP server (hl:http1) that
  2. // hands every request to `handler(method, path, body, authorization)` and answers { status, body } as JSON. As a class
  3. // file, so the daemon can give it a closure over its own state: `new AgentServer(port = …, host = …, handler = fn)`.
  4. // Hybriel has no WebSocket CLIENT (hybriel#109), so agents connect OUT with plain HTTPS requests (agent.hl): the agent
  5. // asks, the scheduler answers — no connection is held open, a dropped one breaks nothing.
  6. import { NativeHttpServer, Response } from 'hl:http1'
  7. Number port = 0
  8. String host = '127.0.0.1'
  9. Function handler = null
  10. http = new NativeHttpServer(port = port, host = host)
  11. on http.request(req) {
  12. let auth = req.headers['authorization']
  13. if (auth == null) { auth = req.headers['Authorization'] }
  14. let out = handler(req.method, req.path, req.body, auth)
  15. return new Response(JSON.stringify(out.body), { status = out.status headers = { 'Content-Type' = 'application/json' } })
  16. }

Branches

Latest commits

  • 7f9660eeState of 2026-09-27, before the move to gitoriamre