Skip to main content

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

Project description

Cortex Agent

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

Python TypeScript Node License

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


双语言实现

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

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


快速开始

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

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

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

设计哲学

┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐
│  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 配置

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-edit ✏️ 自动批准编辑 + SYSTEM 放行
yolo ⚠️ 全部放行 (CI/CD)

License

MIT

Project details


Download files

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

Source Distribution

cortx-1.0.0.tar.gz (57.9 kB view details)

Uploaded Source

Built Distribution

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

cortx-1.0.0-py3-none-any.whl (64.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cortx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d48e07c218f3d2fb3261f2c34cd0f565f7258f7a698f7132a1e5e155be879712
MD5 11eb5cc31506f34b6d7b9c09a1d9e16d
BLAKE2b-256 01bb9556a3d90a174e5eec6e276f373792a47fa1769d08ec7e9d133a89464edf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cortx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86b40d55834e264f74af0126ecce5696e27e6c843d06c9cfde2676e91d8d9b4b
MD5 26751d8d36db5fc9507ddd4fe3a1d148
BLAKE2b-256 ada3a69dd9d4a8d3bb983059ae51ce17bf721ccb6c20d45c06bf5bf4e6aee922

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page