Metadata-Version: 2.5
Name: kontext-studio
Version: 0.261.1
Summary: Local-first AI data workspace: server, CLI, and runtime
License: MIT
License-File: LICENSE
Requires-Python: <3.15,>=3.12
Requires-Dist: agno[anthropic,aws,azure,google,lmstudio,mistral,ollama,openai]>=3.1.10
Requires-Dist: croniter>=6.0.0
Requires-Dist: docstring-parser>=0.15
Requires-Dist: duckdb>=2.0.0
Requires-Dist: fastapi[standard]>=0.161.1
Requires-Dist: fastembed>=0.4.2
Requires-Dist: greenlet>=3.5.6
Requires-Dist: lancedb>=0.38.0
Requires-Dist: markitdown[pdf]>=0.1.9
Requires-Dist: mistune>=3.4.0
Requires-Dist: openpyxl>=3.1.0
Requires-Dist: oracledb>=26.0.0
Requires-Dist: psycopg[binary]>=3.3.6
Requires-Dist: pyarrow>=26.0.0
Requires-Dist: pydantic-settings>=2.16.0
Requires-Dist: pydantic>=2.14.1
Requires-Dist: pyfiglet>=1.0.0
Requires-Dist: pyiceberg>=0.11.1
Requires-Dist: pyjwt[crypto]>=2.12.0
Requires-Dist: pymysql>=1.2.3
Requires-Dist: pyodbc>=5.2.0
Requires-Dist: python-json-logger>=2.0.7
Requires-Dist: python-multipart>=0.0.9
Requires-Dist: pytz>=2025.2
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: rich>=15.0.0
Requires-Dist: sqlalchemy>=2.1.6
Requires-Dist: tantivy>=0.27.0
Requires-Dist: teradatasql>=20.0.0.72
Requires-Dist: teradatasqlalchemy>=20.0.0.7
Requires-Dist: uvicorn[standard]>=0.54.0
Provides-Extra: telemetry
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.25.0; extra == 'telemetry'
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.46b0; extra == 'telemetry'
Requires-Dist: opentelemetry-sdk>=1.45.1; extra == 'telemetry'
Description-Content-Type: text/markdown

# Kontext (local runtime)

Local server and CLI composition root for Kontext. It is the end-user
entry point: `kontext-studio` starts the local API server, serves the built React
app, and runs an embedded local job worker.

## Features

- **Local server**: hosts the React app and exposes the same API contract as
  the cloud deployment.
- **Local-first runtime**: SQLite plus the local filesystem, with in-process
  execution. No external database or object store required.
- **CLI subcommands**: manage projects, import data, run jobs, and execute SQL
  without starting the full server.
- **Rich UI**: terminal banners and tables via `rich` (ASCII art via `pyfiglet`).

## Installation

This package is installed as part of the unified `kontext-studio` wheel. See the
repository [README](../../README.md#install) for the end-user install path.

For local development, sync the whole uv workspace from the repository root:

```bash
uv sync
```

`pyfiglet`, `rich`, and `python-dotenv` are regular dependencies of this package.

## Usage

```bash
# Start the local server and web app (default command)
kontext

# Same, via the explicit serve entry point
kontext serve

# Manage projects, import data, run jobs, and query
kontext project list
kontext project create --name "My project"
kontext project import --project <id> ./data
kontext job list
kontext job run <job> --project <id>
kontext query "select * from my_table limit 10" --project <id>
```

Run `kontext --help` or `kontext <subcommand> --help` for flags.

At startup the server prints the URL to open, including a per-run launch token
in the fragment (`http://127.0.0.1:8000/#token=...`). Open that URL rather than
the bare host: the API only issues credentials to callers presenting the
token. The app removes the token from the address bar after reading it, and
keeps the session in an HttpOnly cookie so file previews and new tabs work.
The latest token is in `~/.kontext/runtime/launch.token`; a per-port copy lives
in `launch-<port>.token` when several servers run.

## Architecture

```text
src/kontext/labs/
├── cli.py          # argparse entry points (kontext)
├── server.py       # FastAPI app: serves the UI and the local API surface
├── local_worker.py # Embedded local job worker
├── async_cleanup.py
├── telemetry.py
└── _app_dist/      # Built React app synced in at package time
```

The `kontext` console script points at `kontext.labs.cli`. Local routers reuse
the standard routers from
`kontext-api`; keep local routes compatible with that contract rather than
inventing separate local shapes.

## Development

```bash
# Run the whole local stack (API + app) from the repository root
pnpm run dev:local

# Package tests
uv run --package kontext-studio pytest py/kontext-labs/tests
```

## License

MIT. See the repository [LICENSE](../../LICENSE).
