@tokenrip/cli
v1.0.1
Published
CLI and library for AI agents to create and share assets via Tokenrip
Downloads
61
Readme
@tokenrip/cli
Asset sharing for AI agents. Create shareable links for PDFs, images, HTML pages, markdown documents, and charts — from the command line or programmatically.
Install
npm install -g @tokenrip/cliQuick Start
# 1. Create an API key (auto-saved)
tokenrip auth create-key
# 2. Upload a file
tokenrip asset upload report.pdf --title "Q1 Report"
# 3. Publish structured content
tokenrip asset publish dashboard.html --type html --title "Dashboard"
# 4. Check your assets
tokenrip asset listEvery command outputs machine-readable JSON:
{ "ok": true, "data": { "id": "abc-123", "url": "https://...", "title": "Q1 Report", "type": "file" } }CLI Commands
tokenrip asset upload <file> [--title <title>]
Upload a binary file (PDF, image, etc.) and get a shareable link. MIME type is auto-detected.
tokenrip asset upload chart.png
tokenrip asset upload slides.pdf --title "Team Slides"tokenrip asset publish <file> --type <type> [--title <title>]
Publish structured content for rich rendering in the browser.
Supported types: markdown, html, chart, code, text, json
tokenrip asset publish notes.md --type markdown
tokenrip asset publish page.html --type html --title "Landing Page"
tokenrip asset publish data.json --type chart --title "Revenue Chart"tokenrip asset list
List your published assets and their metadata.
tokenrip asset list
tokenrip asset list --since 2026-03-30T00:00:00Z --type markdown --limit 5tokenrip asset update <uuid> <file> [--type <type>]
Publish a new version of an existing asset.
tokenrip asset update 550e8400-... report-v2.md --type markdown
tokenrip asset update 550e8400-... chart.png --label "with axes fixed"tokenrip asset delete <uuid>
Permanently delete an asset and its shareable link.
tokenrip asset delete 550e8400-e29b-41d4-a716-446655440000tokenrip asset stats
Show storage usage statistics.
tokenrip auth create-key
Create a new API key (auto-saved to config).
tokenrip auth create-key
tokenrip auth create-key --name "My Agent" --no-savetokenrip config set-key <key>
Save your API key to ~/.config/tokenrip/config.json.
tokenrip config set-url <url>
Set a custom API server URL (default: https://api.tokenrip.com).
Provenance Tracking
All asset commands support lineage metadata:
--parent <uuid>— Parent asset ID--context <text>— Creator context (agent name, task description)--refs <urls>— Comma-separated input reference URLs
Library Usage
@tokenrip/cli also works as a Node.js library for programmatic asset creation.
import { loadConfig, getApiUrl, getApiKey, createHttpClient } from '@tokenrip/cli';
const config = loadConfig();
const client = createHttpClient({
baseUrl: getApiUrl(config),
apiKey: getApiKey(config),
});
// Publish markdown content
const { data } = await client.post('/v0/assets', {
type: 'markdown',
content: '# Hello\n\nGenerated by my agent.',
title: 'Agent Output',
});
console.log(data.data.id); // asset UUIDExports
| Export | Description |
|--------|-------------|
| loadConfig() | Load config from ~/.config/tokenrip/config.json |
| saveConfig(config) | Persist config to disk |
| getApiUrl(config) | Resolve API URL (config > env > default) |
| getApiKey(config) | Resolve API key (config > env) |
| createHttpClient(config?) | Axios instance with auth and error handling |
| CliError | Typed error class with error codes |
| toCliError(err) | Normalize any error to CliError |
| outputSuccess(data) | Print { ok: true, data } JSON |
| outputError(err) | Print { ok: false, error, message } and exit |
| wrapCommand(fn) | Wrap async handler with error catching |
Configuration
Configuration is read from ~/.config/tokenrip/config.json:
{
"apiKey": "tr_...",
"apiUrl": "https://api.tokenrip.com",
"preferences": {}
}Environment variables take precedence over the config file:
| Variable | Overrides |
|----------|-----------|
| TOKENRIP_API_KEY | apiKey |
| TOKENRIP_API_URL | apiUrl |
Output Format
All commands output JSON to stdout. In a TTY, output is human-readable by default — use --json or pipe to get JSON. Errors exit with code 1.
Success:
{ "ok": true, "data": { ... } }Error:
{ "ok": false, "error": "NO_API_KEY", "message": "No API key configured. Run `tokenrip config set-key <key>`" }Error Codes
| Code | Meaning |
|------|---------|
| NO_API_KEY | No API key configured |
| FILE_NOT_FOUND | Input file does not exist |
| INVALID_TYPE | Publish type not one of: markdown, html, chart, code, text, json |
| UNAUTHORIZED | API key is invalid or expired |
| TIMEOUT | Request timed out (30s) |
| NETWORK_ERROR | Cannot reach the API server |
License
MIT
