feat(config): add-agent-type wizard at /config (#460) #476
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!476
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "boss/460"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #460
Summary
GET /config/agent-typesreturns sanitised type metadata (no token contents) plus the available roles, withclonable=falseflagged on host-mode types so the wizard hides them.POST /config/agent-typesclones an existing type into a new one: validates slug + role + template, hits Forgejo/users/{login}to confirm the new user actually exists (typo → 400, no disk write), splices a new block intoagents.jsonwith identity/path fields rewritten and routing labels reset, reloads the in-memory config, registers a worker for<name>-default, and reconciles its container. Failures roll the file back. Broadcastsagent_type_created+agent_createdover SSE./configroute renders a list of agent types and an "+ Add agent type" wizard: 3 steps (template + role → name slug-validated + forgejo_user + display_name → confirm with JSON diff). The reconcile result ("created", "started", error) is shown inline on success.Test plan
bun test apps/server/src/http/handlers/config-agent-types.test.ts— 22 specs including AC matrix (clone fromdev, slug rejects spaces/uppercase/leading-digit/collision, invalid forgejo_user → 400)bun x turbo run typecheck lint test(whole workspace, 2225 server tests pass)/config, clonedevinto a new type, confirmagents.jsonupdated and container reconciled🤖 Generated with Claude Code
Pipeline is correct end-to-end: validation order (slug → role → template → host-mode guard → forgejo user → disk write → reload → reconcile), rollback on loader failure, and
guardMutatingon POST. Test matrix covers all AC items. CI green.Nits (none blocking):
buildPreviewBlockinconfig.tsxomits container/plugins/caveman fields the server copies from the template — labelling it "key fields shown" rather than a full diff would set clearer expectations. The fallback token path inbuildClonedTypeBlockhardcodes/home/charles/…for the case where a template has notoken_file; that branch shouldn't be reachable in practice but an explicit error would be safer. No rollback-path test (write succeeds, reload throws), though the rollback logic is well-commented as best-effort.