๐ Remote Job
The execution layer. Portal dispatches work to Bifrost (local Node.js API) which spawns CLI agents.
Schema
D1 remote_jobs table
Job queue โ portal writes, Bifrost reads and executes.
idTEXT PK โ UUID
typeTEXT โ session | research |
workflow | clara | autopilot
statusTEXT โ pending | running |
done | failed | rate_limited
payloadTEXT โ JSON with job
instructions
outputTEXT โ Job output (truncated
for D1 limits)
task_idTEXT โ Linked task
(optional, set when started from TaskModal)
session_idTEXT โ Claude CLI
session ID (for resume)
retry_atTEXT โ ISO timestamp for
auto-retry (rate_limited jobs)
started_atTEXT โ When Bifrost
began execution
completed_atTEXT โ When job
finished
created_atTEXT โ ISO
timestamp
updated_atTEXT โ ISO
timestamp
Lifecycle
Full status flow with timeouts, auto-retry, and recovery: Bifrost โ Job Lifecycle
pending
โ
running
โ
done
running
โ
failed
running
โ
rate_limited
โ (auto-retry)
running
Job Types
Detailed prompt templates and payloads: Bifrost โ Job Types
| Type | What it does | CLI Backend |
|---|---|---|
session |
General-purpose interactive session | Claude / Gemini CLI |
research |
Research a topic, produce a report | Claude / Gemini CLI |
workflow |
Run a specific slash command | Claude / Gemini CLI |
clara |
Clara inbox/sweep/focus operations | Claude / Gemini CLI |
autopilot |
Long-running autonomous programs | Claude / Gemini CLI |
Architecture
Air-gapped pull model: The portal writes jobs to D1. Bifrost (local Node.js Express API,
PM2-managed) polls for pending jobs. No webhooks, no public tunnel needed for job dispatch โ Bifrost pulls
from D1 via Cloudflare API. See Troubleshooting for common issues.
Execution Flow
Portal UI
โ POST
D1 (pending)
โ poll
Bifrost API
โ spawn
CLI Agent
Real-time Output
Bifrost streams CLI output via SSE (Server-Sent Events) at /jobs/:id/stream. The portal connects
to this endpoint for live output display.
Auto-Resume
When a job hits a rate limit, Bifrost captures the session_id from the CLI's NDJSON output,
parses the reset time, and queues an auto-retry via retry-queue.js. The portal shows a countdown
timer with Cancel Retry / Resume buttons. See Job Lifecycle โ Rate Limit & Auto-Retry.
API
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/remote-jobs |
List jobs. Filter: ?status=pending, ?task_id=A82 |
POST |
/api/remote-jobs |
Create job. Body: { type, payload, task_id? } |
PATCH |
/api/remote-jobs?id=xxx |
Update status/output. { status: "done", output: "..." } |
POST |
/api/remote-jobs?heartbeat=1 |
Bifrost health heartbeat (every 30s) |