axiom 0.11.0 → 0.11.2
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.
- package/dist/bin.cjs +12 -10
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +3 -5
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-NGGNYE5N.js → chunk-CQCLS3XJ.js} +37 -3
- package/dist/chunk-CQCLS3XJ.js.map +1 -0
- package/dist/evals.cjs +68 -44
- package/dist/evals.cjs.map +1 -1
- package/dist/evals.d.cts +31 -33
- package/dist/evals.d.ts +31 -33
- package/dist/evals.js +61 -39
- package/dist/evals.js.map +1 -1
- package/dist/index.cjs +1 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/scorer.types-D6mnSKTJ.d.cts +12 -0
- package/dist/scorer.types-D6mnSKTJ.d.ts +12 -0
- package/package.json +1 -1
- package/dist/chunk-NGGNYE5N.js.map +0 -1
- package/dist/chunk-NR7XRR3Z.js +0 -35
- package/dist/chunk-NR7XRR3Z.js.map +0 -1
- package/dist/reporter-B9Ly79ok.d.cts +0 -18
- package/dist/reporter-B9Ly79ok.d.ts +0 -18
package/dist/bin.cjs
CHANGED
|
@@ -385,6 +385,7 @@ var import_node = require("vitest/node");
|
|
|
385
385
|
|
|
386
386
|
// src/evals/reporter.ts
|
|
387
387
|
var import_console_table_printer = require("console-table-printer");
|
|
388
|
+
var prRed = (s) => `\x1B[91m ${s}\x1B[00m`;
|
|
388
389
|
var AxiomReporter = class {
|
|
389
390
|
onTestSuiteReady(_testSuite) {
|
|
390
391
|
}
|
|
@@ -398,14 +399,15 @@ var AxiomReporter = class {
|
|
|
398
399
|
if (!testMeta.eval) {
|
|
399
400
|
return;
|
|
400
401
|
}
|
|
401
|
-
const scores =
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
402
|
+
const scores = Object.keys(testMeta.eval.scores).map((k) => {
|
|
403
|
+
const v = testMeta.eval.scores[k].score ? testMeta.eval.scores[k].score : 0;
|
|
404
|
+
const scoreValue = Number(v * 100).toFixed(2);
|
|
405
|
+
const score = testMeta.eval.threshold && v < testMeta.eval.threshold ? prRed(scoreValue + "%") : scoreValue + "%";
|
|
406
|
+
return [k, score];
|
|
407
|
+
});
|
|
406
408
|
scoreboard.addRow({
|
|
407
|
-
case: testMeta.eval.
|
|
408
|
-
...Object.fromEntries(scores
|
|
409
|
+
case: testMeta.eval.index.toString(),
|
|
410
|
+
...Object.fromEntries(scores)
|
|
409
411
|
});
|
|
410
412
|
}
|
|
411
413
|
scoreboard.printTable();
|
|
@@ -441,12 +443,12 @@ var processor = new import_sdk_trace_node.BatchSpanProcessor(exporter, {
|
|
|
441
443
|
var provider = new import_sdk_trace_node.NodeTracerProvider({
|
|
442
444
|
resource: (0, import_resources.resourceFromAttributes)({
|
|
443
445
|
["service.name"]: "axiom-ai",
|
|
444
|
-
["service.version"]: "0.11.
|
|
446
|
+
["service.version"]: "0.11.2"
|
|
445
447
|
}),
|
|
446
448
|
spanProcessors: [processor]
|
|
447
449
|
});
|
|
448
450
|
provider.register();
|
|
449
|
-
var tracer = import_api.trace.getTracer("axiom-ai", "0.11.
|
|
451
|
+
var tracer = import_api.trace.getTracer("axiom-ai", "0.11.2");
|
|
450
452
|
var flush = async () => {
|
|
451
453
|
await provider.forceFlush();
|
|
452
454
|
};
|
|
@@ -488,7 +490,7 @@ var loadRunCommand = (program2) => {
|
|
|
488
490
|
var { loadEnvConfig } = import_env.default;
|
|
489
491
|
loadEnvConfig(process.cwd());
|
|
490
492
|
var program = new import_commander4.Command();
|
|
491
|
-
program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.11.
|
|
493
|
+
program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.11.2");
|
|
492
494
|
loadPushCommand(program);
|
|
493
495
|
loadPullCommand(program);
|
|
494
496
|
loadRunCommand(program);
|
package/dist/bin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bin.ts","../src/commands/push.command.ts","../src/transpiler.ts","../src/commands/pull.command.ts","../src/commands/eval.command.ts","../src/evals/run-vitest.ts","../src/evals/reporter.ts","../src/evals/instrument.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// Load environment variables using @next/env\nimport pkg from '@next/env';\nconst { loadEnvConfig } = pkg;\n\n// Load .env files from the current working directory\nloadEnvConfig(process.cwd());\n\nimport { Command } from 'commander';\nimport { loadPushCommand } from './commands/push.command';\nimport { loadPullCommand } from './commands/pull.command';\nimport { loadRunCommand } from './commands/eval.command';\n\nconst program = new Command();\n\nprogram\n .name('axiom')\n .description(\"Axiom's CLI to manage your objects and run evals\")\n .version(__SDK_VERSION__);\n\nloadPushCommand(program);\nloadPullCommand(program);\nloadRunCommand(program);\n\nprogram.parse();\n","import { Command } from 'commander';\nimport {\n loadPromptModule,\n extractPromptFromModule,\n generatePromptFileFromApiResponse,\n} from '../transpiler';\nimport type { Prompt } from '../types';\nimport fs from 'node:fs/promises';\nimport readline from 'node:readline';\n\nasync function askConfirmation(message: string): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(`${message} (y/N): `, (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');\n });\n });\n}\n\nexport const loadPushCommand = (program: Command) => {\n const push = new Command('push')\n .description('Push a new version of an object')\n .argument(\n '<object>',\n 'The object to push, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--prod', 'Adds the production tag to the prompt')\n .option('--yes', 'Automatically confirm overwriting the file with server response')\n .action(async (filePath: string, options: { yes?: boolean; prod?: boolean }) => {\n let content: Prompt | null = null;\n if (!filePath.endsWith('.prompt.ts')) {\n console.error('Prompt files must end with .prompt.ts');\n process.exit(1);\n }\n\n try {\n const moduleContent = await loadPromptModule(filePath);\n const promptData = extractPromptFromModule(moduleContent, filePath);\n\n content = promptData;\n\n console.log(`Transpiled prompt: ${promptData.name} (${promptData.slug})`);\n } catch (error) {\n console.error('Failed to transpile prompt file:', error);\n process.exit(1);\n }\n\n if (!content) {\n console.error('No content found');\n process.exit(1);\n }\n\n let shouldProceed = options.yes;\n if (!shouldProceed) {\n shouldProceed = await askConfirmation(\n `This will push \"${content.name}\" to Axiom and overwrite ${filePath}, are you sure you want to continue?`,\n );\n }\n\n if (!shouldProceed) {\n console.log('Push operation cancelled.');\n process.exit(0);\n }\n\n try {\n const response = await fetch(`${process.env.AXIOM_URL}/v1/prompts`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n body: JSON.stringify({\n ...content,\n tags: options.yes ? ['production'] : [],\n }),\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n console.log(\n `Successfully pushed prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`,\n );\n console.log(`Version: ${apiResponse.version.version}`);\n\n const updatedTsContent = generatePromptFileFromApiResponse(apiResponse);\n\n await fs.writeFile(filePath, updatedTsContent, 'utf-8');\n\n console.log(`Successfully updated ${filePath}`);\n } catch (error) {\n console.error('Failed to push prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(push);\n};\n","import { build } from 'esbuild';\nimport os from 'node:os';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { basename } from 'node:path';\nimport type { Prompt } from './types';\n\nexport async function loadPromptModule(filePath: string) {\n const result = await build({\n entryPoints: [filePath],\n bundle: true,\n write: false,\n platform: 'node',\n format: 'esm',\n target: ['node18'],\n sourcemap: false,\n external: [\n // Only Node.js built-ins should be external\n 'fs',\n 'fs/promises',\n 'node:fs',\n 'node:fs/promises',\n 'readline',\n 'node:readline',\n 'path',\n 'node:path',\n 'os',\n 'node:os',\n 'url',\n 'node:url',\n 'util',\n 'node:util',\n 'crypto',\n 'node:crypto',\n 'events',\n 'node:events',\n 'stream',\n 'node:stream',\n 'buffer',\n 'node:buffer',\n 'process',\n 'node:process',\n ],\n });\n\n const code = result.outputFiles[0].text;\n\n // Create a unique temporary file\n const tempDir = os.tmpdir();\n const tempFileName = `axiom-ai-prompt-${Date.now()}-${Math.random().toString(36).substring(2)}.mjs`;\n const tempFilePath = path.join(tempDir, tempFileName);\n\n try {\n // Write the bundled code to temporary file\n await fs.writeFile(tempFilePath, code, 'utf-8');\n\n // Dynamically import the temporary module\n const moduleUrl = `file://${tempFilePath}`;\n const module = await import(moduleUrl);\n\n return module.default || module;\n } finally {\n // Clean up the temporary file\n try {\n await fs.unlink(tempFilePath);\n } catch (error) {\n // Ignore cleanup errors - temp files will be cleaned up by OS eventually\n console.warn(`Failed to clean up temporary file ${tempFilePath}:`, error);\n }\n }\n}\n\n/**\n * Convert TypeBox arguments to JSON Schema format expected by the API\n */\nfunction convertTypeBoxArgumentsToJsonSchema(arguments_: Record<string, any>): any {\n if (!arguments_ || typeof arguments_ !== 'object') {\n return {\n type: 'object',\n properties: {},\n required: [],\n additionalProperties: false,\n };\n }\n\n const properties: Record<string, any> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(arguments_)) {\n if (value && typeof value === 'object' && value.type) {\n // This is a TypeBox schema object that has been serialized\n properties[key] = {\n type: value.type,\n ...(value.description && { description: value.description }),\n ...(value.enum && { enum: value.enum }),\n ...(value.items && { items: value.items }),\n ...(value.properties && { properties: value.properties }),\n ...(value.required && { required: value.required }),\n };\n\n // For now, treat all arguments as required (this matches the existing behavior)\n // In the future, we could detect Type.Optional() usage\n required.push(key);\n }\n }\n\n return {\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n };\n}\n\nexport function extractPromptFromModule(moduleContent: any, filePath: string): Prompt {\n // Generate ID from file path if not provided\n const fileBaseName = basename(filePath, '.ts'); // Remove .ts extension\n const defaultId = fileBaseName.toLowerCase().replace(/[^a-z0-9]/g, '-');\n\n // Convert TypeBox arguments to JSON Schema format\n const convertedArguments = convertTypeBoxArgumentsToJsonSchema(moduleContent.arguments);\n\n // Extract and validate required fields from the module content\n const prompt: Prompt = {\n name: moduleContent.name || 'Untitled Prompt',\n slug: moduleContent.slug || defaultId,\n messages: moduleContent.messages || [],\n model: moduleContent.model,\n options: moduleContent.options,\n arguments: convertedArguments,\n id: moduleContent.id || defaultId,\n version: moduleContent.version || '1.0.0',\n // Optional fields from API response\n ...(moduleContent.promptId && { promptId: moduleContent.promptId }),\n ...(moduleContent.description && { description: moduleContent.description }),\n };\n\n // Validate required fields\n if (!prompt.name) {\n throw new Error('Prompt must have a name');\n }\n if (!prompt.slug) {\n throw new Error('Prompt must have a slug');\n }\n if (!Array.isArray(prompt.messages)) {\n throw new Error('Prompt messages must be an array');\n }\n\n if (!prompt.model) {\n throw new Error('Prompt must have a model');\n }\n\n return prompt;\n}\n\n/**\n * Transform JSON Schema to TypeBox/Template validator format\n */\nexport function transformJsonSchemaToTypeBox(schema: any): string {\n if (schema.type === 'string') {\n if (schema.enum && Array.isArray(schema.enum)) {\n // Handle enum as Union of Literals\n const literals = schema.enum.map((value: string) => `Type.Literal('${value}')`).join(', ');\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Union([${literals}]${options})`;\n } else {\n // Regular string\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.String(${options})`;\n }\n }\n\n if (schema.type === 'number' || schema.type === 'integer') {\n const typeMethod = schema.type === 'integer' ? 'Integer' : 'Number';\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.${typeMethod}(${options})`;\n }\n\n if (schema.type === 'boolean') {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Boolean(${options})`;\n }\n\n if (schema.type === 'array') {\n const itemsType = schema.items ? transformJsonSchemaToTypeBox(schema.items) : 'Type.String()';\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Array(${itemsType}${options})`;\n }\n\n if (schema.type === 'object') {\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(([key, value]: [string, any]) => {\n const isRequired = schema.required && schema.required.includes(key);\n const propType = transformJsonSchemaToTypeBox(value);\n return ` ${key}: ${isRequired ? propType : `Type.Optional(${propType})`}`;\n })\n .join(',\\n');\n\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Object({\\n${props}\\n }${options})`;\n } else {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Object({}${options ? `, ${options}` : ''})`;\n }\n }\n\n // Fallback for unknown types\n return 'Type.String()';\n}\n\n/**\n * Generate TypeScript prompt file content from API response\n */\nexport function generatePromptFileFromApiResponse(apiResponse: any): string {\n const { prompt, version } = apiResponse;\n const { data, options } = version;\n\n // Transform arguments from JSON Schema to TypeBox format\n let argumentsCode = '{}';\n if (data.arguments && data.arguments.properties) {\n const argEntries = Object.entries(data.arguments.properties)\n .map(([key, schema]: [string, any]) => {\n const isRequired = data.arguments.required && data.arguments.required.includes(key);\n const typeCode = transformJsonSchemaToTypeBox(schema);\n return ` ${key}: ${isRequired ? typeCode : `Type.Optional(${typeCode})`}`;\n })\n .join(',\\n');\n\n if (argEntries) {\n argumentsCode = `{\\n${argEntries}\\n }`;\n }\n }\n\n // Generate the TypeScript file content\n return `import { Type } from 'axiom/ai';\n\nexport default {\n name: '${prompt.name}',\n slug: '${prompt.slug}',\n description: '${prompt.description || ''}',\n messages: [${data.messages\n .map(\n (msg: any) => `\n {\n role: '${msg.role}',\n content: '${msg.content.replace(/'/g, \"\\\\'\")}',\n }`,\n )\n .join(',')}\n ],\n model: '${data.model || 'gpt-4'}',\n options: {\n${\n options\n ? Object.entries(options)\n .map(([key, value]) => ` ${key}: ${value}`)\n .join(',\\n')\n : ''\n}\n },\n arguments: ${argumentsCode},\n version: '${version.version}',\n promptId: '${prompt.promptId}',\n};\n`;\n}\n","import { Command } from 'commander';\nimport { generatePromptFileFromApiResponse } from '../transpiler';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nexport const loadPullCommand = (program: Command) => {\n const pull = new Command('pull')\n .description('Pull a version of an object')\n .argument(\n '<slug>',\n 'The object to pull, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--version <version>', 'The version to pull, default: latest', 'latest')\n .option('--output <path>', 'Output file path (optional, defaults to <slug>.prompt.ts)')\n .action(async (slug: string, options: { version: string; output?: string }) => {\n try {\n console.log(`Pulling prompt: ${slug} (version: ${options.version})`);\n\n const url = `${process.env.AXIOM_URL}/v1/prompts/${slug}`;\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n\n const tsContent = generatePromptFileFromApiResponse(apiResponse);\n\n const outputPath = options.output || `${slug}.prompt.ts`;\n const fullPath = path.resolve(outputPath);\n\n await fs.writeFile(fullPath, tsContent, 'utf-8');\n\n console.log(`Successfully generated prompt file: ${fullPath}`);\n console.log(`Prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`);\n console.log(`Version: ${apiResponse.version.version}`);\n } catch (error) {\n console.error('Failed to pull prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(pull);\n};\n","import { Command } from 'commander';\nimport { runVitest } from '../evals/run-vitest';\n\nexport const loadRunCommand = (program: Command) => {\n return program.addCommand(\n new Command('eval')\n .description('run evals locally')\n .argument('<path>', 'Path to an eval test file, should be in the form of *.eval.ts')\n .action(async (file: string) => {\n if (!process.env.AXIOM_URL || !process.env.AXIOM_TOKEN || !process.env.AXIOM_DATASET) {\n throw new Error('AXIOM_URL, AXIOM_TOKEN, and AXIOM_DATASET must be set');\n }\n await runVitest(file);\n }),\n );\n};\n","import { createVitest, registerConsoleShortcuts } from 'vitest/node';\nimport { AxiomReporter } from './reporter';\nimport { flush } from './instrument';\n\nexport const runVitest = async (file: string) => {\n const vi = await createVitest('test', {\n // root: process.cwd(),\n mode: 'test',\n include: [file ? file : '**/*.eval.ts'],\n reporters: ['verbose', new AxiomReporter()],\n environment: 'node',\n browser: undefined,\n });\n\n await vi.start();\n\n const dispose = registerConsoleShortcuts(vi, process.stdin, process.stdout);\n\n if (!vi.shouldKeepServer()) {\n dispose();\n await flush();\n await vi.close();\n process.exit(0);\n }\n\n await flush();\n};\n","import type { SerializedError } from 'vitest';\nimport type { Reporter, TestModule, TestRunEndReason, TestSuite } from 'vitest/node.js';\nimport type { TaskMeta } from 'vitest/index.cjs';\nimport { Table } from 'console-table-printer';\nimport type { EvalReport } from './eval';\n\n/**\n * Custom Vitest reporter for Axiom AI evaluations.\n *\n * This reporter collects evaluation results and scores from tests\n * and processes them for further analysis and reporting.\n *\n * @experimental This API is experimental and may change in future versions.\n */\nexport class AxiomReporter implements Reporter {\n onTestSuiteReady(_testSuite: TestSuite) {}\n\n onTestSuiteResult(testSuite: TestSuite) {\n const scoreboard = new Table({\n title: testSuite.name,\n });\n for (const test of testSuite.children.array()) {\n if (test.type !== 'test') continue;\n const testMeta = test.meta() as TaskMeta & { eval: EvalReport };\n\n if (!testMeta.eval) {\n return;\n }\n\n // build scores array\n const scores: { name: string; score: number }[] = [];\n for (const [_, s] of Object.entries(testMeta.eval.scores)) {\n const roundedScore = Math.round(s.score * 100) / 100; // Number(s.score).toFixed(2)\n scores.push({ name: s.name, score: roundedScore });\n }\n\n scoreboard.addRow({\n case: testMeta.eval.order,\n ...Object.fromEntries(scores.map((s) => [s.name, s.score])),\n });\n }\n\n scoreboard.printTable();\n }\n\n async onTestRunEnd(\n _testModules: ReadonlyArray<TestModule>,\n _errors: ReadonlyArray<SerializedError>,\n _reason: TestRunEndReason,\n ) {}\n}\n","import { BatchSpanProcessor, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { resourceFromAttributes } from '@opentelemetry/resources';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport { trace, type Context, type SpanOptions } from '@opentelemetry/api';\n\nconst collectorOptions = {\n url: process.env.AXIOM_URL\n ? `${process.env.AXIOM_URL}/v1/traces`\n : 'https://api.axiom.co/v1/traces', // Axiom API endpoint for trace data\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`, // Replace API_TOKEN with your actual API token\n 'X-Axiom-Dataset': process.env.AXIOM_DATASET || '', // Replace DATASET_NAME with your dataset\n },\n concurrencyLimit: 10, // an optional limit on pending requests\n};\n\n// export const consoleExporter = new ConsoleSpanExporter()\nexport const exporter = new OTLPTraceExporter(collectorOptions);\n\nconst processor = new BatchSpanProcessor(exporter, {\n maxQueueSize: 2048,\n maxExportBatchSize: 512,\n scheduledDelayMillis: 5000,\n exportTimeoutMillis: 30000,\n});\n\nconst provider = new NodeTracerProvider({\n resource: resourceFromAttributes({\n ['service.name']: 'axiom-ai',\n ['service.version']: __SDK_VERSION__,\n }),\n spanProcessors: [processor],\n});\n\nprovider.register();\n\n// Create a shared tracer instance\nconst tracer = trace.getTracer('axiom-ai', __SDK_VERSION__);\n\nexport const flush = async () => {\n await provider.forceFlush();\n};\n\nexport const startSpan = (name: string, opts: SpanOptions, context?: Context) => {\n return tracer.startSpan(name, opts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AAQ,IAAI,CAAC;AAO3B,IAAM,UAAU,IAAI,0BAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,kDAAkD,EAC9D,QAAQ,QAAe;AAE1B,gBAAgB,OAAO;AACvB,gBAAgB,OAAO;AACvB,eAAe,OAAO;AAEtB,QAAQ,MAAM;","names":["import_commander","import_node_path","os","path","fs","module","import_promises","readline","resolve","program","fs","import_commander","fs","path","program","import_commander","program","pkg"]}
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts","../src/commands/push.command.ts","../src/transpiler.ts","../src/commands/pull.command.ts","../src/commands/eval.command.ts","../src/evals/run-vitest.ts","../src/evals/reporter.ts","../src/evals/instrument.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// Load environment variables using @next/env\nimport pkg from '@next/env';\nconst { loadEnvConfig } = pkg;\n\n// Load .env files from the current working directory\nloadEnvConfig(process.cwd());\n\nimport { Command } from 'commander';\nimport { loadPushCommand } from './commands/push.command';\nimport { loadPullCommand } from './commands/pull.command';\nimport { loadRunCommand } from './commands/eval.command';\n\nconst program = new Command();\n\nprogram\n .name('axiom')\n .description(\"Axiom's CLI to manage your objects and run evals\")\n .version(__SDK_VERSION__);\n\nloadPushCommand(program);\nloadPullCommand(program);\nloadRunCommand(program);\n\nprogram.parse();\n","import { Command } from 'commander';\nimport {\n loadPromptModule,\n extractPromptFromModule,\n generatePromptFileFromApiResponse,\n} from '../transpiler';\nimport type { Prompt } from '../types';\nimport fs from 'node:fs/promises';\nimport readline from 'node:readline';\n\nasync function askConfirmation(message: string): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(`${message} (y/N): `, (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');\n });\n });\n}\n\nexport const loadPushCommand = (program: Command) => {\n const push = new Command('push')\n .description('Push a new version of an object')\n .argument(\n '<object>',\n 'The object to push, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--prod', 'Adds the production tag to the prompt')\n .option('--yes', 'Automatically confirm overwriting the file with server response')\n .action(async (filePath: string, options: { yes?: boolean; prod?: boolean }) => {\n let content: Prompt | null = null;\n if (!filePath.endsWith('.prompt.ts')) {\n console.error('Prompt files must end with .prompt.ts');\n process.exit(1);\n }\n\n try {\n const moduleContent = await loadPromptModule(filePath);\n const promptData = extractPromptFromModule(moduleContent, filePath);\n\n content = promptData;\n\n console.log(`Transpiled prompt: ${promptData.name} (${promptData.slug})`);\n } catch (error) {\n console.error('Failed to transpile prompt file:', error);\n process.exit(1);\n }\n\n if (!content) {\n console.error('No content found');\n process.exit(1);\n }\n\n let shouldProceed = options.yes;\n if (!shouldProceed) {\n shouldProceed = await askConfirmation(\n `This will push \"${content.name}\" to Axiom and overwrite ${filePath}, are you sure you want to continue?`,\n );\n }\n\n if (!shouldProceed) {\n console.log('Push operation cancelled.');\n process.exit(0);\n }\n\n try {\n const response = await fetch(`${process.env.AXIOM_URL}/v1/prompts`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n body: JSON.stringify({\n ...content,\n tags: options.yes ? ['production'] : [],\n }),\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n console.log(\n `Successfully pushed prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`,\n );\n console.log(`Version: ${apiResponse.version.version}`);\n\n const updatedTsContent = generatePromptFileFromApiResponse(apiResponse);\n\n await fs.writeFile(filePath, updatedTsContent, 'utf-8');\n\n console.log(`Successfully updated ${filePath}`);\n } catch (error) {\n console.error('Failed to push prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(push);\n};\n","import { build } from 'esbuild';\nimport os from 'node:os';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { basename } from 'node:path';\nimport type { Prompt } from './types';\n\nexport async function loadPromptModule(filePath: string) {\n const result = await build({\n entryPoints: [filePath],\n bundle: true,\n write: false,\n platform: 'node',\n format: 'esm',\n target: ['node18'],\n sourcemap: false,\n external: [\n // Only Node.js built-ins should be external\n 'fs',\n 'fs/promises',\n 'node:fs',\n 'node:fs/promises',\n 'readline',\n 'node:readline',\n 'path',\n 'node:path',\n 'os',\n 'node:os',\n 'url',\n 'node:url',\n 'util',\n 'node:util',\n 'crypto',\n 'node:crypto',\n 'events',\n 'node:events',\n 'stream',\n 'node:stream',\n 'buffer',\n 'node:buffer',\n 'process',\n 'node:process',\n ],\n });\n\n const code = result.outputFiles[0].text;\n\n // Create a unique temporary file\n const tempDir = os.tmpdir();\n const tempFileName = `axiom-ai-prompt-${Date.now()}-${Math.random().toString(36).substring(2)}.mjs`;\n const tempFilePath = path.join(tempDir, tempFileName);\n\n try {\n // Write the bundled code to temporary file\n await fs.writeFile(tempFilePath, code, 'utf-8');\n\n // Dynamically import the temporary module\n const moduleUrl = `file://${tempFilePath}`;\n const module = await import(moduleUrl);\n\n return module.default || module;\n } finally {\n // Clean up the temporary file\n try {\n await fs.unlink(tempFilePath);\n } catch (error) {\n // Ignore cleanup errors - temp files will be cleaned up by OS eventually\n console.warn(`Failed to clean up temporary file ${tempFilePath}:`, error);\n }\n }\n}\n\n/**\n * Convert TypeBox arguments to JSON Schema format expected by the API\n */\nfunction convertTypeBoxArgumentsToJsonSchema(arguments_: Record<string, any>): any {\n if (!arguments_ || typeof arguments_ !== 'object') {\n return {\n type: 'object',\n properties: {},\n required: [],\n additionalProperties: false,\n };\n }\n\n const properties: Record<string, any> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(arguments_)) {\n if (value && typeof value === 'object' && value.type) {\n // This is a TypeBox schema object that has been serialized\n properties[key] = {\n type: value.type,\n ...(value.description && { description: value.description }),\n ...(value.enum && { enum: value.enum }),\n ...(value.items && { items: value.items }),\n ...(value.properties && { properties: value.properties }),\n ...(value.required && { required: value.required }),\n };\n\n // For now, treat all arguments as required (this matches the existing behavior)\n // In the future, we could detect Type.Optional() usage\n required.push(key);\n }\n }\n\n return {\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n };\n}\n\nexport function extractPromptFromModule(moduleContent: any, filePath: string): Prompt {\n // Generate ID from file path if not provided\n const fileBaseName = basename(filePath, '.ts'); // Remove .ts extension\n const defaultId = fileBaseName.toLowerCase().replace(/[^a-z0-9]/g, '-');\n\n // Convert TypeBox arguments to JSON Schema format\n const convertedArguments = convertTypeBoxArgumentsToJsonSchema(moduleContent.arguments);\n\n // Extract and validate required fields from the module content\n const prompt: Prompt = {\n name: moduleContent.name || 'Untitled Prompt',\n slug: moduleContent.slug || defaultId,\n messages: moduleContent.messages || [],\n model: moduleContent.model,\n options: moduleContent.options,\n arguments: convertedArguments,\n id: moduleContent.id || defaultId,\n version: moduleContent.version || '1.0.0',\n // Optional fields from API response\n ...(moduleContent.promptId && { promptId: moduleContent.promptId }),\n ...(moduleContent.description && { description: moduleContent.description }),\n };\n\n // Validate required fields\n if (!prompt.name) {\n throw new Error('Prompt must have a name');\n }\n if (!prompt.slug) {\n throw new Error('Prompt must have a slug');\n }\n if (!Array.isArray(prompt.messages)) {\n throw new Error('Prompt messages must be an array');\n }\n\n if (!prompt.model) {\n throw new Error('Prompt must have a model');\n }\n\n return prompt;\n}\n\n/**\n * Transform JSON Schema to TypeBox/Template validator format\n */\nexport function transformJsonSchemaToTypeBox(schema: any): string {\n if (schema.type === 'string') {\n if (schema.enum && Array.isArray(schema.enum)) {\n // Handle enum as Union of Literals\n const literals = schema.enum.map((value: string) => `Type.Literal('${value}')`).join(', ');\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Union([${literals}]${options})`;\n } else {\n // Regular string\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.String(${options})`;\n }\n }\n\n if (schema.type === 'number' || schema.type === 'integer') {\n const typeMethod = schema.type === 'integer' ? 'Integer' : 'Number';\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.${typeMethod}(${options})`;\n }\n\n if (schema.type === 'boolean') {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Boolean(${options})`;\n }\n\n if (schema.type === 'array') {\n const itemsType = schema.items ? transformJsonSchemaToTypeBox(schema.items) : 'Type.String()';\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Array(${itemsType}${options})`;\n }\n\n if (schema.type === 'object') {\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(([key, value]: [string, any]) => {\n const isRequired = schema.required && schema.required.includes(key);\n const propType = transformJsonSchemaToTypeBox(value);\n return ` ${key}: ${isRequired ? propType : `Type.Optional(${propType})`}`;\n })\n .join(',\\n');\n\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Object({\\n${props}\\n }${options})`;\n } else {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Object({}${options ? `, ${options}` : ''})`;\n }\n }\n\n // Fallback for unknown types\n return 'Type.String()';\n}\n\n/**\n * Generate TypeScript prompt file content from API response\n */\nexport function generatePromptFileFromApiResponse(apiResponse: any): string {\n const { prompt, version } = apiResponse;\n const { data, options } = version;\n\n // Transform arguments from JSON Schema to TypeBox format\n let argumentsCode = '{}';\n if (data.arguments && data.arguments.properties) {\n const argEntries = Object.entries(data.arguments.properties)\n .map(([key, schema]: [string, any]) => {\n const isRequired = data.arguments.required && data.arguments.required.includes(key);\n const typeCode = transformJsonSchemaToTypeBox(schema);\n return ` ${key}: ${isRequired ? typeCode : `Type.Optional(${typeCode})`}`;\n })\n .join(',\\n');\n\n if (argEntries) {\n argumentsCode = `{\\n${argEntries}\\n }`;\n }\n }\n\n // Generate the TypeScript file content\n return `import { Type } from 'axiom/ai';\n\nexport default {\n name: '${prompt.name}',\n slug: '${prompt.slug}',\n description: '${prompt.description || ''}',\n messages: [${data.messages\n .map(\n (msg: any) => `\n {\n role: '${msg.role}',\n content: '${msg.content.replace(/'/g, \"\\\\'\")}',\n }`,\n )\n .join(',')}\n ],\n model: '${data.model || 'gpt-4'}',\n options: {\n${\n options\n ? Object.entries(options)\n .map(([key, value]) => ` ${key}: ${value}`)\n .join(',\\n')\n : ''\n}\n },\n arguments: ${argumentsCode},\n version: '${version.version}',\n promptId: '${prompt.promptId}',\n};\n`;\n}\n","import { Command } from 'commander';\nimport { generatePromptFileFromApiResponse } from '../transpiler';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nexport const loadPullCommand = (program: Command) => {\n const pull = new Command('pull')\n .description('Pull a version of an object')\n .argument(\n '<slug>',\n 'The object to pull, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--version <version>', 'The version to pull, default: latest', 'latest')\n .option('--output <path>', 'Output file path (optional, defaults to <slug>.prompt.ts)')\n .action(async (slug: string, options: { version: string; output?: string }) => {\n try {\n console.log(`Pulling prompt: ${slug} (version: ${options.version})`);\n\n const url = `${process.env.AXIOM_URL}/v1/prompts/${slug}`;\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n\n const tsContent = generatePromptFileFromApiResponse(apiResponse);\n\n const outputPath = options.output || `${slug}.prompt.ts`;\n const fullPath = path.resolve(outputPath);\n\n await fs.writeFile(fullPath, tsContent, 'utf-8');\n\n console.log(`Successfully generated prompt file: ${fullPath}`);\n console.log(`Prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`);\n console.log(`Version: ${apiResponse.version.version}`);\n } catch (error) {\n console.error('Failed to pull prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(pull);\n};\n","import { Command } from 'commander';\nimport { runVitest } from '../evals/run-vitest';\n\nexport const loadRunCommand = (program: Command) => {\n return program.addCommand(\n new Command('eval')\n .description('run evals locally')\n .argument('<path>', 'Path to an eval test file, should be in the form of *.eval.ts')\n .action(async (file: string) => {\n if (!process.env.AXIOM_URL || !process.env.AXIOM_TOKEN || !process.env.AXIOM_DATASET) {\n throw new Error('AXIOM_URL, AXIOM_TOKEN, and AXIOM_DATASET must be set');\n }\n await runVitest(file);\n }),\n );\n};\n","import { createVitest, registerConsoleShortcuts } from 'vitest/node';\nimport { AxiomReporter } from './reporter';\nimport { flush } from './instrument';\n\nexport const runVitest = async (file: string) => {\n const vi = await createVitest('test', {\n // root: process.cwd(),\n mode: 'test',\n include: [file ? file : '**/*.eval.ts'],\n reporters: ['verbose', new AxiomReporter()],\n environment: 'node',\n browser: undefined,\n });\n\n await vi.start();\n\n const dispose = registerConsoleShortcuts(vi, process.stdin, process.stdout);\n\n if (!vi.shouldKeepServer()) {\n dispose();\n await flush();\n await vi.close();\n process.exit(0);\n }\n\n await flush();\n};\n","import type { SerializedError } from 'vitest';\nimport type { Reporter, TestModule, TestRunEndReason, TestSuite } from 'vitest/node.js';\nimport type { TaskMeta } from 'vitest/index.cjs';\nimport { Table } from 'console-table-printer';\nimport type { EvalReport } from './eval.types';\n\nconst prRed = (s: string): string => `\\x1b[91m ${s}\\x1b[00m`;\n\n/**\n * Custom Vitest reporter for Axiom AI evaluations.\n *\n * This reporter collects evaluation results and scores from tests\n * and processes them for further analysis and reporting.\n *\n * @experimental This API is experimental and may change in future versions.\n */\nexport class AxiomReporter implements Reporter {\n onTestSuiteReady(_testSuite: TestSuite) {}\n\n onTestSuiteResult(testSuite: TestSuite) {\n const scoreboard = new Table({\n title: testSuite.name,\n });\n for (const test of testSuite.children.array()) {\n if (test.type !== 'test') continue;\n const testMeta = test.meta() as TaskMeta & { eval: EvalReport };\n\n if (!testMeta.eval) {\n return;\n }\n\n // round scores\n const scores = Object.keys(testMeta.eval.scores).map((k) => {\n const v = testMeta.eval.scores[k].score ? testMeta.eval.scores[k].score : 0;\n const scoreValue = Number(v * 100).toFixed(2);\n\n // if score is lower then threshold then print it in red\n const score =\n testMeta.eval.threshold && v < testMeta.eval.threshold\n ? prRed(scoreValue + '%')\n : scoreValue + '%';\n\n return [k, score];\n });\n\n scoreboard.addRow({\n case: testMeta.eval.index.toString(),\n ...Object.fromEntries(scores),\n });\n }\n\n scoreboard.printTable();\n }\n\n async onTestRunEnd(\n _testModules: ReadonlyArray<TestModule>,\n _errors: ReadonlyArray<SerializedError>,\n _reason: TestRunEndReason,\n ) {}\n}\n","import { BatchSpanProcessor, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { resourceFromAttributes } from '@opentelemetry/resources';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport { trace, type Context, type SpanOptions } from '@opentelemetry/api';\n\nconst collectorOptions = {\n url: process.env.AXIOM_URL\n ? `${process.env.AXIOM_URL}/v1/traces`\n : 'https://api.axiom.co/v1/traces', // Axiom API endpoint for trace data\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`, // Replace API_TOKEN with your actual API token\n 'X-Axiom-Dataset': process.env.AXIOM_DATASET || '', // Replace DATASET_NAME with your dataset\n },\n concurrencyLimit: 10, // an optional limit on pending requests\n};\n\n// export const consoleExporter = new ConsoleSpanExporter()\nexport const exporter = new OTLPTraceExporter(collectorOptions);\n\nconst processor = new BatchSpanProcessor(exporter, {\n maxQueueSize: 2048,\n maxExportBatchSize: 512,\n scheduledDelayMillis: 5000,\n exportTimeoutMillis: 30000,\n});\n\nconst provider = new NodeTracerProvider({\n resource: resourceFromAttributes({\n ['service.name']: 'axiom-ai',\n ['service.version']: __SDK_VERSION__,\n }),\n spanProcessors: [processor],\n});\n\nprovider.register();\n\n// Create a shared tracer instance\nconst tracer = trace.getTracer('axiom-ai', __SDK_VERSION__);\n\nexport const flush = async () => {\n await provider.forceFlush();\n};\n\nexport const startSpan = (name: string, opts: SpanOptions, context?: Context) => {\n return tracer.startSpan(name, opts, context);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,iBAAgB;AAMhB,IAAAA,oBAAwB;;;ACTxB,uBAAwB;;;ACAxB,qBAAsB;AACtB,qBAAe;AACf,sBAAe;AACf,uBAAiB;AACjB,IAAAC,oBAAyB;AAGzB,eAAsB,iBAAiB,UAAkB;AACvD,QAAM,SAAS,UAAM,sBAAM;AAAA,IACzB,aAAa,CAAC,QAAQ;AAAA,IACtB,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ,CAAC,QAAQ;AAAA,IACjB,WAAW;AAAA,IACX,UAAU;AAAA;AAAA,MAER;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,OAAO,OAAO,YAAY,CAAC,EAAE;AAGnC,QAAM,UAAU,eAAAC,QAAG,OAAO;AAC1B,QAAM,eAAe,mBAAmB,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC;AAC7F,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AM;AACf,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,MAAM;AACd;;;ADvBO,IAAM,iBAAiB,CAACC,aAAqB;AAClD,SAAOA,SAAQ;AAAA,IACb,IAAI,0BAAQ,MAAM,EACf,YAAY,mBAAmB,EAC/B,SAAS,UAAU,+DAA+D,EAClF,OAAO,OAAO,SAAiB;AAC9B,UAAI,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,IAAI,eAAe,CAAC,QAAQ,IAAI,eAAe;AACpF,cAAM,IAAI,MAAM,uDAAuD;AAAA,MACzE;AACA,YAAM,UAAU,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AACF;;;AJXA,IAAM,EAAE,cAAc,IAAI,WAAAC;AAG1B,cAAc,QAAQ,IAAI,CAAC;AAO3B,IAAM,UAAU,IAAI,0BAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,kDAAkD,EAC9D,QAAQ,QAAe;AAE1B,gBAAgB,OAAO;AACvB,gBAAgB,OAAO;AACvB,eAAe,OAAO;AAEtB,QAAQ,MAAM;","names":["import_commander","import_node_path","os","path","fs","module","import_promises","readline","resolve","program","fs","import_commander","fs","path","program","import_commander","program","pkg"]}
|
package/dist/bin.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
AxiomReporter,
|
|
3
4
|
flush
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
AxiomReporter
|
|
7
|
-
} from "./chunk-NR7XRR3Z.js";
|
|
5
|
+
} from "./chunk-CQCLS3XJ.js";
|
|
8
6
|
import "./chunk-KEXKKQVW.js";
|
|
9
7
|
|
|
10
8
|
// src/bin.ts
|
|
@@ -402,7 +400,7 @@ var loadRunCommand = (program2) => {
|
|
|
402
400
|
var { loadEnvConfig } = pkg;
|
|
403
401
|
loadEnvConfig(process.cwd());
|
|
404
402
|
var program = new Command4();
|
|
405
|
-
program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.11.
|
|
403
|
+
program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.11.2");
|
|
406
404
|
loadPushCommand(program);
|
|
407
405
|
loadPullCommand(program);
|
|
408
406
|
loadRunCommand(program);
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bin.ts","../src/commands/push.command.ts","../src/transpiler.ts","../src/commands/pull.command.ts","../src/commands/eval.command.ts","../src/evals/run-vitest.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// Load environment variables using @next/env\nimport pkg from '@next/env';\nconst { loadEnvConfig } = pkg;\n\n// Load .env files from the current working directory\nloadEnvConfig(process.cwd());\n\nimport { Command } from 'commander';\nimport { loadPushCommand } from './commands/push.command';\nimport { loadPullCommand } from './commands/pull.command';\nimport { loadRunCommand } from './commands/eval.command';\n\nconst program = new Command();\n\nprogram\n .name('axiom')\n .description(\"Axiom's CLI to manage your objects and run evals\")\n .version(__SDK_VERSION__);\n\nloadPushCommand(program);\nloadPullCommand(program);\nloadRunCommand(program);\n\nprogram.parse();\n","import { Command } from 'commander';\nimport {\n loadPromptModule,\n extractPromptFromModule,\n generatePromptFileFromApiResponse,\n} from '../transpiler';\nimport type { Prompt } from '../types';\nimport fs from 'node:fs/promises';\nimport readline from 'node:readline';\n\nasync function askConfirmation(message: string): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(`${message} (y/N): `, (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');\n });\n });\n}\n\nexport const loadPushCommand = (program: Command) => {\n const push = new Command('push')\n .description('Push a new version of an object')\n .argument(\n '<object>',\n 'The object to push, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--prod', 'Adds the production tag to the prompt')\n .option('--yes', 'Automatically confirm overwriting the file with server response')\n .action(async (filePath: string, options: { yes?: boolean; prod?: boolean }) => {\n let content: Prompt | null = null;\n if (!filePath.endsWith('.prompt.ts')) {\n console.error('Prompt files must end with .prompt.ts');\n process.exit(1);\n }\n\n try {\n const moduleContent = await loadPromptModule(filePath);\n const promptData = extractPromptFromModule(moduleContent, filePath);\n\n content = promptData;\n\n console.log(`Transpiled prompt: ${promptData.name} (${promptData.slug})`);\n } catch (error) {\n console.error('Failed to transpile prompt file:', error);\n process.exit(1);\n }\n\n if (!content) {\n console.error('No content found');\n process.exit(1);\n }\n\n let shouldProceed = options.yes;\n if (!shouldProceed) {\n shouldProceed = await askConfirmation(\n `This will push \"${content.name}\" to Axiom and overwrite ${filePath}, are you sure you want to continue?`,\n );\n }\n\n if (!shouldProceed) {\n console.log('Push operation cancelled.');\n process.exit(0);\n }\n\n try {\n const response = await fetch(`${process.env.AXIOM_URL}/v1/prompts`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n body: JSON.stringify({\n ...content,\n tags: options.yes ? ['production'] : [],\n }),\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n console.log(\n `Successfully pushed prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`,\n );\n console.log(`Version: ${apiResponse.version.version}`);\n\n const updatedTsContent = generatePromptFileFromApiResponse(apiResponse);\n\n await fs.writeFile(filePath, updatedTsContent, 'utf-8');\n\n console.log(`Successfully updated ${filePath}`);\n } catch (error) {\n console.error('Failed to push prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(push);\n};\n","import { build } from 'esbuild';\nimport os from 'node:os';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { basename } from 'node:path';\nimport type { Prompt } from './types';\n\nexport async function loadPromptModule(filePath: string) {\n const result = await build({\n entryPoints: [filePath],\n bundle: true,\n write: false,\n platform: 'node',\n format: 'esm',\n target: ['node18'],\n sourcemap: false,\n external: [\n // Only Node.js built-ins should be external\n 'fs',\n 'fs/promises',\n 'node:fs',\n 'node:fs/promises',\n 'readline',\n 'node:readline',\n 'path',\n 'node:path',\n 'os',\n 'node:os',\n 'url',\n 'node:url',\n 'util',\n 'node:util',\n 'crypto',\n 'node:crypto',\n 'events',\n 'node:events',\n 'stream',\n 'node:stream',\n 'buffer',\n 'node:buffer',\n 'process',\n 'node:process',\n ],\n });\n\n const code = result.outputFiles[0].text;\n\n // Create a unique temporary file\n const tempDir = os.tmpdir();\n const tempFileName = `axiom-ai-prompt-${Date.now()}-${Math.random().toString(36).substring(2)}.mjs`;\n const tempFilePath = path.join(tempDir, tempFileName);\n\n try {\n // Write the bundled code to temporary file\n await fs.writeFile(tempFilePath, code, 'utf-8');\n\n // Dynamically import the temporary module\n const moduleUrl = `file://${tempFilePath}`;\n const module = await import(moduleUrl);\n\n return module.default || module;\n } finally {\n // Clean up the temporary file\n try {\n await fs.unlink(tempFilePath);\n } catch (error) {\n // Ignore cleanup errors - temp files will be cleaned up by OS eventually\n console.warn(`Failed to clean up temporary file ${tempFilePath}:`, error);\n }\n }\n}\n\n/**\n * Convert TypeBox arguments to JSON Schema format expected by the API\n */\nfunction convertTypeBoxArgumentsToJsonSchema(arguments_: Record<string, any>): any {\n if (!arguments_ || typeof arguments_ !== 'object') {\n return {\n type: 'object',\n properties: {},\n required: [],\n additionalProperties: false,\n };\n }\n\n const properties: Record<string, any> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(arguments_)) {\n if (value && typeof value === 'object' && value.type) {\n // This is a TypeBox schema object that has been serialized\n properties[key] = {\n type: value.type,\n ...(value.description && { description: value.description }),\n ...(value.enum && { enum: value.enum }),\n ...(value.items && { items: value.items }),\n ...(value.properties && { properties: value.properties }),\n ...(value.required && { required: value.required }),\n };\n\n // For now, treat all arguments as required (this matches the existing behavior)\n // In the future, we could detect Type.Optional() usage\n required.push(key);\n }\n }\n\n return {\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n };\n}\n\nexport function extractPromptFromModule(moduleContent: any, filePath: string): Prompt {\n // Generate ID from file path if not provided\n const fileBaseName = basename(filePath, '.ts'); // Remove .ts extension\n const defaultId = fileBaseName.toLowerCase().replace(/[^a-z0-9]/g, '-');\n\n // Convert TypeBox arguments to JSON Schema format\n const convertedArguments = convertTypeBoxArgumentsToJsonSchema(moduleContent.arguments);\n\n // Extract and validate required fields from the module content\n const prompt: Prompt = {\n name: moduleContent.name || 'Untitled Prompt',\n slug: moduleContent.slug || defaultId,\n messages: moduleContent.messages || [],\n model: moduleContent.model,\n options: moduleContent.options,\n arguments: convertedArguments,\n id: moduleContent.id || defaultId,\n version: moduleContent.version || '1.0.0',\n // Optional fields from API response\n ...(moduleContent.promptId && { promptId: moduleContent.promptId }),\n ...(moduleContent.description && { description: moduleContent.description }),\n };\n\n // Validate required fields\n if (!prompt.name) {\n throw new Error('Prompt must have a name');\n }\n if (!prompt.slug) {\n throw new Error('Prompt must have a slug');\n }\n if (!Array.isArray(prompt.messages)) {\n throw new Error('Prompt messages must be an array');\n }\n\n if (!prompt.model) {\n throw new Error('Prompt must have a model');\n }\n\n return prompt;\n}\n\n/**\n * Transform JSON Schema to TypeBox/Template validator format\n */\nexport function transformJsonSchemaToTypeBox(schema: any): string {\n if (schema.type === 'string') {\n if (schema.enum && Array.isArray(schema.enum)) {\n // Handle enum as Union of Literals\n const literals = schema.enum.map((value: string) => `Type.Literal('${value}')`).join(', ');\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Union([${literals}]${options})`;\n } else {\n // Regular string\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.String(${options})`;\n }\n }\n\n if (schema.type === 'number' || schema.type === 'integer') {\n const typeMethod = schema.type === 'integer' ? 'Integer' : 'Number';\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.${typeMethod}(${options})`;\n }\n\n if (schema.type === 'boolean') {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Boolean(${options})`;\n }\n\n if (schema.type === 'array') {\n const itemsType = schema.items ? transformJsonSchemaToTypeBox(schema.items) : 'Type.String()';\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Array(${itemsType}${options})`;\n }\n\n if (schema.type === 'object') {\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(([key, value]: [string, any]) => {\n const isRequired = schema.required && schema.required.includes(key);\n const propType = transformJsonSchemaToTypeBox(value);\n return ` ${key}: ${isRequired ? propType : `Type.Optional(${propType})`}`;\n })\n .join(',\\n');\n\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Object({\\n${props}\\n }${options})`;\n } else {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Object({}${options ? `, ${options}` : ''})`;\n }\n }\n\n // Fallback for unknown types\n return 'Type.String()';\n}\n\n/**\n * Generate TypeScript prompt file content from API response\n */\nexport function generatePromptFileFromApiResponse(apiResponse: any): string {\n const { prompt, version } = apiResponse;\n const { data, options } = version;\n\n // Transform arguments from JSON Schema to TypeBox format\n let argumentsCode = '{}';\n if (data.arguments && data.arguments.properties) {\n const argEntries = Object.entries(data.arguments.properties)\n .map(([key, schema]: [string, any]) => {\n const isRequired = data.arguments.required && data.arguments.required.includes(key);\n const typeCode = transformJsonSchemaToTypeBox(schema);\n return ` ${key}: ${isRequired ? typeCode : `Type.Optional(${typeCode})`}`;\n })\n .join(',\\n');\n\n if (argEntries) {\n argumentsCode = `{\\n${argEntries}\\n }`;\n }\n }\n\n // Generate the TypeScript file content\n return `import { Type } from 'axiom/ai';\n\nexport default {\n name: '${prompt.name}',\n slug: '${prompt.slug}',\n description: '${prompt.description || ''}',\n messages: [${data.messages\n .map(\n (msg: any) => `\n {\n role: '${msg.role}',\n content: '${msg.content.replace(/'/g, \"\\\\'\")}',\n }`,\n )\n .join(',')}\n ],\n model: '${data.model || 'gpt-4'}',\n options: {\n${\n options\n ? Object.entries(options)\n .map(([key, value]) => ` ${key}: ${value}`)\n .join(',\\n')\n : ''\n}\n },\n arguments: ${argumentsCode},\n version: '${version.version}',\n promptId: '${prompt.promptId}',\n};\n`;\n}\n","import { Command } from 'commander';\nimport { generatePromptFileFromApiResponse } from '../transpiler';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nexport const loadPullCommand = (program: Command) => {\n const pull = new Command('pull')\n .description('Pull a version of an object')\n .argument(\n '<slug>',\n 'The object to pull, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--version <version>', 'The version to pull, default: latest', 'latest')\n .option('--output <path>', 'Output file path (optional, defaults to <slug>.prompt.ts)')\n .action(async (slug: string, options: { version: string; output?: string }) => {\n try {\n console.log(`Pulling prompt: ${slug} (version: ${options.version})`);\n\n const url = `${process.env.AXIOM_URL}/v1/prompts/${slug}`;\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n\n const tsContent = generatePromptFileFromApiResponse(apiResponse);\n\n const outputPath = options.output || `${slug}.prompt.ts`;\n const fullPath = path.resolve(outputPath);\n\n await fs.writeFile(fullPath, tsContent, 'utf-8');\n\n console.log(`Successfully generated prompt file: ${fullPath}`);\n console.log(`Prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`);\n console.log(`Version: ${apiResponse.version.version}`);\n } catch (error) {\n console.error('Failed to pull prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(pull);\n};\n","import { Command } from 'commander';\nimport { runVitest } from '../evals/run-vitest';\n\nexport const loadRunCommand = (program: Command) => {\n return program.addCommand(\n new Command('eval')\n .description('run evals locally')\n .argument('<path>', 'Path to an eval test file, should be in the form of *.eval.ts')\n .action(async (file: string) => {\n if (!process.env.AXIOM_URL || !process.env.AXIOM_TOKEN || !process.env.AXIOM_DATASET) {\n throw new Error('AXIOM_URL, AXIOM_TOKEN, and AXIOM_DATASET must be set');\n }\n await runVitest(file);\n }),\n );\n};\n","import { createVitest, registerConsoleShortcuts } from 'vitest/node';\nimport { AxiomReporter } from './reporter';\nimport { flush } from './instrument';\n\nexport const runVitest = async (file: string) => {\n const vi = await createVitest('test', {\n // root: process.cwd(),\n mode: 'test',\n include: [file ? file : '**/*.eval.ts'],\n reporters: ['verbose', new AxiomReporter()],\n environment: 'node',\n browser: undefined,\n });\n\n await vi.start();\n\n const dispose = registerConsoleShortcuts(vi, process.stdin, process.stdout);\n\n if (!vi.shouldKeepServer()) {\n dispose();\n await flush();\n await vi.close();\n process.exit(0);\n }\n\n await flush();\n};\n"],"mappings":";;;;;;;;;;AAGA,OAAO,SAAS;AAMhB,SAAS,WAAAA,gBAAe;;;ACTxB,SAAS,eAAe;;;ACAxB,SAAS,aAAa;AACtB,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AAGzB,eAAsB,iBAAiB,UAAkB;AACvD,QAAM,SAAS,MAAM,MAAM;AAAA,IACzB,aAAa,CAAC,QAAQ;AAAA,IACtB,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ,CAAC,QAAQ;AAAA,IACjB,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AM,MAAM;AACd;;;ADvBO,IAAM,iBAAiB,CAACC,aAAqB;AAClD,SAAOA,SAAQ;AAAA,IACb,IAAIC,SAAQ,MAAM,EACf,YAAY,mBAAmB,EAC/B,SAAS,UAAU,+DAA+D,EAClF,OAAO,OAAO,SAAiB;AAC9B,UAAI,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,IAAI,eAAe,CAAC,QAAQ,IAAI,eAAe;AACpF,cAAM,IAAI,MAAM,uDAAuD;AAAA,MACzE;AACA,YAAM,UAAU,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AACF;;;AJXA,IAAM,EAAE,cAAc,IAAI;AAG1B,cAAc,QAAQ,IAAI,CAAC;AAO3B,IAAM,UAAU,IAAIC,SAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,kDAAkD,EAC9D,QAAQ,QAAe;AAE1B,gBAAgB,OAAO;AACvB,gBAAgB,OAAO;AACvB,eAAe,OAAO;AAEtB,QAAQ,MAAM;","names":["Command","fs","resolve","program","Command","fs","path","program","Command","Command","program","Command","Command"]}
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts","../src/commands/push.command.ts","../src/transpiler.ts","../src/commands/pull.command.ts","../src/commands/eval.command.ts","../src/evals/run-vitest.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// Load environment variables using @next/env\nimport pkg from '@next/env';\nconst { loadEnvConfig } = pkg;\n\n// Load .env files from the current working directory\nloadEnvConfig(process.cwd());\n\nimport { Command } from 'commander';\nimport { loadPushCommand } from './commands/push.command';\nimport { loadPullCommand } from './commands/pull.command';\nimport { loadRunCommand } from './commands/eval.command';\n\nconst program = new Command();\n\nprogram\n .name('axiom')\n .description(\"Axiom's CLI to manage your objects and run evals\")\n .version(__SDK_VERSION__);\n\nloadPushCommand(program);\nloadPullCommand(program);\nloadRunCommand(program);\n\nprogram.parse();\n","import { Command } from 'commander';\nimport {\n loadPromptModule,\n extractPromptFromModule,\n generatePromptFileFromApiResponse,\n} from '../transpiler';\nimport type { Prompt } from '../types';\nimport fs from 'node:fs/promises';\nimport readline from 'node:readline';\n\nasync function askConfirmation(message: string): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(`${message} (y/N): `, (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');\n });\n });\n}\n\nexport const loadPushCommand = (program: Command) => {\n const push = new Command('push')\n .description('Push a new version of an object')\n .argument(\n '<object>',\n 'The object to push, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--prod', 'Adds the production tag to the prompt')\n .option('--yes', 'Automatically confirm overwriting the file with server response')\n .action(async (filePath: string, options: { yes?: boolean; prod?: boolean }) => {\n let content: Prompt | null = null;\n if (!filePath.endsWith('.prompt.ts')) {\n console.error('Prompt files must end with .prompt.ts');\n process.exit(1);\n }\n\n try {\n const moduleContent = await loadPromptModule(filePath);\n const promptData = extractPromptFromModule(moduleContent, filePath);\n\n content = promptData;\n\n console.log(`Transpiled prompt: ${promptData.name} (${promptData.slug})`);\n } catch (error) {\n console.error('Failed to transpile prompt file:', error);\n process.exit(1);\n }\n\n if (!content) {\n console.error('No content found');\n process.exit(1);\n }\n\n let shouldProceed = options.yes;\n if (!shouldProceed) {\n shouldProceed = await askConfirmation(\n `This will push \"${content.name}\" to Axiom and overwrite ${filePath}, are you sure you want to continue?`,\n );\n }\n\n if (!shouldProceed) {\n console.log('Push operation cancelled.');\n process.exit(0);\n }\n\n try {\n const response = await fetch(`${process.env.AXIOM_URL}/v1/prompts`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n body: JSON.stringify({\n ...content,\n tags: options.yes ? ['production'] : [],\n }),\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n console.log(\n `Successfully pushed prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`,\n );\n console.log(`Version: ${apiResponse.version.version}`);\n\n const updatedTsContent = generatePromptFileFromApiResponse(apiResponse);\n\n await fs.writeFile(filePath, updatedTsContent, 'utf-8');\n\n console.log(`Successfully updated ${filePath}`);\n } catch (error) {\n console.error('Failed to push prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(push);\n};\n","import { build } from 'esbuild';\nimport os from 'node:os';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { basename } from 'node:path';\nimport type { Prompt } from './types';\n\nexport async function loadPromptModule(filePath: string) {\n const result = await build({\n entryPoints: [filePath],\n bundle: true,\n write: false,\n platform: 'node',\n format: 'esm',\n target: ['node18'],\n sourcemap: false,\n external: [\n // Only Node.js built-ins should be external\n 'fs',\n 'fs/promises',\n 'node:fs',\n 'node:fs/promises',\n 'readline',\n 'node:readline',\n 'path',\n 'node:path',\n 'os',\n 'node:os',\n 'url',\n 'node:url',\n 'util',\n 'node:util',\n 'crypto',\n 'node:crypto',\n 'events',\n 'node:events',\n 'stream',\n 'node:stream',\n 'buffer',\n 'node:buffer',\n 'process',\n 'node:process',\n ],\n });\n\n const code = result.outputFiles[0].text;\n\n // Create a unique temporary file\n const tempDir = os.tmpdir();\n const tempFileName = `axiom-ai-prompt-${Date.now()}-${Math.random().toString(36).substring(2)}.mjs`;\n const tempFilePath = path.join(tempDir, tempFileName);\n\n try {\n // Write the bundled code to temporary file\n await fs.writeFile(tempFilePath, code, 'utf-8');\n\n // Dynamically import the temporary module\n const moduleUrl = `file://${tempFilePath}`;\n const module = await import(moduleUrl);\n\n return module.default || module;\n } finally {\n // Clean up the temporary file\n try {\n await fs.unlink(tempFilePath);\n } catch (error) {\n // Ignore cleanup errors - temp files will be cleaned up by OS eventually\n console.warn(`Failed to clean up temporary file ${tempFilePath}:`, error);\n }\n }\n}\n\n/**\n * Convert TypeBox arguments to JSON Schema format expected by the API\n */\nfunction convertTypeBoxArgumentsToJsonSchema(arguments_: Record<string, any>): any {\n if (!arguments_ || typeof arguments_ !== 'object') {\n return {\n type: 'object',\n properties: {},\n required: [],\n additionalProperties: false,\n };\n }\n\n const properties: Record<string, any> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(arguments_)) {\n if (value && typeof value === 'object' && value.type) {\n // This is a TypeBox schema object that has been serialized\n properties[key] = {\n type: value.type,\n ...(value.description && { description: value.description }),\n ...(value.enum && { enum: value.enum }),\n ...(value.items && { items: value.items }),\n ...(value.properties && { properties: value.properties }),\n ...(value.required && { required: value.required }),\n };\n\n // For now, treat all arguments as required (this matches the existing behavior)\n // In the future, we could detect Type.Optional() usage\n required.push(key);\n }\n }\n\n return {\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n };\n}\n\nexport function extractPromptFromModule(moduleContent: any, filePath: string): Prompt {\n // Generate ID from file path if not provided\n const fileBaseName = basename(filePath, '.ts'); // Remove .ts extension\n const defaultId = fileBaseName.toLowerCase().replace(/[^a-z0-9]/g, '-');\n\n // Convert TypeBox arguments to JSON Schema format\n const convertedArguments = convertTypeBoxArgumentsToJsonSchema(moduleContent.arguments);\n\n // Extract and validate required fields from the module content\n const prompt: Prompt = {\n name: moduleContent.name || 'Untitled Prompt',\n slug: moduleContent.slug || defaultId,\n messages: moduleContent.messages || [],\n model: moduleContent.model,\n options: moduleContent.options,\n arguments: convertedArguments,\n id: moduleContent.id || defaultId,\n version: moduleContent.version || '1.0.0',\n // Optional fields from API response\n ...(moduleContent.promptId && { promptId: moduleContent.promptId }),\n ...(moduleContent.description && { description: moduleContent.description }),\n };\n\n // Validate required fields\n if (!prompt.name) {\n throw new Error('Prompt must have a name');\n }\n if (!prompt.slug) {\n throw new Error('Prompt must have a slug');\n }\n if (!Array.isArray(prompt.messages)) {\n throw new Error('Prompt messages must be an array');\n }\n\n if (!prompt.model) {\n throw new Error('Prompt must have a model');\n }\n\n return prompt;\n}\n\n/**\n * Transform JSON Schema to TypeBox/Template validator format\n */\nexport function transformJsonSchemaToTypeBox(schema: any): string {\n if (schema.type === 'string') {\n if (schema.enum && Array.isArray(schema.enum)) {\n // Handle enum as Union of Literals\n const literals = schema.enum.map((value: string) => `Type.Literal('${value}')`).join(', ');\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Union([${literals}]${options})`;\n } else {\n // Regular string\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.String(${options})`;\n }\n }\n\n if (schema.type === 'number' || schema.type === 'integer') {\n const typeMethod = schema.type === 'integer' ? 'Integer' : 'Number';\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.${typeMethod}(${options})`;\n }\n\n if (schema.type === 'boolean') {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Boolean(${options})`;\n }\n\n if (schema.type === 'array') {\n const itemsType = schema.items ? transformJsonSchemaToTypeBox(schema.items) : 'Type.String()';\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Array(${itemsType}${options})`;\n }\n\n if (schema.type === 'object') {\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(([key, value]: [string, any]) => {\n const isRequired = schema.required && schema.required.includes(key);\n const propType = transformJsonSchemaToTypeBox(value);\n return ` ${key}: ${isRequired ? propType : `Type.Optional(${propType})`}`;\n })\n .join(',\\n');\n\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Object({\\n${props}\\n }${options})`;\n } else {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Object({}${options ? `, ${options}` : ''})`;\n }\n }\n\n // Fallback for unknown types\n return 'Type.String()';\n}\n\n/**\n * Generate TypeScript prompt file content from API response\n */\nexport function generatePromptFileFromApiResponse(apiResponse: any): string {\n const { prompt, version } = apiResponse;\n const { data, options } = version;\n\n // Transform arguments from JSON Schema to TypeBox format\n let argumentsCode = '{}';\n if (data.arguments && data.arguments.properties) {\n const argEntries = Object.entries(data.arguments.properties)\n .map(([key, schema]: [string, any]) => {\n const isRequired = data.arguments.required && data.arguments.required.includes(key);\n const typeCode = transformJsonSchemaToTypeBox(schema);\n return ` ${key}: ${isRequired ? typeCode : `Type.Optional(${typeCode})`}`;\n })\n .join(',\\n');\n\n if (argEntries) {\n argumentsCode = `{\\n${argEntries}\\n }`;\n }\n }\n\n // Generate the TypeScript file content\n return `import { Type } from 'axiom/ai';\n\nexport default {\n name: '${prompt.name}',\n slug: '${prompt.slug}',\n description: '${prompt.description || ''}',\n messages: [${data.messages\n .map(\n (msg: any) => `\n {\n role: '${msg.role}',\n content: '${msg.content.replace(/'/g, \"\\\\'\")}',\n }`,\n )\n .join(',')}\n ],\n model: '${data.model || 'gpt-4'}',\n options: {\n${\n options\n ? Object.entries(options)\n .map(([key, value]) => ` ${key}: ${value}`)\n .join(',\\n')\n : ''\n}\n },\n arguments: ${argumentsCode},\n version: '${version.version}',\n promptId: '${prompt.promptId}',\n};\n`;\n}\n","import { Command } from 'commander';\nimport { generatePromptFileFromApiResponse } from '../transpiler';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nexport const loadPullCommand = (program: Command) => {\n const pull = new Command('pull')\n .description('Pull a version of an object')\n .argument(\n '<slug>',\n 'The object to pull, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--version <version>', 'The version to pull, default: latest', 'latest')\n .option('--output <path>', 'Output file path (optional, defaults to <slug>.prompt.ts)')\n .action(async (slug: string, options: { version: string; output?: string }) => {\n try {\n console.log(`Pulling prompt: ${slug} (version: ${options.version})`);\n\n const url = `${process.env.AXIOM_URL}/v1/prompts/${slug}`;\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n\n const tsContent = generatePromptFileFromApiResponse(apiResponse);\n\n const outputPath = options.output || `${slug}.prompt.ts`;\n const fullPath = path.resolve(outputPath);\n\n await fs.writeFile(fullPath, tsContent, 'utf-8');\n\n console.log(`Successfully generated prompt file: ${fullPath}`);\n console.log(`Prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`);\n console.log(`Version: ${apiResponse.version.version}`);\n } catch (error) {\n console.error('Failed to pull prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(pull);\n};\n","import { Command } from 'commander';\nimport { runVitest } from '../evals/run-vitest';\n\nexport const loadRunCommand = (program: Command) => {\n return program.addCommand(\n new Command('eval')\n .description('run evals locally')\n .argument('<path>', 'Path to an eval test file, should be in the form of *.eval.ts')\n .action(async (file: string) => {\n if (!process.env.AXIOM_URL || !process.env.AXIOM_TOKEN || !process.env.AXIOM_DATASET) {\n throw new Error('AXIOM_URL, AXIOM_TOKEN, and AXIOM_DATASET must be set');\n }\n await runVitest(file);\n }),\n );\n};\n","import { createVitest, registerConsoleShortcuts } from 'vitest/node';\nimport { AxiomReporter } from './reporter';\nimport { flush } from './instrument';\n\nexport const runVitest = async (file: string) => {\n const vi = await createVitest('test', {\n // root: process.cwd(),\n mode: 'test',\n include: [file ? file : '**/*.eval.ts'],\n reporters: ['verbose', new AxiomReporter()],\n environment: 'node',\n browser: undefined,\n });\n\n await vi.start();\n\n const dispose = registerConsoleShortcuts(vi, process.stdin, process.stdout);\n\n if (!vi.shouldK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AM,YAAY,OAAO,SAAiB;AAC/C,QAAM,KAAK,MAAM,aAAa,QAAQ;AAAA;AAAA,IAEpC,MAAM;AAAA,IACN,SAAS,CAAC,OAAO,OAAO,cAAc;AAAA,IACtC,WAAW,CAAC,WAAW,IAAI,cAAc,CAAC;AAAA,IAC1C,aAAa;AAAA,IACb,SAAS;AAAA,EACX,CAAC;AAED,QAAM,GAAG,MAAM;AAEf,QAAM,UAAU,yBAAyB,IAAI,QAAQ,OAAO,QAAQ,MAAM;AAE1E,MAAI,CAAC,GAAG,iBAAiB,GAAG;AAC1B,YAAQ;AACR,UAAM,MAAM;AACZ,UAAM,GAAG,MAAM;AACf,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,MAAM;AACd;;;ADvBO,IAAM,iBAAiB,CAACC,aAAqB;AAClD,SAAOA,SAAQ;AAAA,IACb,IAAIC,SAAQ,MAAM,EACf,YAAY,mBAAmB,EAC/B,SAAS,UAAU,+DAA+D,EAClF,OAAO,OAAO,SAAiB;AAC9B,UAAI,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,IAAI,eAAe,CAAC,QAAQ,IAAI,eAAe;AACpF,cAAM,IAAI,MAAM,uDAAuD;AAAA,MACzE;AACA,YAAM,UAAU,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AACF;;;AJXA,IAAM,EAAE,cAAc,IAAI;AAG1B,cAAc,QAAQ,IAAI,CAAC;AAO3B,IAAM,UAAU,IAAIC,SAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,kDAAkD,EAC9D,QAAQ,QAAe;AAE1B,gBAAgB,OAAO;AACvB,gBAAgB,OAAO;AACvB,eAAe,OAAO;AAEtB,QAAQ,MAAM;","names":["Command","fs","resolve","program","Command","fs","path","program","Command","Command","program","Command","Command"]}
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
// src/evals/reporter.ts
|
|
2
|
+
import { Table } from "console-table-printer";
|
|
3
|
+
var prRed = (s) => `\x1B[91m ${s}\x1B[00m`;
|
|
4
|
+
var AxiomReporter = class {
|
|
5
|
+
onTestSuiteReady(_testSuite) {
|
|
6
|
+
}
|
|
7
|
+
onTestSuiteResult(testSuite) {
|
|
8
|
+
const scoreboard = new Table({
|
|
9
|
+
title: testSuite.name
|
|
10
|
+
});
|
|
11
|
+
for (const test of testSuite.children.array()) {
|
|
12
|
+
if (test.type !== "test") continue;
|
|
13
|
+
const testMeta = test.meta();
|
|
14
|
+
if (!testMeta.eval) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const scores = Object.keys(testMeta.eval.scores).map((k) => {
|
|
18
|
+
const v = testMeta.eval.scores[k].score ? testMeta.eval.scores[k].score : 0;
|
|
19
|
+
const scoreValue = Number(v * 100).toFixed(2);
|
|
20
|
+
const score = testMeta.eval.threshold && v < testMeta.eval.threshold ? prRed(scoreValue + "%") : scoreValue + "%";
|
|
21
|
+
return [k, score];
|
|
22
|
+
});
|
|
23
|
+
scoreboard.addRow({
|
|
24
|
+
case: testMeta.eval.index.toString(),
|
|
25
|
+
...Object.fromEntries(scores)
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
scoreboard.printTable();
|
|
29
|
+
}
|
|
30
|
+
async onTestRunEnd(_testModules, _errors, _reason) {
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
1
34
|
// src/evals/instrument.ts
|
|
2
35
|
import { BatchSpanProcessor, NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
3
36
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
@@ -25,12 +58,12 @@ var processor = new BatchSpanProcessor(exporter, {
|
|
|
25
58
|
var provider = new NodeTracerProvider({
|
|
26
59
|
resource: resourceFromAttributes({
|
|
27
60
|
["service.name"]: "axiom-ai",
|
|
28
|
-
["service.version"]: "0.11.
|
|
61
|
+
["service.version"]: "0.11.2"
|
|
29
62
|
}),
|
|
30
63
|
spanProcessors: [processor]
|
|
31
64
|
});
|
|
32
65
|
provider.register();
|
|
33
|
-
var tracer = trace.getTracer("axiom-ai", "0.11.
|
|
66
|
+
var tracer = trace.getTracer("axiom-ai", "0.11.2");
|
|
34
67
|
var flush = async () => {
|
|
35
68
|
await provider.forceFlush();
|
|
36
69
|
};
|
|
@@ -39,7 +72,8 @@ var startSpan = (name, opts, context) => {
|
|
|
39
72
|
};
|
|
40
73
|
|
|
41
74
|
export {
|
|
75
|
+
AxiomReporter,
|
|
42
76
|
flush,
|
|
43
77
|
startSpan
|
|
44
78
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-CQCLS3XJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/evals/reporter.ts","../src/evals/instrument.ts"],"sourcesContent":["import type { SerializedError } from 'vitest';\nimport type { Reporter, TestModule, TestRunEndReason, TestSuite } from 'vitest/node.js';\nimport type { TaskMeta } from 'vitest/index.cjs';\nimport { Table } from 'console-table-printer';\nimport type { EvalReport } from './eval.types';\n\nconst prRed = (s: string): string => `\\x1b[91m ${s}\\x1b[00m`;\n\n/**\n * Custom Vitest reporter for Axiom AI evaluations.\n *\n * This reporter collects evaluation results and scores from tests\n * and processes them for further analysis and reporting.\n *\n * @experimental This API is experimental and may change in future versions.\n */\nexport class AxiomReporter implements Reporter {\n onTestSuiteReady(_testSuite: TestSuite) {}\n\n onTestSuiteResult(testSuite: TestSuite) {\n const scoreboard = new Table({\n title: testSuite.name,\n });\n for (const test of testSuite.children.array()) {\n if (test.type !== 'test') continue;\n const testMeta = test.meta() as TaskMeta & { eval: EvalReport };\n\n if (!testMeta.eval) {\n return;\n }\n\n // round scores\n const scores = Object.keys(testMeta.eval.scores).map((k) => {\n const v = testMeta.eval.scores[k].score ? testMeta.eval.scores[k].score : 0;\n const scoreValue = Number(v * 100).toFixed(2);\n\n // if score is lower then threshold then print it in red\n const score =\n testMeta.eval.threshold && v < testMeta.eval.threshold\n ? prRed(scoreValue + '%')\n : scoreValue + '%';\n\n return [k, score];\n });\n\n scoreboard.addRow({\n case: testMeta.eval.index.toString(),\n ...Object.fromEntries(scores),\n });\n }\n\n scoreboard.printTable();\n }\n\n async onTestRunEnd(\n _testModules: ReadonlyArray<TestModule>,\n _errors: ReadonlyArray<SerializedError>,\n _reason: TestRunEndReason,\n ) {}\n}\n","import { BatchSpanProcessor, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { resourceFromAttributes } from '@opentelemetry/resources';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport { trace, type Context, type SpanOptions } from '@opentelemetry/api';\n\nconst collectorOptions = {\n url: process.env.AXIOM_URL\n ? `${process.env.AXIOM_URL}/v1/traces`\n : 'https://api.axiom.co/v1/traces', // Axiom API endpoint for trace data\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`, // Replace API_TOKEN with your actual API token\n 'X-Axiom-Dataset': process.env.AXIOM_DATASET || '', // Replace DATASET_NAME with your dataset\n },\n concurrencyLimit: 10, // an optional limit on pending requests\n};\n\n// export const consoleExporter = new ConsoleSpanExporter()\nexport const exporter = new OTLPTraceExporter(collectorOptions);\n\nconst processor = new BatchSpanProcessor(exporter, {\n maxQueueSize: 2048,\n maxExportBatchSize: 512,\n scheduledDelayMillis: 5000,\n exportTimeoutMillis: 30000,\n});\n\nconst provider = new NodeTracerProvider({\n resource: resourceFromAttributes({\n ['service.name']: 'axiom-ai',\n ['service.version']: __SDK_VERSION__,\n }),\n spanProcessors: [processor],\n});\n\nprovider.register();\n\n// Create a shared tracer instance\nconst tracer = trace.getTracer('axiom-ai', __SDK_VERSION__);\n\nexport const flush = async () => {\n await provider.forceFlush();\n};\n\nexport const startSpan = (name: string, opts: SpanOptions, context?: Context) => {\n return tracer.startSpan(name, opts, context);\n};\n"],"mappings":";AAGA,SAAS,aAAa;AAGtB,IAAM,QAAQ,CAAC,MAAsB,YAAY,CAAC;AAU3C,IAAM,gBAAN,MAAwC;AAAA,EAC7C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