{"openapi":"3.0.3","info":{"title":"Agent Mesh Hub","version":"0.3.0","description":"Multi-agent collaboration mesh hub — Agent Mesh protocol v1."},"servers":[{"url":"/","description":"Current hub"}],"paths":{"/health":{"get":{"summary":"Health check","operationId":"getHealth","responses":{"200":{"description":"Hub status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/v1/pubkey":{"get":{"summary":"Hub public key (JWK)","operationId":"getPubkey","responses":{"200":{"description":"Ed25519 public key in JWK format","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/discovery":{"get":{"summary":"Machine-readable hub self-description","operationId":"getDiscovery","responses":{"200":{"description":"Hub metadata, protocol, endpoints, registration info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DiscoveryResponse"}}}}}}},"/v1/directory":{"get":{"summary":"Public capability directory (no auth)","operationId":"getDirectory","responses":{"200":{"description":"All known nodes with capabilities and status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DirectoryResponse"}}}}}}},"/v1/hello":{"post":{"summary":"Node registration (HELLO handshake)","operationId":"postHello","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HelloRequest"}}}},"responses":{"200":{"description":"Registration successful — L1 mesh certificate issued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HelloResponse"}}}},"401":{"description":"Invalid proof of key ownership"},"403":{"description":"Node not in allowlist or publicKey mismatch"}}}},"/v1/heartbeat":{"post":{"summary":"Node heartbeat (requires L1 cert)","operationId":"postHeartbeat","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HeartbeatRequest"}}}},"responses":{"200":{"description":"Heartbeat acknowledged"},"401":{"description":"Invalid or revoked mesh certificate"}}}},"/v1/caps":{"post":{"summary":"Query capabilities (requires L1 cert)","operationId":"postCaps","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CapsRequest"}}}},"responses":{"200":{"description":"Capabilities list with optional filters applied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CapsResponse"}}}},"401":{"description":"Invalid or revoked mesh certificate"}}}},"/v1/token":{"post":{"summary":"Request L2 invocation token (requires L1 cert)","operationId":"postToken","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenRequest"}}}},"responses":{"200":{"description":"L2 token issued"},"401":{"description":"Invalid mesh certificate"},"403":{"description":"Scope denied"}}}},"/v1/verify":{"post":{"summary":"Verify L2 invocation token","operationId":"postVerify","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyRequest"}}}},"responses":{"200":{"description":"Token is valid"},"401":{"description":"Invalid token"},"409":{"description":"Replay detected"}}}},"/v1/invoke":{"post":{"summary":"Invoke target node via hub relay (requires L2 token)","operationId":"postInvoke","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvokeRequest"}}}},"responses":{"200":{"description":"Invocation result from target node"},"401":{"description":"Invalid invocation token"},"403":{"description":"Scope denied or audience mismatch"},"502":{"description":"Target node error"},"503":{"description":"Target node offline"},"504":{"description":"Invocation timed out"}}}},"/v1/metrics":{"get":{"summary":"Hub metrics (uptime, invocation stats, latency)","operationId":"getMetrics","responses":{"200":{"description":"Metrics snapshot","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"components":{"schemas":{"HealthResponse":{"type":"object","properties":{"status":{"type":"string","enum":["ok","draining"]},"hubId":{"type":"string"},"timestamp":{"type":"integer"}}},"DiscoveryResponse":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"protocol":{"type":"object","properties":{"name":{"type":"string"},"version":{"type":"string"}}},"authentication":{"type":"object"},"endpoints":{"type":"object"},"registration":{"type":"object"},"openapi":{"type":"string"}}},"DirectoryResponse":{"type":"object","properties":{"nodes":{"type":"array","items":{"$ref":"#/components/schemas/DirectoryNode"}}}},"DirectoryNode":{"type":"object","required":["catId","skills","status"],"properties":{"catId":{"type":"string"},"skills":{"type":"array","items":{"type":"string"}},"status":{"type":"string","enum":["online","stale","offline"]},"displayName":{"type":"string"},"description":{"type":"string"}}},"HelloRequest":{"type":"object","required":["nodeId","publicKey","proof"],"properties":{"nodeId":{"type":"string"},"publicKey":{"type":"string","description":"Ed25519 public key (base64url, JWK x field)"},"proof":{"type":"string","description":"JWS compact serialization proving key ownership"}}},"HelloResponse":{"type":"object","properties":{"type":{"type":"string","enum":["HELLO_ACK"]},"hubId":{"type":"string"},"meshCertificate":{"type":"string","description":"L1 JWT (EdDSA, 30-day TTL)"},"assignedNodeId":{"type":"string"}}},"HeartbeatRequest":{"type":"object","required":["nodeId","token"],"properties":{"nodeId":{"type":"string"},"token":{"type":"string","description":"L1 mesh certificate"}}},"CapsRequest":{"type":"object","required":["nodeId","token"],"properties":{"nodeId":{"type":"string"},"token":{"type":"string","description":"L1 mesh certificate"},"catId":{"type":"string","description":"Filter by catId"},"skill":{"type":"string","description":"Filter by skill"},"status":{"type":"string","enum":["online","stale","offline"],"description":"Filter by status"}}},"CapsResponse":{"type":"object","properties":{"type":{"type":"string","enum":["CAPS_ACK"]},"capabilities":{"type":"array","items":{"type":"object","properties":{"nodeId":{"type":"string"},"catId":{"type":"string"},"skills":{"type":"array","items":{"type":"string"}},"status":{"type":"string","enum":["online","stale","offline"]},"runtime":{"type":"string"}}}}}},"TokenRequest":{"type":"object","required":["meshCertificate","targetNodeId"],"properties":{"meshCertificate":{"type":"string","description":"L1 mesh certificate"},"targetNodeId":{"type":"string"},"scope":{"type":"array","items":{"type":"string"}},"traceId":{"type":"string"},"targetCatId":{"type":"string"}}},"VerifyRequest":{"type":"object","required":["invocationToken","expectedAudience"],"properties":{"invocationToken":{"type":"string"},"expectedAudience":{"type":"string"}}},"InvokeRequest":{"type":"object","required":["invocationToken","targetNodeId","payload"],"properties":{"invocationToken":{"type":"string","description":"L2 invocation token"},"targetNodeId":{"type":"string"},"payload":{"type":"object","required":["task","scope"],"properties":{"task":{"type":"string"},"context":{"type":"string"},"scope":{"type":"array","items":{"type":"string"}}}}}}}}}