Files
openclaw/scripts/e2e/cron-mcp-cleanup-seed.ts
Peter Steinberger edecdbd05e refactor(config): config-surface reduction tranche 3 — product consolidations (review request) (#111527)
* refactor(config): consolidate media model lists

* refactor(config): unify memory configuration

* refactor(config): consolidate TTS ownership

* refactor(config): move typing policy to agents

* refactor(config): retire product-level config surfaces

* refactor(config): share scoped tool policy type

* chore(config): refresh generated baselines

* fix(config): honor agent typing overrides

* fix(config): migrate sibling config consumers

* refactor(infra): keep base64url decoder private

* fix(config): strip invalid legacy TTS values

* chore(config): refresh rebased baseline hash

* fix(doctor): route legacy messages.tts.realtime voice to talk during tts move

* refactor(config): polish final layout names

* refactor(config): freeze retired tuning defaults

* feat(config): add fast mode default symmetry

* refactor(config): key agent entries by id

* docs(config): update final layout reference

* test(config): cover final layout migrations

* chore(config): refresh final layout baselines

* fix(config): align final layout runtime readers

* fix(config): align remaining readers

* fix(config): stabilize final layout migrations

* fix(config): finalize config projection proof

* fix(config): address final layout review

* docs(release): preserve historical config names

* fix(config): complete keyed agent migration

* fix(config): close final migration gaps

* fix(config): finish full-branch review

* fix(config): complete runtime secret detection

* fix(config): close final review findings

* fix(config): finish canonical docs and heartbeat migration

* fix(config): integrate latest main after rebase

* refactor(env): isolate test-only controls

* refactor(env): isolate build and development controls

* refactor(env): collapse process identity indirection

* refactor(env): remove duplicate config and temp aliases

* docs(env): define the operator-facing allowlist

* ci(env): ratchet production variable count

* fix(env): remove stale provider helper import

* fix(env): make ratchet sorting explicit

* test(env): keep test seam in dead-code audit

* test(env): cover ratchet growth and boundary; document surface budgets

* docs(config): document tier-eval consolidations

* docs(config): clarify speech preference ownership

* test(memory): align retired tuning fixtures

* refactor(memory): freeze engine heuristics

* refactor(config): apply tier-eval tranche

* refactor(tts): move persona shaping to providers

* refactor(compaction): move prompt policy to providers

* test(config): align hookified prompt fixtures

* chore(deadcode): classify test-only exports

* chore(github): remove unused spawn helper

* chore(deadcode): classify queue diagnostics

* chore(deadcode): remove unused lane snapshot export

* chore(plugin-sdk): ratchet consolidated surface

* fix(config): integrate latest main after rebase
2026-07-21 20:28:43 -07:00

135 lines
3.8 KiB
TypeScript

// Cron Mcp Cleanup Seed script supports OpenClaw repository automation.
import fs from "node:fs/promises";
import { createRequire } from "node:module";
import os from "node:os";
import path from "node:path";
import { applyDockerOpenAiProviderConfig, type OpenClawConfig } from "./docker-openai-seed.ts";
const require = createRequire(import.meta.url);
async function writeProbeServer(params: {
serverPath: string;
pidPath: string;
pidsPath: string;
exitPath: string;
}) {
const sdkMcpServerPath = require.resolve("@modelcontextprotocol/sdk/server/mcp.js");
const sdkStdioServerPath = require.resolve("@modelcontextprotocol/sdk/server/stdio.js");
await fs.writeFile(
params.serverPath,
`#!/usr/bin/env node
import fs from "node:fs";
import fsp from "node:fs/promises";
import { McpServer } from ${JSON.stringify(sdkMcpServerPath)};
import { StdioServerTransport } from ${JSON.stringify(sdkStdioServerPath)};
process.title = "openclaw-cron-mcp-cleanup-probe";
await fsp.mkdir(${JSON.stringify(path.dirname(params.pidPath))}, { recursive: true });
await fsp.writeFile(${JSON.stringify(params.pidPath)}, String(process.pid), "utf8");
await fsp.appendFile(${JSON.stringify(params.pidsPath)}, String(process.pid) + "\\n", "utf8");
process.once("exit", () => {
try {
fs.writeFileSync(${JSON.stringify(params.exitPath)}, "exited", "utf8");
} catch {}
});
for (const signal of ["SIGINT", "SIGTERM"]) {
process.once(signal, () => {
process.exit(0);
});
}
setInterval(() => {}, 1000);
const server = new McpServer({ name: "cron-mcp-cleanup-probe", version: "1.0.0" });
server.tool("cleanup_probe", "Cron MCP cleanup probe", async () => ({
content: [{ type: "text", text: "cron-mcp-cleanup-ok" }],
}));
await server.connect(new StdioServerTransport());
`,
{ encoding: "utf-8", mode: 0o755 },
);
}
async function main() {
const stateDir = process.env.OPENCLAW_STATE_DIR?.trim() || path.join(os.homedir(), ".openclaw");
const configPath =
process.env.OPENCLAW_CONFIG_PATH?.trim() || path.join(stateDir, "openclaw.json");
const probeDir = path.join(stateDir, "cron-mcp-cleanup");
const serverPath = path.join(probeDir, "probe-server.mjs");
const pidPath = path.join(probeDir, "probe.pid");
const pidsPath = path.join(probeDir, "probe.pids");
const exitPath = path.join(probeDir, "probe.exit");
await fs.mkdir(probeDir, { recursive: true });
await fs.mkdir(path.dirname(configPath), { recursive: true });
await fs.rm(pidPath, { force: true });
await fs.rm(pidsPath, { force: true });
await fs.rm(exitPath, { force: true });
await writeProbeServer({ serverPath, pidPath, pidsPath, exitPath });
const seededConfig = applyDockerOpenAiProviderConfig(
{
gateway: {
controlUi: {
enabled: false,
},
},
cron: {
enabled: false,
},
agents: {
defaults: {
heartbeat: {
every: "0m",
},
skipBootstrap: true,
contextInjection: "never",
skills: [],
subagents: {
runTimeoutSeconds: 8,
},
},
},
tools: {
profile: "coding",
alsoAllow: ["bundle-mcp"],
subagents: {
tools: {
alsoAllow: ["bundle-mcp"],
},
},
},
plugins: {
enabled: false,
},
mcp: {
servers: {
cronCleanupProbe: {
command: "node",
args: [serverPath],
cwd: probeDir,
},
},
},
} satisfies OpenClawConfig,
"sk-docker-cron-mcp-cleanup-test",
);
await fs.writeFile(configPath, `${JSON.stringify(seededConfig, null, 2)}\n`, "utf-8");
process.stdout.write(
JSON.stringify({
ok: true,
stateDir,
configPath,
serverPath,
pidPath,
pidsPath,
exitPath,
}) + "\n",
);
}
await main();