Skip to main content

DamnatioX Agent

DamnatioX Agent 是终端优先的本地 Coding Agent。当前版本由 Python Harness V2 负责 Session、模型、工具、权限、预算和持久化,由 React + TypeScript + Ink 负责默认全屏终端界面;Rich / prompt-toolkit 界面继续作为兼容入口。

安装

需要 Python 3.14。发布包提供三种常用安装方式:

# 推荐:隔离安装 CLI
pipx install damnatiox-agent

# uv tool
uv tool install damnatiox-agent

# 普通 pip / 虚拟环境
python -m pip install --upgrade damnatiox-agent

Windows 上若 pip 提示用户级 Scripts 目录不在 PATH,执行一次以下命令并 重新打开终端:

$scripts = Join-Path (python -m site --user-base) 'Python314\Scripts'
$path = [Environment]::GetEnvironmentVariable('Path', 'User')
[Environment]::SetEnvironmentVariable('Path', "$path;$scripts", 'User')

默认安装保持 CLI 与 Harness 依赖轻量。需要本地 embedding 模型和语义 知识库工具时,安装 rag extra:

pipx install 'damnatiox-agent[rag]'
# 或
python -m pip install 'damnatiox-agent[rag]'

安装后可在任意已有目录启动:

cd /path/to/project
damnatioX

damnatioX 与 damnatiox 均为正式 CLI 入口。

启动目录就是本次 Agent 的 Workspace;文件工具和命令始终绑定到该目录。 Session、Attempt、Event 与 Artifact 按 Workspace 隔离;Workspace 可写时沿用 <workspace>/.damnatiox,只读目录(例如 C:\Windows\System32)自动使用 ~/.damnatiox/workspaces/<workspace>-<hash>。首次运行会在 React TUI 内显示 DeepSeek API Key 密码输入引导,也可预先设置:

export DEEPSEEK_API_KEY="..."

Windows PowerShell:

$env:DEEPSEEK_API_KEY = "..."

交互式输入的 Key 保存到用户目录 ~/.damnatiox/config.json。首次设置只通过 本机 Node→Python stdio RPC 传递一次,输入全程掩码且服务端不回显;后续启动由 Python gateway 从环境或配置读取。/config 仅显示配置状态和路径。

CLI

damnatiox                         新 Session,默认 --ui auto
damnatiox --continue              恢复当前 Workspace 最近的 Session
damnatiox --resume SESSION_ID     恢复指定 Session
damnatiox --manual-approval       React 界面中在写入与独占工具前显示审批框
damnatiox --ui react              明确使用 React / Ink
damnatiox --ui rich               使用 Rich 兼容界面
damnatiox --ui-info               检查前端 manifest、SHA256 和 Node 运行时
damnatiox --frontend-smoke        无 API Key 前端渲染 smoke
damnatiox --version

--ui auto 优先选择经过 manifest SHA256 校验的 React 前端:

  • 平台 wheel 使用包内 Node 24.14.0;
  • 通用 wheel 使用系统 Node 22 或更高版本;
  • 通用 wheel 找不到兼容 Node 时进入 Rich 界面;
  • stdin/stdout 被重定向时,auto 保留 Rich 的线性输入输出路径;
  • --ui react 的资源、完整性或运行时错误使用稳定的 DX-UI-* 错误码。

React 启动前不打印 Rich banner,因此 React / Ink 独占 TTY。--ui-info 和 --frontend-smoke 都不读取 API Key。

React / Ink 终端界面

默认界面沿用原 Rich TUI 的信息层次,而不是把 Harness 状态拼成普通日志:

Header
├── Model / reasoning effort / Session / Workspace / Git
Transcript
├── User turn
├── Thinking(可隐藏)
├── ToolActivity(queued / running / approval / result)
└── Assistant response
Composer
└── 输入与 slash command
Approval
├── tool、参数名称与有界脱敏预览
└── Y / N / Esc
Status
└── 当前阶段、耗时、Token、诊断

主要快捷键:

Enter          发送
Ctrl+C         中断活动 Turn;空闲时退出
Y / N / Esc    处理当前工具审批
Mouse wheel    每次上下滚动 Transcript 3 行
PageUp/Down    按页浏览 Transcript
Ctrl+Home/End  跳到 Transcript 顶部/尾部

