sarangai-cli 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +34 -70
  2. package/dist/index.js +39 -10
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,104 +1,68 @@
1
1
  # SarangAI CLI
2
2
 
3
- Akses 400+ model AI unggulan (DeepSeek, Claude, GPT, Qwen, Minimax, dsb.) langsung dari terminal Anda melalui SarangAI Gateway.
3
+ Gateway AI Coding Workspace interaktif langsung dari terminal Anda, didukung oleh model-model reasoning & coding terbaik dunia (Anthropic, OpenAI, DeepSeek, Alibaba, Google, Meta).
4
4
 
5
5
  ---
6
6
 
7
7
  ## Fitur Utama
8
8
 
9
- - **Streaming Teks Cepat**: Respons AI mengalir secara real-time langsung di terminal.
10
- - **Katalog 400+ Model**: Jelajahi dan gunakan ratusan varian model AI populer.
11
- - **Pencarian Cepat**: Filter model berdasarkan nama, provider, atau model gratis.
12
- - **Dukungan Unix Piping**: Teruskan output perintah bash/kode program langsung ke AI.
13
- - **Manajemen Saldo**: Cek status kredit akun langsung lewat terminal.
9
+ - **Interactive Terminal Workspace (TUI)**: Antarmuka terminal interaktif modern berbasis full-screen alternate buffer tanpa flicker.
10
+ - **Top Coding Models (1 Brand = 1 Flagship)**: Dikurasi khusus untuk programming, arsitektur sistem, dan debugging mendalam:
11
+ - Claude 3.7 Sonnet (Anthropic) - Architecture & Agentic coding
12
+ - GPT-4o (OpenAI) - Fast full-stack & complex logic
13
+ - DeepSeek-R1 (DeepSeek) - Deep reasoning & hard algorithms
14
+ - Qwen 2.5 Coder 32B (Alibaba) - Multi-language syntax specialist
15
+ - Gemini 2.5 Flash (Google) - 1M context & full repo analysis
16
+ - Llama 3.3 70B (Meta) - Robust open-source coding engine
17
+ - **Real-Time Streaming**: Output kode dan respons AI mengalir seketika (zero-latency stream).
18
+ - **Auto-Auth via Browser**: Login cepat dan aman tanpa perlu input API Key manual.
19
+ - **Credit & Tier Monitoring**: Pantau sisa saldo credit secara live langsung di dalam terminal.
14
20
 
15
21
  ---
16
22
 
17
23
  ## Instalasi
18
24
 
19
- Instal paket secara global menggunakan npm:
25
+ Pastikan Node.js (>= 18) telah terpasang, lalu instal paket secara global:
20
26
 
21
- ```bash
22
- npm install -g sarangai-cli
23
- ```
27
+ npm install -g sarangai-cli@latest
24
28
 
25
29
  ---
26
30
 
27
- ## Panduan Penggunaan
31
+ ## Memulai Workspace Interaktif
28
32
 
29
- ### 1. Autentikasi
30
- Dapatkan API Key dari dashboard akun SarangAI Anda, lalu hubungkan ke CLI:
33
+ Cukup jalankan satu perintah:
31
34
 
32
- ```bash
33
- sarang login
34
- ```
35
+ sarang
35
36
 
36
- API Key akan disimpan di berkas konfigurasi lokal `~/.sarangairc`.
37
+ Terminal akan otomatis menampilkan modal seleksi model coding, ringkasan saldo akun, dan opsi masuk ke ruang kerja (Workspace).
37
38
 
38
- ### 2. Cek Saldo Kredit
39
- Lihat sisa saldo kredit dan status akun:
39
+ ### Navigasi Keyboard:
40
+ - [↑/↓] (Panah) : Navigasi antar opsi dan pilihan model.
41
+ - [Enter / Space] : Konfirmasi pilihan / Masuk ke Workspace.
42
+ - [c] : Salin tautan dashboard referal ke clipboard.
43
+ - [Esc] : Mengakhiri sesi aktif di Workspace dan kembali ke menu seleksi.
44
+ - [q] : Keluar dari SarangAI CLI.
40
45
 
