Skip to main content

Server Specification

The formal contract that every Weblisk server implementation must fulfil — agent protocol, orchestrator endpoints, identity, and error handling.

Overview

The Weblisk Agent Protocol v1 defines how autonomous agents register with an orchestrator, receive tasks, execute domain-specific logic, communicate with each other, and report results. All communication is HTTP + JSON. Any implementation — regardless of language or platform — that conforms to this specification is compatible with the Weblisk client framework, any blueprint, and any agent.

The specification covers two component types:

The protocol supports the continuous optimisation lifecycle: strategise → observe → recommend → execute → feedback.

Conventions

Design Principles

Agent Endpoints

Every agent MUST serve these 5 endpoints on a single HTTP port:

PathMethodAuthPurpose
/v1/describePOSTNoReturn the agent's AgentManifest — identity, capabilities, inputs, outputs
/v1/executePOSTYesExecute a task; accepts TaskRequest, returns signed TaskResult
/v1/healthGETNoHealth check — returns HealthStatus with name, version, uptime, metrics
/v1/messagePOSTYesAgent-to-agent messaging — dispatches to handler by action field
/v1/servicesPOSTYesAccept service directory updates pushed by the orchestrator

POST /v1/describe

Returns the agent's full manifest. No auth required — this is how the orchestrator discovers agent capabilities.

AgentManifest response
{
  "name": "seo-analyzer",
  "type": "agent",
  "version": "1.0.0",
  "description": "Scans HTML files and analyzes SEO metadata",
  "url": "http://localhost:9710",
  "public_key": "<64-char hex Ed25519 public key>",
  "capabilities": [
    {"name": "file:read", "resources": ["app/**/*.html"]},
    {"name": "llm:chat", "resources": []},
    {"name": "agent:message", "resources": []}
  ],
  "inputs": [
    {"name": "html_files", "type": "file_list", "description": "HTML files to analyze"}
  ],
  "outputs": [
    {"name": "seo_report", "type": "json", "description": "SEO analysis with proposed changes"}
  ],
  "collaborators": ["a11y-checker"],
  "approval": "required",
  "max_concurrent": 5
}

POST /v1/execute

Executes a task. The agent MUST validate the request has a non-empty id and token, update its internal service directory from context.services, execute domain-specific logic, and return a signed TaskResult with task_id matching the request id.

Task results include a status of success, failed, or pending_approval. Results MAY contain changes (proposed file modifications), observations (measurements), and recommendations (suggested actions).

POST /v1/message

Direct agent-to-agent messaging. The agent MUST verify the sender's signature against their public key from the service directory, dispatch to the appropriate handler based on the action field, and sign the response. Signature covers: JSON.stringify({from, to, action, payload}).

Orchestrator Endpoints

The orchestrator is the central coordination service. It does NOT execute agent logic — it manages registration, routing, security, and discovery.

PathMethodAuthPurpose
/v1/registerPOSTNoAgent registration — this is how agents get auth tokens
/v1/registerDELETEYesAgent deregistration — removes from registry and broadcasts
/v1/taskPOSTYesSubmit a task — routes to target agent via domain or directly
/v1/channelPOSTYesBroker a secure agent-to-agent channel (requires agent:message capability)
/v1/servicesGETYesCurrent service directory — all registered agents
/v1/healthGETNoOrchestrator health with agent/domain/channel counts
/v1/auditGETYesAppend-only audit log — every operation recorded
/v1/strategyGET/POSTYesCreate, update, and list business strategies
/v1/contextGET/POSTYesSet and retrieve entity context (company, project, site)
/v1/observationsGETYesObservation history with filtering and pagination
/v1/approveGET/POSTYesList pending recommendations; approve or reject them

Registration Flow

Agents register by sending their signed manifest to POST /v1/register:

  1. Agent builds its AgentManifest and signs it with its Ed25519 private key
  2. Sends {manifest, signature, timestamp} to the orchestrator
  3. Orchestrator verifies the signature against manifest.public_key
  4. Enforces replay protection — rejects if |now - timestamp| > 300 seconds
  5. Generates a unique agent_id and issues a WLT auth token (24-hour TTL)
  6. If manifest.type = "domain": evaluates required_agents availability
  7. Logs audit entry and broadcasts updated ServiceDirectory to all other agents
  8. Returns RegisterResponse with token, service directory, and negotiated protocol version

Task Routing

When a task is submitted to POST /v1/task, the orchestrator routes it based on the target agent's type:

The orchestrator injects context (workspace_root, service directory, entity context) and a trace_id for distributed tracing. If the response contains observations or recommendations, they are stored for the lifecycle loop.

Channel Brokering

Agents that need direct communication request a channel via POST /v1/channel. The orchestrator verifies the requester has the agent:message capability, generates a channel ID and a time-limited channel token (1-hour TTL), stores the active channel, signs the grant, and returns a ChannelGrant with the target agent's URL and public key.

Strategy & Lifecycle Endpoints

The orchestrator manages the continuous optimisation loop through several supporting endpoints:

Identity & Security

Every agent and orchestrator generates an Ed25519 key pair (RFC 8032) on first startup. Keys are stored in .weblisk/keys/ with restricted permissions. See Protocols for the full signing and token specification.

WLT Token Format

Tokens follow the format: base64url(header).base64url(payload).base64url(signature)

