# AGENTS.md

## Dev Commands

```bash
pnpm dev          # Run with tsx (src/gadget-drone.ts)
pnpm build        # Compile TypeScript to dist/
pnpm start        # Run built code (dist/gadget-drone.js)
```

## Requirements

- **Redis** must be running (configure via `GADGET_REDIS_HOST`, `GADGET_REDIS_PORT`)
- **Platform credentials** required in `.env`:
  - `GADGET_PLATFORM_URL`
  - `GADGET_PLATFORM_KEY`

## Architecture

- **Entry**: `src/gadget-drone.ts` - extends `GadgetProcess`, registers with platform, attaches to Bull queue
- **Services**: `AgentService`, `PlatformService` in `src/services/`
- **Queue**: Bull queue named `gadget-drone`, job type `prompt`

## Build

`tsc` with `module: NodeNext` outputs to `dist/`. ES modules only.

## Tests

None configured (`pnpm test` exits with error).

## GadgetId

All entity IDs use `GadgetId` (a string alias) from `@gadget/api`:

```ts
import { GadgetId } from "@gadget/api";

// Use GadgetId for all ID fields
const registrationId: GadgetId = "abc123...";
```

**Schema `_id` pattern (for Mongoose models):**

```ts
_id: { type: String, default: () => nanoid() }
```

**Never add `unique: true` or `required: true` to `_id`** — MongoDB handles this automatically.

See `docs/gadget-id.md` for full documentation.