-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-ingress-agent-owner-context.mjs
More file actions
41 lines (36 loc) · 1.41 KB
/
check-ingress-agent-owner-context.mjs
File metadata and controls
41 lines (36 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node
import path from "node:path";
import ts from "typescript";
import { runCallsiteGuard } from "./lib/callsite-guard.mjs";
import {
collectCallExpressionLines,
runAsScript,
unwrapExpression,
} from "./lib/ts-guard-utils.mjs";
const sourceRoots = ["src/gateway", "extensions/discord/src/voice"];
const enforcedFiles = new Set([
"extensions/discord/src/voice/manager.ts",
"src/gateway/openai-http.ts",
"src/gateway/openresponses-http.ts",
"src/gateway/server-methods/agent.ts",
"src/gateway/server-node-events.ts",
]);
export function findLegacyAgentCommandCallLines(content, fileName = "source.ts") {
const sourceFile = ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true);
return collectCallExpressionLines(ts, sourceFile, (node) => {
const callee = unwrapExpression(node.expression);
return ts.isIdentifier(callee) && callee.text === "agentCommand" ? callee : null;
});
}
export async function main() {
await runCallsiteGuard({
importMetaUrl: import.meta.url,
sourceRoots,
findCallLines: findLegacyAgentCommandCallLines,
skipRelativePath: (relPath) => !enforcedFiles.has(relPath.replaceAll(path.sep, "/")),
header: "Found ingress callsites using local agentCommand() (must be explicit owner-aware):",
footer:
"Use agentCommandFromIngress(...) and pass senderIsOwner explicitly at ingress boundaries.",
});
}
runAsScript(import.meta.url, main);