mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 17:53:39 +00:00
* refactor: remove TypeScript 6 from plugin runtime and tooling Keep source plugin loading on Jiti and native module transforms, move development analysis and declaration builds to TypeScript 7, and preserve captured loader and input ownership contracts. Scaffolds compile to the same entry path without shipping a compiler in production. * refactor: use native checker for restart preflight detection * fix: keep test-directory docs out of native helper scans * fix: preserve native compiler tooling across CI runtimes Keep compiler-backed tests on the supported Node transport, preserve declared Windows aliases and partial-source analysis, and bind relocated SDK reports to their installed compiler. Retain strict package input admission and the existing fixture assertions. * test: compare messaging guard diagnostics without sorting * fix: bound native tooling memory and preserve bootstrap loading * fix: bound native declaration builds with tsdown scheduling * fix: retire compiler-only helpers from installed packages * test: migrate routing import scan to native parser * test(ui): wait for recovered model catalog receipt
97 lines
2.7 KiB
TypeScript
97 lines
2.7 KiB
TypeScript
#!/usr/bin/env node
|
|
|
|
// Checks pairing config logic for account-scoped allowlist handling.
|
|
import * as ts from "typescript/unstable/ast";
|
|
import { createPairingGuardContext } from "./lib/pairing-guard-context.mts";
|
|
import {
|
|
collectFileViolations,
|
|
getPropertyNameText,
|
|
runAsScript,
|
|
toLine,
|
|
} from "./lib/ts-guard-utils.mts";
|
|
|
|
const { repoRoot, sourceRoots } = createPairingGuardContext(import.meta.url);
|
|
|
|
function isUndefinedLikeExpression(node: ts.Node) {
|
|
if (ts.isIdentifier(node) && node.text === "undefined") {
|
|
return true;
|
|
}
|
|
return node.kind === ts.SyntaxKind.NullKeyword;
|
|
}
|
|
|
|
function hasRequiredAccountIdProperty(node: ts.Node) {
|
|
if (!ts.isObjectLiteralExpression(node)) {
|
|
return false;
|
|
}
|
|
for (const property of node.properties) {
|
|
if (
|
|
ts.isShorthandPropertyAssignment(property) &&
|
|
ts.isIdentifier(property.name) &&
|
|
property.name.text === "accountId"
|
|
) {
|
|
return true;
|
|
}
|
|
if (!ts.isPropertyAssignment(property)) {
|
|
continue;
|
|
}
|
|
if (getPropertyNameText(property.name) !== "accountId") {
|
|
continue;
|
|
}
|
|
if (isUndefinedLikeExpression(property.initializer)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function findViolations(_content: string, _filePath: string, sourceFile: ts.SourceFile) {
|
|
const violations: { line: number; reason: string }[] = [];
|
|
|
|
const visit = (node: ts.Node): void => {
|
|
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
|
|
const callName = node.expression.text;
|
|
if (callName === "readChannelAllowFromStore") {
|
|
const accountIdArgument = node.arguments[2];
|
|
if (!accountIdArgument || isUndefinedLikeExpression(accountIdArgument)) {
|
|
violations.push({
|
|
line: toLine(sourceFile, node),
|
|
reason: "readChannelAllowFromStore call must pass explicit accountId as 3rd arg",
|
|
});
|
|
}
|
|
} else if (callName === "upsertChannelPairingRequest") {
|
|
const firstArg = node.arguments[0];
|
|
if (!firstArg || !hasRequiredAccountIdProperty(firstArg)) {
|
|
violations.push({
|
|
line: toLine(sourceFile, node),
|
|
reason: "upsertChannelPairingRequest call must include accountId in params",
|
|
});
|
|
}
|
|
}
|
|
}
|
|
node.forEachChild(visit);
|
|
};
|
|
|
|
visit(sourceFile);
|
|
return violations;
|
|
}
|
|
|
|
async function main() {
|
|
const violations = await collectFileViolations({
|
|
sourceRoots,
|
|
repoRoot,
|
|
findViolations,
|
|
});
|
|
|
|
if (violations.length === 0) {
|
|
return;
|
|
}
|
|
|
|
console.error("Found unscoped pairing-store calls:");
|
|
for (const violation of violations) {
|
|
console.error(`- ${violation.path}:${violation.line} (${violation.reason})`);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
|
|
runAsScript(import.meta.url, main);
|