Plugin Runtime Helpers
Reference for the api.runtime object injected into every plugin during
registration. Use these helpers instead of importing host internals directly.
Runtime namespaces
api.runtime.agent
Agent identity, directories, and session management.
runEmbeddedAgent(...) is the neutral helper for starting a normal Velaclaw
agent turn from plugin code. It uses the same provider/model resolution and
agent-harness selection as channel-triggered replies.
runEmbeddedPiAgent(...) remains as a compatibility alias.
Session store helpers are under api.runtime.agent.session:
api.runtime.agent.defaults
Default model and provider constants:
api.runtime.subagent
Launch and manage background subagent runs.
Model overrides (provider/model) require operator opt-in via
plugins.entries.<id>.subagent.allowModelOverride: true in config.
Untrusted plugins can still run subagents, but override requests are rejected.
api.runtime.taskFlow
Bind a Task Flow runtime to an existing Velaclaw session key or trusted tool
context, then create and manage Task Flows without passing an owner on every call.
Use bindSession({ sessionKey, requesterOrigin }) when you already have a
trusted Velaclaw session key from your own binding layer. Do not bind from raw
user input.
api.runtime.tts
Text-to-speech synthesis.
Uses core messages.tts configuration and provider selection. Returns PCM audio
buffer + sample rate.
Image, audio, and video analysis.
Returns { text: undefined } when no output is produced (e.g. skipped input).
api.runtime.stt.transcribeAudioFile(...) remains as a compatibility alias
for api.runtime.mediaUnderstanding.transcribeAudioFile(...).
api.runtime.imageGeneration
Image generation.
api.runtime.webSearch
Web search.
Low-level media utilities.
api.runtime.config
Config load and write.
api.runtime.system
System-level utilities.
api.runtime.events
Event subscriptions.
api.runtime.logging
Logging.
api.runtime.modelAuth
Model and provider auth resolution.
api.runtime.state
State directory resolution.
Memory tool factories and CLI.
api.runtime.channel
Channel-specific runtime helpers (available when a channel plugin is loaded).
api.runtime.channel.mentions is the shared inbound mention-policy surface for
bundled channel plugins that use runtime injection:
Available mention helpers:
buildMentionRegexes
matchesMentionPatterns
matchesMentionWithExplicit
implicitMentionKindWhen
resolveInboundMentionDecision
api.runtime.channel.mentions intentionally does not expose the older
resolveMentionGating* compatibility helpers. Prefer the normalized
{ facts, policy } path.
Storing runtime references
Use createPluginRuntimeStore to store the runtime reference for use outside
the register callback:
Prefer pluginId for the runtime-store identity. The lower-level key form is
for uncommon cases where one plugin intentionally needs more than one runtime
slot.
Other top-level api fields
Beyond api.runtime, the API object also provides: