From 41427cb8d13bc907b7b69068797496c2731598b4 Mon Sep 17 00:00:00 2001 From: Aadesh Kheria Date: Tue, 26 May 2026 12:35:59 -0700 Subject: [PATCH] renaming changes --- apps/backend/src/lib/ai/loggers/ai-query-logger.ts | 8 ++++---- apps/backend/src/lib/ai/qa/qa-reviewer.ts | 6 +++--- apps/backend/src/lib/ai/spacetimedb-client.ts | 10 +++++----- apps/backend/src/lib/ai/tools/index.ts | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/backend/src/lib/ai/loggers/ai-query-logger.ts b/apps/backend/src/lib/ai/loggers/ai-query-logger.ts index 5cb08a051..b1d9c5a97 100644 --- a/apps/backend/src/lib/ai/loggers/ai-query-logger.ts +++ b/apps/backend/src/lib/ai/loggers/ai-query-logger.ts @@ -2,7 +2,7 @@ import { extractCachedTokens, extractCostFromUsage, extractOpenRouterCost, refin import type { CommonLogFields } from "@/lib/ai/types"; import { runAsynchronouslyAndWaitUntil } from "@/utils/background-tasks"; import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env"; -import { captureError, StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors"; +import { captureError, HexclaveAssertionError } from "@stackframe/stack-shared/dist/utils/errors"; import { type LanguageModelUsage, type StepResult, type ToolSet } from "ai"; import { callReducer, opt } from "../spacetimedb-client"; @@ -11,7 +11,7 @@ const MAX_TOOL_RESULT_CHARS = 50_000; function sanitizeOptionalNumber(name: string, n: number | undefined): number | undefined { if (n == null) return undefined; if (!Number.isFinite(n)) { - captureError("ai-query-logger", new StackAssertionError(`Invalid ${name}: ${n}`)); + captureError("ai-query-logger", new HexclaveAssertionError(`Invalid ${name}: ${n}`)); return undefined; } return n; @@ -19,7 +19,7 @@ function sanitizeOptionalNumber(name: string, n: number | undefined): number | u function sanitizeRequiredNumber(name: string, n: number): number { if (!Number.isFinite(n)) { - captureError("ai-query-logger", new StackAssertionError(`Invalid ${name}: ${n}`)); + captureError("ai-query-logger", new HexclaveAssertionError(`Invalid ${name}: ${n}`)); return 0; } return n; @@ -30,7 +30,7 @@ function truncateLargeToolResult(toolName: string, output: unknown): unknown { if (serialized.length <= MAX_TOOL_RESULT_CHARS) return output; captureError( "ai-query-tool-result-truncated", - new StackAssertionError( + new HexclaveAssertionError( `Tool ${toolName} returned ${serialized.length} chars (limit ${MAX_TOOL_RESULT_CHARS}); truncating in stepsJson log.` ) ); diff --git a/apps/backend/src/lib/ai/qa/qa-reviewer.ts b/apps/backend/src/lib/ai/qa/qa-reviewer.ts index 19493ac0d..cbdc14bf2 100644 --- a/apps/backend/src/lib/ai/qa/qa-reviewer.ts +++ b/apps/backend/src/lib/ai/qa/qa-reviewer.ts @@ -1,6 +1,6 @@ import { createMCPClient } from "@ai-sdk/mcp"; import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env"; -import { captureError, StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors"; +import { captureError, HexclaveAssertionError } from "@stackframe/stack-shared/dist/utils/errors"; import { generateText, stepCountIs } from "ai"; import { createOpenRouterProvider } from "../models"; import { callReducer, opt } from "../spacetimedb-client"; @@ -144,7 +144,7 @@ export async function reviewMcpCall(entry: { const raw = extractJsonObject(result.text); if (raw == null) { - throw new StackAssertionError(`No valid JSON object found in QA review response: ${result.text.slice(0, 200)}`); + throw new HexclaveAssertionError(`No valid JSON object found in QA review response: ${result.text.slice(0, 200)}`); } if ( typeof raw.needsHumanReview !== "boolean" || @@ -154,7 +154,7 @@ export async function reviewMcpCall(entry: { typeof raw.overallScore !== "number" || !Number.isFinite(raw.overallScore) ) { - throw new StackAssertionError(`Invalid QA review response shape: ${JSON.stringify(raw).slice(0, 200)}`); + throw new HexclaveAssertionError(`Invalid QA review response shape: ${JSON.stringify(raw).slice(0, 200)}`); } const parsed = raw as { needsHumanReview: boolean, diff --git a/apps/backend/src/lib/ai/spacetimedb-client.ts b/apps/backend/src/lib/ai/spacetimedb-client.ts index 41ae20204..ae7219d5d 100644 --- a/apps/backend/src/lib/ai/spacetimedb-client.ts +++ b/apps/backend/src/lib/ai/spacetimedb-client.ts @@ -1,5 +1,5 @@ import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env"; -import { StackAssertionError, StatusError } from "@stackframe/stack-shared/dist/utils/errors"; +import { HexclaveAssertionError, StatusError } from "@stackframe/stack-shared/dist/utils/errors"; function httpBase(): string | null { return getEnvVariable("STACK_SPACETIMEDB_URL", "") || null; @@ -37,7 +37,7 @@ async function getServiceToken(): Promise { async function rawCallReducer(token: string, reducer: string, args: unknown[]): Promise { const base = httpBase(); - if (!base) throw new StackAssertionError("SpacetimeDB not configured"); + if (!base) throw new HexclaveAssertionError("SpacetimeDB not configured"); const dbName = getEnvVariable("STACK_SPACETIMEDB_DB_NAME"); const res = await fetch(`${base}/v1/database/${encodeURIComponent(dbName)}/call/${encodeURIComponent(reducer)}`, { method: "POST", @@ -64,7 +64,7 @@ function spacetimeDbError(label: string, status: number, preview: string): Error const detail = `${label} (${status}): ${preview}`; if (status >= 400 && status < 500) return new StatusError(status, detail); if (status >= 500) return new StatusError(StatusError.BadGateway, `${label} (upstream ${status}): ${preview}`); - return new StackAssertionError(detail); + return new HexclaveAssertionError(detail); } async function withEnrollmentRetry(op: (token: string) => Promise): Promise { @@ -88,7 +88,7 @@ export async function callReducer(reducer: string, args: unknown[]): Promise { const ran = await withEnrollmentRetry((token) => rawCallReducer(token, reducer, args)); if (ran === null) { - throw new StackAssertionError( + throw new HexclaveAssertionError( `SpacetimeDB is not configured. Reducer ${reducer} cannot run. ` + `Check STACK_SPACETIMEDB_URL and STACK_SPACETIMEDB_SERVICE_TOKEN.` ); @@ -109,7 +109,7 @@ async function rawCallSql(token: string, sql: string): Promise> { const base = httpBase(); - if (!base) throw new StackAssertionError("SpacetimeDB not configured"); + if (!base) throw new HexclaveAssertionError("SpacetimeDB not configured"); const dbName = getEnvVariable("STACK_SPACETIMEDB_DB_NAME"); const res = await fetch(`${base}/v1/database/${encodeURIComponent(dbName)}/sql`, { method: "POST", diff --git a/apps/backend/src/lib/ai/tools/index.ts b/apps/backend/src/lib/ai/tools/index.ts index f66cecf21..1bb2ccc0d 100644 --- a/apps/backend/src/lib/ai/tools/index.ts +++ b/apps/backend/src/lib/ai/tools/index.ts @@ -1,5 +1,5 @@ import { SmartRequestAuth } from "@/route-handlers/smart-request"; -import { StackAssertionError, captureError } from "@stackframe/stack-shared/dist/utils/errors"; +import { HexclaveAssertionError, captureError } from "@stackframe/stack-shared/dist/utils/errors"; import { ToolSet } from "ai"; import { patchDashboardTool, updateDashboardTool } from "./create-dashboard"; import { createEmailDraftTool } from "./create-email-draft"; @@ -71,7 +71,7 @@ export async function getTools( default: { const _exhaustive: never = toolName; - captureError("ai-tools-getTools", new StackAssertionError(`Unknown tool name: ${_exhaustive as string}`)); + captureError("ai-tools-getTools", new HexclaveAssertionError(`Unknown tool name: ${_exhaustive as string}`)); } } }