UNPKG

@mastra/core

Version:
175 lines • 7.34 kB
/** Full-history thread rows. Legacy identity queries remain in trace-query.ts. */ import { z } from 'zod/v4'; import type { TraceQueryPlanOptions, TrustedTraceQueryScalarPredicate } from './trace-query.js'; export { THREAD_QUERY_FIELD_REGISTRY } from './trace-query.js'; export type { ThreadQueryField } from './trace-query.js'; export declare const THREAD_QUERY_MAX_LIMIT = 100; export declare const THREAD_QUERY_DEFAULT_LIMIT = 25; declare const requestSchema: z.ZodObject<{ timeRange: z.ZodUnion<readonly [z.ZodObject<{ traces: z.ZodObject<{ from: z.ZodString; to: z.ZodString; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ threads: z.ZodObject<{ from: z.ZodString; to: z.ZodString; field: z.ZodEnum<{ endedAt: "endedAt"; startedAt: "startedAt"; }>; }, z.core.$strict>; }, z.core.$strict>]>; where: z.ZodOptional<z.ZodType<import("./trace-query").TraceQueryScalarPredicate, import("./trace-query").TraceQueryScalarPredicate, z.core.$ZodTypeInternals<import("./trace-query").TraceQueryScalarPredicate, import("./trace-query").TraceQueryScalarPredicate>>>; orderBy: z.ZodDefault<z.ZodArray<z.ZodObject<{ field: z.ZodEnum<{ endedAt: "endedAt"; startedAt: "startedAt"; }>; direction: z.ZodEnum<{ asc: "asc"; desc: "desc"; }>; }, z.core.$strict>>>; page: z.ZodDefault<z.ZodObject<{ limit: z.ZodDefault<z.ZodNumber>; after: z.ZodOptional<z.ZodString>; }, z.core.$strict>>; }, z.core.$strict>; export declare const threadQueryRequestSchema: z.ZodPreprocess<z.ZodObject<{ timeRange: z.ZodUnion<readonly [z.ZodObject<{ traces: z.ZodObject<{ from: z.ZodString; to: z.ZodString; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ threads: z.ZodObject<{ from: z.ZodString; to: z.ZodString; field: z.ZodEnum<{ endedAt: "endedAt"; startedAt: "startedAt"; }>; }, z.core.$strict>; }, z.core.$strict>]>; where: z.ZodOptional<z.ZodType<import("./trace-query").TraceQueryScalarPredicate, import("./trace-query").TraceQueryScalarPredicate, z.core.$ZodTypeInternals<import("./trace-query").TraceQueryScalarPredicate, import("./trace-query").TraceQueryScalarPredicate>>>; orderBy: z.ZodDefault<z.ZodArray<z.ZodObject<{ field: z.ZodEnum<{ endedAt: "endedAt"; startedAt: "startedAt"; }>; direction: z.ZodEnum<{ asc: "asc"; desc: "desc"; }>; }, z.core.$strict>>>; page: z.ZodDefault<z.ZodObject<{ limit: z.ZodDefault<z.ZodNumber>; after: z.ZodOptional<z.ZodString>; }, z.core.$strict>>; }, z.core.$strict>, unknown>; export declare const threadQueryIdentitySchema: z.ZodObject<{ organizationId: z.ZodNullable<z.ZodString>; threadId: z.ZodString; }, z.core.$strict>; export declare const threadQueryRowSchema: z.ZodObject<{ organizationId: z.ZodNullable<z.ZodString>; threadId: z.ZodString; firstTraceId: z.ZodString; lastTraceId: z.ZodString; resourceId: z.ZodNullable<z.ZodString>; userId: z.ZodNullable<z.ZodString>; entityType: z.ZodNullable<z.ZodString>; entityId: z.ZodNullable<z.ZodString>; entityName: z.ZodNullable<z.ZodString>; entityVersionId: z.ZodNullable<z.ZodString>; runId: z.ZodNullable<z.ZodString>; sessionId: z.ZodNullable<z.ZodString>; requestId: z.ZodNullable<z.ZodString>; serviceName: z.ZodNullable<z.ZodString>; experimentId: z.ZodNullable<z.ZodString>; environment: z.ZodNullable<z.ZodString>; executionSource: z.ZodNullable<z.ZodString>; status: z.ZodEnum<{ error: "error"; success: "success"; }>; startedAt: z.ZodString; endedAt: z.ZodString; timeToFirstChunkMs: z.ZodNullable<z.ZodNumber>; timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>; inputPreview: z.ZodNullable<z.ZodString>; outputPreview: z.ZodNullable<z.ZodString>; errorPreview: z.ZodNullable<z.ZodString>; traceCount: z.ZodNumber; }, z.core.$strip>; export declare const threadQueryResponseSchema: z.ZodObject<{ threads: z.ZodArray<z.ZodObject<{ organizationId: z.ZodNullable<z.ZodString>; threadId: z.ZodString; firstTraceId: z.ZodString; lastTraceId: z.ZodString; resourceId: z.ZodNullable<z.ZodString>; userId: z.ZodNullable<z.ZodString>; entityType: z.ZodNullable<z.ZodString>; entityId: z.ZodNullable<z.ZodString>; entityName: z.ZodNullable<z.ZodString>; entityVersionId: z.ZodNullable<z.ZodString>; runId: z.ZodNullable<z.ZodString>; sessionId: z.ZodNullable<z.ZodString>; requestId: z.ZodNullable<z.ZodString>; serviceName: z.ZodNullable<z.ZodString>; experimentId: z.ZodNullable<z.ZodString>; environment: z.ZodNullable<z.ZodString>; executionSource: z.ZodNullable<z.ZodString>; status: z.ZodEnum<{ error: "error"; success: "success"; }>; startedAt: z.ZodString; endedAt: z.ZodString; timeToFirstChunkMs: z.ZodNullable<z.ZodNumber>; timeToFirstTokenMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>; inputPreview: z.ZodNullable<z.ZodString>; outputPreview: z.ZodNullable<z.ZodString>; errorPreview: z.ZodNullable<z.ZodString>; traceCount: z.ZodNumber; }, z.core.$strip>>; page: z.ZodObject<{ next: z.ZodNullable<z.ZodString>; }, z.core.$strict>; }, z.core.$strict>; export type ThreadQueryRequest = z.input<typeof requestSchema>; export type NormalizedThreadQueryRequest = z.output<typeof requestSchema>; export type ThreadQueryRow = z.infer<typeof threadQueryRowSchema>; export type ThreadQueryResponse = z.infer<typeof threadQueryResponseSchema>; declare const cursorValuesSchema: z.ZodObject<{ organizationId: z.ZodNullable<z.ZodString>; threadId: z.ZodString; sortValue: z.ZodString; }, z.core.$strict>; /** * Scope applies to both qualification and population. Group by organizationId/threadId; * nullable organization IDs sort last. Other context comes from the first trace. * Order by the requested activity timestamp, then organizationId/threadId ascending * with bytewise string ordering. First/last traces use (startedAt, traceId). */ export interface TrustedThreadRowsQueryPlan { result: 'threadRows'; timeRange: { mode: 'traces' | 'threads'; field: 'startedAt' | 'endedAt'; from: string; to: string; }; where?: TrustedTraceQueryScalarPredicate; scope?: TraceQueryPlanOptions['scope']; orderBy: NormalizedThreadQueryRequest['orderBy'][number]; limit: number; binding: string; cursor?: z.infer<typeof cursorValuesSchema>; } export declare function planThreadRowsQuery(input: unknown, options?: TraceQueryPlanOptions): TrustedThreadRowsQueryPlan; export declare function encodeThreadQueryCursor(plan: TrustedThreadRowsQueryPlan, values: z.infer<typeof cursorValuesSchema>): string; //# sourceMappingURL=thread-query.d.ts.map