LangBot Docs

ワークスペース API

プラグインから Agent、パイプライン、ボット、モデル、ナレッジベースなどのワークスペースリソースを参照・管理します。

ワークスペース API を使うと、プラグインは自分がインストールされているワークスペースを操作できます。Agent やパイプラインの一覧取得と編集、ボットの参照、モデルやナレッジベースの管理、モニタリングデータの読み取りなどです。公開されている操作は LangBot の HTTP API、MCP サーバー、ワークスペースアシスタントとまったく同じなので、メンバーがそれらで行えることは、メンバーが許可した範囲内でプラグインからも自動化できます。

各操作には pipeline.list や knowledge.base.retrieve のような固定の ID があります。プラグインが呼び出せるのは、マニフェストで宣言し、かつメンバーがそのインストールに許可した操作だけです。

操作を呼び出す

どのコンポーネントからも self.plugin.workspace を使います。各操作には ID に対応した型付きメソッドがあります。

from langbot_plugin.api.definition.components.tool.tool import Tool


class WorkspaceSummary(Tool):
    async def call(self, params, session, query_id):
        result = await self.plugin.workspace.pipeline.list()
        if not result["ok"]:
            return f"パイプラインを取得できませんでした: {result['error']['message']}"

        names = [pipeline["name"] for pipeline in result["result"]]
        return "パイプライン: " + "、".join(names)

メソッドは操作の入力スキーマに対応するキーワード引数を受け取り、エディターでは型と説明が表示されます。一部の名前は Python として有効になるよう調整されます。Python のキーワードと重なる部分には末尾にアンダースコアが付き(例:import_)、その他の無効な文字はアンダースコアに置き換えられます。送信時には元の引数名が使われます。

呼び出す操作を実行時に決めたい場合は、ID を指定して呼び出せます。型付きメソッドとまったく同じように動作します。

result = await self.plugin.workspace.call("knowledge.base.retrieve", kb_uuid=kb_uuid, query="返金ポリシー")

await self.plugin.workspace.list() は、インストールに許可された操作とその入力スキーマを domains ごとにまとめて返します。ツール一覧を動的に組み立てたり、機能を提供する前に許可の有無を確かめたりするのに便利です。

Runner の中で使う

Runner では、実行に紐づいたプロキシを ctx.api.workspace として受け取ります。メソッドも、認可に使われるインストールの許可も同じです。違いは、LangBot が各呼び出しを現在の実行に記録する点です。

実行を開始した Agent やパイプラインが、モデルに見せるワークスペース操作を絞り込んでいる場合があります。その選択は ctx.resources.workspace_operations で渡されます。ワークスペース操作をツールとしてモデルに提供する Runner は、この中の操作だけを提供し、リストが空なら何も提供しないでください。LangBot 組み込みの LocalAgent もそのように動作します。

戻り値とエラー

ワークスペースの呼び出しは、業務上のエラーで例外を送出しません。常に辞書を返します。

# 成功
{"ok": True, "result": ..., "operation": {"id": "pipeline.list", ...}}

# 失敗
{"ok": False, "error": {"code": "permission_denied", "message": "...", "details": {...}}}

result を読む前に ok を確認してください。主なエラーコード:

コード意味
permission_deniedこの操作がインストールに許可されていないか、インストールが無効です。details.denied_operations に不足している ID が入ります。
invalid_input引数が操作の入力スキーマに合っていません。
not_found参照したリソースが現在のワークスペースに存在しません。
application_error操作は実行されましたが失敗しました。理由は message にあります。

メンバーは宣言された権限の一部だけを許可することもあるため、権限不足は想定内の結果です。コマンドや実行全体を失敗させるのではなく、何が足りないかを説明してください。

宣言する操作の選び方

各操作にはリスクレベルがあり、メンバーは確認時にそれを目にします。

  • 読み取り:データを返すだけの操作。例:pipeline.list、stats.basic。
  • 書き込み:ワークスペースの設定を変更する操作。例:pipeline.update、knowledge.file.store。
  • 高リスク:リソースの削除、LangBot 外部への影響、大量のリソース消費を伴う操作。例:bot.delete、pipeline.chat.broadcast。確認ダイアログで強調表示されます。

