This document describes all the message interfaces defined in for WebSocket communication between the Second Life viewer and an external editor such as a VSCode extension.
- Usage Flow
- JSON-RPC Method Summary
- Session Management Interfaces
- Language and Syntax Interfaces
- Script Subscription Interfaces
- Compilation Interfaces
- Runtime Event Interfaces
- Handler and Configuration Interfaces
-
Connection Establishment:
- Viewer sends
session.handshakenotification withSessionHandshakedata - Extension responds with
SessionHandshakeResponse - Viewer confirms with
session.oknotification
- Viewer sends
-
Language Information Exchange:
- Extension makes
language.syntax.idcall to get current syntax version - Extension makes
language.syntaxcalls with differentkindparameters to get specific language data - Viewer responds with
LanguageInfodata containing the requested information
- Extension makes
-
Script Subscription Management:
- Extension makes
script.subscribecall withScriptSubscribedata to request live synchronization for a script - Viewer responds with
ScriptSubscribeResponseindicating success or failure - When subscription needs to be terminated, viewer sends
script.unsubscribenotification withScriptUnsubscribedata - Extension handles unsubscription by cleaning up local script tracking
- Extension makes
-
Runtime Events:
- Viewer sends
language.syntax.changenotification withSyntaxChangewhen language changes - Viewer sends
script.compilednotification withCompilationResultafter script compilation - Viewer sends
runtime.debugnotification withRuntimeDebugfor debug messages during script execution - Viewer sends
runtime.errornotification withRuntimeErrorwhen runtime errors occur
- Viewer sends
-
Connection Termination:
- Either side can send
session.disconnectnotification withSessionDisconnectdata - Connection is closed gracefully
- Either side can send
| Method | Direction | Type | Interface/Parameters |
|---|---|---|---|
session.handshake |
Viewer → Extension | Notification | SessionHandshake |
session.handshake (response) |
Extension → Viewer | Response | SessionHandshakeResponse |
session.ok |
Viewer → Extension | Notification | (no interface) |
session.disconnect |
Bidirectional | Notification | SessionDisconnect |
script.subscribe |
Extension → Viewer | Call | ScriptSubscribe |
script.subscribe (response) |
Viewer → Extension | Response | ScriptSubscribeResponse |
script.unsubscribe |
Viewer → Extension | Notification | ScriptUnsubscribe |
language.syntax.id |
Extension → Viewer | Call | (no parameters) |
language.syntax.id (response) |
Viewer → Extension | Response | { id: string } |
language.syntax |
Extension → Viewer | Call | { kind: string } |
language.syntax (response) |
Viewer → Extension | Response | LanguageInfo |
language.syntax.change |
Viewer → Extension | Notification | SyntaxChange |
script.compiled |
Viewer → Extension | Notification | CompilationResult |
runtime.debug |
Viewer → Extension | Notification | RuntimeDebug |
runtime.error |
Viewer → Extension | Notification | RuntimeError |
JSON-RPC Method: session.handshake (notification from viewer)
The initial handshake message sent by the viewer to establish a connection.
interface SessionHandshake {
server_version: "1.0.0";
protocol_version: "1.0";
viewer_name: string;
viewer_version: string;
agent_id: string;
agent_name: string;
challenge?: string;
languages: string[];
syntax_id: string;
features: { [feature: string]: boolean };
}Fields:
server_version: Fixed version "1.0.0" indicating the server API versionprotocol_version: Fixed version "1.0" for the communication protocolviewer_name: Name of the Second Life viewer applicationviewer_version: Version string of the vieweragent_id: Unique identifier for the user/agentagent_name: Human-readable name of the agentchallenge(optional): Security challenge string for authenticationlanguages: Array of supported scripting languages (e.g., ["lsl", "luau"])syntax_id: Current active syntax/language identifierfeatures: Dictionary of feature flags indicating viewer capabilities
JSON-RPC Method: Response to session.handshake
The response sent by the VS Code extension to complete the handshake.
interface SessionHandshakeResponse {
client_name: string;
client_version: "1.0";
protocol_version: string;
challenge_response?: string;
languages: string[];
features: { [feature: string]: boolean };
}Fields:
client_name: Name of the client (VS Code extension)client_version: Fixed version "1.0" of the clientprotocol_version: Protocol version the client supportschallenge_response(optional): Response to the security challenge if providedlanguages: Array of languages supported by the clientfeatures: Dictionary of features supported by the client
JSON-RPC Method: session.ok (notification from viewer)
Confirmation notification sent by the viewer after successful handshake completion. This interface has no defined structure as it appears to be a simple confirmation message.
JSON-RPC Method: session.disconnect (notification, bidirectional)
Message sent when terminating the connection.
interface SessionDisconnect {
reason: number;
message: string;
}Fields:
reason: Numeric code indicating the reason for disconnectionmessage: Human-readable description of the disconnect reason
JSON-RPC Method: language.syntax.change (notification from viewer)
Notification sent when the active language syntax changes in the viewer.
interface SyntaxChange {
id: string;
}Fields:
id: Identifier for the new syntax/language
JSON-RPC Method: language.syntax.id (call from extension to viewer)
Requests the current active language syntax identifier from the viewer. This method takes no parameters.
Response: Returns an object with an id field containing the current syntax identifier.
JSON-RPC Method: language.syntax (call from extension to viewer)
Requests detailed syntax information for a specific language kind.
Parameters:
{
kind: string; // The type of syntax information requested
}Fields:
kind: The type of syntax information to retrieve (e.g., "functions", "constants", "events", "types.luau")
Response: Returns LanguageInfo data containing the requested syntax information:
interface LanguageInfo {
id: string;
lslDefs?: {
controls?: any;
types?: any;
constants?: { [name: string]: ConstantDef };
events?: { [name: string]: FunctionDef };
functions?: { [name: string]: FunctionDef };
};
luaDefs?: {
modules?: { [name: string]: TypeDef };
classes?: { [name: string]: TypeDef };
aliases?: { [name: string]: TypeDef };
functions?: { [name: string]: FunctionDef };
};
}Response Fields:
id: Version identifier for the language syntaxlslDefs(optional): LSL-specific language definitions containing:controls(optional): Control flow and language constructstypes(optional): LSL type definitionsconstants(optional): Object containing constant definitions keyed by constant nameevents(optional): Object containing event definitions keyed by event namefunctions(optional): Object containing function definitions keyed by function name
luaDefs(optional): Lua-specific language definitions containing:modules(optional): Module type definitions keyed by module nameclasses(optional): Class type definitions keyed by class namealiases(optional): Type alias definitions keyed by alias namefunctions(optional): Function definitions keyed by function name
The specific sections returned depend on the kind parameter and the active language context.
JSON-RPC Method: script.subscribe (call from extension to viewer)
Requests subscription to a script for live synchronization between the editor and viewer.
interface ScriptSubscribe {
script_id: string;
script_name: string;
script_language: string;
}Fields:
script_id: Unique identifier for the script to subscribe toscript_name: Display name of the script filescript_language: Programming language of the script (e.g., "lsl", "luau")
JSON-RPC Method: Response to script.subscribe
Response from the viewer indicating whether script subscription was successful.
interface ScriptSubscribeResponse {
script_id: string;
success: boolean;
status: number;
object_id?: string;
object_name?: string;
item_id?: string;
message?: string;
}Fields:
script_id: The script identifier that was subscribed tosuccess: Whether the subscription was successfulstatus: Numeric status code indicating the resultobject_id(optional): The in-world ID of the object containing the scriptobject_name(optional): The name of the object containing the script.message(optional): Additional information about the subscription result
JSON-RPC Method: script.unsubscribe (notification from viewer)
Notification sent by the viewer when a script subscription should be terminated.
interface ScriptUnsubscribe {
script_id: string;
}Fields:
script_id: Unique identifier for the script to unsubscribe from
Individual compilation error record.
interface CompilationError {
row: number;
column: number;
level: "ERROR";
message: string;
}Fields:
row: Line number where the error occurred (0-based or 1-based depending on context)column: Column position of the errorlevel: Severity level (currently only "ERROR" is defined)message: Error description
JSON-RPC Method: script.compiled (notification from viewer)
Result of a compilation operation in the viewer.
interface CompilationResult {
script_id: string;
success: boolean;
running: boolean;
errors?: CompilationError[];
}Fields:
script_id: Unique identifier for the script that was compiledsuccess: Whether the compilation was successfulrunning: Whether the compiled script is currently runningerrors(optional): Array of compilation errors if any occurred
JSON-RPC Method: runtime.debug (notification from viewer)
Debug message notification sent by the viewer during script execution.
interface RuntimeDebug {
script_id: string;
object_id: string;
object_name: string;
message: string;
}Fields:
script_id: Unique identifier for the script generating the debug messageobject_id: Unique identifier for the object containing the scriptobject_name: Human-readable name of the objectmessage: The debug message content
JSON-RPC Method: runtime.error (notification from viewer)
Runtime error notification sent by the viewer when a script encounters an error during execution.
interface RuntimeError {
script_id: string;
object_id: string;
object_name: string;
message: string;
error: string;
line: number;
stack?: string[];
}Fields:
script_id: Unique identifier for the script that encountered the errorobject_id: Unique identifier for the object containing the scriptobject_name: Human-readable name of the objectmessage: Error message descriptionerror: Specific error type or codeline: Line number where the error occurredstack(optional): Stack trace information if available
Event handler interface for WebSocket events.
interface WebSocketHandlers {
onHandshake?: (message: SessionHandshake) => SessionHandshakeResponse;
onHandshakeOk?: () => void;
onDisconnect?: (message: SessionDisconnect) => void;
onSubscribe?: (message: ScriptSubscribe) => ScriptSubscribeResponse;
onUnsubscribe?: (message: ScriptUnsubscribe) => void;
onSyntaxChange?: (message: SyntaxChange) => void;
onConnectionClosed?: () => void;
onCompilationResult?: (message: CompilationResult) => void;
onRuntimeDebug?: (message: RuntimeDebug) => void;
onRuntimeError?: (message: RuntimeError) => void;
}Methods:
onHandshake: Handler for initial handshake message, returns handshake responseonHandshakeOk: Handler called when handshake is successfully completedonDisconnect: Handler for disconnect notificationsonSubscribe: Handler for script subscription requests from viewer, returns subscription responseonUnsubscribe: Handler for script unsubscription notifications from vieweronSyntaxChange: Handler for syntax change notificationsonConnectionClosed: Handler called when connection is closedonCompilationResult: Handler for compilation result notificationsonRuntimeDebug: Handler for runtime debug message notificationsonRuntimeError: Handler for runtime error notifications
Client information used in handshake responses.
interface ClientInfo {
scriptName: string;
scriptId: string;
extension: string;
}Fields:
scriptName: Name of the script being editedscriptId: Unique identifier for the scriptextension: File extension or script type