界面支持 /help、/status、/tools、/skills、/sessions、/new、 /resume、/history [count]、/context(兼容 /content)、/compact(兼容 /compress)、/config、/diff、/model、/effort、/thinking、/clear 和 /exit。

前端源码位于 frontend/,生产 bundle 位于 damnatiox_agent/ui/assets/app.mjs。Python launcher 会先校验 assets/manifest.json 中记录的 SHA256,再使用包内或系统 Node 启动它。

完整运行链路

flowchart TD
    CLI["damnatiox:Python CLI launcher"]
    NODE["Node 24 / Node >= 22"]
    REACT["React + TypeScript + Ink TUI"]
    RPC["NDJSON framed JSON-RPC 2.0 over stdio"]
    GW["tui_gateway"]
    API["LocalAgentAPI"]
    APP["AgentApplication"]
    TURN["TurnService"]
    LOOP["AgentLoop"]
    CTX["ContextBuilder / CompletionPolicy / TurnBudget"]
    MODEL["ModelGateway"]
    RUNTIME["ToolRuntime"]
    EXEC["ToolExecutor / Sandbox / ProcessRunner"]
    STORE["Session / Attempt / Event / Artifact Stores"]
    EXT["Skills / Workspace Facts / Attempt Facts"]

    CLI --> NODE
    NODE --> REACT
    REACT <--> RPC
    RPC <--> GW
    GW --> API
    API --> APP
    APP --> TURN
    TURN --> LOOP
    LOOP --> CTX
    LOOP <--> MODEL
    LOOP <--> RUNTIME
    RUNTIME --> EXEC
    TURN <--> STORE
    LOOP --> STORE
    EXT --> CTX

线性表示:

CLI Python launcher
→ Node React/Ink
→ NDJSON JSON-RPC stdio
→ damnatiox_agent.interfaces.tui_gateway
→ LocalAgentAPI / AgentApplication
→ TurnService / AgentLoop
→ ModelGateway / ToolRuntime
→ AgentEvent / Turn result
→ JSON-RPC notification
→ React reducer 与终端组件

Node 前端占用终端 stdin/stdout,并启动独立 Python gateway 子进程。Gateway 的 stdout 只写一行一条的 JSON-RPC;诊断写 stderr。请求读取保留在主线程,Turn 和 Compaction 在 worker 中运行,因此 turn/interrupt 和工具审批在模型或工具运行 期间仍可响应。

RPC 与前后端边界

tui_gateway 只负责协议校验、序列化、worker 调度和进程关闭;模型、工具、 Session 和文件访问仍位于 LocalAgentAPI 与 AgentApplication 后方。

主要 RPC:

领域 方法或通知
初始化 / 配置 initialize、config/read、config/setApiKey、runtime/status、shutdown
Session session/read、session/list、session/create、session/resume、session/save、session/history
Attempt / Events attempt/list、attempt/read、events/list
Turn turn/start、turn/interrupt、turn/result
流式事件 agent/event
审批 tool/resolveApproval
Context context/read、context/compact、context/compacted
Workspace workspace/read、workspace/diff
能力 tool/list、skill/list、skill/update、model/list、model/update

initialize 协商 protocol version。缺少凭据时先返回 credentialRequired 和 脱敏配置元数据,React 显示密码输入界面;配置完成后返回 capability、当前 Session 的有界尾部快照、Workspace、模型、reasoning effort、命令表和事件 cursor。更早的 Session 历史使用 session/history 分页读取,界面会显示已省略的 Turn 数量。 AgentEvent 包含 session_id、 attempt_id、sequence、timestamp、kind、text 和 details;前端按 cursor 去重和恢复,不假定 sequence 连续。

API Key 只在首次 config/setApiKey 的本机 stdio 请求中出现且不进入响应、事件或 日志;OpenAI/DeepSeek client、ToolExecutor 和可变 Session 对象不穿过 RPC。 审批事件仅传工具身份、参数名称与有界脱敏预览;原始完整值留在 ToolRuntime 一侧,EventStore 不持久化该预览。

Harness V2 分层

