> For the complete documentation index, see [llms.txt](https://robodex.gitbook.io/robodex-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://robodex.gitbook.io/robodex-docs/frontend/frontend-contracts.md).

# Frontend Contracts

Frontend contracts live in `apps/web/lib/types.ts`.

These types are the product-visible shape of generated robot data. They do not need to expose every internal research or pipeline field.

## Important contracts

| Type                      | Purpose                                    |
| ------------------------- | ------------------------------------------ |
| `RobotDesignCandidate`    | Product-facing generated candidate         |
| `TaskIntent`              | Normalized task description                |
| `RobotDesignProgram`      | Program data when surfaced to the frontend |
| `GrammarHitl`             | Grammar-loop review payload                |
| `GenerateDesignsResponse` | Response from design generation            |
| `DesignSpecResponse`      | Design specification response              |
| `WorkspaceProject`        | Project metadata                           |
| `WorkspaceThread`         | Thread metadata                            |
| `ThreadMessage`           | User/assistant chat messages               |
| `ThreadArtifact`          | Generated artifacts attached to a thread   |
| `SimulationSpec`          | Simulation-check request and result        |
| `PolicySpec`              | Policy/training request and result         |

## Contract discipline

When changing a generated-design field, update all relevant places together:

* `apps/api/routes/designs.py`,
* `apps/api/workspace_sdk.py`,
* `apps/api/workspace_store.py` if persisted,
* `apps/web/lib/types.ts`,
* `apps/web/components/MorphologyViewer.tsx`,
* route or frontend contract tests.

## Candidate versus IR

`RobotDesignCandidate` is a product view. It is optimized for:

* display,
* review,
* selection,
* simple rendering,
* user explanation.

`RobotDesignIR` is a canonical robotics representation. It is optimized for:

* compilation,
* validation,
* simulation,
* deterministic downstream processing.

Do not collapse them unless the product and pipeline requirements truly become identical.

## Grammar HITL payload

The HITL payload is the safest place to expose structured generation context to the frontend. It can include:

* summary,
* compile-safe status,
* graph information,
* component program,
* selected program,
* validation messages,
* candidate metadata.

The frontend should display or inspect this data, not mutate it into a new source of truth.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://robodex.gitbook.io/robodex-docs/frontend/frontend-contracts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