41
- ```bash
42
- sarang balance
43
- ```
44
-
45
- ### 3. Jelajahi dan Filter Model
46
- Melihat seluruh model yang tersedia:
47
-
48
- ```bash
49
- sarang models
50
- ```
51
-
52
- Menyaring model berdasarkan kata kunci:
53
-
54
- ```bash
55
- sarang models -s deepseek
56
- sarang models -s claude
57
- sarang models -s free
58
- ```
59
-
60
- ### 4. Ganti Default Model
61
- Tentukan model yang selalu digunakan secara otomatis:
62
-
63
- ```bash
64
- sarang set-model minimax/minimax-m2.7
65
- ```
66
-
67
- ### 5. Chat & Streaming
68
- Mengirim prompt langsung:
69
-
70
- ```bash
71
- sarang chat "Jelaskan konsep index di database PostgreSQL."
72
- ```
73
-
74
- Menggunakan model tertentu tanpa mengubah default:
75
-
76
- ```bash
77
- sarang chat -m anthropic/claude-sonnet-4 "Buatkan regex validasi nomor telepon Indonesia."
78
- ```
46
+ ---
79
47
 
80
- ### 6. Integrasi Unix Piping
81
- Membaca input langsung dari terminal atau berkas kode:
48
+ ## Autentikasi Otomatis
82
49
 
83
- ```bash
84
- cat main.py | sarang chat "Review potensi bug dan tingkatkan performa kode ini."
85
- git diff | sarang chat "Buatkan pesan commit yang ringkas berdasarkan perubahan ini."
86
- ```
50
+ Jika pertama kali menggunakan CLI:
51
+ 1. Jalankan `sarang`.
52
+ 2. CLI akan mengenerate tautan otorisasi unik dan otomatis menyalinnya ke clipboard.
53
+ 3. Buka tautan tersebut di browser untuk mengizinkan sesi.
54
+ 4. Terminal akan otomatis mendeteksi sesi dan menyimpan token ke `~/.sarangairc`.
87
55
 
88
56
  ---
89
57
 
90
58
  ## Konfigurasi Gateway
91
59
 
92
- Secara default, CLI membaca konfigurasi dari `~/.sarangairc` atau environment variable `SARANGAI_BASE_URL`.
93
-
94
- Untuk gateway self-hosted atau pengujian lokal:
60
+ Secara default, CLI terhubung ke `[https://idshop.or.id](https://idshop.or.id)`. Jika Anda menggunakan custom gateway atau development server lokal:
95
61
 
96
- ```bash
97
- export SARANGAI_BASE_URL="http://localhost:3001"
98
- ```
62
+ export SARANGAI_BASE_URL="http://localhost:3001"
99
63
 
100
64
  ---
101
65
 
102
66
  ## Lisensi
103
67
 
104
- MIT
68
+ MIT License (c) SarangAI
package/dist/index.js CHANGED
@@ -35,12 +35,12 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "sarangai-cli",
38
- version: "1.0.9",
38
+ version: "1.0.11",
39
39
  description: "CLI resmi SarangAI \u2014 Gateway multi-model AI langsung dari terminal Anda",
40
40
  main: "dist/index.js",
41
41
  bin: {
42
42
  sarang: "dist/index.js",
43
- sarangai: "dist/index.cjs"
43
+ sarangai: "dist/index.js"
44
44
  },
