@artemiskit/sdk 0.3.1 → 0.3.3

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +213 -0
  2. package/README.md +44 -1
  3. package/dist/artemiskit.d.ts +149 -0
  4. package/dist/artemiskit.d.ts.map +1 -0
  5. package/dist/builders/index.d.ts +350 -0
  6. package/dist/builders/index.d.ts.map +1 -0
  7. package/dist/builders/index.js +398 -0
  8. package/dist/contracts/index.d.ts +253 -0
  9. package/dist/contracts/index.d.ts.map +1 -0
  10. package/dist/contracts/index.js +99 -0
  11. package/dist/guardian/action-validator.d.ts +92 -0
  12. package/dist/guardian/action-validator.d.ts.map +1 -0
  13. package/dist/guardian/circuit-breaker.d.ts +211 -0
  14. package/dist/guardian/circuit-breaker.d.ts.map +1 -0
  15. package/dist/guardian/guardian.d.ts +213 -0
  16. package/dist/guardian/guardian.d.ts.map +1 -0
  17. package/dist/guardian/guardrails.d.ts +107 -0
  18. package/dist/guardian/guardrails.d.ts.map +1 -0
  19. package/dist/guardian/index.d.ts +35 -0
  20. package/dist/guardian/index.d.ts.map +1 -0
  21. package/dist/guardian/intent-classifier.d.ts +81 -0
  22. package/dist/guardian/intent-classifier.d.ts.map +1 -0
  23. package/dist/guardian/interceptor.d.ts +141 -0
  24. package/dist/guardian/interceptor.d.ts.map +1 -0
  25. package/dist/guardian/policy.d.ts +52 -0
  26. package/dist/guardian/policy.d.ts.map +1 -0
  27. package/dist/guardian/semantic-validator.d.ts +61 -0
  28. package/dist/guardian/semantic-validator.d.ts.map +1 -0
  29. package/dist/guardian/types.d.ts +653 -0
  30. package/dist/guardian/types.d.ts.map +1 -0
  31. package/dist/index.d.ts +23 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +24847 -13653
  34. package/dist/matchers/core.d.ts +81 -0
  35. package/dist/matchers/core.d.ts.map +1 -0
  36. package/dist/matchers/index.d.ts +6 -0
  37. package/dist/matchers/index.d.ts.map +1 -0
  38. package/dist/matchers/jest.d.ts +46 -0
  39. package/dist/matchers/jest.d.ts.map +1 -0
  40. package/dist/matchers/vitest.d.ts +24 -0
  41. package/dist/matchers/vitest.d.ts.map +1 -0
  42. package/dist/types-only.d.ts +31 -0
  43. package/dist/types-only.d.ts.map +1 -0
  44. package/dist/types-only.js +1 -0
  45. package/dist/types.d.ts +377 -0
  46. package/dist/types.d.ts.map +1 -0
  47. package/dist/utils/index.d.ts +112 -0
  48. package/dist/utils/index.d.ts.map +1 -0
  49. package/dist/utils/index.js +104 -0
  50. package/package.json +17 -2
  51. package/src/__tests__/builders.test.ts +445 -0
  52. package/src/__tests__/circuit-breaker.test.ts +704 -0
  53. package/src/__tests__/compare.test.ts +469 -0
  54. package/src/__tests__/contracts.test.ts +354 -0
  55. package/src/__tests__/guardian-modes.test.ts +215 -0
  56. package/src/__tests__/guardrails.test.ts +404 -0
  57. package/src/__tests__/semantic-validator.test.ts +421 -0
  58. package/src/__tests__/utils.test.ts +324 -0
  59. package/src/__tests__/validate.test.ts +307 -0
  60. package/src/artemiskit.ts +478 -5
  61. package/src/builders/index.ts +698 -0
  62. package/src/contracts/index.ts +357 -0
  63. package/src/guardian/circuit-breaker.ts +74 -28
  64. package/src/guardian/guardian.ts +307 -20
  65. package/src/guardian/guardrails.ts +143 -1
  66. package/src/guardian/index.ts +35 -1
  67. package/src/guardian/interceptor.ts +87 -11
  68. package/src/guardian/semantic-validator.ts +399 -0
  69. package/src/guardian/types.ts +413 -2
  70. package/src/index.ts +258 -14
  71. package/src/types-only.ts +276 -0
  72. package/src/types.ts +183 -0
  73. package/src/utils/index.ts +225 -0
  74. package/tsconfig.json +2 -1
