Skip to main content
The stn files commands manage files in NATS Object Store for staging data to/from sandbox containers.

Overview

Files serve as a staging area between your local system and sandbox containers:
  1. Upload files from local filesystem
  2. Agents stage files into sandbox using sandbox_stage_file
  3. Agents process data in the sandbox
  4. Agents publish results using sandbox_publish_file
  5. Download results to local filesystem
File staging bypasses LLM context entirely—no token costs, no size limits, full binary support.

Commands

Upload

Upload a file to NATS Object Store.
stn files upload <path> [flags]
FlagDescription
--keyCustom file key (default: auto-generated)
--ttlTime-to-live (e.g., 24h, 7d)
--stationStation API URL for remote upload
stn files upload data.csv
# Output: files/f_01JGXYZ123ABC (2.4 MB)

Download

Download a file from the object store.
stn files download <file_key> [flags]
FlagShortDescription
--output-oOutput file path
--stationStation API URL
stn files download f_abc123 -o output.csv
You can use either the full key (files/f_abc123) or just the file ID (f_abc123)—it auto-expands.

List

List files in the object store.
stn files list [flags]
FlagDescription
--prefixFilter by key prefix
--jsonOutput as JSON
--stationStation API URL
stn files list
Example output:
📁 Files
Found 3 file(s):

• files/f_01JGABC123DEF
    Size: 2.4 MB | Type: text/csv | Created: 2025-01-15 10:30
• files/f_01JGXYZ789UVW
    Size: 128 KB | Type: application/json | Created: 2025-01-15 11:45
• runs/run_abc/output/summary.csv
    Size: 64 KB | Type: text/csv | Created: 2025-01-15 12:00
    Expires: 2025-01-22 12:00

Info

Show metadata for a file.
stn files info <file_key> [flags]
FlagDescription
--stationStation API URL
stn files info f_abc123
Output:
ℹ️  File Info
Key: files/f_01JGABC123DEF
Size: 2.4 MB
Content-Type: text/csv
Checksum: sha256:abc123...
Created: 2025-01-15T10:30:00Z

Delete

Delete a file from the object store.
stn files delete <file_key> [flags]
FlagShortDescription
--force-fSkip confirmation
--stationStation API URL
# With confirmation
stn files delete f_abc123

# Skip confirmation
stn files delete f_abc123 --force

File Key Conventions

Station uses a hierarchical key structure:
PatternDescriptionLifecycle
files/{file_id}User uploadsPermanent until deleted
runs/{run_id}/output/*Workflow outputsAuto-cleanup after TTL
sessions/{session_id}/*Session artifactsCleanup with session
File ID format: f_{ulid} (time-ordered, globally unique)

Local vs Remote Mode

Connects directly to NATS JetStream on the local machine.
# Uses WORKFLOW_NATS_URL (default: nats://127.0.0.1:4222)
stn files upload data.csv
stn files list
Requires NATS server running locally.

Complete Example

Process a large CSV file through a sandbox workflow:
# 1. Upload input file (5 MB CSV)
$ stn files upload sales_data.csv
📤 Upload File
 Uploaded successfully
   Key: files/f_01JGABC123DEF
   Size: 5.2 MB
   Type: text/csv

# 2. Run workflow referencing the file
$ stn workflow run csv-analyzer \
    --input '{"input_file": "files/f_01JGABC123DEF"}'

# Workflow runs:
# - Agent opens sandbox
# - Agent stages file: sandbox_stage_file(file_key="files/f_01JGABC123DEF")
# - Agent processes with Python/pandas
# - Agent publishes: sandbox_publish_file(source="output/results.csv")
# Output: "Analysis complete. Results: files/f_01JGXYZ789UVW"

# 3. Download results
$ stn files download f_01JGXYZ789UVW -o analysis_results.csv
📥 Download File
 Downloaded successfully
   Output: analysis_results.csv
   Size: 128 KB
   Type: text/csv

Configuration

Environment Variables

VariableDefaultDescription
WORKFLOW_NATS_URLnats://127.0.0.1:4222NATS server for local mode

Station Config

storage:
  bucket: "sandbox-files"           # Object Store bucket
  max_file_size: 104857600          # 100 MB max file size
  max_total_bytes: 10737418240      # 10 GB total storage
  default_ttl: 0                    # No expiration by default

Troubleshooting

Error: failed to connect to NATS at nats://127.0.0.1:4222
Fix: Ensure NATS is running or set custom URL:
export WORKFLOW_NATS_URL=nats://your-nats-server:4222
Error: file not found: files/f_abc123
Fix: Verify the file key:
stn files list --prefix files/
Error: file exceeds maximum size of 100 MB
Fix: Increase storage.max_file_size in config or split the file.

Next Steps