<!-- zibby-template-version: 1 -->
# /zibby-app-logs — tail or fetch logs from a Zibby Managed App

You are helping the user see what an app is doing — container stdout/stderr, agent-ops supervisor turns, and (for multi-service entries) per-service streams.

Canonical docs: **https://docs.zibby.app/apps/logs**

## Two modes

| Mode | Flag | What it does |
|---|---|---|
| **Snapshot** | (no `-t`) | Fetch last N lines and exit. Good for "what happened?". |
| **Tail** | `-t` | Live-follow new lines until Ctrl-C. Good for boot-watching. |

```
Bash(zibby app logs <instanceId>)                 # snapshot, default 200 lines
Bash(zibby app logs <instanceId> --lines 1000)    # bigger snapshot, max 5000
Bash(zibby app logs <instanceId> -t)              # live tail
```

For `-t`, ALWAYS run it in the background. A live tail blocks indefinitely:
```
Bash({ command: "zibby app logs <instanceId> -t", run_in_background: true })
```

## Multi-service: --service

Some catalog entries (e.g. `wordpress + mysql`, `gas-town` with worker + scheduler) run multiple containers in one task. By default the log stream is the **app's primary service** (whatever the catalog manifest declared as `mainService`). To tail another:

```
Bash(zibby app logs <instanceId> --service mysql)
Bash(zibby app logs <instanceId> --service agent-ops)   # the supervisor itself
```

If you don't know what services exist, `Bash(zibby app status <instanceId>)` lists them under `services[]`.

## What you see for each app type

- **Catalog deploys** → stdout/stderr of the app's container. E.g. n8n prints `Editor is now accessible via: http://localhost:5678/`.
- **Goal-mode deploys** → the `agent-ops` supervisor's turns. Each turn shows the prompt, the tool call(s), and the response. This is the install/repair trail.
- **`--service agent-ops`** (on any app) → the supervised loop's heartbeat: scheduled checks, periodic goal verification, repair attempts.

## Steps

1. **Identify the instanceId** — `Bash(zibby app list)` if user only has the friendly name.
2. **Decide snapshot vs tail.** If they're asking "what happened?" → snapshot. If "I just deployed, watch it come up" → tail.
3. **Decide which service.** For single-service catalog apps, default. For multi-service or "show me the supervisor", pass `--service`.
4. **Run the command.** For tail, background it; for snapshot, foreground is fine.
5. **Surface the meaningful part to the user.** Don't dump 200 lines — find the error / the success marker / the agent-ops decision, paraphrase it.

## Watch for

- **`--service` value typos** → 400 with the list of valid service names. Read that list back to the user.
- **No log stream yet** → if the task hasn't started, there's nothing to tail. Status will say `pending`. Wait 30s and retry.
- **Goal-mode tail looks frozen** → agent turns can each take 30-90s. If you've been quiet for 2 min, the task is likely stuck mid-tool-call. Check `/zibby-app-status` for `lastSupervisorRun` timestamp.
- **Lines flag clamping** — `--lines` is clamped to 1..5000. Don't bother passing 100000; you'll get 5000.

## Stop tailing

Kill the backgrounded Bash task. The CLI exits cleanly. The app keeps running.
