Basic Usage
Signature
Configuration Options
Required Properties
| Property | Type | Description |
|---|---|---|
name | string | Unique job identifier |
inputSchema | ZodShape | Zod object shape for input validation |
outputSchema | ZodShape | Zod schema for output validation |
Optional Properties
| Property | Type | Default | Description |
|---|---|---|---|
description | string | — | Job description |
id | string | name | Stable identifier for tracking |
timeout | number | 300000 | Max execution time in ms (5 min) |
retry | JobRetryConfig | — | Retry configuration |
tags | string[] | — | Categorization tags |
labels | Record<string, string> | — | Key-value labels |
hideFromDiscovery | boolean | false | Hide from list-jobs |
permissions | JobPermission[] | — | RBAC permission rules |
RetryConfig
| Property | Type | Default | Description |
|---|---|---|---|
maxAttempts | number | 3 | Maximum retry attempts |
backoffMs | number | 1000 | Initial backoff delay in ms |
backoffMultiplier | number | 2 | Backoff multiplier per attempt |
maxBackoffMs | number | 60000 | Maximum backoff delay in ms |
Permission
| Property | Type | Description |
|---|---|---|
action | 'create' | 'read' | 'update' | 'delete' | 'execute' | 'list' | Permission action |
roles | string[] | Required roles (at least one must match) |
scopes | string[] | Required OAuth scopes |
custom | (authInfo) => boolean | Promise<boolean> | Custom guard function |
Examples
Simple Job
Job with Retry
Job with Permissions
Function-Based Alternative
For simpler jobs, use thejob() function:
Context Methods
TheJobContext base class provides:
Dependency Injection
Logging and Progress
Error Handling
Related
JobContext
Context class details
JobRegistry
Job registry API
Jobs Guide
Jobs documentation
@Workflow
Define workflows