renaming changes

This commit is contained in:
Aadesh Kheria 2026-05-26 12:35:59 -07:00
parent a3b6d5f7e6
commit 41427cb8d1
4 changed files with 14 additions and 14 deletions

View File

@ -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.`
)
);

View File

@ -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,

View File

@ -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<string | null> {
async function rawCallReducer(token: string, reducer: string, args: unknown[]): Promise<void> {
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<T>(op: (token: string) => Promise<T>): Promise<T | null> {
@ -88,7 +88,7 @@ export async function callReducer(reducer: string, args: unknown[]): Promise<voi
export async function callReducerStrict(reducer: string, args: unknown[]): Promise<void> {
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<Array<{
rows: unknown[][],
}>> {
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",

View File

@ -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}`));
}
}
}