Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 49 lines 1.62 KB
Raw
1 /**
2 * Fixture files: one per journey, provider, and model.
3 *
4 * fixtures/<journey>.<provider>.<model>.json
5 *
6 * The model segment of a hand-authored file is `hand-authored`; no real model
7 * produced it.
8 */
9
10 import { readdirSync } from 'node:fs';
11 import { join } from 'node:path';
12
13 export const FIXTURE_DIRECTORY = join(import.meta.dir, '..', 'fixtures');
14 export const HAND_AUTHORED = 'hand-authored';
15
16 export type Provider = 'anthropic' | 'openai';
17
18 export interface FixtureFile {
19 readonly journeyId: string;
20 readonly provider: Provider;
21 readonly model: string;
22 readonly path: string;
23 }
24
25 export const fixturePath = (journeyId: string, provider: Provider, model: string): string =>
26 join(FIXTURE_DIRECTORY, `${journeyId}.${provider}.${model}.json`);
27
28 const FILE_NAME =
29 /^(?<journeyId>[a-z0-9-]+)\.(?<provider>anthropic|openai)\.(?<model>[a-z0-9.-]+)\.json$/;
30
31 /** Every file in the fixture directory. A file the name pattern does not explain is an error. */
32 export const listFixtures = (): FixtureFile[] =>
33 readdirSync(FIXTURE_DIRECTORY)
34 .sort()
35 .map(name => {
36 const groups = FILE_NAME.exec(name)?.groups;
37 if (!groups?.journeyId || !groups.model) {
38 // Skipping it would drop a journey's coverage without a failing test.
39 throw new Error(
40 `fixtures/${name} is not named <journey>.<anthropic|openai>.<model>.json; rename or remove it.`
41 );
42 }
43 return {
44 journeyId: groups.journeyId,
45 provider: groups.provider === 'anthropic' ? ('anthropic' as const) : ('openai' as const),
46 model: groups.model,
47 path: join(FIXTURE_DIRECTORY, name),
48 };
49 });