Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { FunctionName } from '@shared/types/api/request';
import { AIProvider } from '@shared/types/constants';
import { HttpMethod } from '@shared/types/http';
import { CacheMode, CacheStatus } from '@shared/types/middleware/cache';
import { Hook, HookResult } from '@shared/types/middleware/hooks';
import { z } from 'zod';
export const LogResponseBodyError = z.object({
message: z.string(),
response: z.string(),
});
export type LogResponseBodyError = z.infer<typeof LogResponseBodyError>;
export const AIProviderRequestLog = z.object({
provider: z.enum(AIProvider),
function_name: z.enum(FunctionName),
method: z.enum(HttpMethod),
request_url: z.string(),
status: z.number(),
request_body: z.record(z.string(), z.unknown()),
response_body: z.record(z.string(), z.unknown()).nullable(), // Allow null for streaming responses
raw_request_body: z.string(),
raw_response_body: z.string(),
cache_mode: z.enum(CacheMode),
cache_status: z.enum(CacheStatus),
});
export type AIProviderRequestLog = z.infer<typeof AIProviderRequestLog>;
export const HookLog = z.object({
trace_id: z.string(),
hook: Hook,
result: HookResult,
request_body: z.record(z.string(), z.unknown()).optional(),
response_body: z.record(z.string(), z.unknown()).optional(),
start_time: z.number(),
end_time: z.number(),
duration: z.number(),
cache_status: z.enum(CacheStatus),
});
export type HookLog = z.infer<typeof HookLog>;
export const Log = z.object({
// Base info
id: z.uuid(),
agent_id: z.uuid(),
skill_id: z.uuid(),
cluster_id: z.uuid().nullable(),
method: z.enum(HttpMethod),
endpoint: z.string(),
function_name: z.enum(FunctionName),
status: z.number(),
start_time: z.number(),
first_token_time: z.number().nullable(),
end_time: z.number(),
duration: z.number(),
base_sa_config: z.record(z.string(), z.unknown()),
// Maybe redundant. Used for indexing.
ai_provider: z.enum(AIProvider),
model: z.string(),
// Main data
ai_provider_request_log: AIProviderRequestLog,
hook_logs: z.array(HookLog),
metadata: z.record(z.string(), z.unknown()),
embedding: z.array(z.number()).nullable(),
// Cache info
cache_status: z.enum(CacheStatus),
// Tracing info
trace_id: z.string().nullable(),
parent_span_id: z.string().nullable(),
span_id: z.string().nullable(),
span_name: z.string().nullable(),
// User metadata
app_id: z.string().nullable(),
external_user_id: z.string().nullable(),
external_user_human_name: z.string().nullable(),
user_metadata: z.record(z.string(), z.unknown()).nullable(),
// Computed fields from logs_with_eval_scores view (optional)
avg_eval_score: z.number().nullable().optional(),
eval_run_count: z.number().int().nullable().optional(),
});
export type Log = z.infer<typeof Log>;
export type LogMessage = {
data: string;
event: string;
id: string;
};
export interface LogsClient {
sendLog: (logMessage: LogMessage) => Promise<void>;
}
export const LogsQueryParams = z.object({
id: z.uuid().optional(),
ids: z.array(z.uuid()).optional(),
agent_id: z.uuid().optional(),
skill_id: z.uuid().optional(),
cluster_id: z.uuid().optional(),
arm_id: z.uuid().optional(),
app_id: z.uuid().optional(),
after: z
.string()
.transform((val) => (val ? Number(val) : undefined))
.optional(),
before: z
.string()
.transform((val) => (val ? Number(val) : undefined))
.optional(),
method: z.enum(HttpMethod).optional(),
endpoint: z.string().optional(),
function_name: z.string().optional(),
status: z
.string()
.transform((val) => (val ? Number(val) : undefined))
.optional(),
cache_status: z.enum(CacheStatus).optional(),
embedding_not_null: z.coerce.boolean().optional(),
limit: z.string().default('50').transform(Number).optional(),
offset: z.string().default('0').transform(Number).optional(),
});
export type LogsQueryParams = z.infer<typeof LogsQueryParams>;
export const LogCreateParams = z.object({
agent_id: z.uuid(),
skill_id: z.uuid(),
cluster_id: z.uuid().optional(),
method: z.enum(HttpMethod),
endpoint: z.string(),
function_name: z.enum(FunctionName),
status: z.int(),
start_time: z.number(),
first_token_time: z.number().optional(),
end_time: z.number(),
duration: z.number(),
base_sa_config: z.record(z.string(), z.unknown()),
// Maybe redundant. Used for indexing.
ai_provider: z.enum(AIProvider),
model: z.string(),
// Main data
ai_provider_request_log: AIProviderRequestLog,
hook_logs: z.array(HookLog),
metadata: z.record(z.string(), z.unknown()),
embedding: z.array(z.number()).optional(),
// Cache info
cache_status: z.enum(CacheStatus),
// Tracing info
trace_id: z.string().optional(),
parent_span_id: z.string().optional(),
span_id: z.string().optional(),
span_name: z.string().optional(),
// User metadata
app_id: z.string().optional(),
external_user_id: z.string().optional(),
external_user_human_name: z.string().optional(),
user_metadata: z.record(z.string(), z.unknown()).optional(),
});
export type LogCreateParams = z.infer<typeof LogCreateParams>;
|