Derive the remaining within-server agent-type tables from shared - #950
Merged
Merged
Conversation
apps/server/src/shared/agent-types.ts has been the single source of truth for the agent-type tables since PR #849, but three within-server hand-written copies survived that consolidation. Point them all at the shared tables. - agents/types.ts: the literal AgentType union becomes a re-export of the shared derived type (identical member set). - shared/mcp/crud-tools.ts: JOB_AGENT_TYPES / TEMPLATE_AGENT_TYPES become aliases of CLI_AGENT_TYPES / AGENT_TYPES. - shared/mcp/persona-interaction-tools.ts: LAUNCH_PERSONA_AGENT_TYPES / LaunchPersonaAgentType become aliases of CLI_AGENT_TYPES / CliAgentType. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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 freeto 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.
What
apps/server/src/shared/agent-types.tshas been the single source of truth for the agent-type tables since PR #849, but three within-server hand-written copies survived that consolidation. This points all three at the shared tables. No behavior change to what any endpoint or tool accepts.agents/types.ts:10export type AgentType = "codex" | "claude" | "opencode" | "cursor" | "terminal"AgentType(derived fromAGENT_TYPES)shared/mcp/crud-tools.ts:81-82JOB_AGENT_TYPES/TEMPLATE_AGENT_TYPESliteral tuplesCLI_AGENT_TYPES/AGENT_TYPESshared/mcp/persona-interaction-tools.ts:27-34LAUNCH_PERSONA_AGENT_TYPESliteral tuple + derived typeCLI_AGENT_TYPES/CliAgentTypeagents/types.tsusesAgentTypelocally at two more sites, so it pairs the re-export with animport type— the same shape already used two lines below forPinShortcutVariant/PinType.The two MCP modules keep their domain-specific exported names (
JOB_AGENT_TYPES,LAUNCH_PERSONA_AGENT_TYPES) rather than being deleted: the names document which subset that tool accepts, andLAUNCH_PERSONA_AGENT_TYPES/LaunchPersonaAgentTypeare part of the module's surface (shared/mcp/server.ts:29,330imports the type). The debt was the duplicated table, not the name.Why it's tech debt
Member sets were already identical in all three cases, so these are pure copies that can silently drift when a new agent type is added — exactly the failure mode
shared/agent-types.tswas created to prevent. This is the follow-up sweep flagged when PR #849 created the shared module; a content-grep for"opencode"acrossapps/server/srcis how the copies were found, since duplicated tables get renamed when pasted but their contents don't.The one visible delta
CLI_AGENT_TYPESorders membersclaude, codex, cursor, opencode; the crud-tools copy ordered themclaude, codex, opencode, cursor. Same set, so validation is unchanged, but two derived strings reorder:modelparam description onadd_job/update_job:"opencode and cursor accept no model override"→"cursor and opencode accept no model override"create_template/update_template:"opencode, cursor, and terminal"→"cursor, opencode, and terminal"This makes them consistent with
dispatch_launch_persona, which already rendered its catalog fromCLI_AGENT_TYPES. No test pins the ordering (apps/server/test/agent-models.test.tsiterates the tuple rather than asserting a literal). Zod's invalid-enum error message also lists the same members in the new order.Deliberately excluded near-misses
The content-grep surfaced several lookalikes that are not copies of the table and were left alone:
apps/server/src/config.ts:98—"opencode"is a CLI binary-name default (OPENCODE_BIN), not a type member.apps/server/src/agents/tmux/runtime.ts:19-25—AGENT_CLI_BASENAMESis a set of process basenames for pid-walking; it includes"agent"(cursor's actual binary) and is not the type table.apps/server/src/db/seed/jobs.ts:13anddb/seed/agents.ts:12— deliberate 3-member subsets used to type seed fixtures, not the full table.apps/web/src/components/app/types.ts:91(reviewAgentType?: "codex" \| "claude" \| "opencode" \| "cursor" \| null) andagent-type-icon.tsx:28(adds an"unknown"member) — real web-side copies, but out of scope for a server-only change. Queued in the backlog.Validation
pnpm run check✅ ·pnpm run test(2718 server + 842 web + 60 extension) ✅ ·pnpm run test:e2e(180 passed / 12 skipped) ✅. Noapps/web/files changed, sofinalize:webwas not required.Queued next
A fresh broad audit — the backlog is down to 5 items and one entry was found stale while scoping this run (a prior run had recorded crud-tools' zod enums as already fixed; they were still hand-written locally).
🤖 Generated with Claude Code