fix(aistio): create agent_shares table and expose tierForCurrentUser (#2977) - #2978
Open
shynemo wants to merge 3 commits into
Open
fix(aistio): create agent_shares table and expose tierForCurrentUser (#2977)#2978shynemo wants to merge 3 commits into
shynemo wants to merge 3 commits into
Conversation
…gentscope-ai#2977) The agent share handlers (listShares/addShare/revokeShare) and the admin user-deletion cascade all read and write the `agent_shares` table, but no migration ever created it — only the legacy, unused `resource_shares` table was. Once agent listing filtered visibility through `agent_shares`, opening the Agents page failed with `relation "agent_shares" does not exist (SQLSTATE 42P01)`. - Add the `agent_shares` CREATE TABLE migration (owner_id, agent_id, grantee_type, grantee_id, tier, created_at, with a unique constraint on the share tuple matching the addShare ON CONFLICT clause) plus lookup indexes. - Mark `resource_shares` as a legacy table that has no readers or writers. - Return `tierForCurrentUser` from the agent API: owners resolve to EDIT; other users get their highest CLONE/RUN/EDIT grant from `agent_shares` (a direct USER grant or a WORKSPACE '*' grant). The console AgentLayout relies on this field to render the detail tabs, so without it the whole tab strip (Workspace/Skills/Tools/Subagents/Channels/Settings) was hidden. - Scope listAgents/getAgent to agents the caller owns or has a share for, and load shared agents across owners via loadSharedAgent with a tier check. Fixes agentscope-ai#2977 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The self-hosted Hands worker authenticates with an environment key issued
as `ek_<id>` (product.shortID("ek_")), not `ebk_`. Fix the javadoc usage
example so the documented --environment-key matches the issued key.
Ref agentscope-ai#2977
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Fixes #2977.
The Agent sharing feature in the
agentscope-serviceaistiod control plane reads/writes a table namedagent_shares, but the startup schema migration never created it — only the legacy, unusedresource_sharestable was. This causes Share operations (and any agent-list visibility query that joinsagent_shares) to fail withrelation "agent_shares" does not exist (SQLSTATE 42P01).A closely related defect: the console
AgentLayoutgates every Agent detail tab (Workspace/Skills/Tools/Subagents/Channels/Settings, allminTier: 'RUN') ontierForCurrentUser, but the Go agent API never returned that field, so the whole tab strip was hidden — even for the agent owner.Changes
aistio/internal/product/migrate.goagent_sharesCREATE TABLEmigration (owner_id, agent_id, grantee_type, grantee_id, tier, created_at), with a unique constraint on(owner_id, agent_id, grantee_type, grantee_id)matching theaddShareON CONFLICTclause, plus lookup indexes. The migration is idempotent (CREATE TABLE IF NOT EXISTS), so existing deployments pick it up on aistiod restart — no data-volume reset required.resource_sharesas a legacy table with no readers/writers (doc comment only).aistio/internal/product/handlers_agents.gotierForCurrentUser: owners resolve toEDIT; other users get their highest CLONE/RUN/EDIT grant fromagent_shares(a directUSERgrant or aWORKSPACE '*'grant).listAgents/getAgentto agents the caller owns or has a share for; load cross-owner shared agents vialoadSharedAgentwith a tier check.service-scheduler/.../worker/HandsWorkerMain.javaek_<id>(product.shortID("ek_")), notebk_.Verification
go build ./... && go vet ./internal/product/ && go test ./internal/product/— pass.agent_shares:listShares/addShare/revokeShare(handlers_agent_extras.go), the admin user-deletion cascade (handlers_admin.go), and the visibility/tier queries (handlers_agents.go).running cp schema migration→cp schema migration complete); the Agents page then loads, the detail tabs render, and Share list/add/revoke succeed.Additional notes
resource_sharesis left in place (not dropped) for compatibility with existing databases; it has no code readers or writers and is now documented as legacy.