neolabs-go

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0

README

neolabs-go

Shared Go foundation of the NeoLabs apps (NeoAgent, NeoRouter, NeoCloud, NeoRecall). One implementation of each protection and building block, used by every app, so the four share the same behaviour and the same security baseline.

Package What it gives you
secretbox AES-256-GCM sealed secrets at rest (enc:v1: layout)
sessionx HMAC-signed cookie sessions on a SQLite store, express-session compatible
passhash bcrypt hashes, random tokens, SHA-256 token digests, constant-time compare
secheaders baseline security headers and an ordered CSP builder
httpx JSON helpers, middleware chain, CORS, origin guard, API case guard, panic recovery
ratelimit fixed-window limiter with RateLimit-* headers
ssrf outbound HTTP client that only reaches public addresses
runtimecfg data directories (0700), private files (0600), .env loading
dbx SQLite (pure Go, FTS5), writer/reader pools, user_version migrations
testkit test helpers that never touch a real data directory
cli app CLI building blocks: --json setup event stream, terminal output and prompts, port probes, command list
cli/envfile .env read/edit with atomic private (0600) writes
cli/service per-user service: launchd agent, systemd user unit, Windows logon task, detached fallback
cli/release release channels, version order, Ed25519-signed manifests, verified HTTPS downloads, safe zip extraction
cli/oauthcli command-line OAuth sign-in: PKCE browser flow with a loopback redirect, device-code polling
googleauth access tokens from Google Application Default Credentials files (service account JWT or authorized user), no SDK
llm/openaiimages OpenAI-compatible /images/generations client (OpenAI, xAI) returning base64 images

Compatibility with the existing Node servers is tested with vectors generated from the Node implementations (sealed values, cookie signatures, bcrypt hashes, helmet and rate-limit captures).

go vet ./... && go test -race ./...

Licensed under AGPL-3.0, like the apps that use it.

Directories