45
45
  files: [
46
46
  "dist"
@@ -131,8 +131,8 @@ var greenDot = import_chalk.default.hex("#4ade80");
131
131
  var grayMuted = import_chalk.default.hex("#94a3b8");
132
132
  var CODING_MODELS = [
133
133
  {
134
- id: "anthropic/claude-3.7-sonnet",
135
- name: "Claude 3.7 Sonnet",
134
+ id: "anthropic/claude-sonnet-4.6",
135
+ name: "Claude Sonnet 4.6",
136
136
  desc: "Anthropic \u2022 Best coding & agentic workflow",
137
137
  rate: "12,000 Credits/hr"
138
138
  },
@@ -183,20 +183,20 @@ function copyToClipboard(text) {
183
183
  }
184
184
  async function fetchUserMeta(baseUrl2, apiKey) {
185
185
  try {
186
- const res = await fetch(`${baseUrl2}/api/user/stats`, {
186
+ const res = await fetch(`${baseUrl2}/api/gateway/v1/balance`, {
187
187
  headers: { Authorization: `Bearer ${apiKey}` }
188
188
  });
189
189
  if (res.ok) {
190
190
  const d = await res.json();
191
191
  return {
192
- balance: d.balance ?? 75313,
192
+ balance: d.balance ?? 0,
193
193
  tier: d.tier || "DEVELOPER",
194
- accountId: d.accountId || "SA-8WwREVSJ"
194
+ accountId: d.accountId ? `SA-${d.accountId}` : "SA-\u2014"
195
195
  };
196
196
  }
197
197
  } catch {
198
198
  }
199
- return { balance: 75313, tier: "DEVELOPER", accountId: "SA-8WwREVSJ" };
199
+ return { balance: 0, tier: "DEVELOPER", accountId: "SA-\u2014" };
200
200
  }
201
201
  function getDisplayDir() {
202
202
  const cwd = process.cwd();
@@ -378,7 +378,7 @@ function enterWorkspace() {
378
378
  }
379
379
  }, 1e3);
380
380
  }
381
- async function runPromptStream(query) {
381
+ async function runPromptStream(query, isRetry = false) {
382
382
  isExecuting = true;
383
383
  process.stdout.write("\x1B[?25l");
384
384
  const pad = getCenterPad(72);
@@ -399,9 +399,31 @@ async function runPromptStream(query) {
399
399
  })
400
400
  });
401
401
  if (!res.ok) {
402
+ let detail = res.statusText || `HTTP ${res.status}`;
403
+ try {
404
+ const errBody = await res.json();
405
+ const msg = errBody?.error?.message || errBody?.error || errBody?.message;
406
+ if (msg) detail = typeof msg === "string" ? msg : JSON.stringify(msg);
407
+ } catch {
408
+ }
402
409
  console.log(pad + import_chalk.default.red(`
403
- Error: ${res.statusText}
410
+ Error (${res.status}): ${detail}
404
411
  `));
412
+ if (res.status === 401 && !isRetry) {
413
+ console.log(pad + import_chalk.default.yellow("API key tidak valid atau sudah di-revoke. Memulai ulang otorisasi...\n"));
414
+ try {
415
+ saveConfig({ apiKey: void 0 });
416
+ } catch {
417
+ }
418
+ cfg = getConfig();
419
+ const newKey = await handleAutoAuth(baseUrl);
420
+ if (newKey) {
421
+ cfg = getConfig();
422
+ userMeta = await fetchUserMeta(baseUrl, cfg.apiKey || "");
423
+ return runPromptStream(query, true);
424
+ }
425
+ console.log(pad + import_chalk.default.red("Otorisasi ulang dibatalkan.\n"));
426
+ }
405
427
  } else {
406
428
  const reader = res.body?.getReader();
407
429
  const decoder = new TextDecoder();
@@ -468,6 +490,13 @@ async function handleAutoAuth(baseUrl2) {
468
490
  async function startInteractiveSession() {
469
491
  cfg = getConfig();
470
492
  baseUrl = resolveBaseUrl();
493
+ const MODEL_MIGRATIONS = {
494
+ "anthropic/claude-3.7-sonnet": "anthropic/claude-sonnet-4.6"
495
+ };
496
+ if (cfg.defaultModel && MODEL_MIGRATIONS[cfg.defaultModel]) {
497
+ cfg.defaultModel = MODEL_MIGRATIONS[cfg.defaultModel];
498
+ saveConfig({ defaultModel: cfg.defaultModel });
499
+ }
471
500
  if (!cfg.apiKey) {
472
501
  const key = await handleAutoAuth(baseUrl);
473
502
  if (!key) {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "sarangai-cli",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "CLI resmi SarangAI — Gateway multi-model AI langsung dari terminal Anda",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "sarang": "dist/index.js",
8
- "sarangai": "dist/index.cjs"
8
+ "sarangai": "dist/index.js"
9
9
  },
10
10
  "files": [
11
11
  "dist"