arian-gogani/nobulex

GitHub: arian-gogani/nobulex

为自主AI代理提供信用评分的信任经济模型。

Stars: 37 | Forks: 10

Nobulex — Trust Capital for AI Agents
[![CI](https://img.shields.io/github/actions/workflow/status/arian-gogani/nobulex/ci.yml?style=flat-square&label=CI&color=22c55e)](https://github.com/arian-gogani/nobulex/actions/workflows/ci.yml) [![OpenSSF](https://img.shields.io/badge/OpenSSF-passing-22c55e?style=flat-square)](https://www.bestpractices.dev/projects/10338) [![PyPI](https://img.shields.io/pypi/v/nobulex?style=flat-square&color=22c55e&label=PyPI)](https://pypi.org/project/nobulex/) [![npm](https://img.shields.io/npm/v/@nobulex/core?style=flat-square&color=22c55e)](https://www.npmjs.com/package/@nobulex/core) [![License](https://img.shields.io/badge/License-MIT-22c55e?style=flat-square)](https://opensource.org/licenses/MIT) [![Spec](https://img.shields.io/badge/Spec-Proof_of_Behavior-22c55e?style=flat-square)](./drafts/draft-gogani-nobulex-proof-of-behavior-00.txt)

**每个人都有信用评分。每家企业都有。** **而 AI agents 却一无所有。** Nobulex 是面向自主 AI agents 的信用与信任协议。
Agents 通过经过验证的行为赚取 Trust Capital。信任度越高,访问权限越多。
自主权是赚取的,而非被授予的。 [官网](https://nobulex.com) · [在线体验](https://nobulex.com/demo) · [快速开始](./GETTING-STARTED.md) · [规范](./drafts/draft-gogani-nobulex-proof-of-behavior-00.txt) · [PyPI](https://pypi.org/project/nobulex/) · [npm](https://www.npmjs.com/package/@nobulex/core)
## 安装 ``` pip install nobulex ``` ``` npm install @nobulex/core ``` ``` from nobulex.agent import Agent agent = Agent("my-agent") receipt = agent.act("send_email", scope="user@example.com") assert receipt.verify() # tamper-proof ``` ## 工作原理 每一次 agent 操作都会产生一个加密凭证 —— 在执行前后均进行 Ed25519 签名,并通过哈希链相连以提供防篡改证据。第三方可以在不信任 agent 或运营者的情况下验证完整历史记录。 以下是一次运行中的完整理念(`python -m nobulex demo`): ``` generated 3 receipts allow: 141ca2947a7e819b8bdebbf8... verified=True allow: f3377758ac94d812535cbb99... verified=True deny: 85b2dfd6b87f2678795726e4... verified=True trust score: 23.26 tamper test: modified receipt verified=False (tamper detected) ``` 修改凭证中的任何一个字节,验证都会失败。这就是全部的保证。 **性能:** 在 p50 下约为 13,683 个签名凭证/秒(Python SDK,单核)。完整的签名与链接凭证端到端耗时约 73 μs。请参阅 [BENCHMARKS.md](./docs/BENCHMARKS.md) 了解详细分解;可通过 `python3 scripts/benchmark.py` 进行复现。 凭证会累积成 **Trust Capital** —— agent 的信用评分。 | 等级 | Trust Capital | 访问级别 | |------|--------------|--------------| | Restricted | 0 -- 30 | 只读,沙盒化执行 | | Standard | 30 -- 60 | 最高 $500 的财务操作,API 访问权限 | | Trusted | 60 -- 85 | 跨组织操作,受监管市场 | | Sovereign | 85+ | 完全自主,自我主导 | 创造更多价值的 agents 会获得更多访问权限。发生偏离的 agents 会被自动切断。这不是惩罚——而是数学。 ## 快速开始 ### Python(推荐用于 AI agents) ``` # 或从源码安装 pip install git+https://github.com/arian-gogani/nobulex.git#subdirectory=packages/python ``` ``` # 或立即尝试 CLI demo git clone https://github.com/arian-gogani/nobulex.git cd nobulex/packages/python pip install -e . python -m nobulex demo ``` ``` from nobulex import Agent agent = Agent("my-agent") receipt = agent.act("send_email", scope="user@example.com") assert receipt.verify() # Cryptographic proof print(agent.trust_score) # Trust Capital: 13.86 ``` #### LangChain 集成 ``` from nobulex.integrations.langchain import NobulexAuditHandler handler = NobulexAuditHandler(agent_id="my-agent") agent.invoke({"input": "..."}, config={"callbacks": [handler]}) handler.export("audit.json") # signed, hash-chained audit trail ``` #### CrewAI 集成 ``` from nobulex.integrations.crewai import NobulexCrewAudit audit = NobulexCrewAudit(agent_id="my-crew") audit.record_task("credit_check", "loan-app-4821") audit.export("audit.json") ``` #### Google ADK 集成 ``` from nobulex.integrations.google_adk import NobulexADKCallback cb = NobulexADKCallback(agent_id="my-agent") @cb.wrap_tool("web_search") def search(query): return do_search(query) cb.export("audit.json") ``` #### PydanticAI 集成 ``` from nobulex.integrations.pydantic_ai import NobulexPydanticAIAudit audit = NobulexPydanticAIAudit(agent_id="typed-agent") audit.record_tool("get_weather", {"city": "Berlin"}, {"temp": 22}) audit.export("audit.json") ``` #### Haystack 集成 ``` from nobulex.integrations.haystack import NobulexHaystackAudit audit = NobulexHaystackAudit(agent_id="my-pipeline") audit.record_component("Retriever", {"query": "test"}, {"docs": 5}) audit.export("audit.json") ``` #### LlamaIndex 集成 ``` from nobulex.integrations.llama_index import NobulexLlamaIndexAudit audit = NobulexLlamaIndexAudit(agent_id="llama-agent") audit.record_tool("web_search", {"query": "test"}, {"results": 5}) audit.export("audit.json") ``` #### 验证任何导出的记录(无需信任运营者) ``` from nobulex.chain import verify_audit_trail report = verify_audit_trail("audit.json", authorized_keys=AGENT_PUBLIC_KEY) assert report["chain_intact"] and report["authenticated"] ``` ### JavaScript / TypeScript ``` npm install @nobulex/core npx tsx examples/trust-capital-demo.ts ``` ``` Agent starts at RESTRICTED tier (Trust Capital: 0) Action 1: read_data — ALLOWED (Trust Capital: 12) Action 2: read_data — ALLOWED (Trust Capital: 24) Action 3: process_payment — BLOCKED (insufficient trust) Action 4: read_data — ALLOWED (Trust Capital: 36) Action 5: read_data — ALLOWED (Trust Capital: 48) Agent promoted to STANDARD tier Action 6: process_payment — ALLOWED (Trust Capital: 65) Agent promoted to TRUSTED tier (Trust Capital: 89) Action 8: approve_contract — ALLOWED ``` ## 协议 ``` DECLARE ──► ENFORCE ──► PROVE ──► ACCUMULATE Covenant Pre-execution Receipt chain Trust Capital defines receipt blocks verified by earned over the rules violations third parties time before they happen ──► more access ──► more receipts ──► higher trust ``` 飞轮效应:更多的 Trust Capital 带来更有价值的工作,从而产生更多凭证,进而建立更高的 Trust Capital。问责制由此成为最具盈利能力的策略。 ## 代码 ``` import { createDID, parseSource, EnforcementMiddleware, verify } from '@nobulex/core'; const agent = await createDID(); const spec = parseSource(` covenant SafeTrader { permit read; permit transfer (amount <= 500); forbid transfer (amount > 500); forbid delete; } `); const mw = new EnforcementMiddleware({ agentDid: agent.did, spec }); await mw.execute( { action: 'transfer', params: { amount: 300 } }, // allowed async () => ({ success: true }), ); await mw.execute( { action: 'transfer', params: { amount: 600 } }, // BLOCKED before execution async () => ({ success: true }), // never runs ); const result = verify(spec, mw.getLog()); console.log(result.compliant); // true ``` ## 发展情况 独立、可验证的信号(每一项均附有证据链接): | | 内容 | 证据 | |---|---|---| | | **OWASP CheatSheetSeries** | 第 8-11 节(JCS 规范化、跨 agent 问责制、制裁名单时效性、监管映射)由 Jim Manico 于 2026 年 6 月合并至 master 分支([PR #2210](https://github.com/OWASP/CheatSheetSeries/pull/2210)) | | | **vaara v0.50** | 独立第三方采用 —— Henri Sirkkavaara 发布了欧盟《AI 法案》第 12 条的审计记录,并引用了 nobulex 的签名凭证设计([GitHub](https://github.com/vaaraio/vaara)) | | | **Dify Marketplace** | 在 60,000+ star 的平台上开放了插件 PR([PR #2500](https://github.com/langgenius/dify-plugins/pull/2500))。LangGenius 社区运营确认其架构可靠,且 Trust Capital 具有真正的差异化优势。 | | | **Microsoft AI Agents for Beginners** | 已提交 PR,拟在第 18 课《使用加密凭证保护 AI Agents》中将 nobulex 添加为 Python 生产级凭证库([PR #571](https://github.com/microsoft/ai-agents-for-beginners/pull/571)) | | | **AgentAudit AI** | 五点整合合作伙伴关系生效。签名样本凭证可在 10 行 Python 代码中实现端到端验证([fixture](./fixtures/agentaudit-specimen-v1.json)) | | | **Microsoft AGT** | 列入 [ADOPTERS](https://github.com/microsoft/agent-governance-toolkit/pull/1703)(PR 由 Microsoft 维护者合并) | | | **builderz-labs / mission-control** | 跨会话 Trust Capital RFC 作为公开 issue 被接受;已交付 TypeScript 参考实现 | 欧盟《AI 法案》第 12 条执行日期:2026 年 8 月 2 日。 ## 为什么是现在 AI agents 正在部署到生产环境中,但却缺乏问责基础设施。 - **86%** 的 AI agents 在部署时未经安全审批 (CSA, 2026) - **UUMit** 推出了首个无任何身份验证的 A2A 市场 - **$138B+** 投入到物理 AI 中,且零问责层 - 顶级模型在处理实际问题时得分仅为 **10-15%** (LemmaBench),且在失败时毫无可追溯性 Agents 已经部署。资金正在涌入。而问责基础设施却尚未存在。我们正在构建它。 ## 标准 | 标准 | 状态 | |---|---| | Proof-of-Behavior 规范 | [`draft-gogani-nobulex-proof-of-behavior-00`](./drafts/draft-gogani-nobulex-proof-of-behavior-00.txt) | | Microsoft AGT | 列入 [ADOPTERS](https://github.com/microsoft/agent-governance-toolkit/pull/1703)(PR 已合并) | | CTEF v0.3.2 | 14/14 字节匹配一致性 | | A2A Protocol | 凭证行已提议;URN 方案 `urn:nobulex:receipt:` | | NIST RFI | 已提交正式意见 | ## 开发 ``` git clone https://github.com/arian-gogani/nobulex.git cd nobulex && npm install npx vitest run # tests npx tsx examples/demo.ts # end-to-end npx tsx benchmarks/bench.ts # benchmarks ```
[官网](https://nobulex.com) · [体验](https://nobulex.com/demo) · [npm](https://www.npmjs.com/package/@nobulex/core) · [规范](./drafts/draft-gogani-nobulex-proof-of-behavior-00.txt) · [X @nobulexlabs](https://x.com/nobulexlabs) **[为本项目加星](https://github.com/arian-gogani/nobulex/stargazers)** 以持续关注 MIT License
标签:AI智能体, GNU通用公共许可证, Node.js, Python, Streamlit, 信任机制, 密码学, 手动系统调用, 无后门, 自动化攻击, 行为验证, 访问控制