> For the complete documentation index, see [llms.txt](https://docs.haikaldev.my.id/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.haikaldev.my.id/tentang/instalasi.md).

# Instalasi dan Setup

Dari nol sampai bot membalas chat pertamamu — sekitar 10 menit.

Tutorial lengkap dari `git clone` sampai QR ter-scan. Waktu yang dibutuhkan: ±10 menit (di luar antre kuota QR 😄).

## Prasyarat

| Kebutuhan               | Keterangan                                                                                                                                                                                   |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Node.js v18+**        | Dikembangkan & diuji di v25; produksi penulis jalan di v20. Cek: `node -v`                                                                                                                   |
| **API key provider AI** | **Wajib minimal satu.** Bot memakai rantai [Griphub](/koneksi-ai/griphub.md) → [OhhMyAgent](/koneksi-ai/ohhmyagent.md) → Gemini; yang kuncinya kosong dilewati                               |
| **API key Gemini**      | Opsional tapi sangat disarankan — tanpa ini bot **tuli**. Gratis di [aistudio.google.com](https://aistudio.google.com/app/apikey), lihat [Google AI Studio](/koneksi-ai/google-ai-studio.md) |
| **Nomor WhatsApp**      | Nomor khusus bot lebih aman daripada nomor pribadi                                                                                                                                           |
| ffmpeg                  | **Tidak perlu** — sudah dibundel via `ffmpeg-static`                                                                                                                                         |
| Python 3                | Opsional — hanya untuk unduh sosmed (yt-dlp) dan runtime python workspace                                                                                                                    |

## Langkah demi langkah

{% stepper %}
{% step %}

### Clone & install

```bash
git clone https://github.com/AnakTentara/AI-Haikaru.git
cd AI-Haikaru
npm install
```

Kalau `npm install` gagal di paket native (sharp dsb.), pastikan versi Node-mu ≥18 dan arsitekturnya umum (x64/arm64) — paket-paket ini memakai prebuild, bukan kompilasi.
{% endstep %}

{% step %}

### Konfigurasi `.env`

```bash
cp .env.example .env
```

Minimum supaya hidup — **cukup salah satu** dari dua blok ini:

```env
# Provider primer (disarankan)
GRIPHUB_API_KEY=key-griphub-kamu
GRIPHUB_BASE_URL=https://griphubrouter.web.id/v1
GRIPHUB_MODEL=claude-sonnet-5
GRIPHUB_PREMIUM_MODEL=claude-opus-5
```

```env
# Cadangan ke-2 — boleh diisi berdampingan dengan yang di atas
API_KEY=sk-key-ohhmyagent-kamu
BASE_URL=https://ohhmyagent.com
MODEL=ohh/gpt-5.6
PREMIUM_MODEL=ohh/opus-5
```

Mengisi keduanya bukan pemborosan: kalau yang pertama kena kuota atau tumbang, bot **pindah sendiri** ke yang kedua tanpa user perlu tahu.

Yang disarankan sekalian:

```env
# Telinga bot — tanpa ini voice note tidak pernah terbaca.
# Key yang sama juga jadi penyedia pencarian web cadangan
# DAN kaki terakhir rantai chat.
GEMINI_API_KEY_1=AIzaSy-key1
GEMINI_API_KEY_FALLBACK_1=AIzaSy-key2

# Pencarian web — tanpa ini bot tidak bisa mengecek apa pun yang berubah
# hari ini (dan dia akan bilang begitu, bukan menebak). Gratis, tanpa kartu.
TAVILY_API_KEY=tvly-key-kamu

# Hosting website workspace
PUBLIC_BASE_URL=https://domain-kamu.com
SITE_PORT=

# Portal /config di dashboard web — tanpa token, halamannya MATI (fail closed)
CONFIG_TOKEN=hasil-openssl-rand-hex-32
```

{% hint style="danger" %}
**Jangan pernah commit `.env`** — isinya kredensial asli. Sudah ada di `.gitignore`, biarkan begitu.
{% endhint %}

Penjelasan tiap variabel ada di [peta koneksi AI](/koneksi-ai/koneksi-ai.md).
{% endstep %}

{% step %}

### Sesuaikan `config.json`

```bash
cp config.example.json config.json
```

Isi yang perlu disentuh:

```json
{
  "prefix": ".",
  "botName": "AI-Haikaru",
  "targetUserIds": [
    "628xxxxxxxxxx"
  ],
  "port": 3000
}
```

`targetUserIds` adalah **identitas bot sendiri** (untuk deteksi mention). Setelah login pertama, tambahkan juga LID bot — angkanya muncul di log start (`myLID`).

{% hint style="warning" %}
Tanpa LID, mention di sebagian grup **tidak terdeteksi** — dan tidak ada error apa pun yang memberitahumu. Lihat [Troubleshooting](/referensi/troubleshooting.md).
{% endhint %}

{% hint style="info" %}
`config.json` **tidak dilacak git** — dashboard `/config` menulisinya, dan kalau ikut ter-commit maka `git pull` berikutnya gagal (dan API key mendarat di repo). Templatnya `config.example.json`; `run.sh` menyalinnya otomatis kalau belum ada.
{% endhint %}
{% endstep %}

{% step %}

### Jalankan

{% tabs %}
{% tab title="Development" %}

```bash
npm start
```

{% endtab %}

{% tab title="Produksi (Linux)" %}

```bash
./run.sh
```

Script ini juga memasang & menyegarkan yt-dlp otomatis, dan menyalin `config.example.json` kalau `config.json` belum ada.
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Scan QR

1. Terminal menampilkan QR code (juga tersedia di `http://localhost:3000/` selama belum login)
2. WhatsApp di ponsel → **Pengaturan** → **Perangkat Tertaut** → **Tautkan Perangkat**
3. Scan → tunggu `Own LID session created successfully` di log
4. Kirim chat pribadi ke nomor bot: *"halo!"*

{% hint style="danger" %}
Sesi tersimpan di `data/baileys_auth/`. **Folder itu = akun WhatsApp bot** — siapa pun yang menyalinnya bisa mengambil alih akunnya. Jangan pernah dibagikan atau di-commit.
{% endhint %}

Restart tidak perlu scan ulang.
{% endstep %}
{% endstepper %}

## Verifikasi fitur

Urutan tes yang enak setelah bot hidup:

| Tes                  | Perintah                                                                                                           |
| -------------------- | ------------------------------------------------------------------------------------------------------------------ |
| Bot hidup            | `.ping`                                                                                                            |
| AI jalan             | "halo, kamu siapa?"                                                                                                |
| Vision               | kirim foto + "ini gambar apa?"                                                                                     |
| Audio (butuh Gemini) | kirim VN                                                                                                           |
| Workspace            | `/ws` lalu *"bikin project halo dunia pakai python, jalanin"*                                                      |
| Hosting              | *"bikinin website satu halaman terus hostingin"* — lihat [Hosting Website](/coding-and-hosting/hosting-website.md) |

## Struktur `data/` yang terbentuk

```
data/
├── baileys_auth/     # sesi WhatsApp — JANGAN disentuh/dibagikan
├── history/          # riwayat chat per chat (JSON)
├── memory/           # memori per chat
├── media/            # arsip media masuk (dibersihkan 30 hari)
├── generated/        # file buatan bot (dibersihkan 7 hari)
├── audio_archive/    # arsip voice note + transkrip
└── workspaces/       # workspace coding + situs
    ├── index/        # metadata per pemilik
    ├── files/<id>/   # isi tiap workspace
    ├── users.json    # tautan identitas nomor↔LID
    └── usernames.json# username publik untuk URL situs
```

{% hint style="warning" %}
Seluruh `data/` ada di `.gitignore` — di dalamnya ada percakapan asli orang. **Backup folder ini** kalau botmu menyimpan hal penting; jangan pernah meng-commit-nya.
{% endhint %}

## Berikutnya

* Produksi di panel: [Deploy di Pterodactyl](/tentang/deploy-pterodactyl.md)
* Semua perintah: [Referensi Perintah](/referensi/perintah.md)
* Ada masalah: [Troubleshooting](/referensi/troubleshooting.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.haikaldev.my.id/tentang/instalasi.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
