Skip to content

codevfllc/codevf-sdk-js

Repository files navigation

CodeVF JS SDK

A modular TypeScript SDK for integrating with the CodeVF API. Submit tasks for human review, manage projects, track credits, and leverage engineer expertise levels.

Features

  • Project Management - Create and organize projects for grouping API tasks
  • Task Submission - Submit tasks for human engineer review with customizable service levels
  • Credit System - Monitor your credit balance and usage across tasks
  • Engineer Expertise - Select engineer expertise levels with cost multipliers
  • File Attachments - Attach screenshots, logs, code files, and documents to tasks
  • Comprehensive Error Handling - Typed error classes for all HTTP status codes and failure modes

Quick Start

Installation

bun install

Basic Usage

import { createClient, createProject, createTask } from 'codevf-js-sdk';

// Initialize the SDK
const client = createClient({ apiKey: 'your-api-key' });

// Create a project
const project = await createProject(client, {
  name: 'My API Project',
  description: 'Project for API integration'
});

// Submit a task for review
const task = await createTask(client, {
  prompt: 'Review this authentication system',
  projectId: project.id,
  maxCredits: 100,
  mode: 'fast'
});

// Check task status
const status = await getTask(client, task.id);

// Check credit balance
const balance = await getBalance(client);

Architecture

The SDK follows a modular architecture with strict separation between internal core logic and public API modules:

  • Core (/src/core) - Internal HTTP client, authentication, error handling, and configuration
  • Modules (/src/modules) - Public feature domains: projects, tasks, credits, tags
  • Types (/src/types) - Shared TypeScript interfaces used across modules

API Reference

Projects

  • createProject(client, data) - Create a new project for grouping tasks

Tasks

  • createTask(client, data) - Submit a task for human engineer review
  • getTask(client, taskId) - Retrieve task status and results
  • cancelTask(client, taskId) - Cancel a pending or in-progress task

Credits

  • getBalance(client) - Check current credit balance, available and on-hold amounts

Tags

  • getTags(client) - Get available engineer expertise levels with cost multipliers

Error Handling

The SDK provides typed error classes for granular error handling:

  • BadRequestError (400) - Invalid parameters or malformed request
  • AuthError (401) - Invalid or missing API key
  • InsufficientCreditsError (402) - Not enough credits to complete task
  • NotFoundError (404) - Resource not found or access denied
  • ConflictError (409) - Idempotency conflict
  • PayloadTooLargeError (413) - Request exceeds size limit
  • RateLimitError (429) - Rate limit exceeded
  • ServerError (500) - Internal server error
  • NetworkError - Connection or timeout issues

Running Tests

bun test

Tests are organized in /tests directory with the same structure as source code. Uses vitest for testing framework.

Development

This project uses Bun as the runtime and build tool:

  • bun run index.ts - Execute main entry point
  • bun test - Run test suite
  • bun docs - Generate TypeDoc documentation
  • bun run build - Build TypeScript to JavaScript in /dist directory

Publishing to NPM

To publish a new version of this SDK to npm:

  1. Update the version in package.json:

    npm version patch|minor|major
  2. Build the distribution files:

    bun run build
  3. Ensure all tests pass:

    bun test
  4. Publish to npm:

    npm publish

The package will be published under the scope codevf-js-sdk with all distribution files and documentation included.

Requirements

  • Bun v1.3.6+
  • TypeScript 5+
  • npm account for publishing

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors