Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

REST API

lacause edited this page Mar 29, 2026 · 1 revision

REST API Reference

OCC exposes a REST API on port 4242 (configurable via REST_PORT). All responses are JSON unless noted.

Base URL: http://localhost:4242


Chains

List Chains

GET /chains

Response:

[
 {
 "name": "deep-researcher",
 "description": "Multi-perspective research engine",
 "version": "1.0",
 "stepCount": 6
 }
]

Get Chain (YAML)

GET /chains/:name

Response: Raw YAML (Content-Type: text/yaml)

Errors: 404 if chain not found

Create/Update Chain

POST /chains/:name
Content-Type: application/json (JSON object)
Content-Type: text/yaml (raw YAML string)

Response: {"ok": true}

Errors: 400 if YAML is invalid

Delete Chain

DELETE /chains/:name

Response: {"ok": true}

Errors: 404 if chain not found


Execution

Execute a Chain

POST /execute/:name
Content-Type: application/json
{
 "input": {
 "topic": "quantum computing",
 "depth": "deep"
 }
}

Response: Returns immediately (async execution)

{"executionId": "1a2b3c4d5e6f7890"}

Errors:

  • 400 — Chain not found or missing required inputs
  • 429 — Too many concurrent executions (max 5)

Stream Execution (SSE)

GET /executions/:id/stream

Response: Server-Sent Events stream

data: {"type":"execution_started","executionId":"...","chainName":"deep-researcher"}
data: {"type":"step_started","executionId":"...","stepId":"search_mainstream","label":"Mainstream perspective"}
data: {"type":"step_output","executionId":"...","stepId":"search_mainstream","chunk":"Results found..."}
data: {"type":"step_done","executionId":"...","stepId":"search_mainstream","durationMs":12345}
data: {"type":"execution_done","executionId":"...","result":"Final output...","durationMs":47000}

Event types:

Type Fields Description
execution_started executionId, chainName Chain execution began
step_started executionId, stepId, label Step began executing
step_output executionId, stepId, chunk Streaming output chunk
step_done executionId, stepId, durationMs, inputTokens, outputTokens Step completed
step_error executionId, stepId, error Step failed
step_log executionId, stepId, message, level Informational log
step_cache_hit executionId, stepId Step served from cache
step_waiting_approval executionId, stepId, prompt Gate step waiting
gate_action executionId, stepId, action, reason Gate approved/rejected
execution_done executionId, result, durationMs Chain completed
execution_error executionId, error Chain failed

Notes:

  • Heartbeat comment (: heartbeat) sent every 30s to keep connection alive
  • Late-connecting clients receive catch-up events for completed steps
  • Completed/failed executions send final event immediately then close

Get Execution Status

GET /executions/:id

Response:

{
 "id": "1a2b3c4d5e6f7890",
 "chainName": "deep-researcher",
 "status": "done",
 "input": {"topic": "quantum computing"},
 "steps": {
 "search_mainstream": {
 "stepId": "search_mainstream",
 "status": "done",
 "output": "Research results...",
 "durationMs": 12345,
 "inputTokens": 500,
 "outputTokens": 2000
 }
 },
 "result": "Final synthesized report...",
 "startedAt": "2026年03月29日T14:00:00.000Z",
 "finishedAt": "2026年03月29日T14:00:47.000Z",
 "durationMs": 47000
}

Statuses: pending, running, done, error, skipped

List Executions

GET /executions?limit=50&offset=0

Response: Array of execution summaries (without full step outputs).

Cancel Execution

DELETE /executions/:id

Kills all running processes for the execution. Steps are marked as skipped.

Response: {"ok": true}

Resume Execution

POST /executions/:id/resume

Resumes a failed execution from the last checkpoint. Completed steps are skipped.

Response: {"executionId": "...", "result": "..."}


Gates (Human-in-the-Loop)

List Pending Approvals

GET /approvals

Response:

[
 {
 "executionId": "1a2b3c4d",
 "stepId": "approval_gate",
 "chainName": "code-review",
 "prompt": "Review the report before publishing",
 "startedAt": "2026年03月29日T14:00:00.000Z"
 }
]

Approve/Reject a Gate

POST /executions/:id/approve/:stepId
Content-Type: application/json
{"approved": true}

Response: {"ok": true}


Schedules

List Schedules

GET /schedules

Get Schedule

GET /schedules/:id

Create Schedule

POST /schedules
Content-Type: application/json
{
 "label": "Daily briefing",
 "chainName": "smart-briefing",
 "input": {"topic": "tech news"},
 "cron": "0 8 * * *",
 "enabled": true
}

Response: 201 with schedule object

Update Schedule

PUT /schedules/:id
Content-Type: application/json
{"cron": "0 9 * * *", "enabled": false}

Toggle Schedule

PATCH /schedules/:id/toggle

Toggles enabled on/off.

Run Schedule Now

POST /schedules/:id/run

Response: {"executionId": "..."}

Delete Schedule

DELETE /schedules/:id

Pipelines

List Pipelines

GET /pipelines

Get Pipeline (YAML)

GET /pipelines/:name

Get Pipeline (JSON)

GET /pipelines/:name/json

Create/Update Pipeline

POST /pipelines/:name

Delete Pipeline

DELETE /pipelines/:name

Execute Pipeline

POST /pipelines/:name/execute
Content-Type: application/json
{"input": {"topic": "AI agents"}}

Response: {"executionId": "..."}

List Pipeline Executions

GET /pipeline-executions

Get Pipeline Execution

GET /pipeline-executions/:id

Chain Generation (AI)

Generate Chain from Description

POST /generate-chain
Content-Type: application/json
{"description": "Create a chain that audits code for security vulnerabilities"}

Response (questions):

{
 "status": "questions",
 "sessionId": "gen-...",
 "questions": ["What language?", "How deep?"]
}

Response (created):

{
 "status": "created",
 "chainName": "security-audit",
 "yaml": "name: security-audit\n..."
}

Generate Chain (Streaming SSE)

POST /generate-chain/stream
Content-Type: application/json
{"description": "..."}

Returns SSE stream with real-time Claude output during chain generation.


Utilities

Health Check

GET /health

Response:

{"ok": true, "version": "2.0.0", "runningExecutions": 2}

Download File

GET /download?path=/tmp/report.pdf

Serves a file as attachment. Restricted to /tmp and WORKSPACE_DIR.

Errors: 400 missing path, 403 path not allowed, 404 file not found


CORS

All origins allowed (*). Configure for production by modifying rest.ts.

Rate Limiting

Max 5 concurrent executions (configurable via MAX_CONCURRENT_EXECUTIONS env var). Returns 429 Too Many Requests when exceeded.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /