Skip to main content

viben queue

Command queue management for operations, debugging, and monitoring queue status.

Overview​

The viben queue command is the CLI client for CommandQueue, sharing the same underlying operation layer with /api/queue/* Gateway endpoints. Primarily designed for agent debugging scenarios with detailed output information.

Design Principles​

  • Debug-first: Detailed output for agent problem analysis
  • CLI/API consistency: All operations share the same underlying ops with Gateway REST API
  • Format-friendly: Human-readable by default, --json output for parsing

Architecture​

+---------------------------------------------------------------------+
| CLI / Gateway |
+---------------------------------------------------------------------+
| +------------------+ +------------------+ |
| | viben queue * | | /api/queue/* | |
| | (CLI commands) | | (REST routes) | |
| +--------+---------+ +--------+---------+ |
| | | |
| +------------+---------------+ |
| | |
| v |
| +---------------------------------------------------------------+ |
| | packages/core/src/queue/ops | |
| | enqueue, cancel, retry, status, list, logs, config, clean | |
| +---------------------------------------------------------------+ |
+---------------------------------------------------------------------+

Command Structure​

viben queue <subcommand> [options]

Ops-to-API Mapping​

QueueOps​

CLI CommandOps FunctionREST API Endpoint
viben queue statusgetStatus()GET /api/queue/status
viben queue listlist()GET /api/queue/list
viben queue inspect <id>getItem()GET /api/queue/:id
viben queue enqueueenqueue()POST /api/queue/enqueue
viben queue cancel <id>cancel()DELETE /api/queue/:id
viben queue retry <id>retry()POST /api/queue/:id/retry
viben queue logs <id>getLogs()GET /api/queue/:id/logs
viben queue watch(WebSocket)WebSocket /ws/queue
viben queue configgetConfig() / setConfig()GET/PUT /api/queue/config
viben queue cleanclean()DELETE /api/queue/clean

ProcessOps​

OperationOps FunctionDescription
SpawnspawnProcess()Start a new process for a queue task
KillkillProcess()Terminate a running process (SIGTERM)
MonitormonitorProcess()Check process health and status

Subcommand Overview​

SubcommandDescription
statusOverall queue status
listTask list
inspectTask details
enqueueSubmit command
cancelCancel task
retryRetry failed task
logsView task logs
watchReal-time queue monitoring
configConfiguration management
cleanClean completed tasks

Queue Status​

View Status​

viben queue status [--json]

Output:

Queue Status
────────────────────────────────────────
Pending: 3 task(s)
Running: 2 / 3 (max concurrency)
Completed: 15 task(s)

Running Tasks:
q_abc123 sleep 60 2m 15s
q_def456 claude -p 45s

Persistence: ~/.viben/queue/ (healthy)

List Tasks​

viben queue list [--status <status>] [--limit <n>] [--all] [--json]

Options:

OptionDescription
--status, -sFilter by status (pending, running, completed)
--limit, -nLimit number of results, default 50
--allShow all tasks (including completed)
--jsonJSON format output

Examples:

viben queue list # Default shows pending + running
viben queue list --status completed # Only completed tasks
viben queue list --all --limit 100 # All statuses, max 100 entries

Output:

ID STATUS COMMAND CREATED ELAPSED RETRIES
─────────────────────────────────────────────────────────────────────────────
q_abc123 running sleep 60 2m ago 2m 15s 0/3
q_def456 running claude -p "hello" 1m ago 45s 0/3
q_ghi789 pending npm test 30s ago - 0/3
q_jkl012 pending make build 10s ago - 0/3

Showing 4 of 4 tasks

Task Operations​

Submit Command​

viben queue enqueue --command <cmd> --cwd <path> [options]
viben queue enqueue --stdin --cwd <path> [options]

Options:

OptionDescription
--command, -cBash command to execute
--cwdWorking directory
--stdinRead command from stdin
--metadataMetadata in JSON format
--max-retriesMaximum retry count, default 3
--jsonJSON format output

Examples:

# Specify command directly
viben queue enqueue --command "sleep 60" --cwd /tmp

# Execute Claude Code
viben queue enqueue --command 'claude -p "Implement user login"' --cwd /path/to/project

# With metadata
viben queue enqueue --command "npm test" --cwd /app --metadata '{"task_dir":".viben/tasks/my-task"}'

# Read from stdin
echo 'npm run build && npm test' | viben queue enqueue --stdin --cwd /app

Output:

Task enqueued successfully
ID: q_abc123
Position: 4 (3 pending ahead)
Status: pending

Use 'viben queue inspect q_abc123' to view details
Use 'viben queue logs q_abc123 --follow' to stream output

Cancel Task​

viben queue cancel <id> [--force] [--json]

Options:

OptionDescription
--force, -fForce terminate running task (sends SIGTERM)
--jsonJSON format output

Examples:

viben queue cancel q_abc123 # Cancel pending task
viben queue cancel q_abc123 --force # Force terminate running task

View Task Details​

viben queue inspect <id> [--json]

Output:

Task: q_abc123
────────────────────────────────────────
Status: running
Command: claude -p "Implement user login"
CWD: /path/to/project

Timeline:
Created: 2024-03-03 14:30:00 (2m 15s ago)
Started: 2024-03-03 14:30:05 (2m 10s ago)
Elapsed: 2m 10s

Execution:
PID: 12345
Log: ~/.viben/queue/logs/q_abc123.log
Retries: 0 / 3

Metadata:
task_dir: .viben/tasks/03-14-user-login

Retry Task​

viben queue retry <id> [--reset-count] [--json]

Options:

OptionDescription
--reset-countReset retry counter to 0
--jsonJSON format output

Examples:

viben queue retry q_abc123 # Retry, keep count
viben queue retry q_abc123 --reset-count # Retry, reset counter

Logs and Monitoring​

View Logs​

viben queue logs <id> [--follow] [--tail <n>] [--timestamps] [--json]

Options:

OptionDescription
--follow, -fFollow output in real-time
--tail, -nShow last N lines, default all
--timestampsShow timestamps
--jsonJSON format output

Examples:

viben queue logs q_abc123 # View full logs
viben queue logs q_abc123 --tail 50 # Last 50 lines
viben queue logs q_abc123 --follow # Follow in real-time

Real-time Monitoring​

viben queue watch [--task <id>...] [--events <type>...] [--json]

Options:

OptionDescription
--task, -tMonitor only specified tasks (can be specified multiple times)
--events, -eShow only specified event types
--jsonJSON format output

Event Types:

EventDescription
task:enqueuedTask enqueued
task:startedTask started execution
task:completedTask completed
task:failedTask failed
queue:status_changedQueue status changed

Examples:

viben queue watch # Monitor all events
viben queue watch --task q_abc123 # Monitor specific task only
viben queue watch --events task:failed,task:completed # Only show completed and failed

Configuration Management​

View/Modify Configuration​

viben queue config [--json] # View configuration
viben queue config --set <key>=<value> [--set ...] # Modify configuration
viben queue config --reset # Reset to defaults

Configurable Items:

Config ItemTypeDefaultDescription
max_concurrencyint3Maximum concurrent tasks
promoter_interval_msint5000Promoter check interval
monitor_interval_msint30000Monitor check interval
default_max_retriesint3Default maximum retry count
log_retention_daysint7Log retention days
completed_retention_daysint30Completed record retention days

Examples:

viben queue config # View current configuration
viben queue config --set max_concurrency=5 # Modify concurrency
viben queue config --reset # Reset configuration

Cleanup Commands​

Clean Tasks​

viben queue clean [--status <status>] [--before <time>] [--keep <n>] [--dry-run] [--force] [--json]

Options:

OptionDescription
--status, -sClean tasks with specified status, default completed
--before, -bOnly clean tasks before specified time
--keep, -kKeep most recent N tasks
--dry-runPreview tasks to be cleaned without executing
--force, -fSkip confirmation prompt
--jsonJSON format output

Time Format: 1h, 2d, 1w (hours/days/weeks) or 2024-03-01

Examples:

viben queue clean # Clean all completed
viben queue clean --before 1d # Clean tasks older than 1 day
viben queue clean --keep 10 # Keep most recent 10
viben queue clean --dry-run # Preview, don't execute

Task Status​

StatusDescription
pendingEnqueued, waiting for execution
runningCurrently executing
retryingExecution failed, preparing to retry
completedExecution completed successfully
failedExecution failed, reached maximum retry count

File Persistence​

Queue data is stored in ~/.viben/queue/ directory:

~/.viben/queue/
├── config.yaml # Queue configuration
├── state.yaml # Queue metadata
├── tasks/ # Task details
│ ├── task-{id}.yaml
│ └── ...
└── logs/ # Task logs
└── {id}.log

Global Options​

All subcommands support the following global options:

OptionDescription
--jsonJSON format output
--quiet, -qSuppress non-essential output
--verbose, -vShow detailed debug information
--help, -hShow help information

Examples:

# Debug mode with detailed info
viben queue status --verbose

# Quiet mode for scripting
viben queue list --quiet --json

# JSON output for parsing
viben queue inspect q_abc123 --json

Error Handling​

All commands output detailed information on errors to help agents diagnose problems.

Common Error Scenarios​

Task not found:

Error: Task not found
ID: q_abc123
Reason: No task with this ID exists

Hint: Use 'viben queue list --all' to see all tasks

Invalid operation:

Error: Invalid operation
Task: q_abc123
Status: running
Action: cancel (without --force)

Hint: Use 'viben queue cancel q_abc123 --force' to terminate running task

Retry not available:

Error: Cannot retry task
Task: q_abc123
Status: running
Reason: Only completed (failed) tasks can be retried

Current task status:
Status: running
Elapsed: 2m 15s
PID: 12345

Error Codes​

Error CodeDescriptionResolution
TASK_NOT_FOUNDTask ID does not existUse viben queue list --all to verify
INVALID_STATUSOperation not allowed for current statusCheck task status first
PROCESS_RUNNINGCannot cancel without --forceAdd --force flag
MAX_RETRIES_EXCEEDEDRetry count exhaustedUse --reset-count with retry
QUEUE_FULLQueue at maximum capacityWait or increase max_concurrency
PERSISTENCE_ERRORFailed to read/write queue stateCheck ~/.viben/queue/ permissions