# A paid business agent, end to end

> The video editor example: a paid agent chart that adds an agent and its automation, proves each part, and ends its first quest on a real result.

You follow a complete paid chart, the video editor: the player drops rushes in a folder and gets a cut teaser back. The chart adds an agent, turns on an automation that watches the folder, proves each part by reading the machine, and its first quest ends on a file the machine can see. Every part is a field of the standard, so your own agent can be written the same way.

**Before you begin (25 minutes)**

- [Package a quest pack](https://docs.altasystem.ai/charts/guides/quest-pack): the card, `support` and `branch` work the same way.
- The repository cloned (see [Install the CLI](https://docs.altasystem.ai/start/install)): the example is in `examples/chart-agent/video-editor/`.

### Say where it works

This agent works on recent Macs with Apple chips and on Linux. In a hosted world it is `limited`: the note says what changes, in words the player reads before agreeing.

```json [video-editor/chart.json]
{
  "platforms": [
    { "os": "macos", "arch": ["arm64"], "min": "14" },
    { "os": "linux", "arch": ["x64", "arm64"] }
  ],
  "hosted": "limited",
  "notes": {
    "linux": {
      "en": "In a hosted world, rushes are uploaded to the world first.",
      "fr": "Dans un monde hébergé, les rushes sont d'abord envoyés dans le monde."
    }
  }
}
```

### Declare the agent and its automation

`agents` declares the agent itself: its name, the files of its folder (`agents/editor/`), its model and the tools it may and may not use. `automations` declares what wakes it up: here, every 15 minutes, a message from a file of the chart. Nothing is created yet; these are declarations the parts use.

```json [video-editor/chart.json]
[
  {
    "id": "editor",
    "name": { "en": "Editor", "fr": "Monteur" },
    "role": "operator",
    "files": ["SOUL.md", "AGENTS.md"],
    "model": "need:mind",
    "permissions": {
      "tools": {
        "allow": ["read", "write", "message"],
        "deny": ["browser", "secrets", "exec"]
      }
    },
    "wake": ["video-editor-watch"]
  }
]
```

```json [video-editor/chart.json]
[
  {
    "key": "video-editor-watch",
    "title": { "en": "Watch the rushes", "fr": "Surveiller les rushes" },
    "agent": "editor",
    "schedule": { "every": "15m" },
    "message": "automations/video-editor-watch.message.md",
    "spends": "model"
  }
]
```

### Parts, undo, proof

`parts` lists the steps of the plan, each an executor from the closed list, run after the player agrees: create the agent, then turn on the automation. Each part says how it is undone (`archive` keeps the agent's folder; nothing is deleted) and the read-only checks that prove it holds. `proofs` says when the chart is installed, ready and still alive.

```json [video-editor/chart.json]
[
  {
    "id": "agent",
    "do": "agent.create",
    "args": { "agent": "editor" },
    "undo": "archive",
    "proof": [{ "type": "agent", "id": "editor" }]
  },
  {
    "id": "watch",
    "do": "automation.enable",
    "args": { "key": "video-editor-watch" },
    "requires": ["agent"],
    "undo": "auto",
    "proof": [
      {
        "type": "automation",
        "key": "video-editor-watch",
        "enabled": true
      }
    ]
  }
]
```

```json [video-editor/chart.json]
{
  "installed": [{ "type": "agent", "id": "editor" }],
  "ready": [
    {
      "type": "automation",
      "key": "video-editor-watch",
      "enabled": true
    }
  ],
  "alive": [
    {
      "id": "watching",
      "check": {
        "type": "automation",
        "key": "video-editor-watch",
        "ranWithinHours": 2
      },
      "every": "1h"
    }
  ]
}
```

### End the first quest on a real result

The first quest adds to the game's main branch. The player drops a clip (a `file` check on the folder), sends an agent to cut a teaser, then watches it: a `file` check on the teaser ends the quest. Folders differ between macOS and Linux, so each proof is written twice, one step per system with `os`.

```json [video-editor/chart.json]
{
  "id": "cut",
  "kind": "mission",
  "title": {
    "en": "Send the editor to cut a teaser",
    "fr": "Envoie le monteur faire un teaser"
  },
  "mission": {
    "agent": "operator",
    "brief": {
      "en": "Cut a 30-second teaser from the clips in my rushes folder. Keep the best moments.",
      "fr": "Monte un teaser de 30 secondes à partir des clips de mon dossier de rushes. Garde les meilleurs moments."
    },
    "target": "module:video-editor"
  }
}
```

```json [video-editor/chart.json]
{
  "id": "result-mac",
  "kind": "check",
  "title": { "en": "Watch your teaser", "fr": "Regarde ton teaser" },
  "check": { "type": "file", "path": "~/Movies/Alta/out/teaser.mp4" },
  "os": ["macos"]
}
```

### Make it appear

`spawn` puts a new thing on the map, and `scene` plays when the chart arrives: the camera goes to the edge, the editor appears, the operator speaks. Each universe names the new thing with its own words.

```json [video-editor/chart.json]
{
  "title": { "en": "A video editor joins", "fr": "Un monteur vidéo arrive" },
  "recap": [
    {
      "en": "The video editor is installed and watches your rushes folder.",
      "fr": "Le monteur vidéo est installé et surveille ton dossier de rushes."
    },
    {
      "en": "Next: your first cut.",
      "fr": "Ensuite : ton premier montage."
    }
  ],
  "shots": [
    { "kind": "pan", "dur": 2, "to": "edge" },
    { "kind": "reveal", "dur": 3, "entity": "module:video-editor" },
    {
      "kind": "line",
      "dur": 3,
      "who": "operator",
      "text": {
        "en": "Send me your rushes.",
        "fr": "Envoie-moi tes rushes."
      }
    }
  ]
}
```

### Check it

Run the check from the repository folder. It checks the folder's files, the parts against the closed list, the proofs and the quests against the game.

```sh [Terminal]
alta lint examples/chart-agent/video-editor
```

```text [Output]
ok   examples/chart-agent/video-editor (chart)
1 checked, 0 errors, 0 warnings
```

**Try it:**

```sh
alta dev examples/chart-agent/video-editor
```

Open the address it prints, then the quest **Your first cut** in the journal. In the demo, nothing is installed on your machine.

## Pitfalls

| Do | Avoid |
|---|---|
| A first quest that ends on a result the machine sees | A first quest that ends on "I did it" |
| One step per system when a path differs | A proof that only holds on one system, offered on both |
| A proof for every part that writes | A part without proof: refused |
| The price as `free` or `paid` | An amount in the chart: the catalog holds it |

Known limits, said plainly: an agent added by a chart cannot take a mission itself yet; the mission goes to one of the game's agents (here, the operator). A check cannot be written per system yet, hence the two steps.

## Go further

- [Agent Chart](https://docs.altasystem.ai/reference/standards/chart): every field, the parts and the proofs.
- [Badges](https://docs.altasystem.ai/marketplace/badges): where a chart comes from, and what the player is shown.
- [Errors](https://docs.altasystem.ai/reference/errors#standard-chart): each rule of `alta lint` for a chart.

**Next:**

- [Send an agent on a mission](https://docs.altasystem.ai/guides/missions/send-agent)
- [Publish a chart](https://docs.altasystem.ai/marketplace/publish)
- [Executors](https://docs.altasystem.ai/reference/standards/executors)
