# Engine and widget (/docs/engine-and-widget)

conciv is two programs that your dev server starts together. The engine runs in node and runs the agent. The widget
runs on your page and is the chat you type into.

## What runs where [#what-runs-where]

```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'

export default defineConfig({
  plugins: [
    conciv(), // <- starts the engine and adds the widget, in development only
  ],
})
```

<Mermaid
  height={708}
  chart={`flowchart TB
  subgraph browser[Your browser]
    widget[Widget on your page]
  end
  subgraph machine[Your machine]
    dev[Dev server with conciv] -->|starts| engine[Engine on 127.0.0.1]
    engine -->|runs| harness[Agent CLI: claude, codex, ...]
    outside[Agent in your terminal] -->|MCP| engine
  end
  widget <-->|websocket, after login| engine`}
/>

## Build plugin [#build-plugin]

The build plugin is `@conciv/it` in your bundler config. In development it starts the engine and adds the widget to
every page. A production build leaves both out. Learn more in [Bundlers](/docs/bundlers).

## Engine [#engine]

The engine is a node server inside your dev server's process. It listens on `127.0.0.1` only, on a port of its own. It
answers only browsers that logged in. Learn more in [Logging in](/docs/usage/logging-in).

## Widget [#widget]

The widget is the conciv button, the panel and the quick terminal. It mounts in a shadow root, so your styles and its
styles stay apart. It talks to the engine over one websocket.

## Harness [#harness]

A harness is the agent CLI the engine runs a turn with, such as Claude Code. It runs on your machine, with your own
login. Learn more in [Harnesses](/docs/harnesses).

## A turn [#a-turn]

A turn is one message from you and everything the agent does to answer it:

1. The widget sends your message to the engine over the websocket.
2. The engine runs the harness in your project folder, with conciv's tools added.
3. The agent calls tools. It reads the page, drives it, edits files and runs tests.
4. A risky call waits on a permission card in the panel. It goes on once you answer.
5. Text, tool calls and cards stream back into the panel.

If the socket drops, the widget dials again. A running turn picks up from its last event. Learn more in [Tools and
code mode](/docs/tools-and-code-mode).

<Playground
  page="vite-react"
  script="intro/first-session"
  caption="One turn: a message, the agent reading the page, and its answer."
/>

## Outside agents [#outside-agents]

An agent CLI in your own terminal can reach the engine too, over MCP. It drives your open tabs with the same tools.
Learn how in [Outside agent](/docs/usage/outside-agent).

## Where state lives [#where-state-lives]

The engine keeps its state in `.conciv/` at your project root. The folder has its own `.gitignore`, which ignores
everything except `settings/`.

<Files>
  <Folder name=".conciv" defaultOpen>
    <File name=".gitignore" />
    <File name="server.json" />
    <File name="trusted-browsers.json" />
    <File name="conciv.db" />
    <File name="chat-system-prompt.txt" />
    <File name="mcp-endpoint.json" />
    <Folder name="claude-connect" />
    <Folder name="settings" />
    <Folder name="bin" />
  </Folder>
</Files>

- `server.json` holds the engine's port and token. The engine reuses the port on its next start.
- `trusted-browsers.json` lists the browsers that logged in.
- `conciv.db` is a SQLite file. It holds sessions, chat history and saved permission answers.
- `chat-system-prompt.txt` is the prompt the engine gives the agent, written on every start.
- `mcp-endpoint.json` holds the engine's MCP address. The engine writes it on every start.
- `claude-connect/` holds the Claude Code plugin that `init` sets up. Its bridge reads `mcp-endpoint.json`.
- `settings/` holds project settings saved from the widget. Git does not ignore it, so you can commit it.
- `bin/conciv` is the conciv command. It comes first on the `PATH` of the agents the engine starts.

<Callout type="info" title="Move the folder">
  Set `stateRoot` to keep `.conciv/` somewhere else. Learn more in
  [Configuration](/docs/reference/configuration#stateroot).
</Callout>

## Next steps [#next-steps]

- **[Sessions](/docs/sessions):** what a conversation holds, and where it is kept.
- **[Tools and code mode](/docs/tools-and-code-mode):** how the agent calls conciv's tools.
- **[Agents and permissions](/docs/agents-and-permissions):** what decides when a card asks you.