层 代码位置 职责
CLI / UI damnatiox_agent/cli.py、damnatiox_agent/ui/、frontend/、tui/ UI 选择、TTY、React 渲染、Rich 兼容
Transport damnatiox_agent/interfaces/tui_gateway.py、python_api.py JSON-RPC、NDJSON、DTO、stream、cancel、approval
Application damnatiox_agent/application/ Composition root、Session 选择、Turn 生命周期、Compaction
Agent Core damnatiox_agent/agent/ 单一模型—工具循环、上下文、预算、取消、完成检查、事件
Model damnatiox_agent/model/ timeout、retry、backoff、stream、usage、cost
Tools damnatiox_agent/tools/、tool/ ToolSpec、参数校验、权限、执行、Sandbox、进程树、结果
Workspace damnatiox_agent/workspace/ 路径边界和 Mutation Journal
Persistence context/session_store.py、damnatiox_agent/persistence/ Session、Attempt、Event、Artifact 原子保存和恢复
Extensions damnatiox_agent/extensions/ Skills、Workspace Facts、Attempt Facts、ToolProvider 接缝
Evals damnatiox_agent/evals/、evals/tasks.json declarative baseline 与 Application runner

默认 composition root 是 damnatiox_agent.application.bootstrap.build_agent_application。Router、独立 Planner、LLM Validator、Replanner 和 Answer Repair 仍只存在于 legacy 源码, 不进入默认 React、Rich 或 Python API 热路径。

Agent Loop

核心实现为 damnatiox_agent/agent/loop.py::AgentLoop.run:

while True:
    cancel_token.raise_if_cancelled()
    budget.check()

    context = context_builder.build(session, attempt, tool_registry.schemas())
    context = context_builder.fit_to_budget(
        context,
        budget.remaining_input_tokens,
    )
    response = model_gateway.generate(context, budget, cancel_token)
    attempt.append_assistant_message(response.message)

    if not response.tool_calls:
        completion_policy.validate(response.content, attempt, budget)
        return response.content

    tool_runtime.execute_calls(
        response.tool_calls,
        budget,
        cancel_token,
        tool_result_sink=append_and_checkpoint,
    )

Harness 负责权限、Workspace、预算、timeout、API retry、取消、执行和停止;模型 决定是否调用工具以及收到结果后的下一步。确定性的 schema、路径、退出码和完成 条件由代码判断。

有限默认预算:

资源 默认值
Turn 总墙钟 600 秒
单次模型 API timeout 60 秒
模型请求 24
工具调用 96
输入 Token 1,000,000
输出 Token 200,000
估算费用 5 USD

模型 SDK 自带 retry 关闭,重试和预算由 ModelGateway 统一控制。 CancellationToken 会停止后续 Loop、关闭 stream,并把取消传播给进程工具; ProcessRunner 负责终止子进程树。

工具、上下文和持久化

ToolRuntime 在现有 ToolExecutor 外统一处理:

  1. Tool 注册与 JSON/schema 参数;
  2. PermissionPolicy 和 WorkspacePathPolicy;
  3. TurnBudget、timeout 与 cancellation;
  4. 读并行与写/独占 barrier;
  5. ToolResult、Verification、Mutation 和 Artifact 标准化;
  6. 每个 barrier 结果立即 checkpoint。

RAG 是模型按需选择的 search_knowledge_base 普通工具,本地 embedding 模型由 damnatiox-agent[rag] extra 提供;read_artifact 对超长 结果执行有界读取。Skills、Workspace Facts 和 Attempt Facts 以 ContextBlock 注入,不在 Loop 内增加路由分支。

Workspace 可写时的状态布局:

