Skip to content

Derive the remaining within-server agent-type tables from shared - #950

Merged
selfcontained merged 1 commit into
mainfrom
agt_10161852c70d/job-debt-collector-df4c869d
Aug 13, 2026
Merged

Derive the remaining within-server agent-type tables from shared#950
selfcontained merged 1 commit into
mainfrom
agt_10161852c70d/job-debt-collector-df4c869d

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

What

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. This points all three at the shared tables. No behavior change to what any endpoint or tool accepts.

FileBeforeAfter
agents/types.ts:10export type AgentType = "codex" | "claude" | "opencode" | "cursor" | "terminal"re-export of shared AgentType (derived from AGENT_TYPES)
shared/mcp/crud-tools.ts:81-82JOB_AGENT_TYPES / TEMPLATE_AGENT_TYPES literal tuplesaliases of CLI_AGENT_TYPES / AGENT_TYPES
shared/mcp/persona-interaction-tools.ts:27-34LAUNCH_PERSONA_AGENT_TYPES literal tuple + derived typealiases of CLI_AGENT_TYPES / CliAgentType

agents/types.ts uses AgentType locally at two more sites, so it pairs the re-export with an import type — the same shape already used two lines below for PinShortcutVariant / 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, and LAUNCH_PERSONA_AGENT_TYPES / LaunchPersonaAgentType are part of the module's surface (shared/mcp/server.ts:29,330 imports 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.ts was created to prevent. This is the follow-up sweep flagged when PR #849 created the shared module; a content-grep for "opencode" across apps/server/src is how the copies were found, since duplicated tables get renamed when pasted but their contents don't.

The one visible delta

CLI_AGENT_TYPES orders members claude, codex, cursor, opencode; the crud-tools copy ordered them claude, codex, opencode, cursor. Same set, so validation is unchanged, but two derived strings reorder:

  • the model param description on add_job/update_job: "opencode and cursor accept no model override""cursor and opencode accept no model override"
  • same on 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 from CLI_AGENT_TYPES. No test pins the ordering (apps/server/test/agent-models.test.ts iterates 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-25AGENT_CLI_BASENAMES is 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:13 and db/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) and agent-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) ✅. No apps/web/ files changed, so finalize:web was 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

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>
@selfcontained
selfcontained merged commit 5438cf1 into mainAug 13, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_10161852c70d/job-debt-collector-df4c869d branch August 13, 2026 09:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@selfcontained