Skip to main content

Cbstate API

The cbstate module of the @codebolt/plugin-sdk.

import plugin from '@codebolt/plugin-sdk';

Quick Reference

MethodDescription
addToAgentStateAdds a key-value pair to the agent's state on the server via WebSocket.
getAgentStateRetrieves the current state of the agent from the server via WebSocket.
getApplicationStateRetrieves the current application state from the server via WebSocket.
getProjectStateRetrieves the current project state from the server via WebSocket.
updateProjectStateUpdates the project state on the server via WebSocket.

Methods


addToAgentState

plugin.cbstate.addToAgentState(key: string, value: string): Promise<AddToAgentStateResponse>

Adds a key-value pair to the agent's state on the server via WebSocket.

ParameterTypeRequiredDescription
keystringYesThe key to add to the agent's state.
valuestringYesThe value associated with the key.

Returns: Promise<AddToAgentStateResponse> — A promise that resolves with the response to the addition request.

Full reference →


getAgentState

plugin.cbstate.getAgentState(): Promise<GetAgentStateResponse>

Retrieves the current state of the agent from the server via WebSocket.

No parameters.

Returns: Promise<GetAgentStateResponse> — A promise that resolves with the agent's state.

Full reference →


getApplicationState

plugin.cbstate.getApplicationState(): Promise<ApplicationState>

Retrieves the current application state from the server via WebSocket.

No parameters.

Returns: Promise<ApplicationState> — A promise that resolves with the application state.

Full reference →


getProjectState

plugin.cbstate.getProjectState(): Promise<GetProjectStateResponse>

Retrieves the current project state from the server via WebSocket.

No parameters.

Returns: Promise<GetProjectStateResponse> — A promise that resolves with the project's state.

Full reference →


updateProjectState

plugin.cbstate.updateProjectState(key: string, value: any): Promise<UpdateProjectStateResponse>

Updates the project state on the server via WebSocket.

ParameterTypeRequiredDescription
keystringYesThe key to update in the project state.
valueanyYesThe value to set for the key.

Returns: Promise<UpdateProjectStateResponse> — A promise that resolves with the response to the update request.

Full reference →