Skip to main content
The Hogpass Node.js SDK provides a programmatic interface for configuring Docker containers to route through the Hogpass gateway, so containerized agents can access external APIs without exposing credentials.

@onecli-sh/sdk

View on npm

Requirements

Installation

Quick start

Environment variables

Instead of passing options explicitly, set environment variables:

Organization API keys

Organization-level API keys (oc_org_...) grant access across all projects in an org. Pass a projectId to specify which project to target.
The projectId can also be set via the ONECLI_PROJECT_ID environment variable. Per-operation overrides always take precedence over the constructor default.

API reference

OneCLI

Main SDK client.

Parameters


onecli.getContainerConfig(options?)

Fetch the raw container configuration from Hogpass.
Parameters Returns
Throws OneCLIRequestError if Hogpass returns a non-200 response.

onecli.applyContainerConfig(args, options?)

Fetch the container config and push Docker flags onto the args array. Returns true if config was applied, false if Hogpass was unreachable.
Parameters This method:
  1. Fetches /api/container-config from Hogpass with Bearer auth
  2. Pushes -e KEY=VALUE for each environment variable
  3. Writes the CA certificate to a temp file and mounts it with -v
  4. Builds a combined CA bundle (system CAs + Hogpass CA) so all tools trust Hogpass
  5. Adds --add-host host.docker.internal:host-gateway on Linux
If Hogpass is unreachable, returns false without mutating the args array.

Project provisioning

Project provisioning is a cloud-only feature. Calling provisionProject() against an OSS instance throws OneCLIError.

onecli.provisionProject(input?, options?)

Pre-create a user account with a project and API key. The API key works immediately. Requires admin or owner role.
Parameters Options Returns: ProvisionProjectResponse Throws OneCLIError if called against an OSS instance. Throws OneCLIRequestError with status 403 if the API key doesn’t belong to an admin/owner. See the User Provisioning guide for the full workflow.

Manual approval

onecli.configureManualApproval(callback, options?)

Register a callback that’s invoked whenever an agent request needs human approval. Starts background long-polling to the gateway. Returns a handle to stop polling.
The callback is called once per pending approval. Multiple approvals are handled concurrently, and each callback runs independently without blocking the others. If the callback throws or the decision fails to submit, the same request is retried on the next poll cycle. Callback parameter: ApprovalRequest Return value: ManualApprovalHandle
Manual approval requires a policy rule with the Manual Approval action configured in the dashboard. Without a matching rule, no requests are held for approval.

onecli.org.configureManualApproval(callback, options?)

Organization-scoped approvals require an organization API key (oc_org_...) and Hogpass Cloud or a self-hosted Enterprise instance.
Watch manual-approval requests across every project in the organization from a single handler. Identical to onecli.configureManualApproval, with two differences: the poll carries no X-Project-Id (the organization is derived from the key), and each request includes its own projectId, which the SDK uses to route the decision back to the right project.
Callback parameter: OrgApprovalRequest Every field of ApprovalRequest (above), plus: Options Return value: ManualApprovalHandle (the same stop() handle as the project handler).

Error classes

OneCLIError

General SDK error (e.g., missing API key).

OneCLIRequestError

HTTP request error with additional context.

Types

All types are exported for use in your own code:

How it works

Hogpass runs on the host machine and acts as a gateway for containerized agents. When a container makes HTTPS requests to intercepted domains (e.g. api.anthropic.com), Hogpass:
  1. Terminates TLS using a local CA certificate
  2. Inspects the request and injects real credentials (replacing placeholder tokens)
  3. Forwards the request to the upstream service
  4. Returns the response to the container
Containers never see real API keys. They only have placeholder tokens that Hogpass swaps out transparently. The SDK configures containers with the right environment variables (HTTPS_PROXY, HTTP_PROXY) and CA certificate mounts so this works automatically.