atuin: add atuin-ai-server for the CLI's ai feature #1

Open
litelotus wants to merge 7 commits from feat/atuin-ai-server into main
Owner

Adds atuin-ai-server alongside the existing atuin server: a stateless backend for the CLI's ai feature that speaks the Atuin AI protocol and fronts an OpenAI-compatible chat endpoint.

What lands

  • atuin-ai-config ConfigMap holding config.toml
  • atuin-ai-secret Opaque Secret holding the CLI bearer token
  • atuin-ai-deployment (image pinned by digest) + atuin-ai-service:8080
  • atuin-ai private Pangolin resource on site testy-bush-rat
  • No PVC: the server keeps no accounts, no database, no history

Decisions you may want to overrule

  • Backend: the in-cluster LiteLLM gateway (litellm.agents.svc.cluster.local:4000/v1), not ollama directly, so keys/spend/fallbacks stay in one place.
  • One model exposed: qwen3-30b-a3b. The protocol drives tools on every turn, so a model without tool calling cannot work here.
  • Token: generated by Pulumi (random.RandomPassword, 48 chars, no specials) and stored in a Pulumi-owned Secret, consumed via secretKeyRef. Read it back with pulumi stack output --show-secrets "atuin-ai auth token". Replacing that random resource invalidates every client - treat a Length change as a cutover.
  • LiteLLM key: read from OpenBao litellm/env at deploy time, so pulumi up needs VAULT_ADDR + VAULT_TOKEN.
  • Private, not public: PrivateResource on the site that fronts this cluster. No public FQDN, no forward-auth, no health-check question (the site-resource surface has none). Scheme is set to http because it defaults to https and this service speaks plain HTTP in-cluster. Clients need the Pangolin client running to resolve the hostname.
  • Probes are TCP: both routes are bearer-gated, so an HTTP probe would have to treat 401 as healthy.

After deploy

pulumi stack output --show-secrets "atuin-ai auth token"

That value goes into agenix (secrets/atuin-ai-token.age) and reaches the CLI as ATUIN_AI__API_TOKEN, which atuin layers over config.toml - so the token never enters programs.atuin.settings or the nix store.

Note

First commit (9cd4efe) commits the previously-uncommitted Pangolin work as the deployed state - verified live: atuin.litelot.us answers 200 when resolved straight at the edge IP.

Adds `atuin-ai-server` alongside the existing atuin server: a stateless backend for the CLI's `ai` feature that speaks the Atuin AI protocol and fronts an OpenAI-compatible chat endpoint. ## What lands - `atuin-ai-config` ConfigMap holding `config.toml` - `atuin-ai-secret` Opaque Secret holding the CLI bearer token - `atuin-ai-deployment` (image pinned by digest) + `atuin-ai-service:8080` - `atuin-ai` **private** Pangolin resource on site `testy-bush-rat` - No PVC: the server keeps no accounts, no database, no history ## Decisions you may want to overrule - **Backend**: the in-cluster LiteLLM gateway (`litellm.agents.svc.cluster.local:4000/v1`), not ollama directly, so keys/spend/fallbacks stay in one place. - **One model exposed**: `qwen3-30b-a3b`. The protocol drives tools on every turn, so a model without tool calling cannot work here. - **Token**: generated by Pulumi (`random.RandomPassword`, 48 chars, no specials) and stored in a Pulumi-owned Secret, consumed via `secretKeyRef`. Read it back with `pulumi stack output --show-secrets "atuin-ai auth token"`. Replacing that random resource invalidates every client - treat a Length change as a cutover. - **LiteLLM key**: read from OpenBao `litellm/env` at deploy time, so `pulumi up` needs `VAULT_ADDR` + `VAULT_TOKEN`. - **Private, not public**: `PrivateResource` on the site that fronts this cluster. No public FQDN, no forward-auth, no health-check question (the site-resource surface has none). `Scheme` is set to `http` because it defaults to https and this service speaks plain HTTP in-cluster. Clients need the Pangolin client running to resolve the hostname. - **Probes are TCP**: both routes are bearer-gated, so an HTTP probe would have to treat 401 as healthy. ## After deploy pulumi stack output --show-secrets "atuin-ai auth token" That value goes into agenix (`secrets/atuin-ai-token.age`) and reaches the CLI as `ATUIN_AI__API_TOKEN`, which atuin layers over `config.toml` - so the token never enters `programs.atuin.settings` or the nix store. ## Note First commit (`9cd4efe`) commits the previously-uncommitted Pangolin work as the deployed state - verified live: `atuin.litelot.us` answers 200 when resolved straight at the edge IP.
The resource has been live since the deployment: atuin.litelot.us resolves to
the edge and answers 200 through it. Committing the working tree as-is so the
next change starts from a clean base.
Stateless Elixir/Gleam server that speaks the Atuin AI protocol and fronts an
OpenAI-compatible chat endpoint. New workload in the existing atuin namespace;
no PVC, no database, no accounts.

