# `core/missions/missions.ts`

<p class="generated-note">Generated from the exports of <a href="https://github.com/altasystem-ai/alta/blob/main/core/missions/missions.ts"><code>core/missions/missions.ts</code></a> · <code>npm run docs:gen</code></p>

Missions (PLAN-V2 §3.3, lot M): an agent sent with written instructions, out on the map, back with its answer. The timer shows the real time elapsed (and an estimate drawn from past durations), never an artificial wait. These are the shared types and the request validator; the server side (server/missions/) and the client feature (client/features/missions/) belong to lot M. The text travels by stdin to `openclaw agent` (executor agent.message).

**Standards that cite this file**: [Missions (sending an agent)](https://docs.altasystem.ai/reference/advanced/specs/missions)

## Exports

### `MISSION_AGENTS` 
```ts
const MISSION_AGENTS = ["daemon", "architect", "operator", "reviewer", "guardian"] as const
```

### `MissionAgent` 
```ts
type MissionAgent = (typeof MISSION_AGENTS)[number];
```

### `MissionState` 
```ts
type MissionState = "out" | "ok" | "failed";
```

### `MissionRequest` 
POST /api/missions

```ts
interface MissionRequest { agent: MissionAgent; text: string; quest?: string; step?: string; target?: string }
```

### `Mission` 
```ts
interface Mission {
  id: string;
  agent: MissionAgent;
  state: MissionState;
  quest?: string;
  step?: string;
  /** The step key ("uid/step" or "uid@period/step") this mission proves, when sent from a step. */
  key?: string;
  target?: string;
  sentAt: string;
  backAt?: string;
  durationMs?: number;
  /** The agent's answer, at most MAX_REPLY characters. */
  reply?: string;
  error?: string;
  archived?: boolean;
}
```

### `MAX_TEXT` 
```ts
const MAX_TEXT = 4000
```

### `MAX_REPLY` 
```ts
const MAX_REPLY = 8000
```

### `MISSION_TIMEOUT_MS` 
How long the server waits for an agent before the mission fails.

```ts
const MISSION_TIMEOUT_MS = 10 * 60 * 1000
```

### `agentArg` 
The server names the main agent "main".

```ts
const agentArg = (a: MissionAgent) => …
```

### `checkMissionRequest` 
Problems of a mission request (empty = it can be sent).

```ts
function checkMissionRequest(r: unknown): string[]
```

### `estimate` 
An estimate of the next mission's duration: the median of the last ones by this agent, or null.

```ts
function estimate(past: Mission[], agent: MissionAgent): number | null
```

### `missionsByKey` 
Missions by step key, as evaluate() reads them (Context.missions): the latest one wins.

```ts
function missionsByKey(list: Mission[]): Record<string, MissionState>
```
