agent-zero/plugins/_chat_naming/commands/rename_command.py
frdel bebe6826cf
Some checks failed
Build And Publish Docker Images / plan (push) Has been cancelled
Build And Publish Docker Images / build (push) Has been cancelled
Improve WebUI bundling, manifest and stop command
Introduce a WebUI extension manifest and rewrite the asset bundler/server to support caller-supplied entry sets, extension-injected entries, and negotiated gzip. Key changes: add get_webui_extension_manifest() to helpers/extension, refactor Stop logic into stop_context() and reuse it from the connector `/stop` command, and add a new `/rename` slash command for chat naming. ui_bundler now accepts entry_urls, includes enabled extension entry files, raises the embedded text file size limit to 512 KiB, computes per-entry-set cache keys, and returns a bundle version based on the bundle signature. ui_server applies Starlette GZip middleware, adds routes (/, /index.html, /ui/index, /safe), serves splash/safe documents, injects the serialized webui_extension_manifest into the rendered index, and streamlines the /ui/asset-bundle endpoint with ETag and gzip handling. Also add multiple WebUI assets and fonts, new/updated plugin command YAML and Python command handlers, and corresponding tests covering bundling, commands, chat naming, and WebUI behaviors. Documentation (.dox.md) updated to reflect the new runtime contracts and guidance.
2026-07-29 19:49:07 +02:00

29 lines
909 B
Python

from __future__ import annotations
from typing import Any
from plugins._chat_naming.helpers import naming
async def run(payload: dict[str, Any]) -> dict[str, Any]:
invocation = payload.get("invocation") or {}
raw_name = str(invocation.get("raw_arguments") or "").strip()
agent = (payload.get("context") or {}).get("agent")
if not agent:
return _toast("Open or create a chat context first.", level="error")
if not raw_name:
return _toast("Usage: /rename <new name|auto>", level="error")
if raw_name.casefold() == "auto":
raw_name = await naming.generate_name(agent)
name = naming.save_context_name(agent, raw_name)
return _toast(f'Chat renamed to "{name}".')
def _toast(message: str, *, level: str = "success") -> dict[str, Any]:
return {
"text": "",
"effects": [{"type": "toast", "message": message, "level": level}],
}