Metadata-Version: 2.4
Name: byoe
Version: 2.2.3
Summary: 鍗滀竴鏅鸿埅 鈥?鎼烘櫤鑰屾潵锛屽喅绛栭殢琛屻€侫I 寮€鍙戝洟闃熺紪鎺?+ 鍐呯疆澶氭ā鍨嬬紪绋?Agent 涓€浣撳寲宸ュ叿
Author-email: "byoe.net" <hi@byoe.net>
License-Expression: MIT
Project-URL: Homepage, https://www.byoe.net
Project-URL: Repository, https://github.com/byoenet/byoe
Project-URL: Bug Tracker, https://www.byoe.net/bugs
Project-URL: Changelog, https://www.byoe.net/changelog
Keywords: ai,agent,orchestration,coding,llm,cli,dev-team,byoe
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Environment :: Console
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openai>=1.0
Requires-Dist: rich>=13.0
Requires-Dist: prompt_toolkit>=3.0
Provides-Extra: dotenv
Requires-Dist: python-dotenv>=1.0; extra == "dotenv"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Provides-Extra: web
Provides-Extra: fast
Requires-Dist: tiktoken>=0.5; extra == "fast"
Provides-Extra: structured
Requires-Dist: pydantic>=2.0; extra == "structured"
Provides-Extra: enterprise
Requires-Dist: cryptography>=42.0; extra == "enterprise"
Provides-Extra: langfuse
Requires-Dist: langfuse>=2.60; extra == "langfuse"
Provides-Extra: tracing
Requires-Dist: opentelemetry-api>=1.20; extra == "tracing"
Requires-Dist: opentelemetry-sdk>=1.20; extra == "tracing"
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.20; extra == "tracing"
Provides-Extra: all
Requires-Dist: python-dotenv>=1.0; extra == "all"
Requires-Dist: tiktoken>=0.5; extra == "all"
Requires-Dist: pydantic>=2.0; extra == "all"
Requires-Dist: cryptography>=42.0; extra == "all"
Requires-Dist: opentelemetry-api>=1.20; extra == "all"
Requires-Dist: opentelemetry-sdk>=1.20; extra == "all"
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.20; extra == "all"
Dynamic: license-file

﻿# BYOE - Bring Your Own Executive AI

