# compute

> What runs on NoClick for you now: your machines (with the conversations on each), every agent's sandbox that's up, and your live sandboxes, each with its price an hour.

```python
running = noclick.compute(user_filter="all")
per_hour = sum(c.usd_per_hour or 0 for c in running if c.status == "running")
```

## compute

```typescript
function compute(options?: ReadOptions): Promise<ComputeItem[]>
```

Your machines (any status, with the conversations on each), every agent's sandbox up now and every live `Sandbox`,
each with its price an hour. Each part needs its area's scope (`machines`, `agents`, `sandboxes`); a key with only
some gets those. Your own computers aren't in it.

Parameters:

- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Each machine or sandbox: its `kind`, status, size, price an hour and what runs on it.

Types:

```typescript
/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;
```

## ComputeItem

```typescript
interface ComputeItem
```

A machine, an agent's sandbox or a sandbox, as it runs now.

| Attribute | Type | Description |
| --- | --- | --- |
| `kind` | `"machine" | "agent_sandbox" | "sandbox"` | `machine` (a NoClick machine, any status), `agent_sandbox` (an agent's warm sandbox) or `sandbox` (`Sandbox`). |
| `id` | `string` | Its id (an agent's sandbox: its name). |
| `name` | `string | null` | The machine's name, the agent's, or a sandbox's image. |
| `status` | `string | null` |  |
| `userId` | `string | null` |  |
| `region` | `string | null` |  |
| `cpu` | `number | null` |  |
| `memoryGb` | `number | null` |  |
| `startedAt` | `Date | null` |  |
| `usdPerHour` | `number | null` | What an hour of it costs (a machine: its month's price over 730 hours). |
| `usdPerMonth` | `number | null` | A machine's price a month. |
| `spentUsdToday` | `number | null` | What an agent's sandbox charged since midnight UTC. |
| `running` | `ComputeRun[]` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## ComputeRun

```typescript
interface ComputeRun
```

A conversation running on a machine or in an agent's sandbox.

| Attribute | Type | Description |
| --- | --- | --- |
| `agentId` | `string | null` |  |
| `agentName` | `string | null` |  |
| `conversation` | `string | null` | The agent's conversation (as `agent.message({ conversation })` names it). |
| `harness` | `string | null` |  |
| `state` | `string` | `starting`, `live` or `running`. |