Decisions in this change:

* Backend is the in-cluster LiteLLM gateway (litellm:4000/v1 in ns agents) so
  keys, spend and fallbacks stay in one place. Only qwen3-30b-a3b is exposed:
  the chat protocol drives tools on every turn, so a model without tool calling
  is not usable here.
* The LiteLLM key comes from OpenBao (mount litellm, entry env, field
  LITELLM_MASTER_KEY) and is passed as LLM_API_KEY, referenced from config.toml
  by name. No secret in the ConfigMap.
* The CLI bearer token comes from OpenBao (mount atuin, entry env, field
  AUTH_TOKEN) and is an explicit Env, not an ExternalSecret. The server treats a
  missing token as open access and starts anyway, so an ESO sync race would
  silently publish an unauthenticated endpoint. An explicit read fails the
  deploy instead.
* Image is pinned by digest: the project publishes only `latest` and `main`
  tags, so a tag would float.
* Labels are litelot.us/deployment=atuin-ai, deliberately not the atuin
  server's labels, which are the existing Service's selector.
* Probes are TCP, not HTTP: every route is bearer-gated, so an HTTP probe would
  have to treat 401 as healthy.

Requires, before the first deploy: the atuin KV2 mount with an AUTH_TOKEN entry
in OpenBao. The value must match the CLI's ai.api_token in ~/.config/atuin.

Exposure is intentionally NOT included; that decision is the user's.
The pulumi role is read-only on the existing mounts and no atuin mount exists, so
the previous lookup could never have resolved. Replace it with a
random.RandomPassword (48 chars, no specials so it survives a TOML string and an
HTTP header) stored in a Pulumi-owned Opaque Secret, consumed via secretKeyRef.

The token is exported as a secret stack output, so the value for the CLI comes
from `pulumi stack output --show-secrets`. Replacing that random resource
invalidates every configured client, so treat Length changes as a cutover.

pulumi-random is pinned to v4.18.2: every release from v4.19 needs pulumi/sdk
>= 3.213, which would lift the whole module off 3.205.0.
Public Pangolin resource in the same site as atuin sync, SSO off for the same
reason: the CLI authenticates with a token and cannot complete a browser login.

Health check is disabled deliberately. Every route is bearer-gated, so Pangolin's
default GET / probe sees 404 (unknown route) and /api/cli/models answers 401 —
either would mark the target unhealthy and pull it from rotation. Revisit once
live: a path+status check that accepts 401 is the right answer if the edge
honours HealthCheck.Status.
Reachable only through the Pangolin client tunnel, so there is no public FQDN to
scan and no forward-auth to break token clients with.

Switches from Resource to PrivateResource, which is the site-scoped surface: the
destination is inline host/port rather than a Target sub-resource, there is no
health check configuration at all (removing the probe question entirely), and
Scheme has to be stated explicitly because it defaults to https while this
service speaks plain HTTP in-cluster.

Clients therefore need the Pangolin client running to resolve atuin-ai.litelot.us.
The image ends with `USER nobody`, a name, and kubelet refuses runAsNonRoot
against a non-numeric user because it cannot prove the uid isn't 0:

  Error: container has runAsNonRoot and image has non-numeric user (nobody),
  cannot verify user is non-root

Set runAsUser/runAsGroup to 65534 (Debian's nobody, and the user the image
chowns /app to) so the guarantee is checkable instead of dropped.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/atuin-ai-server:feat/atuin-ai-server
git switch feat/atuin-ai-server

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feat/atuin-ai-server
git switch feat/atuin-ai-server
git rebase main
git switch main
git merge --ff-only feat/atuin-ai-server
git switch feat/atuin-ai-server
git rebase main
git switch main
git merge --no-ff feat/atuin-ai-server
git switch main
git merge --squash feat/atuin-ai-server
git switch main
git merge --ff-only feat/atuin-ai-server
git switch main
git merge feat/atuin-ai-server
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
homelab/atuin!1
No description provided.