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,324 @@
// Memory Lancedb helper module supports config behavior.
import fs from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
import { parseFiniteNumber } from "openclaw/plugin-sdk/number-runtime";
export type MemoryConfig = {
embedding: {
provider: string;
model: string;
apiKey?: string;
baseUrl?: string;
dimensions?: number;
};
dreaming?: Record<string, unknown>;
dbPath?: string;
autoCapture?: boolean;
autoRecall?: boolean;
captureMaxChars?: number;
customTriggers?: string[];
recallMaxChars?: number;
storageOptions?: Record<string, string>;
};
export const MEMORY_CATEGORIES = ["preference", "fact", "decision", "entity", "other"] as const;
export type MemoryCategory = (typeof MEMORY_CATEGORIES)[number];
const DEFAULT_MODEL = "text-embedding-3-small";
export const DEFAULT_CAPTURE_MAX_CHARS = 500;
export const DEFAULT_RECALL_MAX_CHARS = 1000;
const LEGACY_STATE_DIRS: string[] = [];
function resolveDefaultDbPath(): string {
const home = homedir();
const preferred = join(home, ".openclaw", "memory", "lancedb");
try {
if (fs.existsSync(preferred)) {
return preferred;
}
} catch {
// best-effort
}
for (const legacy of LEGACY_STATE_DIRS) {
const candidate = join(home, legacy, "memory", "lancedb");
try {
if (fs.existsSync(candidate)) {
return candidate;
}
} catch {
// best-effort
}
}
return preferred;
}
const DEFAULT_DB_PATH = resolveDefaultDbPath();
const EMBEDDING_DIMENSIONS: Record<string, number> = {
"text-embedding-3-small": 1536,
"text-embedding-3-large": 3072,
};
const EMBEDDING_CONFIG_KEYS = ["provider", "apiKey", "model", "baseUrl", "dimensions"] as const;
function assertAllowedKeys(value: Record<string, unknown>, allowed: string[], label: string) {
const unknown = Object.keys(value).filter((key) => !allowed.includes(key));
if (unknown.length === 0) {
return;
}
throw new Error(`${label} has unknown keys: ${unknown.join(", ")}`);
}
export function vectorDimsForModel(model: string): number {
const dims = EMBEDDING_DIMENSIONS[model];
if (!dims) {
throw new Error(`Unsupported embedding model: ${model}`);
}
return dims;
}
function resolveEnvVars(value: string): string {
return value.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
const envValue = process.env[envVar];
if (!envValue) {
throw new Error(`Environment variable ${envVar} is not set`);
}
return envValue;
});
}
function resolveEmbeddingModel(
embedding: Record<string, unknown>,
dimensions: number | undefined,
): string {
const model = typeof embedding.model === "string" ? embedding.model : DEFAULT_MODEL;
if (dimensions === undefined) {
vectorDimsForModel(model);
}
return model;
}
function resolveFiniteIntegerConfig(value: unknown): number | undefined {
if (typeof value !== "number") {
return undefined;
}
const parsed = parseFiniteNumber(value);
return parsed === undefined ? undefined : Math.floor(parsed);
}
function resolveBoundedIntegerConfig(params: {
value: unknown;
fallback: number;
min: number;
max: number;
label: string;
}): number {
const resolved = resolveFiniteIntegerConfig(params.value) ?? params.fallback;
if (resolved < params.min || resolved > params.max) {
throw new Error(`${params.label} must be between ${params.min} and ${params.max}`);
}
return resolved;
}
function resolveEmbeddingDimensions(embedding: Record<string, unknown>): number | undefined {
if (embedding.dimensions === undefined) {
return undefined;
}
const dimensions =
typeof embedding.dimensions === "number" ? parseFiniteNumber(embedding.dimensions) : undefined;
if (dimensions === undefined || !Number.isInteger(dimensions) || dimensions < 1) {
throw new Error("embedding.dimensions must be a positive integer");
}
return dimensions;
}
export const memoryConfigSchema = {
parse(value: unknown): MemoryConfig {
if (!value || typeof value !== "object" || Array.isArray(value)) {
throw new Error("memory config required");
}
const cfg = value as Record<string, unknown>;
assertAllowedKeys(
cfg,
[
"embedding",
"dreaming",
"dbPath",
"autoCapture",
"autoRecall",
"captureMaxChars",
"customTriggers",
"recallMaxChars",
"storageOptions",
],
"memory config",
);
const embedding = cfg.embedding as Record<string, unknown> | undefined;
if (!embedding || typeof embedding !== "object" || Array.isArray(embedding)) {
throw new Error("embedding config required");
}
assertAllowedKeys(embedding, [...EMBEDDING_CONFIG_KEYS], "embedding config");
if (Object.keys(embedding).length === 0) {
throw new Error("embedding config must include at least one setting");
}
const dimensions = resolveEmbeddingDimensions(embedding);
const model = resolveEmbeddingModel(embedding, dimensions);
const provider = typeof embedding.provider === "string" ? embedding.provider.trim() : "openai";
if (!provider) {
throw new Error("embedding.provider must not be empty");
}
const captureMaxChars = resolveBoundedIntegerConfig({
value: cfg.captureMaxChars,
fallback: DEFAULT_CAPTURE_MAX_CHARS,
min: 100,
max: 10_000,
label: "captureMaxChars",
});
const recallMaxChars = resolveBoundedIntegerConfig({
value: cfg.recallMaxChars,
fallback: DEFAULT_RECALL_MAX_CHARS,
min: 100,
max: 10_000,
label: "recallMaxChars",
});
let customTriggers: string[] | undefined;
if (cfg.customTriggers !== undefined) {
if (!Array.isArray(cfg.customTriggers)) {
throw new Error("customTriggers must be an array of strings");
}
customTriggers = cfg.customTriggers.map((trigger, index) => {
if (typeof trigger !== "string") {
throw new Error(`customTriggers.${index} must be a string`);
}
const normalized = trigger.trim();
if (!normalized) {
throw new Error(`customTriggers.${index} must not be empty`);
}
if (normalized.length > 100) {
throw new Error(`customTriggers.${index} must be at most 100 characters`);
}
return normalized;
});
if (customTriggers.length > 50) {
throw new Error("customTriggers must include at most 50 entries");
}
}
const dreaming =
cfg.dreaming === undefined
? undefined
: cfg.dreaming && typeof cfg.dreaming === "object" && !Array.isArray(cfg.dreaming)
? (cfg.dreaming as Record<string, unknown>)
: (() => {
throw new Error("dreaming config must be an object");
})();
// Parse storageOptions (object with string values)
let storageOptions: Record<string, string> | undefined;
const storageOpts = cfg.storageOptions as Record<string, unknown> | undefined;
if (storageOpts !== undefined && storageOpts !== null) {
if (!storageOpts || typeof storageOpts !== "object" || Array.isArray(storageOpts)) {
throw new Error("storageOptions must be an object");
}
storageOptions = {};
// Validate all values are strings
for (const [key, valueLocal] of Object.entries(storageOpts)) {
if (typeof valueLocal !== "string") {
throw new Error(`storageOptions.${key} must be a string`);
}
storageOptions[key] = resolveEnvVars(valueLocal);
}
}
return {
embedding: {
provider,
model,
apiKey: typeof embedding.apiKey === "string" ? resolveEnvVars(embedding.apiKey) : undefined,
baseUrl:
typeof embedding.baseUrl === "string" ? resolveEnvVars(embedding.baseUrl) : undefined,
dimensions,
},
dreaming,
dbPath: typeof cfg.dbPath === "string" ? cfg.dbPath : DEFAULT_DB_PATH,
autoCapture: cfg.autoCapture === true,
autoRecall: cfg.autoRecall !== false,
captureMaxChars,
...(customTriggers ? { customTriggers } : {}),
recallMaxChars,
...(storageOptions ? { storageOptions } : {}),
};
},
uiHints: {
"embedding.provider": {
label: "Embedding Provider",
placeholder: "openai",
help: "Memory embedding provider adapter to use (for example openai, github-copilot, ollama)",
},
"embedding.apiKey": {
label: "OpenAI API Key",
sensitive: true,
placeholder: "sk-proj-...",
help: "Optional API key override for OpenAI-compatible embeddings; omit to use configured provider auth",
},
"embedding.baseUrl": {
label: "Base URL",
placeholder: "https://api.openai.com/v1",
help: "Optional provider or OpenAI-compatible embedding endpoint base URL",
advanced: true,
},
"embedding.dimensions": {
label: "Dimensions",
placeholder: "1536",
help: "Vector dimensions for custom models (required for non-standard models)",
advanced: true,
},
"embedding.model": {
label: "Embedding Model",
placeholder: DEFAULT_MODEL,
help: "OpenAI embedding model to use",
},
dbPath: {
label: "Database Path",
placeholder: "~/.openclaw/memory/lancedb",
advanced: true,
help: "Local filesystem path or cloud storage URI (s3://, gs://) for LanceDB database",
},
autoCapture: {
label: "Auto-Capture",
help: "Automatically capture important information from conversations",
},
autoRecall: {
label: "Auto-Recall",
help: "Automatically inject relevant memories into context",
},
captureMaxChars: {
label: "Capture Max Chars",
help: "Maximum message length eligible for auto-capture",
advanced: true,
placeholder: String(DEFAULT_CAPTURE_MAX_CHARS),
},
customTriggers: {
label: "Custom Triggers",
help: "Literal phrases that should make auto-capture consider a message memory-worthy",
advanced: true,
},
recallMaxChars: {
label: "Recall Query Max Chars",
help: "Maximum prompt/query length embedded for memory recall. Lower for small local embedding models.",
advanced: true,
placeholder: String(DEFAULT_RECALL_MAX_CHARS),
},
storageOptions: {
label: "Storage Options",
sensitive: true,
advanced: true,
help: "Storage configuration options (access_key, secret_key, endpoint, etc.); supports ${ENV_VAR} values",
},
},
};