[Gastown] PR 8.5: Mayor Tools — Cross-Rig Delegation#347
Merged
jrf0110 merged 2 commits into204-gt-prop-dfrom Feb 19, 2026
Merged
[Gastown] PR 8.5: Mayor Tools — Cross-Rig Delegation#347jrf0110 merged 2 commits into204-gt-prop-dfrom
jrf0110 merged 2 commits into204-gt-prop-dfrom
Conversation
Add mayor-specific tools so the Mayor agent can delegate work across rigs, transforming it from a chatbot into the town coordinator described in the Gastown architecture spec. Worker: - New /api/mayor/:townId/tools/* routes (sling, rigs, beads, agents, mail) - mayorAuthMiddleware validates townId-scoped JWT (no rigId restriction) - Handlers fan out to GastownUserDO (list rigs) and RigDO (sling, beads, agents, mail) Plugin: - MayorGastownClient for town-scoped HTTP operations - 5 mayor tools (gt_sling, gt_list_rigs, gt_list_beads, gt_list_agents, gt_mail_send) - Conditional loading: GASTOWN_AGENT_ROLE=mayor loads mayor tools, otherwise rig tools - Guarded prime/checkpoint hooks (mayor has no rig-scoped prime) MayorDO: - Passes GASTOWN_AGENT_ROLE, GASTOWN_TOWN_ID, GASTOWN_API_URL env vars to container - Uses buildMayorSystemPrompt() with detailed tool docs and delegation instructions Closes #339
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge All 3 issues from the previous review have been addressed in commit d2b6273:
The implementation is clean, follows existing patterns (auth middleware, client/handler structure), and properly separates mayor (town-scoped) from rig-scoped concerns. Files Reviewed (9 files)
|
…llback, unused import - Add verifyRigBelongsToTown() to all handlers that accept a rig_id, preventing cross-town rig access - Add resolveUserId() with query param fallback for dev mode (where mayorAuthMiddleware is skipped and agentJWT is unset) - Remove unused AgentJWTPayload import from mayor-auth.middleware.ts
This was referenced Feb 19, 2026
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
gt_sling,gt_list_rigs,gt_list_beads,gt_list_agents,gt_mail_send) so the Mayor agent can delegate work across rigs/api/mayor/:townId/tools/*worker routes with townId-scoped JWT auth (no rigId restriction)GASTOWN_AGENT_ROLE=mayorloads mayor tools, otherwise rig toolsCloses #339
Architecture
Changes
Worker (
cloudflare-gastown/src/)handlers/mayor-tools.handler.ts(new) — 5 handlers:handleMayorSling,handleMayorListRigs,handleMayorListBeads,handleMayorListAgents,handleMayorSendMailmiddleware/mayor-auth.middleware.ts(new) — JWT middleware that validatestownIdmatch (cross-rig, no rigId constraint)prompts/mayor-system.prompt.ts(new) —buildMayorSystemPrompt()with role, tool docs, conversational model, GUPPgastown.worker.ts— 5 new routes under/api/mayor/:townId/tools/*dos/Mayor.do.ts— UsesbuildMayorSystemPrompt(), passesGASTOWN_AGENT_ROLE=mayor,GASTOWN_TOWN_ID,GASTOWN_API_URLenv vars to containerPlugin (
cloudflare-gastown/container/plugin/)mayor-tools.ts(new) —createMayorTools()with 5 tools for cross-rig delegationclient.ts—MayorGastownClientclass +createMayorClientFromEnv()for town-scoped API callstypes.ts—Rig,SlingResult,MayorGastownEnvtypes; fixedBeadStatusto include'failed'index.ts— Conditional tool loading based onGASTOWN_AGENT_ROLE; guarded prime/checkpoint for mayorTesting