Files
LangBot/sdk/docs/runner.md
0d84c334ba feat(sdk): move the plugin SDK into the monorepo with independent releases (LANG-420) (#2993)
* chore(sdk): import langbot-plugin-sdk v0.7.24 snapshot into sdk/ (LANG-420)

Snapshot of langbot-app/langbot-plugin-sdk at 76443bb8 (tag v0.7.24),
without history. The repository's .github/ workflows are not imported;
they are replaced by sdk-*.yml workflows in the next commit. The root
.gitignore keeps the template .vscode/launch.json.example tracked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

* feat(sdk): move the plugin SDK into the monorepo with independent releases (LANG-420)

- CI: sdk-tests.yml / sdk-box-docker.yml run the SDK suite from sdk/ in
  its own environment (Python 3.10-3.12); run-tests.yml gains a
  "Core with in-tree SDK" job that overlays sdk/ on Core's venv.
- Releases: sdk-publish.yml publishes langbot-plugin from sdk/vX.Y.Z tag
  pushes and never creates a GitHub Release. Core release workflows now
  only accept v* tags, and scripts/check_sdk_release_pin.py blocks a Core
  PyPI/Docker release whose langbot-plugin pin differs from the released,
  unchanged sdk/.
- Packaging: Core still installs the PyPI pin. Core wheel/sdist, git
  export, Docker context, release ZIP and fnOS package exclude sdk/.
- Generator/tests: generate_plugin_workspace_api.py writes sdk/ directly;
  the SDK's generator drift tests now run instead of skipping.
- Docs: AGENTS/ARCHITECTURE, sdk/ guides (+ RELEASING.md, SOURCE.json),
  agent skills and lbs probes, public docs (zh/en/ja) and dev-docs
  point at sdk/ instead of the sibling langbot-plugin-sdk checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-11-11 23:12:53 +08:00

4.5 KiB

Runner

A Runner implements processing logic for Agents, plugin processors, or both. It is a separate component kind from EventListener. Legacy EventListener plugins continue to participate in Pipeline lifecycle hooks; they do not subscribe to platform events automatically.

Scaffold and activate

Run lbp comp Runner in a plugin project. Build and install the plugin, then create a Plugin processor in LangBot's Processors area, select the component, configure its parameters and bind a Bot event to that instance. Installation and instance creation alone do not activate event subscriptions.

The plugin manifest declares the component directory:

spec:
  components:
    Runner:
      fromDirs:
        - path: components/runner/

A component manifest uses this shape:

apiVersion: langbot/v1
kind: Runner
metadata:
  name: welcome
  label:
    en_US: Welcome members
    zh_Hans: Welcome members
spec:
  usages: [event]
  events: [group.member_joined]
  config: []
  capabilities:
    tool_calling: true
  permissions:
    tools: [detail, call]
execution:
  python:
    path: welcome.py
    attr: WelcomeProcessor
from langbot_plugin.api.definition.components.runner import (
    Runner,
    RunnerContext,
)
from langbot_plugin.api.entities.builtin.platform.events import MemberJoinedEvent


class WelcomeProcessor(Runner):
    async def initialize(self):
        @self.handler(MemberJoinedEvent)
        async def welcome(ctx: RunnerContext):
            await ctx.log(f"Welcoming {ctx.platform_event.member.id}")
            await ctx.reply(f"Hello, {ctx.platform_event.member.nickname}")

Invocation contract

  • ctx.platform_event is the typed EBA event, including its full public fields. All built-in event types, including PlatformSpecificEvent, are supported. Raw platform objects and the Host's legacy-event backup are excluded from transport.
  • ctx.config contains parameters for the selected processor instance. It is separate from plugin installation configuration.
  • ctx.run_id identifies the invocation. Context operations use ctx; platform and LangBot operations use self.plugin, as in other components. The current invocation and its grants are attached automatically.
  • await ctx.log(text, level='info') records a log entry. Levels are debug, info, warning and error; a single entry is limited to 65,536 characters. Logs never send platform messages.
  • await ctx.reply(text) calls the Host's event_reply tool. Platform capability and resource authorization still apply. Unsupported actions fail explicitly.
  • Returning normally completes the run. Exceptions fail it and preserve preceding logs. Closing or cancelling the run cancels its handler. There is no implicit model loop or automatic retry of side effects.
  • Register EBAEvent for a catch-all fallback. Exact typed handlers take precedence. Multiple handlers of the same type execute in registration order. Concurrent runs have separate contexts; do not store invocation state on self.

All components use the reference plugin:author/plugin/name. Component names must be unique within a plugin. spec.usages accepts agent, event, or both; event usage requires an explicit spec.events declaration. The Host filters selectors by usage and checks the same declaration again at invocation.

Override run(ctx) for an execution engine, or use the default typed-handler dispatch shown above. Both receive RunnerContext. A custom run may call await super().run(ctx) to dispatch registered handlers. It can yield RunnerResult objects; the runtime supplies completion when execution returns without a terminal result. ctx.event remains the event envelope and ctx.platform_event exposes typed platform fields.

await ctx.get_available_tools() returns callable tools with name, description, parameters (JSON Schema), type, and operations. It includes only tools granted for this invocation. Changing the returned copy does not grant access. Use ctx.call_tool(name, parameters) for context actions, or self.plugin.call_tool(name, parameters) from component code. Models, storage, knowledge bases, and platform APIs use the same self.plugin entrypoint as other components while retaining run authorization. Event-target grants cannot access another target, and debug platform calls remain simulated.

Do not store a current run ID or context on the shared component instance, or continue run-bound calls from background tasks after the handler has returned.