NocturnusAI
NocturnusAI
许可协议简述。 商业源码许可 1.1 (SPDX:
BUSL-1.1)。在您自己的组织内部使用(包括内部生产环境)是免费的。若要将 NocturnusAI 或其核心功能作为产品/托管服务提供给第三方,则需要商业许可 (licensing@nocturnus.ai)。该协议将于 2030 年 2 月 19 日转换为 Apache 2.0 协议。

输入海量轮次。输出精简上下文窗口。
如果您的智能体在每次模型调用时都在不断重复聊天记录、工具输出、CRM 备注、重试记录和陈旧的摘要,NocturnusAI 首先会为您削减这些冗余内容。
其核心工作流并非“学习谓词”,而是:
发送您现有的原始轮次。
获取一个更小的有效集。
为下一个问题缩小该集合。
重用差异(diffs),以便后续轮次仅发送变更内容。
谓词、规则、推理、真值维护、作用域和时序逻辑依然存在且至关重要。它们只是处于幕后,而非前台。
工作循环
自然语言轮次需要 LLM 支持。 下面的示例通过 LLM 发送原始文本轮次以提取结构化事实。如果您在没有 LLM 提供商的情况下启动服务器,自然语言轮次将返回零事实。请参阅 快速入门 获取设置选项,或使用谓词语法(例如
"customer_tier(acme_corp, enterprise)"),该语法无需 LLM 即可工作。
1. 首次精简:POST /context
curl -X POST http://localhost:9300/context \
-H 'Content-Type: application/json' \
-H 'X-Tenant-ID: default' \
-d '{
"turns": [
"user: Customer says they are enterprise and blocked on SLA credits.",
"tool: CRM says account is Acme Corp with a 2M ARR contract.",
"agent: Last week support promised to review SLA eligibility.",
"tool: Billing note says renewal is due next month."
],
"maxFacts": 12
}'响应结构(事实和显著性值取决于 LLM 提取):
{
"facts": [
{"predicate":"customer_tier","args":["acme_corp","enterprise"],"salience":0.65},
{"predicate":"contract_value","args":["acme_corp","2000000"],"salience":0.65},
{"predicate":"issue","args":["acme_corp","sla_credits"],"salience":0.64}
],
"totalFactsInKB": 7,
"factsReturned": 3,
"contradictions": 0,
"newFactsExtracted": 3
}2. 目标驱动的传递:POST /memory/context
curl -X POST http://localhost:9300/memory/context \
-H 'Content-Type: application/json' \
-H 'X-Tenant-ID: default' \
-d '{
"goals": [
{"predicate":"eligible_for_sla","args":["acme_corp"]}
],
"maxFacts": 12,
"sessionId": "ticket-42"
}'当您明确下一次模型调用旨在回答什么问题时,请使用此接口。
3. 后续轮次:POST /context/diff
curl -X POST http://localhost:9300/context/diff \
-H 'Content-Type: application/json' \
-H 'X-Tenant-ID: default' \
-d '{
"sessionId": "ticket-42",
"maxFacts": 12
}'此接口仅返回快照之间 added(新增)和 removed(移除)的条目。
4. 会话结束:POST /context/session/clear
curl -X POST http://localhost:9300/context/session/clear \
-H 'Content-Type: application/json' \
-H 'X-Tenant-ID: default' \
-d '{"sessionId":"ticket-42"}'选择您的交互界面
Python SDK
from nocturnusai import SyncNocturnusAIClient
with SyncNocturnusAIClient("http://localhost:9300") as client:
ctx = client.process_turns(
turns=[
"user: Customer says they are enterprise and blocked on SLA credits.",
"tool: CRM says account is Acme Corp with a 2M ARR contract.",
],
scope="ticket-42",
session_id="ticket-42",
)
diff = client.diff_context(session_id="ticket-42", max_facts=12)
client.clear_context_session("ticket-42")
print(ctx.briefing_delta)TypeScript SDK
import { NocturnusAIClient } from 'nocturnusai-sdk';
const client = new NocturnusAIClient({
baseUrl: 'http://localhost:9300',
tenantId: 'default',
});
const ctx = await client.processTurns({
turns: [
'user: Customer says they are enterprise and blocked on SLA credits.',
'tool: CRM says account is Acme Corp with a 2M ARR contract.',
],
scope: 'ticket-42',
sessionId: 'ticket-42',
});
const diff = await client.diffContext({
sessionId: 'ticket-42',
maxFacts: 12,
});
await client.clearContextSession('ticket-42');
console.log(ctx.briefingDelta);MCP
将 Nocturnus 添加为 MCP 服务器:
{
"mcpServers": {
"nocturnus": {
"url": "http://localhost:9300/mcp/sse",
"transport": "sse"
}
}
}在每一轮中使用 context 工具获取按显著性排序的有效集。当您需要目标驱动的组装和差异对比时,请将 MCP 与 HTTP 上下文端点结合使用。
工作流背后的机制
当您确实需要后端机制时,NocturnusAI 提供了以下功能:
确定性的事实和规则存储
带有证明链的后向链推理
真值维护和矛盾处理
带有
ttl、validFrom和validUntil的时序事实通过
X-Database和X-Tenant-ID实现多租户支持在同一引擎上提供 MCP、REST、Python SDK、TypeScript SDK 和 CLI 接口
这就是后端。而产品的前端故事依然是轮次精简。
快速入门
Docker(最快)
docker run -d --name nocturnusai -p 9300:9300 \
--restart unless-stopped \
-v nocturnusai-data:/data \
ghcr.io/auctalis/nocturnusai:latest验证其是否正在运行:
curl http://localhost:9300/health尝试逻辑引擎(立即生效,无需 LLM):
curl -X POST http://localhost:9300/tell \
-H 'Content-Type: application/json' \
-H 'X-Tenant-ID: default' \
-d '{"predicate":"customer_tier","args":["acme_corp","enterprise"]}'
curl -X POST http://localhost:9300/tell \
-H 'Content-Type: application/json' \
-H 'X-Tenant-ID: default' \
-d '{"predicate":"contract_value","args":["acme_corp","2000000"]}'
curl -X POST http://localhost:9300/ask \
-H 'Content-Type: application/json' \
-H 'X-Tenant-ID: default' \
-d '{"predicate":"customer_tier","args":["acme_corp","?tier"]}'就是这样。服务器正在运行,将数据持久化到指定的 Docker 卷中,并自动重启。如需进行自然语言轮次提取(上述工作循环),请添加 LLM 提供商 —— 请参阅下一节。
结合 Ollama 的 Docker(启用自然语言提取)
如果您在本地运行了 Ollama:
docker run -d --name nocturnusai -p 9300:9300 \
--add-host=host.docker.internal:host-gateway \
-e LLM_PROVIDER=ollama \
-e LLM_MODEL=granite3.3:8b \
-e LLM_BASE_URL=http://host.docker.internal:11434/v1 \
-e EXTRACTION_ENABLED=true \
ghcr.io/auctalis/nocturnusai:latest安装脚本(CLI + 设置向导)
curl -fsSL https://raw.githubusercontent.com/Auctalis/nocturnusai/main/install.sh | bash下载 CLI 二进制文件并启动交互式设置向导,您可以在其中选择 LLM 提供商(Ollama、Anthropic、OpenAI、Google 或跳过)。它会创建一个持久化的 Docker Compose 安装。
如果您已知晓所需配置,可使用以下快捷方式:
curl -fsSL ... | bash -s -- --host-ollama # Reuse local Ollama
curl -fsSL ... | bash -s -- --ollama # Bundle Ollama in Docker
curl -fsSL ... | bash -s -- --key sk-ant-... # Use AnthropicPython SDK
pip install nocturnusaiTypeScript SDK
npm install nocturnusai-sdkMCP 客户端
从 mcp-configs/ 复制其中一个配置。
从本仓库构建(贡献者)
make up-ollama
make smokeCLI
CLI 对于交互式检查和显著性窗口检索非常有用:
nocturnusai # Interactive REPL
nocturnusai -e "context 10" # Salience-ranked working set
nocturnusai -e "compress" # Simplified alias: POST /memory/compress
nocturnusai -e "cleanup 0.05" # Simplified alias: POST /memory/cleanup对于目标驱动的上下文窗口和差异对比,请结合使用 REST API 或 SDK 与 CLI。
文档
完整文档:nocturnus.ai
从轮次精简工作流开始 | |
原始轮次 -> 优化 -> 差异 -> 清除 | |
REST 端点和响应结构 | |
Python 和 TypeScript 客户端方法 | |
LangChain, CrewAI, AutoGen, LangGraph, OpenAI Agents, Anthropic, MCP | |
MCP 配置及配套上下文 API 使用 | |
事实、规则、推理、显著性、作用域 | |
API 密钥、RBAC、TLS、静态加密 |
Docker Compose(高级)
用于持久化配置、监控或 Ollama 捆绑:
git clone https://github.com/Auctalis/nocturnusai.git && cd nocturnusai
make up # Server using .env.example defaults
make up-ollama # + Ollama (reuses host or starts bundled)
make up-monitoring # + Prometheus + Grafana
make smoke # Verify health + context endpoint从源码构建
需要 JDK 17+。
./gradlew :nocturnusai-server:run # HTTP server on :9300
./gradlew :nocturnusai-cli:run # Interactive REPL (JVM)
./gradlew :nocturnusai-cli:nativeCompile # Build native binary
./gradlew test # Full test suite贡献
请参阅 CONTRIBUTING.md。标记为 good first issue 的问题是很好的切入点。
安全
请通过 GitHub 安全公告 私下报告漏洞。请参阅 SECURITY.md。
许可
商业源码许可 1.1 - 非生产环境使用及组织内部生产环境使用免费。将 NocturnusAI 作为产品或服务提供给第三方需要从 licensing@nocturnus.ai 获取商业许可。该协议将于 2030 年 2 月 19 日转换为 Apache 2.0 协议。请参阅 LICENSE 和 DISCLAIMER.md。
法律与安全声明
NocturnusAI 是一个确定性的推理引擎,但 其输出的可靠性仅取决于提供给它的事实。
无真实性保证。 “已验证”是指推理的逻辑一致性,而非现实世界主张的准确性。
不适用于自主高风险决策。 未经独立的人工验证步骤,请勿将此引擎用于无人值守的医疗、金融、法律或物理安全决策。
仅限逻辑层。 NocturnusAI 提供信息和推理;它不执行操作。
免责声明。 请参阅 DISCLAIMER.md 和 LICENSE。
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Auctalis/nocturnusai'
If you have feedback or need assistance with the MCP directory API, please join our Discord server