feat(v3.12.0): media pipeline, AI image generation, capability probe, companion v2.9.0
Some checks failed
Release / Test before release (push) Has been cancelled
Release / Publish to PyPI (push) Has been cancelled
Release / Publish to Docker Hub (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled

Three-month batch sync from internal repo (~80 commits) covering Tracks F.5a, F.7e, F.8, F.17, F.18, F.X.

WordPress media pipeline
- Pillow-based optimization, AI image generation (OpenAI / Stability / Replicate / Google Nano Banana / OpenRouter), chunked + resumable uploads, bulk delete/reassign, idempotent retries.

Capability discovery (F.7e)
- Per-site credential probe + adapters for WordPress / WooCommerce / Gitea, tier-fit unions granted ∪ roles, capability badge UI with HTMX partial re-check, install hint in every companion-unreachable error.

Companion plugin overhaul
- Renamed wordpress-plugin/airano-mcp-seo-bridge → wordpress-plugin/airano-mcp-bridge.
- Eight new endpoints: /capabilities, /bulk-meta, /export, /cache-purge, /transient-flush, /site-health, /audit-hook, /upload-and-attach.
- wp.org Plugin Check pass: i18n, WP_Filesystem, scheme allowlist on audit-hook URL.

Other
- Gitea ergonomics (F.17): batch files, tree, search, compare, releases, fork.
- Opportunistic bcrypt upgrade for legacy SHA-256 admin keys (F.8).
- n8n refactor: structured errors, capability probe, missing tools backfilled.
- Idempotency-Key dedup for AI media upload retries; WP client fast-fails on unreachable sites.

Docs
- README + CLAUDE.md drop the fixed "633 tools" claim. The total grows with each release; per-plugin approximations + dashboard-surfaced counts replace it.
- Tools/Tests badges removed in favour of "Plugins: 10".

Deployment
- PyPI mirror chain, optional BUILD_HTTP_PROXY, Alpine→Yandex apk mirror, Debian-slim Plan-B Dockerfile, mirror.gcr.io variant.

CI
- Black + Ruff clean on Python 3.12; pytest tests/ green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-25 16:25:58 +02:00
parent 788439e377
commit f203ca88de
140 changed files with 23802 additions and 2253 deletions

View File

@@ -0,0 +1,129 @@
"""F.5a.8.4 — resumable chunked upload status tool.
Verifies the new ``upload_media_chunked_status`` tool returns the
expected ``received_bytes`` / ``next_chunk`` for active sessions and
yields a ``NOT_FOUND`` error for unknown / finalised / aborted ones.
"""
from __future__ import annotations
import base64
import json
from pathlib import Path
import pytest
from core.database import Database
from core.upload_sessions import (
UploadSessionStore,
set_upload_session_store,
)
from plugins.wordpress.client import WordPressClient
from plugins.wordpress.handlers.media_chunked import (
MediaChunkedHandler,
get_tool_specifications,
)
@pytest.fixture
async def _db(tmp_path: Path):
db = Database(str(tmp_path / "status.db"))
await db.initialize()
yield db
await db.close()
@pytest.fixture
async def _store(tmp_path: Path, _db: Database):
s = UploadSessionStore(db=_db, spill_dir=tmp_path / "spill")
set_upload_session_store(s)
try:
yield s
finally:
set_upload_session_store(None)
@pytest.fixture
def _handler(_store: UploadSessionStore) -> MediaChunkedHandler:
client = WordPressClient(site_url="https://wp.example.com", username="u", app_password="p")
return MediaChunkedHandler(client, user_id="alice", store=_store)
class TestStatusToolSpec:
@pytest.mark.unit
def test_status_tool_is_registered(self):
specs = get_tool_specifications()
names = [s["name"] for s in specs]
assert "upload_media_chunked_status" in names
@pytest.mark.unit
def test_status_tool_is_read_scope(self):
specs = get_tool_specifications()
status = next(s for s in specs if s["name"] == "upload_media_chunked_status")
assert status["scope"] == "read"
assert status["schema"]["required"] == ["session_id"]
class TestStatusLookup:
@pytest.mark.asyncio
async def test_unknown_session_returns_no_session(self, _handler):
out = json.loads(await _handler.upload_media_chunked_status(session_id="does-not-exist"))
# NO_SESSION is the documented taxonomy code used by the rest of
# the chunked-session surface for exactly this case.
assert out["error_code"] == "NO_SESSION"
assert out["session_id"] == "does-not-exist"
@pytest.mark.asyncio
async def test_fresh_session_reports_zero_received(self, _handler):
started = json.loads(
await _handler.upload_media_chunked_start(filename="big.mp4", total_bytes=1_000_000)
)
sid = started["session_id"]
out = json.loads(await _handler.upload_media_chunked_status(session_id=sid))
assert out["session_id"] == sid
assert out["received_bytes"] == 0
assert out["next_chunk"] == 0
assert out["total_bytes"] == 1_000_000
@pytest.mark.asyncio
async def test_partial_session_reports_progress(self, _handler):
started = json.loads(
await _handler.upload_media_chunked_start(filename="big.mp4", total_bytes=100)
)
sid = started["session_id"]
chunk = base64.b64encode(b"A" * 40).decode()
await _handler.upload_media_chunked_chunk(session_id=sid, index=0, data_b64=chunk)
out = json.loads(await _handler.upload_media_chunked_status(session_id=sid))
assert out["received_bytes"] == 40
assert out["next_chunk"] == 1
# Still open for more chunks.
assert out["status"] == "open"
@pytest.mark.asyncio
async def test_resume_flow_via_status_then_chunk(self, _handler):
"""End-to-end resume: start → chunk → (simulate disconnect) →
status → chunk from next_chunk → progress should advance."""
started = json.loads(
await _handler.upload_media_chunked_start(filename="big.bin", total_bytes=60)
)
sid = started["session_id"]
first = base64.b64encode(b"x" * 20).decode()
await _handler.upload_media_chunked_chunk(session_id=sid, index=0, data_b64=first)
# Simulate client coming back from a disconnect.
status = json.loads(await _handler.upload_media_chunked_status(session_id=sid))
resume_idx = status["next_chunk"]
assert resume_idx == 1
second = base64.b64encode(b"y" * 25).decode()
progressed = json.loads(
await _handler.upload_media_chunked_chunk(
session_id=sid, index=resume_idx, data_b64=second
)
)
assert progressed["received_bytes"] == 45
assert progressed["next_chunk"] == 2