schrodinger.application.bunsen.tool module

exception schrodinger.application.bunsen.tool.CriticalSecurityError(*, operation: str, reason: str, details: str)

Bases: RuntimeError

A Bunsen tool attempted an operation that violates security policy.

__init__(*, operation: str, reason: str, details: str)
schrodinger.application.bunsen.tool.get_bunsen_service()
class schrodinger.application.bunsen.tool.Provider(tag: str, description: str = '', *, execution_context_factory: collections.abc.Callable[[Tool], contextlib.AbstractContextManager] | None = None, argument_validator: collections.abc.Callable[[dict], None] | None = None, parent=None)

Bases: QObject

__init__(tag: str, description: str = '', *, execution_context_factory: collections.abc.Callable[[Tool], contextlib.AbstractContextManager] | None = None, argument_validator: collections.abc.Callable[[dict], None] | None = None, parent=None)

Create a provider for a related set of tools.

Parameters:
  • tag – Provider identifier used in external tool messages.

  • description – Description sent during tool registration.

  • execution_context_factory – Accepts the tool being invoked and returns a fresh context manager wrapping its synchronous execution.

  • argument_validator – Optional callback that validates raw tool arguments before file downloads and tool construction.

  • parent – Optional Qt parent object.

addTool(ToolClass)

Register a Tool class with this provider.

getToolSummaries() → list[dict]

Return name and description for every registered tool.

getSchemas() → list[dict]

Return the full schema for every registered tool.

getJsonSchemas() → list[dict]

Return JSON Schema tool definitions for BTI registration.

Each dict contains name (prefixed with the provider tag), description, and input_schema. The built-in help tool is excluded because structured schemas make it redundant.

getTag()
getDescription()
validateArgs(args: dict) → None

Apply this provider’s raw argument policy, if configured.

getToolClass(tool_name: str) → type

Return the Tool subclass registered under tool_name.

Raises:

ValueError – If no tool with that name is registered.

runTool(tool: Tool) → None

Run a tool inside this provider’s execution context.

Parameters:

tool – Tool instance to run synchronously.

class schrodinger.application.bunsen.tool.ToolParam(name: str, type: str, description: str = '')

Bases: object

name: str
type: str
description: str = ''
__init__(name: str, type: str, description: str = '') → None
class schrodinger.application.bunsen.tool.Tool(call_id: str, args: dict, parent=None)

Bases: QObject

Base class for tools that Bunsen can invoke.

Subclasses must define the class attributes PROVIDER, NAME, DESCRIPTION, and PARAMS, and implement main.

responseReady

A pyqtSignal emitted by instances of the class.

NAME: str = ''
DESCRIPTION: str = ''
PARAMS: tuple[ToolParam, ...] = ()
RESPONSE_FILES: tuple[str, ...] = ()
RESPONSE_FILE_DIR: str | None = None
classmethod getSchema() → dict

Return a dict describing this tool for Bunsen.

__init__(call_id: str, args: dict, parent=None)
getCallId()
getUiEvents() → list[dict]

Return the mutable UI events to include in this tool’s response.

run()
main(**kwargs)

The main function is responsible for calling self.sendResponse() itself or in a downstream callback or slot. This allows for both synchronous and asynchronous tool implementations.

getTempFile(suffix: str) → str

Create a temporary file tracked for cleanup.

Parameters:

suffix – File extension (without dot), e.g. "mae".

Returns:

Path to the new temporary file.

sendResponse(result: dict)