package/src/index.ts CHANGED
@@ -34,45 +34,258 @@ export type {
34
34
  // Event emitter
35
35
  ArtemisKitEvents,
36
36
  ArtemisKitEventName,
37
+ // Validation types (v0.3.2+)
38
+ ValidateOptions,
39
+ ValidationResult,
40
+ ValidationError,
41
+ ValidationWarning,
42
+ ScenarioValidation,
43
+ // Comparison types (v0.3.2+)
44
+ CompareOptions,
45
+ CompareResult,
46
+ RunSummary,
47
+ ComparisonDetails,
37
48
  } from './types';
38
49
 
39
- // Re-export core types for convenience
50
+ // ============================================================================
51
+ // Core Types - Scenarios & Test Cases
52
+ // ============================================================================
53
+
40
54
  export type {
41
- // Core types
42
55
  Scenario,
43
56
  TestCase,
44
57
  Expected,
45
58
  Provider,
59
+ ProviderConfig,
60
+ ChatMessageType,
61
+ Variables,
62
+ } from '@artemiskit/core';
63
+
64
+ // ============================================================================
65
+ // Core Types - Results & Manifests
66
+ // ============================================================================
67
+
68
+ export type {
69
+ // Case results
46
70
  CaseResult,
71
+ CaseRedactionInfo,
72
+ // Run manifest
47
73
  RunManifest,
74
+ RunConfig,
75
+ RunMetrics,
76
+ // Red team manifest
48
77
  RedTeamManifest,
49
- StressManifest,
78
+ RedTeamConfig,
79
+ RedTeamMetrics,
50
80
  RedTeamCaseResult,
81
+ RedTeamStatus,
82
+ RedTeamSeverity,
83
+ // Stress manifest
84
+ StressManifest,
85
+ StressConfig,
86
+ StressMetrics,
51
87
  StressRequestResult,
52
- // Adapter types
88
+ // Common
89
+ AnyManifest,
90
+ ResolvedConfig,
91
+ ConfigSource,
92
+ ManifestRedactionInfo,
93
+ CostEstimateInfo,
94
+ GitInfo,
95
+ ProvenanceInfo,
96
+ } from '@artemiskit/core';
97
+
98
+ // ============================================================================
99
+ // Core Types - Adapters
100
+ // ============================================================================
101
+
102
+ export type {
103
+ // Client interface
53
104
  ModelClient,
54
- AdapterConfig,
105
+ ModelCapabilities,
106
+ // Request/Response
55
107
  GenerateOptions,
56
108
  GenerateResult,
57
- // Redaction
58
- RedactionConfig,
109
+ TokenUsage,
110
+ // Messages
111
+ ChatMessage,
112
+ // Function/Tool calling
113
+ FunctionDefinition,
114
+ ToolDefinition,
115
+ ToolCall,
116
+ // Config types
117
+ AdapterConfig,
118
+ BaseAdapterConfig,
119
+ OpenAIAdapterConfig,
120
+ AzureOpenAIAdapterConfig,
121
+ VercelAIAdapterConfig,
122
+ AnthropicAdapterConfig,
123
+ LangChainAdapterConfig,
124
+ DeepAgentsAdapterConfig,
125
+ ProviderType,
126
+ } from '@artemiskit/core';
127
+
128
+ // ============================================================================
129
+ // Core Types - Evaluators
130
+ // ============================================================================
131
+
132
+ export type { Evaluator, EvaluatorContext, EvaluatorResult } from '@artemiskit/core';
133
+
134
+ // ============================================================================
135
+ // Core Types - Storage
136
+ // ============================================================================
137
+
138
+ export type {
139
+ StorageAdapter,
140
+ StorageConfig,
141
+ RunListItem,
142
+ ListOptions,
143
+ ComparisonResult,
144
+ BaselineMetadata,
145
+ BaselineStorageAdapter,
146
+ // Analytics
147
+ CaseResultRecord,
148
+ CaseResultStatus,
149
+ CaseResultQueryOptions,
150
+ MetricsSnapshot,
151
+ MetricsTrendOptions,
152
+ TrendDataPoint,
153
+ AnalyticsStorageAdapter,
59
154
  } from '@artemiskit/core';
