fix(studio): keep AI provider and model details private

This commit is contained in:
Clintchiz committed 2026-10-19 23:20:50 +05:30
1 parent 5aec369054
commit 6d0c47fba7
5 files changed
+65 -51

No files matched your search

+16 -16
View File
@@ -18,23 +18,21 @@ type FailureKind =
| "response"
| "request";
const failureMessages: Record<FailureKind, string> = {
auth: "APIMart rejected the server API key. Check APIMART_API_KEY and its permissions, then restart the app.",
auth: "AI generation is unavailable due to a server configuration issue. Contact the site administrator.",
quota:
"APIMart reports insufficient credit or quota. Check the provider account balance and limits.",
"AI generation has reached its service usage limit. Try again later or contact the site administrator.",
model:
"APIMart could not access the configured model. Check that this model is enabled for the server API key.",
rate: "APIMart is rate limiting requests. Wait a minute and generate again.",
unavailable:
"APIMart is temporarily unavailable. Try generating again shortly.",
network:
"The server could not reach APIMart. Check the VM's outbound HTTPS connection and try again.",
"AI generation is unavailable due to a server configuration issue. Contact the site administrator.",
rate: "AI generation is rate limiting requests. Wait a minute and generate again.",
unavailable: "AI generation is temporarily unavailable. Try again shortly.",
network: "The server could not reach the AI service. Try again shortly.",
truncated:
"APIMart stopped before completing all design alternatives. Try a shorter brief or generate again.",
filtered: "APIMart declined this generation. Revise the brief and try again.",
response:
"APIMart returned an empty or unreadable completion. Try generating again.",
"AI generation stopped before completing all design alternatives. Try a shorter brief or generate again.",
filtered:
"This generation could not be completed. Revise the brief and try again.",
response: "AI generation returned an empty or unreadable result. Try again.",
request:
"APIMart rejected the completion request. Check the provider's model configuration.",
"AI generation could not process this request. Try again or contact the site administrator.",
};
class APIMartFailure extends Error {
constructor(
@@ -202,8 +200,7 @@ function synchronousStudioAI(
return json({ error: "Same-origin requests only." }, 403);
if (url.pathname.endsWith("/generation") && request.method === "GET")
return json({
provider: "APIMart",
model,
provider: "AI",
templateVersion: 1,
delivery: "polling",
maxAttempts: 2,
@@ -291,7 +288,7 @@ function synchronousStudioAI(
code: "WRN-STUDIO-PROPOSAL",
path: "$",
message:
"APIMart returned a design that did not meet the schema after both provider requests were used. Generate again. Your draft and previous alternatives are unchanged.",
"AI generation returned a design that did not meet the schema after both attempts were used. Generate again. Your draft and previous alternatives are unchanged.",
},
];
}
@@ -317,6 +314,9 @@ function synchronousStudioAI(
},
];
}
// Public responses retain useful provenance without exposing infrastructure choices.
result.provenance.provider = "AI";
delete result.provenance.model;
return json(result);
} catch (error) {
const message =