Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled

Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11),
free to diverge. Tree copied sans upstream .git; upstream remote added for
future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19.
Preserves docs/ARCHITECTURE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
2026-07-05 09:36:54 +00:00
parent 3216769225
commit bedb527145
21108 changed files with 6010766 additions and 0 deletions

View File

@@ -0,0 +1,538 @@
// Signal tests cover approval native plugin behavior.
import type {
ExecApprovalRequest,
PluginApprovalRequest,
} from "openclaw/plugin-sdk/approval-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { describe, expect, it } from "vitest";
import {
shouldSuppressLocalSignalExecApprovalPrompt,
signalApprovalCapability,
} from "./approval-native.js";
type SignalConfig = NonNullable<NonNullable<OpenClawConfig["channels"]>["signal"]>;
function buildConfig(
params: {
signal?: Partial<SignalConfig>;
approvals?: OpenClawConfig["approvals"];
} = {},
): OpenClawConfig {
return {
channels: {
signal: {
enabled: true,
...params.signal,
},
},
approvals: params.approvals,
} as OpenClawConfig;
}
function buildExecRequest(
turnSourceTo: string,
overrides: Partial<ExecApprovalRequest["request"]> = {},
): ExecApprovalRequest {
return {
id: "exec-1",
request: {
command: "echo hi",
agentId: "main",
turnSourceChannel: "signal",
turnSourceTo,
turnSourceAccountId: "default",
sessionKey: `agent:main:signal:${turnSourceTo}`,
...overrides,
},
createdAtMs: 0,
expiresAtMs: 1000,
};
}
function buildPluginRequest(
turnSourceTo: string,
overrides: Partial<PluginApprovalRequest["request"]> = {},
): PluginApprovalRequest {
return {
id: "plugin:approval-1",
request: {
title: "Plugin approval",
description: "Allow plugin action",
agentId: "main",
turnSourceChannel: "signal",
turnSourceTo,
turnSourceAccountId: "default",
sessionKey: `agent:main:signal:${turnSourceTo}`,
...overrides,
},
createdAtMs: 0,
expiresAtMs: 1000,
};
}
function nativeShouldHandle(params: {
cfg: OpenClawConfig;
request: ExecApprovalRequest | PluginApprovalRequest;
accountId?: string | null;
}) {
return signalApprovalCapability.nativeRuntime?.availability.shouldHandle({
cfg: params.cfg,
accountId: params.accountId ?? "default",
context: {},
request: params.request,
});
}
function buildLocalApprovalPayload(
params: {
approvalKind?: "exec" | "plugin";
agentId?: string | null;
sessionKey?: string | null;
} = {},
) {
return {
text: "Approval required.",
channelData: {
execApproval: {
approvalId: params.approvalKind === "plugin" ? "plugin:approval-1" : "exec-1",
approvalSlug: params.approvalKind === "plugin" ? "plugin:approval-1" : "exec-1",
approvalKind: params.approvalKind ?? "exec",
agentId: params.agentId,
sessionKey: params.sessionKey,
},
},
};
}
describe("signal approval capability", () => {
it("does not enable exec or plugin native approvals from Signal readiness alone", () => {
const cfg = buildConfig();
const execRequest = buildExecRequest("+15551230000");
const pluginRequest = buildPluginRequest("+15551230000");
expect(
signalApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
approvalKind: "exec",
}),
).toEqual({ kind: "disabled" });
expect(
signalApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
approvalKind: "plugin",
}),
).toEqual({ kind: "disabled" });
expect(
signalApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
request: execRequest,
}).enabled,
).toBe(false);
expect(nativeShouldHandle({ cfg, request: execRequest })).toBe(false);
expect(nativeShouldHandle({ cfg, request: pluginRequest })).toBe(false);
});
it("allows session-mode exec delivery for matching Signal origins", () => {
const cfg = buildConfig({ approvals: { exec: { enabled: true } } });
const request = buildExecRequest("+15551230000");
expect(
signalApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
request,
}),
).toEqual({
enabled: true,
preferredSurface: "origin",
supportsOriginSurface: true,
supportsApproverDmSurface: false,
notifyOriginWhenDmOnly: true,
});
expect(nativeShouldHandle({ cfg, request })).toBe(true);
});
it("requires explicit approvers before delivering group-origin approvals", () => {
const cfg = buildConfig({ approvals: { exec: { enabled: true } } });
const request = buildExecRequest("group:g1");
expect(
signalApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
request,
}).enabled,
).toBe(false);
const withApprover = buildConfig({
signal: { allowFrom: ["+15551230000"] },
approvals: { exec: { enabled: true } },
});
expect(
signalApprovalCapability.native?.describeDeliveryCapabilities({
cfg: withApprover,
accountId: "default",
approvalKind: "exec",
request,
}).enabled,
).toBe(true);
});
it("keeps exec and plugin forwarding gates independent", () => {
const execOnly = buildConfig({ approvals: { exec: { enabled: true } } });
const pluginOnly = buildConfig({ approvals: { plugin: { enabled: true } } });
expect(nativeShouldHandle({ cfg: execOnly, request: buildPluginRequest("+15551230000") })).toBe(
false,
);
expect(nativeShouldHandle({ cfg: pluginOnly, request: buildExecRequest("+15551230000") })).toBe(
false,
);
expect(
nativeShouldHandle({ cfg: pluginOnly, request: buildPluginRequest("+15551230000") }),
).toBe(true);
});
it("does not use session mode for non-Signal-origin requests", () => {
const cfg = buildConfig({ approvals: { exec: { enabled: true } } });
const request = buildExecRequest("", {
turnSourceChannel: "slack",
turnSourceTo: "C123",
sessionKey: "agent:main:slack:channel:c123",
});
expect(nativeShouldHandle({ cfg, request })).toBe(false);
expect(
signalApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
request,
}).enabled,
).toBe(false);
});
it("uses target-mode config for requestless availability without native runtime handling", () => {
const cfg = buildConfig({
signal: { allowFrom: ["+15551230000"] },
approvals: {
exec: {
enabled: true,
mode: "targets",
targets: [{ channel: "signal", to: "+15551230000" }],
},
},
});
const request = buildExecRequest("+15551230000");
expect(
signalApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
approvalKind: "exec",
}),
).toEqual({ kind: "enabled" });
expect(
signalApprovalCapability.nativeRuntime?.availability.isConfigured({
cfg,
accountId: "default",
context: {},
}),
).toBe(false);
expect(nativeShouldHandle({ cfg, request })).toBe(false);
expect(
signalApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
request,
}).enabled,
).toBe(false);
});
it("renders target-mode exec prompts without unbound reaction choices", () => {
const cfg = buildConfig({
signal: { allowFrom: ["+15551230000"] },
approvals: {
exec: {
enabled: true,
mode: "targets",
targets: [{ channel: "signal", to: "+15551230000" }],
},
},
});
const request = buildExecRequest("+15551230000", {
ask: "always",
cwd: "/tmp/work",
host: "gateway",
});
const payload = signalApprovalCapability.render?.exec?.buildPendingPayload?.({
cfg,
request,
target: { channel: "signal", to: "+15551230000", source: "target" },
nowMs: 0,
});
const text = payload?.text ?? "";
expect(text).toContain("/approve exec-1 allow-once");
expect(text).not.toContain("React with:");
expect(text).not.toContain("👍 Allow Once");
expect(text).not.toContain("👎 Deny");
expect(text).not.toContain("<id>");
expect(text).not.toContain("1⃣ Allow Once");
expect(text).not.toContain("2⃣ Allow Always");
expect(text).not.toContain("3⃣ Deny");
});
it("does not show reaction choices when Signal has no explicit approvers", () => {
const cfg = buildConfig({
approvals: {
exec: {
enabled: true,
mode: "targets",
targets: [{ channel: "signal", to: "+15551230000" }],
},
},
});
const request = buildExecRequest("+15551230000");
const payload = signalApprovalCapability.render?.exec?.buildPendingPayload?.({
cfg,
request,
target: { channel: "signal", to: "+15551230000", source: "target" },
nowMs: 0,
});
const text = payload?.text ?? "";
expect(text).toContain("/approve exec-1 allow-once");
expect(text).not.toContain("React with:");
expect(text).not.toContain("👍 Allow Once");
expect(text).not.toContain("👎 Deny");
});
it("normalizes equivalent Signal UUID target forms without suppressing generic target delivery", () => {
const cfg = buildConfig({
approvals: {
exec: {
enabled: true,
mode: "targets",
targets: [{ channel: "signal", to: "uuid:ABCDEF12-3456-7890-ABCD-EF1234567890" }],
},
},
});
const request = buildExecRequest("abcdef12-3456-7890-abcd-ef1234567890", {
turnSourceChannel: "slack",
turnSourceTo: "C123",
sessionKey: "agent:main:slack:channel:c123",
});
expect(
signalApprovalCapability.delivery?.shouldSuppressForwardingFallback?.({
cfg,
approvalKind: "exec",
request,
target: {
channel: "signal",
to: "abcdef12-3456-7890-abcd-ef1234567890",
source: "target",
},
}),
).toBe(false);
});
});
describe("shouldSuppressLocalSignalExecApprovalPrompt", () => {
const activeExecHint = {
kind: "approval-pending",
approvalKind: "exec",
nativeRouteActive: true,
} as const;
it("suppresses eligible session-mode exec approval prompts", () => {
const cfg = buildConfig({
signal: { allowFrom: ["+15551230000"] },
approvals: {
exec: {
enabled: true,
agentFilter: ["main"],
},
},
});
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg,
accountId: "default",
payload: buildLocalApprovalPayload({
agentId: null,
sessionKey: "agent:main:signal:+15551230000",
}),
hint: activeExecHint,
}),
).toBe(true);
});
it("keeps local prompts for disabled, ambiguous, or non-exec cases", () => {
const enabledConfig = buildConfig({
signal: { allowFrom: ["+15551230000"] },
approvals: { exec: { enabled: true } },
});
const payload = buildLocalApprovalPayload({
agentId: "main",
sessionKey: "agent:main:signal:+15551230000",
});
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg: buildConfig(),
payload,
hint: activeExecHint,
}),
).toBe(false);
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg: buildConfig({
signal: { allowFrom: ["+15551230000"] },
approvals: { exec: { enabled: false } },
}),
payload,
hint: activeExecHint,
}),
).toBe(false);
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg: buildConfig({
signal: { allowFrom: ["+15551230000"] },
approvals: {
exec: {
enabled: true,
mode: "targets",
targets: [{ channel: "signal", to: "+15551230000" }],
},
},
}),
payload,
hint: activeExecHint,
}),
).toBe(false);
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg: enabledConfig,
payload,
hint: { ...activeExecHint, nativeRouteActive: false },
}),
).toBe(false);
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg: enabledConfig,
payload: buildLocalApprovalPayload({ approvalKind: "plugin" }),
hint: activeExecHint,
}),
).toBe(false);
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg: enabledConfig,
payload: { text: "Approval required." },
hint: activeExecHint,
}),
).toBe(false);
});
it("suppresses direct same-chat Signal prompts without explicit approvers", () => {
const cfg = buildConfig({
approvals: { exec: { enabled: true } },
});
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg,
payload: buildLocalApprovalPayload({
agentId: "main",
sessionKey: "agent:main:signal:+15551230000",
}),
hint: activeExecHint,
}),
).toBe(true);
});
it("keeps no-approver local prompts for ambiguous or group Signal sessions", () => {
const cfg = buildConfig({
approvals: { exec: { enabled: true } },
});
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg,
payload: buildLocalApprovalPayload({
agentId: "main",
sessionKey: "agent:main:signal:group:test-group",
}),
hint: activeExecHint,
}),
).toBe(false);
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg,
payload: buildLocalApprovalPayload({
agentId: "main",
sessionKey: "agent:main:slack:C123",
}),
hint: activeExecHint,
}),
).toBe(false);
});
it("applies top-level approval filters with agent fallback from session key", () => {
const cfg = buildConfig({
signal: { allowFrom: ["+15551230000"] },
approvals: {
exec: {
enabled: true,
agentFilter: ["ops"],
sessionFilter: ["signal"],
},
},
});
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg,
payload: buildLocalApprovalPayload({
agentId: null,
sessionKey: "agent:ops:signal:+15551230000",
}),
hint: activeExecHint,
}),
).toBe(true);
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg,
payload: buildLocalApprovalPayload({
agentId: null,
sessionKey: "agent:main:signal:+15551230000",
}),
hint: activeExecHint,
}),
).toBe(false);
expect(
shouldSuppressLocalSignalExecApprovalPrompt({
cfg,
payload: buildLocalApprovalPayload({
agentId: null,
sessionKey: "agent:ops:slack:C123",
}),
hint: activeExecHint,
}),
).toBe(false);
});
});