[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/script-host](https://jsprismarine.dev/api/@jsprismarine/script-host/index.md) / debugger/protocol

# debugger/protocol

## Interfaces

### DebuggerPlugin

Defined in: [script-host/src/debugger/protocol.ts:24](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L24)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L26)

##### name

> `readonly` **name**: `string`

Defined in: [script-host/src/debugger/protocol.ts:25](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L25)

***

### DebuggerStat

Defined in: [script-host/src/debugger/protocol.ts:33](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L33)

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`](#debuggerstat)[]

Defined in: [script-host/src/debugger/protocol.ts:38](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L38)

##### name

> `readonly` **name**: `string`

Defined in: [script-host/src/debugger/protocol.ts:34](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L34)

##### should\_aggregate

> `readonly` **should\_aggregate**: `boolean`

Defined in: [script-host/src/debugger/protocol.ts:35](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L35)

##### values?

> `readonly` `optional` **values?**: readonly (`string` \| `number`)[]

Defined in: [script-host/src/debugger/protocol.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L37)

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

***

### DiagnosticsTab

Defined in: [script-host/src/debugger/protocol.ts:45](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L45)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L48)

##### display\_type

> `readonly` **display\_type**: `string`

Defined in: [script-host/src/debugger/protocol.ts:49](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L49)

##### is\_empty\_tab

> `readonly` **is\_empty\_tab**: `boolean`

Defined in: [script-host/src/debugger/protocol.ts:50](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L50)

##### key\_label?

> `readonly` `optional` **key\_label?**: `string`

Defined in: [script-host/src/debugger/protocol.ts:54](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L54)

##### name

> `readonly` **name**: `string`

Defined in: [script-host/src/debugger/protocol.ts:46](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L46)

##### stat\_group\_id

> `readonly` **stat\_group\_id**: `string`

Defined in: [script-host/src/debugger/protocol.ts:47](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L47)

##### tick\_range?

> `readonly` `optional` **tick\_range?**: `number`

Defined in: [script-host/src/debugger/protocol.ts:52](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L52)

##### value\_scalar?

> `readonly` `optional` **value\_scalar?**: `number`

Defined in: [script-host/src/debugger/protocol.ts:53](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L53)

##### y\_label?

> `readonly` `optional` **y\_label?**: `string`

Defined in: [script-host/src/debugger/protocol.ts:51](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L51)

***

### ForwardedRequest

Defined in: [script-host/src/debugger/protocol.ts:131](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L131)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L134)

##### command

> `readonly` **command**: `string`

Defined in: [script-host/src/debugger/protocol.ts:133](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L133)

##### request\_seq

> `readonly` **request\_seq**: `number`

Defined in: [script-host/src/debugger/protocol.ts:132](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L132)

## Type Aliases

### DebuggerEvent

> **DebuggerEvent** = \{ `plugins`: readonly [`DebuggerPlugin`](#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`](#debuggerstat)[]; `tick`: `number`; `type`: `"StatEvent2"`; \} \| \{ `descriptors`: readonly [`DiagnosticsTab`](#diagnosticstab)[]; `type`: `"SchemaEvent"`; \} \| \{ `capture_base_path`: `string`; `capture_data`: `string`; `type`: `"ProfilerCapture"`; \} \| \{ `type`: `"terminated"`; \}

Defined in: [script-host/src/debugger/protocol.ts:94](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L94)

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

#### Union Members

##### Type Literal

\{ `plugins`: readonly [`DebuggerPlugin`](#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`](#debuggerstat)[]; `tick`: `number`; `type`: `"StatEvent2"`; \}

***

##### Type Literal

\{ `descriptors`: readonly [`DiagnosticsTab`](#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`](#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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L138)

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

***

### HostMessage

> **HostMessage** = \{ `event`: [`DebuggerEvent`](#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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L117)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L15)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L18)

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

***

### DIAGNOSTICS\_TABS

> `const` **DIAGNOSTICS\_TABS**: readonly [`DiagnosticsTab`](#diagnosticstab)[]

Defined in: [script-host/src/debugger/protocol.ts:62](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L62)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L21)

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`](#extensionmessage)

Defined in: [script-host/src/debugger/protocol.ts:173](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L173)

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`](#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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/protocol.ts#L235)

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

#### Parameters

##### args

`Record`\<`string`, `unknown`\>

#### Returns

`number`[]
