UNPKG

@agentled/cli

Version:

CLI for Agentled — manage workflows, apps, and knowledge from the command line. Zero context-window cost for AI agents.

86 lines (85 loc) 3 kB
/** * Declarative test runner — runs assertions against captured fixture outputs * (zero credits) or live API calls (`--live`, costs credits for AI/app steps). * * Test file format (tests/<workflowId>.test.json): * { * "workflowId": "wf_abc", * "fixtureExecutionId": "exec_xyz", * "steps": [ * { * "stepId": "score-lead", * "type": "aiAction", * "fixtureSource": "exec_xyz/score-lead", * "assertions": [ * { "verb": "hasKey", "path": "score" }, * { "verb": "isType", "path": "score", "expect": "number" }, * { "verb": "inRange", "path": "score", "min": 0, "max": 100 }, * { "verb": "matches", "path": "decision", "pattern": "^(HOT|WARM|COLD)$" } * ] * } * ] * } * * Assertion verbs: hasKey, isType, equals, matches, inRange, hasLength, contains */ export interface Assertion { verb: 'hasKey' | 'isType' | 'equals' | 'matches' | 'inRange' | 'hasLength' | 'contains'; path: string; expect?: unknown; pattern?: string; min?: number; max?: number; comment?: string; } export interface StepTest { stepId: string; type: string; description?: string; fixtureSource?: string | null; skip?: boolean; assertions: Assertion[]; promptTemplate?: string; promptVariables?: Record<string, unknown>; promptResponseStructure?: Record<string, unknown>; codeConfig?: { language: string; code: string; }; appId?: string; actionId?: string; appInputs?: Record<string, unknown>; liveInputs?: Record<string, unknown>; } export interface TestFile { workflowId: string; workflowName?: string; description?: string; fixtureExecutionId?: string | null; steps: StepTest[]; } export interface TestResult { stepId: string; description?: string; mode: 'fixture' | 'live' | 'skipped'; passed: number; failed: number; skipped: number; errors: string[]; } export declare function getPath(obj: unknown, dotPath: string): unknown; export declare function runAssertion(output: unknown, assertion: Assertion): { pass: boolean; reason: string; }; export declare function loadFixture(wsDir: string | null, fixtureSource: string): Record<string, unknown> | null; export declare function runStepFixture(step: StepTest, wsDir: string | null): TestResult; interface MinimalClient { testAiAction(template: string, variables?: Record<string, unknown>, responseStructure?: Record<string, unknown>): Promise<unknown>; testAppAction(appId: string, actionId: string, input?: Record<string, unknown>): Promise<unknown>; testCodeAction(code: string, language: string, variables?: Record<string, unknown>): Promise<unknown>; } export declare function runStepLive(step: StepTest, client: MinimalClient): Promise<TestResult>; type Pipeline = Record<string, unknown>; export declare function makeTestSkeleton(workflowId: string, pipeline: Pipeline): TestFile; export {};