fix: allow public code agent chat proxy

This commit is contained in:
Code Queue Review
2026-05-24 09:20:02 +00:00
parent 13e589641f
commit b63dd948dc
8 changed files with 160 additions and 19 deletions
+13 -6
View File
@@ -224,13 +224,14 @@ export async function buildM3IoControlSourceReport(options = {}) {
}
export async function runM3IoControlSourceChecks({ repoRoot: root = repoRoot } = {}) {
const [serverSource, jsonRpcSource, m3Source, appSource, htmlSource, artifactPublisherSource] = await Promise.all([
const [serverSource, jsonRpcSource, m3Source, appSource, htmlSource, artifactPublisherSource, cloudWebRouteSource] = await Promise.all([
readRepoText(root, "internal/cloud/server.mjs"),
readRepoText(root, "internal/cloud/json-rpc.mjs"),
readRepoText(root, "internal/cloud/m3-io-control.mjs"),
readRepoText(root, "web/hwlab-cloud-web/app.mjs"),
readRepoText(root, "web/hwlab-cloud-web/index.html"),
readRepoText(root, "scripts/dev-artifact-publish.mjs")
readRepoText(root, "scripts/dev-artifact-publish.mjs"),
readRepoText(root, "internal/dev-entrypoint/cloud-web-routes.mjs")
]);
const contract = describeM3IoControl({
@@ -241,7 +242,8 @@ export async function runM3IoControlSourceChecks({ repoRoot: root = repoRoot } =
const frontendGuardrails = checkFrontendNoDirectRuntimeCalls({
appSource,
htmlSource,
artifactPublisherSource
artifactPublisherSource,
cloudWebRouteSource
});
const requestSchema = validateExpectedRequestSchemas(expectedM3IoLiveSequence());
const responseSchema = validateM3IoSourceResponseContract(m3Source);
@@ -323,7 +325,7 @@ export async function runM3IoControlSourceChecks({ repoRoot: root = repoRoot } =
];
}
export function checkFrontendNoDirectRuntimeCalls({ appSource, htmlSource = "", artifactPublisherSource = "" }) {
export function checkFrontendNoDirectRuntimeCalls({ appSource, htmlSource = "", artifactPublisherSource = "", cloudWebRouteSource = "" }) {
const source = `${appSource}\n${htmlSource}`;
const fetchTargets = literalFetchTargets(appSource);
const issues = [];
@@ -382,10 +384,15 @@ export function checkFrontendNoDirectRuntimeCalls({ appSource, htmlSource = "",
issues.push(`m3ControlCanOperate must require ${label}`);
}
}
if (!/url\.pathname === "\/v1\/m3\/io"/u.test(artifactPublisherSource)) {
const artifactUsesCloudWebRoutePolicy = /cloudWebProxyRoutePolicy\(request\.method,\s*url\.pathname\)/u.test(artifactPublisherSource);
const routePolicyProxiesM3Io = artifactUsesCloudWebRoutePolicy &&
new RegExp(`"${escapeRegExp(M3_IO_CONTROL_ROUTE)}"`, "u").test(cloudWebRouteSource);
const routePolicyProxiesV1Status = artifactUsesCloudWebRoutePolicy &&
/const GET_PROXY_PREFIXES = Object\.freeze\(\["\/v1\/"\]\)/u.test(cloudWebRouteSource);
if (!routePolicyProxiesM3Io && !/url\.pathname === "\/v1\/m3\/io"/u.test(artifactPublisherSource)) {
issues.push("cloud-web artifact server must proxy same-origin /v1/m3/io to cloud-api");
}
if (!/\/v1\/m3\/status/u.test(artifactPublisherSource)) {
if (!routePolicyProxiesV1Status && !/\/v1\/m3\/status/u.test(artifactPublisherSource)) {
issues.push("cloud-web artifact server must proxy same-origin /v1/m3/status to cloud-api");
}