Skip to content

Docs · Hosted deployment

From a colony to a hosted workload.

The environment is where work is coordinated; the host is where colony code runs. Use the open-source Mandible SDK to define the workload and @mandible-ai/cloud to run it on the hosted platform.

1. Get access and prepare a project

  • Use Node.js 20 or later, an ES-module project ("type": "module" in package.json), and an approved hosted account. Sign in at mandible.cloud through the existing console sign-in flow.
  • Create or choose a project, note its project ID, and create an API key with the deployment permissions that project needs.
  • Set MANDIBLE_API_KEY and MANDIBLE_PROJECT_ID in your local shell or secret manager. Do not put credential values in code, browser storage, or a committed configuration file.
  • For the GitHub example below, add GITHUB_TOKEN to the project's secrets with access to the chosen repository. The environment declares that secret by name; the runner retrieves it in the workload.

Console sign-in identifies a person. The deployment API key authorizes tooling. Neither replaces the short-lived workload identity issued to a running sandbox.

2. Install the two packages

@mandible-ai/mandible is public on npm. @mandible-ai/cloud is distributed through GitHub Packages; obtain repository/package access during onboarding. Use a GitHub package token with read:packages.

Your local .npmrc should reference an environment variable, never a literal token:

//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
npm install @mandible-ai/mandible
npm install @mandible-ai/cloud --registry=https://npm.pkg.github.com
npm install --save-dev tsx

Do not redirect the entire @mandible-ai scope to GitHub Packages: that would also redirect the public SDK. Keep the registry URLs in your lockfile and use npm ci for repeatable installs. The local package token and the project's repository token have different purposes, even though both use the name GITHUB_TOKEN.

3. Define and deploy the workload

Save these files together as deploy.ts and worker.ts. Replace the example repository and run from that directory. Module references let the hosted SDK bundle the worker rather than relying on a local closure. This example observes issue signals and logs their IDs; it does not propose or apply changes.

import { mandible, GitHubEnvironment } from "@mandible-ai/mandible";
import { cloud } from "@mandible-ai/cloud";

const apiKey = process.env.MANDIBLE_API_KEY;
const project = process.env.MANDIBLE_PROJECT_ID;
if (!apiKey || !project) {
  throw new Error("Set MANDIBLE_API_KEY and MANDIBLE_PROJECT_ID before deploying.");
}

// Replace the example repository with one your project is allowed to access.
// Store GITHUB_TOKEN in the project's secrets, not in this file.
const env = new GitHubEnvironment({ owner: "your-org", repo: "your-repo" });

const host = await mandible("hosted-observer")
  .environment(env)
  .host(cloud({ apiKey, project }))
  .colony("observer", {
    module: "./worker.ts",
    export: "worker",
  })
  .start();

// Open the hosted console. Sign-in is separate from the deployment API key.
await host.dashboard({ open: true });

// When the workload is no longer needed:
// await host.stop();
npx tsx deploy.ts

Run this only when you intend to create hosted resources. An exclusive or leased claim coordinates workers; it is not an authorization grant. Governed actions still go through the platform's policy and controller boundary.

4. Inspect the run and stop when finished

Open the project in the console. Check deployment state, workload identity, CPU, memory, network I/O, and logs. Confirm the worker observes the intended repository before adding capabilities or increasing concurrency. Use the console to stop the workload, or call host.stop() from your deployment program when the work is finished.