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,51 @@
# 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, AsyncGenerator
from langbot_plugin.api.definition.components.command.command import Command, Subcommand
from langbot_plugin.api.entities.builtin.command.context import ExecuteContext, CommandReturn
class Info(Command):
def __init__(self):
super().__init__()
@self.subcommand(
name="", # empty string means the root command
help="Show information of the query", # command help message
usage="info", # command usage example, displayed in the command help message
aliases=["i"], # command aliases
)
async def send(self, context: ExecuteContext) -> AsyncGenerator[CommandReturn, None]:
reply_text = f"Query ID: {context.query_id}\n"
reply_text += f"command: {context.command}\n"
reply_text += f"command_text: {context.command_text}\n"
reply_text += f"params: {context.params}\n"
reply_text += f"crt_params: {context.crt_params}\n"
reply_text += f"privilege: {context.privilege}\n"
reply_text += f"session: {context.session.launcher_type.value}_{context.session.launcher_id}\n"
print(f"发起者ID{context.session.launcher_id}发送者ID{context.session.sender_id}消息类型{context.session.launcher_type}")
yield CommandReturn(
text=reply_text,
)
@self.subcommand(
name="field",
help="Show information of the field",
usage="info field",
aliases=["f"],
)
async def field(self, context: ExecuteContext) -> AsyncGenerator[CommandReturn, None]:
field_name = context.crt_params[0]
field_value = getattr(context, field_name)
yield CommandReturn(
text=f"{field_name}: {field_value}",
)
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Command
metadata:
name: info
label:
en_US: Info
zh_Hans: Info
description:
en_US: 'Show information of the query'
zh_Hans: 'Show information of the query'
spec:
execution:
python:
path: info.py
attr: Info
@@ -0,0 +1,90 @@
# 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
import base64
from langbot_plugin.api.definition.components.common.event_listener import EventListener
from langbot_plugin.api.entities import events, context
from langbot_plugin.api.entities.builtin.platform import message as platform_message
from langbot_plugin.api.entities.builtin.provider import message as provider_message
class DefaultEventListener(EventListener):
def __init__(self):
super().__init__()
@self.handler(events.GroupNormalMessageReceived)
@self.handler(events.PersonNormalMessageReceived)
async def handler(event_context: context.EventContext):
print("Hello LangBot Plugin!")
event_context.event.user_message_alter = provider_message.ContentElement.from_text("Hello from LangBot Plugin!")
# event_context.prevent_default()
# # event_context.event.reply_message_chain = platform_message.MessageChain([
# # platform_message.Plain(text=f"Hello from LangBot Plugin!"),
# # ])
# # Simple text response
# # await event_context.reply(
# # platform_message.MessageChain([
# # platform_message.Plain(text=f"Hello from LangBot Plugin! 1"),
# # ])
# # )
# # raw_message_event = event_context.event.message_event
# # print(raw_message_event)
# with open("assets/image.png", "rb") as f:
# image_data = f.read()
# image_base64 = base64.b64encode(image_data).decode("utf-8")
# # image = platform_message.Image(base64=f"data:image/png;base64,{image_base64}")
# image = platform_message.Image(url="https://langbot.app/docs/langbot-logo.png")
# with open("assets/rec.wav", "rb") as f:
# voice_data = f.read()
# voice_base64 = base64.b64encode(voice_data).decode("utf-8")
# voice = platform_message.Voice(base64=f"data:audio/wav;base64,{voice_base64}")
# # Comprehensive test message with various components
# await event_context.reply(
# platform_message.MessageChain([
# platform_message.Plain(text=f"Hello\n"),
# platform_message.Plain(text="This is a test message, containing various component types:\n"),
# platform_message.Plain(text="1. Text message "),
# # platform_message.At(target=event_context.event.sender_id, display="@you"),
# platform_message.Plain(text="\n2. At someone\n"),
# platform_message.Plain(text="3. Image (example)\n"),
# image,
# platform_message.Plain(text="\n4. Voice (example)\n"),
# voice,
# platform_message.Plain(text="\n5. File (example)\n"),
# platform_message.Plain(text="\n✅ All components tested successfully!"),
# ])
# )
# await event_context.reply(
# platform_message.MessageChain([
# platform_message.File(
# name=".mcp.json",
# size=1024000,
# url="https://raw.githubusercontent.com/langbot-app/LangBot/refs/heads/master/.mcp.json"
# ),
# ])
# )
# # Test message with Quote component
# await event_context.reply(
# platform_message.MessageChain([
# platform_message.Quote(
# id=event_context.event.message_chain.message_id,
# sender_id=event_context.event.sender_id,
# origin=[platform_message.Plain(text="Quote the original message")]
# ),
# platform_message.Plain(text="This is a quoted reply message"),
# ])
# )
@@ -0,0 +1,12 @@
apiVersion: v1
kind: EventListener
metadata:
name: default
label:
en_US: DefaultEventListener
zh_Hans: DefaultEventListener
spec:
execution:
python:
path: default.py
attr: DefaultEventListener
@@ -0,0 +1,56 @@
# 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
from langbot_plugin.api.definition.components.tool.tool import Tool
import httpx
# Constants
NWS_API_BASE = "https://api.weather.gov"
USER_AGENT = "weather-app/1.0"
async def make_nws_request(url: str) -> dict[str, Any] | None:
"""Make a request to the NWS API with proper error handling."""
headers = {
"User-Agent": USER_AGENT,
"Accept": "application/geo+json"
}
async with httpx.AsyncClient() as client:
try:
response = await client.get(url, headers=headers, timeout=30.0)
response.raise_for_status()
return response.json()
except Exception:
return None
def format_alert(feature: dict) -> str:
"""Format an alert feature into a readable string."""
props = feature["properties"]
return f"""
Event: {props.get('event', 'Unknown')}
Area: {props.get('areaDesc', 'Unknown')}
Severity: {props.get('severity', 'Unknown')}
Description: {props.get('description', 'No description available')}
Instructions: {props.get('instruction', 'No specific instructions provided')}
"""
class GetWeatherAlerts(Tool):
async def call(self, params: dict[str, Any]) -> dict[str, Any]:
"""Fill your tool code here"""
state = params.get("state", "CA")
url = f"{NWS_API_BASE}/alerts/active/area/{state}"
data = await make_nws_request(url)
if not data or "features" not in data:
return "Unable to fetch alerts or no alerts found."
if not data["features"]:
return "No active alerts for this state."
alerts = [format_alert(feature) for feature in data["features"]]
return "\n---\n".join(alerts)
@@ -0,0 +1,24 @@
apiVersion: v1 # 请勿修改
kind: Tool # 请勿修改
metadata:
name: get_weather_alerts # 工具名称,供 LLM 识别
label:
en_US: GetWeatherAlerts # 工具显示名称,用于显示在 LangBot 的 UI 上,支持多语言
zh_Hans: GetWeatherAlerts
description:
en_US: 'Get weather alerts for a US state.' # 工具描述,用于显示在 LangBot 的 UI 上,支持多语言。可选
zh_Hans: '获取美国某个州的天气预警'
spec:
parameters:
type: object # 请勿修改
properties: # 请勿修改,在此处添加参数
state:
type: string
description: 'Two-letter US state code (e.g. CA, NY)'
required: # 在此添加必填参数说明
- state
llm_prompt: 'Get weather alerts for a US state.' # 工具提示词,供 LLM 判断是否调用该工具
execution:
python:
path: get_weather_alerts.py # 工具处理程序,请勿修改
attr: GetWeatherAlerts # 工具处理程序的类名,与 get_weather_alerts.py 中的类名一致