Metadata-Version: 2.4
Name: spark-agent
Version: 0.15.4
Summary: Local-first AI coding agent and office workbench with auditable guardrails
License: MIT
Keywords: ai-agent,coding-agent,local-first,openai-compatible,office-automation,mcp
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.11.5
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: agent-client-protocol<1.1,>=1.0.0
Requires-Dist: chromadb>=1.0
Requires-Dist: instructor<2.0,>=1.4
Requires-Dist: litellm<2.0,>=1.110.1
Requires-Dist: llama-index-core<1.0,>=0.14.26
Requires-Dist: llama-index-llms-openai-like<1.0,>=0.9.0
Requires-Dist: httpx<1.0,>=0.27
Requires-Dist: langgraph<2.0,>=1.2.22
Requires-Dist: langgraph-checkpoint-sqlite<4.0,>=3.1.1
Requires-Dist: aiosqlite<0.23,>=0.20
Requires-Dist: croniter<8.0,>=7.0
Requires-Dist: mcp<2.0,>=1.0; python_version >= "3.10"
Requires-Dist: nbformat<6.0,>=5.10
Requires-Dist: pydantic<3.0,>=2.14.3
Requires-Dist: pydantic-settings<3.0,>=2.16.3
Requires-Dist: packaging<27,>=23
Requires-Dist: filelock<5,>=4.2.1
Requires-Dist: textual<1.0,>=0.80
Requires-Dist: tomlkit<1.0,>=0.13
Requires-Dist: tree-sitter<0.27,>=0.26.1
Requires-Dist: tree-sitter-javascript<0.26,>=0.23
Requires-Dist: tree-sitter-python<0.26,>=0.23
Requires-Dist: tree-sitter-typescript<0.24,>=0.23
Requires-Dist: typer<1.0,>=0.29.1
Provides-Extra: browser
Requires-Dist: playwright>=1.65.2; extra == "browser"
Provides-Extra: local
Requires-Dist: llama-cpp-python<0.4,>=0.3.37; extra == "local"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=1.5.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: ruff>=0.17.5; extra == "dev"
Requires-Dist: import-linter>=2.16; extra == "dev"
Requires-Dist: mypy>=1.11; extra == "dev"
Requires-Dist: bandit>=1.7; extra == "dev"
Requires-Dist: pre-commit>=3.6; extra == "dev"
Requires-Dist: playwright>=1.65.2; extra == "dev"
Provides-Extra: openapi
Requires-Dist: fastapi>=0.163.1; extra == "openapi"
Provides-Extra: platform
Requires-Dist: fastapi>=0.163.1; extra == "platform"
Requires-Dist: uvicorn>=0.54; extra == "platform"
Requires-Dist: sse-starlette>=3.7.0; extra == "platform"
Requires-Dist: tiktoken>=0.14; extra == "platform"
Requires-Dist: tenacity>=9.2; extra == "platform"
Requires-Dist: SQLAlchemy>=2.1; extra == "platform"
Requires-Dist: pathspec>=1.1; extra == "platform"
Requires-Dist: wcmatch>=12.0.3; extra == "platform"
Requires-Dist: psutil>=7.2; extra == "platform"
Provides-Extra: enterprise
Requires-Dist: fastapi>=0.163.1; extra == "enterprise"
Requires-Dist: uvicorn>=0.54; extra == "enterprise"
Requires-Dist: SQLAlchemy>=2.1; extra == "enterprise"
Requires-Dist: alembic>=1.14; extra == "enterprise"
Requires-Dist: authlib>=1.9.8; extra == "enterprise"
Requires-Dist: casbin>=1.43; extra == "enterprise"
Requires-Dist: pyjwt>=2.10; extra == "enterprise"
Requires-Dist: python-multipart>=0.0.34; extra == "enterprise"
Provides-Extra: postgres
Requires-Dist: asyncpg>=0.30; extra == "postgres"
Requires-Dist: psycopg[binary]>=3.3.9; extra == "postgres"
Provides-Extra: office
Requires-Dist: python-docx>=1.1; extra == "office"
Requires-Dist: openpyxl>=3.1; extra == "office"
Requires-Dist: python-pptx>=1.0; extra == "office"
Requires-Dist: pypdf>=7.1.0; extra == "office"
Requires-Dist: pypdfium2>=4.0; extra == "office"
Requires-Dist: rapidocr-onnxruntime>=1.4; extra == "office"
Requires-Dist: extract-msg>=0.58; extra == "office"
Requires-Dist: reportlab>=4.0; extra == "office"
Provides-Extra: asr
Requires-Dist: faster-whisper>=1.2; extra == "asr"
Requires-Dist: av<19,>=15; extra == "asr"
Provides-Extra: notebook
Requires-Dist: nbclient<1.0,>=0.11; extra == "notebook"
Provides-Extra: search
Requires-Dist: ddgs>=9.16; extra == "search"
Requires-Dist: trafilatura>=2.3; extra == "search"
Provides-Extra: telemetry
Requires-Dist: opentelemetry-api>=1.28; extra == "telemetry"
Requires-Dist: opentelemetry-sdk>=1.28; extra == "telemetry"
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.28; extra == "telemetry"
Provides-Extra: pty
Requires-Dist: ptyprocess>=0.7; sys_platform != "win32" and extra == "pty"
Requires-Dist: pywinpty>=3.1; sys_platform == "win32" and extra == "pty"
Provides-Extra: desktop
Requires-Dist: pywebview>=5.0; sys_platform != "linux" and extra == "desktop"
Requires-Dist: pywebview[qt]>=5.0; sys_platform == "linux" and extra == "desktop"
Dynamic: license-file

