Metadata-Version: 2.2
Name: aicortexpy
Version: 0.1.0
Summary: AICortex Python local agent runtime daemon (no Docker)
Author: AICortex
License: Apache-2.0
Project-URL: Homepage, https://gitee.com/seacozz2007/aicortex
Project-URL: Repository, https://gitee.com/seacozz2007/aicortex
Project-URL: Issues, https://gitee.com/seacozz2007/aicortex/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: websocket-client>=1.6
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"

# aicortexpy（Python daemon）

用已批准的 `python.exe` 跑本地 agent runtime（跨 Windows / macOS / Linux），**无需 Docker**。

| | 名称 |
|--|--|
| PyPI | `aicortexpy`（`aicortex` 与已有包 `ai-cortex` 过近被拒） |
| 模块 | `aicortexpy`（不能叫 `aicortex`：本仓库目录也叫 `aicortex`，在父目录执行会撞 PEP 420 命名空间包） |
| 调用 | `python -m aicortexpy`（不注册 console script，避免与 Go CLI `aicortex` 抢 PATH） |

```powershell
pip install aicortexpy
python -m aicortexpy --help
```

## 安装

### 从 PyPI

```powershell
pip install -U aicortexpy
```

### 从源码（本仓库）

```powershell
cd python-daemon
pip install -e .
pip install -e ".[dev]"   # 含 build / twine
```

## 运行

```powershell
# 方式 A：经 Go aicortex CLI（推荐；需已 pip 安装本包）
$env:AICORTEX_DAEMON_BACKEND = "python"
aicortex daemon start
aicortex daemon status
aicortex daemon stop

# 方式 B：直接启动
python -m aicortexpy start --foreground
python -m aicortexpy capabilities
python -m aicortexpy --version
```

需要 `~/.aicortex/config.json`（token + server_url）以及 PATH 上的 agent CLI。

Health 默认端口 **19514**（与 Go / `aicortex daemon status` 一致）。**不要**与 Go daemon 同时跑在同一端口。

## 发布到 PyPI（对齐 aicorkit / aicortex-bridge）

在 `python-daemon/` 目录：

```powershell
python -m pip install -U build twine
python -m build
python -m twine upload dist/*
```

版本号改 `pyproject.toml` 的 `version` 与 `aicortexpy/__init__.py` 的 `__version__`（保持一致），再重新 build / upload。

## 已对齐能力（相对 Go daemon）

- 注册/心跳/wakeup/claim/cancel、agentEnv、prior_work_dir 复用
- Claude（stream-json + **MCP `--mcp-config`**）、Codex（+ semantic inactivity）
- Cursor/Gemini/OpenCode/Copilot **stream-json/json 事件流**
- Cursor/Kiro chat ACP 池；Kiro/Hermes/Kimi/Dsh ACP oneshot
- OpenClaw / pi 启动参数；OpenClaw config **fail-closed**
- Repo：**allowlist** + per-workspace bare + **worktree 锁** + co-authored hook
- Design：**handoff zip** + **example seed**
- Model list：**ACP discovery** + 60s cache
- GC：`.gc_meta.json` + **active-root 保护**
- Wakeup 侧带：**tunnel**、**artifact browse/chunk upload**、terminal（pipe MVP，需 `AICORTEX_DAEMON_TERMINAL_PTY=true`）

**仍偏薄 / partial**：真正的 ConPTY/unix PTY（现为 pipe shell）、OS sandbox wrapper（bwrap/Seatbelt）、Go 式 auto-update（用 `pip install -U aicortexpy`）。

## 环境变量（节选）

| 变量 | 含义 |
|------|------|
| `AICORTEX_DAEMON_BACKEND` | `python` 时 `aicortex daemon start` 启 Python daemon |
| `AICORTEX_DAEMON_HEALTH_PORT` | 默认 19514 |
| `AICORTEX_DAEMON_TERMINAL_PTY` | `true` 启用远程终端（pipe MVP） |
| `AICORTEX_AGENT_IDLE_WATCHDOG` | 无活动强停秒数（默认 300；`0` 关闭） |
| `AICORTEX_CODEX_SEMANTIC_INACTIVITY_TIMEOUT` | Codex 无输出强停（默认 600；`0` 关闭） |
| `AICORTEX_CODEX_MULTI_AGENT` | `1` 保留 Codex native multi_agent |
| `AICORTEX_INJECT_TENCENT_DOCS` | `1` 注入完整 tencent-docs 包 |
| `AICORTEX_GC_*` | GC 开关与 TTL |
