Why
Model integration is already well-factored internally (src/server/models: anthropic, google, openai, cloudflare, vertex, catalog, limits, types, url-guard), but sits under src/server alongside HTTP routing, and the runners in src/server/services (model.ts, model-chain-runner.ts, model-review-batch.ts, model-review-file.ts, model-rate-limits.ts, model-support.ts) mix chain orchestration with provider transport and rate-limit bookkeeping.
Scope
- Move src/server/models/* and the model-running services listed above into packages/models/src, exposing a single
ModelRunner port implementation (packages/models/src/runner.ts) to packages/core: given a prompt, a chain and a budget, return a completion plus token accounting.
- Keep the catalog data-driven, no model ids hardcoded in engine or UI code. Catalog and per-provider limits stay declarative and loadable from configuration.
- Move src/server/core/llm-crypto.ts and src/server/models/url-guard.ts into packages/models, keeping the SSRF protections intact, behind a secret-store port (defined in the earlier platform-port issue) for the actual key material.
- Move chain fallback, retry classification (packages/schema's transient-errors.ts, or wherever it landed) and rate-limit accounting into packages/models as internals, not exposed to callers.
- Move test/model into packages/models/test.
Acceptance criteria
Why
Model integration is already well-factored internally (src/server/models: anthropic, google, openai, cloudflare, vertex, catalog, limits, types, url-guard), but sits under src/server alongside HTTP routing, and the runners in src/server/services (model.ts, model-chain-runner.ts, model-review-batch.ts, model-review-file.ts, model-rate-limits.ts, model-support.ts) mix chain orchestration with provider transport and rate-limit bookkeeping.
Scope
ModelRunnerport implementation (packages/models/src/runner.ts) to packages/core: given a prompt, a chain and a budget, return a completion plus token accounting.Acceptance criteria
ModelRunnerport; adding a provider touches only packages/models.