> **English** | [中文](README_zh.md)

# Spark

**Local-first AI coding agent and office workbench, with guardrails you can audit.**

Spark gives you one agent loop across the terminal, browser, desktop, IDE and API. Every write is gated by approval and a sandbox, every turn can be rolled back, and the model layer works with any OpenAI-compatible endpoint.

```bash
# Linux / macOS — SHA256-verified installer
curl -fsSL https://raw.githubusercontent.com/badhope/spark/main/scripts/install.sh | sh

# Windows (PowerShell)
irm https://raw.githubusercontent.com/badhope/spark/main/scripts/install.ps1 | iex

spark init    # connect any OpenAI-compatible endpoint
spark web     # open the browser UI
```

No API key? Spark starts in demo mode with a local mock model. Add a key in settings and the next turn uses the real model without a restart.

![Spark chat with reasoning, tool calls and a live context meter](assets/screenshots/11-chat.png)

## What it does

- **Auditable execution.** Approval modes and sandbox levels are enforced before a write or command runs. Wildcard rules are scoped to user, project and local config; `deny` always wins. Protected credential paths and shell token checks stay on.
- **Recoverable by design.** Each turn snapshots the workspace and can restore files and conversation together, including outside git repositories.
- **Task-as-branch.** Start a task, commit each verified step, and finish on green tests; a failed run abandons its branch instead of leaking changes.
- **Built for real files.** The office workbench turns documents, meeting recordings and spreadsheets into cited minutes, action items, reports and exports. Local OCR and transcription keep the source on your machine.
- **Provider freedom.** Any OpenAI-compatible endpoint, fallback model chain and credential pool, plus a separate small model for auxiliary calls.

## Run it

```bash
spark                         # terminal TUI
spark web                     # browser UI on loopback
spark desktop                 # native window, loopback only
spark exec "task" --json      # NDJSON events for scripts and CI
spark review                  # inspect the uncommitted diff
spark doctor                  # check config, credentials and runtime
```

The office workbench runs through the enterprise control plane:

```bash
spark enterprise --host 127.0.0.1 --port 18800
# http://127.0.0.1:18800/office
```

`spark exec` emits one JSON object per line and ends with `{"type":"final","text":"…"}`, so it pipes directly into `jq`.

## Interfaces

| Interface | Command | Use it for |
|---|---|---|
| Web UI | `spark web` | Chat, files, terminal, execution graph |
| Enterprise API | `spark enterprise` | `/api/v1` control plane and `/office` |
| Desktop | `spark desktop` | Native window, loopback only |
| TUI / CLI | `spark` · `spark exec --json` | Terminal work and automation |
| IDE / ACP | `spark acp` · `spark ide install` | Zed, JetBrains, Neovim |
| MCP / A2A | `spark mcp-serve` · `spark a2a-serve` | Tool and agent-to-agent integration |

## Safety model

Three layers narrow each other:

1. **Approval** — from plan-only to full-auto. The default asks before writes and commands.
2. **Sandbox** — workspace isolation by default; escapes and protected paths are refused.
3. **Rules** — tool and resource matching across user, project and local scopes. A cloned repository can tighten permissions, never grant itself more.

OS-level isolation is used where available: bwrap on Linux, Job Objects on Windows, `sandbox-exec` on macOS. When a platform cannot enforce a control, the tool result says so instead of pretending.

## Documentation

| Doc | 中文 |
|---|---|
| [Install & build](docs/en/INSTALL.md) | [安装与打包](docs/INSTALL.md) |
| [Configuration](docs/en/CONFIG.md) | [配置](docs/CONFIG.md) |
| [HTTP API](docs/en/API.md) | [API](docs/API.md) |
| [Architecture](docs/en/ARCHITECTURE.md) | [架构](docs/ARCHITECTURE.md) |
| [Features](docs/FEATURES.md) | [功能总览](docs/FEATURES.md) |
| [Enterprise control plane](docs/ENTERPRISE.md) | [企业控制面](docs/ENTERPRISE.md) |
| [A2A protocol](docs/A2A.md) | [A2A](docs/A2A.md) |
| [ACP / IDE setup](docs/ACP.md) | [IDE 接入](docs/ACP.md) |

More: [docs index](docs/README.md) · [English docs](docs/en/README.md) · [VS Code extension](vscode-spark/README.md) · [audit notes](docs/reviews/).

## Verify locally

```bash
pytest -q
ruff check src tests scripts
mypy src/spark --ignore-missing-imports
```

CI also runs a Windows checkout check, frontend build drift, packaging checks, a secret scan, an OpenAPI snapshot check and a mock-mode agent eval.

## Requirements

Python 3.11.5+ (or the bundled executable), Node.js 18+ only for frontend development, Windows / macOS / Linux.

---

**License:** MIT · **Author:** badhope