操作を許可するメンバーは、その操作が要求する権限(下の表の最後の列)を自分で持っている必要があります。必要な操作だけを申請してください。高リスクの操作を多数申請すると、拒否されたり削られたりする可能性が高くなります。

knowledge.* のようなワイルドカードで、あるプレフィックス配下の操作をまとめて申請できますが、すべてのプレフィックスで使えるわけではありません。ワイルドカードを参照してください。

操作一覧

現在の LangBot でプラグインが申請できるすべての操作を、ドメインごとに示します。メソッドは workspace.… と表記しています。コンポーネントでは self.plugin.workspace、Runner では ctx.api.workspace です。SDK の型付きメソッドはこのカタログから生成されているため、表のすべての操作がメソッドとして利用できます。

Adapter (adapter)

操作ID とメソッドリスク付与するメンバーに必要な権限
Get Adapter
Get configuration schema and requirements for an adapter.
adapter.get
workspace.adapter.get()
読み取りresource.view
List Adapters
List available chat platform adapters in the workspace.
adapter.list
workspace.adapter.list()
読み取りresource.view

Agent (agent)

操作ID とメソッドリスク付与するメンバーに必要な権限
Create Agent
Create a new autonomous AI agent in the workspace.
agent.create
workspace.agent.create()
書き込みresource.manage
Debug Agent
Execute a test turn on an agent for debugging purposes.
agent.debug
workspace.agent.debug()
書き込みruntime.operate
Delete Agent
Delete an autonomous AI agent from the workspace.
agent.delete
workspace.agent.delete()
高リスクresource.manage
Get Agent
Get full configuration and parameters for an AI agent.
agent.get
workspace.agent.get()
読み取りresource.view
List Agents
List all autonomous AI agents configured in the workspace.
agent.list
workspace.agent.list()
読み取りresource.view
Agent Metadata
Get supported agent capabilities, model types, and schemas.
agent.metadata
workspace.agent.metadata()
読み取りresource.view
Get Run Events
Fetch step-by-step trace events for an agent execution run.
agent.runs.events
workspace.agent.runs.events()
読み取りresource.view
List Agent Runs
List historical execution runs for an agent or processor.
agent.runs.list
workspace.agent.runs.list()
読み取りresource.view
Update Agent
Update configuration, model, or prompts of an agent.
agent.update
workspace.agent.update()
書き込みresource.manage

Bot (bot)

操作ID とメソッドリスク付与するメンバーに必要な権限
List Bot Admins
List platform users configured as administrators for a bot.
bot.admins.list
workspace.bot.admins.list()
読み取りresource.view
Create Bot
Create a new chat bot connected to an IM adapter.
bot.create
workspace.bot.create()
書き込みresource.manage
Delete Bot
Delete a chat bot and remove its adapter connection.
bot.delete
workspace.bot.delete()
高リスクresource.manage
Get Bot
Get detailed configuration and status for a specific bot.
bot.get
workspace.bot.get()
読み取りresource.view
Apply Group Filter
Apply group filtering rules to enable or disable pipelines.
bot.group_filter.apply
workspace.bot.group_filter.apply()
書き込みresource.manage
Preview Group Filter
Preview chat group filtering rules for a bot.
bot.group_filter.preview
workspace.bot.group_filter.preview()
読み取りresource.manage
List Bots
List all configured chat bots in the workspace.
bot.list
workspace.bot.list()
読み取りresource.view
Bot Logs
Fetch runtime connection logs and events for a bot.
bot.logs
workspace.bot.logs()
読み取りresource.view
Send Bot Message
Send an outbound message to a chat user or group via a bot.
bot.message.send
workspace.bot.message.send()
高リスクruntime.operate
Test Bot Message
Test bot messaging capability by sending a test message.
bot.message.test
workspace.bot.message.test()
書き込みresource.manage
Preview Routes
Preview message routing decisions for a simulated event.
bot.routes.preview
workspace.bot.routes.preview()
読み取りresource.manage
Routing Status
Get active message routing bindings and rules for a bot.
bot.routes.status
workspace.bot.routes.status()
読み取りresource.view
Bot Runtime Status
Inspect live connection state and health of a bot.
bot.runtime.get
workspace.bot.runtime.get()
読み取りresource.view
Update Bot
Update settings or pipeline bindings for an existing bot.
bot.update
workspace.bot.update()
書き込みresource.manage

