mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 22:10:43 +00:00
* fix(scripts): find codex protocol source from worktrees * fix(test): keep codex harness docker caches writable * fix(test): relax live codex cache mount permissions * test(codex): add live docker harness debug output * fix(test): detect numeric ci env in codex docker harness * fix(codex): skip duplicate agent-command telemetry * fix(tooling): skip sparse-missing oxlint tsconfig * fix(tooling): route changed checks through testbox * fix(qa): keep coverage json source-clean * fix(test): preflight codex docker auth * fix(codex): validate bind option values * fix(codex): parse quoted command arguments * fix(codex): reject extra control args * fix(codex): use content for blank bound prompts * fix(codex): decode local image file urls * fix(codex): treat local media urls as images * fix(codex): keep windows media paths local * fix(codex): reject malformed diagnostics confirmations * fix(codex): reject malformed resume commands * fix(codex): reject malformed thread actions * fix(codex): reject malformed turn controls * fix(codex): reject malformed model controls * fix(codex): resolve empty user input prompts * fix(codex): enforce user input options * fix(codex): reject ambiguous computer-use actions * fix(codex): ignore stale bound turn notifications * test(gateway): close task registries in gateway harness * test(gateway): route cleanup through task seams * fix(codex): describe current permission approvals * fix(codex): disclose command approval amendments * fix(codex): preserve approval detail under truncation * fix(codex): propagate dynamic tool failures * test(codex): align dynamic tool block contract * fix(codex): reject extra read-only command operands * fix(codex): escape command readout fields * fix(codex): escape status probe errors * fix(codex): narrow formatted thread details * fix(codex): escape successful status summaries * fix(codex): escape bound control replies * fix(codex): escape user input prompts * fix(codex): escape control failure replies * fix(codex): escape approval prompt text * test(codex): narrow escaped reply assertions * test(codex): complete strict reply fixtures * test(codex): preserve account fixture literals * test(codex): align status probe fixtures * fix(codex): satisfy sanitizer regex lint * fix(codex): harden command readouts * fix(codex): harden bound image inputs * fix(codex): sanitize command failure replies * test(codex): complete rate limit fixture * test(tooling): isolate postinstall compile cache fixture * fix(codex): keep app-server event ownership explicit --------- Co-authored-by: pashpashpash <nik@vault77.ai>
190 lines
5.8 KiB
TypeScript
190 lines
5.8 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { resolveCodexAppServerProtocolSource } from "./lib/codex-app-server-protocol-source.js";
|
|
|
|
const { sourceRoot: sourceSchemaRoot } = await resolveCodexAppServerProtocolSource(process.cwd());
|
|
const schemaRoot = path.join(sourceSchemaRoot, "typescript");
|
|
const generatedRoot = path.resolve(
|
|
process.cwd(),
|
|
"extensions/codex/src/app-server/protocol-generated",
|
|
);
|
|
|
|
const selectedJsonSchemas = [
|
|
"DynamicToolCallParams.json",
|
|
"v2/ErrorNotification.json",
|
|
"v2/GetAccountResponse.json",
|
|
"v2/ModelListResponse.json",
|
|
"v2/ThreadResumeResponse.json",
|
|
"v2/ThreadStartResponse.json",
|
|
"v2/TurnCompletedNotification.json",
|
|
"v2/TurnStartResponse.json",
|
|
] as const;
|
|
|
|
const checks: Array<{ file: string; snippets: string[] }> = [
|
|
{
|
|
file: "ServerRequest.ts",
|
|
snippets: [
|
|
'"item/commandExecution/requestApproval"',
|
|
'"item/fileChange/requestApproval"',
|
|
'"item/permissions/requestApproval"',
|
|
'"item/tool/call"',
|
|
],
|
|
},
|
|
{
|
|
file: "v2/ThreadItem.ts",
|
|
snippets: [
|
|
'"type": "contextCompaction"',
|
|
'"type": "dynamicToolCall"',
|
|
'"type": "commandExecution"',
|
|
'"type": "mcpToolCall"',
|
|
],
|
|
},
|
|
{
|
|
file: "v2/DynamicToolSpec.ts",
|
|
snippets: ["name: string", "description: string", "inputSchema: JsonValue"],
|
|
},
|
|
{
|
|
file: "v2/CommandExecutionApprovalDecision.ts",
|
|
snippets: ['"accept"', '"acceptForSession"', '"decline"', '"cancel"'],
|
|
},
|
|
{
|
|
file: "v2/Account.ts",
|
|
snippets: ['"type": "apiKey"', '"type": "chatgpt"', '"type": "amazonBedrock"'],
|
|
},
|
|
{
|
|
file: "v2/ThreadStartParams.ts",
|
|
snippets: [
|
|
"permissionProfile?: PermissionProfile | null",
|
|
"experimentalRawEvents: boolean",
|
|
"persistExtendedHistory: boolean",
|
|
],
|
|
},
|
|
{
|
|
file: "v2/TurnStartParams.ts",
|
|
snippets: ["permissionProfile?: PermissionProfile | null", "serviceTier?: ServiceTier | null"],
|
|
},
|
|
{
|
|
file: "ReviewDecision.ts",
|
|
snippets: ['"approved"', '"approved_for_session"', '"denied"', '"abort"'],
|
|
},
|
|
{
|
|
file: "v2/PlanDeltaNotification.ts",
|
|
snippets: ["itemId: string", "delta: string"],
|
|
},
|
|
{
|
|
file: "v2/TurnPlanUpdatedNotification.ts",
|
|
snippets: ["explanation: string | null", "plan: Array<TurnPlanStep>"],
|
|
},
|
|
];
|
|
|
|
const failures: string[] = [];
|
|
|
|
await compareGeneratedProtocolMirror();
|
|
|
|
for (const check of checks) {
|
|
const filePath = path.join(schemaRoot, check.file);
|
|
let text: string;
|
|
try {
|
|
text = await fs.readFile(filePath, "utf8");
|
|
} catch (error) {
|
|
failures.push(`${check.file}: missing (${String(error)})`);
|
|
continue;
|
|
}
|
|
for (const snippet of check.snippets) {
|
|
if (!text.includes(snippet)) {
|
|
failures.push(`${check.file}: missing ${snippet}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (failures.length > 0) {
|
|
console.error("Codex app-server generated protocol drift:");
|
|
for (const failure of failures) {
|
|
console.error(`- ${failure}`);
|
|
}
|
|
console.error(
|
|
`Run \`pnpm codex-app-server:protocol:sync\` after refreshing the Codex checkout at ${path.resolve(sourceSchemaRoot, "../../..")}.`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(
|
|
`Codex app-server generated protocol matches OpenClaw bridge assumptions: ${sourceSchemaRoot}`,
|
|
);
|
|
|
|
async function compareGeneratedProtocolMirror(): Promise<void> {
|
|
const sourceTsRoot = path.join(sourceSchemaRoot, "typescript");
|
|
const targetTsRoot = path.join(generatedRoot, "typescript");
|
|
const sourceFiles = await listFiles(sourceTsRoot, ".ts");
|
|
const targetFiles = await listFiles(targetTsRoot, ".ts");
|
|
const sourceSet = new Set(sourceFiles);
|
|
const targetSet = new Set(targetFiles);
|
|
|
|
for (const file of sourceFiles) {
|
|
if (!targetSet.has(file)) {
|
|
failures.push(`protocol-generated/typescript/${file}: missing local mirror`);
|
|
continue;
|
|
}
|
|
const source = normalizeGeneratedTypeScript(
|
|
await fs.readFile(path.join(sourceTsRoot, file), "utf8"),
|
|
);
|
|
const target = await fs.readFile(path.join(targetTsRoot, file), "utf8");
|
|
if (source !== target) {
|
|
failures.push(`protocol-generated/typescript/${file}: differs from normalized source schema`);
|
|
}
|
|
}
|
|
for (const file of targetFiles) {
|
|
if (!sourceSet.has(file)) {
|
|
failures.push(`protocol-generated/typescript/${file}: no longer present in source schema`);
|
|
}
|
|
}
|
|
|
|
for (const schema of selectedJsonSchemas) {
|
|
const sourcePath = path.join(sourceSchemaRoot, "json", schema);
|
|
const targetPath = path.join(generatedRoot, "json", schema);
|
|
let source: string;
|
|
let target: string;
|
|
try {
|
|
source = await fs.readFile(sourcePath, "utf8");
|
|
} catch (error) {
|
|
failures.push(
|
|
`protocol-generated/json/${schema}: missing upstream schema (${String(error)})`,
|
|
);
|
|
continue;
|
|
}
|
|
try {
|
|
target = await fs.readFile(targetPath, "utf8");
|
|
} catch (error) {
|
|
failures.push(`protocol-generated/json/${schema}: missing local schema (${String(error)})`);
|
|
continue;
|
|
}
|
|
if (source !== target) {
|
|
failures.push(`protocol-generated/json/${schema}: differs from source schema`);
|
|
}
|
|
}
|
|
}
|
|
|
|
async function listFiles(root: string, suffix: string): Promise<string[]> {
|
|
const files: string[] = [];
|
|
async function visit(dir: string): Promise<void> {
|
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
for (const entry of entries) {
|
|
const fullPath = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
await visit(fullPath);
|
|
} else if (entry.isFile() && entry.name.endsWith(suffix)) {
|
|
files.push(path.relative(root, fullPath));
|
|
}
|
|
}
|
|
}
|
|
await visit(root);
|
|
return files.toSorted();
|
|
}
|
|
|
|
function normalizeGeneratedTypeScript(text: string): string {
|
|
return text
|
|
.replace(/(from\s+["'])(\.{1,2}\/[^"']+?)(\.js)?(["'])/g, "$1$2.js$4")
|
|
.replace('export * as v2 from "./v2.js";', 'export * as v2 from "./v2/index.js";')
|
|
.replaceAll("| null | null", "| null");
|
|
}
|