> An AI developer-team orchestration tool by [byoe.net](https://www.byoe.net)

**BYOE** combines a lightweight coding Agent with a Crew orchestration layer, so every developer can have an AI crew standing by at all times.

Website: https://www.byoe.net | Install: `pip install byoe`

## 重要更新（1.0.0）

### Python 库 API 全面开放

BYOE 现在是一个**可编程 Python 库**，不再只是 CLI 工具：

```python
pip install byoe
```

```python
import byoe

# 工厂函数，自动从环境变量读取配置
agent = byoe.create_agent()

# 三种调用方式
result = agent.chat("解释向量数据库")          # 同步

stream = agent.stream("写一首诗")              # 流式
for tok in stream:
    print(tok, end="", flush=True)
poem = stream.result                           # 完整文本

import asyncio
result = asyncio.run(agent.achat("重构这段代码"))  # asyncio 异步
```

### 产品功能特点（1.0.0）

| 特性 | 说明 |
|------|------|
| 🐍 **Python 库 API** | `from byoe import Agent, LLM, Tool, create_agent` |
| 📦 **结构化输出** | `agent.chat("...", response_model=MyModel)` 返回 pydantic 实例 |
| 🔗 **模型降级链** | `fallback_models=["gpt-4o-mini"]` 自动切换备用模型 |
| 💾 **会话持久化** | `agent.save()` / `agent.load(path)` 跨进程恢复对话 |
| 🧠 **语义记忆** | `BYOE_EMBEDDING_MODEL` 启用向量搜索，零新依赖 |
| 🔀 **Swarm 并行分组** | `parallel_groups=[["安全","性能"],["主管"]]` scatter-gather |
| 🔌 **工具插件系统** | pip 包通过 entry-point 自动注册工具 |
| 🔄 **MCP 双向集成** | `byoe mcp-server` 暴露工具；`create_agent(mcp_servers=[...])` 接入外部 MCP 工具 |
| 🖼️ **多模态图片输入** | `chat/stream/achat(images=[...])` 支持图片理解，内置 `read_image` 工具 |
| 🛡️ **CLI Git 安全确认** | risky Git 操作交互确认，危险操作默认拒绝 |
| 🌐 **Helm Web UI** | 内置前端界面，支持会话、工具轨迹与状态可视化 |
| 📊 **`byoe metrics`** | Token 用量与费用统计 |
| 🗂️ **`byoe memory`** | 命令行直接搜索/管理记忆 |

升级命令：
```bash
pip install -U byoe
```


## 企业级功能（v1.4.0）

### 密钥管理

```bash
# 设置加密密钥（首次使用自动生成）
byoe secrets set OPENAI_API_KEY sk-...

# 列出已存储的密钥
byoe secrets list

# 查看密钥值
byoe secrets get OPENAI_API_KEY

# 删除密钥
byoe secrets rm OPENAI_API_KEY
```

密钥使用 Fernet 加密存储于 `~/.byoe/secrets.json`，自动降级到 XOR 加密（无需额外依赖）。

### API Key 认证

```bash
# 生成 API Key
byoe auth create --name "my-app" --role admin

# 列出所有 Key
byoe auth list

# 吊销 Key
byoe auth revoke <key-id>
```

### HTTP 网关

```bash
# 安装企业依赖
pip install byoe[enterprise]

# 启动 HTTP 网关（默认端口 8000）
byoe serve

# 指定端口和主机
byoe serve --port 8080 --host 0.0.0.0
```

```bash
# 调用示例
curl -H "X-API-Key: <key>" -H "Content-Type: application/json" \
  -d '{"q":"解释二分查找"}' \
  http://localhost:8000/chat
```

---

## A2A 协议（v2.2.0）

byoe agent 可作为 **A2A（Agent2Agent，Linux Foundation 开放标准）** 的对等节点被发现与调用：

- **发现**：`GET /.well-known/agent.json` —— AgentCard（身份/能力/技能/端点）
- **同步任务**：`POST /v1/a2a`，JSON-RPC `message/send` → Task（submitted→working→completed，
  产物 artifacts + 对话 history）
- **流式任务**：`message/stream`（SSE）——逐 token message 帧 + statusUpdate +
  artifactUpdate(lastChunk)，事件顺序 = 生成顺序
- 失败语义：引擎异常 → Task(state=failed, status.message 带原因)；未知任务 → -32001；
  方法归一同时接受 0.3 snake_case 与 1.0 TitleCase

```bash
curl http://localhost:8010/.well-known/agent.json
curl -X POST http://localhost:8010/v1/a2a -H "content-type: application/json"   -d '{"jsonrpc":"2.0","id":1,"method":"message/send",
       "params":{"message":{"role":"user","parts":[{"kind":"text","text":"hi"}]}}}'
```

任意 A2A 客户端（含第三方框架 agent）即可把 byoe agent 当远程专家协作——
与 MCP（工具侧）、AG-UI（前端侧，`/v1/agui`）构成完整互操作三件套。

## 沙箱代码执行（v2.1.0）

LLM 生成的代码在**可插拔沙箱后端**中执行，隔离强度按需选择：

| 后端 | 隔离等级 | 依赖 | 选择方式 |
|---|---|---|---|
| `subprocess`（缺省） | 独立子进程 + 精简 env + 超时强杀 | 零依赖 | 缺省 |
| `inprocess` | 进程内（共享状态延续，仅可信代码） | 零依赖 | `BYOE_SANDBOX=inprocess` |
| `docker` | 容器（无网络 + 内存/CPU 配额 + no-new-privileges） | docker CLI | `BYOE_SANDBOX=docker` |
| `e2b` | 云 microVM（Firecracker 级硬件隔离） | `pip install e2b-code-interpreter` + E2B_API_KEY | `BYOE_SANDBOX=e2b` |

```python
tool = PythonReplTool(backend="docker")           # 或环境变量全局选择
agent = byoe.create_agent(model=..., tools=[tool], ...)
```

配套 2.0 能力：Langfuse trace 树（`byoe[langfuse]` + `BYOE_LANGFUSE=1`）、评测骨架
（`byoe.engine.evals`）、Agent checkpoint 断点续聊、工具超时+熔断、成本感知路由、
PII/密钥自动脱敏。

## OpenTelemetry 可观测性（v1.6.0+）

```bash
pip install byoe[tracing]
```

```python
import byoe
byoe.setup_tracing(service_name="my-app")
```

或通过环境变量一键启用：

```bash
export BYOE_TRACING=1
export OTEL_SERVICE_NAME=byoe
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
```

自动追踪：LLM 调用 (span: `llm.chat`)、工具执行 (span: `tool.execute.<name>`)、Agent 回合 (span: `agent.turn`)。

## Java 客户端 SDK（v1.6.0+）

`java/` 目录提供官方 Java 客户端，支持 pipe 协议和 HTTP 网关：

```xml
<dependency>
    <groupId>net.byoe</groupId>
    <artifactId>byoe-client</artifactId>
    <version>1.6.0</version>
</dependency>
```

```java
ByoeClient client = new ByoeClient(ByoeConfig.fromEnv());
String response = client.chat("解释二分查找");
client.chat("写一首诗", token -> System.out.print(token));
client.close();
```

详细文档见 [java/README.md](java/README.md)。

---

## 历史更新 (0.7.3)

- **技术栈更新和工具集成**： CLI 中使用 `byoe sober` 即可通过原生多文件正则实现项目代码扫描检测，提供 `console/md` 两种输出模式！
- **修复**: 更新了 PyPI 的项目页面元信息，确保链接准确指向 `www.byoe.net`
- 升级命令：
        ```bash
        pip install -U byoe
        ```

## Features

- **AI Coding Agent** — reads/writes files, runs bash commands, searches the web
- **Web UI (Helm)** — React frontend with dark/light theme, session history, token usage
- **CLI** — `byoe chat` for terminal-first workflows
- **Crew Orchestration** — plan and track multi-agent project workflows
- **Any LLM** — OpenAI, Anthropic, DeepSeek, Ollama, or any OpenAI-compatible API
- **Deep Integration** — auto-injects INSTRUCTIONS.md and crew.yaml into the system prompt
- **Session Memory** — save and restore conversations with full token accounting
- **Custom Skills** — extend the agent with your own tools

---

## Installation

```bash
pip install byoe
```

Development install:

```bash
git clone https://github.com/byoenet/byoe
cd byoe
pip install -e .
```

---

## Quick Start

### Web UI

```bash
export OPENAI_API_KEY=sk-...
export BYOE_MODEL=deepseek-chat
byoe web
```

Open http://localhost:7860 in your browser.

### CLI Chat

```bash
export OPENAI_API_KEY=sk-...
export BYOE_MODEL=deepseek-chat
byoe chat
```

### BYOE Hosted Service

```bash
export BYOE_API_KEY=<your-token>
export BYOE_BASE_URL=https://api.byoe.net
byoe web
```

---

## Configuration

Config file: `~/.byoe/config.yaml`

```yaml
provider: openai    # openai | anthropic | deepseek | byoe | ollama
api_key: sk-...
model: gpt-4o
base_url: ""        # optional: custom endpoint
```

Environment variables:

```bash
export BYOE_PROVIDER=openai
export BYOE_API_KEY=sk-...
export BYOE_MODEL=gpt-4o
```

---

## Supported Providers

| Provider | --provider value | Notes |
|----------|-----------------|-------|
| OpenAI | openai | GPT-4o, o1, etc. |
| Anthropic | anthropic | Claude 3.5 Sonnet, etc. |
| DeepSeek | deepseek | deepseek-chat, deepseek-coder |
| Ollama | ollama | Local models |
| BYOE | byoe | Hosted service at byoe.net |
| Any OpenAI-compat | openai + --base-url | LM Studio, vLLM, etc. |

---

## Crew Commands

```bash
byoe init              # Initialize project (creates INSTRUCTIONS.md + crew.yaml)
byoe plan "<goal>"     # Generate a sprint plan
byoe status            # Show current sprint / task status
byoe release           # Tag and document a release
byoe run               # Execute the next planned task
byoe agents            # List available specialist agents
```

---

## License

MIT (c) byoe.net