Extension (extension)

操作ID とメソッドリスク付与するメンバーに必要な権限
List All Extensions
List all available plugins, MCP servers, and skills combined.
extension.list
workspace.extension.list()
読み取りresource.view

Knowledge Base (knowledge)

操作ID とメソッドリスク付与するメンバーに必要な権限
Create Knowledge Base
Create a new knowledge base with storage and vector engine.
knowledge.base.create
workspace.knowledge.base.create()
書き込みresource.manage
Delete Knowledge Base
Permanently delete a knowledge base and indexed documents.
knowledge.base.delete
workspace.knowledge.base.delete()
高リスクresource.manage
Get Knowledge Base
Get configuration and indexing status of a knowledge base.
knowledge.base.get
workspace.knowledge.base.get()
読み取りresource.view
List Knowledge Bases
List all knowledge bases configured in the workspace.
knowledge.base.list
workspace.knowledge.base.list()
読み取りresource.view
Retrieve Knowledge Chunks
Search and retrieve relevant text chunks from knowledge base.
knowledge.base.retrieve
workspace.knowledge.base.retrieve()
読み取りresource.view
Update Knowledge Base
Update configuration or description of a knowledge base.
knowledge.base.update
workspace.knowledge.base.update()
書き込みresource.manage
Engine Creation Schema
Get configuration schema required to create an engine.
knowledge.engine.creation_schema
workspace.knowledge.engine.creation_schema()
読み取りresource.view
List Knowledge Engines
List available storage and vector retrieval engine types.
knowledge.engine.list
workspace.knowledge.engine.list()
読み取りresource.view
Engine Retrieval Schema
Get parameter schema for retrieving from an engine.
knowledge.engine.retrieval_schema
workspace.knowledge.engine.retrieval_schema()
読み取りresource.view
Delete Knowledge File
Delete an indexed document from a knowledge base.
knowledge.file.delete
workspace.knowledge.file.delete()
高リスクresource.manage
List Knowledge Files
List all documents indexed within a knowledge base.
knowledge.file.list
workspace.knowledge.file.list()
読み取りresource.view
Store Knowledge File
Index and store a document into a knowledge base.
knowledge.file.store
workspace.knowledge.file.store()
書き込みresource.manage
List Document Parsers
List supported document parser formats and capabilities.
knowledge.parser.list
workspace.knowledge.parser.list()
読み取りresource.view

MCP (mcp)

操作ID とメソッドリスク付与するメンバーに必要な権限
List MCP Resources
List all resources exposed by connected MCP servers.
mcp.resource.list
workspace.mcp.resource.list()
読み取りresource.view
Read MCP Resource
Read contents of a specific resource from an MCP server.
mcp.resource.read
workspace.mcp.resource.read()
読み取りresource.view
List MCP Resource Templates
List parameterized resource URI templates from MCP servers.
mcp.resource.templates
workspace.mcp.resource.templates()
読み取りresource.view
Delete MCP Server
Disconnect and delete an MCP server from the workspace.
mcp.server.delete
workspace.mcp.server.delete()
高リスクresource.manage
Get MCP Server
Get configuration and parameters of a specific MCP server.
mcp.server.get
workspace.mcp.server.get()
読み取りresource.view
List MCP Servers
List configured Model Context Protocol (MCP) servers.
mcp.server.list
workspace.mcp.server.list()
読み取りresource.view
MCP Server Logs
Retrieve communication and error logs for an MCP server.
mcp.server.logs
workspace.mcp.server.logs()
読み取りaudit.view
MCP Server Runtime
Inspect live health and session state of an MCP server.
mcp.server.runtime
workspace.mcp.server.runtime()
読み取りresource.view
Test MCP Server Connection
Test connectivity and ping an MCP server configuration.
mcp.server.test
workspace.mcp.server.test()
書き込みresource.manage

Model (model)

