npm package: @172ai/a2a-client
Description: Official Node.js client library for 172.ai A2A (Agent-to-Agent) communication
Author: 172.ai
Latest version: 1.1.0

# @172ai/a2a-client

Official Node.js client library for 172.ai A2A (Agent-to-Agent) communication system.

## Installation

```bash
npm install @172ai/a2a-client
```

## Quick Start

```javascript
const { A2AClient } = require('@172ai/a2a-client');

const client = new A2AClient({
  apiKey: 'sk_your_api_key',
  agentId: 'my-agent-v1',
  agentType: 'code-analysis'
});

// Create container
const result = await client.createContainer({
  name: 'code-analysis-' + Date.now(),
  dockerfile: 'FROM node:18\nCOPY . /app\nRUN npm audit',
  tags: ['code-analysis', 'automated']
});

// Build container
const buildResult = await client.buildContainer(result.id);
console.log('Build initiated:', buildResult.buildLogId);
```

## Configuration

### Required Parameters

- `apiKey`: API key with A2A scope from 172.ai dashboard
- `agentId`: Unique identifier for your agent instance
- `agentType`: One of:
  - `code-analysis` - Code quality and security analysis
  - `testing` - Automated testing and QA
  - `deployment` - CI/CD and orchestration
  - `monitoring` - Observability and metrics
  - `security` - Vulnerability scanning
  - `documentation` - Technical documentation
  - `integration` - API management
  - `generic` - General purpose

### Optional Parameters

- `baseUrl`: API base URL (default: 'https://api.172.ai')
- `timeout`: Request timeout in ms (default: 30000)

## API Methods

### Authentication

```javascript
// Test authentication
await client.authenticate();

// Get platform capabilities
const capabilities = await client.getCapabilities();

// Health check
const health = await client.healthCheck();
```

### Container Operations

```javascript
// List containers
const containers = await client.listContainers({ limit: 10 });

// Get container
const container = await client.getContainer(containerId);

// Create container
const newContainer = await client.createContainer({
  name: 'my-container',
  dockerfile: 'FROM alpine:latest',
  tags: ['test'],
  isPrivate: true
});

// Build container
const build = await client.buildContainer(containerId);

// Update container
await client.updateContainer(containerId, { name: 'new-name' });

// Delete container
await client.deleteContainer(containerId);
```

### Build Operations

```javascript
// Get build status
const status = await client.getBuildStatus(containerId, buildLogId);

// Get build logs
const logs = await client.getBuildLogs(containerId, buildLogId);

// List builds
const builds = await client.listBuilds(containerId);
```

### Container Execution

```javascript
// Get cost estimate
const estimate = await client.getExecutionCostEstimate(containerId, 1);

// Start execution
const execution = await client.startExecution(containerId, { durationDays: 1 });

// Get execution status
const status = await client.getExecutionStatus(containerId);

// Stop execution
await client.stopExecution(containerId);

// Get execution history
const history = await client.getExecutionHistory(containerId);

// List all executions
const executions = await client.listExecutions();
```

### File Operations

```javascript
// Upload file
await client.uploadFile(
  containerId,
  'config.yml',
  Buffer.from('config: value').toString('base64'),
  'application/x-yaml'
);

// List files
const files = await client.listFiles(containerId, '/app');

// Get file content
const content = await client.getFile(containerId, 'config.yml');
```

### Container Fix Operations (AI-Powered)

```javascript
// Analyze container build failures
const analysis = await client.analyzeContainerFailure(containerId);
console.log('Issues found:', analysis.issues);

// Execute full fix workflow (analyze + apply + rebuild)
const fixResult = await client.executeContainerFix(containerId, {
  autoApply: true,  // Auto-apply AI-generated fixes
  analyzeOnly: false
});
console.log('Fix applied:', fixResult.success);

// Apply a specific fix
await client.applyContainerFix(containerId, fixId);

// Get fix history
const history = await client.getContainerFixHistory(containerId);

// Get specific fix attempt details
const attempt = await client.getContainerFixAttempt(containerId, fixId);
```

### Container Improvements Operations (AI-Powered)

```javascript
// Get AI improvement suggestions
const suggestions = await client.suggestContainerImprovements(containerId);
console.log('Suggested improvements:', suggestions);

// Apply an improvement
const applyResult = await client.applyContainerImprovement(
  containerId,
  modificationId
);

// Check improvement status
const status = await client.getImprovementStatus(containerId, modificationId);

// List all applied improvements
const improvements = await client.listAppliedImprovements(containerId);
```

## Examples

See the [examples directory](./examples) for complete SDLC workflow examples.

## License

MIT