ExecutionGateway API
The executionGateway module of the @codebolt/plugin-sdk.
import plugin from '@codebolt/plugin-sdk';
Quick Reference
| Method | Description |
|---|---|
claim | Claim exclusive handling of execution requests. |
offNotification | Remove a previously registered notification callback. |
offRequest | Remove a previously registered request callback. |
onNotification | Register a callback for execution notifications. |
onRequest | Register a callback for incoming execution requests. |
relinquish | Release the claim on the execution gateway. |
sendReply | Send a reply for a specific execution request. |
subscribe | Subscribe to execution notifications. |
unsubscribe | Unsubscribe 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>
offNotification
plugin.executionGateway.offNotification(callback: Function): void
Remove a previously registered notification callback.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback | Function | Yes |
Returns: void
offRequest
plugin.executionGateway.offRequest(callback: Function): void
Remove a previously registered request callback.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback | Function | Yes |
Returns: void
onNotification
plugin.executionGateway.onNotification(callback: Function): void
Register a callback for execution notifications. These are broadcast after any locally-executed agent action.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback | Function | Yes | Called with each ExecutionNotification |
Returns: void
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.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback | Function | Yes | Called with each ExecutionRequest |
Returns: void
relinquish
plugin.executionGateway.relinquish(): Promise<ExecutionGatewayResponse>
Release the claim on the execution gateway.
No parameters.
Returns: Promise<ExecutionGatewayResponse>
sendReply
plugin.executionGateway.sendReply(requestId: string, result: any, success: boolean): void
Send a reply for a specific execution request.
| Parameter | Type | Required | Description |
|---|---|---|---|
requestId | string | Yes | The requestId from the ExecutionRequest |
result | any | Yes | The result object to send back (will be the response to the agent) |
success | boolean | Yes | Whether the execution succeeded (default: true) (default: true) |
Returns: void
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>
unsubscribe
plugin.executionGateway.unsubscribe(): Promise<ExecutionGatewayResponse>
Unsubscribe from execution notifications.
No parameters.
Returns: Promise<ExecutionGatewayResponse>