Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ GenieData/
.kilocode/
.worktrees/

.astrbot_sdk_testing/
dashboard/bun.lock
11 changes: 11 additions & 0 deletions astrbot-sdk/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
AstrBot SDK repository notice
=============================

This repository does not currently publish a standalone open-source license text.

This file exists so the source repository and its `vendor/` subtree snapshot carry
the same notice instead of silently omitting licensing information.

Unless the maintainers publish different licensing terms, do not assume this
repository grants redistribution or modification rights beyond applicable law and
explicit permission from the maintainers.
14 changes: 14 additions & 0 deletions astrbot-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# AstrBot SDK Vendor Snapshot

This directory is the minimized subtree payload consumed by the AstrBot main
repository.

- `src/astrbot_sdk/` keeps the runtime SDK package plus the minimal testing
helpers that AstrBot and SDK-generated templates still treat as part of the
vendored contract
- agent skill templates and embedded markdown reference files are excluded
- root project-note templates for `astr init` stay vendored because the CLI
still generates `AGENTS.md` / `CLAUDE.md` by default
- `pyproject.toml` keeps the src-layout package discovery but drops dev/test-only metadata
- `VENDORED.md` describes the vendoring contract
- tests, docs, CI files, and other source-repo-only content stay outside this directory
22 changes: 22 additions & 0 deletions astrbot-sdk/VENDORED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Vendored Snapshot Notes

This directory is a minimized snapshot for the AstrBot main repository to import
via `git subtree`.

- The source of truth is this `astrbot-sdk` repository.
- `vendor/src/astrbot_sdk/` is synchronized from `src/astrbot_sdk/`.
- Vendored snapshots keep the runtime SDK plus the minimal testing helpers
(`testing.py`, `_testing_support.py`, `_internal/testing_support.py`) because
AstrBot and SDK-generated test templates still depend on them.
- Vendored snapshots retain the default `AGENTS.md` / `CLAUDE.md` project-note
templates and the minimal `astrbot-plugin-dev` skill scaffold used by
`astr init --agents`, but still exclude larger markdown reference assets that
are not needed by the subtree consumer.
- `vendor/pyproject.toml` keeps src-layout package discovery, but strips
test/dev-only sections so the subtree stays runtime-focused.
- Do not edit vendored files directly inside the AstrBot main repository.
- Tests and broader documentation remain only in the SDK source repository.
The vendored snapshot only keeps the runtime-facing templates required by
`astr init`.
- If the vendored copy needs changes, update the SDK source repository first and
regenerate the `vendor/` snapshot.
50 changes: 50 additions & 0 deletions astrbot-sdk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "astrbot-sdk"
version = "0.1.0"
description = "AstrBot SDK with s5r runtime, worker protocol, and plugin tooling"
readme = "README.md"
requires-python = ">=3.12"
classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"aiohttp>=3.13.2",
"anthropic>=0.72.1",
"certifi>=2025.10.5",
"click>=8.3.0",
"docstring-parser>=0.17.0",
"google-genai>=1.50.0",
"loguru>=0.7.3",
"msgpack>=1.1.1",
"openai>=2.7.2",
"pydantic>=2.12.3",
"pyyaml>=6.0.3",
"uv>=0.9.17",
]

[project.scripts]
astr = "astrbot_sdk.cli:cli"

[tool.hatch.build.targets.wheel]
packages = ["src/astrbot_sdk"]
exclude = ["/src/astrbot_sdk/AGENTS.md"]

[tool.hatch.build.targets.sdist]
include = [
"/src",
"/README.md",
"/LICENSE",
]

# ============================================================
# Optional Dependencies
# ============================================================
213 changes: 213 additions & 0 deletions astrbot-sdk/src/astrbot_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
"""AstrBot SDK 的顶层公共 API。

这里仅重新导出 astrbot-sdk 推荐直接导入的稳定入口。

新插件应直接使用此模块的导出:
from astrbot_sdk import Star, Context, MessageEvent
from astrbot_sdk.decorators import on_command, on_message

迁移期适配入口位于独立模块;此处只暴露 astrbot-sdk 原生主入口。
"""

