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
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:
162
scripts/generate-kysely-types.mjs
Normal file
162
scripts/generate-kysely-types.mjs
Normal file
@@ -0,0 +1,162 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Generates Kysely database types from the SQLite schema.
|
||||
import fs from "node:fs";
|
||||
import process from "node:process";
|
||||
import { DatabaseSync } from "node:sqlite";
|
||||
|
||||
const SCHEMAS = [
|
||||
{
|
||||
name: "openclaw-state",
|
||||
schema: "src/state/openclaw-state-schema.sql",
|
||||
outFile: "src/state/openclaw-state-db.generated.d.ts",
|
||||
schemaOutFile: "src/state/openclaw-state-schema.generated.ts",
|
||||
schemaExport: "OPENCLAW_STATE_SCHEMA_SQL",
|
||||
},
|
||||
{
|
||||
name: "openclaw-agent",
|
||||
schema: "src/state/openclaw-agent-schema.sql",
|
||||
outFile: "src/state/openclaw-agent-db.generated.d.ts",
|
||||
schemaOutFile: "src/state/openclaw-agent-schema.generated.ts",
|
||||
schemaExport: "OPENCLAW_AGENT_SCHEMA_SQL",
|
||||
},
|
||||
];
|
||||
|
||||
const verify = process.argv.includes("--verify") || process.argv.includes("--check");
|
||||
|
||||
function toInterfaceName(tableName) {
|
||||
return tableName
|
||||
.split("_")
|
||||
.map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`)
|
||||
.join("");
|
||||
}
|
||||
|
||||
function columnBaseType(columnTypeLocal) {
|
||||
const normalized = columnTypeLocal.toUpperCase();
|
||||
if (normalized.includes("BLOB")) {
|
||||
return "Uint8Array";
|
||||
}
|
||||
if (
|
||||
normalized.includes("INT") ||
|
||||
normalized.includes("REAL") ||
|
||||
normalized.includes("FLOA") ||
|
||||
normalized.includes("DOUB") ||
|
||||
normalized.includes("NUM") ||
|
||||
normalized.includes("DEC")
|
||||
) {
|
||||
return "number";
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
function columnType(column, primaryKeyColumnCount) {
|
||||
const baseType = columnBaseType(String(column.type ?? ""));
|
||||
const generated =
|
||||
column.dflt_value != null ||
|
||||
(primaryKeyColumnCount === 1 &&
|
||||
Number(column.pk) > 0 &&
|
||||
String(column.type ?? "")
|
||||
.toUpperCase()
|
||||
.includes("INT"));
|
||||
const nullable = Number(column.notnull) !== 1 && !generated;
|
||||
const valueType = nullable ? `${baseType} | null` : baseType;
|
||||
return generated ? `Generated<${valueType}>` : valueType;
|
||||
}
|
||||
|
||||
function quoteSqliteIdentifier(identifier) {
|
||||
return `"${identifier.replaceAll('"', '""')}"`;
|
||||
}
|
||||
|
||||
function generateTypes(db) {
|
||||
const tables = db
|
||||
.prepare(
|
||||
"SELECT name FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%' ORDER BY name;",
|
||||
)
|
||||
.all()
|
||||
.map((row) => String(row.name));
|
||||
const lines = [
|
||||
"/**",
|
||||
" * This file was generated by kysely-codegen.",
|
||||
" * Please do not edit it manually.",
|
||||
" */",
|
||||
"",
|
||||
'import type { ColumnType } from "kysely";',
|
||||
"",
|
||||
"export type Generated<T> =",
|
||||
" T extends ColumnType<infer S, infer I, infer U>",
|
||||
" ? ColumnType<S, I | undefined, U>",
|
||||
" : ColumnType<T, T | undefined, T>;",
|
||||
"",
|
||||
];
|
||||
|
||||
const interfaces = [];
|
||||
for (const table of tables) {
|
||||
const interfaceName = toInterfaceName(table);
|
||||
interfaces.push({ interfaceName, table });
|
||||
lines.push(`export interface ${interfaceName} {`);
|
||||
const columns = db
|
||||
.prepare(`PRAGMA table_xinfo(${quoteSqliteIdentifier(table)});`)
|
||||
.all()
|
||||
.filter((column) => Number(column.hidden) === 0)
|
||||
.toSorted((left, right) => String(left.name).localeCompare(String(right.name)));
|
||||
const primaryKeyColumnCount = columns.filter((column) => Number(column.pk) > 0).length;
|
||||
for (const column of columns) {
|
||||
lines.push(` ${column.name}: ${columnType(column, primaryKeyColumnCount)};`);
|
||||
}
|
||||
lines.push("}", "");
|
||||
}
|
||||
|
||||
lines.push("export interface DB {");
|
||||
for (const { interfaceName, table } of interfaces) {
|
||||
lines.push(` ${table}: ${interfaceName};`);
|
||||
}
|
||||
lines.push("}", "");
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
function readUtf8(file) {
|
||||
return fs.readFileSync(file, "utf8");
|
||||
}
|
||||
|
||||
function generatedSchemaModule(schema) {
|
||||
const source = readUtf8(schema.schema).trimEnd();
|
||||
const literal = source.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${");
|
||||
return [
|
||||
"/**",
|
||||
" * This file was generated from the SQLite schema source.",
|
||||
" * Please do not edit it manually.",
|
||||
" */",
|
||||
"",
|
||||
`export const ${schema.schemaExport} = \`${literal}\\n\`;`,
|
||||
"",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
function generate(schema) {
|
||||
const db = new DatabaseSync(":memory:");
|
||||
try {
|
||||
db.exec(readUtf8(schema.schema));
|
||||
const typesSource = generateTypes(db);
|
||||
const schemaSource = generatedSchemaModule(schema);
|
||||
|
||||
if (verify) {
|
||||
if (typesSource !== readUtf8(schema.outFile)) {
|
||||
console.error(`${schema.outFile} is out of date. Run pnpm db:kysely:gen.`);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
if (schemaSource !== readUtf8(schema.schemaOutFile)) {
|
||||
console.error(`${schema.schemaOutFile} is out of date. Run pnpm db:kysely:gen.`);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
} else {
|
||||
fs.writeFileSync(schema.outFile, typesSource);
|
||||
fs.writeFileSync(schema.schemaOutFile, schemaSource);
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
||||
for (const schema of SCHEMAS) {
|
||||
generate(schema);
|
||||
}
|
||||
Reference in New Issue
Block a user