Skip to content

feat(agent): lk agent private-link through the Public API when signed in - #1142

Open
Topherhindman wants to merge 3 commits into
topherhindman/agent-user-auth-deployfrom
topherhindman/agent-user-auth-private-links
Open

Topherhindman wants to merge 3 commits into
topherhindman/agent-user-auth-deployfrom
topherhindman/agent-user-auth-private-links

Conversation

@Topherhindman

@Topherhindman Topherhindman commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Under --user-auth, lk agent private-link create, list, health-status and delete now go through the Public API's AgentService in place of the token bridge. The bridge needs Agent.Admin, so before this only a project admin could manage private links. Now a WRITE member can, as in the dashboard.

Stacked on #1141.

Commands after this PR (every lk agent command that calls LiveKit Cloud)

Command Under --user-auth Who
agent list, status, config, versions, dockerfile, build logs AgentService (#1138, #1139) READ
agent secrets AgentService (#1139) ADMIN
agent restart, rollback, promote AgentService (#1140) WRITE
agent delete, update-secrets, update with secrets AgentService (#1140) ADMIN
agent create, deploy (source), init --deploy AgentService (#1141) WRITE (ADMIN with secrets)
agent private-link create, list, health-status, delete AgentService (this PR) WRITE
agent create --image/--image-tar, deploy --image/--image-tar bridge (registry push) ADMIN, with the bridge's refusal
runtime logs, update-secrets --overwrite bridge ADMIN, with the bridge's refusal

What's in it

  • feat(public): CreatePrivateLink, ListPrivateLinks (each link with its health, or with none when the API couldn't read it), DeletePrivateLink and GetPrivateLinkStatus. Links and statuses decode as LiveKit's own protos, as agents do. The client was regenerated in feat(agent): lk agent create and deploy from source through the Public API when signed in #1141.
  • feat(agent): the four privateLinkAPI methods in userAuthAgentAPI. listPrivateLinks now gets the links and their health from privateLinksWithHealth. With an API key it still makes one status call for each link. Under --user-auth it uses the health that the Public API's one list call returns, through a small optional interface, privateLinkHealthLister.

Decisions

  • List health. The Public API reads each link's health itself (livekit/public-api-server#243), so lk makes one call where it made 1 + N. A link that comes back without a health shows Error with "LiveKit could not read its health", in the table's Reason column and in health_error with --json. That is the same shape as a status call that fails with an API key.
  • Errors. A member below WRITE hears "this command needs write access to the project". Other refusals ("private link not found", cloud agents' validation text) are passed through as the Public API words them, behind lk's existing unable to <verb> private link: prefix.
  • Testscripts. Two existing scripts used private-link list as their example of a bridged command. They now use update-secrets --overwrite, which is still bridged.

Output differences vs the API-key path

  • The tables and the create and delete lines are the same. The testscript compares list and health-status output in full across both modes.
  • The Public API lists links in name order. cloud agents lists them in its own order.
  • An unreadable health has a fixed reason under --user-auth. With an API key, the reason is cloud agents' error text.

Open questions

  • The Public API gates list and status at agent:manage (WRITE), as the dashboard does. Should they be agent:read? (livekit/public-api-server#243)
  • lk never sets CreatePrivateLinkRequest.config (the AWS oneof), and the Public API doesn't take it. Nothing is lost today.

Blockers

  • pkg/public generated from livekit/public-api-server@372fb27e (production v2026-12-02-2258).

Testing

  • GOPRIVATE= go build ./..., go vet ./cmd/lk/... ./pkg/..., go test ./cmd/lk/... ./pkg/... and golangci-lint run ./cmd/lk/... ./pkg/public/... pass.
  • New testscript agent-private-links-with-user-auth: create, list, health-status and delete, once with an API key (fake cloud agents) and once under --user-auth (fake Public API), with the same expected table output. Also covers a link listed without its health (--json), and a READ member's refusal. The request log shows one list call and no token request under --user-auth.
  • Unit tests: privateLinksWithHealth in both modes (N status calls and a kept error with the SDK; one call and errHealthUnread under --user-auth), each native method's response shape, a role refusal and a NotFound. The pkg/public tests cover each call's request and decoding, including a missing health, more than one page and a missing link.

Review fixes

Demo

Recorded on staging, not uploaded yet: ~/hosted-agents-work/demos/M5/m5-private-links.mp4 (write-up ~/hosted-agents-work/demos/M5/README.md). Read-only: no private link was created. WRITE lists private links and gets NotFound for an unknown one; READ is refused list and create (refused before any cloud-agents call).

Depends on #1136 (the hints name lk agent builder).

ListPrivateLinks returns each link with its health, which the API reads
for every link itself; a link whose health it couldn't read comes
without one.
Under --user-auth, lk agent private-link create, list, health-status and
delete call the Public API's AgentService, which a WRITE member may
call, in place of the token bridge, which needs a project admin. The
Public API reads every link's health in its list call, so list makes one
call where it made one for each link; a link whose health the Public API
couldn't read shows an error, as one whose health cloud agents refuses
does.
The Public API's CreatePrivateLink now returns privateLink as
ListPrivateLinks returns each item: the link under link, and its health
under status, which is unset when LiveKit couldn't read it. lk read the
link from privateLink itself, so with the new shape it decoded an empty
link and printed "Created private link []".

CreatePrivateLink now returns a PrivateLink, as ListPrivateLinks does,
and both decode it the same way. lk agent private-link create under
--user-auth prints only the link, as it does with an API key, since
cloud agents' CreatePrivateLink returns no health.
@Topherhindman
Topherhindman force-pushed the topherhindman/agent-user-auth-private-links branch from 5de96e5 to 13e3ad1 Compare December 3, 2026 00:33
@Topherhindman
Topherhindman marked this pull request as ready for review December 3, 2026 00:58

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant