{
  "components": {
    "headers": {
      "API-Version": {
        "description": "Version of the API that served the response.",
        "schema": {
          "example": "0.2.0",
          "type": "string"
        }
      },
      "Deprecation": {
        "description": "RFC 9745 deprecation timestamp when an endpoint is scheduled for replacement.",
        "schema": {
          "type": "string"
        }
      },
      "RateLimit-Limit": {
        "description": "Maximum number of requests permitted in the current rate-limit window.",
        "schema": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "RateLimit-Policy": {
        "description": "IETF RateLimit policy declaration (for example `600;w=60`).",
        "schema": {
          "type": "string"
        }
      },
      "RateLimit-Remaining": {
        "description": "Number of requests remaining in the current rate-limit window.",
        "schema": {
          "minimum": 0,
          "type": "integer"
        }
      },
      "RateLimit-Reset": {
        "description": "Seconds until the rate-limit quota resets.",
        "schema": {
          "minimum": 0,
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before retrying after a 429 Too Many Requests response.",
        "schema": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "Sunset": {
        "description": "RFC 8594 HTTP-date after which a deprecated endpoint will be removed (at least 90 days notice).",
        "schema": {
          "type": "string"
        }
      }
    },
    "parameters": {
      "ApiVersion": {
        "description": "Requested API version label (defaults to the current stable version).",
        "in": "header",
        "name": "API-Version",
        "required": false,
        "schema": {
          "default": "0.2.0",
          "type": "string"
        }
      }
    },
    "schemas": {
      "ProblemDetails": {
        "properties": {
          "code": {
            "description": "Machine-readable error code.",
            "type": "string"
          },
          "detail": {
            "description": "Explanation of this specific error.",
            "type": "string"
          },
          "hint": {
            "description": "Actionable recovery guidance for callers.",
            "type": "string"
          },
          "status": {
            "description": "HTTP status code.",
            "type": "integer"
          },
          "title": {
            "description": "Short summary of the error.",
            "type": "string"
          },
          "type": {
            "description": "Stable URI identifying the error class.",
            "type": "string"
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "oauth2": {
        "description": "Least-privilege OAuth 2.1 scopes for authenticated operations; public read operations also accept anonymous requests.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://worker.ferrite.run/oauth/authorize",
            "scopes": {
              "apps:discover": "Discover available operations, schemas, and public metadata.",
              "apps:read": "Read-only access to declared GET and read-only operations.",
              "apps:write": "Invoke mutating operations and asynchronous jobs."
            },
            "tokenUrl": "https://worker.ferrite.run/oauth/token"
          }
        },
        "type": "oauth2"
      }
    }
  },
  "info": {
    "description": "Ferrite Worker runs JavaScript and TypeScript that a program or an AI assistant wrote, with no access to anything except what each request lends it. Use it to replace a long exchange of tool calls with one program that reads, reshapes and returns only the answer. Its limits, the access a run can be lent and a set of tested example requests are public; running code needs the worker's client token.\n\nVersioning and deprecation policy: endpoints are versioned via URL path and the optional `API-Version` header (current version: 0.2.0). Deprecated endpoints emit RFC 9745 `Deprecation` and RFC 8594 `Sunset` response headers at least 90 days before removal. Rate limits are communicated via IETF `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset`, `RateLimit-Policy`, and `Retry-After` headers.",
    "title": "ferrite-worker",
    "version": "0.2.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/api/capabilities": {
      "get": {
        "operationId": "list_capabilities",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "bindings": {
                      "description": "binding names a store or file store grant can use",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "capabilities": {
                      "description": "every field of caps that lends access",
                      "items": {
                        "additionalProperties": false,
                        "properties": {
                          "field": {
                            "description": "the field of caps",
                            "type": "string"
                          },
                          "grants": {
                            "description": "what it allows",
                            "type": "string"
                          },
                          "used_as": {
                            "description": "how the program reaches it",
                            "type": "string"
                          }
                        },
                        "required": [
                          "field",
                          "grants",
                          "used_as"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "egress_hosts": {
                      "description": "hosts that can be lent",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "fetch_methods": {
                      "description": "HTTP methods fetch delivers",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "bindings",
                    "capabilities",
                    "egress_hosts",
                    "fetch_methods"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Success",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/API-Version"
              },
              "Deprecation": {
                "$ref": "#/components/headers/Deprecation"
              },
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Sunset": {
                "$ref": "#/components/headers/Sunset"
              }
            }
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Invalid request parameters or body (RFC 9457 problem details)"
          },
          "404": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Resource not found (RFC 9457 problem details)"
          },
          "429": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Rate limit exceeded; wait Retry-After seconds before retrying",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "default": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Error (RFC 9457 problem details)"
          }
        },
        "summary": "List everything a run can be lent: stores, file stores, in-memory files, outbound hosts and host operations. Use it to write the caps object of a run_code request. Returns each field with what it grants, how the program uses it, and the hosts and bindings that can be named.",
        "x-idempotent": true,
        "x-read-only": true
      }
    },
    "/api/examples": {
      "get": {
        "operationId": "list_examples",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "examples": {
                      "description": "every example",
                      "items": {
                        "additionalProperties": false,
                        "properties": {
                          "description": {
                            "description": "what it is lent and why",
                            "type": "string"
                          },
                          "id": {
                            "description": "the identifier get_example takes",
                            "type": "string"
                          },
                          "title": {
                            "description": "what the program does",
                            "type": "string"
                          }
                        },
                        "required": [
                          "description",
                          "id",
                          "title"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "examples"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Success",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/API-Version"
              },
              "Deprecation": {
                "$ref": "#/components/headers/Deprecation"
              },
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Sunset": {
                "$ref": "#/components/headers/Sunset"
              }
            }
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Invalid request parameters or body (RFC 9457 problem details)"
          },
          "404": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Resource not found (RFC 9457 problem details)"
          },
          "429": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Rate limit exceeded; wait Retry-After seconds before retrying",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "default": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Error (RFC 9457 problem details)"
          }
        },
        "summary": "List the worked examples. Use it when you are about to write a program and want a request that is known to work as a starting point. Returns the identifier, title and description of each example, in reading order.",
        "x-idempotent": true,
        "x-read-only": true
      }
    },
    "/api/examples/{id}": {
      "get": {
        "operationId": "get_example",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "description": "the identifier, from list_examples",
              "examples": [
                "group-orders"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "description": {
                      "description": "what it is lent and why",
                      "type": "string"
                    },
                    "id": {
                      "description": "the identifier get_example takes",
                      "type": "string"
                    },
                    "reply": {
                      "description": "what the reply contains",
                      "properties": {
                        "logs": {
                          "description": "console lines",
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "output": {
                          "description": "the returned value"
                        },
                        "tool_calls": {
                          "description": "outside calls made",
                          "type": "integer"
                        }
                      },
                      "required": [
                        "output",
                        "logs",
                        "tool_calls"
                      ],
                      "type": "object"
                    },
                    "request": {
                      "description": "the run_code request, without client_token",
                      "type": "object"
                    },
                    "title": {
                      "description": "what the program does",
                      "type": "string"
                    }
                  },
                  "required": [
                    "description",
                    "id",
                    "reply",
                    "request",
                    "title"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Success",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/API-Version"
              },
              "Deprecation": {
                "$ref": "#/components/headers/Deprecation"
              },
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Sunset": {
                "$ref": "#/components/headers/Sunset"
              }
            }
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Invalid request parameters or body (RFC 9457 problem details)"
          },
          "404": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Resource not found (RFC 9457 problem details)"
          },
          "429": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Rate limit exceeded; wait Retry-After seconds before retrying",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "default": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Error (RFC 9457 problem details)"
          }
        },
        "summary": "Read one worked example in full. Use it to copy a request shape for run_code and to see exactly what comes back. Returns the request without a client token, and the output, console lines and call count its reply contains.",
        "x-idempotent": true,
        "x-read-only": true
      }
    },
    "/api/limits": {
      "get": {
        "operationId": "get_limits",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "concurrent_runs": {
                      "description": "runs one instance executes side by side",
                      "type": "integer"
                    },
                    "exit_codes": {
                      "description": "every exit code",
                      "items": {
                        "additionalProperties": false,
                        "properties": {
                          "code": {
                            "description": "exit_code in the reply",
                            "type": "integer"
                          },
                          "meaning": {
                            "description": "why the run ended",
                            "type": "string"
                          }
                        },
                        "required": [
                          "code",
                          "meaning"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "fuel": {
                      "additionalProperties": false,
                      "description": "interpreter instructions",
                      "properties": {
                        "default": {
                          "description": "used when the request says nothing",
                          "type": "integer"
                        },
                        "maximum": {
                          "description": "the most a request is given",
                          "type": "integer"
                        }
                      },
                      "required": [
                        "default",
                        "maximum"
                      ],
                      "type": "object"
                    },
                    "memory_bytes": {
                      "description": "memory one run can use",
                      "type": "integer"
                    },
                    "output_bytes": {
                      "additionalProperties": false,
                      "description": "console bytes kept before truncation",
                      "properties": {
                        "default": {
                          "description": "used when the request says nothing",
                          "type": "integer"
                        },
                        "maximum": {
                          "description": "the most a request is given",
                          "type": "integer"
                        }
                      },
                      "required": [
                        "default",
                        "maximum"
                      ],
                      "type": "object"
                    },
                    "outside_calls": {
                      "additionalProperties": false,
                      "description": "calls to stores, files and hosts",
                      "properties": {
                        "default": {
                          "description": "used when the request says nothing",
                          "type": "integer"
                        },
                        "maximum": {
                          "description": "the most a request is given",
                          "type": "integer"
                        }
                      },
                      "required": [
                        "default",
                        "maximum"
                      ],
                      "type": "object"
                    },
                    "replay_hours": {
                      "description": "how long a reply is kept to answer a redelivered request",
                      "type": "integer"
                    },
                    "requests_per_minute": {
                      "description": "requests accepted on each route from all callers together",
                      "type": "integer"
                    },
                    "run_ms": {
                      "description": "how long one run may take",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "concurrent_runs",
                    "exit_codes",
                    "fuel",
                    "memory_bytes",
                    "output_bytes",
                    "outside_calls",
                    "replay_hours",
                    "requests_per_minute",
                    "run_ms"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Success",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/API-Version"
              },
              "Deprecation": {
                "$ref": "#/components/headers/Deprecation"
              },
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Sunset": {
                "$ref": "#/components/headers/Sunset"
              }
            }
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Invalid request parameters or body (RFC 9457 problem details)"
          },
          "404": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Resource not found (RFC 9457 problem details)"
          },
          "429": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Rate limit exceeded; wait Retry-After seconds before retrying",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "default": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Error (RFC 9457 problem details)"
          }
        },
        "summary": "Read every limit a run is held to: instructions, memory, time, output, outside calls and requests per minute. Use it before sending a program that loops, logs a lot or makes many calls. Returns each default and maximum, and the meaning of every exit code.",
        "x-idempotent": true,
        "x-read-only": true
      }
    },
    "/api/service": {
      "get": {
        "operationId": "get_service",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "accepting_runs": {
                      "description": "true when the engine is loaded and a client token is configured",
                      "type": "boolean"
                    },
                    "engine": {
                      "description": "the JavaScript engine and how it is executed",
                      "type": "string"
                    },
                    "languages": {
                      "description": "values of lang",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "name": {
                      "description": "the service",
                      "type": "string"
                    },
                    "run": {
                      "additionalProperties": false,
                      "properties": {
                        "authentication": {
                          "description": "what a run needs",
                          "type": "string"
                        },
                        "method": {
                          "description": "the HTTP method",
                          "type": "string"
                        },
                        "path": {
                          "description": "the path on this origin",
                          "type": "string"
                        }
                      },
                      "required": [
                        "authentication",
                        "method",
                        "path"
                      ],
                      "type": "object"
                    },
                    "version": {
                      "description": "the version of this API",
                      "type": "string"
                    }
                  },
                  "required": [
                    "accepting_runs",
                    "engine",
                    "languages",
                    "name",
                    "run",
                    "version"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Success",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/API-Version"
              },
              "Deprecation": {
                "$ref": "#/components/headers/Deprecation"
              },
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Sunset": {
                "$ref": "#/components/headers/Sunset"
              }
            }
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Invalid request parameters or body (RFC 9457 problem details)"
          },
          "404": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Resource not found (RFC 9457 problem details)"
          },
          "429": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Rate limit exceeded; wait Retry-After seconds before retrying",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "default": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Error (RFC 9457 problem details)"
          }
        },
        "summary": "Read what this worker is and whether it can run code now. Use it as a health check, or before the first run to learn the engine and where to send requests. Returns the version, the engine, the run endpoint and whether runs are being accepted.",
        "x-idempotent": true,
        "x-read-only": true
      }
    },
    "/run/": {
      "post": {
        "operationId": "run_code",
        "parameters": [
          {
            "description": "Recorded for tracing. This operation is not declared idempotent, so a retry may run again.",
            "in": "header",
            "name": "idempotency-key",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "caps": {
                    "description": "what the program may use; everything left out is refused",
                    "properties": {
                      "blobs": {
                        "description": "file stores the program may use through env.blob(name)",
                        "items": {
                          "properties": {
                            "binding": {
                              "description": "the worker's own binding it stands for",
                              "enum": [
                                "agent-data",
                                "agent-blobs"
                              ],
                              "type": "string"
                            },
                            "name": {
                              "description": "the name the program uses for it",
                              "type": "string"
                            },
                            "prefix": {
                              "description": "the key prefix the program is confined to",
                              "type": "string"
                            },
                            "read": {
                              "description": "allow reads; true when left out",
                              "type": "boolean"
                            },
                            "transparent": {
                              "description": "hide the prefix, so the program sees keys relative to it",
                              "type": "boolean"
                            },
                            "write": {
                              "description": "allow writes; false when left out",
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "name",
                            "binding"
                          ],
                          "type": "object"
                        },
                        "type": "array"
                      },
                      "egress_hosts": {
                        "description": "hosts the program may fetch, from list_capabilities",
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      },
                      "files": {
                        "description": "in-memory files for this run",
                        "items": {
                          "properties": {
                            "contents": {
                              "description": "the text of the file",
                              "type": "string"
                            },
                            "path": {
                              "description": "the name ferrite.readFile takes",
                              "type": "string"
                            }
                          },
                          "required": [
                            "path",
                            "contents"
                          ],
                          "type": "object"
                        },
                        "type": "array"
                      },
                      "limits": {
                        "description": "budgets for this run, each held to the maximum in get_limits",
                        "properties": {
                          "fuel": {
                            "description": "interpreter instructions",
                            "type": "integer"
                          },
                          "max_output_bytes": {
                            "description": "console bytes kept",
                            "type": "integer"
                          },
                          "max_tool_calls": {
                            "description": "calls to stores, files and hosts",
                            "type": "integer"
                          }
                        },
                        "type": "object"
                      },
                      "stores": {
                        "description": "key-value stores the program may use through env.store(name)",
                        "items": {
                          "properties": {
                            "binding": {
                              "description": "the worker's own binding it stands for",
                              "enum": [
                                "agent-data",
                                "agent-blobs"
                              ],
                              "type": "string"
                            },
                            "name": {
                              "description": "the name the program uses for it",
                              "type": "string"
                            },
                            "prefix": {
                              "description": "the key prefix the program is confined to",
                              "type": "string"
                            },
                            "read": {
                              "description": "allow reads; true when left out",
                              "type": "boolean"
                            },
                            "transparent": {
                              "description": "hide the prefix, so the program sees keys relative to it",
                              "type": "boolean"
                            },
                            "write": {
                              "description": "allow writes; false when left out",
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "name",
                            "binding"
                          ],
                          "type": "object"
                        },
                        "type": "array"
                      },
                      "tools": {
                        "description": "operation names ferrite.callTool may use, such as store.get or fetch",
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      }
                    },
                    "type": "object"
                  },
                  "client_token": {
                    "description": "the worker's client token, issued by its operator; the program never sees it",
                    "examples": [
                      "YOUR_CLIENT_TOKEN"
                    ],
                    "type": "string"
                  },
                  "code": {
                    "description": "the body of an async function: return the result, and use await at the top level",
                    "examples": [
                      "return [3, 4, 5].map((n) => n * n);"
                    ],
                    "type": "string"
                  },
                  "input": {
                    "description": "any JSON value, available to the program as the global input",
                    "examples": [
                      {
                        "a": 6,
                        "b": 7
                      }
                    ],
                    "type": [
                      "object",
                      "array",
                      "string",
                      "number",
                      "boolean",
                      "null"
                    ]
                  },
                  "lang": {
                    "description": "ts or typescript removes type annotations before the run; js when left out",
                    "enum": [
                      "js",
                      "ts",
                      "typescript"
                    ],
                    "type": "string"
                  },
                  "now_ms": {
                    "description": "the fixed time the program sees, in epoch milliseconds; the time of the request when left out",
                    "type": "integer"
                  }
                },
                "required": [
                  "client_token",
                  "code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "execution_state": {
                      "description": "only after a deadline: whether any outside call had already completed",
                      "enum": [
                        "not_dispatched",
                        "partial_do_not_retry_blindly"
                      ],
                      "type": "string"
                    },
                    "exit_code": {
                      "description": "0 for success; get_limits explains the others",
                      "type": "integer"
                    },
                    "logs": {
                      "description": "console lines, in order",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "ms": {
                      "description": "always 0, because a run cannot observe real time",
                      "type": "integer"
                    },
                    "ok": {
                      "description": "true when the program finished without an error",
                      "type": "boolean"
                    },
                    "output": {
                      "description": "the value the program returned",
                      "type": [
                        "object",
                        "array",
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    },
                    "rounds": {
                      "description": "stretches of execution, one more than tool_calls",
                      "type": "integer"
                    },
                    "stderr": {
                      "description": "an uncaught error and its stack, or the reason a run was refused",
                      "type": "string"
                    },
                    "stdout": {
                      "description": "other output of the engine",
                      "type": "string"
                    },
                    "tool_calls": {
                      "description": "calls the program made to stores, files and hosts",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "ok",
                    "output",
                    "logs",
                    "stdout",
                    "stderr",
                    "exit_code",
                    "tool_calls",
                    "rounds",
                    "ms"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Success",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/API-Version"
              },
              "Deprecation": {
                "$ref": "#/components/headers/Deprecation"
              },
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Sunset": {
                "$ref": "#/components/headers/Sunset"
              }
            }
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Invalid request parameters or body (RFC 9457 problem details)"
          },
          "404": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Resource not found (RFC 9457 problem details)"
          },
          "429": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Rate limit exceeded; wait Retry-After seconds before retrying",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "default": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Error (RFC 9457 problem details)"
          }
        },
        "summary": "Run a JavaScript or TypeScript program with only the access this request lends it. Use it when one short program can do the work of many separate calls, or when code from a model has to run safely; read list_capabilities first. Needs the worker's client token. Returns the program's value, its console lines, an exit code and the number of calls it made.",
        "x-idempotent": false,
        "x-read-only": false
      }
    }
  },
  "security": [
    {},
    {
      "oauth2": [
        "apps:discover",
        "apps:read",
        "apps:write"
      ]
    }
  ],
  "servers": [
    {
      "url": "https://worker.ferrite.run"
    }
  ],
  "x-agent-card": "https://worker.ferrite.run/.well-known/agent-card.json",
  "x-ard-catalog": "https://worker.ferrite.run/.well-known/ard.json",
  "x-llms-txt": "https://worker.ferrite.run/llms.txt",
  "x-mcp-endpoint": "https://worker.ferrite.run/mcp",
  "x-webmcp": "https://worker.ferrite.run/.well-known/webmcp.js"
}