Store sessions from headless machines
A machine is an identity for places where nobody can sign in: CI runners, build boxes, ephemeral agent sandboxes. It stores sessions like a user, is never an administrator or a project member, and authenticates with two environment variables that kcap exchanges for a short-lived token by itself. Store headless/machine coding agent sessions is the walkthrough; this page is the reference
Machine credentials are available on workspaces that sign in through single sign-on
Two computers take part, and each section below says which one it is for. Your computer is wherever you are signed in to kcap as yourself, your laptop say: machines are created, listed, rotated and revoked there, and nothing else about it changes. The machine is the runner, box or sandbox that runs the coding agent unattended: it only ever holds the two variables
Create, on your computer
Section titled “Create, on your computer”Signed in as yourself, with the organisation’s owner or admin role and kcap administrator rights. The name is yours to choose, and it is how the machine’s sessions are labelled; ci-runner below is only an example:
kcap machine create <name> [--visibility org_public] [--role member]The secret is printed once, to stdout alone; the client id and instructions go to stderr. Capture stdout and hand it to a secret store only when the command succeeded, because the secret is printed before the machine is registered and a failed registration still exits non-zero after printing it. For GitHub Actions:
secret="$(kcap machine create ci-runner)" && printf '%s' "$secret" | gh secret set KCAP_CLIENT_SECRET``` `kcap machine list` shows client ids any time; the secret is never shown again
## Configure the machine
Everything here happens on the machine itself: in a pipeline, as the job's steps; on a long-lived box, once
### The variables
The machine's identity is two environment variables. Set them where every process that will run kcap can see them: in a CI pipeline, the job's environment, fed from the secret store; on a box, the environment file of the service or the shell profile of the account that runs the agent. With them present kcap never opens a browser or asks for a login
| Variable | Value || --- | --- || `KCAP_CLIENT_ID` | The client id. Public || `KCAP_CLIENT_SECRET` | The secret. From the secret store || `KCAP_URL` | The workspace URL, when kcap on the machine has no profile pointing at it |
The token exchange calls `signin.kcap.ai`, which the machine's egress must allow
### Install kcap and the agent's hooks
The script installer puts the CLI on the machine and then runs `kcap setup` with the options you pass after a second `--`; without a terminal it adds `--no-prompt`, so nothing waits for an answer:
```bashcurl -fsSL https://www.kurrent.io/install | bash -s -- -- --server-url https://acme.kcap.ai --default-visibility org_public --skip-import--server-urlis the workspace, the same address people use in the browser--default-visibilityis who can read what the machine stores; see Visibility--skip-importstops setup looking for old transcripts on the machine
On Windows, the install script reads the same options from KCAP_SETUP_ARGS:
$env:KCAP_SETUP_ARGS = '--server-url https://acme.kcap.ai --default-visibility org_public --skip-import'irm https://www.kurrent.io/install.ps1 | iexInstall the coding agent before or after kcap; kcap setup finds the agents present and installs their hooks, so in a pipeline run it after the agent is installed. If you build a machine image, for example a container image, with kcap and the hooks already installed, the machine needs none of this: the two variables, plus KCAP_URL when the image carries no profile, are enough
Visibility, on the machine
Section titled “Visibility, on the machine”A machine’s sessions use the default_visibility of the profile it runs under, or org_public with no profile. project is not available, because a machine is never a project member. Unlike a person’s, a machine’s org_public sessions never fall back to private in personal repositories. Avoid private: nobody could read those sessions, because the machine cannot sign in to look
Verify, on the machine
Section titled “Verify, on the machine”kcap statusThe auth line names the machine credential. Run the agent as usual; its sessions appear owned by the machine
Rotate and revoke, on your computer
Section titled “Rotate and revoke, on your computer”kcap machine listkcap machine revoke service:<id>Revocation is immediate for new requests and cannot be undone; a token already held expires within the hour. Rotate by creating a replacement and revoking the old one. Admins can review and revoke under Administration → Integrations → Machines; creation stays in the CLI so the secret never passes through the server
Keep the variables off your computer
Section titled “Keep the variables off your computer”With either variable set, every kcap process uses the machine, not you, including the sessions your own agents store. kcap status warns when it sees them in an interactive shell
Help me get unstuck
Section titled “Help me get unstuck”You need the owner or admin role in this organization. Your organisation role is member; ask an owner or admin to create the machine
You need to be a kcap administrator to register a machine. The credential was issued but registration needs administrator rights on the workspace
Machine credentials aren’t enabled. This workspace has them switched off. Contact Kurrent
KCAP_CLIENT_ID is set but KCAP_CLIENT_SECRET is not. The machine has half its identity; check how the secret reaches the environment
The machine credential was rejected. Wrong or revoked values. Revoke and create a fresh one
Sessions store but nobody can see them. The machine’s default visibility is private; set --default-visibility org_public on the machine and run kcap setup again