操作ID とメソッドリスク付与するメンバーに必要な権限
Create Embedding Model
Configure and add a new embedding model to the workspace.
model.embedding.create
workspace.model.embedding.create()
書き込みprovider_secret.manage
Delete Embedding Model
Delete an embedding model configuration from the workspace.
model.embedding.delete
workspace.model.embedding.delete()
高リスクresource.manage
Get Embedding Model
Get configuration and parameters of an embedding model.
model.embedding.get
workspace.model.embedding.get()
読み取りresource.view
List Embedding Models
List all text embedding models configured in the workspace.
model.embedding.list
workspace.model.embedding.list()
読み取りresource.view
List Embeddings by Provider
List embedding models configured under a specific provider.
model.embedding.list_by_provider
workspace.model.embedding.list_by_provider()
読み取りresource.view
Test Embedding Model
Test vector generation and connectivity for embedding model.
model.embedding.test
workspace.model.embedding.test()
書き込みprovider_secret.manage
Update Embedding Model
Update configuration and parameters of an embedding model.
model.embedding.update
workspace.model.embedding.update()
書き込みprovider_secret.manage
Create LLM Model
Configure and add a new LLM model to the workspace.
model.llm.create
workspace.model.llm.create()
書き込みprovider_secret.manage
Get Default LLM Model
Get workspace default large language model configuration.
model.llm.default.get
workspace.model.llm.default.get()
読み取りresource.manage
Delete LLM Model
Delete an LLM model configuration from the workspace.
model.llm.delete
workspace.model.llm.delete()
高リスクresource.manage
Get LLM Model
Get configuration and parameters of a specific LLM model.
model.llm.get
workspace.model.llm.get()
読み取りresource.view
List LLM Models
List all configured large language models in the workspace.
model.llm.list
workspace.model.llm.list()
読み取りresource.view
List LLMs by Provider
List LLM models configured under a specific model provider.
model.llm.list_by_provider
workspace.model.llm.list_by_provider()
読み取りresource.view
Get Starred LLM Model
Get the starred favorite LLM model of the workspace.
model.llm.starred.get
workspace.model.llm.starred.get()
読み取りresource.view
Set Starred LLM Model
Designate a specific LLM model as the starred favorite.
model.llm.starred.set
workspace.model.llm.starred.set()
書き込みprovider_secret.manage
Test LLM Model
Test connectivity and response generation for an LLM model.
model.llm.test
workspace.model.llm.test()
書き込みprovider_secret.manage
Update LLM Model
Update configuration and parameters of an LLM model.
model.llm.update
workspace.model.llm.update()
書き込みprovider_secret.manage
Create Rerank Model
Configure and add a new rerank model to the workspace.
model.rerank.create
workspace.model.rerank.create()
書き込みprovider_secret.manage
Delete Rerank Model
Delete a rerank model configuration from the workspace.
model.rerank.delete
workspace.model.rerank.delete()
高リスクresource.manage
Get Rerank Model
Get configuration and parameters of a rerank model.
model.rerank.get
workspace.model.rerank.get()
読み取りresource.view
List Rerank Models
List all document reranking models in the workspace.
model.rerank.list
workspace.model.rerank.list()
読み取りresource.view
List Reranks by Provider
List rerank models configured under a specific provider.
model.rerank.list_by_provider
workspace.model.rerank.list_by_provider()
読み取りresource.view
Test Rerank Model
Test connectivity and scoring capability of a rerank model.
model.rerank.test
workspace.model.rerank.test()
書き込みprovider_secret.manage
Update Rerank Model
Update configuration and parameters of a rerank model.
model.rerank.update
workspace.model.rerank.update()
書き込みprovider_secret.manage

Monitoring (monitoring)

