Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install ruff
- run: ruff check src scripts tests
- run: ruff format --check src scripts tests

unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: pip install -e ".[dev]"
- run: pytest tests/unit -q

build-sync:
# Fails if the committed single-file distributables drifted from src/.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -e ".[dev]"
- run: python scripts/build.py
- name: Verify distributables are in sync with src/
run: git diff --exit-code open-webui/

integration-tests:
# Live tests against real Tenki microVMs. Only run when the secret is present
# (first-party pushes / manual dispatch); a no-op otherwise.
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -e ".[dev]"
- name: Run live integration tests (skips if no key)
env:
TENKI_API_KEY: ${{ secrets.TENKI_API_KEY }}
TENKI_API_ENDPOINT: ${{ secrets.TENKI_API_ENDPOINT }}
TENKI_PROJECT_ID: ${{ secrets.TENKI_PROJECT_ID }}
run: pytest tests/integration -q
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Release tag to validate against (e.g. v0.1.0)"
required: true

# No PyPI publish: these plugins are distributed as single files via the Open
# WebUI community hub and as GitHub Release assets, not as a pip package.
jobs:
release-assets:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -e ".[dev]"

- name: Build distributables
run: python scripts/build.py

- name: Assert committed distributables are in sync
run: git diff --exit-code open-webui/

- name: Assert version matches the release tag
run: |
TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}"
python scripts/check_version.py "$TAG"

- name: Upload distributables as release assets
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${{ github.event.release.tag_name }}" \
open-webui/tools/tenki_code_execution.py \
open-webui/functions/tenki_run_code.py \
--clobber
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.egg-info/
.eggs/
build/
dist/
wheels/

# Virtual environments
.venv/
venv/
env/

# Testing / tooling
.pytest_cache/
.ruff_cache/
.mypy_cache/
.coverage
htmlcov/

# Editors / OS
.idea/
.vscode/
.DS_Store

# Local run artifacts
live_out/

# Local Claude Code settings
.claude/settings.local.json
89 changes: 89 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Contributing

## Development

The logic is written once under `src/open_webui_tenki/` and inlined into the two
single-file distributables under `open-webui/` by `scripts/build.py`. **Never edit
the files under `open-webui/` by hand** — they are generated.

```bash
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

ruff check src scripts tests # lint
ruff format src scripts tests # format
pytest tests/unit # unit tests (mocked SDK, no credentials)
python scripts/build.py # regenerate the distributables
```

After changing anything in `src/`, run `python scripts/build.py` and commit the
regenerated `open-webui/` files in the same change. CI's `build-sync` job fails
if they drift (`git diff --exit-code open-webui/`).

### Live integration tests

```bash
export TENKI_API_KEY=sk-...
# optional: export TENKI_API_ENDPOINT=https://api.tenki.cloud
# optional: export TENKI_PROJECT_ID=proj_...
pytest tests/integration # provisions real microVMs; costs quota
python scripts/try_live.py # ad-hoc single run; images saved to ./live_out/
```

## Cutting a release

1. Bump the version in these places (they must match — `scripts/check_version.py`
enforces it): `pyproject.toml`, `src/open_webui_tenki/__init__.py`
(`__version__`), and the `version:` frontmatter for both distributables (which
lives in `scripts/build.py`).
2. `python scripts/build.py` and commit the regenerated files.
3. `python scripts/check_version.py vX.Y.Z` to confirm consistency.
4. Create a GitHub Release tagged `vX.Y.Z`. The `release` workflow verifies the
tag matches the declared version and attaches both distributables as release
assets. (No PyPI publish — distribution is single-file via the hub.)

## Publishing to the Open WebUI Community site

Both plugins are published to the [Open WebUI Community site](https://openwebui.com/)
so operators can discover them by keyword and import them in one click (imported
Tools land under **Workspace → Tools**, Functions under **Admin Panel → Functions**).

**Publish both, from the built single-file distributables** (not `src/`):

1. Build and sanity-check first: `python scripts/build.py`, `pytest tests/unit`,
`ruff check src scripts tests`.
2. Sign in at [openwebui.com](https://openwebui.com/).
3. **Tool** — create a new Tool and paste the full contents of
`open-webui/tools/tenki_code_execution.py`.
4. **Function** — create a new Function (Action) and paste the full contents of
`open-webui/functions/tenki_run_code.py`.
5. Link both listings back to this repository, and keep the version in the
listing in sync with the file's frontmatter `version:`.

### Discovery

Listings are found via keyword [search](https://openwebui.com/search). The
frontmatter `title` + `description` are the searchable text, so keep them
keyword-rich — both descriptions cover **code execution, code interpreter,
sandbox, python, shell, isolated, microVM**. Don't shorten the descriptions when
publishing.

### What to know before publishing

- **Listings are unaudited.** Being listed/featured on the community site is not
an endorsement — reviewers are expected to read the source before importing. So
keep the distributables readable and the `README` clear; that is what earns
trust. (Ours: secrets only in Valves, never logged; fully `async` handlers;
documented security posture — all in line with Open WebUI's sharing guidance.)
- **`requirements:` installs at load time.** Open WebUI pip-installs
`tenki-sandbox[async]` on import. This requires that version to be published on
PyPI. Note for operators: in multi-replica deployments, runtime installs can
race across workers — they can set
`ENABLE_PIP_INSTALL_FRONTMATTER_REQUIREMENTS=False` and bake the dependency into
their image instead. (Worth a line in the README's install notes.)

### Optional: docs PR

Consider opening a PR against [`open-webui/docs`](https://github.com/open-webui/docs)
adding a short tutorial that references this plugin, to index "Tenki" as a
code-execution backend for Open WebUI.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 LuxorLabs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading