Skip to main content

addToAgentState

codebolt.cbstate.addToAgentState(key: string, value: string): Promise<AddToAgentStateResponse>
Adds a key-value pair to the agent's state on the server via WebSocket.

Parameters

NameTypeDescription
keystringThe key to add to the agent's state.
valuestringThe value associated with the key.

Returns:

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

Example

// Add a user ID to the agent's state
await codebolt.cbstate.addToAgentState("userID", "12345");

// Add a configuration setting to the agent's state
await codebolt.cbstate.addToAgentState("configSetting", "darkModeEnabled");

Explanation

The codebolt.cbstate.addToAgentState(key: string, value: string) function is used to set key-value pair to the current agent's state. This function allows you to store state information.