feat(plugins): consolidate official plugins with independent releases (LANG-180) (#2797)

Co-authored-by: multica-agent <[email protected]>
This commit is contained in:
RockChinQ
2026-10-28 17:32:24 +08:00
committed by GitHub
co-authored by multica-agent
parent d099033d79
commit 3a77306c3c
1144 changed files with 142049 additions and 130 deletions
@@ -0,0 +1 @@
# Components package
@@ -0,0 +1 @@
# Commands package
@@ -0,0 +1,87 @@
# Auto generated by LangBot Plugin SDK.
# Please refer to https://langbot.app/docs/en/plugin/dev/tutor.html for more details.
from __future__ import annotations
from typing import AsyncGenerator
from langbot_plugin.api.definition.components.command.command import Command
from langbot_plugin.api.entities.builtin.command.context import ExecuteContext, CommandReturn
class DscheCommand(Command):
"""
Command to delete a scheduled notification by index.
Usage: !dsche <index>
Example: !dsche 1
"""
def __init__(self):
super().__init__()
@self.subcommand(
name="i",
help="Delete a scheduled notification by index",
usage="dsche i <index>",
aliases=["d"],
)
async def delete_notification(self, context: ExecuteContext) -> AsyncGenerator[CommandReturn, None]:
"""Delete a scheduled notification by index"""
# Get language setting
config = self.plugin.get_config()
language = config.get("language", "zh_Hans")
# Check if index parameter is provided
if len(context.crt_params) == 0:
if language == "en_US":
reply = '[Notify] Command format: !dsche <index>, e.g. !dsche 1. Please use !sche to view scheduled notifications first.'
else:
reply = '[Notify] 命令格式: !dsche <index>,例如 !dsche 1。请先使用 !sche 查看计划中的提醒'
yield CommandReturn(text=reply)
return
try:
index = int(context.crt_params[0]) - 1
except ValueError:
if language == "en_US":
reply = '[Notify] Invalid index. Please provide a number.'
else:
reply = '[Notify] 无效的索引,请提供数字'
yield CommandReturn(text=reply)
return
# Get the full session identity from the trusted session: a target id
# alone is shared by other bots and by the person/group namespaces.
session = context.session
session_key = self.plugin.session_key(
session.bot_uuid, session.launcher_type.value, str(session.launcher_id)
)
# Get scheduled events from plugin
scheduled_events = await self.plugin.get_scheduled_events(session_key)
if index < 0 or index >= len(scheduled_events):
if language == "en_US":
reply = '[Notify] Index out of range'
else:
reply = '[Notify] 索引超出范围'
yield CommandReturn(text=reply)
return
event = scheduled_events[index]
# Delete the event; the plugin re-checks that it belongs to this session.
if not await self.plugin.delete_scheduled_event(event, session_key):
if language == "en_US":
reply = '[Notify] Index out of range'
else:
reply = '[Notify] 索引超出范围'
yield CommandReturn(text=reply)
return
if language == "en_US":
reply = f'[Notify] Deleted notification: {event["time"]} {event["message"]}'
else:
reply = f'[Notify] 已删除提醒:{event["time"]} {event["message"]}'
yield CommandReturn(text=reply)
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Command
metadata:
name: dsche
label:
en_US: Delete Scheduled Notification
zh_Hans: 删除计划的通知
description:
en_US: 'Delete a scheduled notification by index'
zh_Hans: '通过索引删除计划的通知'
spec:
execution:
python:
path: dsche.py
attr: DscheCommand
@@ -0,0 +1,59 @@
# Auto generated by LangBot Plugin SDK.
# Please refer to https://langbot.app/docs/en/plugin/dev/tutor.html for more details.
from __future__ import annotations
from typing import AsyncGenerator
from langbot_plugin.api.definition.components.command.command import Command
from langbot_plugin.api.entities.builtin.command.context import ExecuteContext, CommandReturn
class ScheCommand(Command):
"""
Command to list all scheduled notifications for the current session.
Usage: !sche
"""
def __init__(self):
super().__init__()
@self.subcommand(
name="",
help="List all scheduled notifications",
usage="sche",
aliases=["s"],
)
async def list_notifications(self, context: ExecuteContext) -> AsyncGenerator[CommandReturn, None]:
"""List all scheduled notifications for current session"""
# Get language setting
config = self.plugin.get_config()
language = config.get("language", "zh_Hans")
# Get the full session identity from the trusted session: a target id
# alone is shared by other bots and by the person/group namespaces.
session = context.session
session_key = self.plugin.session_key(
session.bot_uuid, session.launcher_type.value, str(session.launcher_id)
)
# Get scheduled events from plugin
scheduled_events = await self.plugin.get_scheduled_events(session_key)
if not scheduled_events or len(scheduled_events) == 0:
if language == "en_US":
reply = '[Notify] No scheduled notifications'
else:
reply = '[Notify] 没有计划中的提醒'
else:
if language == "en_US":
reply = '[Notify] Scheduled notifications:\n'
else:
reply = '[Notify] 计划中的提醒:\n'
index = 1
for event in scheduled_events:
reply += f'#{index} {event["time"]}:{event["message"]}\n'
index += 1
yield CommandReturn(text=reply)
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Command
metadata:
name: sche
label:
en_US: List Scheduled Notifications
zh_Hans: 列出计划的通知
description:
en_US: 'List all scheduled notifications for the current session'
zh_Hans: '列出当前会话的所有计划通知'
spec:
execution:
python:
path: sche.py
attr: ScheCommand
@@ -0,0 +1 @@
# Tools package
@@ -0,0 +1,34 @@
# Auto generated by LangBot Plugin SDK.
# Please refer to https://langbot.app/docs/en/plugin/dev/tutor.html for more details.
from __future__ import annotations
from typing import Any
import datetime
from langbot_plugin.api.definition.components.tool.tool import Tool
from langbot_plugin.api.entities.builtin.provider import session as provider_session
class GetCurrentTimeStr(Tool):
"""
Get the current time as a string.
This function should be called:
- When the user directly asks for the current time
- Before scheduling any notification to ensure accurate time calculation
"""
async def call(self, params: dict[str, Any], session: provider_session.Session, query_id: int) -> str:
"""
Get current time string in format: %Y-%m-%d %H:%M:%S
Args:
params: Tool parameters (not used)
session: Current session information
query_id: Query ID
Returns:
str: Current time string
"""
# Return current time
current_time = datetime.datetime.now()
return current_time.strftime("%Y-%m-%d %H:%M:%S")
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Tool
metadata:
name: get_current_time_str
label:
en_US: Get Current Time
zh_Hans: 获取当前时间
description:
en_US: 'Get the current time as a string'
zh_Hans: '获取当前时间的字符串'
spec:
parameters:
type: object
properties: {}
required: []
llm_prompt: 'Get the current time. Call this function before scheduling any notification to ensure you have the latest current time.'
execution:
python:
path: get_current_time_str.py
attr: GetCurrentTimeStr
@@ -0,0 +1,113 @@
# Auto generated by LangBot Plugin SDK.
# Please refer to https://langbot.app/docs/en/plugin/dev/tutor.html for more details.
from __future__ import annotations
from typing import Any
import time
import datetime
from langbot_plugin.api.definition.components.tool.tool import Tool
from langbot_plugin.api.entities.builtin.provider import session as provider_session
class ScheduleNotify(Tool):
"""
Schedule a notification at a specific time.
This function should be called after getting the current time using get_current_time_str.
The program checks for notifications every minute, so precision is to the minute level.
"""
def _get_message(self, key: str, **kwargs) -> str:
"""
Get localized message based on plugin language setting.
Args:
key: Message key
**kwargs: Format arguments
Returns:
Formatted message string
"""
config = self.plugin.get_config()
language = config.get("language", "zh_Hans")
messages = {
"zh_Hans": {
"time_passed": "计划时间已经过去",
"success": "计划成功:\n将在{time}提醒您:{message}",
"no_session": "错误:无法获取会话信息,请先发送一条消息",
"too_many": "错误:本会话的计划提醒数量已达上限,请先删除一些提醒",
},
"en_US": {
"time_passed": "The scheduled time has already passed",
"success": "Scheduled successfully:\nWill remind you at {time}: {message}",
"no_session": "Error: Cannot get session info, please send a message first",
"too_many": "Error: This installation has reached its scheduled reminder limit; delete some reminders first",
}
}
template = messages.get(language, messages["zh_Hans"]).get(key, "")
return template.format(**kwargs) if kwargs else template
async def call(self, params: dict[str, Any], session: provider_session.Session, query_id: int) -> str:
"""
Schedule a notification.
Args:
params: {
"time_str": Time string in format "%Y-%m-%d %H:%M:%S",
"message": Notification message content
}
session: Current session information
query_id: Query ID
Returns:
str: Success message or error message
"""
time_str = params.get("time_str")
message = params.get("message")
if not time_str or not message:
return "Error: time_str and message are required"
try:
# Convert time string to timestamp
time_stamp = time.mktime(time.strptime(time_str, "%Y-%m-%d %H:%M:%S"))
# Get current timestamp
current_time_stamp = time.time()
# If scheduled time has already passed, return error
if time_stamp <= current_time_stamp:
return self._get_message("time_passed")
real_date = datetime.datetime.fromtimestamp(time_stamp)
# Get session info. The bot uuid is part of the session identity, so
# it is taken from the trusted session (falling back to its active
# conversation) and stored with the target type and id.
bot_uuid = session.bot_uuid or (
session.using_conversation.bot_uuid if session.using_conversation else None
)
target_type = session.launcher_type.value
target_id = str(session.launcher_id)
if not bot_uuid:
return self._get_message("no_session")
# Add to plugin's scheduled events with session info
queued = await self.plugin.add_scheduled_event(
time=real_date,
message=message,
bot_uuid=bot_uuid,
target_type=target_type,
target_id=target_id
)
if not queued:
return self._get_message("too_many")
return self._get_message("success", time=real_date, message=message)
except ValueError as e:
return f"Error: Invalid time format. Expected '%Y-%m-%d %H:%M:%S', got '{time_str}'"
except Exception as e:
return f"Error: {str(e)}"
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Tool
metadata:
name: schedule_notify
label:
en_US: Schedule Notification
zh_Hans: 计划通知
description:
en_US: 'Schedule a notification at a specific time'
zh_Hans: '在指定时间计划一个通知提醒'
spec:
parameters:
type: object
properties:
time_str:
type: string
description: 'Time string in format "%Y-%m-%d %H:%M:%S", e.g. "2024-12-25 18:30:00". MUST call get_current_time_str first to get the current time before scheduling.'
message:
type: string
description: 'The notification message content to remind the user'
required:
- time_str
- message
llm_prompt: 'Schedule a notification at a specific time. IMPORTANT: You MUST call get_current_time_str first to get the latest current time before calling this function.'
execution:
python:
path: schedule_notify.py
attr: ScheduleNotify