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,2 @@
// Web Content Core public barrel exports the package API surface.
export * from "./provider-runtime-shared.js";

View File

@@ -0,0 +1,127 @@
// Web Content Core tests cover provider runtime shared behavior.
import { describe, expect, it } from "vitest";
import {
hasWebProviderEntryCredential,
readWebProviderEnvValue,
resolveWebProviderConfig,
resolveWebProviderDefinition,
} from "./provider-runtime-shared.js";
describe("resolveWebProviderConfig", () => {
it("selects the requested web tool config", () => {
const search = { provider: "search-provider" };
expect(
resolveWebProviderConfig(
{
tools: {
web: {
search,
},
},
},
"search",
),
).toBe(search);
});
});
describe("readWebProviderEnvValue", () => {
it("normalizes env credentials before returning them", () => {
expect(readWebProviderEnvValue(["API_KEY"], { API_KEY: " key\r\nvalue🙂 " })).toBe("keyvalue");
});
it("strips embedded controls from env credentials while preserving ordinary spaces", () => {
expect(readWebProviderEnvValue(["API_KEY"], { API_KEY: " sk-\u0000ab\tc\u007f\u0085 " })).toBe(
"sk-abc",
);
expect(readWebProviderEnvValue(["API_KEY"], { API_KEY: " Bearer token value " })).toBe(
"Bearer token value",
);
});
});
describe("hasWebProviderEntryCredential", () => {
const provider = {
id: "custom",
envVars: ["CUSTOM_API_KEY"],
};
it("treats non-env secret refs as configured credentials", () => {
expect(
hasWebProviderEntryCredential({
provider,
config: {},
toolConfig: undefined,
resolveRawValue: () => ({
source: "file",
provider: "mounted-json",
id: "/custom/apiKey",
}),
resolveEnvValue: () => undefined,
}),
).toBe(true);
});
it("resolves env secret ref ids through the env resolver", () => {
expect(
hasWebProviderEntryCredential({
provider,
config: {},
toolConfig: undefined,
resolveRawValue: () => ({
source: "env",
provider: "default",
id: "CUSTOM_API_KEY",
}),
resolveEnvValue: ({ configuredEnvVarId }) =>
configuredEnvVarId === "CUSTOM_API_KEY" ? "secret" : undefined,
}),
).toBe(true);
});
it("falls back to provider auth before env probing", () => {
expect(
hasWebProviderEntryCredential({
provider: {
...provider,
authProviderId: "custom-auth",
},
config: {},
toolConfig: undefined,
resolveRawValue: () => undefined,
resolveEnvValue: () => undefined,
resolveProviderAuthValue: (providerId) => providerId === "custom-auth",
}),
).toBe(true);
});
});
describe("resolveWebProviderDefinition", () => {
it("falls back to auto-detect when runtime metadata has no selected provider", () => {
const resolved = resolveWebProviderDefinition({
config: {},
toolConfig: { enabled: true },
runtimeMetadata: {},
providers: [
{
id: "custom",
},
],
resolveEnabled: () => true,
resolveAutoProviderId: () => "custom",
createTool: ({ provider }) => ({
name: provider.id,
}),
});
expect(resolved).toEqual({
provider: {
id: "custom",
},
definition: {
name: "custom",
},
});
});
});

View File

