Repository navigation
feat(agent): lk agent list, status and config through the Public API when signed in - #1138
Open
Topherhindman wants to merge 7 commits into
Open
Topherhindman wants to merge 7 commits into
Topherhindman wants to merge 7 commits into
Conversation
This was referenced Nov 24, 2026
Open
Topherhindman
force-pushed
the
topherhindman/agent-user-auth-list
branch
from
December 1, 2026 04:54
071368a to
13d2b0c
Compare
Picks up the Public API's AgentService: list, get, versions, secret names, build logs and client settings of cloud agents; restart, roll back, promote and delete them and update their secrets; create, deploy and build them from source; and their private links. Also picks up AgentBuilderService.UpdateAgentSecrets. Nothing on main calls them. The eval criterion type "code" and its check field are gone (livekit/public-api-server#256). Nothing in lk reads them. Every other path, operation and type is unchanged. Generated from livekit/public-api-server@372fb27, production v2026-12-02-2258
The cloud agent commands and the private-link commands now call one interface each, as the sip and number commands do (#1124). With an API key, server-sdk-go's cloudagents client implements both, so nothing changes. Under --user-auth, userAuthAgentAPI implements both: it holds the Public API client and the cloudagents client on the token bridge, and sends every call through the bridge for now. A later change moves a method to the Public API's AgentService without touching the commands. Two scripts pin the requests in each mode.
Under --user-auth, every agent command reaches cloud agents through the token bridge, which asks the Public API for the Agent.Admin grant. The Public API gives that grant only to a project admin, so a writer or a reader got cloudAPIError's hint that their account doesn't have access to the project, inside a Twirp "failed to do request" line. userAuthAgentAPI now passes each bridge error through bridgeError. When the Public API refused the token, the error says the command needs a project admin, keeps the Public API's message, and says that a project API key works meanwhile. Any other error comes back as it is.
`lk agent logs` streamed from the region of the agent's first deployment without checking that it has one, and `lk agent create` streamed from the first server region cloud agents returned, without checking that it returned one. Either panicked with an index out of range. logs now says "no agent deployments found" for an agent with no deployment, as it does for no agent. create says the agent was created and points at `lk agent logs`. The create path runs only at an interactive prompt, so only logs has a test.
ListAgents and GetAgent return a cloud agent's info as livekit.AgentInfo, which the API sends as protojson, so they decode it as the telephony methods decode their messages: lk's agent commands already print that type, and the round trip keeps every field. IsAgentNotFound tells GetAgent's NotFound for an agent from the one for a project. Agent is as livekit/public-api-server#240 shapes it: AgentID, AgentName, Kind, Status and Cloud, the cloud agent as livekit.AgentInfo, nil when the API sends none. Tested: unit tests that decode an agent with every field of AgentInfo and the messages in it set, a list that reports a next page, a missing payload, and both NotFound answers.
server-sdk-go's Twirp clients speak protobuf, so a script could only answer a Twirp method with an empty message. A Twirp method's 200 body is now its response message as protojson, which the fake checks strictly when the script sets it and sends as protobuf to a client that asks for protobuf. An empty body is still an empty message.
Under --user-auth, every agent command reached cloud agents through the token bridge, which needs the Agent.Admin grant, so only a project admin could list agents or show an agent's status. ListAgents under --user-auth now calls the Public API's AgentService, which a READ member may call and which mints no token: GetAgent when the request names an agent, ListAgents otherwise. Every other method still goes through the bridge. - An agent the project doesn't have is an empty list, as cloud agents answers, so status says "no agents found" and config "agent not found" in both modes. A project that isn't found is still an error. - The Public API leaves out a version or deploy time that cloud agents doesn't know, where cloud agents lists "---" and the zero time. cloudAgentsInfo puts those back, so list, status and config print the same in both modes; without it list showed a deploy time of 1970-01-01 for an agent never deployed. The agent name "<Pending>" or "<Unavailable>", which the Public API also leaves out, can't be put back and stays empty. - Commands that pick an agent, or read its regions before another call (logs, deploy's summary), read it the same way. - lk reads an agent's cloud, and leaves out an agent without one, as cloud agents lists only cloud agents. Tested: a testscript that runs list, list --id, status (table and --json) and config with an API key and under --user-auth against the same agents, compares the output, checks an unknown agent in both modes, and that no token is requested; unit tests for cloudAgentsInfo and for a get the Public API refuses.
Topherhindman
force-pushed
the
topherhindman/agent-user-auth-list
branch
from
December 3, 2026 00:18
13d2b0c to
507fae9
Compare
Topherhindman
marked this pull request as ready for review
December 3, 2026 00:48
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
rektdeckard
approved these changes
Dec 3, 2026
Member
|
I think keeping placeholder values is fine, and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Under
--user-auth,lk agent list,lk agent statusandlk agent confignow read agents through the Public API'sAgentService. Before, every agent command reached cloud agents through the token bridge. The bridge needs theAgent.Admingrant, so only a project admin could list agents or see an agent's status.AgentServicetakesagent:read, so READ and WRITE members can now run these three commands. lk asks for no token for them.What's in it
The first three commits are the scaffold from
topherhindman/agent-user-auth, which has no PR of its own:refactor(agent): each agent command takes anagentAPIorprivateLinkAPIinterface with the SDK's signatures. The SDK client implements them with an API key, anduserAuthAgentAPIimplements them under--user-auth. This follows thelk sip/lk numberprecedent (feat(lk): lk sip and lk number use the Public API under --user-auth #1124).fix(agent): when the Public API refuses the bridge's token, the error says the command needs a project admin and that an API key works meanwhile. It no longer says the user lacks access to the project.fix(agent): fixes for two index panics:agent logson an agent with no deployment, andagent create's log tail when no region comes back.The native list and get:
chore(public): regeneratespkg/publiconce, from livekit/public-api-server@372fb27e (production v2026-12-02-2258):AgentService, with the Agent that livekit/public-api-server#240 reshaped (agentId,agentName,kind,statusasAgentStatusandagentBuilderIdat the top, and the cloud agent ascloud, in a oneof), andAgentBuilderService.UpdateAgentSecrets. The only removal is the eval criterion type "code" and itscheckfield (livekit/public-api-server#256), which nothing in lk reads.feat(public):ListAgents,GetAgentandIsAgentNotFound. An agent's cloud agent (cloud,infobefore the reshape) islivekit.AgentInfosent as protojson, so it is decoded with protojson, as the telephony methods decode theirs. Every field survives.test(lk): the fake cloud used by the testscripts can now answer a Twirp protobuf client from a protojson body. Before, a script could only answer with an empty message.feat(agent):userAuthAgentAPI.ListAgentscallsGetAgentwhen the request names an agent, andListAgentsotherwise. Every other method still goes through the bridge.refactor(agent):public.Agentfollows the new shape (AgentID,AgentName,Kind,Status,AgentBuilderID,Cloud). lk readscloudas it readinfo, and leaves out an agent without one, so the output doesn't change.Decisions
GetAgent's NotFound "agent not found" becomes an empty list, which is what cloud agents returns. Sostatussays "no agents found" andconfigsays "agent not found" in both modes. A "project not found" stays an error.---and the zero time. lk puts---and the zero time back (cloudAgentsInfo), so the table and--jsonoutput match the API-key path. Without this,listshowed1970-01-01T00:00:00Zas the deploy time of an agent that was never deployed.logs, the agent picker, and the summary after a deploy also read agents throughListAgents, so they read them the same way.logsstill streams through the bridge, so it still needs an admin.Output differences vs the API-key path
<Pending>or<Unavailable>can't be put back, because the Public API leaves it out. Under--user-auth,listshows an empty Dispatch Name for such an agent.listsorts by deploy time. Agents with the same deploy time, such as two agents that were never deployed, can come out in a different order: cloud agents lists them in database order, and the Public API lists them in ID order.Open questions
--user-auth?statusandagentBuilderIdare decoded but not shown. Shouldstatusorlistshow them?Blockers
pkg/publicgenerated 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/...andgolangci-lint run ./cmd/lk/... ./pkg/public/...all pass.agent-reads-with-user-auth. It runslist,list --id,status(table and--json) andconfig, once with an API key against a fake cloud agents and once under--user-authagainst a fake Public API, with the same agents. It checks that both modes print the same output and write the samelivekit.toml, and it checks an unknown agent in both modes. The fake Public API refuses any token request, as it does for a member below admin, and the request log shows that lk made none. WithoutcloudAgentsInfothe script fails on the deploy time and version of the agent that was never deployed.AgentInfoset, and the fields of the messages inside it. They also covercloudAgentsInfo, a refused get, and a "project not found".Demo
Recorded on staging, not uploaded yet:
~/hosted-agents-work/demos/M1/m1-list-status-config.mp4(write-up~/hosted-agents-work/demos/M1/README.md). The Public API ran locally from this branch against staging cloud-agents, reading the staging database read-only; lk from #1138. A WRITE member is refused by lk main's token bridge, then runslk agent list,statusandconfigunder--user-auth; a READ member and an ADMIN do the same.Depends on #1136 (the hints name
lk agent builder).