nocturn

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: Apache-2.0

README ΒΆ

Nocturn

An AI assistant that works autonomously β€” but stops to ask for your approval on your phone before doing anything you can't take back.

One single Go binary. No cloud, no database, no runtime required.

Documentation Go License

πŸ“– Read the documentation β†’


[!WARNING] This is an alpha. Expect bugs, and expect change β€” everything here is still moving: the UI, the UX, the tooling, the wire protocol and the feature set alike. Some of that movement will break what you set up. The security boundaries are the part that gets the scrutiny; everything around them is going to get better fast, which is another way of saying it is not finished. Issues and pull requests are exactly what this phase is for.

⚑ Why is Nocturn different?

Most AI agents have full access to your system by default simply because they run on Node or Python. Nocturn flips this principle: a capability is absent until you hand it over, never present until something denies it. It provides a solid technical foundation that harmonizes the execution of plugins and scripts while keeping boundaries strictly enforced.

  • Your smartphone is the gatekeeper: Before the AI reaches the network or modifies a file β€” sending that email, writing that document β€” an approval request pops up in the companion app on your phone. You retain absolute control.
  • Zero-Trust Sandbox: Foreign code and AI-generated scripts run inside an isolated WebAssembly (WASM) sandbox. No filesystem access, no network access, no environment variables β€” unless explicitly handed over.
  • Secrets stay secret: The language model never sees your API keys or passwords, yet it can still drive an API that needs one. It just asks for a URL; the host injects the token in the background as the request crosses the boundary.
  • Plug & Play: No heavy dependencies, no containers. Just download the binary and run it.

πŸ›  What can Nocturn do?

Nocturn isn't just a chatbot; it's a capable assistant that handles tasks in the background (or on a schedule) while keeping your machine safe:

  • Process files & code: Let the AI write and execute scripts (code_run) to analyze data or automate workflows β€” safely locked inside the WASM sandbox.
  • Connect your infrastructure: Integrate your email, calendar, local files, or external APIs via MCP servers and plugins. Everything is modular and extensible.
  • Autonomous routines: Schedule agents via cron jobs (e.g., "Summarize my unread emails every morning at 7 AM") while you sleep.
  • Local memory: Nocturn remembers important details about your preferences in a durable, local state.
  • Voice control: experimental Talk directly to Nocturn via your machine or connected satellite speakers.

πŸš€ Quickstart

# Just the binary β€” no Node, Python, or containers to install
go build ./cmd/nocturn

# Configure an OpenAI-compatible endpoint
cp .env.example .env

# Start the local terminal chat
./nocturn

# Or start the server your phone and satellites connect to
./nocturn serve

(Nocturn does not ship with a model β€” point it at any API you control. Everything it knows stays strictly local in a nocturn-data/ folder.)

πŸ“± The companion app

The app is what answers an approval when you are nowhere near the machine: it finds nocturn by name on your own network β€” no account, no relay β€” and shows the ask as the gate recorded it, never as the conversation phrased it. It is also a full client: the same chats the terminal is talking to, and every tool call the model made, timed and attributable.

Screenshots and the walkthrough are in the app guide.

TestFlightAndroid APK
Public beta Latest release

No nocturn of your own yet? On the first screen tap Enter server manually and enter demo as the host β€” sample data, held entirely on the device.

🧱 Architecture

Nocturn is built on two strictly separated core components:

  • agentkit/ (the engine): a completely independent, policy-blind turn loop with zero external dependencies.

  • internal/ (the boundary): the security system that decides what the engine is allowed to do β€” WASM sandbox, encrypted vault, out-of-band approvals.

  • Full documentation β€” architecture, threat model, plugin development

  • examples/ β€” a workspace with one of everything: an agent, a skill, a plugin, an MCP server, memory, documents to search

  • ADRS.md Β· CONTRIBUTING.md Β· SECURITY.md

πŸ€– How this was built

The idea, the architecture, the security boundaries and the threat model are human. So are the constraints the code is held to: the tech stack, the dependency budget, the code style, and every decision recorded in ADRS.md. And the mantra:

One aspect at a time β€” clarify, build, prove stable. Explicit over implicit. No sprawl, no cruft, no backward-compat ballast in greenfield.

Inside those constraints, Nocturn was built with frontier models as a pair programmer β€” and almost every line here was typed by one. Not a handoff: each piece was talked through before it was written, the reasoning went both ways, and no diff landed unread. That is what made this pace possible. A system this size stays coherent because someone holds its shape while the implementation moves fast.

Agentic contributions are welcome on exactly those terms β€” bring what your agent wrote, once you have read the diff yourself.

License

Apache-2.0.

Directories ΒΆ

