@evalgate/sdk 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +638 -0
- package/README.md +398 -0
- package/dist/assertions.d.ts +189 -0
- package/dist/assertions.js +662 -0
- package/dist/batch.d.ts +68 -0
- package/dist/batch.js +179 -0
- package/dist/cache.d.ts +65 -0
- package/dist/cache.js +131 -0
- package/dist/cli/api.d.ts +108 -0
- package/dist/cli/api.js +132 -0
- package/dist/cli/baseline.d.ts +10 -0
- package/dist/cli/baseline.js +172 -0
- package/dist/cli/check.d.ts +73 -0
- package/dist/cli/check.js +355 -0
- package/dist/cli/ci-context.d.ts +6 -0
- package/dist/cli/ci-context.js +112 -0
- package/dist/cli/ci.d.ts +45 -0
- package/dist/cli/ci.js +192 -0
- package/dist/cli/config.d.ts +30 -0
- package/dist/cli/config.js +230 -0
- package/dist/cli/constants.d.ts +15 -0
- package/dist/cli/constants.js +18 -0
- package/dist/cli/diff.d.ts +173 -0
- package/dist/cli/diff.js +685 -0
- package/dist/cli/discover.d.ts +84 -0
- package/dist/cli/discover.js +419 -0
- package/dist/cli/doctor.d.ts +88 -0
- package/dist/cli/doctor.js +675 -0
- package/dist/cli/env.d.ts +21 -0
- package/dist/cli/env.js +42 -0
- package/dist/cli/explain.d.ts +58 -0
- package/dist/cli/explain.js +561 -0
- package/dist/cli/formatters/github.d.ts +8 -0
- package/dist/cli/formatters/github.js +135 -0
- package/dist/cli/formatters/human.d.ts +6 -0
- package/dist/cli/formatters/human.js +110 -0
- package/dist/cli/formatters/json.d.ts +6 -0
- package/dist/cli/formatters/json.js +10 -0
- package/dist/cli/formatters/pr-comment.d.ts +12 -0
- package/dist/cli/formatters/pr-comment.js +103 -0
- package/dist/cli/formatters/types.d.ts +103 -0
- package/dist/cli/formatters/types.js +8 -0
- package/dist/cli/gate.d.ts +21 -0
- package/dist/cli/gate.js +179 -0
- package/dist/cli/impact-analysis.d.ts +63 -0
- package/dist/cli/impact-analysis.js +252 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +332 -0
- package/dist/cli/init.d.ts +16 -0
- package/dist/cli/init.js +292 -0
- package/dist/cli/manifest.d.ts +103 -0
- package/dist/cli/manifest.js +282 -0
- package/dist/cli/migrate.d.ts +41 -0
- package/dist/cli/migrate.js +349 -0
- package/dist/cli/policy-packs.d.ts +23 -0
- package/dist/cli/policy-packs.js +89 -0
- package/dist/cli/print-config.d.ts +29 -0
- package/dist/cli/print-config.js +270 -0
- package/dist/cli/profiles.d.ts +28 -0
- package/dist/cli/profiles.js +30 -0
- package/dist/cli/reason-codes.d.ts +17 -0
- package/dist/cli/reason-codes.js +19 -0
- package/dist/cli/regression-gate.d.ts +15 -0
- package/dist/cli/regression-gate.js +341 -0
- package/dist/cli/render/snippet.d.ts +5 -0
- package/dist/cli/render/snippet.js +15 -0
- package/dist/cli/render/sort.d.ts +10 -0
- package/dist/cli/render/sort.js +24 -0
- package/dist/cli/report/build-check-report.d.ts +19 -0
- package/dist/cli/report/build-check-report.js +132 -0
- package/dist/cli/run.d.ts +101 -0
- package/dist/cli/run.js +395 -0
- package/dist/cli/share.d.ts +17 -0
- package/dist/cli/share.js +91 -0
- package/dist/cli/upgrade.d.ts +15 -0
- package/dist/cli/upgrade.js +492 -0
- package/dist/cli/workspace.d.ts +31 -0
- package/dist/cli/workspace.js +68 -0
- package/dist/client.d.ts +368 -0
- package/dist/client.js +893 -0
- package/dist/client.request.test.d.ts +1 -0
- package/dist/client.request.test.js +232 -0
- package/dist/context.d.ts +134 -0
- package/dist/context.js +215 -0
- package/dist/errors.d.ts +82 -0
- package/dist/errors.js +298 -0
- package/dist/export.d.ts +195 -0
- package/dist/export.js +344 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +153 -0
- package/dist/integrations/anthropic.d.ts +91 -0
- package/dist/integrations/anthropic.js +163 -0
- package/dist/integrations/openai-eval.d.ts +57 -0
- package/dist/integrations/openai-eval.js +232 -0
- package/dist/integrations/openai.d.ts +92 -0
- package/dist/integrations/openai.js +160 -0
- package/dist/local.d.ts +39 -0
- package/dist/local.js +148 -0
- package/dist/logger.d.ts +128 -0
- package/dist/logger.js +227 -0
- package/dist/matchers/index.d.ts +1 -0
- package/dist/matchers/index.js +6 -0
- package/dist/matchers/to-pass-gate.d.ts +29 -0
- package/dist/matchers/to-pass-gate.js +35 -0
- package/dist/pagination.d.ts +74 -0
- package/dist/pagination.js +139 -0
- package/dist/regression.d.ts +100 -0
- package/dist/regression.js +44 -0
- package/dist/runtime/adapters/config-to-dsl.d.ts +33 -0
- package/dist/runtime/adapters/config-to-dsl.js +400 -0
- package/dist/runtime/adapters/testsuite-to-dsl.d.ts +63 -0
- package/dist/runtime/adapters/testsuite-to-dsl.js +276 -0
- package/dist/runtime/context.d.ts +26 -0
- package/dist/runtime/context.js +74 -0
- package/dist/runtime/eval.d.ts +46 -0
- package/dist/runtime/eval.js +244 -0
- package/dist/runtime/execution-mode.d.ts +80 -0
- package/dist/runtime/execution-mode.js +357 -0
- package/dist/runtime/executor.d.ts +16 -0
- package/dist/runtime/executor.js +152 -0
- package/dist/runtime/registry.d.ts +78 -0
- package/dist/runtime/registry.js +403 -0
- package/dist/runtime/run-report.d.ts +200 -0
- package/dist/runtime/run-report.js +222 -0
- package/dist/runtime/types.d.ts +356 -0
- package/dist/runtime/types.js +76 -0
- package/dist/snapshot.d.ts +176 -0
- package/dist/snapshot.js +322 -0
- package/dist/streaming.d.ts +173 -0
- package/dist/streaming.js +268 -0
- package/dist/testing.d.ts +273 -0
- package/dist/testing.js +317 -0
- package/dist/types.d.ts +754 -0
- package/dist/types.js +54 -0
- package/dist/utils/input-hash.d.ts +8 -0
- package/dist/utils/input-hash.js +41 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.js +10 -0
- package/dist/workflows.d.ts +389 -0
- package/dist/workflows.js +671 -0
- package/package.json +117 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,754 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for the EvalGate SDK client
|
|
3
|
+
* Tier 1.4: TypeScript-First with Generics
|
|
4
|
+
*/
|
|
5
|
+
export interface ClientConfig {
|
|
6
|
+
/** Your API key from the EvalGate dashboard */
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
/** Base URL for the API (default: relative URLs in browser, http://localhost:3000 in Node.js) */
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
/** Organization ID for multi-tenant setups */
|
|
11
|
+
organizationId?: number;
|
|
12
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
13
|
+
timeout?: number;
|
|
14
|
+
/** Debug mode - enables request/response logging (default: false) */
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
/** Log level for debug mode (default: 'info') */
|
|
17
|
+
logLevel?: "trace" | "debug" | "info" | "warn" | "error";
|
|
18
|
+
/** Retry configuration */
|
|
19
|
+
retry?: {
|
|
20
|
+
/** Maximum retry attempts (default: 3) */
|
|
21
|
+
maxAttempts?: number;
|
|
22
|
+
/** Backoff strategy (default: 'exponential') */
|
|
23
|
+
backoff?: "exponential" | "linear" | "fixed";
|
|
24
|
+
/** Retryable error codes */
|
|
25
|
+
retryableErrors?: string[];
|
|
26
|
+
};
|
|
27
|
+
/** Enable request caching for GET requests (default: true) */
|
|
28
|
+
enableCaching?: boolean;
|
|
29
|
+
/** Maximum cache size in entries (default: 1000) */
|
|
30
|
+
cacheSize?: number;
|
|
31
|
+
/** Enable request batching (default: true) */
|
|
32
|
+
enableBatching?: boolean;
|
|
33
|
+
/** Maximum batch size (default: 10) */
|
|
34
|
+
batchSize?: number;
|
|
35
|
+
/** Batch delay in milliseconds (default: 50) */
|
|
36
|
+
batchDelay?: number;
|
|
37
|
+
/** Enable HTTP keep-alive for connection pooling (default: true) */
|
|
38
|
+
keepAlive?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Evaluation template categories
|
|
42
|
+
* Updated with new template types for comprehensive LLM testing
|
|
43
|
+
*/
|
|
44
|
+
export declare const EvaluationTemplates: {
|
|
45
|
+
readonly UNIT_TESTING: "unit-testing";
|
|
46
|
+
readonly OUTPUT_QUALITY: "output-quality";
|
|
47
|
+
readonly PROMPT_OPTIMIZATION: "prompt-optimization";
|
|
48
|
+
readonly CHAIN_OF_THOUGHT: "chain-of-thought";
|
|
49
|
+
readonly LONG_CONTEXT_TESTING: "long-context-testing";
|
|
50
|
+
readonly MODEL_STEERING: "model-steering";
|
|
51
|
+
readonly REGRESSION_TESTING: "regression-testing";
|
|
52
|
+
readonly CONFIDENCE_CALIBRATION: "confidence-calibration";
|
|
53
|
+
readonly SAFETY_COMPLIANCE: "safety-compliance";
|
|
54
|
+
readonly RAG_EVALUATION: "rag-evaluation";
|
|
55
|
+
readonly CODE_GENERATION: "code-generation";
|
|
56
|
+
readonly SUMMARIZATION: "summarization";
|
|
57
|
+
};
|
|
58
|
+
export type EvaluationTemplateType = (typeof EvaluationTemplates)[keyof typeof EvaluationTemplates];
|
|
59
|
+
/**
|
|
60
|
+
* Feature usage limits for per-organization quotas
|
|
61
|
+
*/
|
|
62
|
+
export interface FeatureUsage {
|
|
63
|
+
/** Feature ID (e.g., 'traces_per_project', 'evals_per_project') */
|
|
64
|
+
feature_id: string;
|
|
65
|
+
/** Whether the feature has unlimited usage */
|
|
66
|
+
unlimited: boolean;
|
|
67
|
+
/** Billing interval (month, year, etc.) */
|
|
68
|
+
interval: string;
|
|
69
|
+
/** Remaining balance */
|
|
70
|
+
balance: number;
|
|
71
|
+
/** Current usage amount */
|
|
72
|
+
usage: number;
|
|
73
|
+
/** Total included usage allowance */
|
|
74
|
+
included_usage: number;
|
|
75
|
+
/** When the usage resets */
|
|
76
|
+
next_reset_at: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Organization resource limits
|
|
80
|
+
*/
|
|
81
|
+
export interface OrganizationLimits {
|
|
82
|
+
/** Traces per organization limit */
|
|
83
|
+
traces_per_organization?: FeatureUsage;
|
|
84
|
+
/** Evaluations per organization limit */
|
|
85
|
+
evals_per_organization?: FeatureUsage;
|
|
86
|
+
/** Annotations per organization limit */
|
|
87
|
+
annotations_per_organization?: FeatureUsage;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Trace object representing a single execution trace
|
|
91
|
+
* Generic metadata support for type safety
|
|
92
|
+
*/
|
|
93
|
+
export interface Trace<TMetadata = Record<string, unknown>> {
|
|
94
|
+
id: number;
|
|
95
|
+
name: string;
|
|
96
|
+
traceId: string;
|
|
97
|
+
organizationId: number;
|
|
98
|
+
status: "pending" | "success" | "error";
|
|
99
|
+
durationMs: number | null;
|
|
100
|
+
metadata: TMetadata | null;
|
|
101
|
+
createdAt: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Parameters for creating a new trace
|
|
105
|
+
*/
|
|
106
|
+
export interface CreateTraceParams<TMetadata = Record<string, unknown>> {
|
|
107
|
+
name: string;
|
|
108
|
+
traceId: string;
|
|
109
|
+
organizationId?: number;
|
|
110
|
+
status?: "pending" | "success" | "error";
|
|
111
|
+
durationMs?: number;
|
|
112
|
+
metadata?: TMetadata;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Parameters for updating an existing trace
|
|
116
|
+
*/
|
|
117
|
+
export interface UpdateTraceParams<TMetadata = Record<string, unknown>> {
|
|
118
|
+
status?: "pending" | "success" | "error";
|
|
119
|
+
durationMs?: number;
|
|
120
|
+
metadata?: TMetadata;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parameters for listing traces
|
|
124
|
+
*/
|
|
125
|
+
export interface ListTracesParams {
|
|
126
|
+
limit?: number;
|
|
127
|
+
offset?: number;
|
|
128
|
+
organizationId?: number;
|
|
129
|
+
status?: "pending" | "success" | "error";
|
|
130
|
+
search?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Span object representing a sub-operation within a trace
|
|
134
|
+
*/
|
|
135
|
+
export interface Span<TMetadata = Record<string, unknown>> {
|
|
136
|
+
id: number;
|
|
137
|
+
traceId: number;
|
|
138
|
+
name: string;
|
|
139
|
+
spanId: string;
|
|
140
|
+
parentSpanId: string | null;
|
|
141
|
+
startTime: string;
|
|
142
|
+
endTime: string | null;
|
|
143
|
+
durationMs: number | null;
|
|
144
|
+
metadata: TMetadata | null;
|
|
145
|
+
createdAt: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Parameters for creating a span
|
|
149
|
+
*/
|
|
150
|
+
export interface CreateSpanParams<TMetadata = Record<string, unknown>> {
|
|
151
|
+
name: string;
|
|
152
|
+
spanId: string;
|
|
153
|
+
type: string;
|
|
154
|
+
parentSpanId?: string;
|
|
155
|
+
startTime: string;
|
|
156
|
+
endTime?: string;
|
|
157
|
+
durationMs?: number;
|
|
158
|
+
input?: unknown;
|
|
159
|
+
output?: unknown;
|
|
160
|
+
metadata?: TMetadata;
|
|
161
|
+
evaluationRunId?: number | null;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Evaluation object representing a test evaluation
|
|
165
|
+
*/
|
|
166
|
+
export interface Evaluation<TMetadata = Record<string, unknown>> {
|
|
167
|
+
id: number;
|
|
168
|
+
name: string;
|
|
169
|
+
description: string | null;
|
|
170
|
+
type: string;
|
|
171
|
+
status: "draft" | "active" | "archived";
|
|
172
|
+
organizationId: number;
|
|
173
|
+
createdBy: number;
|
|
174
|
+
createdAt: string;
|
|
175
|
+
updatedAt: string;
|
|
176
|
+
metadata?: TMetadata | null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Parameters for creating a new evaluation
|
|
180
|
+
*/
|
|
181
|
+
export interface CreateEvaluationParams {
|
|
182
|
+
name: string;
|
|
183
|
+
description?: string;
|
|
184
|
+
type: string;
|
|
185
|
+
organizationId?: number;
|
|
186
|
+
createdBy: number;
|
|
187
|
+
status?: "draft" | "active" | "archived";
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Parameters for updating an evaluation
|
|
191
|
+
*/
|
|
192
|
+
export interface UpdateEvaluationParams {
|
|
193
|
+
name?: string;
|
|
194
|
+
description?: string;
|
|
195
|
+
type?: string;
|
|
196
|
+
status?: "draft" | "active" | "archived";
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Parameters for listing evaluations
|
|
200
|
+
*/
|
|
201
|
+
export interface ListEvaluationsParams {
|
|
202
|
+
limit?: number;
|
|
203
|
+
offset?: number;
|
|
204
|
+
organizationId?: number;
|
|
205
|
+
type?: string;
|
|
206
|
+
status?: "draft" | "active" | "archived";
|
|
207
|
+
search?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Test case for an evaluation
|
|
211
|
+
*/
|
|
212
|
+
export interface TestCase {
|
|
213
|
+
id: number;
|
|
214
|
+
evaluationId: number;
|
|
215
|
+
input: string;
|
|
216
|
+
expectedOutput: string | null;
|
|
217
|
+
metadata: Record<string, unknown> | null;
|
|
218
|
+
createdAt: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Parameters for creating a test case
|
|
222
|
+
*/
|
|
223
|
+
export interface CreateTestCaseParams {
|
|
224
|
+
input: string;
|
|
225
|
+
expectedOutput?: string;
|
|
226
|
+
metadata?: Record<string, unknown>;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Evaluation run
|
|
230
|
+
*/
|
|
231
|
+
export interface EvaluationRun {
|
|
232
|
+
id: number;
|
|
233
|
+
evaluationId: number;
|
|
234
|
+
organizationId: number;
|
|
235
|
+
status: string;
|
|
236
|
+
totalCases: number | null;
|
|
237
|
+
passedCases: number | null;
|
|
238
|
+
failedCases: number | null;
|
|
239
|
+
environment: string | null;
|
|
240
|
+
startedAt: string | null;
|
|
241
|
+
completedAt: string | null;
|
|
242
|
+
createdAt: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Result of getRun — includes the run and its test results
|
|
246
|
+
*/
|
|
247
|
+
export interface EvaluationRunDetail {
|
|
248
|
+
run: EvaluationRun;
|
|
249
|
+
results: Array<Record<string, unknown>>;
|
|
250
|
+
baselineResults?: Array<Record<string, unknown>>;
|
|
251
|
+
compareRunId?: number;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Parameters for creating an evaluation run
|
|
255
|
+
*/
|
|
256
|
+
export interface CreateRunParams {
|
|
257
|
+
environment?: string;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* LLM Judge evaluation result
|
|
261
|
+
*/
|
|
262
|
+
export interface LLMJudgeResult {
|
|
263
|
+
id: number;
|
|
264
|
+
configId: number;
|
|
265
|
+
input: string;
|
|
266
|
+
output: string;
|
|
267
|
+
score: number | null;
|
|
268
|
+
reasoning: string | null;
|
|
269
|
+
metadata: Record<string, unknown> | null;
|
|
270
|
+
createdAt: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Result of a single LLM judge evaluation call
|
|
274
|
+
*/
|
|
275
|
+
export interface LLMJudgeEvaluateResult {
|
|
276
|
+
score: number;
|
|
277
|
+
reasoning: string;
|
|
278
|
+
passed: boolean;
|
|
279
|
+
details: unknown;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Parameters for running an LLM judge evaluation
|
|
283
|
+
*/
|
|
284
|
+
export interface RunLLMJudgeParams {
|
|
285
|
+
configId: number;
|
|
286
|
+
input: string;
|
|
287
|
+
output: string;
|
|
288
|
+
score?: number;
|
|
289
|
+
reasoning?: string;
|
|
290
|
+
metadata?: Record<string, unknown>;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* SDK Error class with additional error details
|
|
294
|
+
*
|
|
295
|
+
* Common error codes:
|
|
296
|
+
* - MISSING_API_KEY: API key not provided
|
|
297
|
+
* - MISSING_ORGANIZATION_ID: Organization ID not provided
|
|
298
|
+
* - MISSING_REQUIRED_FIELDS: Required parameters missing
|
|
299
|
+
* - INVALID_ID: Invalid ID format
|
|
300
|
+
* - NOT_FOUND: Resource not found
|
|
301
|
+
* - UNAUTHORIZED: Authentication required
|
|
302
|
+
* - FORBIDDEN: Access forbidden
|
|
303
|
+
* - RATE_LIMIT_EXCEEDED: Rate limit exceeded
|
|
304
|
+
* - TIMEOUT: Request timed out
|
|
305
|
+
* - NETWORK_ERROR: Network connectivity issue
|
|
306
|
+
* - VALIDATION_ERROR: Request validation failed
|
|
307
|
+
* - INTERNAL_SERVER_ERROR: Server error
|
|
308
|
+
* - FEATURE_LIMIT_REACHED: Feature usage limit reached
|
|
309
|
+
* - UNKNOWN_ERROR: Unknown error occurred
|
|
310
|
+
*/
|
|
311
|
+
export declare class SDKError extends Error {
|
|
312
|
+
code: string;
|
|
313
|
+
statusCode: number;
|
|
314
|
+
details?: unknown;
|
|
315
|
+
documentation?: string;
|
|
316
|
+
solutions?: string[];
|
|
317
|
+
retryable?: boolean;
|
|
318
|
+
retryAfter?: number;
|
|
319
|
+
constructor(message: string, code: string, statusCode: number, details?: unknown);
|
|
320
|
+
}
|
|
321
|
+
export type AIEvalConfig = ClientConfig;
|
|
322
|
+
export type TraceData<TMetadata = unknown> = Trace<TMetadata>;
|
|
323
|
+
export type SpanData<TMetadata = unknown> = Span<TMetadata>;
|
|
324
|
+
export interface TraceDetail<TMetadata = Record<string, unknown>> {
|
|
325
|
+
trace: Trace<TMetadata>;
|
|
326
|
+
spans: Span<TMetadata>[];
|
|
327
|
+
}
|
|
328
|
+
export type EvaluationData<TMetadata = unknown> = Evaluation<TMetadata>;
|
|
329
|
+
export type LLMJudgeData = LLMJudgeResult;
|
|
330
|
+
export type AnnotationData = unknown;
|
|
331
|
+
export interface RetryConfig {
|
|
332
|
+
maxAttempts?: number;
|
|
333
|
+
backoff?: "exponential" | "linear" | "fixed";
|
|
334
|
+
retryableErrors?: string[];
|
|
335
|
+
}
|
|
336
|
+
export interface GenericMetadata {
|
|
337
|
+
[key: string]: unknown;
|
|
338
|
+
}
|
|
339
|
+
export interface TracedResponse<T> {
|
|
340
|
+
data: T;
|
|
341
|
+
traceId?: string;
|
|
342
|
+
metadata?: GenericMetadata;
|
|
343
|
+
}
|
|
344
|
+
export interface TestResult {
|
|
345
|
+
passed: boolean;
|
|
346
|
+
message?: string;
|
|
347
|
+
expected?: unknown;
|
|
348
|
+
actual?: unknown;
|
|
349
|
+
metadata?: GenericMetadata;
|
|
350
|
+
}
|
|
351
|
+
export interface SnapshotData {
|
|
352
|
+
id: string;
|
|
353
|
+
name: string;
|
|
354
|
+
data: unknown;
|
|
355
|
+
metadata?: GenericMetadata;
|
|
356
|
+
createdAt: string;
|
|
357
|
+
updatedAt: string;
|
|
358
|
+
}
|
|
359
|
+
export interface ExportOptions {
|
|
360
|
+
format: "json" | "csv" | "jsonl";
|
|
361
|
+
includeTraces?: boolean;
|
|
362
|
+
includeEvaluations?: boolean;
|
|
363
|
+
includeTestCases?: boolean;
|
|
364
|
+
includeRuns?: boolean;
|
|
365
|
+
dateRange?: {
|
|
366
|
+
from: string;
|
|
367
|
+
to: string;
|
|
368
|
+
};
|
|
369
|
+
organizationId?: number;
|
|
370
|
+
limit?: number;
|
|
371
|
+
}
|
|
372
|
+
export interface ImportOptions {
|
|
373
|
+
organizationId?: number;
|
|
374
|
+
createdBy?: number;
|
|
375
|
+
skipDuplicates?: boolean;
|
|
376
|
+
dryRun?: boolean;
|
|
377
|
+
}
|
|
378
|
+
export interface StreamOptions {
|
|
379
|
+
onData: (data: unknown) => void;
|
|
380
|
+
onError?: (error: Error) => void;
|
|
381
|
+
onComplete?: () => void;
|
|
382
|
+
signal?: AbortSignal;
|
|
383
|
+
}
|
|
384
|
+
export interface BatchOptions {
|
|
385
|
+
batchSize?: number;
|
|
386
|
+
concurrency?: number;
|
|
387
|
+
onProgress?: (progress: {
|
|
388
|
+
processed: number;
|
|
389
|
+
total: number;
|
|
390
|
+
}) => void;
|
|
391
|
+
signal?: AbortSignal;
|
|
392
|
+
}
|
|
393
|
+
export type ExportFormat = "json" | "csv" | "jsonl";
|
|
394
|
+
/**
|
|
395
|
+
* Annotation object representing human feedback
|
|
396
|
+
*/
|
|
397
|
+
export interface Annotation {
|
|
398
|
+
id: number;
|
|
399
|
+
evaluationRunId: number;
|
|
400
|
+
testCaseId: number;
|
|
401
|
+
annotatorId: string;
|
|
402
|
+
rating: number | null;
|
|
403
|
+
feedback: string | null;
|
|
404
|
+
labels: Record<string, unknown>;
|
|
405
|
+
metadata: Record<string, unknown>;
|
|
406
|
+
createdAt: string;
|
|
407
|
+
annotator?: {
|
|
408
|
+
id: string;
|
|
409
|
+
name: string;
|
|
410
|
+
email: string;
|
|
411
|
+
};
|
|
412
|
+
testCase?: {
|
|
413
|
+
name: string;
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Parameters for creating an annotation
|
|
418
|
+
*/
|
|
419
|
+
export interface CreateAnnotationParams {
|
|
420
|
+
evaluationRunId: number;
|
|
421
|
+
testCaseId: number;
|
|
422
|
+
rating?: number;
|
|
423
|
+
feedback?: string;
|
|
424
|
+
labels?: Record<string, unknown>;
|
|
425
|
+
metadata?: Record<string, unknown>;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Parameters for listing annotations
|
|
429
|
+
*/
|
|
430
|
+
export interface ListAnnotationsParams {
|
|
431
|
+
evaluationRunId?: number;
|
|
432
|
+
testCaseId?: number;
|
|
433
|
+
limit?: number;
|
|
434
|
+
offset?: number;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Annotation task object
|
|
438
|
+
*/
|
|
439
|
+
export interface AnnotationTask {
|
|
440
|
+
id: number;
|
|
441
|
+
name: string;
|
|
442
|
+
description: string | null;
|
|
443
|
+
instructions: string | null;
|
|
444
|
+
type: string;
|
|
445
|
+
status: "pending" | "in_progress" | "completed" | "archived";
|
|
446
|
+
organizationId: number;
|
|
447
|
+
annotationSettings: Record<string, unknown>;
|
|
448
|
+
createdAt: string;
|
|
449
|
+
updatedAt: string;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Parameters for creating an annotation task
|
|
453
|
+
*/
|
|
454
|
+
export interface CreateAnnotationTaskParams {
|
|
455
|
+
name: string;
|
|
456
|
+
description?: string;
|
|
457
|
+
instructions?: string;
|
|
458
|
+
type: string;
|
|
459
|
+
organizationId: number;
|
|
460
|
+
annotationSettings?: Record<string, unknown>;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Parameters for listing annotation tasks
|
|
464
|
+
*/
|
|
465
|
+
export interface ListAnnotationTasksParams {
|
|
466
|
+
organizationId?: number;
|
|
467
|
+
status?: "pending" | "in_progress" | "completed" | "archived";
|
|
468
|
+
limit?: number;
|
|
469
|
+
offset?: number;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Annotation item object
|
|
473
|
+
*/
|
|
474
|
+
export interface AnnotationItem {
|
|
475
|
+
id: number;
|
|
476
|
+
taskId: number;
|
|
477
|
+
content: string;
|
|
478
|
+
annotation: unknown | null;
|
|
479
|
+
annotatedBy: string | null;
|
|
480
|
+
annotatedAt: string | null;
|
|
481
|
+
createdAt: string;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Parameters for creating an annotation item
|
|
485
|
+
*/
|
|
486
|
+
export interface CreateAnnotationItemParams {
|
|
487
|
+
content: string;
|
|
488
|
+
annotation?: unknown;
|
|
489
|
+
annotatedBy?: string;
|
|
490
|
+
annotatedAt?: string;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Parameters for listing annotation items
|
|
494
|
+
*/
|
|
495
|
+
export interface ListAnnotationItemsParams {
|
|
496
|
+
limit?: number;
|
|
497
|
+
offset?: number;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* API Key object
|
|
501
|
+
*/
|
|
502
|
+
export interface APIKey {
|
|
503
|
+
id: number;
|
|
504
|
+
userId: string;
|
|
505
|
+
organizationId: number;
|
|
506
|
+
keyPrefix: string;
|
|
507
|
+
name: string;
|
|
508
|
+
scopes: string[];
|
|
509
|
+
lastUsedAt: string | null;
|
|
510
|
+
expiresAt: string | null;
|
|
511
|
+
revokedAt: string | null;
|
|
512
|
+
createdAt: string;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* API Key with full key (only returned on creation)
|
|
516
|
+
*/
|
|
517
|
+
export interface APIKeyWithSecret extends APIKey {
|
|
518
|
+
apiKey: string;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Parameters for creating an API key
|
|
522
|
+
*/
|
|
523
|
+
export interface CreateAPIKeyParams {
|
|
524
|
+
name: string;
|
|
525
|
+
organizationId: number;
|
|
526
|
+
scopes: string[];
|
|
527
|
+
expiresAt?: string;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Parameters for updating an API key
|
|
531
|
+
*/
|
|
532
|
+
export interface UpdateAPIKeyParams {
|
|
533
|
+
name?: string;
|
|
534
|
+
scopes?: string[];
|
|
535
|
+
expiresAt?: string;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Parameters for listing API keys
|
|
539
|
+
*/
|
|
540
|
+
export interface ListAPIKeysParams {
|
|
541
|
+
organizationId?: number;
|
|
542
|
+
limit?: number;
|
|
543
|
+
offset?: number;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* API Key usage statistics
|
|
547
|
+
*/
|
|
548
|
+
export interface APIKeyUsage {
|
|
549
|
+
keyId: number;
|
|
550
|
+
totalRequests: number;
|
|
551
|
+
successfulRequests: number;
|
|
552
|
+
failedRequests: number;
|
|
553
|
+
lastUsedAt: string | null;
|
|
554
|
+
usageByEndpoint: Record<string, number>;
|
|
555
|
+
usageByDay: Array<{
|
|
556
|
+
date: string;
|
|
557
|
+
requests: number;
|
|
558
|
+
}>;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Webhook object
|
|
562
|
+
*/
|
|
563
|
+
export interface Webhook {
|
|
564
|
+
id: number;
|
|
565
|
+
organizationId: number;
|
|
566
|
+
url: string;
|
|
567
|
+
events: string[];
|
|
568
|
+
secret: string;
|
|
569
|
+
status: "active" | "inactive";
|
|
570
|
+
lastDeliveredAt: string | null;
|
|
571
|
+
createdAt: string;
|
|
572
|
+
updatedAt: string;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Parameters for creating a webhook
|
|
576
|
+
*/
|
|
577
|
+
export interface CreateWebhookParams {
|
|
578
|
+
organizationId: number;
|
|
579
|
+
url: string;
|
|
580
|
+
events: string[];
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Parameters for updating a webhook
|
|
584
|
+
*/
|
|
585
|
+
export interface UpdateWebhookParams {
|
|
586
|
+
url?: string;
|
|
587
|
+
events?: string[];
|
|
588
|
+
status?: "active" | "inactive";
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Parameters for listing webhooks
|
|
592
|
+
*/
|
|
593
|
+
export interface ListWebhooksParams {
|
|
594
|
+
organizationId: number;
|
|
595
|
+
status?: "active" | "inactive";
|
|
596
|
+
limit?: number;
|
|
597
|
+
offset?: number;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Webhook delivery object
|
|
601
|
+
*/
|
|
602
|
+
export interface WebhookDelivery {
|
|
603
|
+
id: number;
|
|
604
|
+
webhookId: number;
|
|
605
|
+
eventType: string;
|
|
606
|
+
payload: Record<string, unknown>;
|
|
607
|
+
responseBody: string | null;
|
|
608
|
+
responseStatus: number | null;
|
|
609
|
+
status: string;
|
|
610
|
+
attemptCount: number;
|
|
611
|
+
createdAt: string;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Parameters for listing webhook deliveries
|
|
615
|
+
*/
|
|
616
|
+
export interface ListWebhookDeliveriesParams {
|
|
617
|
+
limit?: number;
|
|
618
|
+
offset?: number;
|
|
619
|
+
status?: "success" | "failed" | "pending";
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Usage statistics
|
|
623
|
+
*/
|
|
624
|
+
export interface UsageStats {
|
|
625
|
+
analytics: {
|
|
626
|
+
totalRequests: number;
|
|
627
|
+
avgResponseTime: number;
|
|
628
|
+
errorRate: number;
|
|
629
|
+
successRate: number;
|
|
630
|
+
groupedData: Array<{
|
|
631
|
+
key: string;
|
|
632
|
+
count: number;
|
|
633
|
+
avgResponseTime: number;
|
|
634
|
+
}>;
|
|
635
|
+
};
|
|
636
|
+
period: {
|
|
637
|
+
start: string;
|
|
638
|
+
end: string;
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Parameters for getting usage stats
|
|
643
|
+
*/
|
|
644
|
+
export interface GetUsageParams {
|
|
645
|
+
period?: "7d" | "30d" | "90d";
|
|
646
|
+
groupBy?: "endpoint" | "method" | "day";
|
|
647
|
+
limit?: number;
|
|
648
|
+
offset?: number;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Usage summary
|
|
652
|
+
*/
|
|
653
|
+
export interface UsageSummary {
|
|
654
|
+
summary: {
|
|
655
|
+
totalRequests: number;
|
|
656
|
+
avgResponseTime: number;
|
|
657
|
+
minResponseTime: number;
|
|
658
|
+
maxResponseTime: number;
|
|
659
|
+
errorRate: number;
|
|
660
|
+
successRate: number;
|
|
661
|
+
requestsByStatusCode: Record<string, number>;
|
|
662
|
+
topEndpoints: Array<{
|
|
663
|
+
endpoint: string;
|
|
664
|
+
count: number;
|
|
665
|
+
}>;
|
|
666
|
+
requestsOverTime: Array<{
|
|
667
|
+
date: string;
|
|
668
|
+
count: number;
|
|
669
|
+
}>;
|
|
670
|
+
};
|
|
671
|
+
period: {
|
|
672
|
+
start: string;
|
|
673
|
+
end: string;
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* LLM Judge configuration object
|
|
678
|
+
*/
|
|
679
|
+
export interface LLMJudgeConfig {
|
|
680
|
+
id: number;
|
|
681
|
+
name: string;
|
|
682
|
+
model: string;
|
|
683
|
+
promptTemplate: string;
|
|
684
|
+
criteria: unknown;
|
|
685
|
+
settings: unknown;
|
|
686
|
+
organizationId: number;
|
|
687
|
+
createdBy: string;
|
|
688
|
+
createdAt: string;
|
|
689
|
+
updatedAt: string;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Parameters for creating an LLM judge config
|
|
693
|
+
*/
|
|
694
|
+
export interface CreateLLMJudgeConfigParams {
|
|
695
|
+
name: string;
|
|
696
|
+
model: string;
|
|
697
|
+
promptTemplate: string;
|
|
698
|
+
criteria?: Record<string, unknown>;
|
|
699
|
+
settings?: Record<string, unknown>;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Parameters for listing LLM judge configs
|
|
703
|
+
*/
|
|
704
|
+
export interface ListLLMJudgeConfigsParams {
|
|
705
|
+
organizationId?: number;
|
|
706
|
+
limit?: number;
|
|
707
|
+
offset?: number;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Parameters for listing LLM judge results
|
|
711
|
+
*/
|
|
712
|
+
export interface ListLLMJudgeResultsParams {
|
|
713
|
+
configId?: number;
|
|
714
|
+
evaluationId?: number;
|
|
715
|
+
limit?: number;
|
|
716
|
+
offset?: number;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* LLM Judge alignment analysis
|
|
720
|
+
*/
|
|
721
|
+
export interface LLMJudgeAlignment {
|
|
722
|
+
alignmentData: Array<{
|
|
723
|
+
testCaseId: number;
|
|
724
|
+
humanScore: number;
|
|
725
|
+
judgeScore: number;
|
|
726
|
+
alignment: number;
|
|
727
|
+
}>;
|
|
728
|
+
metrics: {
|
|
729
|
+
averageAlignment: number;
|
|
730
|
+
totalComparisons: number;
|
|
731
|
+
highAlignment: number;
|
|
732
|
+
lowAlignment: number;
|
|
733
|
+
alignmentRate: number;
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Parameters for getting alignment analysis
|
|
738
|
+
*/
|
|
739
|
+
export interface GetLLMJudgeAlignmentParams {
|
|
740
|
+
evaluationRunId: number;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Organization object
|
|
744
|
+
*/
|
|
745
|
+
export interface Organization {
|
|
746
|
+
id: number;
|
|
747
|
+
name: string;
|
|
748
|
+
role?: string;
|
|
749
|
+
slug?: string;
|
|
750
|
+
plan?: string;
|
|
751
|
+
status?: string;
|
|
752
|
+
createdAt?: string;
|
|
753
|
+
updatedAt?: string;
|
|
754
|
+
}
|