Skip to main content

Cortx

安全可控的 AI Agent 运行时 — Harness Agent 架构 + Agentic Loop 引擎

Python TypeScript Node PyPI npm License

Cortex = 大脑皮层。如同大脑皮层负责感知推理、血脑屏障严格过滤、海马体持久记忆 — Cortex Agent 将 Agentic Loop(推理)、PolicyEngine(安全)、Memory(记忆)融为一体。


双语言实现

Python TypeScript
位置 python/cortex_agent/ src/
工具数 43 43
安装 pip install cortx npm install -g @chnaicorp/cortx
CLI 命令 ctx ctx

💡 PyPI: pip install cortx,npm: npm install -g @chnaicorp/cortx。运行只需 ctx


快速开始

# Python (3 字母包名)
pip install cortx
ctx

# TypeScript
npm install -g @chnaicorp/cortx
ctx
ctx                         # 交互 REPL
ctx -q "hello"              # 单次查询
ctx --model pro             # 指定模型

# 单次查询
ctx -q "用 Python 写斐波那契函数"

🎯 Agent 自主开发 Demo

给 Agent 一句话指令,它自主完成项目规划、架构设计、前后端编码、依赖安装、编译验证、运行调试全流程,0 人工干预

🛒 企业级购物网站 — cortx-demo-shop-app

指标 数据
源文件数 33 个
总代码行数 2,612 行
技术栈 React + Vite + Express + TypeScript + SQLite + JWT
Agent 续行轮次 3 轮,182 步
人工干预 0 次
# 复现 Agent 自主开发过程
ctx --mode yolo --long --max-rounds 0 -q "请开发设计一个企业级购物网站,完整项目包含:
1.后端(Node.js+Express+TypeScript) RESTful API(商品列表、商品详情、购物车、订单、用户认证JWT),
SQLite数据库含products/users/carts/orders表,密码bcrypt加密,中间件CORS/错误处理/JWT验证。
2.前端(React+Vite+TypeScript) 首页商品展示、商品详情页、购物车管理、用户登录注册、订单提交。
3.数据库:SQLite自动建表+种子数据至少10个商品。"

👉 查看完整项目代码: github.com/CHNAICORP/cortx-demo-shop-app

🧱 打砖块游戏 — cortx-demo-breakout

指标 数据
源文件数 1 个 (单文件 HTML5)
总代码行数 574 行
技术栈 HTML5 Canvas + 原生 JavaScript + CSS3
依赖 0 (零依赖、零构建)
人工干预 0 次
# 复现 Agent 自主开发过程
ctx -q "用 HTML5 Canvas 做一个打砖块 Breakout 游戏,单文件 index.html,包含:
多关卡、计分、生命系统、粒子特效、鼠标+键盘+触摸控制、霓虹风格UI"

👉 查看游戏源码: github.com/CHNAICORP/cortx-demo-breakout · 🎮 直接打开即玩


设计哲学

┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐
│  Think   │ →  │  Guard   │ →  │   Act    │ →  │ Reflect  │
│ (LLM流式)│    │(Policy)  │    │(Executor)│    │(步数收敛)│
└──────────┘    └──────────┘    └──────────┘    └──────────┘
原则 说明
Agent 自主决策 不注入行为指令,Agent 从工具结果中自行推理
完整中介 所有工具调用必经 PolicyEngine 4 级审计
Share-nothing 隔离 每实例独立 work_dir / executor / observer

项目结构

ctx/
├── python/cortex_agent/        # Python 包
│   ├── cortex_agent.py          # Agentic Loop 核心引擎
│   ├── policy.py                # PolicyEngine 安全策略
│   ├── llm.py                   # LLM Provider (DeepSeek/OpenAI)
│   ├── tools.py                 # 核心工具 (25)
│   ├── tools_mcp.py             # MCP 客户端 + 注册表
│   ├── tools_browser.py         # CDP WebSocket 浏览器
│   ├── tools_computer.py        # 桌面控制
│   ├── tools_network.py         # 代理/镜像
│   ├── tools_rag.py             # RAG 知识检索
│   ├── main.py                  # CLI 入口
│   ├── terminal.py              # 流式终端
│   ├── memory.py                # 记忆/会话
│   ├── config.py                # 配置加载
│   └── skills.py                # 技能系统
│
├── src/                         # TypeScript 包
│   ├── core/                    # 核心引擎
│   ├── tools/                   # 工具模块 (7 文件)
│   └── cli/                     # CLI 入口
│
├── cortex_workspace/            # 运行时工作区
├── CORTEX.md                    # 项目知识库
├── pyproject.toml               # Python 包配置
├── package.json                 # npm 包配置
├── tsconfig.json                # TypeScript 配置
└── PUBLISH.md                   # 发布指南

