Skip to content

API reference / @jsprismarine/script-host / debugger/protocol

debugger/protocol ​

Interfaces ​

DebuggerPlugin ​

Defined in: script-host/src/debugger/protocol.ts:24

One script pack the extension may debug: its name and the UUID of its script module.

Properties ​

module_uuid ​

readonly module_uuid: string

Defined in: script-host/src/debugger/protocol.ts:26

name ​

readonly name: string

Defined in: script-host/src/debugger/protocol.ts:25


DebuggerStat ​

Defined in: script-host/src/debugger/protocol.ts:33

One statistic of a StatEvent2, the extension's StatDataModel (src/stats/stats-provider.ts): a value for this tick, or a group of named children.

Properties ​

children? ​

readonly optional children?: readonly DebuggerStat[]

Defined in: script-host/src/debugger/protocol.ts:38

name ​

readonly name: string

Defined in: script-host/src/debugger/protocol.ts:34

should_aggregate ​

readonly should_aggregate: boolean

Defined in: script-host/src/debugger/protocol.ts:35

values? ​

readonly optional values?: readonly (string | number)[]

Defined in: script-host/src/debugger/protocol.ts:37

The values; the last one is this tick's.


DiagnosticsTab ​

Defined in: script-host/src/debugger/protocol.ts:45

A tab of the extension's diagnostics panel, the extension's DiagnosticsTabDescriptor (src/diagnostics-schema.ts), with the fields Bedrock Dedicated Server (BDS) fills.

Properties ​

data_source ​

readonly data_source: "server" | "client" | "server_script"

Defined in: script-host/src/debugger/protocol.ts:48

display_type ​

readonly display_type: string

Defined in: script-host/src/debugger/protocol.ts:49

is_empty_tab ​

readonly is_empty_tab: boolean

Defined in: script-host/src/debugger/protocol.ts:50

key_label? ​

readonly optional key_label?: string

Defined in: script-host/src/debugger/protocol.ts:54

name ​

readonly name: string

Defined in: script-host/src/debugger/protocol.ts:46

stat_group_id ​

readonly stat_group_id: string

Defined in: script-host/src/debugger/protocol.ts:47

tick_range? ​

readonly optional tick_range?: number

Defined in: script-host/src/debugger/protocol.ts:52

value_scalar? ​

readonly optional value_scalar?: number

Defined in: script-host/src/debugger/protocol.ts:53

y_label? ​

readonly optional y_label?: string

Defined in: script-host/src/debugger/protocol.ts:51


ForwardedRequest ​

Defined in: script-host/src/debugger/protocol.ts:131

A Debug Adapter Protocol request the extension forwards: stackTrace, next and the rest.

Properties ​

args ​

readonly args: Record<string, unknown>

Defined in: script-host/src/debugger/protocol.ts:134

command ​

readonly command: string

Defined in: script-host/src/debugger/protocol.ts:133

request_seq ​

readonly request_seq: number

Defined in: script-host/src/debugger/protocol.ts:132

Type Aliases ​

DebuggerEvent ​

DebuggerEvent = { plugins: readonly DebuggerPlugin[]; require_passcode?: boolean; type: "ProtocolEvent"; version: number; } | { reason: string; thread: number; type: "StoppedEvent"; } | { reason: "new" | "exited"; thread: number; type: "ThreadEvent"; } | { logLevel: number; message: string; type: "PrintEvent"; } | { logLevel: number; message: string; type: "NotificationEvent"; } | { stats: readonly DebuggerStat[]; tick: number; type: "StatEvent2"; } | { descriptors: readonly DiagnosticsTab[]; type: "SchemaEvent"; } | { capture_base_path: string; capture_data: string; type: "ProfilerCapture"; } | { type: "terminated"; }

Defined in: script-host/src/debugger/protocol.ts:94

The events the host sends, each inside an { type: 'event', event } envelope.

Union Members ​

Type Literal ​

{ plugins: readonly DebuggerPlugin[]; require_passcode?: boolean; type: "ProtocolEvent"; version: number; }


Type Literal ​

{ reason: string; thread: number; type: "StoppedEvent"; }


Type Literal ​

