@mastra/core
Version: 1,324 lines • 53.7 kB
TypeScript
import { z } from 'zod/v4';
import type { SpanRecord } from './tracing.js';
export declare const TRACE_QUERY_MAX_DEPTH = 12;
export declare const TRACE_QUERY_MAX_NODES = 100;
export declare const TRACE_QUERY_MAX_SET_VALUES = 100;
export declare const TRACE_QUERY_MAX_RELATED_CLAUSES = 8;
export declare const TRACE_QUERY_MAX_LITERAL_UNITS = 1000;
export declare const TRACE_QUERY_MAX_STRING_BYTES = 4096;
export declare const TRACE_QUERY_MAX_PATH_BYTES = 128;
export declare const TRACE_QUERY_DISCOVERY_DEFAULT_LIMIT = 25;
export declare const TRACE_QUERY_DISCOVERY_MAX_LIMIT = 100;
export declare const TRACE_QUERY_DISCOVERY_MAX_SEARCH_LENGTH = 256;
export declare const TRACE_QUERY_DEFAULT_TIMEOUT_MS = 15000;
export declare const TRACE_QUERY_MAX_TIMEOUT_MS = 300000;
/**
* Fields trace and span queries can sort by. `timeToFirstChunkMs` and `timeToFirstTokenMs` are
* numbers that can be empty; empty values sort last in both directions.
*/
export declare const TRACE_QUERY_ORDER_FIELDS: readonly ["startedAt", "endedAt", "timeToFirstChunkMs", "timeToFirstTokenMs"];
export type TraceQueryOrderField = (typeof TRACE_QUERY_ORDER_FIELDS)[number];
/** A keyset cursor's sort value: an ISO timestamp, or a number or `null` for a numeric order field. */
export type TraceQuerySortValue = string | number | null;
/** @internal Whether a decoded cursor's sort value has the kind its order field produces. */
export declare function isTraceQuerySortValueFor(field: TraceQueryOrderField, value: TraceQuerySortValue): boolean;
/** @internal Cursor sort values: ISO timestamps, or finite numbers and `null` for numeric fields. */
export declare const traceQuerySortValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
/** @internal Shared with the trace-aggregate request schema so both report identical complexity issues. */
export declare const TRACE_QUERY_PREDICATE_COMPLEXITY_MESSAGE = "Predicates are limited to 100 nodes and 12 levels";
export declare function compareTraceQueryStrings(left: string, right: string): number;
/** Maximum Unicode code points in a token-search literal, before store tokenization. */
export declare const TRACE_QUERY_TOKEN_SEARCH_MAX_LENGTH = 256;
export declare const TRACE_QUERY_TOKEN_FIELDS: readonly ['input', 'output', 'error', 'inputPreview', 'outputPreview', 'errorPreview', 'all'];
export type TraceQueryTokenField = (typeof TRACE_QUERY_TOKEN_FIELDS)[number];
export declare const traceQueryScalarPredicateSchema: z.ZodType<TraceQueryScalarPredicate, TraceQueryScalarPredicate>;
export declare const traceQueryPredicateSchema: z.ZodType<TraceQueryPredicate, TraceQueryPredicate>;
export declare const traceQueryTimeRangeSchema: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>;
export declare const traceQueryPredicateScopeSchema: z.ZodEnum<{
feedback: "feedback";
scores: "scores";
spans: "spans";
trace: "trace";
}>;
export declare const traceQueryOperatorSchema: z.ZodEnum<{
eq: "eq";
exists: "exists";
gt: "gt";
gte: "gte";
in: "in";
includes: "includes";
lt: "lt";
lte: "lte";
matches: "matches";
ne: "ne";
notExists: "notExists";
notIn: "notIn";
notIncludes: "notIncludes";
notMatches: "notMatches";
}>;
export declare const traceQueryValueKindSchema: z.ZodEnum<{
array: "array";
number: "number";
presence: "presence";
string: "string";
stringOrNumber: "stringOrNumber";
timestamp: "timestamp";
}>;
export declare const getTraceQueryFieldsArgsSchema: z.ZodObject<{
timeRange: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>;
predicateScope: z.ZodEnum<{
feedback: "feedback";
scores: "scores";
spans: "spans";
trace: "trace";
}>;
search: z.ZodOptional<z.ZodString>;
limit: z.ZodDefault<z.ZodNumber>;
}, z.core.$strict>;
export declare const getTraceQueryValuesArgsSchema: z.ZodObject<{
timeRange: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>;
predicateScope: z.ZodEnum<{
feedback: "feedback";
scores: "scores";
spans: "spans";
trace: "trace";
}>;
path: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
search: z.ZodOptional<z.ZodString>;
limit: z.ZodDefault<z.ZodNumber>;
}, z.core.$strict>;
export declare const traceQueryCanonicalFieldDescriptorSchema: z.ZodObject<{
path: z.ZodString;
valueKind: z.ZodEnum<{
array: "array";
number: "number";
presence: "presence";
string: "string";
stringOrNumber: "stringOrNumber";
timestamp: "timestamp";
}>;
operators: z.ZodArray<z.ZodEnum<{
eq: "eq";
exists: "exists";
gt: "gt";
gte: "gte";
in: "in";
includes: "includes";
lt: "lt";
lte: "lte";
matches: "matches";
ne: "ne";
notExists: "notExists";
notIn: "notIn";
notIncludes: "notIncludes";
notMatches: "notMatches";
}>>;
valueSuggestions: z.ZodBoolean;
}, z.core.$strict>;
export declare const traceQueryObservedFieldDescriptorSchema: z.ZodObject<{
path: z.ZodString & z.ZodType<`metadata.${string}`, string, z.core.$ZodTypeInternals<`metadata.${string}`, string>>;
valueKind: z.ZodLiteral<"string">;
operators: z.ZodArray<z.ZodEnum<{
eq: "eq";
exists: "exists";
in: "in";
ne: "ne";
notExists: "notExists";
notIn: "notIn";
}>>;
valueSuggestions: z.ZodLiteral<true>;
occurrences: z.ZodNumber;
}, z.core.$strict>;
export declare const traceAggregateDimensionDescriptorSchema: z.ZodObject<{
path: z.ZodString;
valueKind: z.ZodLiteral<"string">;
}, z.core.$strict>;
export declare const traceAggregateMeasureDescriptorSchema: z.ZodObject<{
name: z.ZodString;
kind: z.ZodEnum<{
cost: "cost";
count: "count";
duration: "duration";
error: "error";
timeToFirstChunk: "timeToFirstChunk";
timeToFirstToken: "timeToFirstToken";
tokens: "tokens";
}>;
statistic: z.ZodOptional<z.ZodEnum<{
avg: "avg";
count: "count";
max: "max";
min: "min";
p50: "p50";
p90: "p90";
p95: "p95";
p99: "p99";
sum: "sum";
}>>;
unit: z.ZodEnum<{
count: "count";
currency: "currency";
milliseconds: "milliseconds";
ratio: "ratio";
tokens: "tokens";
}>;
approximate: z.ZodBoolean;
}, z.core.$strict>;
export declare const traceAggregateDiscoverySchema: z.ZodObject<{
dimensions: z.ZodArray<z.ZodObject<{
path: z.ZodString;
valueKind: z.ZodLiteral<"string">;
}, z.core.$strict>>;
measures: z.ZodArray<z.ZodObject<{
name: z.ZodString;
kind: z.ZodEnum<{
cost: "cost";
count: "count";
duration: "duration";
error: "error";
timeToFirstChunk: "timeToFirstChunk";
timeToFirstToken: "timeToFirstToken";
tokens: "tokens";
}>;
statistic: z.ZodOptional<z.ZodEnum<{
avg: "avg";
count: "count";
max: "max";
min: "min";
p50: "p50";
p90: "p90";
p95: "p95";
p99: "p99";
sum: "sum";
}>>;
unit: z.ZodEnum<{
count: "count";
currency: "currency";
milliseconds: "milliseconds";
ratio: "ratio";
tokens: "tokens";
}>;
approximate: z.ZodBoolean;
}, z.core.$strict>>;
}, z.core.$strict>;
export declare const getTraceQueryFieldsResponseSchema: z.ZodObject<{
canonicalFields: z.ZodArray<z.ZodObject<{
path: z.ZodString;
valueKind: z.ZodEnum<{
array: "array";
number: "number";
presence: "presence";
string: "string";
stringOrNumber: "stringOrNumber";
timestamp: "timestamp";
}>;
operators: z.ZodArray<z.ZodEnum<{
eq: "eq";
exists: "exists";
gt: "gt";
gte: "gte";
in: "in";
includes: "includes";
lt: "lt";
lte: "lte";
matches: "matches";
ne: "ne";
notExists: "notExists";
notIn: "notIn";
notIncludes: "notIncludes";
notMatches: "notMatches";
}>>;
valueSuggestions: z.ZodBoolean;
}, z.core.$strict>>;
observedFields: z.ZodArray<z.ZodObject<{
path: z.ZodString & z.ZodType<`metadata.${string}`, string, z.core.$ZodTypeInternals<`metadata.${string}`, string>>;
valueKind: z.ZodLiteral<"string">;
operators: z.ZodArray<z.ZodEnum<{
eq: "eq";
exists: "exists";
in: "in";
ne: "ne";
notExists: "notExists";
notIn: "notIn";
}>>;
valueSuggestions: z.ZodLiteral<true>;
occurrences: z.ZodNumber;
}, z.core.$strict>>;
observedFieldsTruncated: z.ZodBoolean;
aggregate: z.ZodOptional<z.ZodObject<{
dimensions: z.ZodArray<z.ZodObject<{
path: z.ZodString;
valueKind: z.ZodLiteral<"string">;
}, z.core.$strict>>;
measures: z.ZodArray<z.ZodObject<{
name: z.ZodString;
kind: z.ZodEnum<{
cost: "cost";
count: "count";
duration: "duration";
error: "error";
timeToFirstChunk: "timeToFirstChunk";
timeToFirstToken: "timeToFirstToken";
tokens: "tokens";
}>;
statistic: z.ZodOptional<z.ZodEnum<{
avg: "avg";
count: "count";
max: "max";
min: "min";
p50: "p50";
p90: "p90";
p95: "p95";
p99: "p99";
sum: "sum";
}>>;
unit: z.ZodEnum<{
count: "count";
currency: "currency";
milliseconds: "milliseconds";
ratio: "ratio";
tokens: "tokens";
}>;
approximate: z.ZodBoolean;
}, z.core.$strict>>;
}, z.core.$strict>>;
}, z.core.$strict>;
export declare const getTraceQueryValuesResponseSchema: z.ZodObject<{
values: z.ZodArray<z.ZodObject<{
value: z.ZodString;
count: z.ZodNumber;
}, z.core.$strict>>;
valuesTruncated: z.ZodBoolean;
}, z.core.$strict>;
export declare const traceSelectionSchema: z.ZodObject<{
timeRange: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>;
where: z.ZodOptional<z.ZodType<TraceQueryPredicate, TraceQueryPredicate, z.core.$ZodTypeInternals<TraceQueryPredicate, TraceQueryPredicate>>>;
}, z.core.$strict>;
export declare const threadPredicateSchema: z.ZodType<ThreadPredicate>;
export declare const traceQueryRootSourceSchema: z.ZodEnum<{
aggregated: "aggregated";
legacy: "legacy";
}>;
declare const traceQueryRequestObjectSchema: z.ZodObject<{
rootSource: z.ZodOptional<z.ZodEnum<{
aggregated: "aggregated";
legacy: "legacy";
}>>;
timeRange: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>;
where: z.ZodOptional<z.ZodType<TraceQueryPredicate, TraceQueryPredicate, z.core.$ZodTypeInternals<TraceQueryPredicate, TraceQueryPredicate>>>;
group: z.ZodOptional<z.ZodObject<{
by: z.ZodTuple<[z.ZodLiteral<"threadId">], null>;
}, z.core.$strict>>;
orderBy: z.ZodOptional<z.ZodArray<z.ZodObject<{
field: z.ZodEnum<{
endedAt: "endedAt";
startedAt: "startedAt";
timeToFirstChunkMs: "timeToFirstChunkMs";
timeToFirstTokenMs: "timeToFirstTokenMs";
}>;
direction: z.ZodEnum<{
asc: "asc";
desc: "desc";
}>;
}, z.core.$strict>>>;
page: z.ZodOptional<z.ZodObject<{
limit: z.ZodDefault<z.ZodNumber>;
after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, z.core.$strict>>;
pagination: z.ZodOptional<z.ZodObject<{
page: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
perPage: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
}, z.core.$strip>>;
mode: z.ZodOptional<z.ZodLiteral<"delta">>;
after: z.ZodOptional<z.ZodString>;
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
}, z.core.$strict>;
export declare const traceQueryRequestSchema: z.ZodPreprocess<z.ZodObject<{
rootSource: z.ZodOptional<z.ZodEnum<{
aggregated: "aggregated";
legacy: "legacy";
}>>;
timeRange: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>;
where: z.ZodOptional<z.ZodType<TraceQueryPredicate, TraceQueryPredicate, z.core.$ZodTypeInternals<TraceQueryPredicate, TraceQueryPredicate>>>;
group: z.ZodOptional<z.ZodObject<{
by: z.ZodTuple<[z.ZodLiteral<"threadId">], null>;
}, z.core.$strict>>;
orderBy: z.ZodOptional<z.ZodArray<z.ZodObject<{
field: z.ZodEnum<{
endedAt: "endedAt";
startedAt: "startedAt";
timeToFirstChunkMs: "timeToFirstChunkMs";
timeToFirstTokenMs: "timeToFirstTokenMs";
}>;
direction: z.ZodEnum<{
asc: "asc";
desc: "desc";
}>;
}, z.core.$strict>>>;
page: z.ZodOptional<z.ZodObject<{
limit: z.ZodDefault<z.ZodNumber>;
after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, z.core.$strict>>;
pagination: z.ZodOptional<z.ZodObject<{
page: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
perPage: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
}, z.core.$strip>>;
mode: z.ZodOptional<z.ZodLiteral<"delta">>;
after: z.ZodOptional<z.ZodString>;
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
}, z.core.$strict>, unknown>;
declare const queryThreadsInputObjectSchema: z.ZodObject<{
traces: z.ZodObject<{
timeRange: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>;
where: z.ZodOptional<z.ZodType<TraceQueryPredicate, TraceQueryPredicate, z.core.$ZodTypeInternals<TraceQueryPredicate, TraceQueryPredicate>>>;
}, z.core.$strict>;
where: z.ZodOptional<z.ZodType<ThreadPredicate, unknown, z.core.$ZodTypeInternals<ThreadPredicate, unknown>>>;
page: z.ZodDefault<z.ZodObject<{
limit: z.ZodDefault<z.ZodNumber>;
after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, z.core.$strict>>;
}, z.core.$strict>;
export declare const queryThreadsInputSchema: z.ZodPreprocess<z.ZodObject<{
traces: z.ZodObject<{
timeRange: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>;
where: z.ZodOptional<z.ZodType<TraceQueryPredicate, TraceQueryPredicate, z.core.$ZodTypeInternals<TraceQueryPredicate, TraceQueryPredicate>>>;
}, z.core.$strict>;
where: z.ZodOptional<z.ZodType<ThreadPredicate, unknown, z.core.$ZodTypeInternals<ThreadPredicate, unknown>>>;
page: z.ZodDefault<z.ZodObject<{
limit: z.ZodDefault<z.ZodNumber>;
after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, z.core.$strict>>;
}, z.core.$strict>, unknown>;
export declare const traceQueryTraceSchema: z.ZodObject<{
traceId: z.ZodString;
rootSpanId: z.ZodString;
rootKind: z.ZodOptional<z.ZodEnum<{
external: "external";
native: "native";
}>>;
runtimeDurationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
errorCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
name: z.ZodString;
entityId: z.ZodNullable<z.ZodString>;
parentSpanId: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
inputPreview: z.ZodNullable<z.ZodString>;
outputPreview: z.ZodNullable<z.ZodString>;
errorPreview: z.ZodNullable<z.ZodString>;
threadId: z.ZodNullable<z.ZodString>;
resourceId: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
endedAt: z.ZodString;
entityName: z.ZodNullable<z.ZodString>;
entityType: z.ZodNullable<z.ZodString>;
environment: z.ZodNullable<z.ZodString>;
status: z.ZodEnum<{
error: "error";
success: "success";
}>;
timeToFirstChunkMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReasonContext: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>;
export declare const traceQueryTraceResponseSchema: z.ZodObject<{
traces: z.ZodArray<z.ZodObject<{
traceId: z.ZodString;
rootSpanId: z.ZodString;
rootKind: z.ZodOptional<z.ZodEnum<{
external: "external";
native: "native";
}>>;
runtimeDurationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
errorCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
name: z.ZodString;
entityId: z.ZodNullable<z.ZodString>;
parentSpanId: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
inputPreview: z.ZodNullable<z.ZodString>;
outputPreview: z.ZodNullable<z.ZodString>;
errorPreview: z.ZodNullable<z.ZodString>;
threadId: z.ZodNullable<z.ZodString>;
resourceId: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
endedAt: z.ZodString;
entityName: z.ZodNullable<z.ZodString>;
entityType: z.ZodNullable<z.ZodString>;
environment: z.ZodNullable<z.ZodString>;
status: z.ZodEnum<{
error: "error";
success: "success";
}>;
timeToFirstChunkMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReasonContext: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
page: z.ZodObject<{
next: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
}, z.core.$strict>;
export declare const traceQueryPaginatedTraceResponseSchema: z.ZodObject<{
traces: z.ZodArray<z.ZodObject<{
traceId: z.ZodString;
rootSpanId: z.ZodString;
rootKind: z.ZodOptional<z.ZodEnum<{
external: "external";
native: "native";
}>>;
runtimeDurationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
errorCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
name: z.ZodString;
entityId: z.ZodNullable<z.ZodString>;
parentSpanId: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
inputPreview: z.ZodNullable<z.ZodString>;
outputPreview: z.ZodNullable<z.ZodString>;
errorPreview: z.ZodNullable<z.ZodString>;
threadId: z.ZodNullable<z.ZodString>;
resourceId: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
endedAt: z.ZodString;
entityName: z.ZodNullable<z.ZodString>;
entityType: z.ZodNullable<z.ZodString>;
environment: z.ZodNullable<z.ZodString>;
status: z.ZodEnum<{
error: "error";
success: "success";
}>;
timeToFirstChunkMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReasonContext: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
pagination: z.ZodObject<{
total: z.ZodNumber;
page: z.ZodNumber;
perPage: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>;
hasMore: z.ZodBoolean;
}, z.core.$strip>;
deltaCursor: z.ZodOptional<z.ZodString>;
}, z.core.$strict>;
export declare const traceQueryDeltaTraceResponseSchema: z.ZodObject<{
traces: z.ZodArray<z.ZodObject<{
traceId: z.ZodString;
rootSpanId: z.ZodString;
rootKind: z.ZodOptional<z.ZodEnum<{
external: "external";
native: "native";
}>>;
runtimeDurationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
errorCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
name: z.ZodString;
entityId: z.ZodNullable<z.ZodString>;
parentSpanId: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
inputPreview: z.ZodNullable<z.ZodString>;
outputPreview: z.ZodNullable<z.ZodString>;
errorPreview: z.ZodNullable<z.ZodString>;
threadId: z.ZodNullable<z.ZodString>;
resourceId: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
endedAt: z.ZodString;
entityName: z.ZodNullable<z.ZodString>;
entityType: z.ZodNullable<z.ZodString>;
environment: z.ZodNullable<z.ZodString>;
status: z.ZodEnum<{
error: "error";
success: "success";
}>;
timeToFirstChunkMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReasonContext: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
delta: z.ZodObject<{
limit: z.ZodNumber;
hasMore: z.ZodBoolean;
}, z.core.$strip>;
deltaCursor: z.ZodString;
}, z.core.$strict>;
/**
* @deprecated Use `queryThreadsResultSchema` instead. Grouped trace queries remain supported until the next major release.
*/
export declare const traceQueryGroupResponseSchema: z.ZodObject<{
groups: z.ZodArray<z.ZodObject<{
threadId: z.ZodString;
}, z.core.$strict>>;
page: z.ZodObject<{
next: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
}, z.core.$strict>;
export declare const traceQueryResponseSchema: z.ZodUnion<readonly [z.ZodObject<{
traces: z.ZodArray<z.ZodObject<{
traceId: z.ZodString;
rootSpanId: z.ZodString;
rootKind: z.ZodOptional<z.ZodEnum<{
external: "external";
native: "native";
}>>;
runtimeDurationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
errorCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
name: z.ZodString;
entityId: z.ZodNullable<z.ZodString>;
parentSpanId: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
inputPreview: z.ZodNullable<z.ZodString>;
outputPreview: z.ZodNullable<z.ZodString>;
errorPreview: z.ZodNullable<z.ZodString>;
threadId: z.ZodNullable<z.ZodString>;
resourceId: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
endedAt: z.ZodString;
entityName: z.ZodNullable<z.ZodString>;
entityType: z.ZodNullable<z.ZodString>;
environment: z.ZodNullable<z.ZodString>;
status: z.ZodEnum<{
error: "error";
success: "success";
}>;
timeToFirstChunkMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReasonContext: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
page: z.ZodObject<{
next: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
}, z.core.$strict>, z.ZodObject<{
traces: z.ZodArray<z.ZodObject<{
traceId: z.ZodString;
rootSpanId: z.ZodString;
rootKind: z.ZodOptional<z.ZodEnum<{
external: "external";
native: "native";
}>>;
runtimeDurationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
errorCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
name: z.ZodString;
entityId: z.ZodNullable<z.ZodString>;
parentSpanId: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
inputPreview: z.ZodNullable<z.ZodString>;
outputPreview: z.ZodNullable<z.ZodString>;
errorPreview: z.ZodNullable<z.ZodString>;
threadId: z.ZodNullable<z.ZodString>;
resourceId: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
endedAt: z.ZodString;
entityName: z.ZodNullable<z.ZodString>;
entityType: z.ZodNullable<z.ZodString>;
environment: z.ZodNullable<z.ZodString>;
status: z.ZodEnum<{
error: "error";
success: "success";
}>;
timeToFirstChunkMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReasonContext: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
pagination: z.ZodObject<{
total: z.ZodNumber;
page: z.ZodNumber;
perPage: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>;
hasMore: z.ZodBoolean;
}, z.core.$strip>;
deltaCursor: z.ZodOptional<z.ZodString>;
}, z.core.$strict>, z.ZodObject<{
traces: z.ZodArray<z.ZodObject<{
traceId: z.ZodString;
rootSpanId: z.ZodString;
rootKind: z.ZodOptional<z.ZodEnum<{
external: "external";
native: "native";
}>>;
runtimeDurationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
errorCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
name: z.ZodString;
entityId: z.ZodNullable<z.ZodString>;
parentSpanId: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
inputPreview: z.ZodNullable<z.ZodString>;
outputPreview: z.ZodNullable<z.ZodString>;
errorPreview: z.ZodNullable<z.ZodString>;
threadId: z.ZodNullable<z.ZodString>;
resourceId: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
endedAt: z.ZodString;
entityName: z.ZodNullable<z.ZodString>;
entityType: z.ZodNullable<z.ZodString>;
environment: z.ZodNullable<z.ZodString>;
status: z.ZodEnum<{
error: "error";
success: "success";
}>;
timeToFirstChunkMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
stopReasonContext: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
delta: z.ZodObject<{
limit: z.ZodNumber;
hasMore: z.ZodBoolean;
}, z.core.$strip>;
deltaCursor: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
groups: z.ZodArray<z.ZodObject<{
threadId: z.ZodString;
}, z.core.$strict>>;
page: z.ZodObject<{
next: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
}, z.core.$strict>]>;
export declare const threadIdentitySchema: z.ZodObject<{
threadId: z.ZodString;
}, z.core.$strict>;
export declare const queryThreadsResultSchema: z.ZodObject<{
threads: z.ZodArray<z.ZodObject<{
threadId: z.ZodString;
}, z.core.$strict>>;
page: z.ZodObject<{
next: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
}, z.core.$strict>;
export type TraceQueryLiteral = string | number | boolean | null;
export type TraceQueryPathOrLiteral = {
path: string;
} | {
literal: TraceQueryLiteral;
};
export type TraceQueryScalarPredicate = {
op: 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte';
left: TraceQueryPathOrLiteral;
right: TraceQueryPathOrLiteral;
} | {
op: 'in' | 'notIn';
value: TraceQueryPathOrLiteral;
set: TraceQueryLiteral[];
} | {
op: 'exists' | 'notExists';
path: string;
} | {
op: 'includes' | 'notIncludes';
path: string;
value: string;
} | {
op: 'hasAllTokens';
left: {
path: TraceQueryTokenField;
};
right: {
literal: string;
};
} | {
op: 'matches' | 'notMatches';
left: {
path: string;
};
right: {
literal: string;
};
} | {
op: 'and' | 'or';
args: TraceQueryScalarPredicate[];
} | {
op: 'not';
arg: TraceQueryScalarPredicate;
};
export type TraceQueryPredicate = Exclude<TraceQueryScalarPredicate, {
op: 'and' | 'or';
} | {
op: 'not';
}> | {
op: 'and' | 'or';
args: TraceQueryPredicate[];
} | {
op: 'not';
arg: TraceQueryPredicate;
} | {
spans: {
some: TraceQueryScalarPredicate;
} | {
none: TraceQueryScalarPredicate;
};
} | {
scores: {
some: TraceQueryScalarPredicate;
} | {
none: TraceQueryScalarPredicate;
};
} | {
feedback: {
some: TraceQueryScalarPredicate;
} | {
none: TraceQueryScalarPredicate;
};
};
export type ThreadPredicate = {
op: 'and' | 'or';
args: ThreadPredicate[];
} | {
op: 'not';
arg: ThreadPredicate;
} | {
traces: {
some: TraceQueryPredicate;
} | {
none: TraceQueryPredicate;
};
};
export type TimeRange = z.infer<typeof traceQueryTimeRangeSchema>;
export type TraceSelection = z.input<typeof traceSelectionSchema>;
export type NormalizedTraceSelection = z.output<typeof traceSelectionSchema>;
export type QueryThreadsInput = z.input<typeof queryThreadsInputObjectSchema>;
export type NormalizedQueryThreadsInput = z.output<typeof queryThreadsInputObjectSchema>;
export type ThreadIdentity = z.infer<typeof threadIdentitySchema>;
export type QueryThreadsResult = z.infer<typeof queryThreadsResultSchema>;
type TraceQueryRequestInput = z.input<typeof traceQueryRequestObjectSchema>;
export type TraceQueryRequest = Omit<TraceQueryRequestInput, 'group'> & {
/**
* @deprecated Use `queryThreads()` instead. Grouped trace queries remain supported until the next major release.
*/
group?: TraceQueryRequestInput['group'];
};
export type NormalizedTraceQueryRequest = z.output<typeof traceQueryRequestObjectSchema>;
export type TraceQueryTrace = z.infer<typeof traceQueryTraceSchema>;
export type TraceQueryTraceResponse = z.infer<typeof traceQueryTraceResponseSchema>;
export type TraceQueryPaginatedTraceResponse = z.infer<typeof traceQueryPaginatedTraceResponseSchema>;
export type TraceQueryDeltaTraceResponse = z.infer<typeof traceQueryDeltaTraceResponseSchema>;
/**
* @deprecated Use `QueryThreadsResult` instead. Grouped trace queries remain supported until the next major release.
*/
export type TraceQueryGroupResponse = z.infer<typeof traceQueryGroupResponseSchema>;
export type TraceQueryResponse = z.infer<typeof traceQueryResponseSchema>;
export type TraceQueryOperator = z.infer<typeof traceQueryOperatorSchema>;
export type TraceQueryValueKind = z.infer<typeof traceQueryValueKindSchema>;
export type TraceQueryPredicateScope = z.infer<typeof traceQueryPredicateScopeSchema>;
interface FieldRule {
valueKind: TraceQueryValueKind;
operators: readonly TraceQueryOperator[];
valueSuggestions: boolean;
nonEmpty?: boolean;
}
export declare const TRACE_QUERY_STRING_OPERATORS: readonly ['eq', 'ne', 'in', 'notIn', 'exists', 'notExists'];
export declare const TRACE_QUERY_ORDERED_OPERATORS: readonly ["eq", "ne", "in", "notIn", "exists", "notExists", "lt", "lte", "gt", "gte"];
export declare const TRACE_QUERY_PRESENCE_OPERATORS: readonly ['exists', 'notExists'];
/** Stored string collections such as `tags`. `exists` means at least one member; `notExists` means none. */
export declare const TRACE_QUERY_ARRAY_OPERATORS: readonly ['includes', 'notIncludes', 'exists', 'notExists'];
/** Human-written text such as feedback comments: exact string operators plus word matching. */
export declare const TRACE_QUERY_TEXT_OPERATORS: readonly ["eq", "ne", "in", "notIn", "exists", "notExists", "matches", "notMatches"];
export declare const TRACE_QUERY_FIELD_REGISTRY: {
readonly trace: {
readonly traceId: FieldRule;
readonly threadId: FieldRule;
readonly resourceId: FieldRule;
readonly runId: FieldRule;
readonly sessionId: FieldRule;
readonly userId: FieldRule;
readonly organizationId: FieldRule;
readonly requestId: FieldRule;
readonly serviceName: FieldRule;
readonly experimentId: FieldRule;
readonly startedAt: FieldRule;
readonly endedAt: FieldRule;
readonly durationMs: FieldRule;
readonly timeToFirstChunkMs: FieldRule;
readonly timeToFirstTokenMs: FieldRule;
readonly entityId: FieldRule;
readonly entityName: FieldRule;
readonly entityType: FieldRule;
readonly name: FieldRule;
readonly spanType: FieldRule;
readonly environment: FieldRule;
readonly status: FieldRule;
readonly outcome: FieldRule;
readonly stopReason: FieldRule;
readonly tags: FieldRule;
};
readonly spans: {
readonly name: FieldRule;
readonly spanType: FieldRule;
readonly model: FieldRule;
readonly provider: FieldRule;
readonly startedAt: FieldRule;
readonly endedAt: FieldRule;
readonly durationMs: FieldRule;
readonly timeToFirstChunkMs: FieldRule;
readonly timeToFirstTokenMs: FieldRule;
readonly status: FieldRule;
readonly outcome: FieldRule;
readonly stopReason: FieldRule;
readonly error: FieldRule;
readonly entityType: FieldRule;
readonly entityId: FieldRule;
readonly entityName: FieldRule;
readonly entityVersionId: FieldRule;
readonly parentEntityVersionId: FieldRule;
readonly rootEntityVersionId: FieldRule;
readonly runId: FieldRule;
readonly sessionId: FieldRule;
readonly userId: FieldRule;
readonly organizationId: FieldRule;
readonly requestId: FieldRule;
readonly serviceName: FieldRule;
readonly experimentId: FieldRule;
};
readonly scores: {
readonly scorerId: FieldRule;
readonly scorerVersion: FieldRule;
readonly scoreSource: FieldRule;
readonly score: FieldRule;
readonly timestamp: FieldRule;
readonly spanId: FieldRule;
readonly entityVersionId: FieldRule;
readonly parentEntityVersionId: FieldRule;
readonly rootEntityVersionId: FieldRule;
};
readonly feedback: {
readonly feedbackType: FieldRule;
readonly feedbackSource: FieldRule;
readonly feedbackUserId: FieldRule;
readonly sourceId: FieldRule;
readonly entityVersionId: FieldRule;
readonly parentEntityVersionId: FieldRule;
readonly rootEntityVersionId: FieldRule;
readonly value: FieldRule;
readonly timestamp: FieldRule;
readonly comment: FieldRule;
};
};
/** Direct span queries have a separate policy from trace queries' related span predicates. */
export declare const SPAN_QUERY_FIELD_REGISTRY: {
readonly name: FieldRule;
readonly spanType: FieldRule;
readonly model: FieldRule;
readonly provider: FieldRule;
readonly status: FieldRule;
readonly outcome: FieldRule;
readonly stopReason: FieldRule;
readonly error: FieldRule;
readonly startedAt: FieldRule;
readonly endedAt: FieldRule;
readonly durationMs: FieldRule;
readonly timeToFirstChunkMs: FieldRule;
readonly timeToFirstTokenMs: FieldRule;
readonly traceId: FieldRule;
readonly spanId: FieldRule;
readonly parentSpanId: FieldRule;
readonly threadId: FieldRule;
readonly organizationId: FieldRule;
readonly resourceId: FieldRule;
readonly runId: FieldRule;
readonly sessionId: FieldRule;
readonly userId: FieldRule;
readonly requestId: FieldRule;
readonly serviceName: FieldRule;
readonly experimentId: FieldRule;
readonly environment: FieldRule;
readonly executionSource: FieldRule;
readonly entityType: FieldRule;
readonly entityId: FieldRule;
readonly entityName: FieldRule;
readonly entityVersionId: FieldRule;
readonly parentEntityType: FieldRule;
readonly parentEntityId: FieldRule;
readonly parentEntityName: FieldRule;
readonly parentEntityVersionId: FieldRule;
readonly rootEntityType: FieldRule;
readonly rootEntityId: FieldRule;
readonly rootEntityName: FieldRule;
readonly rootEntityVersionId: FieldRule;
};
export type SpanQueryField = keyof typeof SPAN_QUERY_FIELD_REGISTRY;
/** Direct thread-row predicates apply after full-history representative selection. */
export declare const THREAD_QUERY_FIELD_REGISTRY: {
readonly threadId: FieldRule;
readonly organizationId: FieldRule;
readonly firstTraceId: FieldRule;
readonly lastTraceId: FieldRule;
readonly resourceId: FieldRule;
readonly userId: FieldRule;
readonly entityType: FieldRule;
readonly entityId: FieldRule;
readonly entityName: FieldRule;
readonly entityVersionId: FieldRule;
readonly runId: FieldRule;
readonly sessionId: FieldRule;
readonly requestId: FieldRule;
readonly serviceName: FieldRule;
readonly experimentId: FieldRule;
readonly environment: FieldRule;
readonly executionSource: FieldRule;
readonly status: {
readonly valueKind: TraceQueryValueKind;
readonly valueSuggestions: boolean;
readonly nonEmpty?: boolean;
readonly operators: readonly ["eq", "ne", "in", "notIn"];
};
readonly startedAt: FieldRule;
readonly endedAt: FieldRule;
readonly traceCount: {
readonly valueKind: TraceQueryValueKind;
readonly valueSuggestions: boolean;
readonly nonEmpty?: boolean;
readonly operators: readonly ["eq", "ne", "lt", "lte", "gt", "gte"];
};
readonly timeToFirstChunkMs: FieldRule;
readonly timeToFirstTokenMs: FieldRule;
};
export type ThreadQueryField = keyof typeof THREAD_QUERY_FIELD_REGISTRY;
export type TraceQueryField = keyof (typeof TRACE_QUERY_FIELD_REGISTRY)['trace'];
export type TraceQuerySpanField = keyof (typeof TRACE_QUERY_FIELD_REGISTRY)['spans'];
export type TraceQueryScoreField = keyof (typeof TRACE_QUERY_FIELD_REGISTRY)['scores'];
export type TraceQueryFeedbackField = keyof (typeof TRACE_QUERY_FIELD_REGISTRY)['feedback'];
export type TraceQueryCanonicalField = ThreadQueryField | SpanQueryField | TraceQueryField | TraceQuerySpanField | TraceQueryScoreField | TraceQueryFeedbackField;
type TraceQueryMetadataKey = Extract<keyof NonNullable<SpanRecord['metadata']>, string>;
export type TraceQueryMetadataField = `metadata.${TraceQueryMetadataKey}`;
export type TraceQueryPredicateField = TraceQueryCanonicalField | TraceQueryMetadataField;
export type TraceQueryComparisonOperator = 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte';
export type TraceQueryMembershipOperator = 'in' | 'notIn';
export type TraceQueryPresenceOperator = 'exists' | 'notExists';
export type TraceQueryCollectionOperator = 'includes' | 'notIncludes' | 'empty' | 'notEmpty';
export type TraceQueryTextOperator = 'matches' | 'notMatches';
export type GetTraceQueryFieldsArgs = z.input<typeof getTraceQueryFieldsArgsSchema>;
export type NormalizedGetTraceQueryFieldsArgs = z.output<typeof getTraceQueryFieldsArgsSchema>;
export type GetTraceQueryValuesArgs = z.input<typeof getTraceQueryValuesArgsSchema>;
export type NormalizedGetTraceQueryValuesArgs = z.output<typeof getTraceQueryValuesArgsSchema>;
export type TraceQueryCanonicalFieldDescriptor = z.infer<typeof traceQueryCanonicalFieldDescriptorSchema>;
export type TraceQueryObservedFieldDescriptor = z.infer<typeof traceQueryObservedFieldDescriptorSchema>;
export type GetTraceQueryFieldsResponse = z.infer<typeof getTraceQueryFieldsResponseSchema>;
export type TraceAggregateDiscovery = z.infer<typeof traceAggregateDiscoverySchema>;
export type GetTraceQueryValuesResponse = z.infer<typeof getTraceQueryValuesResponseSchema>;
export type TrustedTraceQueryScalarPredicate = {
type: 'tokens';
field: TraceQueryTokenField;
operator: 'hasAllTokens';
value: string;
} | {
type: 'comparison';
field: TraceQueryPredicateField;
operator: TraceQueryComparisonOperator;
value: string | number;
} | {
type: 'membership';
field: TraceQueryPredicateField;
operator: TraceQueryMembershipOperator;
values: Array<string | number>;
} | {
type: 'presence';
field: TraceQueryPredicateField;
operator: TraceQueryPresenceOperator;
} | {
type: 'collection';
field: TraceQueryPredicateField;
operator: 'includes' | 'notIncludes';
value: string;
} | {
type: 'collection';
field: TraceQueryPredicateField;
operator: 'empty' | 'notEmpty';
}
/** `value` is the normalized word sequence from {@link normalizeTraceQueryText}. */
| {
type: 'text';
field: TraceQueryPredicateField;
operator: TraceQueryTextOperator;
value: string;
} | {
type: 'boolean';
operator: 'and' | 'or';
args: TrustedTraceQueryScalarPredicate[];
} | {
type: 'not';
arg: TrustedTraceQueryScalarPredicate;
};
export type TrustedTraceQueryPredicate = TrustedTraceQueryScalarPredicate | {
type: 'boolean';
operator: 'and' | 'or';
args: TrustedTraceQueryPredicate[];
} | {
type: 'not';
arg: TrustedTraceQueryPredicate;
} | {
type: 'relation';
collection: 'spans' | 'scores' | 'feedback';
quantifier: 'some' | 'none';
predicate: TrustedTraceQueryScalarPredicate;
};
export type TrustedThreadPredicate = {
type: 'boolean';
operator: 'and' | 'or';
args: TrustedThreadPredicate[];
} | {
type: 'not';
arg: TrustedThreadPredicate;
} | {
type: 'relation';
collection: 'traces';
quantifier: 'some' | 'none';
predicate: TrustedTraceQueryPredicate;
};
/**
* Tenant scope resolved by the host outside the query document. Stores AND it into
* every root and related-signal scan; it is never derived from caller predicates.
* Mirrors the `organizationId` / `resourceId` tenant scope of `BatchDeleteTracesArgs`.
*/
export interface TraceQueryTenantScope {
organizationId: string;
resourceId?: string;
}
export interface TrustedTraceQueryBasePlan {
rootSource?: 'aggregated';
timeRange: {
from: string;
to: string;
};
where?: TrustedTraceQueryPredicate;
scope?: TraceQueryTenantScope;
}
export interface TrustedTraceQueryKeysetPlan {
paginationMode: 'keyset';
limit: number;
binding: string;
}
export interface TrustedTraceQueryPagePlan {
paginationMode: 'page';
page: number;
perPage: number;
deltaBinding: string;
}
interface TrustedTraceQueryTracesBasePlan extends TrustedTraceQueryBasePlan {
result: 'traces';
/** Empty numeric sort values sort last in both directions; ties break by ascending `traceId`. */
orderBy: {
field: TraceQueryOrderField;
direction: 'asc' | 'desc';
};
}
export type TrustedTraceQueryKeysetTracesPlan = TrustedTraceQueryTracesBasePlan & TrustedTraceQueryKeysetPlan & {
cursor?: {
sortValue: TraceQuerySortValue;
traceId: string;
};
};
export type TrustedTraceQueryPaginatedTracesPlan = TrustedTraceQueryTracesBasePlan & TrustedTraceQueryPagePlan;
export type TrustedTraceQueryDeltaTracesPlan = TrustedTraceQueryTracesBasePlan & {
paginationMode: 'delta';
limit: number;
binding: string;
deltaCursor?: {
adapter: string;
watermark: string;
};
};
export type TrustedTraceQueryTracesPlan = TrustedTraceQueryKeysetTracesPlan | TrustedTraceQueryPaginatedTracesPlan | TrustedTraceQueryDeltaTracesPlan;
/**
* @deprecated Use `TrustedThreadQueryPlan` instead. Grouped trace queries remain supported until the next major release.
*/
export type TrustedTraceQueryGroupsPlan = TrustedTraceQueryBasePlan & TrustedTraceQueryKeysetPlan & {
result: 'groups';
orderBy: {
field: 'threadId';
direction: 'asc';
};
cursor?: {
threadId: string;
};
};
export type TrustedTraceQueryPlan = TrustedTraceQueryTracesPlan | TrustedTraceQueryGroupsPlan;
export interface TrustedThreadQueryPlan {
result: 'threads';
traces: {
timeRange: {
from: string;
to: string;
};
where?: TrustedTraceQueryPredicate;
};
where?: TrustedThreadPredicate;
scope?: TraceQueryTenantScope;
orderBy: {
field: 'threadId';
direction: 'asc';
};
limit: number;
binding: string;
cursor?: {
threadId: string;
};
}
export interface TrustedTraceQueryObservedFieldsPlan {
timeRange: {
from: string;
to: string;
};
predicateScope: TraceQueryPredicateScope;
search?: string;
limit: number;
scope?: TraceQueryTenantScope;
}
export interface TrustedTraceQueryValuesPlan extends TrustedTraceQueryObservedFieldsPlan {
path: string;
}
export interface TraceQueryObservedFieldsResult {
observedFields: TraceQueryObservedFieldDescriptor[];
observedFieldsTruncated: boolean;
}
export type TraceQueryCursorPlan = TrustedTraceQueryKeysetTracesPlan | TrustedTraceQueryGroupsPlan | TrustedThreadQueryPlan;
export type TraceQueryCursorValues = {
result: 'traces';
sortValue: TraceQuerySortValue;
traceId: string;
} | {
result: 'groups';
threadId: string;
} | {
result: 'threads';
threadId: string;
};
export type TraceQueryIssueCode = 'invalid_request' | 'invalid_time_range' | 'time_range_too_large' | 'predicate_too_complex' | 'field_not_allowed' | 'invalid_metadata_key' | 'operator_not_allowed' | 'invalid_operands' | 'invalid_literal' | 'too_many_buckets' | 'too_many_rows' | 'group_order_not_supported' | 'pagination_mode_conflict' | 'group_pagination_not_supported';
export interface TraceQueryIssue {
code: TraceQueryIssueCode;
path: Array<string | number>;
message: string;
}
export declare class TraceQueryValidationError extends Error {
readonly issues: TraceQueryIssue[];
readonly code = "TRACE_QUERY_INVALID";
constructor(issues: TraceQueryIssue[]);
}
export declare class TraceQueryCursorError extends Error {
readonly code: 'TRACE_QUERY_CURSOR_MALFORMED' | 'TRACE_QUERY_CURSOR_CONFLICT';
constructor(code: 'TRACE_QUERY_CURSOR_MALFORMED' | 'TRACE_QUERY_CURSOR_CONFLICT');
}
/** A valid query uses a feature the selected storage adapter cannot execute. */
export declare class TraceQueryUnsupportedError extends Error {
readonly code = "TRACE_QUERY_UNSUPPORTED";
constructor(message: string);
}
export declare class TraceQueryExecutionError extends Error {
readonly code = "TRACE_QUERY_EXECUTION_TIMEOUT";
constructor();
}
export declare class TraceQueryResourceLimitError extends Error {
readonly code = "TRACE_QUERY_RESOURCE_LIMIT";
constructor();
}
export declare function resolveTraceQueryTimeoutMs(timeoutMs?: number): number;
type PredicateContext = TraceQueryPredicateScope | 'spanQuery' | 'threadQuery';
/** @internal */
export interface PlannerState {
allowTokenSearch?: boolean;
isThreadQuery?: boolean;
nodes: number;
relatedClauses: number;
literalUnits: number;
issues: TraceQueryIssue[];
}
/** @internal Pre-parse complexity guard shared by the trace-query and trace-aggregate request schemas. */
export declare function findPredicateComplexityIssue(input: unknown, rootPaths: Array<Array<string | number>>): Array<string | number> | undefined;
export declare function isTraceQueryMetadataPath(path: string): path is TraceQueryMetadataField;
export declare function isTraceQueryValueSuggestionsPath(scope: TraceQueryPredicateScope, path: string): boolean;
export declare function getTraceQueryCanonicalFieldDescriptors(scope: TraceQueryPredicateScope, search?: string): TraceQueryCanonicalFieldDescriptor[];
export declare function createTraceQueryObservedFieldDescriptor(path: string, occurrences: number): TraceQueryObservedFieldDescriptor;
export declare function parseGetTraceQueryFieldsArgs(input: unknown): NormalizedGetTraceQueryFieldsArgs;
export declare function parseGetTraceQueryValuesArgs(input: unknown): NormalizedGetTraceQueryValuesArgs;
export interface TraceQueryPlanOptions {
/** Opt in only when the host checks indexed token-search support before execution. */
allowTokenSearch?: boolean;
/** The host provides an aggregated-root reader. Defaults to false. */
allowAggregatedRoots?: boolean;
/** Opaque host authorization state bound into keyset cursors. */
authorizationBinding?: string;
/** Trusted tenant scope; applied by stores and bound into keyset cursors. */
scope?: TraceQueryTenantScope;
}
export declare function planTraceQueryObservedFields(args: NormalizedGetTraceQueryFieldsArgs, options?: Pick<TraceQueryPlanOptions, 'scope'>): TrustedTraceQueryObservedFieldsPlan;
export declare function planTraceQueryValues(args: NormalizedGetTraceQueryValuesArgs, options?: Pick<TraceQueryPlanOptions, 'scope'>): TrustedTraceQueryValuesPlan;
/**
* Drops an absent `resourceId` so the plan and cursor binding are canonical.
*
* @internal Shared with the trace-aggregate planner.
*/
export declare function normalizeTraceQueryTenantScope(scope: TraceQueryTenantScope | undefined): TraceQueryTenantScope | undefined;
export declare function formatTraceQuerySchemaIssues(error: z.ZodError): TraceQueryIssue[];
export declare function parseTraceQueryRequest(input: unknown): NormalizedTraceQueryRequest;
export declare function parseQueryThreadsInput(input: unknown): NormalizedQueryThreadsInput;
/** @internal */
export declare function planThreadPredicate(predicate: ThreadPredicate, path: Array<string | number>, depth: number, state: PlannerState): TrustedThreadPredicate | undefined;
/**
* Plans a trace-scope selection predicate with a fresh complexity budget, appending any
* problems to `issues`.
*
* @internal Shared with the trace-aggregate planner so both apply identical selection
* validation.
*/
export declare function planTraceQuerySelectionPredicate(where: TraceQueryPredicate, issues: TraceQueryIssue[], path?: Array<string | number>, allowTokenSearch?: boolean): TrustedTraceQueryPredicate | undefined;
/** @internal Plans a direct span-row predicate without changing related trace predicates. */
export declare function planSpanQuerySelectionPredicate(where: TraceQueryScalarPredicate, issues: TraceQueryIssue[], allowTokenSearch?: boolean): TrustedTraceQueryScalarPredicate | undefined;
/** @internal Shares scalar validation without admitting related-trace predicates. */
export declare function planThreadQuerySelectionPredicate(where: TraceQueryScalarPredicate, issues: TraceQueryIssue[]): TrustedTraceQueryScalarPredicate | undefined;
/** @internal */
export declare function planPredicate(predicate: TraceQueryPredicate | TraceQueryScalarPredicate, context: PredicateContext, path: Array<string | number>, depth: number, state: PlannerState, underNegation?: boolean): TrustedTraceQueryPredicate | TrustedTraceQueryScalarPredicate | undefined;
/**
* Unwraps `${...}` templates and trims a caller-supplied field path.
*
* @internal Shared with the trace-aggregate planner so dimension, measure, and `having`
* paths are normalized exactly like predicate paths.
*/
export declare function normalizeTraceQueryPath(path: string): string;
/**
* Lowercases text and reduces it to its words: maximal runs of Unicode letters, combining
* marks, and digits, joined by single spaces. Text is composed to NFC first, so an accent
* stored as a separate mark equals its precomposed form, and marks stay inside their word,
* so `नमस्ते` is one word. After that, `İ` folds to plain `i`: it is the only letter whose lowercase form
* is two code points, and the stores' `lower()` returns one. A Greek final `ς` becomes `σ`, since
* `toLowerCase()` picks the final form by position and the stores' `lower()` does not. `matches` succeeds when the
* normalized literal appears as a contiguous word sequence inside the normalized field
* value. Stores apply the same normalization in SQL, so `incorrect` matches
* `This answer is incorrect.` but not `This was incorrectly formatted.`
*/
export declare function normalizeTraceQueryText(text: string): string;
/** Whether a trusted predicate requires indexed token-search support. */
export declare function hasTraceQueryTokenPredicate(predicate: TrustedTraceQueryPredicate | undefined): boolean;
export {};
//# sourceMappingURL=trace-query.d.ts.map