💡 想看 Agent 能做什么? 查看 Demo 项目展示 或直接访问 cortx-demo-shop-app


43 个工具

分类 工具
文件 list_directory read_file write_file edit_file glob grep diff_files file_ops read_json csv_query
执行 run_shell_command run_python execute_sql_query python_lint
网络 web_search web_fetch http_request set_proxy unset_proxy show_proxy
记忆 remember_fact recall_fact forget_fact ask_user
任务 task_create task_list task_update
MCP mcp_list_servers mcp_list_tools mcp_call_tool mcp_registry mcp_install mcp_quick
浏览器 browser_navigate browser_snapshot browser_screenshot
桌面 computer_screenshot computer_click
镜像 pip_mirror npm_mirror
RAG search_knowledge rebuild_knowledge_index
时间 get_current_time

REPL 命令

命令 功能
/help 显示帮助
/context 上下文容量 + 缓存命中率
/kb 查看知识库 CORTEX.md
/goal [目标] 设置/查看持久化目标
/plan [描述] 进入规划模式
/skills 列出所有技能
/skill <name> 调用技能
/mode [s|a|y] 切换权限模式 (Shift+Tab)
/model [pro] 切换模型
/tools 列出工具
/trace /audit 审计追踪
/memory 查看记忆
/sessions 列出会话
@filename 文件引用
/init 初始化项目

权限模式

模式 行为
standard 🛡️ SAFE 自动 / WRITE 区内 / SYSTEM 需确认
auto ✏️ 自动批准编辑 + SYSTEM 放行
yolo ⚠️ 全部放行 (CI/CD)

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cortx-2.4.4.tar.gz (103.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cortx-2.4.4-py3-none-any.whl (109.2 kB view details)

Uploaded Python 3

File details

Details for the file cortx-2.4.4.tar.gz.

File metadata

  • Download URL: cortx-2.4.4.tar.gz
  • Upload date:
  • Size: 103.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for cortx-2.4.4.tar.gz
Algorithm Hash digest
SHA256 579c747cc1a745a8c89fdae7197aabda8d2d5a544be1c1fc257c8a8c99f9b901
MD5 efea1fbd37b093d5347befa4167e87fc
BLAKE2b-256 4c9f9ec42a2bf0d1bcda76f1363b8bb3e8fce8ce86ec4c13b483717ebc0c8a8b

See more details on using hashes here.

File details

Details for the file cortx-2.4.4-py3-none-any.whl.

File metadata

  • Download URL: cortx-2.4.4-py3-none-any.whl
  • Upload date:
  • Size: 109.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for cortx-2.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 03c7a30ca2693c38a7053a369db7722439113e3b948169e9bde14eab6fcd7af4
MD5 959d67d01315fa6059cd6219dcd76930
BLAKE2b-256 907bfba6500ded2c7fb318386454371a1afdc016bc3229b36ee489e382619985

See more details on using hashes here.

Release history Release notifications | RSS feed

2.9.15

2 files

2.9.14

2 files

2.9.13

2 files

2.9.12

2 files

2.9.11

2 files

2.9.10

2 files

2.9.9

2 files

2.9.8

2 files

2.9.7

2 files

2.9.6

2 files

2.9.5

2 files

2.9.4

2 files

2.9.3

2 files

2.9.2

2 files

2.9.1

2 files

2.9.0

2 files

2.8.5

2 files

2.8.4

2 files

2.8.2

2 files

2.8.1

2 files

2.8.0

2 files

2.7.6

2 files

2.7.4

2 files

2.7.3

2 files

2.7.2

2 files

2.7.1

2 files

2.7.0

2 files

2.5.2

2 files

2.5.1

2 files

2.4.5

2 files

This release

2.4.4 This release

2 files

2.4.3

2 files

2.4.2

2 files

2.4.1

2 files

2.4.0

2 files

2.3.1

2 files

2.3.0

2 files

2.2.1

2 files

2.2.0

1 file

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.3.1

1 file

1.3.0

1 file

1.0.35

1 file

1.0.34

1 file

1.0.33

1 file

1.0.32

1 file

1.0.31

1 file

1.0.30

1 file

1.0.29

1 file

1.0.28

1 file

1.0.27

1 file

1.0.26

1 file

1.0.25

1 file

1.0.24

1 file

1.0.23

1 file

1.0.22

1 file

1.0.21

1 file

1.0.20

1 file

1.0.19

1 file

1.0.18

1 file

1.0.17

1 file

1.0.16

1 file

1.0.15

1 file

1.0.14

1 file

1.0.13

1 file

1.0.12

1 file

1.0.11

1 file

1.0.10

1 file

1.0.9

1 file

1.0.8

1 file

1.0.7

1 file

1.0.6

1 file

1.0.5

1 file

1.0.4

1 file

1.0.3

1 file

1.0.0

2 files

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