60
155
 
61
- // Re-export redteam types for convenience
156
+ // ============================================================================
157
+ // Core Types - Redaction
158
+ // ============================================================================
159
+
160
+ export type { RedactionConfig } from '@artemiskit/core';
161
+
162
+ // ============================================================================
163
+ // Core Functions - Type Guards (from core)
164
+ // ============================================================================
165
+
166
+ export { isRunManifest, isRedTeamManifest, isStressManifest } from '@artemiskit/core';
167
+
168
+ // ============================================================================
169
+ // Redteam Types
170
+ // ============================================================================
171
+
62
172
  export type { Severity, SeverityInfo, CvssScore } from '@artemiskit/redteam';
63
173
 
64
- // Export matchers
174
+ // ============================================================================
175
+ // Matchers
176
+ // ============================================================================
177
+
178
+ export { artemiskitMatchers, type ArtemisKitMatchers, type MatcherResult } from './matchers';
179
+
180
+ // ============================================================================
181
+ // Utility Types & Functions
182
+ // ============================================================================
183
+
184
+ export {
185
+ // Type guards for results
186
+ isRunResult,
187
+ isRedTeamResult,
188
+ isStressResult,
189
+ isRunManifestType,
190
+ isRedTeamManifestType,
191
+ isStressManifestType,
192
+ // Assertion helpers
193
+ assertDefined,
194
+ assert,
195
+ // Result analysis helpers
196
+ getFailedCases,
197
+ getPassedCases,
198
+ getCasesByTag,
199
+ calculateSuccessRate,
200
+ } from './utils';
201
+
202
+ export type {
203
+ // Provider/Expectation types
204
+ ProviderName,
205
+ ExpectationType,
206
+ // Result types
207
+ AnyResult,
208
+ ExtractRunCases,
209
+ ExtractRedTeamCases,
210
+ ExtractStressResults,
211
+ ExtractManifest,
212
+ // Partial types
213
+ DeepPartial,
214
+ PartialScenario,
215
+ RequireFields,
216
+ OptionalFields,
217
+ StrictAdapterConfig,
218
+ } from './utils';
219
+
220
+ // ============================================================================
221
+ // Contracts for Custom Implementations
222
+ // ============================================================================
223
+
224
+ export {
225
+ // Adapter contract
226
+ defineAdapter,
227
+ // Evaluator contract
228
+ defineEvaluator,
229
+ // Storage contract
230
+ defineStorage,
231
+ // Plugin system
232
+ definePlugin,
233
+ } from './contracts';
234
+
235
+ export type {
236
+ AdapterContract,
237
+ EvaluatorContract,
238
+ StorageContract,
239
+ AdapterFactory,
240
+ EvaluatorFactory,
241
+ StorageFactory,
242
+ ArtemisKitPlugin,
243
+ } from './contracts';
244
+
245
+ // ============================================================================
246
+ // Builders for Programmatic Scenario Construction
247
+ // ============================================================================
248
+
65
249
  export {
66
- artemiskitMatchers,
67
- type ArtemisKitMatchers,
68
- type MatcherResult,
69
- } from './matchers';
250
+ // Builder classes
251
+ ScenarioBuilder,
252
+ TestCaseBuilder,
253
+ // Factory functions
254
+ scenario,
255
+ testCase,
256
+ // Quick helpers
257
+ containsCase,
258
+ exactCase,
259
+ regexCase,
260
+ jsonCase,
261
+ gradedCase,
262
+ // Expectation helpers
263
+ exact,
264
+ contains,
265
+ notContains,
266
+ regex,
267
+ fuzzy,
268
+ jsonSchema,
269
+ llmGrade,
270
+ similarity,
271
+ inline,
272
+ allOf,
273
+ anyOf,
274
+ } from './builders';
275
+
276
+ // ============================================================================
277
+ // Guardian Module - Runtime Protection
278
+ // ============================================================================
70
279
 
