@gpu-agent/pods (0.2.4)

Published 2026-11-22 19:24:19 -07:00 by donny

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

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, 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 / 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.

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, startCost and effectivePerHour:
    • startCost is the expected first download, VAST_FIRST_DOWNLOAD_GB (10) × downloadPerGb.
    • effectivePerHour = pricePerHour + startCost / settings.defaults.maxHours. The manager sorts "cheapest first" by it, and vast.maxPricePerHour caps it.
    • A 0.2.0 client drops these fields.
  • DEFAULT_VAST_SETTINGS.diskGb is 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 others entry optionally carries consoleUrl, the provider's web console page of that pod (podConsoleUrl(provider, id)): RunPod https://console.runpod.io/pods?id=<podId>, Vast https://cloud.vast.ai/instances/ (Vast has no per-instance page). Absent while the pod is pending: 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. balance is US$ left (RunPod clientBalance, Vast credit); error is not_allowed (the key may not read it) or unavailable, with balance: 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 catalog dataCenters row and every Vast offer: providerDownMbps (what the provider states, Mbps: Vast's inet_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 newest NETWORK_MEASURED_PODS_MAX pods). 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 the PATCH answer) carries providers: 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 no provider === … branch. Absent from a 0.2.3 manager.
  • Settings gpuRules: [{match, localVolume, containerDiskGb?}] (default DEFAULT_GPU_RULES: B200/B300 have no local volume, 250 GB container disk). match is 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 localVolume and containerDiskGb (from gpuRules). Absent from a 0.2.3 manager.
  • A provider id is any short lower-case word (PROVIDER_ID_PATTERN); PROVIDERS / KnownProvider are 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 than runpod / 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
Details
npm
2026-11-22 19:24:19 -07:00
163
UNLICENSED
latest
26 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