npm package: @skillmaster/sdk
Description: Node.js SDK for SkillMaster API - AI-powered image/video generation, media analysis, and more
Author: SkillMaster
Latest version: 1.0.7

# @skillmaster/sdk

Node.js SDK for SkillMaster API - AI-powered image/video generation, media analysis, document processing, and more.

## Installation

```bash
npm install @skillmaster/sdk
```

## Quick Start

```typescript
import { SkillMasterClient } from '@skillmaster/sdk';

// Reads SKILLMASTER_API_KEY from environment variable
const client = new SkillMasterClient();

// Or with explicit config
const client = new SkillMasterClient({
  apiKey: 'your-api-key',
  baseUrl: 'https://skillmaster.fieldshortcut.com',
  taskDir: './tasks',
  timeout: 900000 // 15 minutes
});

// Generate image
const imageResult = await client.image.jimeng({
  prompt: 'A beautiful sunset over mountains',
  size: '2048x2048'
});

// Generate video (Kling)
const videoResult = await client.video.kling({
  prompt: 'A cat playing piano',
  model: 'kling-v2-6',
  aspect_ratio: '16:9',
  duration: '5'
});

// Translate document (local file will be auto-uploaded to get tmp_url)
const docResult = await client.document.translate({
  attachment: [{ path: './files/doc.pdf' }],
  source_language: { value: 'en', label: 'English' },
  target_language: { value: 'zh', label: 'Chinese' }
});

// Analyze media
const mediaResult = await client.media.analyze({
  url: [{ link: 'https://youtube.com/watch?v=...' }]
});
```

## Configuration

### Environment Variables

- `SKILLMASTER_API_KEY` - Your SkillMaster API key
- `SKILLMASTER_BASE_URL` - API base URL (optional, defaults to https://skillmaster.fieldshortcut.com)

### CLI Configuration

Use the CLI to persist configuration:

```bash
# Install globally
npm install -g @skillmaster/sdk

# Set API key (stored in ~/.skillmaster/config.json)
skillmaster-sdk config set apiKey your-api-key

# Set custom base URL
skillmaster-sdk config set baseUrl https://custom.example.com

# View current configuration
skillmaster-sdk config

# Get a specific value
skillmaster-sdk config get apiKey
```

### Configuration Priority

1. Constructor parameters (highest priority)
2. Environment variables
3. Config file (~/.skillmaster/config.json)
4. Default values (lowest priority)

## Task Folders

Each SDK execution creates a task folder with:

- `logs/request.json` - Request details
- `logs/response.json` - API response
- `logs/execution.log` - Execution log
- `attachments/` - Downloaded attachments (to avoid link expiration)

### Default Task Directory

Tasks are stored in `~/Documents/tasks/` by default. You can override this:

```typescript
const client = new UnityClawClient({
  taskDir: '/path/to/custom/tasks'
});
```

## API Reference

### Image Generation

```typescript
// JiMeng
await client.image.jimeng({
  prompt: 'A sunset over mountains',
  size: '2048x2048'
});

// JiMeng (Doubao)
await client.image.jimeng({
  prompt: 'A futuristic city',
  model: 'v6.0'
});
```

### Video Generation

```typescript
// Kling
await client.video.kling({
  prompt: 'A dancing robot',
  model: 'kling-v1-5'
});
```

### Document Processing

```typescript
// Translate document
await client.document.translate({
  attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }],
  source_language: { value: 'en', label: 'English' },
  target_language: { value: 'zh', label: 'Chinese' }
});

// Convert document
await client.document.convert({
  attachment: [{ path: './files/doc.pdf' }],
  input_format: 'pdf',
  output_format: 'docx'
});
```

### Media Analysis

```typescript
const result = await client.media.analyze({
  url: [{ link: 'https://youtube.com/watch?v=...' }]
});

console.log(result.response.data?.summary);
console.log(result.response.data?.subtitle);
```

## License

MIT