from .clients.managers import (
ConversationCreateParams,
ConversationManagerClient,
ConversationRecord,
ConversationUpdateParams,
KnowledgeBaseCreateParams,
KnowledgeBaseDocumentRecord,
KnowledgeBaseDocumentUploadParams,
KnowledgeBaseManagerClient,
KnowledgeBaseRecord,
KnowledgeBaseRetrieveResult,
KnowledgeBaseRetrieveResultItem,
KnowledgeBaseUpdateParams,
MessageHistoryManagerClient,
MessageHistoryPage,
MessageHistoryRecord,
MessageHistorySender,
PersonaCreateParams,
PersonaManagerClient,
PersonaRecord,
PersonaUpdateParams,
)
from .clients.metadata import PluginMetadata, StarMetadata
from .clients.permission import (
PermissionCheckResult,
PermissionClient,
PermissionManagerClient,
)
from .clients.platform import PlatformError, PlatformStats, PlatformStatus
from .clients.provider import (
ManagedProviderRecord,
ProviderChangeEvent,
ProviderManagerClient,
)
from .clients.session import SessionPluginManager, SessionServiceManager
from .commands import CommandGroup, command_group, print_cmd_tree
from .context import Context
from .conversation import (
ConversationClosed,
ConversationReplaced,
ConversationSession,
ConversationState,
)
from .decorators import (
admin_only,
background_task,
conversation_command,
cooldown,
group_only,
http_api,
message_types,
on_command,
on_event,
on_message,
on_provider_change,
on_schedule,
platforms,
priority,
private_only,
provide_capability,
rate_limit,
register_skill,
require_admin,
require_permission,
validate_config,
)
from .errors import AstrBotError
from .events import MessageEvent
from .filters import (
CustomFilter,
MessageTypeFilter,
PlatformFilter,
all_of,
any_of,
custom_filter,
)
from .message.components import (
At,
AtAll,
BaseMessageComponent,
File,
Forward,
Image,
MediaHelper,
Plain,
Poke,
Record,
Reply,
UnknownComponent,
Video,
)
from .message.result import (
EventResultType,
MessageBuilder,
MessageChain,
MessageEventResult,
)
from .message.session import MessageSession
from .plugin_kv import PluginKVStoreMixin
from .schedule import ScheduleContext
from .session_waiter import SessionController, session_waiter
from .star import Star
from .star_tools import StarTools
from .types import GreedyStr

__all__ = [
"AstrBotError",
"At",
"AtAll",
"BaseMessageComponent",
"CommandGroup",
"ConversationClosed",
"ConversationCreateParams",
"ConversationManagerClient",
"ConversationReplaced",
"ConversationRecord",
"ConversationSession",
"ConversationState",
"ConversationUpdateParams",
"Context",
"CustomFilter",
"EventResultType",
"File",
"Forward",
"GreedyStr",
"Image",
"KnowledgeBaseCreateParams",
"KnowledgeBaseDocumentRecord",
"KnowledgeBaseDocumentUploadParams",
"KnowledgeBaseManagerClient",
"KnowledgeBaseRecord",
"KnowledgeBaseRetrieveResult",
"KnowledgeBaseRetrieveResultItem",
"KnowledgeBaseUpdateParams",
"ManagedProviderRecord",
"MediaHelper",
"MessageHistoryManagerClient",
"MessageHistoryPage",
"MessageHistoryRecord",
"MessageHistorySender",
"MessageEvent",
"MessageEventResult",
"MessageChain",
"MessageBuilder",
"MessageSession",
"MessageTypeFilter",
"Plain",
"PluginKVStoreMixin",
"PluginMetadata",
"PermissionCheckResult",
"PermissionClient",
"PermissionManagerClient",
"PlatformFilter",
"PlatformError",
"PlatformStats",
"PlatformStatus",
"Poke",
"PersonaCreateParams",
"PersonaManagerClient",
"PersonaRecord",
"PersonaUpdateParams",
"ProviderChangeEvent",
"ProviderManagerClient",
"Record",
"Reply",
"ScheduleContext",
"SessionPluginManager",
"SessionServiceManager",
"SessionController",
"Star",
"StarMetadata",
"StarTools",
"UnknownComponent",
"Video",
"admin_only",
"all_of",
"any_of",
"background_task",
"cooldown",
"conversation_command",
"command_group",
"custom_filter",
"group_only",
"http_api",
"message_types",
"on_command",
"on_event",
"on_message",
"on_provider_change",
"on_schedule",
"platforms",
"print_cmd_tree",
"priority",
"provide_capability",
"private_only",
"rate_limit",
"require_admin",
"require_permission",
"register_skill",
"session_waiter",
"validate_config",
]
11 changes: 11 additions & 0 deletions astrbot-sdk/src/astrbot_sdk/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""`python -m astrbot_sdk` 的 CLI 入口。"""

from .cli import cli


def main() -> None:
cli()


if __name__ == "__main__":
main()
17 changes: 17 additions & 0 deletions astrbot-sdk/src/astrbot_sdk/_command_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from ._internal.command_model import (
COMMAND_MODEL_DOCS_URL,
CommandModelParseResult,
ResolvedCommandModelParam,
format_command_model_help,
parse_command_model_remainder,
resolve_command_model_param,
)

__all__ = [
"COMMAND_MODEL_DOCS_URL",
"CommandModelParseResult",
"ResolvedCommandModelParam",
"format_command_model_help",
"parse_command_model_remainder",
"resolve_command_model_param",
]
7 changes: 7 additions & 0 deletions astrbot-sdk/src/astrbot_sdk/_internal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Internal implementation modules for astrbot_sdk.

This package groups private helpers that are not part of the public SDK API.
Imports outside the SDK should avoid depending on these modules directly.
"""

__all__: list[str] = []
Loading
Loading