操作ID とメソッドリスク付与するメンバーに必要な権限
Embedding Call Metrics
Query embedding generation metrics and latency statistics.
monitoring.embedding_calls
workspace.monitoring.embedding_calls()
読み取りresource.view
Error Logs
Query runtime errors and failures across bots and pipelines.
monitoring.errors
workspace.monitoring.errors()
読み取りresource.view
Execution Details
Get detailed traces and step execution events for a specific execution.
monitoring.execution.detail
workspace.monitoring.execution.detail()
読み取りresource.view
List Executions
Query execution history records across bots, pipelines, and agents.
monitoring.executions
workspace.monitoring.executions()
読み取りresource.view
List User Feedback
List user ratings and feedback records on bot responses.
monitoring.feedback.list
workspace.monitoring.feedback.list()
読み取りresource.view
Feedback Statistics
Get aggregated positive and negative user feedback metrics.
monitoring.feedback.stats
workspace.monitoring.feedback.stats()
読み取りresource.view
In-Flight Executions
Inspect currently active in-flight requests and pipeline runs.
monitoring.inflight
workspace.monitoring.inflight()
読み取りresource.view
LLM Call Metrics
Query model invocation counts, latencies, and token stats.
monitoring.llm_calls
workspace.monitoring.llm_calls()
読み取りresource.view
Message Details
Retrieve full metadata and trace details for a single message.
monitoring.message.detail
workspace.monitoring.message.detail()
読み取りresource.view
Query Messages
Query processed chat messages across bot sessions.
monitoring.messages
workspace.monitoring.messages()
読み取りresource.view
Monitoring Overview
Get aggregated monitoring overview statistics for bots and pipelines.
monitoring.overview
workspace.monitoring.overview()
読み取りresource.view
Session Analysis
Analyze session metrics, duration, and token usage for a session.
monitoring.session.analysis
workspace.monitoring.session.analysis()
読み取りresource.view
Reset Session
Reset a chat session and clear its context window.
monitoring.session.reset
workspace.monitoring.session.reset()
高リスクresource.manage
List Sessions
List active and historical chat sessions across bots.
monitoring.sessions
workspace.monitoring.sessions()
読み取りresource.view
Token Usage Statistics
Query token consumption metrics aggregated by time buckets.
monitoring.tokens
workspace.monitoring.tokens()
読み取りresource.view
Tool Call Metrics
Query tool invocation history and execution performance.
monitoring.tool_calls
workspace.monitoring.tool_calls()
読み取りresource.view

Pipeline (pipeline)

操作ID とメソッドリスク付与するメンバーに必要な権限
Broadcast Chat Message
Broadcast a message to all active pipeline chat clients.
pipeline.chat.broadcast
workspace.pipeline.chat.broadcast()
高リスクruntime.operate
Pipeline Connections
Inspect live websocket connection status for pipeline chat.
pipeline.chat.connections
workspace.pipeline.chat.connections()
読み取りruntime.operate
Pipeline Chat History
Retrieve debug chat message history for a pipeline session.
pipeline.chat.history
workspace.pipeline.chat.history()
読み取りruntime.operate
Reset Chat Session
Clear memory and chat history for a pipeline debug session.
pipeline.chat.reset
workspace.pipeline.chat.reset()
高リスクruntime.operate
Copy Pipeline
Duplicate an existing pipeline to create a new copy.
pipeline.copy
workspace.pipeline.copy()
書き込みresource.manage
Create Pipeline
Create a new processing pipeline in the workspace.
pipeline.create
workspace.pipeline.create()
書き込みresource.manage
Pipeline Defaults
Get template defaults and initial values for new pipelines.
pipeline.defaults
workspace.pipeline.defaults()
読み取りresource.view
Delete Pipeline
Permanently delete a pipeline from the workspace.
pipeline.delete
workspace.pipeline.delete()
高リスクresource.manage
Get Pipeline Extensions
Get bound plugins, MCP servers, and tools for a pipeline.
pipeline.extensions.get
workspace.pipeline.extensions.get()
読み取りresource.view
Update Pipeline Extensions
Update bound plugins, MCP servers, and tools on a pipeline.
pipeline.extensions.update
workspace.pipeline.extensions.update()
書き込みresource.manage
Get Pipeline
Get complete definition and node graph of a pipeline.
pipeline.get
workspace.pipeline.get()
読み取りresource.view
List Pipelines
List all message processing pipelines in the workspace.
pipeline.list
workspace.pipeline.list()
読み取りresource.view
Pipeline Metadata
Get available component types and node specifications.
pipeline.metadata
workspace.pipeline.metadata()
読み取りresource.view
Run Pipeline
Execute a pipeline run with custom input data.
pipeline.run
workspace.pipeline.run()
書き込みruntime.operate
Update Pipeline
Update topology, nodes, or settings of a pipeline.
pipeline.update
workspace.pipeline.update()
書き込みresource.manage

Plugin (plugin)

