Docs

Introduction

A CrabTalk service is a Rust program compiled to WebAssembly, with its own database, whose tools your agents, apps and other services call over HTTP.

A service belongs to one account, yours or an org's, and is addressed as {owner}/{name}. The API is at https://api.crabtalk.ai. It is a Rust library crate written against berm-lang; A complete service is one to copy.

Have an HTTP API with an OpenAPI contract? Build a service from OpenAPI to generate its inputs, requests and tools.

A service

  • Tools. Every function marked #[tool] is a tool. A tool takes a JSON object and answers JSON.
  • Public tools. Only a tool its crab.toml gives access can be called from outside the service. See Access.
  • Data. A service keeps its data between calls in its own SQLite database. See Data.
  • Settings. A var is a setting each deployed copy holds its own value of, such as the keywords it watches. See Vars.
  • Work on its own. A #[tool(cron)] tool runs on a schedule, and a call can schedule a later call. See Crons and wakes.
  • Bounds. Each call is bounded by its tool's budget of CPU time and rows. See Budgets.

Who calls it

Caller How
Your agents, scripts and servers crab call, or HTTP with an API key Calling a tool
Your other services berm_lang::call inside a service Other services

The sandbox

A service is one WebAssembly module, pinned by its digest at deploy and compiled once. Each call runs in a fresh instance of it: the arguments go in through a syscall, and the result comes out through one.

  • Guest memory is not carried from one call to the next, nor into the calls it makes. What outlives a call goes where the host holds it: the service's values by key or its database.
  • State and database writes are committed only when the tool returns Ok. Logs are kept whatever the call ended as. A wake carries nothing from the call that scheduled it.
  • The linked Wasm imports identify the host calls a service needs; deployment is refused when the host cannot serve one. Its crab.toml restricts outbound HTTP hosts and secrets. Calls to deployed services use the target's access rules.
  • A secret is written in by the host on the way out; the service never holds its value. Another service's state and database cannot be named.
Bound
Memory 128 MiB of linear memory per instance.
CPU and rows Each call's budget.
Time A chain of calls is stopped after 60 seconds.
Depth Calls to other services nest at most 4 deep.
Arguments and result The service's buffer, 16 KiB unless set.

A tool that ran and returned Err answers failed with its message; see Calling a tool. A trap, a panic, a missing tool or a refused image is the host's error, and the call answers an error status.