nlght-ai
The runtime between your app and your LLM: workflows, tools, memory, and model providers.
E2E scope note. The test badge covers the cloud model-client e2e suite (
tests/e2e); each provider skips itself when its API key is absent. The local Ollama model-client suite (tests/local_e2e) runs separately against a local Ollama daemon. Run it withpytest tests/local_e2e -m local_e2e.
What it does
- A protocol adapter accepts an OpenAI or Ollama API request and resolves its workflow trigger.
- The workflow executor runs the configured steps. Steps receive request messages and the configured model, tool, playbook, and session ports.
- Steps call models or tools, use session memory, and emit signals without handling HTTP.
- The adapter returns the result as a batch response or stream.
Features
| Feature | Description |
|---|---|
| OpenAI-compatible API | Chat Completions endpoint for supported OpenAI clients |
| Ollama API | Native Ollama protocol support |
| Multi-provider | Ollama, Anthropic Claude, OpenAI, Google Gemini |
| Workflow engine | Stateless step machine with configurable routing |
| Tool system | Register custom tools, call them from steps |
| Playbook catalog | YAML-defined agent capabilities, loaded from filesystem |
| Session memory | Hive Mind: conversation, session results, and working memory |
| Session routing | Configurable SessionKeyResolver per protocol adapter |
| PostgreSQL persistence | Workflow metadata and resource registry via SQLAlchemy |
| Ports & Adapters | Core contracts have no framework dependency |
Install
Install uv, then add nlght-ai inside a Python project:
uv add nlght-ai
Optional extras:
uv add 'nlght-ai[anthropic]' # Anthropic Claude
uv add 'nlght-ai[openai]' # OpenAI / Azure OpenAI
uv add 'nlght-ai[google]' # Google Gemini
uv add 'nlght-ai[hive-mind]' # File-backed session memory
uv add 'nlght-ai[docker]' # Docker OS runtime
uv add 'nlght-ai[web-search]' # Web search tool
This declares nlght-ai in the project, so later uv sync and uv run
commands keep it installed. For a standalone CLI that is independent of any
project environment, use uv tool install nlght-ai instead.
Quickstart
In the configuration examples, YOUR-LICENSE-KEY means the key from a
free developer license. Replace it with your own key.
1. Configure: Create .config/platform.yaml:
licensing:
license_key: YOUR-LICENSE-KEY # free developer licenses available
protocol_adapters:
- name: openai-http
kind: openai
enabled: true
config:
base_path: /v1
model_provider: ollama
session_key_resolver:
resolver: header
key: x-session-id
gateways:
- name: http-gateway
kind: http
enabled: true
config:
host: 0.0.0.0
port: 8000
integrations:
persistence:
workflows:
backend: postgres
url: postgresql+asyncpg://user:pass@localhost/nlght
model_providers:
- name: ollama
kind: ollama-local
config:
base_url: http://localhost:11434
default_model: llama3.2
2. Start PostgreSQL with the local credentials above:
docker run -d --name nlght-postgres \
-e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass -e POSTGRES_DB=nlght \
-p 5432:5432 postgres:16
3. Migrate the database (initial setup and after every upgrade):
uv run nlght-ai migrate
4. Start Ollama and the runtime (use separate terminals):
Terminal 1:
ollama serve
Terminal 2:
ollama pull llama3.2
uv run nlght-ai serve
5. Call:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "llama3.2", "messages": [{"role": "user", "content": "Hello!"}]}'
Writing a Step
from typing import ClassVar
from nlght.core.model.messages import TrustedInstructionMessage
from nlght.core.workflow.step import StepBase, StepResult, WorkflowStepContext
class SummarizeStep(StepBase):
TYPE: ClassVar[str] = "summarize"
async def run(self, ctx: WorkflowStepContext) -> StepResult:
if ctx.llm is None:
return StepResult(ctx=ctx, verdict="failed")
instructions = TrustedInstructionMessage(
"Summarize the conversation in three bullet points."
)
await ctx.llm.call(messages=[instructions, *ctx.messages])
return StepResult(ctx=ctx, verdict="done")
Register and wire it up in your entrypoint, then reference it in a workflow definition stored in the database.
Session Memory (Hive Mind)
Hive Mind persists conversation turns and session results. Working memory holds transient atoms for the active task. Applications can store JSON-compatible values in namespaced coordinator slots. The store has no directive API.
Configure a session backend and select model context with PromptInputPolicy. See
Session Memory for the current configuration,
store contracts, and copyable examples.
Demo
The Demo Showcase introduces six complete workflows across grounding, tools, routing, session memory, and isolated runtime execution. Setup, migration, and run requirements are maintained by the demo repository linked there.
Model Providers
| Provider | Extra | Config kind |
|---|---|---|
| Ollama (local) | (none) | ollama-local |
| Anthropic Claude | [anthropic] |
anthropic |
| OpenAI | [openai] |
openai |
| Google Gemini | [google] |
google |
Architecture
nlght-ai follows a strict hexagonal (ports & adapters) architecture:
core/: Domain logic and framework independent typesports/: Interfaces for external concernsadapters/inbound/: HTTP and protocol adaptersadapters/outbound/: Model clients, persistence, tools, Hive Mind, and OS runtimeapplication/: Services that coordinate portsbootstrap/: Container, startup, and configuration loading
See the nlght-ai documentation for the full user documentation.
Requirements
- Python 3.11+
- PostgreSQL (for workflow metadata and resource registry)
- A model provider (Ollama recommended for local development)
Development
Dependencies are pinned in uv.lock for a reproducible environment. With
mise (see mise.toml, which pins Python 3.13 and uv):
mise install
uv sync
uv run pytest -q -m "not e2e and not integration"
uv run ruff check src tests
The default dev group installs nlght-ai[all], so local development and CI
exercise every portable runtime capability. Accelerator-specific
embedding-cpu and embedding-cuda remain explicit machine choices.
uv sync --locked (used in CI) fails instead of silently re-resolving if
pyproject.toml and uv.lock have drifted apart. Run uv lock after
changing dependencies and commit the updated lockfile.
Metadata
Release files for nlght-ai 0.1.4
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 |
|---|---|---|---|---|
| nlght_ai-0.1.4.tar.gz | 681.2 kB | With provenance | Details for nlght_ai-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nlght_ai-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for nlght_ai-0.1.4-py3-none-any.whl |
Total release size: 1.6 MB
Release files / nlght_ai-0.1.4.tar.gz
| Download URL | nlght_ai-0.1.4.tar.gz |
|---|---|
| Size | 681.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21472e45784ac05f3b24db837818ed9c82eda140863d42560c3321918ad9e526
|
|
BLAKE2b-256 checksum How to use checksums |
c34e22a0cd324a708c4309c20c7f8ff94d2d1c42380683164db1ea8c97fd7248
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logRelease files / nlght_ai-0.1.4-py3-none-any.whl
| Download URL | nlght_ai-0.1.4-py3-none-any.whl |
|---|---|
| Size | 898.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1247f46a053c45a44a585e771d1d5f4524f6c67791d3f26c3bacb5db1da0b481
|
|
BLAKE2b-256 checksum How to use checksums |
7b5aa0aa0fa24e1c894312a0f1a77210953b21fec043cbf1e789cb882091f183
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logSecurity for nlght-ai 0.1.4
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for nlght_ai-0.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logA 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.