Skip to main content

Action System Reference

Components for parsing and handling action tags from AI responses.

EstuaryActionManager

Parses action tags from bot responses and dispatches events.

import { EstuaryActionManager, ParsedAction } from 'estuary-lens-studio-sdk';

Constructor

const manager = new EstuaryActionManager(character);

Methods

MethodParametersDescription
setTargetCharacter()characterSet character to monitor
registerAction()charId, name, desc?Register an action
registerActions()charId, names[]Register multiple actions
unregisterAction()charId, nameUnregister action
isActionRegistered()charId, nameCheck registration
getRegisteredActions()charIdGet registered actions
setActionEnabled()charId, name, enabledEnable/disable action
onAction()name, handlerSubscribe to action
onActions()names[], handlerSubscribe to multiple
onAnyAction()handlerSubscribe to all
startListening()-Start monitoring responses
stopListening()-Stop monitoring
clearHistory()-Clear action history
wasActionTriggered()name, withinMs?Check if triggered
getActionsByName()nameGet actions by name
dispose()-Clean up resources

Properties

PropertyTypeDescription
currentActionParsedAction | nullMost recent action
actionHistoryParsedAction[]All triggered actions
isListeningbooleanMonitoring status
debugLoggingbooleanDebug mode
onlyFinalResponsesbooleanParse only final responses
maxHistorySizenumberMax history entries
strictModebooleanOnly trigger registered

EstuaryActions

Global action event system for easy access from any script.

import { EstuaryActions, ParsedAction } from 'estuary-lens-studio-sdk';

Static Methods

MethodParametersReturnsDescription
on()actionName, handler() => voidSubscribe to action (returns unsubscribe)
onAny()handler() => voidSubscribe to all actions (returns unsubscribe)
wasTriggered()actionNamebooleanCheck if action was triggered
getManager()-EstuaryActionManagerGet underlying manager instance
setManager()manager: EstuaryActionManagervoidSet the manager instance (called internally)

Static Properties

PropertyTypeDescription
currentActionParsedAction | nullMost recent action
actionHistoryParsedAction[]Action history

Usage Example

// Subscribe to specific action
const unsub = EstuaryActions.on("wave", (action) => {
print(`Wave at ${action.timestamp}`);
});

// Unsubscribe
unsub();

// Subscribe to all actions
EstuaryActions.onAny((action) => {
print(`Action: ${action.name}`);
});

ParsedAction

Represents a parsed action from bot response. Used by both EstuaryActionManager and EstuaryActions.

interface ParsedAction {
name: string; // Action name (e.g., "wave", "sit")
tag: string; // Full tag text (e.g., '<action name="wave" />')
messageId: string; // Source message ID
timestamp: number; // Detection time (Date.now())
}

RegisteredAction

Represents a registered action definition.

interface RegisteredAction {
name: string; // Action name
description?: string; // Optional description
enabled: boolean; // Whether action is enabled
}

Action Tag Format

The action system parses <action> tags embedded in AI responses:

<action name="wave" />
<action name="sit" />
<action name='dance' />

Regex pattern: /<action\s+name\s*=\s*["']([^"']+)["']\s*\/?>/gi