.damnatiox/
├── sessions/*.json
├── attempts/<session_id>/<attempt_id>.json
├── events/<session_id>/<attempt_id>.json
├── events/<session_id>/.sequence-high-water
└── artifacts/<session_id>/<attempt_id>/*

只读 Workspace 使用相同子目录结构,根目录切换到 ~/.damnatiox/workspaces/<workspace>-<hash>/;文件工具的 Workspace 边界保持不变。

Turn 开始即保存 running Attempt;assistant message、tool call/result、usage、 verification 和 mutation 按 checkpoint 更新。重启会终态化遗留 Attempt、补齐 terminal event,并恢复 completed Turn。超长 ToolResult 保存为 Artifact,上下文 只携带预览、hash 和引用。

ContextBuilder 估算 system、summary、历史、Skills、工具 schema、当前 ToolResult、Evidence 和工程事实。Compaction 在回答返回后使用独立预算和单 worker 运行,避免阻塞主回答路径。

Python API

不使用 TUI 时可直接嵌入:

import os
from rich.console import Console

from damnatiox_agent.application import build_agent_application
from damnatiox_agent.interfaces import LocalAgentAPI

application = build_agent_application(
    Console(),
    api_key=os.environ["DEEPSEEK_API_KEY"],
    workspace=".",
)
api = LocalAgentAPI(application)
session = api.create_session()
result = api.start_turn(session["session_id"], "检查当前仓库")

React gateway 和 Python 调用方共享同一个 AgentApplication、Attempt 格式与 AgentEvent 协议。

开发、构建与测试

Python:

python -m pip install -e ".[dev]"
python -m ruff format --check .
python -m ruff check .
python -m compileall -q chain context damnatiox_agent rag skill tool tui validation
python -m pytest -q
python -m build
python -m twine check dist/*

React / TypeScript:

cd frontend
npm ci
npm run typecheck
npm test
npm run build
cd ..

damnatiox --ui-info
damnatiox --frontend-smoke

npm run build 使用 esbuild 生成单一 Node ESM bundle 和 SHA256 manifest。 测试覆盖 JSON-RPC、gateway 并发、stream/cancel/approval、React reducer、 slash commands、布局组件、launcher 完整性、Session 恢复和 Harness Loop。 --frontend-smoke 同时验证静态 Ink 渲染和 Node → Python 隔离模式的 initialize / approval / cancel / shutdown 桥接。

Declarative eval:

python -m damnatiox_agent.evals --tasks evals/tasks.json --pretty

默认 eval runner 用 scripted steps 检查 schema、指标和阈值,不代表在线模型质量; AgentApplicationTurnRunner 用于受控的真实 Application 评测。

Wheel 与 GitHub Actions

发布产物分为:

产物 React 运行时
sdist / py3-none-any 通用 wheel 包含 React bundle;使用系统 Node >= 22,auto 可进入 Rich
Linux x64 platform wheel 内置校验后的 Node 24.14.0
Windows x64 platform wheel 内置校验后的 Node 24.14.0
macOS x64 platform wheel 内置校验后的 Node 24.14.0
macOS arm64 platform wheel 内置校验后的 Node 24.14.0

Node 下载 URL、archive SHA256、目标和 wheel tag 固定在 scripts/node-runtime-lock.json。平台构建再次校验 archive,提取 Node executable 与 LICENSE,并将 runtime manifest 写入 wheel;launcher 在执行包内 Node 前校验 executable SHA256。不在源码树中提交 Node 二进制。

.github/workflows/ci.yml 在每次 branch push 及针对 main 的 Pull Request 上,于 Ubuntu、Windows、macOS 使用 Python 3.14 和 Node 24.14.0,执行 npm typecheck/test/build、Ruff、compileall、pytest、Python 构建、Twine 检查,并在干净环境从仓库外目录运行 --version、--ui-info 和 --frontend-smoke。

.github/workflows/publish.yml 继续由 GitHub Release published 触发:

  1. 校验 tag 与 Python 包版本;
  2. 构建 sdist、通用 wheel 和四个平台 wheel;
  3. 对前端、Node archive、wheel 和干净安装执行检查;
  4. 汇总并核对发布产物集合;
  5. 使用 PyPI Trusted Publishing(OIDC)发布。

Codex / Hermes 的结构借鉴

本项目借鉴的是结构,而非复制实现:

  • Codex 的 App Server 思路:前端通过结构化 request/response/notification 与 后端通信,不解析 CLI 文本;
  • Codex 的 UI/backend 分工:Session、Turn、权限、工具和持久化归 Harness, TUI 只维护展示与输入状态;
  • Hermes 的 facade/gateway 思路:不同入口共享统一 Agent 生命周期和事件;
  • 两者共同体现的稳定 ID、事件 cursor、工具审批和前后端协议边界。

DamnatioX 当前仍使用自己的 Python Harness、LocalAgentAPI、NDJSON gateway、 React reducer、Workspace 策略和持久化格式。Rich 兼容层保留用于显式回退; 后续高级能力继续以真实评测和失败案例为前提加入。

Metadata

Release files for damnatiox-agent 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for damnatiox-agent 0.2.2
File Size Uploaded Provenance
damnatiox_agent-0.2.2.tar.gz 720.0 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for damnatiox-agent 0.2.2
File
damnatiox_agent-0.2.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
damnatiox_agent-0.2.2-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
damnatiox_agent-0.2.2-py3-none-macosx_14_0_x86_64.whl Python 3 none macOS 14.0+ x86-64 Details
damnatiox_agent-0.2.2-py3-none-macosx_14_0_arm64.whl Python 3 none macOS 14.0+ ARM64 Details
damnatiox_agent-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 160.7 MB

Release files / damnatiox_agent-0.2.2.tar.gz

Download URL damnatiox_agent-0.2.2.tar.gz
Size 720.0 kB
Tags Source
SHA-256 checksum
How to use checksums
82bdce9cc5d332ef1583d1ef5978e5280b6fba727bc899f7a12b9aabd40a23b0
BLAKE2b-256 checksum
How to use checksums
4d5258252bda2c57c421de13d5615858a96197dcd44f6c42dc089d08e6c60586
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 Aug 8, 2026.

Transparency log

Release files / damnatiox_agent-0.2.2-py3-none-win_amd64.whl

Download URL damnatiox_agent-0.2.2-py3-none-win_amd64.whl
Size 35.8 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
eb62e2b2fd24c1ff61706fc8b14cef2e0ff13e2c967dc842f7e4b6a4b5d729b6
BLAKE2b-256 checksum
How to use checksums
a419dbb7228451c4cb617b686eeedc449ecb4563644bf2c1d3f1ec3fbfc28bfa
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 Aug 8, 2026.

Transparency log

Release files / damnatiox_agent-0.2.2-py3-none-manylinux_2_28_x86_64.whl

Download URL damnatiox_agent-0.2.2-py3-none-manylinux_2_28_x86_64.whl
Size 44.2 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
55cd6618667f71f87b4a97d8f44c0d2206f6e69ce4b5f142f07348c955ee941f
BLAKE2b-256 checksum
How to use checksums
4de4296e746513c2e6fe9f7d925624c3364b44d7e4e5b989d5aee1dd4f7c7e96
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 Aug 8, 2026.

Transparency log

Release files / damnatiox_agent-0.2.2-py3-none-macosx_14_0_x86_64.whl

Download URL damnatiox_agent-0.2.2-py3-none-macosx_14_0_x86_64.whl
Size 40.2 MB
Tags Python 3 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
ee00a491512ca656e87c9c7d62324a1965275a76baeb1d57715bb3899140d387
BLAKE2b-256 checksum
How to use checksums
8b8052c0361c617cf12874ea46165843c6d3f4cb2a46775f62bd58f606eeb3fe
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 Aug 8, 2026.

Transparency log

Release files / damnatiox_agent-0.2.2-py3-none-macosx_14_0_arm64.whl

Download URL damnatiox_agent-0.2.2-py3-none-macosx_14_0_arm64.whl
Size 39.0 MB
Tags Python 3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
fc5bf627d40ea1572a595fa296cf7dacf06c4b17d405dc3b6ec2c91cf9628a53
BLAKE2b-256 checksum
How to use checksums
0da4039bfdb0a4616e309f6b049e133f68779ef9f48440c104a567bfcb76bbe7
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 Aug 8, 2026.

Transparency log

Release files / damnatiox_agent-0.2.2-py3-none-any.whl

Download URL damnatiox_agent-0.2.2-py3-none-any.whl
Size 632.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22dcc17ec4b8a888584972e5daa2e4475aef64df12657e040d6b6e3132b197e9
BLAKE2b-256 checksum
How to use checksums
cbc64884d59b4aebb0878f1b0afe6d077399d27829cbfa52932052ed94aff781
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 Aug 8, 2026.

Transparency log

Security for damnatiox-agent 0.2.2

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

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for damnatiox_agent-0.2.2.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 Aug 8, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page