docs: document gateway server methods

This commit is contained in:
Peter Steinberger
2026-06-03 18:55:45 -04:00
parent 1fde4ae3b1
commit 46f015a627
14 changed files with 32 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for channel lifecycle, status, and account operations.
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
import {
ErrorCodes,
@@ -245,6 +246,7 @@ function resolveChannelGatewayAccountId(params: {
);
}
/** Log out one channel account through its owning channel plugin. */
export async function logoutChannelAccount(params: {
channelId: ChannelId;
accountId?: string | null;
@@ -279,6 +281,7 @@ export async function logoutChannelAccount(params: {
};
}
/** Start one channel account through its owning channel plugin. */
export async function startChannelAccount(params: {
channelId: ChannelId;
accountId?: string | null;
@@ -305,6 +308,7 @@ export async function startChannelAccount(params: {
};
}
/** Stop one channel account through its owning channel plugin. */
export async function stopChannelAccount(params: {
channelId: ChannelId;
accountId?: string | null;
@@ -328,6 +332,7 @@ export async function stopChannelAccount(params: {
};
}
/** Gateway request handlers for channel list, status, start, stop, and logout. */
export const channelsHandlers: GatewayRequestHandlers = {
"channels.status": async ({ params, respond, context }) => {
if (!validateChannelsStatusParams(params)) {

View File

@@ -1,3 +1,4 @@
// Webchat reply media path normalizer for display-safe outbound payloads.
import { isPassThroughRemoteMediaSource } from "@openclaw/media-core/media-source-url";
import { isAudioFileName } from "@openclaw/media-core/mime";
import { resolveAgentWorkspaceDir } from "../../agents/agent-scope.js";
@@ -24,6 +25,7 @@ function shouldPreserveDisplayMediaUrl(payload: ReplyPayload, mediaUrl: string):
return payload.trustedLocalMedia === true;
}
/** Normalize reply media paths for webchat display without leaking sensitive media. */
export async function normalizeWebchatReplyMediaPathsForDisplay(params: {
cfg: OpenClawConfig;
sessionKey: string;

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for cron job CRUD, run logs, wake, and delivery previews.
import {
ErrorCodes,
errorShape,
@@ -239,6 +240,7 @@ function isCronInvalidRequestError(err: unknown): boolean {
);
}
/** Gateway request handlers for cron jobs and cron run-log access. */
export const cronHandlers: GatewayRequestHandlers = {
wake: ({ params, respond, context }) => {
if (!validateWakeParams(params)) {

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for device pairing and device-token lifecycle operations.
import {
ErrorCodes,
errorShape,
@@ -177,6 +178,7 @@ function pairedDeviceHasNonOperatorRole(device: {
return hasNonOperatorDeviceRole(device) || hasNonOperatorDeviceTokenRole(device.tokens);
}
/** Gateway request handlers for device pair approval, removal, token rotation, and revocation. */
export const deviceHandlers: GatewayRequestHandlers = {
"device.pair.list": async ({ params, respond, client }) => {
if (!validateDevicePairListParams(params)) {

View File

@@ -1,3 +1,4 @@
// Gateway RPC handler for native hook relay invocation.
import { ErrorCodes, errorShape } from "../../../packages/gateway-protocol/src/index.js";
import {
invokeNativeHookRelay,
@@ -5,6 +6,7 @@ import {
} from "../../agents/harness/native-hook-relay.js";
import type { GatewayRequestHandlers } from "./types.js";
/** Gateway request handlers for invoking registered native hook relays. */
export const nativeHookRelayHandlers: GatewayRequestHandlers = {
"nativeHook.invoke": async ({ params, respond }) => {
try {

View File

@@ -1,3 +1,4 @@
// Gateway RPC handler for asynchronous node invocation results.
import {
ErrorCodes,
errorShape,
@@ -26,6 +27,7 @@ function normalizeNodeInvokeResultParams(params: unknown): unknown {
return normalized;
}
/** Handle a node's response to an earlier gateway `node.invoke` request. */
export const handleNodeInvokeResult: GatewayRequestHandler = async ({
params,
respond,

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for plugin approval requests and decisions.
import { randomUUID } from "node:crypto";
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
import {
@@ -26,6 +27,7 @@ import {
} from "./approval-shared.js";
import type { GatewayRequestHandlers } from "./types.js";
/** Create plugin approval handlers backed by the shared approval manager. */
export function createPluginApprovalHandlers(
manager: ExecApprovalManager<PluginApprovalRequestPayload>,
opts?: { forwarder?: ExecApprovalForwarder },

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for safe gateway restart requests and preflight state.
import {
createSafeGatewayRestartPreflight,
requestSafeGatewayRestart,
@@ -16,6 +17,7 @@ function normalizeSkipDeferral(value: unknown): boolean {
return value === true;
}
/** Gateway request handlers for safe restart coordination. */
export const restartHandlers: GatewayRequestHandlers = {
"gateway.restart.request": async ({ respond, params }) => {
const result = requestSafeGatewayRestart({

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for skill discovery, install/update, and proposal workflows.
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
import {
ErrorCodes,
@@ -141,6 +142,7 @@ async function runSkillsProposalWorkspaceHandler<TParams, TResult>(params: {
}
}
/** Gateway request handlers for skill status, catalogs, installs, updates, and workshop proposals. */
export const skillsHandlers: GatewayRequestHandlers = {
...skillsUploadHandlers,
"skills.status": ({ params, respond, context }) => {

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for Talk voice, transcription, and speech synthesis surfaces.
import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalLowercaseString,
@@ -512,6 +513,7 @@ function stripUnresolvedSecretApiKeyFromRecord(
return rest;
}
/** Gateway request handlers for Talk config, catalog, mode, sessions, and speech. */
export const talkHandlers: GatewayRequestHandlers = {
...talkSessionHandlers,
...talkClientHandlers,

View File

@@ -1,3 +1,4 @@
// Gateway RPC handler for the tool catalog shown by clients and Control UI.
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
import {
ErrorCodes,
@@ -189,6 +190,7 @@ function buildPluginGroups(params: {
.toSorted((a, b) => a.label.localeCompare(b.label));
}
/** Build the merged core/plugin tool catalog for one agent. */
export function buildToolsCatalogResult(params: {
cfg: OpenClawConfig;
agentId?: string;
@@ -216,6 +218,7 @@ export function buildToolsCatalogResult(params: {
};
}
/** Gateway request handlers for tool catalog queries. */
export const toolsCatalogHandlers: GatewayRequestHandlers = {
"tools.catalog": ({ params, respond, context }) => {
if (!validateToolsCatalogParams(params)) {

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for text-to-speech status, preferences, and conversion.
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
import { ErrorCodes, errorShape } from "../../../packages/gateway-protocol/src/index.js";
import {
@@ -25,6 +26,7 @@ import {
import { formatForLog } from "../ws-log.js";
import type { GatewayRequestHandlers } from "./types.js";
/** Gateway request handlers for TTS status, preference mutation, and synthesis. */
export const ttsHandlers: GatewayRequestHandlers = {
"tts.status": async ({ respond, context }) => {
try {

View File

@@ -1,3 +1,4 @@
// Gateway RPC handlers for voice wake routing configuration.
import { ErrorCodes, errorShape } from "../../../packages/gateway-protocol/src/index.js";
import {
loadVoiceWakeRoutingConfig,
@@ -7,6 +8,7 @@ import {
} from "../../infra/voicewake-routing.js";
import type { GatewayRequestHandlers } from "./types.js";
/** Gateway request handlers for reading and updating voice wake routing. */
export const voicewakeRoutingHandlers: GatewayRequestHandlers = {
"voicewake.routing.get": async ({ respond }) => {
try {

View File

@@ -1,9 +1,11 @@
// Gateway RPC handlers for voice wake phrase configuration.
import { ErrorCodes, errorShape } from "../../../packages/gateway-protocol/src/index.js";
import { loadVoiceWakeConfig, setVoiceWakeTriggers } from "../../infra/voicewake.js";
import { normalizeVoiceWakeTriggers } from "../server-utils.js";
import { formatForLog } from "../ws-log.js";
import type { GatewayRequestHandlers } from "./types.js";
/** Gateway request handlers for reading and updating voice wake triggers. */
export const voicewakeHandlers: GatewayRequestHandlers = {
"voicewake.get": async ({ respond }) => {
try {