llmist 2.5.0 → 2.6.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.
@@ -1,9 +1,256 @@
1
- import { B as BaseGadget, L as LLMStream, a as LLMStreamChunk, b as LLMMessage, I as IConversationManager } from '../mock-stream-ga4KIiwX.cjs';
2
- export { j as MockAudioData, d as MockBuilder, k as MockImageData, f as MockManager, l as MockMatcher, n as MockMatcherContext, o as MockOptions, M as MockProviderAdapter, p as MockRegistration, q as MockResponse, r as MockStats, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM } from '../mock-stream-ga4KIiwX.cjs';
3
- import { ZodType } from 'zod';
4
1
  import { PassThrough, Readable, Writable } from 'node:stream';
2
+ import { L as LLMMessage, B as BaseGadget, I as IConversationManager, a as LLMStream, b as LLMStreamChunk } from '../mock-stream-Jgg5u6Uf.cjs';
3
+ export { j as MockAudioData, d as MockBuilder, k as MockImageData, f as MockManager, l as MockMatcher, n as MockMatcherContext, o as MockOptions, M as MockProviderAdapter, p as MockRegistration, q as MockResponse, r as MockStats, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM } from '../mock-stream-Jgg5u6Uf.cjs';
4
+ import { ZodType } from 'zod';
5
5
  import 'tslog';
6
6
 
