Skip to content

Commit 2da49ef

Browse files
committed
docs: document gateway node policies
1 parent fba99cd commit 2da49ef

8 files changed

Lines changed: 26 additions & 0 deletions

src/gateway/hooks-policy.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway hook routing policy helpers.
2+
// Normalizes configured agent allowlists for hook dispatch.
13
import { normalizeAgentId } from "../routing/session-key.js";
24

35
// Hook policy config narrows hooks to explicit agent ids. A wildcard means no

src/gateway/hooks.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway hook payload type aliases.
2+
// Keeps hook-facing channel ids on public plugin channel contracts.
13
import type { ChannelId } from "../channels/plugins/types.public.js";
24

35
// Gateway hooks use public channel ids so hook payloads stay aligned with plugin

src/gateway/node-command-policy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway node command policy.
2+
// Computes per-platform allowlists from built-in, plugin, runtime, and config inputs.
13
import { normalizeOptionalLowercaseString } from "@openclaw/normalization-core/string-coerce";
24
import { normalizeUniqueStringEntries } from "@openclaw/normalization-core/string-normalization";
35
import type { OpenClawConfig } from "../config/types.openclaw.js";
@@ -292,6 +294,8 @@ function filterApprovedRuntimeCommands(params: {
292294
if (!isDesktopPlatformId(params.platformId)) {
293295
return [];
294296
}
297+
// Desktop host commands are not default-enabled for normal node sessions.
298+
// A live node can still expose approved commands from its runtime handshake.
295299
return params.commands.filter((command) => DESKTOP_HOST_COMMANDS.has(command.trim()));
296300
}
297301

@@ -338,6 +342,8 @@ function resolveNodeCommandAllowlistInternal(
338342
const extra = cfg.gateway?.nodes?.allowCommands ?? [];
339343
const deny = new Set(cfg.gateway?.nodes?.denyCommands ?? []);
340344
const dangerousPluginCommands = new Set(listDangerousPluginNodeCommands());
345+
// Dangerous plugin commands are excluded from plugin defaults. Explicit
346+
// gateway.nodes.allowCommands below can still opt them in for operators.
341347
const allow = new Set(
342348
[...base, ...talkCommands, ...pluginDefaults, ...approved, ...extra]
343349
.map((cmd) => cmd.trim())

src/gateway/node-invoke-plugin-policy.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Plugin-provided node.invoke policy adapter.
2+
// Lets plugin policies gate dangerous node commands before transport dispatch.
13
import { randomUUID } from "node:crypto";
24
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
35
import type { PluginApprovalRequestPayload } from "../infra/plugin-approvals.js";
@@ -86,6 +88,8 @@ function createApprovalRuntime(params: {
8688
record,
8789
excludeConnId: params.client?.connId,
8890
});
91+
// Approval requests are routed to eligible operator clients only. Falling
92+
// back to broadcast is safe because the event payload carries no secret.
8993
if (approvalClientConnIds) {
9094
params.context.broadcastToConnIds(
9195
"plugin.approval.requested",

src/gateway/node-invoke-sanitize.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Node invocation forwarding sanitizer.
2+
// Strips or validates gateway-only control fields before node transport.
13
import type { ExecApprovalManager } from "./exec-approval-manager.js";
24
import { sanitizeSystemRunParamsForForwarding } from "./node-invoke-system-run-approval.js";
35
import type { GatewayClient } from "./server-methods/types.js";

src/gateway/node-invoke-system-run-approval.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// system.run approval sanitizer.
2+
// Verifies forwarded node exec approvals against stored operator decisions.
13
import { asNullableRecord } from "@openclaw/normalization-core/record-coerce";
24
import { normalizeNullableString } from "@openclaw/normalization-core/string-coerce";
35
import {

src/gateway/resolve-configured-secret-input-string.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SecretRef-aware Gateway config string resolver.
2+
// Resolves configured secret inputs and fallback values without leaking values.
13
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
24
import type { OpenClawConfig } from "../config/types.openclaw.js";
35
import { resolveSecretInputRef } from "../config/types.secrets.js";
@@ -142,6 +144,8 @@ export async function resolveConfiguredSecretInputWithFallback(params: {
142144
if (!resolved.refConfigured) {
143145
const fallback = params.readFallback?.();
144146
if (fallback) {
147+
// Fallbacks are only returned after direct config is absent, preserving
148+
// explicit config precedence while still allowing credential stores.
145149
return {
146150
value: fallback,
147151
source: "fallback",
@@ -161,6 +165,8 @@ export async function resolveConfiguredSecretInputWithFallback(params: {
161165

162166
const fallback = params.readFallback?.();
163167
if (fallback) {
168+
// An unresolved SecretRef does not block fallback credentials. Callers get
169+
// both the source and secretRefConfigured flag for warning policy.
164170
return {
165171
value: fallback,
166172
source: "fallback",

src/gateway/secret-input-paths.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway secret-input path helpers.
2+
// Lists config locations that may contain plaintext values or SecretRefs.
13
import type { OpenClawConfig } from "../config/types.openclaw.js";
24

35
/** Canonical Gateway config paths whose values may be plaintext or secret refs. */

0 commit comments

Comments
 (0)