langbot-plugin 0.3.7__tar.gz → 0.3.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/PKG-INFO +1 -1
- langbot_plugin-0.3.9/docs/PluginPages.md +465 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/pyproject.toml +2 -2
- langbot_plugin-0.3.9/src/langbot_plugin/api/definition/components/page/__init__.py +70 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/proxies/langbot_api.py +3 -1
- langbot_plugin-0.3.9/src/langbot_plugin/assets/langbot-page-sdk.js +271 -0
- langbot_plugin-0.3.9/src/langbot_plugin/assets/templates/components/pages/{page_name}.html.example +31 -0
- langbot_plugin-0.3.9/src/langbot_plugin/assets/templates/components/pages/{page_name}.yaml.example +12 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/commands/buildplugin.py +23 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/commands/gencomponent.py +9 -7
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/commands/runplugin.py +7 -9
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/gen/renderer.py +49 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/run/controller.py +2 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/run/handler.py +73 -4
- langbot_plugin-0.3.9/src/langbot_plugin/cli/utils/page_components.py +56 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/entities/io/actions/enums.py +5 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/handlers/control.py +19 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/handlers/plugin.py +21 -2
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/plugin/mgr.py +35 -15
- langbot_plugin-0.3.9/src/langbot_plugin/version.py +1 -0
- langbot_plugin-0.3.7/src/langbot_plugin/version.py +0 -1
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/.github/workflows/publish-pypi.yaml +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/.gitignore +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/.python-version +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/AGENTS.md +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/CLAUDE.md +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/LICENSE +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/README.md +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/data/.env.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/docs/Message.md +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/docs/communication/apis/lb2rt.md +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/docs/communication/runtime_plugin.md +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/docs/dependency-management.md +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/docs/langbot-plugin-social.png +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/abstract/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/abstract/platform/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/abstract/platform/adapter.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/abstract/platform/event_logger.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/base.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/command/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/command/command.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/common/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/common/event_listener.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/knowledge_engine/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/knowledge_engine/engine.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/manifest.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/parser/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/parser/parser.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/tool/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/components/tool/tool.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/definition/plugin.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/command/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/command/context.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/command/errors.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/pipeline/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/pipeline/query.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/platform/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/platform/entities.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/platform/events.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/platform/logger.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/platform/message.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/provider/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/provider/message.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/provider/prompt.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/provider/session.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/rag/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/rag/context.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/rag/enums.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/rag/errors.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/rag/models.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/resource/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/builtin/resource/tool.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/context.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/entities/events.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/proxies/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/proxies/base.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/proxies/event_context.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/proxies/execute_context.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/api/proxies/query_based_api.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/.env.example.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/.gitignore.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/.vscode/launch.json.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/README.md.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/assets/icon.svg.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/commands/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/commands/{cmd_name}.py.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/commands/{cmd_name}.yaml.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/event_listener/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/event_listener/default.py.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/event_listener/default.yaml.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/knowledge_engine/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/knowledge_engine/{knowledge_engine_name}.py.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/knowledge_engine/{knowledge_engine_name}.yaml.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/parser/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/parser/{parser_name}.py.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/parser/{parser_name}.yaml.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/tools/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/tools/{tool_name}.py.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/components/tools/{tool_name}.yaml.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/main.py.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/manifest.yaml.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/assets/templates/requirements.txt.example +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/__main__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/commands/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/commands/initplugin.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/commands/login.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/commands/logout.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/commands/publish.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/gen/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/i18n.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/locales/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/locales/en_US.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/locales/es_ES.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/locales/ja_JP.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/locales/th_TH.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/locales/vi_VN.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/locales/zh_Hans.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/locales/zh_Hant.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/run/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/run/hotreload.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/utils/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/utils/cloudsv.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/cli/utils/form.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/entities/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/entities/io/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/entities/io/actions/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/entities/io/errors.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/entities/io/req.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/entities/io/resp.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/entities/marketplace.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/LICENSE +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/README.md +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/app.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/context.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/helper/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/helper/marketplace.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/helper/pkgmgr.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/connection.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/connections/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/connections/stdio.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/connections/ws.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/controller.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/controllers/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/controllers/stdio/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/controllers/stdio/client.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/controllers/stdio/server.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/controllers/ws/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/controllers/ws/client.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/controllers/ws/server.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/handler.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/io/handlers/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/plugin/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/plugin/container.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/runtime/settings.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/utils/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/utils/discover/__init__.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/utils/discover/engine.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/utils/importutil.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/utils/log.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/src/langbot_plugin/utils/platform.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/tests/api/entities/test_events.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/tests/test_log.py +0 -0
- {langbot_plugin-0.3.7 → langbot_plugin-0.3.9}/tests/test_message.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langbot-plugin
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.9
|
|
4
4
|
Summary: This package contains the SDK, CLI for building plugins for LangBot, plus the runtime for hosting LangBot plugins
|
|
5
5
|
Project-URL: Homepage, https://langbot.app
|
|
6
6
|
Project-URL: Repository, https://github.com/langbot-app/langbot-plugin-sdk
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
# 插件页面 (Plugin Pages)
|
|
2
|
+
|
|
3
|
+
插件可以注册自定义 HTML 页面,嵌入到 LangBot WebUI 的侧边栏中。页面运行在 iframe 内,通过 `postMessage` 与宿主通信,并可调用插件后端 API。
|
|
4
|
+
|
|
5
|
+
## 目录
|
|
6
|
+
|
|
7
|
+
- [注册页面](#注册页面)
|
|
8
|
+
- [页面 HTML 开发](#页面-html-开发)
|
|
9
|
+
- [JS SDK 参考](#js-sdk-参考)
|
|
10
|
+
- [后端 API 处理](#后端-api-处理)
|
|
11
|
+
- [通信协议](#通信协议)
|
|
12
|
+
- [暗黑模式适配](#暗黑模式适配)
|
|
13
|
+
- [i18n 国际化](#i18n-国际化)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 注册页面
|
|
18
|
+
|
|
19
|
+
页面作为组件注册在 `components/pages/` 目录下,与 EventListener、Tool 等组件遵循相同的规范。
|
|
20
|
+
|
|
21
|
+
### manifest.yaml 配置
|
|
22
|
+
|
|
23
|
+
在 `spec.components` 中添加 `Page` 组件类型:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
spec:
|
|
27
|
+
config: []
|
|
28
|
+
components:
|
|
29
|
+
EventListener:
|
|
30
|
+
fromDirs:
|
|
31
|
+
- path: components/event_listener/
|
|
32
|
+
Page:
|
|
33
|
+
fromDirs:
|
|
34
|
+
- path: components/pages/
|
|
35
|
+
maxDepth: 2
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 页面组件 YAML
|
|
39
|
+
|
|
40
|
+
每个页面有自己的 YAML 元数据文件(如 `dashboard.yaml`),格式与其他组件一致:
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
apiVersion: v1
|
|
44
|
+
kind: Page
|
|
45
|
+
metadata:
|
|
46
|
+
name: dashboard
|
|
47
|
+
label:
|
|
48
|
+
en_US: Demo Dashboard
|
|
49
|
+
zh_Hans: 演示仪表盘
|
|
50
|
+
spec:
|
|
51
|
+
path: index.html
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- `kind` — 固定为 `Page`
|
|
55
|
+
- `metadata.name` — 页面唯一 ID,同一插件内不可重复
|
|
56
|
+
- `metadata.label` — 多语言显示名称,显示在 WebUI 侧边栏「插件扩展页」分组中
|
|
57
|
+
- `spec.path` — HTML 入口文件,相对于该 YAML 所在目录的路径
|
|
58
|
+
|
|
59
|
+
### 目录结构
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
MyPlugin/
|
|
63
|
+
├── manifest.yaml
|
|
64
|
+
├── main.py
|
|
65
|
+
├── README.md
|
|
66
|
+
├── assets/
|
|
67
|
+
│ └── icon.svg
|
|
68
|
+
├── components/
|
|
69
|
+
│ ├── event_listener/ # 事件监听器组件
|
|
70
|
+
│ │ ├── default.yaml
|
|
71
|
+
│ │ └── default.py
|
|
72
|
+
│ └── pages/ # 页面组件
|
|
73
|
+
│ ├── dashboard/ # 第一个页面
|
|
74
|
+
│ │ ├── dashboard.yaml # 页面元数据
|
|
75
|
+
│ │ ├── index.html # 页面入口
|
|
76
|
+
│ │ └── i18n/ # 翻译文件
|
|
77
|
+
│ │ ├── en_US.json
|
|
78
|
+
│ │ └── zh_Hans.json
|
|
79
|
+
│ └── settings/ # 第二个页面
|
|
80
|
+
│ ├── settings.yaml
|
|
81
|
+
│ ├── index.html
|
|
82
|
+
│ └── i18n/
|
|
83
|
+
│ ├── en_US.json
|
|
84
|
+
│ └── zh_Hans.json
|
|
85
|
+
├── requirements.txt
|
|
86
|
+
└── config/
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
语言代码使用下划线分隔(如 `zh_Hans`、`en_US`、`ja_JP`),与 LangBot 多语言 README 规范一致。
|
|
90
|
+
|
|
91
|
+
当没有任何插件注册页面时,侧边栏的「插件扩展页」分组会自动隐藏。
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 页面 HTML 开发
|
|
96
|
+
|
|
97
|
+
在 HTML 文件中引入 JS SDK:
|
|
98
|
+
|
|
99
|
+
```html
|
|
100
|
+
<!DOCTYPE html>
|
|
101
|
+
<html>
|
|
102
|
+
<head>
|
|
103
|
+
<meta charset="UTF-8">
|
|
104
|
+
<style>
|
|
105
|
+
body {
|
|
106
|
+
background: var(--langbot-bg, #ffffff);
|
|
107
|
+
color: var(--langbot-text, #0a0a0a);
|
|
108
|
+
}
|
|
109
|
+
</style>
|
|
110
|
+
</head>
|
|
111
|
+
<body>
|
|
112
|
+
<!-- data-i18n 元素会被 SDK 自动翻译 -->
|
|
113
|
+
<h1 data-i18n="title">My Page</h1>
|
|
114
|
+
<p data-i18n="subtitle"></p>
|
|
115
|
+
|
|
116
|
+
<script src="/api/v1/plugins/_sdk/page-sdk.js"></script>
|
|
117
|
+
<script>
|
|
118
|
+
langbot.onReady(function(ctx) {
|
|
119
|
+
console.log('Theme:', ctx.theme); // 'light' or 'dark'
|
|
120
|
+
console.log('Language:', ctx.language); // 'zh-Hans', 'en-US', etc.
|
|
121
|
+
console.log(langbot.t('title')); // Translated string
|
|
122
|
+
});
|
|
123
|
+
</script>
|
|
124
|
+
</body>
|
|
125
|
+
</html>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
> **注意**: SDK 的 `<script>` 标签必须放在使用 `langbot` 对象的代码之前。
|
|
129
|
+
> SDK 会自动从 `./i18n/{locale}.json` 加载翻译并应用到带有 `data-i18n` 属性的元素。
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## JS SDK 参考
|
|
134
|
+
|
|
135
|
+
SDK 通过全局对象 `window.langbot` 暴露以下 API:
|
|
136
|
+
|
|
137
|
+
### 属性
|
|
138
|
+
|
|
139
|
+
| 属性 | 类型 | 说明 |
|
|
140
|
+
|------|------|------|
|
|
141
|
+
| `langbot.theme` | `string` | 当前主题,`'light'` 或 `'dark'` |
|
|
142
|
+
| `langbot.language` | `string` | 当前语言,如 `'zh-Hans'`、`'en-US'` |
|
|
143
|
+
| `langbot.ready` | `boolean` | SDK 是否已收到宿主的初始上下文 |
|
|
144
|
+
|
|
145
|
+
### 方法
|
|
146
|
+
|
|
147
|
+
#### `langbot.onReady(callback)`
|
|
148
|
+
|
|
149
|
+
注册初始化回调。SDK 收到宿主上下文并完成 i18n 加载后触发。若已就绪则立即执行。
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
langbot.onReady(function(ctx) {
|
|
153
|
+
// ctx.theme: 'light' | 'dark'
|
|
154
|
+
// ctx.language: 'zh-Hans' | 'en-US' | ...
|
|
155
|
+
// 此时 i18n 已加载,data-i18n 元素已翻译
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### `langbot.onThemeChange(callback)`
|
|
160
|
+
|
|
161
|
+
注册主题变更回调。每次用户切换主题时触发。
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
langbot.onThemeChange(function(theme) {
|
|
165
|
+
console.log('主题切换为:', theme);
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### `langbot.onLanguageChange(callback)`
|
|
170
|
+
|
|
171
|
+
注册语言变更回调。切换语言后触发(翻译已自动重新加载)。
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
langbot.onLanguageChange(function(lang) {
|
|
175
|
+
// data-i18n 元素已自动更新
|
|
176
|
+
console.log('语言切换为:', lang);
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### `langbot.t(key, fallback?)`
|
|
181
|
+
|
|
182
|
+
获取翻译字符串。若 key 不存在则返回 fallback 或 key 本身。
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
var title = langbot.t('title'); // 翻译值
|
|
186
|
+
var text = langbot.t('missing.key', 'Default'); // 'Default'
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### `langbot.applyI18n()`
|
|
190
|
+
|
|
191
|
+
手动重新应用翻译到所有 `data-i18n` 元素。适用于动态添加 DOM 元素后。
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
document.getElementById('list').innerHTML += '<li data-i18n="newItem">...</li>';
|
|
195
|
+
langbot.applyI18n();
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### `langbot.api(endpoint, body?, method?)`
|
|
199
|
+
|
|
200
|
+
调用插件后端的 `handle_page_api` 方法。返回 `Promise`。
|
|
201
|
+
|
|
202
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
203
|
+
|------|------|--------|------|
|
|
204
|
+
| `endpoint` | `string` | — | API 端点路径,如 `'/counter/get'` |
|
|
205
|
+
| `body` | `any` | `undefined` | 请求体(会序列化为 JSON) |
|
|
206
|
+
| `method` | `string` | `'POST'` | HTTP 方法 |
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
// GET 请求
|
|
210
|
+
const data = await langbot.api('/counter/get', null, 'GET');
|
|
211
|
+
|
|
212
|
+
// POST 请求
|
|
213
|
+
const result = await langbot.api('/counter/increment', { step: 1 });
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 后端 API 处理
|
|
219
|
+
|
|
220
|
+
在插件类中重写 `handle_page_api` 方法:
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
from langbot_plugin import BasePlugin
|
|
224
|
+
|
|
225
|
+
class MyPlugin(BasePlugin):
|
|
226
|
+
|
|
227
|
+
async def initialize(self):
|
|
228
|
+
self.counter = 0
|
|
229
|
+
|
|
230
|
+
async def handle_page_api(self, page_id: str, endpoint: str, method: str, body=None):
|
|
231
|
+
"""处理来自插件页面的 API 请求。
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
page_id: 页面 ID(manifest.yaml 中定义的 id)
|
|
235
|
+
endpoint: 前端请求的端点路径
|
|
236
|
+
method: HTTP 方法 (GET/POST/PUT/DELETE)
|
|
237
|
+
body: 请求体 (dict 或 None)
|
|
238
|
+
|
|
239
|
+
Returns:
|
|
240
|
+
任意可 JSON 序列化的数据,将作为响应返回给前端
|
|
241
|
+
"""
|
|
242
|
+
if endpoint == '/counter/get':
|
|
243
|
+
return {"count": self.counter}
|
|
244
|
+
|
|
245
|
+
elif endpoint == '/counter/increment':
|
|
246
|
+
step = (body or {}).get('step', 1)
|
|
247
|
+
self.counter += step
|
|
248
|
+
return {"count": self.counter}
|
|
249
|
+
|
|
250
|
+
elif endpoint == '/counter/reset':
|
|
251
|
+
self.counter = 0
|
|
252
|
+
return {"count": 0}
|
|
253
|
+
|
|
254
|
+
return {"error": "Unknown endpoint"}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
`handle_page_api` 可在插件内的任何组件(事件处理器、工具等)中复用同一份状态,因为它们共享同一个插件实例。
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 通信协议
|
|
262
|
+
|
|
263
|
+
页面(iframe)与宿主(LangBot WebUI)之间通过 `postMessage` 通信,共有三种消息类型:
|
|
264
|
+
|
|
265
|
+
### 1. 上下文推送(宿主 → iframe)
|
|
266
|
+
|
|
267
|
+
宿主在 iframe 加载完成后和主题/语言变更时发送:
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
方向: Parent → iframe
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
```json
|
|
274
|
+
{
|
|
275
|
+
"type": "langbot:context",
|
|
276
|
+
"theme": "light",
|
|
277
|
+
"language": "zh-Hans"
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### 2. API 请求(iframe → 宿主)
|
|
282
|
+
|
|
283
|
+
页面通过 SDK 的 `langbot.api()` 发起请求:
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
方向: iframe → Parent
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"type": "langbot:api",
|
|
292
|
+
"requestId": "req_1_1712300000000",
|
|
293
|
+
"endpoint": "/counter/get",
|
|
294
|
+
"method": "GET",
|
|
295
|
+
"body": null
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### 3. API 响应(宿主 → iframe)
|
|
300
|
+
|
|
301
|
+
宿主将后端返回的数据或错误转发给 iframe:
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
方向: Parent → iframe
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
成功:
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"type": "langbot:api:response",
|
|
311
|
+
"requestId": "req_1_1712300000000",
|
|
312
|
+
"data": { "count": 42 }
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
失败:
|
|
317
|
+
```json
|
|
318
|
+
{
|
|
319
|
+
"type": "langbot:api:response",
|
|
320
|
+
"requestId": "req_1_1712300000000",
|
|
321
|
+
"error": "Unknown endpoint"
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### 完整调用链
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
页面 JS (langbot.api)
|
|
329
|
+
→ postMessage (langbot:api)
|
|
330
|
+
→ page.tsx (PluginPageIframe)
|
|
331
|
+
→ httpClient.pluginPageApi()
|
|
332
|
+
→ POST /api/v1/plugins/{author}/{name}/page-api
|
|
333
|
+
→ LangBot handler
|
|
334
|
+
→ WebSocket (LangBotToRuntimeAction.PAGE_API)
|
|
335
|
+
→ Runtime control handler
|
|
336
|
+
→ WebSocket (RuntimeToPluginAction.PAGE_API)
|
|
337
|
+
→ Plugin: handle_page_api()
|
|
338
|
+
← postMessage (langbot:api:response)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## 暗黑模式适配
|
|
344
|
+
|
|
345
|
+
SDK 会自动在 `<html>` 上设置以下 CSS 自定义属性,页面可直接使用:
|
|
346
|
+
|
|
347
|
+
| CSS Variable | Light | Dark | 用途 |
|
|
348
|
+
|---|---|---|---|
|
|
349
|
+
| `--langbot-bg` | `#ffffff` | `#0a0a0a` | 页面背景色 |
|
|
350
|
+
| `--langbot-bg-card` | `#f8fafc` | `#171717` | 卡片背景色 |
|
|
351
|
+
| `--langbot-text` | `#0a0a0a` | `#fafafa` | 主文字色 |
|
|
352
|
+
| `--langbot-text-muted` | `#71717a` | `#a1a1aa` | 次要文字色 |
|
|
353
|
+
| `--langbot-border` | `#e4e4e7` | `#27272a` | 边框色 |
|
|
354
|
+
| `--langbot-accent` | `#2563eb` | `#3b82f6` | 强调色 |
|
|
355
|
+
|
|
356
|
+
同时 `<html>` 元素会添加 `light` 或 `dark` class 和 `data-theme` 属性,方便使用 CSS 选择器:
|
|
357
|
+
|
|
358
|
+
```css
|
|
359
|
+
body {
|
|
360
|
+
background: var(--langbot-bg);
|
|
361
|
+
color: var(--langbot-text);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/* 或者使用 class 选择器 */
|
|
365
|
+
.dark body {
|
|
366
|
+
background: #0a0a0a;
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## i18n 国际化
|
|
373
|
+
|
|
374
|
+
SDK 内置了自动 i18n 支持,无需手动编写翻译加载逻辑。
|
|
375
|
+
|
|
376
|
+
### 翻译文件
|
|
377
|
+
|
|
378
|
+
在页面目录下创建 `i18n/` 目录,放入 JSON 翻译文件:
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
pages/dashboard/
|
|
382
|
+
├── index.html
|
|
383
|
+
└── i18n/
|
|
384
|
+
├── en_US.json # 英文(回退语言)
|
|
385
|
+
├── zh_Hans.json # 简体中文
|
|
386
|
+
├── zh_Hant.json # 繁体中文
|
|
387
|
+
└── ja_JP.json # 日语
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
文件命名使用下划线:`{语言代码}.json`,与 LangBot 插件目录规范一致。
|
|
391
|
+
|
|
392
|
+
翻译文件格式为扁平 JSON 键值对:
|
|
393
|
+
|
|
394
|
+
```json
|
|
395
|
+
{
|
|
396
|
+
"title": "仪表盘",
|
|
397
|
+
"subtitle": "欢迎使用插件页面",
|
|
398
|
+
"counter.increment": "+1",
|
|
399
|
+
"counter.reset": "重置"
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### 自动翻译
|
|
404
|
+
|
|
405
|
+
在 HTML 元素上添加 `data-i18n` 属性,SDK 会自动替换文本内容:
|
|
406
|
+
|
|
407
|
+
```html
|
|
408
|
+
<h1 data-i18n="title">Dashboard</h1>
|
|
409
|
+
<button data-i18n="counter.increment">+1</button>
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
需要翻译元素属性(如 `placeholder`)时,配合 `data-i18n-attr`:
|
|
413
|
+
|
|
414
|
+
```html
|
|
415
|
+
<input data-i18n="search.placeholder" data-i18n-attr="placeholder" placeholder="Search...">
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### 编程式翻译
|
|
419
|
+
|
|
420
|
+
```js
|
|
421
|
+
// 获取翻译
|
|
422
|
+
var title = langbot.t('title');
|
|
423
|
+
var fallback = langbot.t('missing', 'Default Value');
|
|
424
|
+
|
|
425
|
+
// 语言变更时更新动态内容
|
|
426
|
+
langbot.onLanguageChange(function(lang) {
|
|
427
|
+
updateDynamicContent();
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// 动态添加元素后重新应用翻译
|
|
431
|
+
langbot.applyI18n();
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### 语言回退
|
|
435
|
+
|
|
436
|
+
SDK 按以下顺序加载翻译:
|
|
437
|
+
1. 尝试加载 `i18n/{当前语言}.json`(如 `i18n/zh_Hans.json`)
|
|
438
|
+
2. 若不存在,回退到 `i18n/en_US.json`
|
|
439
|
+
3. 若均不存在,保持 HTML 中的原始文本
|
|
440
|
+
|
|
441
|
+
### 支持的语言代码
|
|
442
|
+
|
|
443
|
+
| 语言 | 代码 | 文件名 |
|
|
444
|
+
|------|------|--------|
|
|
445
|
+
| 英文 | en_US | en_US.json |
|
|
446
|
+
| 简体中文 | zh_Hans | zh_Hans.json |
|
|
447
|
+
| 繁体中文 | zh_Hant | zh_Hant.json |
|
|
448
|
+
| 日语 | ja_JP | ja_JP.json |
|
|
449
|
+
| 韩语 | ko_KR | ko_KR.json |
|
|
450
|
+
| 越南语 | vi_VN | vi_VN.json |
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## iframe 安全
|
|
455
|
+
|
|
456
|
+
iframe 使用 `sandbox` 属性限制权限:
|
|
457
|
+
|
|
458
|
+
```
|
|
459
|
+
sandbox="allow-scripts allow-forms"
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
- `allow-scripts` — 允许执行 JavaScript
|
|
463
|
+
- `allow-forms` — 允许提交表单
|
|
464
|
+
|
|
465
|
+
不允许弹窗、导航等操作,确保插件页面在受控环境中运行。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "langbot-plugin"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.9"
|
|
4
4
|
description = "This package contains the SDK, CLI for building plugins for LangBot, plus the runtime for hosting LangBot plugins"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -43,4 +43,4 @@ Repository = "https://github.com/langbot-app/langbot-plugin-sdk"
|
|
|
43
43
|
Issues = "https://github.com/langbot-app/langbot-plugin-sdk/issues"
|
|
44
44
|
|
|
45
45
|
[tool.setuptools]
|
|
46
|
-
package-data = { "langbot_plugin" = ["assets/templates/*"] }
|
|
46
|
+
package-data = { "langbot_plugin" = ["assets/templates/*", "assets/*.js"] }
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
|
|
7
|
+
from langbot_plugin.api.definition.components.base import BaseComponent
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PageRequest(pydantic.BaseModel):
|
|
11
|
+
"""Incoming request to a Page component's handle_api method."""
|
|
12
|
+
|
|
13
|
+
endpoint: str
|
|
14
|
+
"""API endpoint path (e.g. ``'/entries'``)."""
|
|
15
|
+
|
|
16
|
+
method: str
|
|
17
|
+
"""HTTP method (``GET``, ``POST``, ``PUT``, ``DELETE``)."""
|
|
18
|
+
|
|
19
|
+
body: Any = None
|
|
20
|
+
"""Request body (parsed JSON, or ``None``)."""
|
|
21
|
+
|
|
22
|
+
# -- extensible fields for future use --
|
|
23
|
+
|
|
24
|
+
caller: dict[str, Any] | None = None
|
|
25
|
+
"""Caller identity (reserved for future public-facing pages)."""
|
|
26
|
+
|
|
27
|
+
headers: dict[str, str] = pydantic.Field(default_factory=dict)
|
|
28
|
+
"""Request headers (reserved for future use)."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class PageResponse(pydantic.BaseModel):
|
|
32
|
+
"""Response from a Page component's handle_api method."""
|
|
33
|
+
|
|
34
|
+
data: Any = None
|
|
35
|
+
"""Response payload (JSON-serializable)."""
|
|
36
|
+
|
|
37
|
+
error: str | None = None
|
|
38
|
+
"""Error message. If set, the frontend will treat it as a failure."""
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def ok(cls, data: Any = None) -> PageResponse:
|
|
42
|
+
return cls(data=data)
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def fail(cls, error: str) -> PageResponse:
|
|
46
|
+
return cls(error=error)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Page(BaseComponent):
|
|
50
|
+
"""The page component.
|
|
51
|
+
|
|
52
|
+
Each Page component provides a visual page in the LangBot WebUI sidebar
|
|
53
|
+
and can handle API calls from the frontend via ``handle_api``.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
__kind__ = "Page"
|
|
57
|
+
|
|
58
|
+
async def handle_api(self, request: PageRequest) -> PageResponse:
|
|
59
|
+
"""Handle an API call from the page frontend.
|
|
60
|
+
|
|
61
|
+
Override this method to implement a backend for your page.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
request: The incoming request containing endpoint, method, body,
|
|
65
|
+
and future fields like caller identity.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
A ``PageResponse`` with either data or an error message.
|
|
69
|
+
"""
|
|
70
|
+
return PageResponse.fail("Not implemented")
|
|
@@ -84,6 +84,7 @@ class LangBotAPIProxy:
|
|
|
84
84
|
timeout: float | None = None,
|
|
85
85
|
) -> provider_message.Message:
|
|
86
86
|
"""Invoke an LLM model"""
|
|
87
|
+
effective_timeout = timeout if timeout is not None else 120.0
|
|
87
88
|
resp = (
|
|
88
89
|
await self.plugin_runtime_handler.call_action(
|
|
89
90
|
PluginToRuntimeAction.INVOKE_LLM,
|
|
@@ -92,8 +93,9 @@ class LangBotAPIProxy:
|
|
|
92
93
|
"messages": [m.model_dump() for m in messages],
|
|
93
94
|
"funcs": [f.model_dump() for f in funcs],
|
|
94
95
|
"extra_args": extra_args,
|
|
96
|
+
"timeout": effective_timeout,
|
|
95
97
|
},
|
|
96
|
-
timeout=
|
|
98
|
+
timeout=effective_timeout,
|
|
97
99
|
)
|
|
98
100
|
)["message"]
|
|
99
101
|
|