7
+ /**
8
+ * CLI testing utilities for llmist.
9
+ * Provides helpers for testing CLI commands without real I/O.
10
+ */
11
+
12
+ /**
13
+ * Options for creating a test environment.
14
+ */
15
+ interface TestEnvironmentOptions {
16
+ /** Input to provide via stdin (string or line array) */
17
+ stdin?: string | string[];
18
+ /** Whether stdin is a TTY (default: false) */
19
+ isTTY?: boolean;
20
+ /** Environment variables to set */
21
+ env?: Record<string, string>;
22
+ /** Command line arguments (default: ["node", "llmist"]) */
23
+ argv?: string[];
24
+ }
25
+ /**
26
+ * A test environment with captured I/O streams.
27
+ */
28
+ interface TestEnvironment {
29
+ /** Stdin readable stream */
30
+ stdin: Readable;
31
+ /** Stdout writable stream (PassThrough for capturing) */
32
+ stdout: PassThrough;
33
+ /** Stderr writable stream (PassThrough for capturing) */
34
+ stderr: PassThrough;
35
+ /** Whether stdin is TTY */
36
+ isTTY: boolean;
37
+ /** Command line arguments */
38
+ argv: string[];
39
+ /** Environment variables */
40
+ env: Record<string, string>;
41
+ /** Exit code if set */
42
+ exitCode?: number;
43
+ /** Function to set exit code */
44
+ setExitCode: (code: number) => void;
45
+ }
46
+ /**
47
+ * Create a test environment with mocked I/O streams.
48
+ *
49
+ * @param options - Configuration options
50
+ * @returns A test environment with captured streams
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const env = createTestEnvironment({
55
+ * stdin: '{"param": "value"}',
56
+ * isTTY: false
57
+ * });
58
+ *
59
+ * // Pass to CLI command
60
+ * await executeCommand(env);
61
+ *
62
+ * // Check output
63
+ * const output = await collectOutput(env.stdout);
64
+ * expect(output).toContain("Success");
65
+ * ```
66
+ */
67
+ declare function createTestEnvironment(options?: TestEnvironmentOptions): TestEnvironment;
68
+ /**
69
+ * Create a readable stream from a string or array of lines.
70
+ *
71
+ * @param input - String content or array of lines
72
+ * @returns A Readable stream
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const stream = createMockReadable("line1\nline2\n");
77
+ * // or
78
+ * const stream = createMockReadable(["line1", "line2"]);
79
+ * ```
80
+ */
81
+ declare function createMockReadable(input?: string | string[]): Readable;
82
+ /**
83
+ * Create a writable stream that collects all written data.
84
+ *
85
+ * @returns A writable stream with getData() method
86
+ */
87
+ declare function createMockWritable(): Writable & {
88
+ getData(): string;
89
+ };
90
+ /**
91
+ * Collect all output from a PassThrough stream.
92
+ * Waits for the stream to end before returning.
93
+ *
94
+ * @param stream - The stream to collect from
95
+ * @param timeout - Maximum time to wait in ms (default: 5000)
96
+ * @returns All data written to the stream
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const output = await collectOutput(env.stdout);
101
+ * expect(output).toContain("Expected text");
102
+ * ```
103
+ */
104
+ declare function collectOutput(stream: PassThrough, timeout?: number): Promise<string>;
105
+ /**
106
+ * Collect output without waiting for stream end.
107
+ * Returns immediately with whatever has been written.
108
+ *
109
+ * @param stream - The stream to read from
110
+ * @returns Currently buffered data
111
+ */
112
+ declare function getBufferedOutput(stream: PassThrough): string;
113
+ /**
114
+ * Create a mock prompt function for testing interactive input.
115
+ *
116
+ * @param responses - Array of responses to return in order
117
+ * @returns A prompt function that returns the next response
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const prompt = createMockPrompt(["yes", "no", "maybe"]);
122
+ * expect(await prompt("Question 1?")).toBe("yes");
123
+ * expect(await prompt("Question 2?")).toBe("no");
124
+ * ```
125
+ */
126
+ declare function createMockPrompt(responses: string[]): (question: string) => Promise<string>;
127
+ /**
128
+ * Mock prompt that records questions and returns configured responses.
129
+ */
130
+ declare class MockPromptRecorder {
131
+ private responses;
132
+ private index;
133
+ private questions;
134
+ constructor(responses: string[]);
135
+ /**
136
+ * The prompt function to use in tests.
137
+ */
138
+ prompt: (question: string) => Promise<string>;
139
+ /**
140
+ * Get all questions that were asked.
141
+ */
142
+ getQuestions(): string[];
143
+ /**
144
+ * Get the number of questions asked.
145
+ */
146
+ getQuestionCount(): number;
147
+ /**
148
+ * Reset the recorder state.
149
+ */
150
+ reset(newResponses?: string[]): void;
151
+ }
152
+ /**
153
+ * Wait for a condition to be true, with timeout.
154
+ * Useful for async testing scenarios.
155
+ *
156
+ * @param condition - Function that returns true when condition is met
157
+ * @param timeout - Maximum time to wait in ms (default: 5000)
158
+ * @param interval - Check interval in ms (default: 50)
159
+ */
160
+ declare function waitFor(condition: () => boolean, timeout?: number, interval?: number): Promise<void>;
161
+
162
+ /**
163
+ * Conversation fixture generators for testing.
164
+ * Provides utilities for creating test conversation data.
165
+ */
166
+
167
+ /**
168
+ * Create a conversation with a specified number of turns.
169
+ * Each turn consists of a user message and an assistant response.
170
+ *
171
+ * @param turnCount - Number of conversation turns to generate
172
+ * @param options - Configuration options
173
+ * @returns Array of LLMMessages representing the conversation
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const messages = createConversation(5);
178
+ * // Creates 10 messages: 5 user + 5 assistant
179
+ * ```
180
+ */
181
+ declare function createConversation(turnCount: number, options?: {
182
+ /** Prefix for user messages (default: "User message") */
183
+ userPrefix?: string;
184
+ /** Prefix for assistant messages (default: "Assistant response") */
185
+ assistantPrefix?: string;
186
+ /** Base content length per message (default: 100 chars) */
187
+ contentLength?: number;
188
+ }): LLMMessage[];
189
+ /**
190
+ * Create a conversation with gadget calls interspersed.
191
+ * Simulates an agent conversation with tool usage.
192
+ *
193
+ * @param turnCount - Number of conversation turns
194
+ * @param gadgetCallsPerTurn - Number of gadget calls per assistant turn
195
+ * @returns Array of LLMMessages including gadget call/result pairs
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const messages = createConversationWithGadgets(3, 2);
200
+ * // Creates: user, assistant+gadget, gadget-result, assistant+gadget, gadget-result, assistant (per turn)
201
+ * ```
202
+ */
203
+ declare function createConversationWithGadgets(turnCount: number, gadgetCallsPerTurn?: number, options?: {
204
+ /** Gadget names to cycle through (default: ["search", "calculate", "read"]) */
205
+ gadgetNames?: string[];
206
+ /** Content length for messages */
207
+ contentLength?: number;
208
+ }): LLMMessage[];
209
+ /**
210
+ * Estimate token count for a message array.
211
+ * Uses a simple 4-characters-per-token heuristic.
212
+ *
213
+ * @param messages - Messages to estimate tokens for
214
+ * @returns Estimated token count
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const messages = createConversation(10);
219
+ * const tokens = estimateTokens(messages);
220
+ * // Returns approximate token count
221
+ * ```
222
+ */
223
+ declare function estimateTokens(messages: LLMMessage[]): number;
224
+ /**
225
+ * Create a single user message.
226
+ */
227
+ declare function createUserMessage(content: string): LLMMessage;
228
+ /**
229
+ * Create a single assistant message.
230
+ */
231
+ declare function createAssistantMessage(content: string): LLMMessage;
232
+ /**
233
+ * Create a system message.
234
+ */
235
+ declare function createSystemMessage(content: string): LLMMessage;
236
+ /**
237
+ * Create a minimal conversation for quick tests.
238
+ * Returns a single turn: one user message and one assistant response.
239
+ */
240
+ declare function createMinimalConversation(): LLMMessage[];
241
+ /**
242
+ * Create a conversation that exceeds a target token count.
243
+ * Useful for testing compaction triggers.
244
+ *
245
+ * @param targetTokens - Minimum token count to exceed
246
+ * @param options - Configuration options
247
+ * @returns Conversation with at least targetTokens tokens
248
+ */
249
+ declare function createLargeConversation(targetTokens: number, options?: {
250
+ /** Average tokens per turn (default: 200) */
251
+ tokensPerTurn?: number;
252
+ }): LLMMessage[];
253
+
7
254
  /**
8
255
  * Testing utilities for gadgets.
9
256
  *
@@ -104,13 +351,99 @@ declare function testGadget(gadget: BaseGadget, params: Record<string, unknown>,
104
351
  declare function testGadgetBatch(gadget: BaseGadget, paramSets: Record<string, unknown>[], options?: TestGadgetOptions): Promise<TestGadgetResult[]>;
105
352
 
106
353
  /**
107
- * Mock gadget utilities for testing.
108
- *
109
- * Provides helpers for creating mock gadgets with configurable behavior
110
- * and call tracking.
111
- *
112
- * @module testing/mock-gadget
113
- */
354
+ * Mock ConversationManager for testing compaction and agent components.
355
+ * Implements IConversationManager interface with test-friendly features.
356
+ */
357
+
358
+ /**
359
+ * A mock implementation of IConversationManager for testing.
360
+ * Tracks all operations and allows inspection of state changes.
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * const mockConvo = new MockConversationManager([
365
+ * { role: "user", content: "Hello" },
366
+ * { role: "assistant", content: "Hi!" }
367
+ * ]);
368
+ *
369
+ * // Use in compaction tests
370
+ * compactionManager.checkAndCompact(mockConvo, 1);
371
+ *
372
+ * // Assert on state changes
373
+ * expect(mockConvo.wasReplaceHistoryCalled()).toBe(true);
374
+ * expect(mockConvo.getReplacementHistory()).toHaveLength(2);
375
+ * ```
376
+ */
377
+ declare class MockConversationManager implements IConversationManager {
378
+ private history;
379
+ private readonly baseMessages;
380
+ private replacementHistory;
381
+ private replaceHistoryCallCount;
382
+ private addedMessages;
383
+ constructor(history?: LLMMessage[], baseMessages?: LLMMessage[]);
384
+ addUserMessage(content: string): void;
385
+ addAssistantMessage(content: string): void;
386
+ addGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): void;
387
+ getMessages(): LLMMessage[];
388
+ getHistoryMessages(): LLMMessage[];
389
+ getBaseMessages(): LLMMessage[];
390
+ replaceHistory(newHistory: LLMMessage[]): void;
391
+ /**
392
+ * Check if replaceHistory was called.
393
+ */
394
+ wasReplaceHistoryCalled(): boolean;
395
+ /**
396
+ * Get the number of times replaceHistory was called.
397
+ */
398
+ getReplaceHistoryCallCount(): number;
399
+ /**
400
+ * Get the most recent history passed to replaceHistory.
401
+ * Returns undefined if replaceHistory was never called.
402
+ */
403
+ getReplacementHistory(): LLMMessage[] | undefined;
404
+ /**
405
+ * Get all messages that were added via add* methods.
406
+ */
407
+ getAddedMessages(): LLMMessage[];
408
+ /**
409
+ * Reset all tracking state while preserving the conversation.
410
+ */
411
+ resetTracking(): void;
412
+ /**
413
+ * Completely reset the mock to initial state.
414
+ * Note: baseMessages cannot be changed after construction.
415
+ */
416
+ reset(history?: LLMMessage[]): void;
417
+ /**
418
+ * Set the history directly (for test setup).
419
+ */
420
+ setHistory(messages: LLMMessage[]): void;
421
+ /**
422
+ * Get the current history length.
423
+ */
424
+ getHistoryLength(): number;
425
+ /**
426
+ * Get total message count (base + history).
427
+ */
428
+ getTotalMessageCount(): number;
429
+ }
430
+ /**
431
+ * Create a mock conversation manager with a pre-populated conversation.
432
+ *
433
+ * @param turnCount - Number of conversation turns
434
+ * @param baseMessages - Optional base messages (system prompts)
435
+ * @returns Configured MockConversationManager
436
+ */
437
+ declare function createMockConversationManager(turnCount: number, baseMessages?: LLMMessage[]): MockConversationManager;
438
+
439
+ /**
440
+ * Mock gadget utilities for testing.
441
+ *
442
+ * Provides helpers for creating mock gadgets with configurable behavior
443
+ * and call tracking.
444
+ *
445
+ * @module testing/mock-gadget
446
+ */
114
447
 