71
- // Export guardian module for runtime protection
72
280
  export {
73
281
  // Main Guardian class
74
282
  Guardian,
75
283
  createGuardian,
284
+ // Mode normalization (v0.3.2+)
285
+ normalizeGuardianMode,
286
+ // Semantic Validator (v0.3.2+)
287
+ SemanticValidator,
288
+ createSemanticValidator,
76
289
  // Interceptor
77
290
  GuardianInterceptor,
78
291
  GuardianBlockedError,
@@ -91,6 +304,9 @@ export {
91
304
  filterContent,
92
305
  createContentFilterGuardrail,
93
306
  createGuardrails,
307
+ // Pattern matching utilities (v0.3.2+)
308
+ matchPattern,
309
+ createCustomPatternGuardrail,
94
310
  // Policy
95
311
  loadPolicy,
96
312
  parsePolicy,
@@ -115,6 +331,7 @@ export type {
115
331
  IntentClassifierConfig,
116
332
  GuardrailsConfig,
117
333
  RateLimiterConfig,
334
+ CustomPatternOptions,
118
335
  // Core types
119
336
  GuardianMode,
120
337
  ViolationSeverity,
@@ -161,4 +378,31 @@ export type {
161
378
  // Framework types
162
379
  FrameworkType,
163
380
  FrameworkIntegrationConfig,
381
+ // Mode types (v0.3.2+)
382
+ GuardianModeCanonical,
383
+ GuardianModeLegacy,
384
+ GuardianModeAll,
385
+ // Content validation types (v0.3.2+)
386
+ ContentValidationConfig,
387
+ PatternConfig,
388
+ ValidationCategory,
389
+ PatternCategory,
390
+ SemanticValidationResult,
391
+ // Multi-turn detection types (v0.3.3+)
392
+ SessionStorageType,
393
+ SessionStorageConfig,
394
+ SessionMessage,
395
+ SessionMetrics,
396
+ ConversationSession,
397
+ TrustBuildingHeuristicConfig,
398
+ EscalationHeuristicConfig,
399
+ ContextManipulationHeuristicConfig,
400
+ SplitPayloadHeuristicConfig,
401
+ MultiTurnHeuristics,
402
+ MultiTurnSemanticConfig,
403
+ MultiTurnConfig,
404
+ HeuristicResult,
405
+ HeuristicResults,
406
+ MultiTurnValidationResult,
407
+ ValidateMessageOptions,
164
408
  } from './guardian';
@@ -0,0 +1,276 @@
1
+ /**
2
+ * @artemiskit/sdk/types
3
+ * Types-only exports for consumers who only need type definitions
4
+ *
5
+ * Use this export when you only need types for type-checking
6
+ * without importing any runtime code.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import type {
11
+ * Scenario,
12
+ * TestCase,
13
+ * RunResult,
14
+ * ArtemisKitConfig
15
+ * } from '@artemiskit/sdk/types'
16
+ * ```
17
+ */
18
+
19
+ // ============================================================================
20
+ // SDK Types
21
+ // ============================================================================
22
+
23
+ export type {
24
+ // Configuration
25
+ ArtemisKitConfig,
26
+ RunOptions,
27
+ RedTeamOptions,
28
+ StressOptions,
29
+ // Results
30
+ RunResult,
31
+ RedTeamResult,
32
+ StressResult,
33
+ // Events
34
+ CaseStartEvent,
35
+ CaseCompleteEvent,
36
+ ProgressEvent,
37
+ RedTeamMutationStartEvent,
38
+ RedTeamMutationCompleteEvent,
39
+ StressRequestCompleteEvent,
40
+ // Event handlers
41
+ CaseStartHandler,
42
+ CaseCompleteHandler,
43
+ ProgressHandler,
44
+ RedTeamMutationStartHandler,
45
+ RedTeamMutationCompleteHandler,
46
+ StressRequestCompleteHandler,
47
+ // Event emitter
48
+ ArtemisKitEvents,
49
+ ArtemisKitEventName,
50
+ } from './types';
51
+
52
+ // ============================================================================
53
+ // Core Types - Scenarios & Test Cases
54
+ // ============================================================================
55
+
56
+ export type {
57
+ Scenario,
58
+ TestCase,
59
+ Expected,
60
+ Provider,
61
+ ProviderConfig,
62
+ ChatMessageType,
63
+ Variables,
64
+ } from '@artemiskit/core';
65
+
66
+ // ============================================================================
67
+ // Core Types - Results & Manifests
68
+ // ============================================================================
69
+
70
+ export type {
71
+ // Case results
72
+ CaseResult,
73
+ CaseRedactionInfo,
74
+ // Run manifest
75
+ RunManifest,
76
+ RunConfig,
77
+ RunMetrics,
78
+ // Red team manifest
79
+ RedTeamManifest,
80
+ RedTeamConfig,
81
+ RedTeamMetrics,
82
+ RedTeamCaseResult,
83
+ RedTeamStatus,
84
+ RedTeamSeverity,
85
+ // Stress manifest
86
+ StressManifest,
87
+ StressConfig,
88
+ StressMetrics,
89
+ StressRequestResult,
90
+ // Common
91
+ AnyManifest,
92
+ ResolvedConfig,
93
+ ConfigSource,
94
+ ManifestRedactionInfo,
95
+ CostEstimateInfo,
96
+ GitInfo,
97
+ ProvenanceInfo,
98
+ } from '@artemiskit/core';
99
+
100
+ // ============================================================================
101
+ // Core Types - Adapters
102
+ // ============================================================================
103
+
104
+ export type {
105
+ // Client interface
106
+ ModelClient,
107
+ ModelCapabilities,
108
+ // Request/Response
109
+ GenerateOptions,
110
+ GenerateResult,
111
+ TokenUsage,
112
+ // Messages
113
+ ChatMessage,
114
+ // Function/Tool calling
115
+ FunctionDefinition,
116
+ ToolDefinition,
117
+ ToolCall,
118
+ // Config types
119
+ AdapterConfig,
120
+ BaseAdapterConfig,
121
+ OpenAIAdapterConfig,
122
+ AzureOpenAIAdapterConfig,
123
+ VercelAIAdapterConfig,
124
+ AnthropicAdapterConfig,
125
+ LangChainAdapterConfig,
126
+ DeepAgentsAdapterConfig,
127
+ ProviderType,
128
+ } from '@artemiskit/core';
129
+
130
+ // ============================================================================
131
+ // Core Types - Evaluators
132
+ // ============================================================================
133
+
134
+ export type { Evaluator, EvaluatorContext, EvaluatorResult } from '@artemiskit/core';
135
+
136
+ // ============================================================================
137
+ // Core Types - Storage
138
+ // ============================================================================
139
+
140
+ export type {
141
+ StorageAdapter,
142
+ StorageConfig,
143
+ RunListItem,
144
+ ListOptions,
145
+ ComparisonResult,
146
+ BaselineMetadata,
147
+ BaselineStorageAdapter,
148
+ // Analytics
149
+ CaseResultRecord,
150
+ CaseResultStatus,
151
+ CaseResultQueryOptions,
152
+ MetricsSnapshot,
153
+ MetricsTrendOptions,
154
+ TrendDataPoint,
155
+ AnalyticsStorageAdapter,
156
+ } from '@artemiskit/core';
157
+
158
+ // ============================================================================
159
+ // Core Types - Redaction
160
+ // ============================================================================
161
+
162
+ export type { RedactionConfig } from '@artemiskit/core';
163
+
164
+ // ============================================================================
165
+ // Redteam Types
166
+ // ============================================================================
167
+
168
+ export type { Severity, SeverityInfo, CvssScore } from '@artemiskit/redteam';
169
+
170
+ // ============================================================================
171
+ // Guardian Types
172
+ // ============================================================================
173
+
174
+ export type {
175
+ // Config types
176
+ GuardianConfig,
177
+ InterceptorConfig,
178
+ ActionValidatorConfig,
179
+ IntentClassifierConfig,
180
+ GuardrailsConfig,
181
+ RateLimiterConfig,
182
+ // Core types
183
+ GuardianMode,
184
+ ViolationSeverity,
185
+ ViolationAction,
186
+ GuardrailType,
187
+ Violation,
188
+ GuardrailResult,
189
+ // Policy types
190
+ PolicyRule,
191
+ PolicyCondition,
192
+ GuardianPolicy,
193
+ CircuitBreakerConfig,
194
+ RateLimitConfig,
195
+ CostLimitConfig,
196
+ // Action types
197
+ ActionDefinition,
198
+ ActionParameter,
199
+ ParameterValidation,
200
+ // Intent types
201
+ IntentClassification,
202
+ IntentCategory,
203
+ // Detection types
204
+ PIIDetection,
205
+ PIIType,
206
+ PIILocation,
207
+ InjectionDetection,
208
+ InjectionType,
209
+ ContentFilterResult,
210
+ ContentFlag,
211
+ ContentCategory,
212
+ // Metrics types
213
+ GuardianMetrics,
214
+ CircuitBreakerState,
215
+ CostTracking,
216
+ // Event types
217
+ GuardianEventType,
218
+ GuardianEvent,
219
+ GuardianEventHandler,
220
+ // Interceptor types
221
+ InterceptedRequest,
222
+ InterceptedResponse,
223
+ InterceptedToolCall,
224
+ InterceptedAgentStep,
225
+ // Framework types
226
+ FrameworkType,
227
+ FrameworkIntegrationConfig,
228
+ } from './guardian';
229
+
230
+ // ============================================================================
231
+ // Matcher Types
232
+ // ============================================================================
233
+
234
+ export type { ArtemisKitMatchers, MatcherResult } from './matchers';
235
+
236
+ // ============================================================================
237
+ // Utility Types
238
+ // ============================================================================
239
+
240
+ export type {
241
+ // Provider/Expectation types
242
+ ProviderName,
243
+ ExpectationType,
244
+ // Result types
245
+ AnyResult,
246
+ ExtractRunCases,
247
+ ExtractRedTeamCases,
248
+ ExtractStressResults,
249
+ ExtractManifest,
250
+ // Partial types
251
+ DeepPartial,
252
+ PartialScenario,
253
+ RequireFields,
254
+ OptionalFields,
255
+ StrictAdapterConfig,
256
+ } from './utils';
257
+
258
+ // ============================================================================
259
+ // Contract Types
260
+ // ============================================================================
261
+
262
+ export type {
263
+ AdapterContract,
264
+ EvaluatorContract,
265
+ StorageContract,
266
+ AdapterFactory,
267
+ EvaluatorFactory,
268
+ StorageFactory,
269
+ ArtemisKitPlugin,
270
+ } from './contracts';
271
+
272
+ // ============================================================================
273
+ // Builder Types
274
+ // ============================================================================
275
+
276
+ export type { ScenarioBuilder, TestCaseBuilder } from './builders';