{ reason: "new" | "exited"; thread: number; type: "ThreadEvent"; }


Type Literal ​

{ logLevel: number; message: string; type: "PrintEvent"; }


Type Literal ​

{ logLevel: number; message: string; type: "NotificationEvent"; }


Type Literal ​

{ stats: readonly DebuggerStat[]; tick: number; type: "StatEvent2"; }


Type Literal ​

{ descriptors: readonly DiagnosticsTab[]; type: "SchemaEvent"; }


Type Literal ​

{ capture_base_path: string; capture_data: string; type: "ProfilerCapture"; }

A CPU profile, .cpuprofile JSON in base64, for the extension to write under capture_base_path.


Type Literal ​

{ type: "terminated"; }

The host ends the session; BDS sends it just before it closes the connection.


ExtensionMessage ​

ExtensionMessage = { passcode: string | undefined; targetModuleUuid: string | undefined; type: "protocol"; version: number; } | { request: ForwardedRequest; type: "request"; } | { lines: readonly number[]; path: string; type: "breakpoints"; } | { stop: boolean; type: "stopOnException"; } | { type: "resume"; } | { command: string; dimension: string; type: "minecraftCommand"; } | { request: string; request_seq: number; type: "debugger-request"; } | { type: "startProfiler"; } | { capturesPath: string; type: "stopProfiler"; } | { name: string; type: "other"; }

Defined in: script-host/src/debugger/protocol.ts:138

A message the extension sends, parsed into what the host acts on.


HostMessage ​

HostMessage = { event: DebuggerEvent; type: "event"; } | { body?: unknown; error?: string; request_seq: number; type: "response"; } | { event: { request_seq: number; response_message?: string; success: boolean; type: "debuggee-response"; }; type: "debuggee-response"; }

Defined in: script-host/src/debugger/protocol.ts:117

A message the host sends. A response answers a request by its request_seq, with a body or an error. debuggee-response answers a debugger-request; the extension reads it from the envelope's event field (receiveDebugeeMessage in src/session.ts).

Variables ​

DEBUGGER_PROTOCOL_VERSION ​

const DEBUGGER_PROTOCOL_VERSION: 11 = 11

Defined in: script-host/src/debugger/protocol.ts:15

The protocol version the host offers. The extension echoes any version from 2 up to its own DEBUGGER_PROTOCOL_VERSION (src/protocol-events.ts), and 11 is that constant in v1.61.0.


DEFAULT_DEBUGGER_PORT ​

const DEFAULT_DEBUGGER_PORT: 19144 = 19144

Defined in: script-host/src/debugger/protocol.ts:18

The port the extension and Bedrock Dedicated Server use when none is given.


DIAGNOSTICS_TABS ​

const DIAGNOSTICS_TABS: readonly DiagnosticsTab[]

Defined in: script-host/src/debugger/protocol.ts:62

The tabs protocol 2193's pinned BDS sends in its SchemaEvent, captured from its wire: two for a client's frame timings and memory, which a dedicated server never fills, and the engine's memory table, which the scripting_engine statistic fills.


LogLevel ​

const LogLevel: object

Defined in: script-host/src/debugger/protocol.ts:21

The level of a printed or notified message, as the extension's LogLevel numbers them.

Type Declaration ​

error ​

readonly error: 3 = 3

log ​

readonly log: 1 = 1

verbose ​

readonly verbose: 0 = 0

warn ​

readonly warn: 2 = 2

Functions ​

parseExtensionMessage() ​

parseExtensionMessage(message): ExtensionMessage

Defined in: script-host/src/debugger/protocol.ts:173

Reads one message from the extension. The shapes of protocol 8 and later are flat, and the older ones nest their fields one level down (src/protocol-events.ts), so both are read.

Parameters ​

message ​

unknown

A parsed JSON message.

Returns ​

ExtensionMessage

The message, or other for a type the host does not act on.

Throws ​

When the message is not an object with a type.


requestedBreakpointLines() ​

requestedBreakpointLines(args): number[]

Defined in: script-host/src/debugger/protocol.ts:235

Reads the lines of a setBreakpoints request, which protocol 6 and later send as a request.

Parameters ​

args ​

Record<string, unknown>

Returns ​

number[]