Path Synopsis
agentkit module
gate module
gemini module
openai module
runtime module
Package catalog holds the source of the published library catalog β€” the skills and MCP servers a fresh daemon offers before anybody configures anything.
Package catalog holds the source of the published library catalog β€” the skills and MCP servers a fresh daemon offers before anybody configures anything.
cmd
nocturn command
Command nocturn is a terminal chat driven by agentkit Sessions, their tools gated by agentkit/gate with human approval on the terminal, and conversations persisted and multiplexed by internal/chat β€” all composed per workspace by internal/workspace.
Command nocturn is a terminal chat driven by agentkit Sessions, their tools gated by agentkit/gate with human approval on the terminal, and conversations persisted and multiplexed by internal/chat β€” all composed per workspace by internal/workspace.
internal
agent
Package agent is the declaration layer for autonomous assistants: the Agent type, discovery of agent.md files into an immutable Set, and a cron Scheduler.
Package agent is the declaration layer for autonomous assistants: the Agent type, discovery of agent.md files into an immutable Set, and a cron Scheduler.
auth
Package auth is the daemon's device registry: it gates every WebSocket connection on a bearer a device obtained by pairing.
Package auth is the daemon's device registry: it gates every WebSocket connection on a bearer a device obtained by pairing.
chat
Package chat persists conversations and multiplexes them β€” the layer agentkit deliberately leaves to the consumer.
Package chat persists conversations and multiplexes them β€” the layer agentkit deliberately leaves to the consumer.
discovery
Package discovery holds the vocabulary every discoverable kind shares (agents, skills, plugins, MCP servers): how a skipped item is recorded, and how an item's name is resolved.
Package discovery holds the vocabulary every discoverable kind shares (agents, skills, plugins, MCP servers): how a skipped item is recorded, and how an item's name is resolved.
extension
Package extension is what a workspace installs, and the one declaration every installed thing shares.
Package extension is what a workspace installs, and the one declaration every installed thing shares.
frontmatter
Package frontmatter parses the YAML preamble a Markdown file may open with β€” the shape the Agent Skills standard uses, and the same one nocturn's memory notes use to describe themselves.
Package frontmatter parses the YAML preamble a Markdown file may open with β€” the shape the Agent Skills standard uses, and the same one nocturn's memory notes use to describe themselves.
hitl
Package hitl routes a gate approval to a human out of band: it presents the request to every attached connection and takes the first answer (first-committed-wins), or wakes a device via a Pusher when none is attached.
Package hitl routes a gate approval to a human out of band: it presents the request to every attached connection and takes the first answer (first-committed-wins), or wakes a device via a Pusher when none is attached.
knowledge
Package knowledge is retrieval over a workspace's own documents: the folder you drop things into, chunked, embedded, and searched on demand.
Package knowledge is retrieval over a workspace's own documents: the folder you drop things into, chunked, embedded, and searched on demand.
knowledge/embed
Package embed is the remote half of knowledge retrieval: an OpenAI-compatible /v1/embeddings client, and the only place in the tree that sends document text to a third party.
Package embed is the remote half of knowledge retrieval: an OpenAI-compatible /v1/embeddings client, and the only place in the tree that sends document text to a third party.
library
Package library is the curated catalog a person installs extensions from β€” the shop side of extending a workspace, as opposed to assembling a folder by hand.
Package library is the curated catalog a person installs extensions from β€” the shop side of extending a workspace, as opposed to assembling a folder by hand.
mail
Package mail is the household's mailbox: reading it, and sending from it.
Package mail is the household's mailbox: reading it, and sending from it.
mcp
Package mcp connects to remote (HTTP) MCP servers β€” the SAFE half of MCP (ADR-9): a remote server runs no code on your machine, so talking to it is just gated HTTP.
Package mcp connects to remote (HTTP) MCP servers β€” the SAFE half of MCP (ADR-9): a remote server runs no code on your machine, so talking to it is just gated HTTP.
mcp/authflow
Package authflow implements the discovery half of the MCP authorization spec (2025-06-18): the client-side steps that turn a bare MCP server URL into concrete OAuth endpoints and a client id, so nocturn can run the interactive flow without hand-configured endpoints.
Package authflow implements the discovery half of the MCP authorization spec (2025-06-18): the client-side steps that turn a bare MCP server URL into concrete OAuth endpoints and a client id, so nocturn can run the interactive flow without hand-configured endpoints.
memory
Package memory is the assistant's own durable memory: a per-workspace folder of Markdown files whose index (MEMORY.md) is folded into every system prompt, with the detail files loaded on demand.
Package memory is the assistant's own durable memory: a per-workspace folder of Markdown files whose index (MEMORY.md) is folded into every system prompt, with the detail files loaded on demand.
onnx
Package onnx runs a small ONNX graph in pure Go β€” no CGO, no shared library, no WebAssembly, and no dependency outside the standard library.
Package onnx runs a small ONNX graph in pure Go β€” no CGO, no shared library, no WebAssembly, and no dependency outside the standard library.
plugin
Package plugin runs installed, sandboxed plugins as ordinary model tools.
Package plugin runs installed, sandboxed plugins as ordinary model tools.
push
Package push is the native mobile-push side of the companion app: a provider-agnostic Sender port plus the APNs adapter (apns.go) that implements it.
Package push is the native mobile-push side of the companion app: a provider-agnostic Sender port plus the APNs adapter (apns.go) that implements it.
sandbox
Package sandbox runs an untrusted WebAssembly guest (an interpreter such as QuickJS or MicroPython, or a compiled skill) under strict isolation on wazero.
Package sandbox runs an untrusted WebAssembly guest (an interpreter such as QuickJS or MicroPython, or a compiled skill) under strict isolation on wazero.
script
Package script runs untrusted JavaScript on the sandbox interpreter (QuickJS compiled to wasm) and bridges a script's actions through a single generic host gate onto the SAME agentkit tools the model uses.
Package script runs untrusted JavaScript on the sandbox interpreter (QuickJS compiled to wasm) and bridges a script's actions through a single generic host gate onto the SAME agentkit tools the model uses.
secret
Package secret is the host's secret store and credential injection.
Package secret is the host's secret store and credential injection.
secret/oauth
Package oauth runs the host side of OAuth2 (ADR-5): it obtains and refreshes access tokens so the gateway can inject a Bearer at the boundary.
Package oauth runs the host side of OAuth2 (ADR-5): it obtains and refreshes access tokens so the gateway can inject a Bearer at the boundary.
serve
Package serve exposes a workspace's chats over a WebSocket: one backend, many fronts (daemon-as-truth).
Package serve exposes a workspace's chats over a WebSocket: one backend, many fronts (daemon-as-truth).
skill
Package skill is nocturn's consumer-side skills layer: it reads the SKILL.md an extension carries (YAML frontmatter + Markdown body) into an agentkit.SkillSet, and provides skill_read for a skill's bundled files (Tier 3 of progressive disclosure).
Package skill is nocturn's consumer-side skills layer: it reads the SKILL.md an extension carries (YAML frontmatter + Markdown body) into an agentkit.SkillSet, and provides skill_read for a skill's bundled files (Tier 3 of progressive disclosure).
speaker
Package speaker answers "who said this" from 16 kHz PCM, entirely on the machine that runs nocturn: no CGO, no shared library, no service call, and no audio leaving the device.
Package speaker answers "who said this" from 16 kHz PCM, entirely on the machine that runs nocturn: no CGO, no shared library, no service call, and no audio leaving the device.
tools
Package tools bundles nocturn's own gated tools β€” the thin ones whose whole body is "build an agentkit.Tool that gates its target on a shared kind before it acts".
Package tools bundles nocturn's own gated tools β€” the thin ones whose whole body is "build an agentkit.Tool that gates its target on a shared kind before it acts".
tui
Package tui is nocturn's terminal surface: a full-screen chat over the workspace facade.
Package tui is nocturn's terminal surface: a full-screen chat over the workspace facade.
tui/logring
Package logring is a slog.Handler that keeps the last N records in memory for the terminal UI's log pane.
Package logring is a slog.Handler that keeps the last N records in memory for the terminal UI's log pane.
tui/transcript
Package transcript is the ONE pure fold of a chat's rendered state β€” no terminal, no clock, no I/O. Both entry points reduce into the SAME View by the SAME builders, so the snapshot path and the live-stream path can never drift:
Package transcript is the ONE pure fold of a chat's rendered state β€” no terminal, no clock, no I/O. Both entry points reduce into the SAME View by the SAME builders, so the snapshot path and the live-stream path can never drift:
voice
Package voice drives a duplex speech session against an agentkit.LiveLLM, brokering the tool calls it issues through the same ToolSet and the same gate machinery a typed chat uses.
Package voice drives a duplex speech session against an agentkit.LiveLLM, brokering the tool calls it issues through the same ToolSet and the same gate machinery a typed chat uses.
webui
Package webui serves the browser front-end out of the binary itself.
Package webui serves the browser front-end out of the binary itself.
workspace
Package workspace is the composition root per workspace: it bundles the tools (the cage), the permission gate (policy + durable grants + approver), the persona, and the chat store and manager into one aggregate over a shared Host.
Package workspace is the composition root per workspace: it bundles the tools (the cage), the permission gate (policy + durable grants + approver), the persona, and the chat store and manager into one aggregate over a shared Host.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL