This commit is contained in:
2026-07-19 18:57:43 +02:00
parent 48bb6c2ec2
commit c53e2a3319
179 changed files with 9307 additions and 897 deletions
@@ -61,7 +61,7 @@ AI_CORRECTION_ACTIONS: tuple[Action, ...] = (
),
arg(
"prompt",
"The correction instruction (max 2000 chars). Omit to keep the current one.",
"The correction instruction (max 20000 chars). Omit to keep the current one.",
),
),
),
@@ -64,7 +64,7 @@ AI_MODIFIER_ACTIONS: tuple[Action, ...] = (
),
arg(
"prompt",
"The modifier instruction (max 2000 chars). Omit to keep the current one.",
"The modifier instruction (max 20000 chars). Omit to keep the current one.",
),
),
),
@@ -28,7 +28,7 @@ COMMENTS_ACTIONS: tuple[Action, ...] = (
summary="Edit the body of one of your own comments",
params=(
path("comment_uid", "Uid of the comment."),
body("content", "New comment body, 3-1000 characters.", required=True),
body("content", "New comment body, 3-125000 characters.", required=True),
),
),
Action(
@@ -116,6 +116,7 @@ _DEVII_MECHANIC_EVENTS = {
"email_mark": "email.message.flag",
"email_set_flags": "email.message.flag",
"telegram_send": "telegram.send",
"interactions_set": "profile.interactions",
}
_DEVII_CONTAINER_EVENTS = {
@@ -268,6 +269,7 @@ class Dispatcher:
owner_id: str = "",
virtual_tools: Any = None,
behavior: Any = None,
interaction: Any = None,
) -> None:
self._actions = catalog.by_name()
self._client = client
@@ -308,6 +310,7 @@ class Dispatcher:
self._telegram = TelegramSendController(owner_kind, owner_id)
self._virtual_tools = virtual_tools
self._behavior = behavior
self._interaction = interaction
self._read_files: set[tuple[str, str]] = set()
@staticmethod
@@ -500,6 +503,15 @@ class Dispatcher:
)
return await self._behavior.dispatch(action.name, arguments)
if action.handler == "interaction":
if self._interaction is None:
return error_result(
ToolInputError(
"Interactive prompts are not available in this context."
)
)
return await self._interaction.dispatch(action.name, arguments)
if action.handler == "virtual_tool":
if self._virtual_tools is None:
return error_result(
+20 -7
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
from dataclasses import dataclass, field
from functools import lru_cache
from typing import Any, Literal
ParamLocation = Literal["path", "query", "body", "file"]
@@ -49,6 +50,7 @@ class Action:
"virtual_tool",
"email",
"telegram",
"interaction",
] = "http"
freeform_body: bool = False
ajax: bool = False
@@ -117,16 +119,27 @@ class Catalog:
def tool_schemas(self) -> list[dict[str, Any]]:
return [action.tool_schema() for action in self.actions]
@lru_cache(maxsize=16)
def _schemas_for(
self,
authenticated: bool,
is_admin: bool,
is_primary_admin: bool,
) -> tuple[dict[str, Any], ...]:
return tuple(
action.tool_schema()
for action in self.actions
if (authenticated or not action.requires_auth)
and (is_admin or not action.requires_admin)
and (is_primary_admin or not action.requires_primary_admin)
)
def tool_schemas_for(
self,
authenticated: bool,
is_admin: bool = False,
is_primary_admin: bool = False,
) -> list[dict[str, Any]]:
return [
action.tool_schema()
for action in self.actions
if (authenticated or not action.requires_auth)
and (is_admin or not action.requires_admin)
and (is_primary_admin or not action.requires_primary_admin)
]
return list(
self._schemas_for(bool(authenticated), bool(is_admin), bool(is_primary_admin))
)