@@ -0,0 +1,308 @@
// Web Content Core module implements provider runtime shared behavior.
export type WebProviderConfigSource = {
tools?: {
web?: {
search?: unknown;
fetch?: unknown;
};
};
};
type SecretRefSource = "env" | "file" | "exec";
type SecretRef = {
source: SecretRefSource;
provider: string;
id: string;
};
const DEFAULT_SECRET_PROVIDER_ALIAS = "default";
const ENV_SECRET_REF_ID_RE = /^[A-Z][A-Z0-9_]{0,127}$/;
const LEGACY_SECRETREF_ENV_MARKER_PREFIX = "secretref-env:";
const LEGACY_DOUBLE_UNDERSCORE_ENV_MARKER_PREFIX = "__env__:";
const ENV_SECRET_TEMPLATE_RE = /^\$\{([A-Z][A-Z0-9_]{0,127})\}$/;
const ENV_SECRET_SHORTHAND_RE = /^\$([A-Z][A-Z0-9_]{0,127})$/;
type RuntimeWebProviderMetadata = {
providerConfigured?: string;
selectedProvider?: string;
};
type ProviderWithCredential = {
envVars: string[];
authProviderId?: string;
requiresCredential?: boolean;
};
type WebContentProcessEnv = Record<string, string | undefined>;
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function normalizeSecretInputString(value: unknown): string | undefined {
if (typeof value !== "string") {
return undefined;
}
const trimmed = value.trim();
return trimmed.length > 0 ? trimmed : undefined;
}
function normalizeSecretInput(value: unknown): string {
if (typeof value !== "string") {
return "";
}
const collapsed = value.replace(/[\r\n\u2028\u2029]+/g, "");
let latin1Only = "";
for (const char of collapsed) {
const codePoint = char.codePointAt(0);
const isControl =
typeof codePoint === "number" &&
((codePoint >= 0x00 && codePoint <= 0x1f) ||
codePoint === 0x7f ||
(codePoint >= 0x80 && codePoint <= 0x9f));
if (typeof codePoint === "number" && codePoint <= 0xff && !isControl) {
latin1Only += char;
}
}
return latin1Only.trim();
}
function isSecretRef(value: unknown): value is SecretRef {
if (!isRecord(value)) {
return false;
}
if (Object.keys(value).length !== 3) {
return false;
}
return (
(value.source === "env" || value.source === "file" || value.source === "exec") &&
typeof value.provider === "string" &&
value.provider.trim().length > 0 &&
typeof value.id === "string" &&
value.id.trim().length > 0
);
}
function coerceSecretRef(value: unknown): SecretRef | null {
if (isSecretRef(value)) {
return value;
}
if (typeof value === "string") {
const trimmed = value.trim();
const legacyPrefix = trimmed.startsWith(LEGACY_SECRETREF_ENV_MARKER_PREFIX)
? LEGACY_SECRETREF_ENV_MARKER_PREFIX
: trimmed.startsWith(LEGACY_DOUBLE_UNDERSCORE_ENV_MARKER_PREFIX)
? LEGACY_DOUBLE_UNDERSCORE_ENV_MARKER_PREFIX
: undefined;
if (legacyPrefix) {
const id = trimmed.slice(legacyPrefix.length);
return ENV_SECRET_REF_ID_RE.test(id)
? { source: "env", provider: DEFAULT_SECRET_PROVIDER_ALIAS, id }
: null;
}
const match = ENV_SECRET_TEMPLATE_RE.exec(trimmed) ?? ENV_SECRET_SHORTHAND_RE.exec(trimmed);
return match ? { source: "env", provider: DEFAULT_SECRET_PROVIDER_ALIAS, id: match[1] } : null;
}
if (
isRecord(value) &&
(value.source === "env" || value.source === "file" || value.source === "exec") &&
typeof value.id === "string" &&
value.id.trim().length > 0 &&
value.provider === undefined
) {
return {
source: value.source,
provider: DEFAULT_SECRET_PROVIDER_ALIAS,
id: value.id,
};
}
return null;
}
export function resolveWebProviderConfig(
cfg: WebProviderConfigSource | undefined,
kind: "search" | "fetch",
): Record<string, unknown> | undefined {
const webConfig = cfg?.tools?.web;
if (!webConfig || typeof webConfig !== "object") {
return undefined;
}
const toolConfig = webConfig[kind];
if (!toolConfig || typeof toolConfig !== "object") {
return undefined;
}
return toolConfig as Record<string, unknown>;
}
export function readWebProviderEnvValue(
envVars: string[],
processEnv: WebContentProcessEnv = process.env,
): string | undefined {
for (const envVar of envVars) {
const value = normalizeSecretInput(processEnv[envVar]);
if (value) {
return value;
}
}
return undefined;
}
export function providerRequiresCredential(
provider: Pick<ProviderWithCredential, "requiresCredential">,
): boolean {
return provider.requiresCredential !== false;
}
export function hasWebProviderEntryCredential<
TProvider extends ProviderWithCredential,
TConfigSource extends WebProviderConfigSource,
TConfig extends Record<string, unknown> | undefined,
>(params: {
provider: TProvider;
config: TConfigSource | undefined;
toolConfig: TConfig;
resolveRawValue: (params: {
provider: TProvider;
config: TConfigSource | undefined;
toolConfig: TConfig;
}) => unknown;
resolveFallbackRawValue?: (params: {
provider: TProvider;
config: TConfigSource | undefined;
toolConfig: TConfig;
}) => unknown;
resolveEnvValue: (params: {
provider: TProvider;
configuredEnvVarId?: string;
}) => string | undefined;
resolveProviderAuthValue?: (providerId: string) => boolean;
}): boolean {
if (!providerRequiresCredential(params.provider)) {
return true;
}
const rawValue = params.resolveRawValue({
provider: params.provider,
config: params.config,
toolConfig: params.toolConfig,
});
const configuredRef = coerceSecretRef(rawValue);
if (configuredRef && configuredRef.source !== "env") {
return true;
}
const fromConfig = normalizeSecretInput(normalizeSecretInputString(rawValue));
if (fromConfig) {
return true;
}
if (
params.provider.authProviderId &&
params.resolveProviderAuthValue?.(params.provider.authProviderId)
) {
return true;
}
if (
params.resolveEnvValue({
provider: params.provider,
configuredEnvVarId: configuredRef?.source === "env" ? configuredRef.id : undefined,
})
) {
return true;
}
const fallbackRawValue = params.resolveFallbackRawValue?.({
provider: params.provider,
config: params.config,
toolConfig: params.toolConfig,
});
const fallbackRef = coerceSecretRef(fallbackRawValue);
if (fallbackRef && fallbackRef.source !== "env") {
return true;
}
const fallbackConfig = normalizeSecretInput(normalizeSecretInputString(fallbackRawValue));
if (fallbackConfig) {
return true;
}
return Boolean(
fallbackRef?.source === "env"
? params.resolveEnvValue({
provider: params.provider,
configuredEnvVarId: fallbackRef.id,
})
: undefined,
);
}
export function resolveWebProviderDefinition<
TProvider extends { id: string },
TConfigSource extends WebProviderConfigSource,
TConfig extends Record<string, unknown> | undefined,
TRuntimeMetadata extends RuntimeWebProviderMetadata,
TDefinition,
>(params: {
config: TConfigSource | undefined;
toolConfig: TConfig;
runtimeMetadata: TRuntimeMetadata | undefined;
sandboxed?: boolean;
providerId?: string;
providers: TProvider[];
resolveEnabled: (params: { toolConfig: TConfig; sandboxed?: boolean }) => boolean;
resolveAutoProviderId: (params: {
config: TConfigSource | undefined;
toolConfig: TConfig;
providers: TProvider[];
}) => string;
resolveFallbackProviderId?: (params: {
config: TConfigSource | undefined;
toolConfig: TConfig;
providers: TProvider[];
providerId: string;
}) => string | undefined;
createTool: (params: {
provider: TProvider;
config: TConfigSource | undefined;
toolConfig: TConfig;
runtimeMetadata: TRuntimeMetadata | undefined;
}) => TDefinition | null;
}): { provider: TProvider; definition: TDefinition } | null {
if (!params.resolveEnabled({ toolConfig: params.toolConfig, sandboxed: params.sandboxed })) {
return null;
}
const providers = params.providers.filter(Boolean);
if (providers.length === 0) {
return null;
}
const autoProviderId = params.resolveAutoProviderId({
config: params.config,
toolConfig: params.toolConfig,
providers,
});
const providerId =
params.providerId ?? params.runtimeMetadata?.selectedProvider ?? autoProviderId;
if (!providerId) {
return null;
}
const provider =
providers.find((entry) => entry.id === providerId) ??
providers.find(
(entry) =>
entry.id ===
params.resolveFallbackProviderId?.({
config: params.config,
toolConfig: params.toolConfig,
providers,
providerId,
}),
);
if (!provider) {
return null;
}
const definition = params.createTool({
provider,
config: params.config,
toolConfig: params.toolConfig,
runtimeMetadata: params.runtimeMetadata,
});
if (!definition) {
return null;
}
return { provider, definition };
}