@gpu-agent/pods (0.2.4)
Installation
@gpu-agent:registry=https://gitea.dev.blueoceanswim.com/api/packages/donny/npm/npm install @gpu-agent/pods@0.2.4"@gpu-agent/pods": "0.2.4"About this package
@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 needscandidates. - A Vast pod's
idisvast-<instanceId>(vastPodId,vastInstanceId);dataCenterIdis Vast's location text (Oregon, US);cloudisSECUREfor a verified datacenter host,COMMUNITYotherwise. settings.vast(DEFAULT_VAST_SETTINGS: off, US only, reliability ≥ 0.98, verified hosts, 80 GB disk (0.2.1; 200 in 0.2.0), ≥ 500 Mbps down, no price cap); a settings row without it parses to the defaults.allowedDataCenters/deniedDataCentersstay RunPod-only.- Totals: optional
byProviderontoday,thisMonthand eachaccountbucket; 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.
0.2.1 (#225)
Additive, and compatible both ways (src/compat.test.ts keeps the published 0.2.0 schemas as
compat/schemas-0.2.0.ts).
- A Vast offer optionally carries
downloadPerGb,uploadPerGb,startCostandeffectivePerHour:startCostis the expected first download,VAST_FIRST_DOWNLOAD_GB(10) ×downloadPerGb.effectivePerHour=pricePerHour+startCost/settings.defaults.maxHours. The manager sorts "cheapest first" by it, andvast.maxPricePerHourcaps it.- A 0.2.0 client drops these fields.
DEFAULT_VAST_SETTINGS.diskGbis 80 (it was 200). A stored settings row keeps its own value.
0.2.2 (#226)
Additive, and compatible both ways (compat/schemas-0.2.1.ts is the published 0.2.1).
- Every pod view and every
othersentry optionally carriesconsoleUrl, the provider's web console page of that pod (podConsoleUrl(provider, id)): RunPodhttps://console.runpod.io/pods?id=<podId>, Vasthttps://cloud.vast.ai/instances/(Vast has no per-instance page). Absent while the pod ispending:and from a 0.2.1 manager. GET /account(pods.account()):{balances: [{provider, balance, readAt, error?}], readAt}, one entry per configured provider, cached 60 s.balanceis US$ left (RunPodclientBalance, Vastcredit);errorisnot_allowed(the key may not read it) orunavailable, withbalance: null. A 0.2.1 manager answers 404.
0.2.3 (Server #227, pick faster hosts)
Additive, and compatible both ways (compat/schemas-0.2.2.ts is the published 0.2.2).
network(placeNetworkSchema) on every RunPod catalogdataCentersrow and every Vast offer:providerDownMbps(what the provider states, Mbps: Vast'sinet_down; never on RunPod, which states no speed per data center),measuredDownMBps/measuredPods/measuredAt(what our pods' startup downloads got there, MB/s = 10^6 bytes/s, median of the newestNETWORK_MEASURED_PODS_MAXpods). Always present from a 0.2.3 manager (maybe{}); absent from a 0.2.2 one.catalog({sort: "download"}): fastest measured download first (CATALOG_SORTS). A 0.2.2 manager ignores it.podNetwork(id, {app, downMBps, samples, bytes?, seconds?}):POST /pods/:id/network, an app server reports a pod's measured startup download speed. A 0.2.2 manager answers 404.
0.2.4 (Server #239, provider facts as data)
Additive, and compatible both ways (compat/schemas-0.2.3.ts is the published 0.2.3).
GET /settings(and thePATCHanswer) carriesproviders: ProviderDescriptor[], every provider the manager knows, built-in ones first:{id, label, what, configured, enabled, capabilities: {stopResume, accountBilling}, noStopReason?, pickerKind: "stock" | "offers", disk: "volume" | "fixed", cloudLabels: {SECURE, COMMUNITY}, placeWords: {one, many}, allowedPlaces: {kind: "dataCenter" | "country", ids}}. A client shows a provider from this, with noprovider === …branch. Absent from a 0.2.3 manager.- Settings
gpuRules: [{match, localVolume, containerDiskGb?}](defaultDEFAULT_GPU_RULES: B200/B300 have no local volume, 250 GB container disk).matchis a regular expression on the GPU type id; the first match wins; no match = a volume and the settings'containerDiskGb.gpuDiskOf(id, rules, containerDiskGb)applies it.PATCH /settings {gpuRules}replaces the list. - Every RunPod catalog GPU row carries
localVolumeandcontainerDiskGb(fromgpuRules). Absent from a 0.2.3 manager. - A provider id is any short lower-case word (
PROVIDER_ID_PATTERN);PROVIDERS/KnownProviderare the built-in two. The manager answers 400 for an id it does not know. A 0.2.3 client refuses an answer that names a provider other thanrunpod/vast(none exists today).
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 |