fix: derive assistant approval key at runtime
This commit is contained in:
1 parent
e9b24f1242
commit
5f3d676af0
1 file changed
+5
-4
@@ -22,9 +22,10 @@ import { extractMcpTools } from "../../mcp/_extract-tools";
|
|||||||
export const maxDuration = 60;
|
export const maxDuration = 60;
|
||||||
|
|
||||||
const logger = createLogger({ module: "assistant" });
|
const logger = createLogger({ module: "assistant" });
|
||||||
const toolApprovalSecret = Buffer.from(
|
const getToolApprovalSecret = () =>
|
||||||
hkdfSync("sha256", Buffer.from(env.SECRET_ENCRYPTION_KEY, "hex"), "", "assistant-tool-approval", 32),
|
Buffer.from(
|
||||||
).toString("base64url");
|
hkdfSync("sha256", Buffer.from(env.SECRET_ENCRYPTION_KEY, "hex"), "", "assistant-tool-approval", 32),
|
||||||
|
).toString("base64url");
|
||||||
const safeStreamError = "The model endpoint stopped the response. Check its URL, model, and credentials.";
|
const safeStreamError = "The model endpoint stopped the response. Check its URL, model, and credentials.";
|
||||||
|
|
||||||
const requestSchema = z.object({
|
const requestSchema = z.object({
|
||||||
@@ -243,7 +244,7 @@ export async function POST(request: Request) {
|
|||||||
timeout: { totalMs: 55_000, stepMs: 30_000, toolMs: 30_000 },
|
timeout: { totalMs: 55_000, stepMs: 30_000, toolMs: 30_000 },
|
||||||
maxRetries: 2,
|
maxRetries: 2,
|
||||||
toolApproval,
|
toolApproval,
|
||||||
experimental_toolApprovalSecret: toolApprovalSecret,
|
experimental_toolApprovalSecret: getToolApprovalSecret(),
|
||||||
onError: ({ error }) => {
|
onError: ({ error }) => {
|
||||||
logger.error("Assistant response stream failed", {
|
logger.error("Assistant response stream failed", {
|
||||||
error: error instanceof Error ? error.message : String(error),
|
error: error instanceof Error ? error.message : String(error),
|
||||||
|
|||||||
Reference in new issue
Block a user