操作ID とメソッドリスク付与するメンバーに必要な権限
Get Plugin Config
Get configured parameters and settings for a plugin.
plugin.config.get
workspace.plugin.config.get()
読み取りresource.view
Plugin Debug Info
Inspect internal plugin runtime process state and memory.
plugin.debug_info
workspace.plugin.debug_info()
読み取りresource.manage
Get Plugin
Get detailed metadata and manifest for an installed plugin.
plugin.get
workspace.plugin.get()
読み取りresource.view
Plugin GitHub Assets
List downloadable asset files for a GitHub release.
plugin.github.assets
workspace.plugin.github.assets()
読み取りresource.view
Plugin GitHub Releases
List releases of a plugin repository hosted on GitHub.
plugin.github.releases
workspace.plugin.github.releases()
読み取りresource.view
List Plugins
List all installed plugins and their running status.
plugin.list
workspace.plugin.list()
読み取りresource.view
Plugin Logs
Fetch runtime logs and error messages from a plugin.
plugin.logs
workspace.plugin.logs()
読み取りaudit.view
Plugin Readme
Get documentation and usage instructions for a plugin.
plugin.readme
workspace.plugin.readme()
読み取りresource.view

Model Provider (provider)

操作ID とメソッドリスク付与するメンバーに必要な権限
Create Provider
Add a new model provider and credentials to the workspace.
provider.create
workspace.provider.create()
書き込みprovider_secret.manage
Delete Provider
Delete a model provider and its associated models.
provider.delete
workspace.provider.delete()
高リスクresource.manage
Get Provider
Get configuration and credentials of a model provider.
provider.get
workspace.provider.get()
読み取りresource.view
List Providers
List all configured model providers in the workspace.
provider.list
workspace.provider.list()
読み取りresource.view
Provider Models Count
Count models configured under a specific model provider.
provider.models.count
workspace.provider.models.count()
読み取りresource.view
Scan Provider Models
Scan remote provider endpoint for available models.
provider.models.scan
workspace.provider.models.scan()
書き込みprovider_secret.manage
Update Provider
Update credentials or base URL of a model provider.
provider.update
workspace.provider.update()
書き込みprovider_secret.manage

Requester (requester)

操作ID とメソッドリスク付与するメンバーに必要な権限
Get Requester
Get configuration and capabilities of an HTTP requester.
requester.get
workspace.requester.get()
読み取りresource.view
List Requesters
List HTTP request client adapters used for model calls.
requester.list
workspace.requester.list()
読み取りresource.view

Skill (skill)

操作ID とメソッドリスク付与するメンバーに必要な権限
Create Skill
Create and register a new custom skill package.
skill.create
workspace.skill.create()
書き込みresource.manage
Delete Skill
Delete a custom skill and remove its code files.
skill.delete
workspace.skill.delete()
高リスクresource.manage
List Skill Files
List files and directories within a skill package.
skill.file.list
workspace.skill.file.list()
読み取りresource.view
Read Skill File
Read the source code or content of a file in a skill.
skill.file.read
workspace.skill.file.read()
読み取りresource.view
Write Skill File
Write or update a code file inside a skill package.
skill.file.write
workspace.skill.file.write()
書き込みresource.manage
Get Skill
Get full manifest and metadata for a specific skill.
skill.get
workspace.skill.get()
読み取りresource.view
Preview GitHub Skill
Preview a skill package from a GitHub repository.
skill.github.preview
workspace.skill.github.preview()
読み取りresource.manage
List Skills
List all custom skills installed in the workspace.
skill.list
workspace.skill.list()
読み取りresource.view
Reload Skills
Reload all skill packages and refresh runtime registries.
skill.reload
workspace.skill.reload()
書き込みresource.manage
Update Skill
Update metadata or configuration of an existing skill.
skill.update
workspace.skill.update()
書き込みresource.manage

Statistics (stats)

操作ID とメソッドリスク付与するメンバーに必要な権限
Basic Statistics
Get workspace overview counters for bots, models, and pipelines.
stats.basic
workspace.stats.basic()
読み取りresource.view

Tool (tool)

操作ID とメソッドリスク付与するメンバーに必要な権限
Get Tool
Get parameter schema and description for a specific tool.
tool.get
workspace.tool.get()
読み取りresource.view
List Tools
List all registered function tools available for execution.
tool.list
workspace.tool.list()
読み取りresource.view

On this page