mirror of
https://github.com/Heretek-AI/openclaw.git
synced 2026-07-19 18:53:33 -04:00
a9ae1a6778
Matrix Protocol: - docker-compose.matrix.yml: Dendrite homeserver + PostgreSQL + Nginx TLS - src/channels/plugins/matrix-channel.ts: OpenClaw plugin implementation - docs/matrix-triad-setup.md: Setup guide with auth scheme (@tm1-4:triad.local) MCP Server Integration: - docs/mcp-triad-integration.md: SearXNG, Playwright, GitHub MCP configs - docs/mcp-curiosity-mapping.md: Gap-to-capability mapping Node Sync Architecture: - src/services/node-sync-service.ts: WebSocket peer sync + presence detection - src/services/node-sync-service.test.ts: Unit tests - docs/node-sync-architecture.md: Architecture docs Triad Resilience: - scripts/triad-corruption-check.mjs: SQLite + log + config + git integrity - docs/triad-resilience.md: Recovery procedures - .secure/deployment-logs/README.md: Schema v2 - skills/triad-heartbeat/SKILL.md: Corruption check integration NPM Publish Workflow: - scripts/npm-publish.mjs: version, changelog, validate, publish, rollback - .github/workflows/npm-publish.yml: GitHub Actions with provenance - docs/npm-publish-guide.md: Complete documentation All deliverables tested in Docker before production.
52 lines
1.7 KiB
JavaScript
Executable File
52 lines
1.7 KiB
JavaScript
Executable File
// Triad Ledger Init — Creates SQLite consensus DB
|
|
// Usage: node scripts/init-triad-ledger.js
|
|
|
|
import fs from "fs";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
const auraPath = path.join(process.env.HOME || "/home/openclaw", ".openclaw", "workspace", ".aura");
|
|
const dbPath = path.join(auraPath, "consensus.db");
|
|
const schemaPath = path.join(__dirname, "..", "skills", "triad-heartbeat", "schema.sql");
|
|
|
|
// Ensure .aura exists
|
|
if (!fs.existsSync(auraPath)) {
|
|
fs.mkdirSync(auraPath, { recursive: true });
|
|
console.log(`✅ Created ${auraPath}`);
|
|
}
|
|
|
|
// Check if better-sqlite3 is available
|
|
let Database;
|
|
try {
|
|
Database = (await import("better-sqlite3")).default;
|
|
} catch {
|
|
console.log("⚠️ better-sqlite3 not installed. Install with: npm install better-sqlite3");
|
|
console.log("Creating schema SQL file for manual import...");
|
|
process.exit(0);
|
|
}
|
|
|
|
// Create DB
|
|
const db = new Database(dbPath);
|
|
console.log(`✅ Created ${dbPath}`);
|
|
|
|
// Read and execute schema
|
|
const schema = fs.readFileSync(schemaPath, "utf8");
|
|
db.exec(schema);
|
|
console.log("✅ Schema applied");
|
|
|
|
// Verify tables
|
|
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all();
|
|
console.log("✅ Tables:", tables.map((t) => t.name).join(", "));
|
|
|
|
// Insert initial state for TM-1
|
|
db.prepare(`
|
|
INSERT OR REPLACE INTO triad_state (node_id, last_heartbeat, git_hash, ledger_hash, sync_status)
|
|
VALUES ('TM-1', datetime('now'), 'pending', 'pending', 'initializing')
|
|
`).run();
|
|
console.log("✅ TM-1 state initialized");
|
|
|
|
db.close();
|
|
console.log("🦞 Triad ledger ready. Run on TM-2/TM-3 to join quorum.");
|