@gpu-agent/pods (0.2.0)

Published 2026-11-06 18:39:14 -07:00 by donny

Installation

@gpu-agent:registry=https://gitea.dev.blueoceanswim.com/api/packages/donny/npm/
npm install @gpu-agent/pods@0.2.0
"@gpu-agent/pods": "0.2.0"

About this package

Typed client of the pod manager (apps/pod-manager): zod schemas of every route of docs/DESIGN.md §11.5 and a fetch client the ImageLab and Map Maker servers import.

@gpu-agent/pods

The typed client of the pod manager (donny/gpu-agent apps/pod-manager, docs/DESIGN.md §11): zod schemas of every route of §11.5 and a small fetch client. The ImageLab and Map Maker servers import it to proxy /pods/* (ImageLab, super-admin) and /api/pods/* (Map Maker, admins) to the one shared service on .10. Depends on zod only; runs under Bun and Node.

# .npmrc of the consuming repo
@gpu-agent:registry=https://gitea.dev.blueoceanswim.com/api/packages/donny/npm/
//gitea.dev.blueoceanswim.com/api/packages/donny/npm/:_authToken=${GITEA_NPM_TOKEN}
bun add @gpu-agent/pods@<version>

Use

import { PodManagerClient, PodManagerError } from "@gpu-agent/pods";

const pods = new PodManagerClient({ baseUrl: process.env.POD_MANAGER_URL!, token: process.env.POD_MANAGER_TOKEN! });

const catalog = await pods.catalog();                       // allowed DCs only, 60 s cache; { fresh: "1" } re-reads
try {
  const pod = await pods.startPod(
    {
      candidates: [{ gpuTypeId: "NVIDIA GeForce RTX 4090", dataCenterIds: ["US-CA-2", "US-IL-1"] }],
      links: ["lab"],
      modelPacks: ["image"],
      maxHours: 8,
      startedBy: { user: session.user.email },
    },
    { idempotencyKey: req.header("Idempotency-Key") },        // pass the browser's key through
  );
} catch (e) {
  if (e instanceof PodManagerError && e.code === "limit_reached") { /* e.details: { limit, value, current } */ }
  if (e instanceof PodManagerError && e.code === "no_capacity") { /* e.details: { tried: [...] } */ }
}

const { pods: mine, others } = await pods.listPods({ all: true });
await pods.stopPod(id); await pods.resumePod(id); await pods.terminatePod(id);
await pods.extendPod(id, { maxHours: 12 });
await pods.totals({ bucket: "day" });
await pods.settings(); await pods.patchSettings({ limits: { dailyUsd: { action: "turnOff" } }, changedBy: { user } });
await pods.settingsAudit(50);
await pods.limits();                                        // the warning banner: { limits: [...], blocked }

// One SSE stream per app server; relay pod.changed / catalog.changed into the browser realtime.
await pods.events((event) => { if (event.type === "pod.changed") broadcast(event.pod); }, abort.signal);

Every 4xx/5xx is a PodManagerError { status, code, message, details } with the manager's error code (unauthorized, forbidden, not_found, limit_reached, no_capacity, data_center_not_allowed, placed_outside_allow_list, runpod_error, app_unreachable, not_supported_on_provider, ...).

Providers (0.2.0)

0.2.0 adds Vast.ai next to RunPod, additively: every shape gains provider ("runpod" | "vast"), which defaults to runpod, so a 0.1.x client parses a 0.2.0 manager and the other way round (src/compat.test.ts keeps the 0.1.2 schemas and checks both directions).

const vast = await pods.catalog({ provider: "vast" });     // vast.offers: [{ id, machineId, gpu, pricePerHour, reliability, location, ... }]
await pods.startPod({ provider: "vast", offerIds: [vast.offers![0]!.id], links: ["lab"], startedBy: { user } });
  • A Vast start needs offerIds (1..8, tried in order); a RunPod start needs candidates.
  • A Vast pod's id is vast-<instanceId> (vastPodId, vastInstanceId); dataCenterId is Vast's location text (Oregon, US); cloud is SECURE for a verified datacenter host, COMMUNITY otherwise.
  • settings.vast (DEFAULT_VAST_SETTINGS: off, US only, reliability ≥ 0.98, verified hosts, 200 GB disk, ≥ 500 Mbps down, no price cap); a settings row without it parses to the defaults. allowedDataCenters / deniedDataCenters stay RunPod-only.
  • Totals: optional byProvider on today, thisMonth and each account bucket; the daily and monthly limits count both providers.
  • 409 not_supported_on_provider (details: {provider, action}): the action does not exist on the pod's provider, e.g. stop on Vast.

Release

Bump version here, commit to main, then git tag pods-v<version> && git push origin pods-v<version> (.gitea/workflows/publish.yml).

Dependencies

Dependencies

ID Version
zod ^4.6.7
Details
npm
2026-11-06 18:39:14 -07:00
18
UNLICENSED
17 KiB
Assets (1)
Versions (8) View all
0.2.4 2026-11-22
0.2.3 2026-11-06
0.2.2 2026-11-06
0.2.1 2026-11-06
0.2.0 2026-11-06