feat(ui): add agent trace API calls

This commit is contained in:
Ishaan Jaff 2026-09-30 00:40:11 -07:00
parent 5481cdd6c2
commit 69ed633ac4
No known key found for this signature in database

View file

@ -115,6 +115,7 @@ import type { ComplexityRouterConfigPayload } from "./add_model/build_complexity
import type { AutoRouterPresetsResponse } from "@/lib/autorouter_presets";
import type { VectorStoreIndex } from "@/app/(dashboard)/vector-stores/_components/IndexesTab";
import type { RoutingDecision } from "./view_logs/LogDetailsDrawer/RoutingDecisionCard";
import type { SpanDetail, Trace, TracePage } from "./view_logs/TraceView/traceTypes";
import {
createApiClient,
deriveErrorMessage,
@ -2101,6 +2102,33 @@ export const uiSpendLogsCall = async ({
}
};
/**
* Agent tracing. All three respond 501 `{detail}` when `general_settings.tracing` is not
* configured; callers can detect that through the thrown `ApiError`'s `status`.
*/
export const agentTraceListCall = async ({
accessToken,
startMs,
endMs,
cursor,
}: {
accessToken: string;
startMs: number;
endMs: number;
cursor?: string | null;
}): Promise<TracePage> => {
const query = { start_ms: startMs, end_ms: endMs, cursor: cursor ?? undefined };
return apiClient.get<TracePage>(`/v1/traces`, { accessToken, query });
};
export const agentTraceCall = async (accessToken: string, traceId: string): Promise<Trace> =>
apiClient.get<Trace>(`/v1/traces/${encodeURIComponent(traceId)}`, { accessToken });
export const agentTraceSpanCall = async (accessToken: string, traceId: string, spanId: string): Promise<SpanDetail> =>
apiClient.get<SpanDetail>(`/v1/traces/${encodeURIComponent(traceId)}/spans/${encodeURIComponent(spanId)}`, {
accessToken,
});
export const adminSpendLogsCall = async (accessToken: string) => {
try {
const data = await apiClient.get(`/global/spend/logs`, { accessToken });