ScriptRuns

Runs JavaScript on the account's computer with bun, with no agent turn, as the key's owner (account admins only; team keys cannot). tools.<namespace>.<function>(args) calls the Crevio API and connected integrations, and the script's last expression is its result. args reach the script as the global args (and process.argv). Files written into the directory named by the global outputDir (20 at most, 50 MB each) come back as artifacts. A call that needs approval does not run: it resolves to {pending: true, draft_id, approval}, the script carries on, and the run lists it in approvals and pending_approval_ids. Approving it (POST /approvals/{id}/approve) runs that one frozen call, never the script again. 200 when it finished within wait_seconds, 202 otherwise: poll GET /script_runs/{id}. At most 4 runs in flight per user and 8 per account (429). Needs the scripts scope.

post/script_runs

Request

  • Base URL
    https://api.crevio.co/v1
  • Auth
    API key in header Authorization

Headers

Idempotency-Key, string

Makes this write safe to retry: a repeat with the same key replays the first response instead of creating a second resource. Scoped to the account, remembered for 24 hours; reusing a key with a different payload is an error.

Request body

object required
code, string required

The JavaScript to run.

args, string[]

Values the script reads from the global args.

timeout_seconds, integer

How long the script may run.

wait_seconds, integer

Hold the response until the script finishes, up to this many seconds.

Response

The script finished within wait_seconds

ScriptRun required
object, string required
id, string required
status, 'queued' | 'in_progress' | 'completed' | 'failed' | 'cancelled' | 'timed_out' required
result, unknown required
result_truncated, boolean required

The value was too large to return, so result holds the start of its JSON text instead.

output, string nullable required

What the script printed: its start and end when long, with the cut marked.

error, string nullable required
args, string[] required
calls, object[] required

Every tool call the script made, in order: {role, status, read_only, error_code, approval_id}. A 202 call did not run and names its approval.

approvals, Approval[] required

What the script's gated calls froze, as each stands now. Approving one runs that call, never the script again.

pending_approval_ids, string[] required

Approvals still waiting for a decision: POST /approvals/{id}/approve or /deny.

artifacts, Artifact[] required

Files the script wrote to outputDir.

timeout_seconds, integer required
started_at, string nullable required
completed_at, string nullable required
created_at, string date-time required

Changes

    • info

      added the required property approvals/items/details to the response with the status

    • info

      added the required property approvals/items/details to the response with the status

    • info

      added the required property approvals/items/request to the response with the status

    1 more change in this revision