ClaimTypeDescription
substringAgent name or identity
issstringIssuer — "orchestrator" or agent name
iatint64Issued at (Unix epoch seconds)
expint64Expiry (Unix epoch seconds); 0 = no expiry
cap[]stringGranted capabilities (e.g. file:read, llm:chat)
cidstringChannel ID — for channel-scoped tokens

Token lifetimes: agent auth tokens last 24 hours; channel tokens last 1 hour.

The header alg field enables future algorithm agility — e.g. ML-DSA / FIPS 204 (post-quantum) with zero protocol changes.

Auth Middleware

Applied to ALL orchestrator endpoints except GET /v1/health and POST /v1/register:

  1. Check Authorization: Bearer <token> header
  2. If no header, check request body for token field
  3. Verify token signature against orchestrator's public key
  4. Check token expiry
  5. On failure → 401 {"error": "valid token required — register first"}
  6. On success → pass decoded claims to handler

Standard Capabilities

CapabilityDescription
file:readRead files — scoped by glob patterns in resources
file:writeWrite or modify files
llm:chatUse LLM for analysis
agent:messageCommunicate with other agents
workflow:executeExecute multi-agent workflows (domain controllers)
http:get / http:sendMake external HTTP requests
http:receiveReceive inbound HTTP requests
database:read / database:writeRead from or write to data stores
realtime:publishPublish to real-time channels

Error Handling

All errors MUST return JSON using the ErrorResponse format. Implementations SHOULD include code, category, and retryable when available.

ErrorResponse example
{
  "error": "forwarding to agent failed — connection refused",
  "code": "AGENT_UNREACHABLE",
  "category": "transient",
  "retryable": true
}

Error Categories

Standard Error Codes

CodeHTTPCategoryDescription
INVALID_REQUEST400permanentMissing or malformed fields
INVALID_SIGNATURE401permanentEd25519 signature verification failed
TOKEN_EXPIRED401transientToken past expiry — re-register to get a new one
FORBIDDEN403permanentMissing required capability
NOT_FOUND404permanentAgent or resource not in registry
RATE_LIMITED429transientToo many requests — respect Retry-After header
INTERNAL_ERROR500transientUnexpected server error
AGENT_UNREACHABLE502transientOrchestrator could not reach target agent
AGENT_TIMEOUT504transientTarget agent did not respond within timeout
UNSUPPORTED_VERSION400permanentAgent requested an unsupported protocol version
PHASE_FAILED500variesWorkflow phase failed — check detail.phase_name
PARTIAL_FAILURE207partialSome phases succeeded, some failed

Observability

Trace ID Propagation

Every task submission SHOULD include a trace_id in TaskContext. If the caller does not provide one, the orchestrator MUST generate a unique trace_id (32 hex chars) and inject it before forwarding. The trace ID is propagated through all downstream calls:

Trace propagation
Client → POST /v1/task (trace_id in context)
  → Orchestrator forwards to domain → POST /v1/execute (same trace_id)
    → Domain dispatches to agent → POST /v1/message (same trace_id)

Structured Logging

All components SHOULD emit structured JSON logs to stderr. Required fields:

FieldDescription
tsUnix epoch seconds
leveldebug, info, warn, error
msgHuman-readable message
componentComponent name (e.g. orchestrator, seo, seo-analyzer)
trace_idCorrelation ID (when available)

Audit log entries (see GET /v1/audit) are a separate persistent record. Structured logs are operational and ephemeral — for debugging and monitoring, not compliance.

Audit Logging

Every orchestrator operation creates an AuditEntry with actor, action, target, and status. Entries are logged to stderr in real-time AND stored in an append-only in-memory log.

ActionDescription
registerAgent registered
deregisterAgent deregistered
taskTask submitted or forwarded
channelChannel brokered
messageMessage relayed
strategyStrategy created or updated
approvalRecommendation accepted or rejected
observationObservation recorded
recommendationRecommendation stored
feedbackFeedback received

Version Negotiation

On registration, the orchestrator reads the agent's manifest.protocol_version (default "1" if omitted). If the orchestrator supports that version, registration succeeds and RegisterResponse.protocol_version confirms the negotiated version. If the requested version is not in supported_versions, the orchestrator rejects with 400 and error code UNSUPPORTED_VERSION.

Server Lifecycle

A compliant orchestrator follows this startup sequence:

  1. Load Identity — load or generate an Ed25519 key pair (name: "orchestrator"); keys stored in .weblisk/keys/
  2. Initialise Stores — empty agent registry, channel registry, audit log, strategy/observation/recommendation stores
  3. Register Routes — bind HTTP handlers for all protocol endpoints
  4. Start HTTP Server — listen on configured port (default 9800, configurable via --port or WL_ORCH_PORT)
  5. Print Startup Info — URL, public key, instructions for registering agents
  6. Serve — block and handle requests; agents register themselves after startup

On shutdown, the orchestrator drains active connections, deregisters agents, and flushes the audit log.

Verification Checklist

Every compliant implementation MUST pass these checks:

Agent Verification

Orchestrator Verification

The specification is versioned alongside the framework. Breaking changes only occur in major versions. The protocol's forward-compatibility rule (ignore unknown fields) means new optional fields can be added in minor versions without breaking existing agents.