()
| 57 | * Run the simulated test |
| 58 | */ |
| 59 | export async function runSimulatedTest(): Promise<TestResult> { |
| 60 | logSection('Simulated Skills Test') |
| 61 | logInfo('Testing skill creation and reuse with mock adapter') |
| 62 | |
| 63 | // Create shared storage that persists between phases |
| 64 | const storage = createTestStorage() |
| 65 | const driver = createNodeIsolateDriver({ |
| 66 | memoryLimit: 128, |
| 67 | timeout: 30000, |
| 68 | }) |
| 69 | |
| 70 | const result: TestResult = { |
| 71 | passed: false, |
| 72 | phases: { |
| 73 | phase1: { success: false }, |
| 74 | phase2: { success: false }, |
| 75 | }, |
| 76 | skillCreated: false, |
| 77 | skillUsed: false, |
| 78 | } |
| 79 | |
| 80 | // ========================================================================= |
| 81 | // Phase 1: First run - Create skill using code mode |
| 82 | // ========================================================================= |
| 83 | |
| 84 | logSection('Phase 1: Skill Creation') |
| 85 | logStep(1, 'Setting up mock adapter with skill creation responses') |
| 86 | |
| 87 | // Mock adapter for skill selection in Phase 1 (no skills exist yet) |
| 88 | const phase1SelectionAdapter = createSkillSelectionAdapter([]) |
| 89 | |
| 90 | // Mock responses for Phase 1 main chat: |
| 91 | // 1. First, use execute_typescript to solve the problem |
| 92 | // 2. Then, register the skill for future use |
| 93 | // 3. Finally, provide the answer |
| 94 | const phase1ChatAdapter = createMockTextAdapter({ |
| 95 | responses: [ |
| 96 | // Response 1: Execute TypeScript to add numbers |
| 97 | singleToolCall( |
| 98 | 'execute_typescript', |
| 99 | { |
| 100 | typescriptCode: ADD_NUMBERS_CODE, |
| 101 | }, |
| 102 | 'call_execute_1', |
| 103 | ), |
| 104 | |
| 105 | // Response 2: Register the skill |
| 106 | singleToolCall( |
| 107 | 'register_skill', |
| 108 | { |
| 109 | name: 'add_two_numbers', |
| 110 | description: 'Add two numbers together using the add_numbers tool', |
| 111 | code: EXPECTED_SKILL_CODE, |
| 112 | inputSchema: JSON.stringify(EXPECTED_SKILL_INPUT_SCHEMA), |
| 113 | outputSchema: JSON.stringify(EXPECTED_SKILL_OUTPUT_SCHEMA), |
| 114 | usageHints: ['Use when the user wants to add two numbers'], |
| 115 | dependsOn: [], |
| 116 | }, |
no test coverage detected