@artemiskit/sdk 0.3.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/src/types.ts ADDED
@@ -0,0 +1,259 @@
1
+ /**
2
+ * @artemiskit/sdk
3
+ * Type definitions for the programmatic SDK
4
+ */
5
+
6
+ import type {
7
+ AdapterConfig,
8
+ CaseResult,
9
+ ModelClient,
10
+ RedTeamManifest,
11
+ RunManifest,
12
+ StressManifest,
13
+ StressRequestResult,
14
+ } from '@artemiskit/core';
15
+ import type { RedactionConfig } from '@artemiskit/core';
16
+ import type { Scenario } from '@artemiskit/core';
17
+
18
+ // ============================================================================
19
+ // Event Types
20
+ // ============================================================================
21
+
22
+ /**
23
+ * Event emitted when a test case starts
24
+ */
25
+ export interface CaseStartEvent {
26
+ caseId: string;
27
+ caseName?: string;
28
+ index: number;
29
+ total: number;
30
+ }
31
+
32
+ /**
33
+ * Event emitted when a test case completes
34
+ */
35
+ export interface CaseCompleteEvent {
36
+ result: CaseResult;
37
+ index: number;
38
+ total: number;
39
+ }
40
+
41
+ /**
42
+ * Event emitted for progress updates
43
+ */
44
+ export interface ProgressEvent {
45
+ message: string;
46
+ phase: 'setup' | 'running' | 'teardown';
47
+ progress?: number; // 0-100 percentage
48
+ }
49
+
50
+ /**
51
+ * Event emitted when a red team mutation starts
52
+ */
53
+ export interface RedTeamMutationStartEvent {
54
+ mutation: string;
55
+ caseId: string;
56
+ index: number;
57
+ total: number;
58
+ }
59
+
60
+ /**
61
+ * Event emitted when a red team mutation completes
62
+ */
63
+ export interface RedTeamMutationCompleteEvent {
64
+ mutation: string;
65
+ caseId: string;
66
+ status: 'safe' | 'unsafe' | 'blocked' | 'error';
67
+ severity: 'none' | 'low' | 'medium' | 'high' | 'critical';
68
+ index: number;
69
+ total: number;
70
+ }
71
+
72
+ /**
73
+ * Event emitted for stress test request completion
74
+ */
75
+ export interface StressRequestCompleteEvent {
76
+ result: StressRequestResult;
77
+ index: number;
78
+ total: number;
79
+ currentRPS: number;
80
+ }
81
+
82
+ // ============================================================================
83
+ // Event Handler Types
84
+ // ============================================================================
85
+
86
+ export type CaseStartHandler = (event: CaseStartEvent) => void;
87
+ export type CaseCompleteHandler = (event: CaseCompleteEvent) => void;
88
+ export type ProgressHandler = (event: ProgressEvent) => void;
89
+ export type RedTeamMutationStartHandler = (event: RedTeamMutationStartEvent) => void;
90
+ export type RedTeamMutationCompleteHandler = (event: RedTeamMutationCompleteEvent) => void;
91
+ export type StressRequestCompleteHandler = (event: StressRequestCompleteEvent) => void;
92
+
93
+ // ============================================================================
94
+ // Configuration Types
95
+ // ============================================================================
96
+
97
+ /**
98
+ * SDK-level configuration options
99
+ */
100
+ export interface ArtemisKitConfig {
101
+ /** Project name for manifest grouping */
102
+ project?: string;
103
+ /** Default provider to use */
104
+ provider?: AdapterConfig['provider'];
105
+ /** Default model to use */
106
+ model?: string;
107
+ /** Provider-specific configuration */
108
+ providerConfig?: Partial<AdapterConfig>;
109
+ /** Default redaction settings */
110
+ redaction?: RedactionConfig;
111
+ /** Default timeout per case in milliseconds */
112
+ timeout?: number;
113
+ /** Default number of retries per case */
114
+ retries?: number;
115
+ /** Default concurrency for parallel execution */
116
+ concurrency?: number;
117
+ }
118
+
119
+ /**
120
+ * Options for running test scenarios
121
+ */
122
+ export interface RunOptions {
123
+ /** Path to scenario file or inline Scenario object */
124
+ scenario: string | Scenario;
125
+ /** Override provider */
126
+ provider?: AdapterConfig['provider'];
127
+ /** Override model */
128
+ model?: string;
129
+ /** Provider-specific configuration override */
130
+ providerConfig?: Partial<AdapterConfig>;
131
+ /** Pre-configured model client (skips adapter creation) */
132
+ client?: ModelClient;
133
+ /** Filter test cases by tags */
134
+ tags?: string[];
135
+ /** Number of concurrent requests */
136
+ concurrency?: number;
137
+ /** Timeout per case in milliseconds */
138
+ timeout?: number;
139
+ /** Number of retries per case */
140
+ retries?: number;
141
+ /** Redaction configuration */
142
+ redaction?: RedactionConfig;
143
+ }
144
+
145
+ /**
146
+ * Options for red team testing
147
+ */
148
+ export interface RedTeamOptions {
149
+ /** Path to scenario file or inline Scenario object */
150
+ scenario: string | Scenario;
151
+ /** Override provider */
152
+ provider?: AdapterConfig['provider'];
153
+ /** Override model */
154
+ model?: string;
155
+ /** Provider-specific configuration override */
156
+ providerConfig?: Partial<AdapterConfig>;
157
+ /** Pre-configured model client (skips adapter creation) */
158
+ client?: ModelClient;
159
+ /** Mutations to apply (default: all) */
160
+ mutations?: string[];
161
+ /** Number of mutations per case */
162
+ countPerCase?: number;
163
+ /** Filter test cases by tags */
164
+ tags?: string[];
165
+ /** Timeout per case in milliseconds */
166
+ timeout?: number;
167
+ /** Redaction configuration */
168
+ redaction?: RedactionConfig;
169
+ }
170
+
171
+ /**
172
+ * Options for stress testing
173
+ */
174
+ export interface StressOptions {
175
+ /** Path to scenario file or inline Scenario object */
176
+ scenario: string | Scenario;
177
+ /** Override provider */
178
+ provider?: AdapterConfig['provider'];
179
+ /** Override model */
180
+ model?: string;
181
+ /** Provider-specific configuration override */
182
+ providerConfig?: Partial<AdapterConfig>;
183
+ /** Pre-configured model client (skips adapter creation) */
184
+ client?: ModelClient;
185
+ /** Number of concurrent requests */
186
+ concurrency?: number;
187
+ /** Test duration in seconds */
188
+ duration?: number;
189
+ /** Ramp-up period in seconds */
190
+ rampUp?: number;
191
+ /** Maximum number of requests (optional limit) */
192
+ maxRequests?: number;
193
+ /** Redaction configuration */
194
+ redaction?: RedactionConfig;
195
+ }
196
+
197
+ // ============================================================================
198
+ // Result Types
199
+ // ============================================================================
200
+
201
+ /**
202
+ * Result from a test scenario run
203
+ */
204
+ export interface RunResult {
205
+ /** The generated manifest */
206
+ manifest: RunManifest;
207
+ /** Individual case results */
208
+ cases: CaseResult[];
209
+ /** Whether all cases passed */
210
+ success: boolean;
211
+ }
212
+
213
+ /**
214
+ * Result from a red team test run
215
+ */
216
+ export interface RedTeamResult {
217
+ /** The generated manifest */
218
+ manifest: RedTeamManifest;
219
+ /** Whether the defense rate is acceptable (>= threshold) */
220
+ success: boolean;
221
+ /** Defense rate (0-1) */
222
+ defenseRate: number;
223
+ /** Count of unsafe responses */
224
+ unsafeCount: number;
225
+ }
226
+
227
+ /**
228
+ * Result from a stress test run
229
+ */
230
+ export interface StressResult {
231
+ /** The generated manifest */
232
+ manifest: StressManifest;
233
+ /** Whether the test passed success rate threshold */
234
+ success: boolean;
235
+ /** Success rate (0-1) */
236
+ successRate: number;
237
+ /** Requests per second achieved */
238
+ rps: number;
239
+ /** P95 latency in milliseconds */
240
+ p95LatencyMs: number;
241
+ }
242
+
243
+ // ============================================================================
244
+ // Event Emitter Interface
245
+ // ============================================================================
246
+
247
+ /**
248
+ * Event types supported by ArtemisKit
249
+ */
250
+ export interface ArtemisKitEvents {
251
+ caseStart: CaseStartEvent;
252
+ caseComplete: CaseCompleteEvent;
253
+ progress: ProgressEvent;
254
+ redteamMutationStart: RedTeamMutationStartEvent;
255
+ redteamMutationComplete: RedTeamMutationCompleteEvent;
256
+ stressRequestComplete: StressRequestCompleteEvent;
257
+ }
258
+
259
+ export type ArtemisKitEventName = keyof ArtemisKitEvents;
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "declaration": true,
7
+ "declarationMap": true
8
+ },
9
+ "include": ["src/**/*"],
10
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
11
+ }