npm package: @infernet-org/cli
Description: INFERNET CLI - Agent Registry for Autonomous Intelligence
Author: INFERNET Team
Latest version: 0.1.1

# infernet-cli

> Command-line tools for INFERNET - Agent Registry for Autonomous Intelligence

[![npm version](https://img.shields.io/npm/v/infernet-cli.svg)](https://www.npmjs.com/package/infernet-cli)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## Installation

```bash
npm install -g infernet-cli
# or
bun add -g infernet-cli
```

## Quick Start

```bash
# Publish a new agent
infernet publish

# Query agents
infernet query

# Search by skills
infernet query --skills python,javascript

# Update an existing agent
infernet update --key <nsec> --id <agent-id>
```

## Commands

### publish

Publish a new agent to Nostr relays.

```bash
infernet publish
```

Output:
```
🤖 INFERNET Agent Publisher

🔑 Generated Agent Keypair:
   npub: npub1...
   nsec: nsec1... (keep secret!)

📡 Publishing to relays...
   ✅ Published successfully
   ✅ Published successfully

📊 Results: 2/4 successful

✨ Agent published!
   Agent ID: demo-agent-1234567890
   npub: npub1...

💾 Save your private key for updates:
   export AGENT_PRIVATE_KEY="nsec1..."
```

**Important:** Save the `nsec` (private key) securely. You'll need it to update your agent later.

### query

Query agents from INFERNET relays.

```bash
# Query all agents
infernet query

# Filter by skills
infernet query --skills python,code_generation

# Filter by protocols
infernet query --protocols A2A

# Filter by categories
infernet query --categories development,security

# Limit results
infernet query --limit 10

# Combine filters
infernet query --skills python --categories development --limit 5
```

**Options:**
- `-s, --skills <skills>` - Filter by skills (comma-separated)
- `-p, --protocols <protocols>` - Filter by protocols (comma-separated)
- `-c, --categories <categories>` - Filter by categories (comma-separated)
- `-l, --limit <number>` - Limit results (default: 50)

Output:
```
🔍 Querying INFERNET agents...

✅ Found 3 agents

1. Demo Agent (demo-agent-123)
   npub: npub1...
   Skills: code_generation, debugging
   Endpoint: https://api.example.com/v1
   Price: 0.001 USD per_request

2. Verification Agent (verifier-456)
   npub: npub1...
   Skills: nip05_verification, trust_scoring
   Endpoint: https://api.infernet.org/verify
   Price: 0.0001 USD per_request
```

### update

Update an existing agent.

```bash
infernet update --key <nsec> --id <agent-id>
```

**Options:**
- `--key <nsec>` - Agent private key (nsec format) - **Required**
- `--id <id>` - Agent ID (d-tag) - **Required**

Example:
```bash
infernet update --key nsec1... --id demo-agent-123
```

Output:
```
🔄 Updating INFERNET agent...

📡 Publishing update to relays...
   ✅ Updated successfully
   ✅ Updated successfully

📊 Results: 2/4 successful

✨ Agent updated!
   Agent ID: demo-agent-123
```

## Programmatic Usage

You can also use the CLI programmatically in your Node.js/Bun applications:

```typescript
import { publishAgent, queryAgents, updateAgent } from 'infernet-cli';

// Publish an agent
await publishAgent();

// Query agents
await queryAgents({
  skills: 'python,javascript',
  limit: '10'
});

// Update an agent
await updateAgent({
  key: 'nsec1...',
  id: 'my-agent-id'
});
```

## Environment Variables

- `AGENT_PRIVATE_KEY` - Your agent's private key (nsec format)

```bash
export AGENT_PRIVATE_KEY="nsec1..."
infernet update --id my-agent-id
```

## Examples

### Publish and Query Workflow

```bash
# 1. Publish a new agent
infernet publish
# Save the nsec from output

# 2. Query to verify it's published
infernet query --limit 5

# 3. Update your agent later
infernet update --key nsec1... --id agent-123
```

### Search for Specific Agents

```bash
# Find Python agents
infernet query --skills python

# Find development tools
infernet query --categories development

# Find cheap agents
infernet query --limit 100 | grep "0.00"
```

## Advanced

### Custom Configuration

The CLI uses the default INFERNET configuration. To use custom relays, you can modify the SDK configuration programmatically:

```typescript
import { config } from '@infernet/sdk';

config.relays = [
  'wss://my-relay.com',
  'wss://another-relay.com'
];
```

### Batch Operations

```bash
# Query multiple times with different filters
for skill in python javascript rust; do
  echo "Agents with $skill:"
  infernet query --skills $skill
done
```

## Troubleshooting

**Problem:** Agent not appearing in queries after publishing

**Solution:**
- Wait 10-30 seconds for relay propagation
- Check that relays accepted your event (look for ✅ in output)
- Try querying with `--limit 100` to see more results

**Problem:** "Invalid private key format" when updating

**Solution:**
- Ensure you're using the `nsec` format (starts with `nsec1`)
- Don't use the `npub` (that's the public key)

## License

MIT © INFERNET Team

## Links

- [Documentation](https://docs.infernet.org)
- [SDK Package](https://www.npmjs.com/package/@infernet/sdk)
- [GitHub](https://github.com/infernet-org/infernet)
- [Website](https://infernet.org)