> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Background Tasks CLI

> CLI commands for managing background tasks in TypeScript

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    User([User]) --> CLI[CLI]
    CLI --> Task[Task]

    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff

    class Task agent
    class CLI,User tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

**1. Simple Usage**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts background run my-recipe
```

**2. With Configuration**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts background run my-recipe --timeout 600
```

***

Background task CLI (TypeScript)

Manage background tasks using the praisonai-ts CLI.

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npm install -g praisonai-ts
```

## Commands Overview

| Command | Description |
| - | - |
| `praisonai-ts background list` | List all background tasks |
| `praisonai-ts background status <id>` | Get task status |
| `praisonai-ts background cancel <id>` | Cancel a running task |
| `praisonai-ts background clear` | Clear completed tasks |
| `praisonai-ts background submit` | Submit a recipe as background task |

## Submit a Recipe

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Basic submission
praisonai-ts background submit --recipe my-recipe

# With input data
praisonai-ts background submit --recipe my-recipe --input '{"query": "test"}'

# With config overrides
praisonai-ts background submit --recipe my-recipe --config '{"maxTokens": 1000}'

# With session ID
praisonai-ts background submit --recipe my-recipe --session-id session_123

# With timeout
praisonai-ts background submit --recipe my-recipe --timeout 600

# JSON output
praisonai-ts background submit --recipe my-recipe --json
```

### Submit Options

| Option | Description |
| - | - |
| `--recipe` | Recipe name to execute (required) |
| `--input, -i` | Input data as JSON string |
| `--config, -c` | Config overrides as JSON string |
| `--session-id, -s` | Session ID for conversation continuity |
| `--timeout` | Timeout in seconds (default: 300) |
| `--json` | Output JSON for scripting |

## List Tasks

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# List all tasks
praisonai-ts background list

# Filter by status
praisonai-ts background list --status running

# JSON output
praisonai-ts background list --json
```

## Check Status

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Get status
praisonai-ts background status task_abc123

# JSON output
praisonai-ts background status task_abc123 --json
```

## Cancel Task

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Cancel task
praisonai-ts background cancel task_abc123
```

## Clear Completed

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Clear completed tasks
praisonai-ts background clear

# Clear all tasks
praisonai-ts background clear --all
```

## Examples

### Complete Workflow

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# 1. Submit a recipe
praisonai-ts background submit --recipe news-monitor --json

# 2. Check status
praisonai-ts background status task_abc123

# 3. List all tasks
praisonai-ts background list

# 4. Clear completed
praisonai-ts background clear
```

### Scripting with JSON

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
#!/bin/bash

# Submit and capture task ID
RESULT=$(praisonai-ts background submit --recipe my-recipe --json)
TASK_ID=$(echo $RESULT | jq -r '.taskId')

echo "Submitted task: $TASK_ID"

# Poll for completion
while true; do
    STATUS=$(praisonai-ts background status $TASK_ID --json | jq -r '.status')
    if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
        break
    fi
    sleep 5
done

echo "Task finished: $STATUS"
```

## Related

> [card] [Background Tasks](https://praison.ai/docs/js/background-tasks.md)
>
> SDK documentation

> [card] [Async Jobs CLI](https://praison.ai/docs/js/async-jobs-cli.md)
>
> Async jobs CLI

> [card] [Agent](https://praison.ai/docs/js/agent.md)
>
> Single agent API


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.