Path Synopsis
Package adbx runs subprocesses with a deadline and an output cap, and wraps the adb command line for one Android device.
Package adbx runs subprocesses with a deadline and an output cap, and wraps the adb command line for one Android device.
Package apperr is the one error type the NeoLabs apps use for failures a client should see: an HTTP status, a message written for people and, when the client can branch on it, a stable code.
Package apperr is the one error type the NeoLabs apps use for failures a client should see: an HTTP status, a message written for people and, when the client can branch on it, a stable code.
Package audiox holds the small audio helpers the voice features share: 16-bit PCM, WAV wrapping and parsing, audio MIME types, and linear resampling.
Package audiox holds the small audio helpers the voice features share: 16-bit PCM, WAV wrapping and parsing, audio MIME types, and linear resampling.
Package browserx drives a Chromium browser over the DevTools protocol, with the behaviour of Playwright's page API where callers depend on it: auto-waiting for visible/enabled/editable elements, Playwright's key names and selector extensions, load states and screenshots.
Package browserx drives a Chromium browser over the DevTools protocol, with the behaviour of Playwright's page API where callers depend on it: auto-waiting for visible/enabled/editable elements, Playwright's key names and selector extensions, load states and screenshots.
cli
Package cli holds the parts every NeoLabs app CLI shares: the `--json` setup event stream, terminal output and prompts, port probes and a small command dispatcher.
Package cli holds the parts every NeoLabs app CLI shares: the `--json` setup event stream, terminal output and prompts, port probes and a small command dispatcher.
envfile
Package envfile reads and edits an app's `.env` file the way the NeoLabs CLIs always have: KEY=VALUE lines, comments and unknown lines kept in place, every write atomic and private (0600).
Package envfile reads and edits an app's `.env` file the way the NeoLabs CLIs always have: KEY=VALUE lines, comments and unknown lines kept in place, every write atomic and private (0600).
oauthcli
Package oauthcli signs a command-line program in to an OAuth provider: the browser flow with PKCE and a loopback redirect (RFC 8252), and the device authorization flow (RFC 8628) where the person types a code on the provider's site.
Package oauthcli signs a command-line program in to an OAuth provider: the browser flow with PKCE and a loopback redirect (RFC 8252), and the device authorization flow (RFC 8628) where the person types a code on the provider's site.
release
Package release is the update side shared by the NeoLabs CLIs: release channels and version ordering, Ed25519-signed manifests, and verified downloads of signed release assets from GitHub.
Package release is the update side shared by the NeoLabs CLIs: release channels and version ordering, Ed25519-signed manifests, and verified downloads of signed release assets from GitHub.
service
Package service installs a NeoLabs app as a per-user background service: a launchd agent on macOS, a systemd user unit on Linux, a logon task on Windows, and a detached process everywhere else.
Package service installs a NeoLabs app as a per-user background service: a launchd agent on macOS, a systemd user unit on Linux, a logon task on Windows, and a detached process everywhere else.
Package cron schedules work from cron expressions with the semantics of node-cron 4: five or six fields (a leading seconds field is optional), nicknames such as @daily, month and weekday names, ranges that wrap around, the L, L-n, nW, LW, nL and n#m extensions, time zones, a tolerance for late ticks, overlap prevention and random start delay.
Package cron schedules work from cron expressions with the semantics of node-cron 4: five or six fields (a leading seconds field is optional), nicknames such as @daily, month and weekday names, ranges that wrap around, the L, L-n, nW, LW, nL and n#m extensions, time zones, a tolerance for late ticks, overlap prevention and random start delay.
Package dbx opens the SQLite database every NeoLabs app uses and applies schema migrations.
Package dbx opens the SQLite database every NeoLabs app uses and applies schema migrations.
Package embedding calls the OpenAI and Google embedding APIs.
Package embedding calls the OpenAI and Google embedding APIs.
Package geoip looks IP addresses up in the data files of the npm package geoip-lite (geoip-city.dat, geoip-city6.dat, geoip-city-names.dat and the country fallbacks geoip-country.dat, geoip-country6.dat).
Package geoip looks IP addresses up in the data files of the npm package geoip-lite (geoip-city.dat, geoip-city6.dat, geoip-city-names.dat and the country fallbacks geoip-country.dat, geoip-country6.dat).
Package googleauth gets OAuth access tokens from Google Application Default Credentials files: a service account key (signed JWT exchanged for a token) or the authorized-user file `gcloud auth application-default login` writes (refresh token).
Package googleauth gets OAuth access tokens from Google Application Default Credentials files: a service account key (signed JWT exchanged for a token) or the authorized-user file `gcloud auth application-default login` writes (refresh token).
Package httpx is the shared HTTP toolkit of the NeoLabs apps: JSON helpers, middleware composition and the browser-origin protections (CORS, CSRF-style origin guard) that every app's `/api` surface relies on.
Package httpx is the shared HTTP toolkit of the NeoLabs apps: JSON helpers, middleware composition and the browser-origin protections (CORS, CSRF-style origin guard) that every app's `/api` surface relies on.
llm
Package llm is the contract between agent code and language-model providers.
Package llm is the contract between agent code and language-model providers.
anthropic
Package anthropic serves the Anthropic Messages API: Anthropic itself, any service with an Anthropic-compatible endpoint (MiniMax) and Claude Code subscriptions through OAuth.
Package anthropic serves the Anthropic Messages API: Anthropic itself, any service with an Anthropic-compatible endpoint (MiniMax) and Claude Code subscriptions through OAuth.
codex
Package codex serves OpenAI Codex models through the Responses API: the ChatGPT Codex backend (OAuth subscription) or any OpenAI-compatible Responses endpoint.
Package codex serves OpenAI Codex models through the Responses API: the ChatGPT Codex backend (OAuth subscription) or any OpenAI-compatible Responses endpoint.
google
Package google serves Gemini through the Generative Language REST API (generateContent and streamGenerateContent).
Package google serves Gemini through the Generative Language REST API (generateContent and streamGenerateContent).
oauth
Package oauth holds the credentials of an OAuth login that provider clients share.
Package oauth holds the credentials of an OAuth login that provider clients share.
ollama
Package ollama serves local models through an Ollama server (/api/chat with NDJSON streaming, /api/tags catalog, /api/pull) and its SystemOne decision models.
Package ollama serves local models through an Ollama server (/api/chat with NDJSON streaming, /api/tags catalog, /api/pull) and its SystemOne decision models.
openaichat
Package openaichat serves every provider that speaks the OpenAI Chat Completions API: OpenAI, custom OpenAI-compatible endpoints, xAI Grok (key and OAuth), NVIDIA NIM, Nous, OpenRouter, GitHub Copilot and NeoRouter.
Package openaichat serves every provider that speaks the OpenAI Chat Completions API: OpenAI, custom OpenAI-compatible endpoints, xAI Grok (key and OAuth), NVIDIA NIM, Nous, OpenRouter, GitHub Copilot and NeoRouter.
openaiimages
Package openaiimages calls an OpenAI-compatible /images/generations endpoint (OpenAI, xAI, ...) and returns base64 images.
Package openaiimages calls an OpenAI-compatible /images/generations endpoint (OpenAI, xAI, ...) and returns base64 images.
providers
Package providers builds a language-model provider by its catalog id ("openai", "anthropic", "ollama", ...), the Go counterpart of createProviderInstance.
Package providers builds a language-model provider by its catalog id ("openai", "anthropic", "ollama", ...), the Go counterpart of createProviderInstance.
systemone
Package systemone talks to SystemOne decision models: they answer typed questions about a state with probabilities instead of generating text.
Package systemone talks to SystemOne decision models: they answer typed questions about a state with probabilities instead of generating text.
transport
Package transport is the HTTP plumbing shared by the provider clients: insertion-ordered JSON objects (so request bodies match what the Node providers send byte for byte), a client that refuses internal addresses unless told otherwise, bounded response reading and a server-sent-events reader.
Package transport is the HTTP plumbing shared by the provider clients: insertion-ordered JSON objects (so request bodies match what the Node providers send byte for byte), a client that refuses internal addresses unless told otherwise, bounded response reading and a server-sent-events reader.
Package lockout throttles sensitive confirmations (current password, 2FA code) per account, not per client address, so a stolen session or a client that rotates addresses cannot guess faster than the policy allows.
Package lockout throttles sensitive confirmations (current password, 2FA code) per account, not per client address, so a stolen session or a client that rotates addresses cannot guess faster than the policy allows.
Package mcp is a small MCP client for remote servers: connect over streamable HTTP or legacy SSE, list tools, call tools, close.
Package mcp is a small MCP client for remote servers: connect over streamable HTTP or legacy SSE, list tools, call tools, close.
Package oauthclient is the HTTP and OAuth2 plumbing an app needs to talk to third-party APIs on behalf of a signed-in account: bounded JSON requests with one retry for idempotent calls, provider errors with secrets scrubbed, PKCE, authorization URLs and refresh-on-expiry for stored credentials.
Package oauthclient is the HTTP and OAuth2 plumbing an app needs to talk to third-party APIs on behalf of a signed-in account: bounded JSON requests with one retry for idempotent calls, provider errors with secrets scrubbed, PKCE, authorization URLs and refresh-on-expiry for stored credentials.
Package oauthlogin signs people in (and registers or links accounts) with an external identity provider through the OAuth 2 authorization-code flow with PKCE.
Package oauthlogin signs people in (and registers or links accounts) with an external identity provider through the OAuth 2 authorization-code flow with PKCE.
Package pairing signs a phone in with a code shown on a signed-in screen: the screen mints a short-lived single-use code, the phone scans it and swaps it for a session of that account.
Package pairing signs a phone in with a code shown on a signed-in screen: the screen mints a short-lived single-use code, the phone scans it and swaps it for a session of that account.
Package passhash holds the credential primitives every NeoLabs app shares: bcrypt password hashes (compatible with existing `$2b$` hashes), random tokens, SHA-256 token digests and constant-time comparison.
Package passhash holds the credential primitives every NeoLabs app shares: bcrypt password hashes (compatible with existing `$2b$` hashes), random tokens, SHA-256 token digests and constant-time comparison.
Package proc supervises subprocesses: it starts them in their own process group, ends a whole tree with SIGTERM then SIGKILL after a grace period, bounds the output it keeps, and reports how a process ended.
Package proc supervises subprocesses: it starts them in their own process group, ends a whole tree with SIGTERM then SIGKILL after a grace period, bounds the output it keeps, and reports how a process ended.
Package ptyx runs programs on pseudo-terminals in process: a Session owns one terminal, keeps a bounded scrollback, fans its output out to subscribers and can be resized, written to and ended.
Package ptyx runs programs on pseudo-terminals in process: a Session owns one terminal, keeps a bounded scrollback, fans its output out to subscribers and can be resized, written to and ended.
Package publicerr keeps technical failure detail away from people who are not administrators.
Package publicerr keeps technical failure detail away from people who are not administrators.
Package pwpolicy decides whether a new password is acceptable.
Package pwpolicy decides whether a new password is acceptable.
Package qrlogin signs a screen in with a signed-in phone: the screen shows a short-lived code, the phone scans and approves it, the screen claims a session.
Package qrlogin signs a screen in with a signed-in phone: the screen shows a short-lived code, the phone scans and approves it, the screen claims a session.
Package ratelimit is a fixed-window, per-client request limiter that answers exactly like express-rate-limit with `standardHeaders: true` (draft-6): RateLimit-Policy / RateLimit-Limit / RateLimit-Remaining / RateLimit-Reset, and on rejection a 429 JSON body plus Retry-After.
Package ratelimit is a fixed-window, per-client request limiter that answers exactly like express-rate-limit with `standardHeaders: true` (draft-6): RateLimit-Policy / RateLimit-Limit / RateLimit-Remaining / RateLimit-Reset, and on rejection a 429 JSON body plus Retry-After.
Package realtime is a Socket.IO v4 server (Engine.IO v4 underneath) for Go.
Package realtime is a Socket.IO v4 server (Engine.IO v4 underneath) for Go.
Package runtimecfg resolves where a NeoLabs app keeps its data and reads its environment.
Package runtimecfg resolves where a NeoLabs app keeps its data and reads its environment.
Package secheaders sets the baseline browser-hardening response headers every NeoLabs app ships (the helmet defaults the Node servers used), plus an ordered Content-Security-Policy builder so each app declares its own policy.
Package secheaders sets the baseline browser-hardening response headers every NeoLabs app ships (the helmet defaults the Node servers used), plus an ordered Content-Security-Policy builder so each app declares its own policy.
Package secretbox seals short secrets (API keys, tokens) at rest with AES-256-GCM.
Package secretbox seals short secrets (API keys, tokens) at rest with AES-256-GCM.
Package servicemail sends account emails (confirmation, password reset, sign-in and change notices) over SMTP and renders them in the NeoLabs style.
Package servicemail sends account emails (confirmation, password reset, sign-in and change notices) over SMTP and renders them in the NeoLabs style.
Package sessionx implements server-side cookie sessions that are wire- and storage-compatible with express-session + better-sqlite3-session-store, so users stay signed in across the Node → Go switch, and the other NeoLabs apps share one hardened session implementation.
Package sessionx implements server-side cookie sessions that are wire- and storage-compatible with express-session + better-sqlite3-session-store, so users stay signed in across the Node → Go switch, and the other NeoLabs apps share one hardened session implementation.
Package ssrf gives outbound HTTP clients protection against server-side request forgery: every destination IP is checked after DNS resolution and the checked address is the one that gets dialled, so DNS rebinding cannot swap in an internal address.
Package ssrf gives outbound HTTP clients protection against server-side request forgery: every destination IP is checked after DNS resolution and the checked address is the one that gets dialled, so DNS rebinding cannot swap in an internal address.
Package testkit holds helpers for tests across the NeoLabs apps.
Package testkit holds helpers for tests across the NeoLabs apps.
Package totp implements the authenticator-app second factor: RFC 6238 codes (SHA-1, 6 digits, 30 s), the otpauth URI for QR enrolment, and the one-time recovery codes.
Package totp implements the authenticator-app second factor: RFC 6238 codes (SHA-1, 6 digits, 30 s), the otpauth URI for QR enrolment, and the one-time recovery codes.
Package vm holds the generic building blocks for running QEMU guests: command-line assembly helpers, QMP, qemu-img, accelerator selection, local socket handling, orphan reclaiming, and macOS hypervisor signing.
Package vm holds the generic building blocks for running QEMU guests: command-line assembly helpers, QMP, qemu-img, accelerator selection, local socket handling, orphan reclaiming, and macOS hypervisor signing.
Package webauthnx runs passkey / security-key ceremonies for the NeoLabs apps.
Package webauthnx runs passkey / security-key ceremonies for the NeoLabs apps.
Package webextract turns a web page into compact Markdown for a language model: noise removal, readability-style main-content selection, Markdown conversion, a link list and structured-data fallbacks.
Package webextract turns a web page into compact Markdown for a language model: noise removal, readability-style main-content selection, Markdown conversion, a link list and structured-data fallbacks.
Package wsclient is the WebSocket layer of the NeoLabs apps: a client with bounded reads, timeouts and reconnect with backoff, plus the server-side accept, so apps never depend on a WebSocket library directly.
Package wsclient is the WebSocket layer of the NeoLabs apps: a client with bounded reads, timeouts and reconnect with backoff, plus the server-side accept, so apps never depend on a WebSocket library directly.
Package wsgate holds what the raw WebSocket gateways of an app have in common (wearable, desktop companion, computer display, ...): admission of an upgrade request (origin policy, per-address attempt limit, signed session) and a connection with size limits and a ping keepalive.
Package wsgate holds what the raw WebSocket gateways of an app have in common (wearable, desktop companion, computer display, ...): admission of an upgrade request (origin policy, per-address attempt limit, signed session) and a connection with size limits and a ping keepalive.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL