- Zero runtime dependencies. Built on the platform
fetch, so it runs on Node 20 or later, Bun, Deno, and modern browsers and workers. - Faithful to the API contract. Types are transcribed from the OpenAPI spec vendored in the repo and drift-checked nightly against the deployed contract. Admin consoles, auth flows, SCIM, and billing are intentionally out of scope.
- The CLI is built on it. Everything the Coconut CLI does goes through this client.
View on npm
The
coconut-sdk package, published under Apache-2.0.Source on GitHub
lovelybunch/coconut-sdk, including the OpenAPI spec and six runnable examples.Install
Quickstart
Surface map
The client is one configured HTTP transport shared by a set of resource namespaces.
Two methods live on the client itself:
coco.health() is an unauthenticated liveness probe, and coco.session() returns the resolved principal for the configured credential.
Metadata filters
Metadata queries take an array of filters, AND-ed together. Each filter is{ key, op, value }.
The
in and not-in operators arrived in coconut-sdk 0.2.0. If you’re pinned to an earlier 0.1.x range, the MetadataFilter type won’t include them, and a 0.x caret range does not reach the next minor on its own.
Concurrency model
Page writes use the API’s optimistic concurrency. Updates sendIf-Match: W/"<version>". A missing version returns 428 (CocoPreconditionRequiredError), and a stale one returns 412 (CocoVersionConflictError). Re-read and retry, or use pages.upsert(), which does that loop for you. The same convention applies to agent tasks and agent instructions.
Errors
Every non-2xx response becomes a typed error. All of them extendCocoApiError, which carries status, reasonCode, nextSteps, and the parsed body.
Transient failures (network errors, 429, 502, 503, 504) are retried with backoff on GETs only. Writes are never retried automatically.
Auth options
Space agents from code
The agents namespace lets a script hand work to the deployment’s own agent instead of running a model loop itself.runTaskAndWait queues a run and polls until it reaches a terminal status. Use runTask and waitForRun separately if you want to hold the run id in between.
Next steps
SDK examples
Six runnable scripts: pull, write back, visualize, chat with a space, blame, and gardener.
CLI
The same surface from a shell, with auth flows and profiles handled for you.
HTTP API
The routes underneath every SDK method.
Connect your agents
MCP, for clients that speak it natively instead of calling the SDK.