@directive-run/ai 0.1.1

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.
@@ -0,0 +1,345 @@
1
+ import { AgentOrchestrator, OrchestratorOptions } from './index.cjs';
2
+ import { A as ApprovalRequest, I as InputGuardrailData, O as OutputGuardrailData, M as Message, T as ToolCallGuardrailData, a as ToolCall, G as GuardrailResult, b as AgentLike, c as AgentRunner, R as RunOptions, d as GuardrailFn, e as GuardrailContext } from './types-BKCdgKC-.cjs';
3
+ import '@directive-run/core';
4
+ import '@directive-run/core/plugins';
5
+
6
+ /**
7
+ * OpenAI Agents Testing Utilities
8
+ *
9
+ * Provides testing helpers for:
10
+ * - Mock agent runners with configurable responses
11
+ * - Guardrail testing with assertions
12
+ * - Approval workflow simulation
13
+ * - Snapshot testing for constraint evaluation
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { createMockAgentRunner, testGuardrail, createApprovalSimulator } from '@directive-run/ai';
18
+ *
19
+ * describe('MyOrchestrator', () => {
20
+ * it('should block PII in input', async () => {
21
+ * const result = await testGuardrail(createPIIGuardrail(), {
22
+ * input: 'My SSN is 123-45-6789',
23
+ * });
24
+ * expect(result.passed).toBe(false);
25
+ * expect(result.reason).toContain('PII');
26
+ * });
27
+ * });
28
+ * ```
29
+ */
30
+
31
+ /** Configuration for mock agent responses */
32
+ interface MockAgentConfig<T = unknown> {
33
+ /** Final output to return */
34
+ output: T;
35
+ /** Messages to emit during run */
36
+ messages?: Message[];
37
+ /** Tool calls to emit during run */
38
+ toolCalls?: ToolCall[];
39
+ /** Total tokens to report */
40
+ totalTokens?: number;
41
+ /** Delay before responding (ms) */
42
+ delay?: number;
43
+ /** Error to throw instead of returning */
44
+ error?: Error;
45
+ /** Function to generate dynamic responses */
46
+ generate?: (input: string, agent: AgentLike) => Partial<MockAgentConfig<T>>;
47
+ }
48
+ /** Mock agent runner options */
49
+ interface MockAgentRunnerOptions {
50
+ /** Default response for unmatched agents */
51
+ defaultResponse?: MockAgentConfig;
52
+ /** Responses keyed by agent name */
53
+ responses?: Record<string, MockAgentConfig>;
54
+ /** Record all calls for assertions */
55
+ recordCalls?: boolean;
56
+ /** Callback for each run */
57
+ onRun?: (agent: AgentLike, input: string) => void;
58
+ }
59
+ /** Recorded call for assertions */
60
+ interface RecordedCall {
61
+ agent: AgentLike;
62
+ input: string;
63
+ options?: RunOptions;
64
+ timestamp: number;
65
+ }
66
+ /** Mock agent runner instance */
67
+ interface MockAgentRunner {
68
+ /** The run function to pass to orchestrator */
69
+ run: AgentRunner;
70
+ /** Get all recorded calls */
71
+ getCalls(): RecordedCall[];
72
+ /** Get calls for a specific agent */
73
+ getCallsFor(agentName: string): RecordedCall[];
74
+ /** Clear recorded calls */
75
+ clearCalls(): void;
76
+ /** Set response for an agent */
77
+ setResponse<T>(agentName: string, config: MockAgentConfig<T>): void;
78
+ /** Set default response */
79
+ setDefaultResponse<T>(config: MockAgentConfig<T>): void;
80
+ }
81
+ /**
82
+ * Create a mock agent runner for testing.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const mock = createMockAgentRunner({
87
+ * responses: {
88
+ * 'my-agent': {
89
+ * output: 'Hello, world!',
90
+ * totalTokens: 100,
91
+ * },
92
+ * },
93
+ * });
94
+ *
95
+ * const orchestrator = createAgentOrchestrator({ runner: mock.run });
96
+ * const result = await orchestrator.run(myAgent, 'Hi');
97
+ *
98
+ * expect(result.output).toBe('Hello, world!');
99
+ * expect(mock.getCalls()).toHaveLength(1);
100
+ * ```
101
+ */
102
+ declare function createMockAgentRunner(options?: MockAgentRunnerOptions): MockAgentRunner;
103
+ /** Test input for guardrail testing */
104
+ type GuardrailTestInput<T> = T extends InputGuardrailData ? {
105
+ input: string;
106
+ agentName?: string;
107
+ } : T extends OutputGuardrailData ? {
108
+ output: unknown;
109
+ agentName?: string;
110
+ input?: string;
111
+ messages?: Message[];
112
+ } : T extends ToolCallGuardrailData ? {
113
+ toolCall: ToolCall;
114
+ agentName?: string;
115
+ input?: string;
116
+ } : Partial<T>;
117
+ /** Extended guardrail result with test assertions */
118
+ interface GuardrailTestResult extends GuardrailResult {
119
+ /** Time taken to evaluate (ms) */
120
+ duration: number;
121
+ /** The data that was tested */
122
+ testedData: unknown;
123
+ /** Assert that the guardrail passed */
124
+ assertPassed(): void;
125
+ /** Assert that the guardrail failed */
126
+ assertFailed(expectedReason?: string | RegExp): void;
127
+ /** Assert that transformation occurred */
128
+ assertTransformed(expected?: unknown): void;
129
+ }
130
+ /**
131
+ * Test a guardrail with assertions.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * // Test PII detection
136
+ * const result = await testGuardrail(createPIIGuardrail(), {
137
+ * input: 'My SSN is 123-45-6789',
138
+ * });
139
+ * result.assertFailed(/PII/);
140
+ *
141
+ * // Test input transformation
142
+ * const redactResult = await testGuardrail(createPIIGuardrail({ redact: true }), {
143
+ * input: 'My SSN is 123-45-6789',
144
+ * });
145
+ * redactResult.assertPassed();
146
+ * redactResult.assertTransformed();
147
+ * ```
148
+ */
149
+ declare function testGuardrail<T>(guardrail: GuardrailFn<T>, testInput: GuardrailTestInput<T>, context?: Partial<GuardrailContext>): Promise<GuardrailTestResult>;
150
+ /**
151
+ * Test multiple inputs against a guardrail.
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const results = await testGuardrailBatch(createPIIGuardrail(), [
156
+ * { input: 'Hello world', expect: 'pass' },
157
+ * { input: 'My SSN is 123-45-6789', expect: 'fail' },
158
+ * { input: 'Email: test@example.com', expect: 'fail' },
159
+ * ]);
160
+ *
161
+ * expect(results.allPassed()).toBe(true);
162
+ * ```
163
+ */
164
+ declare function testGuardrailBatch<T>(guardrail: GuardrailFn<T>, testCases: Array<{
165
+ input: GuardrailTestInput<T>;
166
+ expect: "pass" | "fail" | "transform";
167
+ context?: Partial<GuardrailContext>;
168
+ }>): Promise<{
169
+ results: GuardrailTestResult[];
170
+ allPassed(): boolean;
171
+ failures(): Array<{
172
+ index: number;
173
+ expected: string;
174
+ actual: GuardrailTestResult;
175
+ }>;
176
+ }>;
177
+ /** Approval simulator options */
178
+ interface ApprovalSimulatorOptions {
179
+ /** Auto-approve requests matching this predicate */
180
+ autoApprove?: (request: ApprovalRequest) => boolean;
181
+ /** Auto-reject requests matching this predicate */
182
+ autoReject?: (request: ApprovalRequest) => boolean | string;
183
+ /** Delay before auto-approval/rejection (ms) */
184
+ delay?: number;
185
+ /** Record all requests for assertions */
186
+ recordRequests?: boolean;
187
+ }
188
+ /** Approval simulator instance */
189
+ interface ApprovalSimulator {
190
+ /** Handle an approval request */
191
+ handle(request: ApprovalRequest): Promise<"approved" | "rejected">;
192
+ /** Get all recorded requests */
193
+ getRequests(): ApprovalRequest[];
194
+ /** Clear recorded requests */
195
+ clearRequests(): void;
196
+ /** Manually approve a request */
197
+ approve(requestId: string): void;
198
+ /** Manually reject a request */
199
+ reject(requestId: string, reason?: string): void;
200
+ /** Wait for a specific request */
201
+ waitForRequest(predicate: (req: ApprovalRequest) => boolean, timeoutMs?: number): Promise<ApprovalRequest>;
202
+ }
203
+ /**
204
+ * Create an approval simulator for testing approval workflows.
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const simulator = createApprovalSimulator({
209
+ * autoApprove: (req) => req.type === 'tool_call' && req.data.name === 'search',
210
+ * autoReject: (req) => req.type === 'tool_call' && req.data.name === 'delete',
211
+ * });
212
+ *
213
+ * // Use in tests
214
+ * orchestrator.onApprovalRequest = (req) => simulator.handle(req);
215
+ * ```
216
+ */
217
+ declare function createApprovalSimulator(options?: ApprovalSimulatorOptions): ApprovalSimulator;
218
+ /** Options for test orchestrator */
219
+ interface TestOrchestratorOptions<F extends Record<string, unknown>> extends Omit<OrchestratorOptions<F>, "runner"> {
220
+ /** Mock responses for agents */
221
+ mockResponses?: Record<string, MockAgentConfig>;
222
+ /** Default mock response */
223
+ defaultMockResponse?: MockAgentConfig;
224
+ }
225
+ /** Test orchestrator with additional testing utilities */
226
+ interface TestOrchestrator<F extends Record<string, unknown>> extends AgentOrchestrator<F> {
227
+ /** The mock runner */
228
+ mockRunner: MockAgentRunner;
229
+ /** Approval simulator */
230
+ approvalSimulator: ApprovalSimulator;
231
+ /** Get recorded agent calls */
232
+ getCalls(): RecordedCall[];
233
+ /** Get approval requests */
234
+ getApprovalRequests(): ApprovalRequest[];
235
+ /** Reset all state */
236
+ resetAll(): void;
237
+ }
238
+ /**
239
+ * Create a test orchestrator with mocking and simulation built in.
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * const test = createTestOrchestrator({
244
+ * mockResponses: {
245
+ * 'my-agent': { output: 'test response' },
246
+ * },
247
+ * constraints: {
248
+ * needsApproval: {
249
+ * when: () => true,
250
+ * require: { type: 'NEED_APPROVAL' },
251
+ * },
252
+ * },
253
+ * });
254
+ *
255
+ * await test.run(myAgent, 'Hello');
256
+ * expect(test.getCalls()).toHaveLength(1);
257
+ * ```
258
+ */
259
+ declare function createTestOrchestrator<F extends Record<string, unknown> = Record<string, never>>(options?: TestOrchestratorOptions<F>): TestOrchestrator<F>;
260
+ /** Constraint evaluation snapshot */
261
+ interface ConstraintSnapshot {
262
+ constraintId: string;
263
+ triggered: boolean;
264
+ requirement?: unknown;
265
+ facts: Record<string, unknown>;
266
+ timestamp: number;
267
+ }
268
+ /**
269
+ * Create a constraint evaluation recorder for snapshot testing.
270
+ *
271
+ * @example
272
+ * ```typescript
273
+ * const recorder = createConstraintRecorder();
274
+ * const orchestrator = createAgentOrchestrator({
275
+ * plugins: [recorder.plugin],
276
+ * });
277
+ *
278
+ * await orchestrator.run(agent, 'Hello');
279
+ *
280
+ * expect(recorder.getSnapshots()).toMatchSnapshot();
281
+ * ```
282
+ */
283
+ declare function createConstraintRecorder(): {
284
+ plugin: {
285
+ name: string;
286
+ onRequirementCreated: (data: {
287
+ constraintId: string;
288
+ requirement: unknown;
289
+ facts: unknown;
290
+ }) => void;
291
+ };
292
+ getSnapshots(): ConstraintSnapshot[];
293
+ clearSnapshots(): void;
294
+ };
295
+ /**
296
+ * Assert that an orchestrator has specific state.
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * assertOrchestratorState(orchestrator, {
301
+ * agentStatus: 'completed',
302
+ * tokenUsage: { min: 0, max: 1000 },
303
+ * pendingApprovals: 0,
304
+ * });
305
+ * ```
306
+ */
307
+ declare function assertOrchestratorState<F extends Record<string, unknown>>(orchestrator: AgentOrchestrator<F>, expected: {
308
+ agentStatus?: "idle" | "running" | "paused" | "completed" | "error";
309
+ tokenUsage?: {
310
+ min?: number;
311
+ max?: number;
312
+ exact?: number;
313
+ };
314
+ pendingApprovals?: number;
315
+ conversationLength?: {
316
+ min?: number;
317
+ max?: number;
318
+ exact?: number;
319
+ };
320
+ }): void;
321
+ /**
322
+ * Create a time controller for testing time-dependent behavior.
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * const time = createTimeController();
327
+ *
328
+ * // Override Date.now
329
+ * const originalNow = Date.now;
330
+ * Date.now = () => time.now();
331
+ *
332
+ * time.advance(1000); // Advance 1 second
333
+ *
334
+ * // Restore
335
+ * Date.now = originalNow;
336
+ * ```
337
+ */
338
+ declare function createTimeController(startTime?: number): {
339
+ now(): number;
340
+ advance(ms: number): void;
341
+ set(time: number): void;
342
+ reset(): void;
343
+ };
344
+
345
+ export { type ApprovalSimulator, type ApprovalSimulatorOptions, type ConstraintSnapshot, type GuardrailTestInput, type GuardrailTestResult, type MockAgentConfig, type MockAgentRunner, type MockAgentRunnerOptions, type RecordedCall, type TestOrchestrator, type TestOrchestratorOptions, assertOrchestratorState, createApprovalSimulator, createConstraintRecorder, createMockAgentRunner, createTestOrchestrator, createTimeController, testGuardrail, testGuardrailBatch };
@@ -0,0 +1,345 @@
1
+ import { AgentOrchestrator, OrchestratorOptions } from './index.js';
2
+ import { A as ApprovalRequest, I as InputGuardrailData, O as OutputGuardrailData, M as Message, T as ToolCallGuardrailData, a as ToolCall, G as GuardrailResult, b as AgentLike, c as AgentRunner, R as RunOptions, d as GuardrailFn, e as GuardrailContext } from './types-BKCdgKC-.js';
3
+ import '@directive-run/core';
4
+ import '@directive-run/core/plugins';
5
+
6
+ /**
7
+ * OpenAI Agents Testing Utilities
8
+ *
9
+ * Provides testing helpers for:
10
+ * - Mock agent runners with configurable responses
11
+ * - Guardrail testing with assertions
12
+ * - Approval workflow simulation
13
+ * - Snapshot testing for constraint evaluation
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { createMockAgentRunner, testGuardrail, createApprovalSimulator } from '@directive-run/ai';
18
+ *
19
+ * describe('MyOrchestrator', () => {
20
+ * it('should block PII in input', async () => {
21
+ * const result = await testGuardrail(createPIIGuardrail(), {
22
+ * input: 'My SSN is 123-45-6789',
23
+ * });
24
+ * expect(result.passed).toBe(false);
25
+ * expect(result.reason).toContain('PII');
26
+ * });
27
+ * });
28
+ * ```
29
+ */
30
+
31
+ /** Configuration for mock agent responses */
32
+ interface MockAgentConfig<T = unknown> {
33
+ /** Final output to return */
34
+ output: T;
35
+ /** Messages to emit during run */
36
+ messages?: Message[];
37
+ /** Tool calls to emit during run */
38
+ toolCalls?: ToolCall[];
39
+ /** Total tokens to report */
40
+ totalTokens?: number;
41
+ /** Delay before responding (ms) */
42
+ delay?: number;
43
+ /** Error to throw instead of returning */
44
+ error?: Error;
45
+ /** Function to generate dynamic responses */
46
+ generate?: (input: string, agent: AgentLike) => Partial<MockAgentConfig<T>>;
47
+ }
48
+ /** Mock agent runner options */
49
+ interface MockAgentRunnerOptions {
50
+ /** Default response for unmatched agents */
51
+ defaultResponse?: MockAgentConfig;
52
+ /** Responses keyed by agent name */
53
+ responses?: Record<string, MockAgentConfig>;
54
+ /** Record all calls for assertions */
55
+ recordCalls?: boolean;
56
+ /** Callback for each run */
57
+ onRun?: (agent: AgentLike, input: string) => void;
58
+ }
59
+ /** Recorded call for assertions */
60
+ interface RecordedCall {
61
+ agent: AgentLike;
62
+ input: string;
63
+ options?: RunOptions;
64
+ timestamp: number;
65
+ }
66
+ /** Mock agent runner instance */
67
+ interface MockAgentRunner {
68
+ /** The run function to pass to orchestrator */
69
+ run: AgentRunner;
70
+ /** Get all recorded calls */
71
+ getCalls(): RecordedCall[];
72
+ /** Get calls for a specific agent */
73
+ getCallsFor(agentName: string): RecordedCall[];
74
+ /** Clear recorded calls */
75
+ clearCalls(): void;
76
+ /** Set response for an agent */
77
+ setResponse<T>(agentName: string, config: MockAgentConfig<T>): void;
78
+ /** Set default response */
79
+ setDefaultResponse<T>(config: MockAgentConfig<T>): void;
80
+ }
81
+ /**
82
+ * Create a mock agent runner for testing.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const mock = createMockAgentRunner({
87
+ * responses: {
88
+ * 'my-agent': {
89
+ * output: 'Hello, world!',
90
+ * totalTokens: 100,
91
+ * },
92
+ * },
93
+ * });
94
+ *
95
+ * const orchestrator = createAgentOrchestrator({ runner: mock.run });
96
+ * const result = await orchestrator.run(myAgent, 'Hi');
97
+ *
98
+ * expect(result.output).toBe('Hello, world!');
99
+ * expect(mock.getCalls()).toHaveLength(1);
100
+ * ```
101
+ */
102
+ declare function createMockAgentRunner(options?: MockAgentRunnerOptions): MockAgentRunner;
103
+ /** Test input for guardrail testing */
104
+ type GuardrailTestInput<T> = T extends InputGuardrailData ? {
105
+ input: string;
106
+ agentName?: string;
107
+ } : T extends OutputGuardrailData ? {
108
+ output: unknown;
109
+ agentName?: string;
110
+ input?: string;
111
+ messages?: Message[];
112
+ } : T extends ToolCallGuardrailData ? {
113
+ toolCall: ToolCall;
114
+ agentName?: string;
115
+ input?: string;
116
+ } : Partial<T>;
117
+ /** Extended guardrail result with test assertions */
118
+ interface GuardrailTestResult extends GuardrailResult {
119
+ /** Time taken to evaluate (ms) */
120
+ duration: number;
121
+ /** The data that was tested */
122
+ testedData: unknown;
123
+ /** Assert that the guardrail passed */
124
+ assertPassed(): void;
125
+ /** Assert that the guardrail failed */
126
+ assertFailed(expectedReason?: string | RegExp): void;
127
+ /** Assert that transformation occurred */
128
+ assertTransformed(expected?: unknown): void;
129
+ }
130
+ /**
131
+ * Test a guardrail with assertions.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * // Test PII detection
136
+ * const result = await testGuardrail(createPIIGuardrail(), {
137
+ * input: 'My SSN is 123-45-6789',
138
+ * });
139
+ * result.assertFailed(/PII/);
140
+ *
141
+ * // Test input transformation
142
+ * const redactResult = await testGuardrail(createPIIGuardrail({ redact: true }), {
143
+ * input: 'My SSN is 123-45-6789',
144
+ * });
145
+ * redactResult.assertPassed();
146
+ * redactResult.assertTransformed();
147
+ * ```
148
+ */
149
+ declare function testGuardrail<T>(guardrail: GuardrailFn<T>, testInput: GuardrailTestInput<T>, context?: Partial<GuardrailContext>): Promise<GuardrailTestResult>;
150
+ /**
151
+ * Test multiple inputs against a guardrail.
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const results = await testGuardrailBatch(createPIIGuardrail(), [
156
+ * { input: 'Hello world', expect: 'pass' },
157
+ * { input: 'My SSN is 123-45-6789', expect: 'fail' },
158
+ * { input: 'Email: test@example.com', expect: 'fail' },
159
+ * ]);
160
+ *
161
+ * expect(results.allPassed()).toBe(true);
162
+ * ```
163
+ */
164
+ declare function testGuardrailBatch<T>(guardrail: GuardrailFn<T>, testCases: Array<{
165
+ input: GuardrailTestInput<T>;
166
+ expect: "pass" | "fail" | "transform";
167
+ context?: Partial<GuardrailContext>;
168
+ }>): Promise<{
169
+ results: GuardrailTestResult[];
170
+ allPassed(): boolean;
171
+ failures(): Array<{
172
+ index: number;
173
+ expected: string;
174
+ actual: GuardrailTestResult;
175
+ }>;
176
+ }>;
177
+ /** Approval simulator options */
178
+ interface ApprovalSimulatorOptions {
179
+ /** Auto-approve requests matching this predicate */
180
+ autoApprove?: (request: ApprovalRequest) => boolean;
181
+ /** Auto-reject requests matching this predicate */
182
+ autoReject?: (request: ApprovalRequest) => boolean | string;
183
+ /** Delay before auto-approval/rejection (ms) */
184
+ delay?: number;
185
+ /** Record all requests for assertions */
186
+ recordRequests?: boolean;
187
+ }
188
+ /** Approval simulator instance */
189
+ interface ApprovalSimulator {
190
+ /** Handle an approval request */
191
+ handle(request: ApprovalRequest): Promise<"approved" | "rejected">;
192
+ /** Get all recorded requests */
193
+ getRequests(): ApprovalRequest[];
194
+ /** Clear recorded requests */
195
+ clearRequests(): void;
196
+ /** Manually approve a request */
197
+ approve(requestId: string): void;
198
+ /** Manually reject a request */
199
+ reject(requestId: string, reason?: string): void;
200
+ /** Wait for a specific request */
201
+ waitForRequest(predicate: (req: ApprovalRequest) => boolean, timeoutMs?: number): Promise<ApprovalRequest>;
202
+ }
203
+ /**
204
+ * Create an approval simulator for testing approval workflows.
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const simulator = createApprovalSimulator({
209
+ * autoApprove: (req) => req.type === 'tool_call' && req.data.name === 'search',
210
+ * autoReject: (req) => req.type === 'tool_call' && req.data.name === 'delete',
211
+ * });
212
+ *
213
+ * // Use in tests
214
+ * orchestrator.onApprovalRequest = (req) => simulator.handle(req);
215
+ * ```
216
+ */
217
+ declare function createApprovalSimulator(options?: ApprovalSimulatorOptions): ApprovalSimulator;
218
+ /** Options for test orchestrator */
219
+ interface TestOrchestratorOptions<F extends Record<string, unknown>> extends Omit<OrchestratorOptions<F>, "runner"> {
220
+ /** Mock responses for agents */
221
+ mockResponses?: Record<string, MockAgentConfig>;
222
+ /** Default mock response */
223
+ defaultMockResponse?: MockAgentConfig;
224
+ }
225
+ /** Test orchestrator with additional testing utilities */
226
+ interface TestOrchestrator<F extends Record<string, unknown>> extends AgentOrchestrator<F> {
227
+ /** The mock runner */
228
+ mockRunner: MockAgentRunner;
229
+ /** Approval simulator */
230
+ approvalSimulator: ApprovalSimulator;
231
+ /** Get recorded agent calls */
232
+ getCalls(): RecordedCall[];
233
+ /** Get approval requests */
234
+ getApprovalRequests(): ApprovalRequest[];
235
+ /** Reset all state */
236
+ resetAll(): void;
237
+ }
238
+ /**
239
+ * Create a test orchestrator with mocking and simulation built in.
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * const test = createTestOrchestrator({
244
+ * mockResponses: {
245
+ * 'my-agent': { output: 'test response' },
246
+ * },
247
+ * constraints: {
248
+ * needsApproval: {
249
+ * when: () => true,
250
+ * require: { type: 'NEED_APPROVAL' },
251
+ * },
252
+ * },
253
+ * });
254
+ *
255
+ * await test.run(myAgent, 'Hello');
256
+ * expect(test.getCalls()).toHaveLength(1);
257
+ * ```
258
+ */
259
+ declare function createTestOrchestrator<F extends Record<string, unknown> = Record<string, never>>(options?: TestOrchestratorOptions<F>): TestOrchestrator<F>;
260
+ /** Constraint evaluation snapshot */
261
+ interface ConstraintSnapshot {
262
+ constraintId: string;
263
+ triggered: boolean;
264
+ requirement?: unknown;
265
+ facts: Record<string, unknown>;
266
+ timestamp: number;
267
+ }
268
+ /**
269
+ * Create a constraint evaluation recorder for snapshot testing.
270
+ *
271
+ * @example
272
+ * ```typescript
273
+ * const recorder = createConstraintRecorder();
274
+ * const orchestrator = createAgentOrchestrator({
275
+ * plugins: [recorder.plugin],
276
+ * });
277
+ *
278
+ * await orchestrator.run(agent, 'Hello');
279
+ *
280
+ * expect(recorder.getSnapshots()).toMatchSnapshot();
281
+ * ```
282
+ */
283
+ declare function createConstraintRecorder(): {
284
+ plugin: {
285
+ name: string;
286
+ onRequirementCreated: (data: {
287
+ constraintId: string;
288
+ requirement: unknown;
289
+ facts: unknown;
290
+ }) => void;
291
+ };
292
+ getSnapshots(): ConstraintSnapshot[];
293
+ clearSnapshots(): void;
294
+ };
295
+ /**
296
+ * Assert that an orchestrator has specific state.
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * assertOrchestratorState(orchestrator, {
301
+ * agentStatus: 'completed',
302
+ * tokenUsage: { min: 0, max: 1000 },
303
+ * pendingApprovals: 0,
304
+ * });
305
+ * ```
306
+ */
307
+ declare function assertOrchestratorState<F extends Record<string, unknown>>(orchestrator: AgentOrchestrator<F>, expected: {
308
+ agentStatus?: "idle" | "running" | "paused" | "completed" | "error";
309
+ tokenUsage?: {
310
+ min?: number;
311
+ max?: number;
312
+ exact?: number;
313
+ };
314
+ pendingApprovals?: number;
315
+ conversationLength?: {
316
+ min?: number;
317
+ max?: number;
318
+ exact?: number;
319
+ };
320
+ }): void;
321
+ /**
322
+ * Create a time controller for testing time-dependent behavior.
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * const time = createTimeController();
327
+ *
328
+ * // Override Date.now
329
+ * const originalNow = Date.now;
330
+ * Date.now = () => time.now();
331
+ *
332
+ * time.advance(1000); // Advance 1 second
333
+ *
334
+ * // Restore
335
+ * Date.now = originalNow;
336
+ * ```
337
+ */
338
+ declare function createTimeController(startTime?: number): {
339
+ now(): number;
340
+ advance(ms: number): void;
341
+ set(time: number): void;
342
+ reset(): void;
343
+ };
344
+
345
+ export { type ApprovalSimulator, type ApprovalSimulatorOptions, type ConstraintSnapshot, type GuardrailTestInput, type GuardrailTestResult, type MockAgentConfig, type MockAgentRunner, type MockAgentRunnerOptions, type RecordedCall, type TestOrchestrator, type TestOrchestratorOptions, assertOrchestratorState, createApprovalSimulator, createConstraintRecorder, createMockAgentRunner, createTestOrchestrator, createTimeController, testGuardrail, testGuardrailBatch };