kollabor-engine
kollabor-engine is the local HTTP/SSE runtime for Kollabor.
It wraps the same core AI, tool, permission, profile, MCP, and hub pieces used by
the terminal app, but exposes them through a FastAPI service. The intended use is
a local companion daemon for kollabor-webui, browser-based control surfaces,
and other trusted local clients.
This package is not yet a production multi-user service. It currently relies on
in-memory sessions and process-global runtime state, so treat it as a per-user
local service bound to 127.0.0.1.
Current Role
- Headless HTTP API for creating chat sessions and sending turns.
- SSE streaming for model tokens, thinking content, tool events, permission prompts, and turn completion metadata.
- Local profile management over the existing Kollabor profile store.
- Session-owned permission manager and MCP integration.
- Hub mesh read/control endpoints for active local agents.
- Web UI backend for
kollabor-webui.
Architecture
The engine is a thin service layer over other workspace packages:
| Package | Engine Use |
|---|---|
kollabor-ai |
profiles, provider calls, streaming, tool-call parsing |
kollabor-agent |
tool execution, MCP connections, permissions |
kollabor-events |
per-session event bus and permission hooks |
kollabor-config |
profile/config compatibility |
kollabor-rpc |
hub-adjacent RPC foundations |
Main engine modules:
| Module | Responsibility |
|---|---|
server.py |
FastAPI app, auth middleware, global session registry |
session.py |
EngineSession, per-session AI/tool/permission state |
turn_runner.py |
multi-step LLM turn loop and SSE event production |
sse.py |
event payload builders |
routes/sessions.py |
session lifecycle, history, system prompt, session MCP |
routes/messages.py |
message stream and cancellation |
routes/permissions.py |
permission responses and approval mode |
routes/profiles.py |
profile CRUD and connectivity checks |
routes/mcp.py |
global MCP server config CRUD |
routes/hub.py / routes/hub_ws.py |
hub mesh REST and WebSocket views |
Usage
To run this alongside kollabor-webui in one step, use kollab --web-ui
from the repo root instead (see packages/kollabor-webui/README.md).
Start the local service on its own:
python -m kollabor_engine serve --host 127.0.0.1 --port 7433
On startup, the service writes a bearer token to:
~/.kollab/engine.token
Use that token for protected endpoints:
TOKEN="$(cat ~/.kollab/engine.token)"
curl -H "Authorization: Bearer $TOKEN" \
http://127.0.0.1:7433/sessions
Programmatic app creation (pass the listening port to enable Web UI persistence):
from kollabor_engine import create_app
app = create_app(port=7433)
Calling create_app() without a port preserves the non-persistent lifecycle used
by embedded/test integrations.
Web UI Agent Persistence
The kollab --web-ui launcher starts the engine with its selected port. Only
sessions created by that Web UI are marked persistent: the engine records a
per-port manifest at ~/.kollab/engine/webui-<port>.json with the daemon PID,
process start time, identity, workspace, socket, and conversation identifier.
The manifest is atomically updated with restrictive file permissions (user-only
on POSIX) and excludes credentials and conversation contents. A new engine adopts only a matching live
PID/socket/identity after the prior owner has shut down or exited, then restores
the session and history in the Web UI. POST /handover flushes that metadata
before an orderly launcher restart; crash recovery does not rely on it.
Closing or restarting the Web UI/engine detaches the engine connection without
stopping a persistent daemon. Web UI Delete and agent /quit remain explicit
stop actions. Agents launched by the terminal/CLI are not marked persistent and
keep their existing stop-on-engine-shutdown behavior.
API Surface
Health and metadata endpoints:
| Method | Path | Notes |
|---|---|---|
GET |
/health |
unauthenticated liveness check |
GET |
/version |
package and Python versions |
GET |
/status |
session count, providers, MCP status |
GET |
/ready |
profile/API credential readiness |
| POST | /handover | flush current WebUI-owned session metadata before a controlled restart; never stops a daemon |
Session and message endpoints:
| Method | Path | Notes |
|---|---|---|
POST |
/sessions |
create a session; workspace is the folder its daemon runs in (default the engine's own), and the session it creates reports that folder, never null |
GET |
/sessions |
list sessions |
GET |
/sessions/{session_id} |
inspect one session |
DELETE |
/sessions/{session_id} |
shut down and remove a session; a removal that stops the agent but cannot update its owner record returns 503 with a retry hint and keeps the session listed (deletion_pending), and a retried call clears the record without stopping it again |
GET |
/sessions/{session_id}/history |
read conversation history |
DELETE |
/sessions/{session_id}/history |
clear history, preserving system prompt |
POST |
/sessions/{session_id}/message |
send one turn; returns SSE until that turn's turn_complete. The engine always sends a request id, and a daemon that echoes it names it in the answering turn's request_ids, so a turn already running when the message came never ends this stream |
POST |
/sessions/{session_id}/cancel |
cancel active turn |
Permissions:
| Method | Path | Notes |
|---|---|---|
GET |
/sessions/{session_id}/permissions |
current approval mode and pending prompts, from the engine (never waits on the agent) |
POST |
/sessions/{session_id}/permission |
approve or deny a pending tool |
POST |
/sessions/{session_id}/permissions/mode |
set approval mode |
Profiles, MCP, and hub routes:
| Method | Path | Notes |
|---|---|---|
GET |
/profiles |
list configured profiles |
POST |
/profiles |
create profile; copy_from duplicates eligible stored profiles server-side, including ACP runtime fields; environment-backed keys require target-profile or global env configuration, keyring references remain shared, and OAuth/provisioned profiles are rejected; supplied fields override |
GET |
/profiles/choices |
every profile × model × effort level the web UI's model picker offers: each level the model takes (live catalog, else its provider's); an ACP harness's come from what its sessions reported |
GET |
/profiles/{name} |
inspect profile |
PUT |
/profiles/{name} |
update or rename profile |
DELETE |
/profiles/{name} |
delete profile |
POST |
/profiles/{name}/test |
test provider connectivity |
GET |
/mcp/servers |
list global MCP server config |
POST |
/mcp/servers |
add global MCP server config |
PUT |
/mcp/servers/{server_name} |
replace server config |
DELETE |
/mcp/servers/{server_name} |
remove server config |
GET |
/sessions/{session_id}/mcp |
session MCP connection status |
POST |
/sessions/{session_id}/mcp/{server_name}/connect |
intended session connect endpoint |
POST |
/sessions/{session_id}/mcp/{server_name}/disconnect |
disconnect session server |
GET |
/agents |
gem identity pool for one folder (?workspace=<abs folder>, default the engine's own): name, caste, color as [r, g, b], and available / active / state / task / agent_id / project / last_ran for the agents in that folder's hub only, so a gem or koordinator running in another folder is free here (a folder inside a git repo shares the repo's hub). ?scope=computer is the sidebar's view: an agent running in any folder shows its state, this folder's first. live lists every running agent in that scope, one per process (name, agent_id, state, current_task, solo, project), because agents holds one entry per name: a row reads its own agent by its instance (= agent_id), never by name. A gem listed alive for the first time is born (gets its random look). POST /sessions with identity + workspace applies the same rule and answers 409 when that folder already runs the name |
GET/PUT |
/agents/appearance |
gem looks: season, born.<name> (face, hat: rolled once, the first time GET /agents lists the gem alive; PUT never changes them) and the user's gems.<name> (face, hat, color); PUT normalizes (unknown keys dropped, at most 256 gems) and writes ~/.kollab/hub/appearance.json atomically |
GET |
/agents/bundles |
agent bundles a session can run (agent of POST /sessions): bundled, global, and the folder's own .kollab/agents (?workspace=<abs folder>, default the engine's own), so every listed name launches in that folder |
GET |
/hub/agents |
list active hub agents |
GET |
/hub/feed |
snapshot SSE feed |
WS |
/ws/hub/feed?token=<engine token> |
polling WebSocket feed (closed with 1008 without a valid token): hub_snapshot on connect, then agent_joined, agent_left and agent_state_changed (fires on a state or current_task change; carries identity, state, old_state, current_task) |
Known Gaps
These are current implementation gaps to address before treating the engine as a reliable service boundary:
- Session
workspaceis stored but not yet enforced for terminal and file tools. - Provider instances are singleton per provider type, which can leak model, base URL, headers, or credentials across sessions.
- The session MCP connect endpoint currently reports
connectingbut does not start a connection. - Anthropic profile testing imports a missing legacy
APIService. - Provider-registry and background watcher lifecycle still need a first-class lifespan model. WebUI-owned daemons now detach and reattach across engine shutdown; ordinary CLI sessions are still stopped by the engine.
Roadmap
Phase 1: Make the local daemon trustworthy
- Enforce session workspace for shell, file, and MCP tool execution.
- Replace provider-type singletons with config-scoped or session-scoped provider instances.
- Implement real session MCP connect behavior and add tests that prove tools are registered after connection.
- Fix
/profiles/{name}/testto use current provider APIs. - Add targeted tests for the findings above.
Phase 2: Harden service lifecycle
- Replace deprecated FastAPI
on_eventstartup/shutdown hooks with lifespan management. - Move the module-level session registry behind an explicit service object.
- Add provider-registry shutdown and WebSocket watcher cleanup to app shutdown.
- Add concurrency guards around session mutation, message turns, permission resolution, and history/system-prompt changes.
- Normalize error payloads and request/response schemas.
Phase 3: Clarify service boundaries
- Decide whether engine owns tool execution directly or wraps the existing CLI runtime as a client-facing API.
- Add a project/session namespace model so multiple workspaces can run without cwd or hub-presence ambiguity.
- Define which endpoints are local-only, trusted-client-only, or safe for broader exposure.
- Document compatibility expectations for
kollabor-webuiand external clients.
Phase 4: Productize the web/hub path
- Finish live hub event streaming beyond snapshot polling.
- Add richer permission scopes and UI feedback over SSE.
- Persist recoverable session metadata where useful.
- Add smoke tests that start engine + web UI against a temporary config home.
Development
Run package tests against the local source tree:
PYTHONPATH=packages/kollabor-engine/src:packages/kollabor-ai/src:packages/kollabor-agent/src:packages/kollabor-events/src:packages/kollabor-config/src:packages/kollabor-rpc/src:packages/kollabor-tui/src:packages/kollabor-plugins/src \
python -m pytest packages/kollabor-engine/tests -q
Without the PYTHONPATH override, this checkout may import an installed
kollabor_engine from site-packages instead of the local package.
Dependencies
kollabor-aikollabor-agentkollabor-eventskollabor-configfastapi >= 0.115uvicorn[standard] >= 0.32sse-starlette >= 2.1
License
Apache-2.0
Metadata
Release files for kollabor-engine 0.21.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kollabor_engine-0.21.1.tar.gz | 369.5 kB | Without provenance | Details for kollabor_engine-0.21.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kollabor_engine-0.21.1-py3-none-any.whl | Python 3 | none | any | Details for kollabor_engine-0.21.1-py3-none-any.whl |
Total release size: 602.0 kB
Release files / kollabor_engine-0.21.1.tar.gz
| Download URL | kollabor_engine-0.21.1.tar.gz |
|---|---|
| Size | 369.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28dc25066e1ff25000a56b99b72a1f6d69c9161f7260d2918e141a797ebd670e
|
|
BLAKE2b-256 checksum How to use checksums |
b744732873c6f435fce393c25cd767e12873e2ece2c32e1207d886dba55b23b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / kollabor_engine-0.21.1-py3-none-any.whl
| Download URL | kollabor_engine-0.21.1-py3-none-any.whl |
|---|---|
| Size | 232.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cc38c83392278c9246fc87be4ea436276c71dbee31b5802ea3ba4a9aa091031
|
|
BLAKE2b-256 checksum How to use checksums |
1161c88b758bf62aabe2de1c709dbe4adff36bc579097d4a6c2c659e82b48683
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for kollabor-engine 0.21.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.