Skip to main content

ExecutionGateway API

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

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

Quick Reference

MethodDescription
claimClaim exclusive handling of execution requests.
offNotificationRemove a previously registered notification callback.
offRequestRemove a previously registered request callback.
onNotificationRegister a callback for execution notifications.
onRequestRegister a callback for incoming execution requests.
relinquishRelease the claim on the execution gateway.
sendReplySend a reply for a specific execution request.
subscribeSubscribe to execution notifications.
unsubscribeUnsubscribe from execution notifications.

Methods


claim

plugin.executionGateway.claim(): Promise<ExecutionGatewayClaimResponse>

Claim exclusive handling of execution requests. Only one plugin can claim at a time. Returns an error if already claimed.

No parameters.

Returns: Promise<ExecutionGatewayClaimResponse>

Full reference →


offNotification

plugin.executionGateway.offNotification(callback: Function): void

Remove a previously registered notification callback.

ParameterTypeRequiredDescription
callbackFunctionYes

Returns: void

Full reference →


offRequest

plugin.executionGateway.offRequest(callback: Function): void

Remove a previously registered request callback.

ParameterTypeRequiredDescription
callbackFunctionYes

Returns: void

Full reference →


onNotification

plugin.executionGateway.onNotification(callback: Function): void

Register a callback for execution notifications. These are broadcast after any locally-executed agent action.

ParameterTypeRequiredDescription
callbackFunctionYesCalled with each ExecutionNotification

Returns: void

Full reference →


onRequest

plugin.executionGateway.onRequest(callback: Function): void

Register a callback for incoming execution requests. These are proxied agent messages that the claiming plugin must handle. After processing, call sendReply() with the requestId and result.

ParameterTypeRequiredDescription
callbackFunctionYesCalled with each ExecutionRequest

Returns: void

Full reference →


relinquish

plugin.executionGateway.relinquish(): Promise<ExecutionGatewayResponse>

Release the claim on the execution gateway.

No parameters.

Returns: Promise<ExecutionGatewayResponse>

Full reference →


sendReply

plugin.executionGateway.sendReply(requestId: string, result: any, success: boolean): void

Send a reply for a specific execution request.

ParameterTypeRequiredDescription
requestIdstringYesThe requestId from the ExecutionRequest
resultanyYesThe result object to send back (will be the response to the agent)
successbooleanYesWhether the execution succeeded (default: true) (default: true)

Returns: void

Full reference →


subscribe

plugin.executionGateway.subscribe(): Promise<ExecutionGatewayResponse>

Subscribe to execution notifications. Notifications are broadcast whenever the server handles a message locally.

No parameters.

Returns: Promise<ExecutionGatewayResponse>

Full reference →


unsubscribe

plugin.executionGateway.unsubscribe(): Promise<ExecutionGatewayResponse>

Unsubscribe from execution notifications.

No parameters.

Returns: Promise<ExecutionGatewayResponse>

Full reference →