115
448
  /**
116
449
  * Recorded gadget call for tracking.
@@ -374,337 +707,4 @@ declare function createEmptyStream(): LLMStream;
374
707
  */
375
708
  declare function createErrorStream(chunksBeforeError: LLMStreamChunk[], error: Error): LLMStream;
376
709
 
377
- /**
378
- * Conversation fixture generators for testing.
379
- * Provides utilities for creating test conversation data.
380
- */
381
-
382
- /**
383
- * Create a conversation with a specified number of turns.
384
- * Each turn consists of a user message and an assistant response.
385
- *
386
- * @param turnCount - Number of conversation turns to generate
387
- * @param options - Configuration options
388
- * @returns Array of LLMMessages representing the conversation
389
- *
390
- * @example
391
- * ```typescript
392
- * const messages = createConversation(5);
393
- * // Creates 10 messages: 5 user + 5 assistant
394
- * ```
395
- */
396
- declare function createConversation(turnCount: number, options?: {
397
- /** Prefix for user messages (default: "User message") */
398
- userPrefix?: string;
399
- /** Prefix for assistant messages (default: "Assistant response") */
400
- assistantPrefix?: string;
401
- /** Base content length per message (default: 100 chars) */
402
- contentLength?: number;
403
- }): LLMMessage[];
404
- /**
405
- * Create a conversation with gadget calls interspersed.
406
- * Simulates an agent conversation with tool usage.
407
- *
408
- * @param turnCount - Number of conversation turns
409
- * @param gadgetCallsPerTurn - Number of gadget calls per assistant turn
410
- * @returns Array of LLMMessages including gadget call/result pairs
411
- *
412
- * @example
413
- * ```typescript
414
- * const messages = createConversationWithGadgets(3, 2);
415
- * // Creates: user, assistant+gadget, gadget-result, assistant+gadget, gadget-result, assistant (per turn)
416
- * ```
417
- */
418
- declare function createConversationWithGadgets(turnCount: number, gadgetCallsPerTurn?: number, options?: {
419
- /** Gadget names to cycle through (default: ["search", "calculate", "read"]) */
420
- gadgetNames?: string[];
421
- /** Content length for messages */
422
- contentLength?: number;
423
- }): LLMMessage[];
424
- /**
425
- * Estimate token count for a message array.
426
- * Uses a simple 4-characters-per-token heuristic.
427
- *
428
- * @param messages - Messages to estimate tokens for
429
- * @returns Estimated token count
430
- *
431
- * @example
432
- * ```typescript
433
- * const messages = createConversation(10);
434
- * const tokens = estimateTokens(messages);
435
- * // Returns approximate token count
436
- * ```
437
- */
438
- declare function estimateTokens(messages: LLMMessage[]): number;
439
- /**
440
- * Create a single user message.
441
- */
442
- declare function createUserMessage(content: string): LLMMessage;
443
- /**
444
- * Create a single assistant message.
445
- */
446
- declare function createAssistantMessage(content: string): LLMMessage;
447
- /**
448
- * Create a system message.
449
- */
450
- declare function createSystemMessage(content: string): LLMMessage;
451
- /**
452
- * Create a minimal conversation for quick tests.
453
- * Returns a single turn: one user message and one assistant response.
454
- */
455
- declare function createMinimalConversation(): LLMMessage[];
456
- /**
457
- * Create a conversation that exceeds a target token count.
458
- * Useful for testing compaction triggers.
459
- *
460
- * @param targetTokens - Minimum token count to exceed
461
- * @param options - Configuration options
462
- * @returns Conversation with at least targetTokens tokens
463
- */
464
- declare function createLargeConversation(targetTokens: number, options?: {
465
- /** Average tokens per turn (default: 200) */
466
- tokensPerTurn?: number;
467
- }): LLMMessage[];
468
-
469
- /**
470
- * Mock ConversationManager for testing compaction and agent components.
471
- * Implements IConversationManager interface with test-friendly features.
472
- */
473
-
474
- /**
475
- * A mock implementation of IConversationManager for testing.
476
- * Tracks all operations and allows inspection of state changes.
477
- *
478
- * @example
479
- * ```typescript
480
- * const mockConvo = new MockConversationManager([
481
- * { role: "user", content: "Hello" },
482
- * { role: "assistant", content: "Hi!" }
483
- * ]);
484
- *
485
- * // Use in compaction tests
486
- * compactionManager.checkAndCompact(mockConvo, 1);
487
- *
488
- * // Assert on state changes
489
- * expect(mockConvo.wasReplaceHistoryCalled()).toBe(true);
490
- * expect(mockConvo.getReplacementHistory()).toHaveLength(2);
491
- * ```
492
- */
493
- declare class MockConversationManager implements IConversationManager {
494
- private history;
495
- private readonly baseMessages;
496
- private replacementHistory;
497
- private replaceHistoryCallCount;
498
- private addedMessages;
499
- constructor(history?: LLMMessage[], baseMessages?: LLMMessage[]);
500
- addUserMessage(content: string): void;
501
- addAssistantMessage(content: string): void;
502
- addGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): void;
503
- getMessages(): LLMMessage[];
504
- getHistoryMessages(): LLMMessage[];
505
- getBaseMessages(): LLMMessage[];
506
- replaceHistory(newHistory: LLMMessage[]): void;
507
- /**
508
- * Check if replaceHistory was called.
509
- */
510
- wasReplaceHistoryCalled(): boolean;
511
- /**
512
- * Get the number of times replaceHistory was called.
513
- */
514
- getReplaceHistoryCallCount(): number;
515
- /**
516
- * Get the most recent history passed to replaceHistory.
517
- * Returns undefined if replaceHistory was never called.
518
- */
519
- getReplacementHistory(): LLMMessage[] | undefined;
520
- /**
521
- * Get all messages that were added via add* methods.
522
- */
523
- getAddedMessages(): LLMMessage[];
524
- /**
525
- * Reset all tracking state while preserving the conversation.
526
- */
527
- resetTracking(): void;
528
- /**
529
- * Completely reset the mock to initial state.
530
- * Note: baseMessages cannot be changed after construction.
531
- */
532
- reset(history?: LLMMessage[]): void;
533
- /**
534
- * Set the history directly (for test setup).
535
- */
536
- setHistory(messages: LLMMessage[]): void;
537
- /**
538
- * Get the current history length.
539
- */
540
- getHistoryLength(): number;
541
- /**
542
- * Get total message count (base + history).
543
- */
544
- getTotalMessageCount(): number;
545
- }
546
- /**
547
- * Create a mock conversation manager with a pre-populated conversation.
548
- *
549
- * @param turnCount - Number of conversation turns
550
- * @param baseMessages - Optional base messages (system prompts)
551
- * @returns Configured MockConversationManager
552
- */
553
- declare function createMockConversationManager(turnCount: number, baseMessages?: LLMMessage[]): MockConversationManager;
554
-
555
- /**
556
- * CLI testing utilities for llmist.
557
- * Provides helpers for testing CLI commands without real I/O.
558
- */
559
-
560
- /**
561
- * Options for creating a test environment.
562
- */
563
- interface TestEnvironmentOptions {
564
- /** Input to provide via stdin (string or line array) */
565
- stdin?: string | string[];
566
- /** Whether stdin is a TTY (default: false) */
567
- isTTY?: boolean;
568
- /** Environment variables to set */
569
- env?: Record<string, string>;
570
- /** Command line arguments (default: ["node", "llmist"]) */
571
- argv?: string[];
572
- }
573
- /**
574
- * A test environment with captured I/O streams.
575
- */
576
- interface TestEnvironment {
577
- /** Stdin readable stream */
578
- stdin: Readable;
579
- /** Stdout writable stream (PassThrough for capturing) */
580
- stdout: PassThrough;
581
- /** Stderr writable stream (PassThrough for capturing) */
582
- stderr: PassThrough;
583
- /** Whether stdin is TTY */
584
- isTTY: boolean;
585
- /** Command line arguments */
586
- argv: string[];
587
- /** Environment variables */
588
- env: Record<string, string>;
589
- /** Exit code if set */
590
- exitCode?: number;
591
- /** Function to set exit code */
592
- setExitCode: (code: number) => void;
593
- }
594
- /**
595
- * Create a test environment with mocked I/O streams.
596
- *
597
- * @param options - Configuration options
598
- * @returns A test environment with captured streams
599
- *
600
- * @example
601
- * ```typescript
602
- * const env = createTestEnvironment({
603
- * stdin: '{"param": "value"}',
604
- * isTTY: false
605
- * });
606
- *
607
- * // Pass to CLI command
608
- * await executeCommand(env);
609
- *
610
- * // Check output
611
- * const output = await collectOutput(env.stdout);
612
- * expect(output).toContain("Success");
613
- * ```
614
- */
615
- declare function createTestEnvironment(options?: TestEnvironmentOptions): TestEnvironment;
616
- /**
617
- * Create a readable stream from a string or array of lines.
618
- *
619
- * @param input - String content or array of lines
620
- * @returns A Readable stream
621
- *
622
- * @example
623
- * ```typescript
624
- * const stream = createMockReadable("line1\nline2\n");
625
- * // or
626
- * const stream = createMockReadable(["line1", "line2"]);
627
- * ```
628
- */
629
- declare function createMockReadable(input?: string | string[]): Readable;
630
- /**
631
- * Create a writable stream that collects all written data.
632
- *
633
- * @returns A writable stream with getData() method
634
- */
635
- declare function createMockWritable(): Writable & {
636
- getData(): string;
637
- };
638
- /**
639
- * Collect all output from a PassThrough stream.
640
- * Waits for the stream to end before returning.
641
- *
642
- * @param stream - The stream to collect from
643
- * @param timeout - Maximum time to wait in ms (default: 5000)
644
- * @returns All data written to the stream
645
- *
646
- * @example
647
- * ```typescript
648
- * const output = await collectOutput(env.stdout);
649
- * expect(output).toContain("Expected text");
650
- * ```
651
- */
652
- declare function collectOutput(stream: PassThrough, timeout?: number): Promise<string>;
653
- /**
654
- * Collect output without waiting for stream end.
655
- * Returns immediately with whatever has been written.
656
- *
657
- * @param stream - The stream to read from
658
- * @returns Currently buffered data
659
- */
660
- declare function getBufferedOutput(stream: PassThrough): string;
661
- /**
662
- * Create a mock prompt function for testing interactive input.
663
- *
664
- * @param responses - Array of responses to return in order
665
- * @returns A prompt function that returns the next response
666
- *
667
- * @example
668
- * ```typescript
669
- * const prompt = createMockPrompt(["yes", "no", "maybe"]);
670
- * expect(await prompt("Question 1?")).toBe("yes");
671
- * expect(await prompt("Question 2?")).toBe("no");
672
- * ```
673
- */
674
- declare function createMockPrompt(responses: string[]): (question: string) => Promise<string>;
675
- /**
676
- * Mock prompt that records questions and returns configured responses.
677
- */
678
- declare class MockPromptRecorder {
679
- private responses;
680
- private index;
681
- private questions;
682
- constructor(responses: string[]);
683
- /**
684
- * The prompt function to use in tests.
685
- */
686
- prompt: (question: string) => Promise<string>;
687
- /**
688
- * Get all questions that were asked.
689
- */
690
- getQuestions(): string[];
691
- /**
692
- * Get the number of questions asked.
693
- */
694
- getQuestionCount(): number;
695
- /**
696
- * Reset the recorder state.
697
- */
698
- reset(newResponses?: string[]): void;
699
- }
700
- /**
701
- * Wait for a condition to be true, with timeout.
702
- * Useful for async testing scenarios.
703
- *
704
- * @param condition - Function that returns true when condition is met
705
- * @param timeout - Maximum time to wait in ms (default: 5000)
706
- * @param interval - Check interval in ms (default: 50)
707
- */
708
- declare function waitFor(condition: () => boolean, timeout?: number, interval?: number): Promise<void>;
709
-
710
710
  export { MockConversationManager, type MockGadget, MockGadgetBuilder, type MockGadgetConfig, MockPromptRecorder, type RecordedCall, type TestEnvironment, type TestEnvironmentOptions, type TestGadgetOptions, type TestGadgetResult, collectOutput, collectStream, collectStreamText, createAssistantMessage, createConversation, createConversationWithGadgets, createEmptyStream, createErrorStream, createLargeConversation, createMinimalConversation, createMockConversationManager, createMockGadget, createMockPrompt, createMockReadable, createMockWritable, createSystemMessage, createTestEnvironment, createTestStream, createTextStream, createUserMessage, estimateTokens, getBufferedOutput, getStreamFinalChunk, mockGadget, testGadget, testGadgetBatch, waitFor };