sarangai-cli 1.0.2 → 1.0.4

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 (2) hide show
  1. package/dist/index.cjs +39 -33
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -59,7 +59,7 @@ function saveConfig(newConfig) {
59
59
  var program = new import_commander.Command();
60
60
  function resolveBaseUrl() {
61
61
  const cfg = getConfig();
62
- return process.env.SARANGAI_BASE_URL || cfg.baseUrl || "https://api.sarang.ai";
62
+ return process.env.SARANGAI_BASE_URL || cfg.baseUrl || "https://idshop.or.id";
63
63
  }
64
64
  function getGitBranch() {
65
65
  try {
@@ -81,7 +81,7 @@ function renderBanner(modelName) {
81
81
  console.log(import_chalk.default.cyanBright(banner));
82
82
  console.log(import_chalk.default.gray(" Tips for getting started:"));
83
83
  console.log(import_chalk.default.gray(" 1. Ketik pesan Anda langsung untuk chat streaming."));
84
- console.log(import_chalk.default.gray(" 2. Perintah khusus: ") + import_chalk.default.yellow("/clear") + import_chalk.default.gray(" (bersihkan layar), ") + import_chalk.default.yellow("/model <id>") + import_chalk.default.gray(", ") + import_chalk.default.yellow("/exit") + import_chalk.default.gray("."));
84
+ console.log(import_chalk.default.gray(" 2. Perintah: ") + import_chalk.default.yellow("/clear") + import_chalk.default.gray(", ") + import_chalk.default.yellow("/model <id>") + import_chalk.default.gray(", ") + import_chalk.default.yellow("/exit") + import_chalk.default.gray("."));
85
85
  console.log("");
86
86
  const cwd = import_path2.default.basename(process.cwd());
87
87
  const branch = getGitBranch();
@@ -94,7 +94,7 @@ function renderBanner(modelName) {
94
94
  async function startInteractiveSession(initialModel) {
95
95
  const cfg = getConfig();
96
96
  if (!cfg.apiKey) {
97
- console.log(import_chalk.default.yellow("Silakan login terlebih dahulu: sarang login"));
97
+ console.log(import_chalk.default.yellow("\nSilakan login terlebih dahulu: sarang login\n"));
98
98
  return;
99
99
  }
100
100
  let currentModel = initialModel || cfg.defaultModel || "minimax/minimax-m2.7";
@@ -133,7 +133,7 @@ async function startInteractiveSession(initialModel) {
133
133
  `));
134
134
  } else {
135
135
  console.log(import_chalk.default.yellow(`
136
- Format: /model <model-id> (contoh: /model openai/gpt-4o-mini)
136
+ Format: /model <model-id>
137
137
  `));
138
138
  }
139
139
  ask();
@@ -201,26 +201,44 @@ Error: ${err.message}
201
201
  };
202
202
  ask();
203
203
  }
204
- program.name("sarang").description(import_chalk.default.cyanBright("SarangAI CLI \u2014 Gateway ratusan model AI langsung di terminal")).version("1.0.0").action(() => {
204
+ program.name("sarang").description(import_chalk.default.cyanBright("SarangAI CLI \u2014 Gateway ratusan model AI langsung di terminal")).version("1.0.3").action(() => {
205
205
  startInteractiveSession();
206
206
  });
207
207
  program.command("login").description("Hubungkan API Key SarangAI akun Anda").action(async () => {
208
+ const baseUrl = resolveBaseUrl();
209
+ console.log(import_chalk.default.cyanBright("\n\u{1F510} Autentikasi SarangAI CLI"));
210
+ console.log(import_chalk.default.gray("Dapatkan API Key di: ") + import_chalk.default.underline.cyan(`${baseUrl}/dashboard`));
211
+ console.log(import_chalk.default.gray("--------------------------------------------------\n"));
208
212
  const res = await (0, import_prompts.default)({
209
213
  type: "password",
210
214
  name: "key",
211
- message: "Masukkan SarangAI API Key Anda (dari dashboard panel):"
215
+ message: "Masukkan API Key:"
212
216
  });
213
217
  if (!res.key) {
214
- console.log(import_chalk.default.red("Login dibatalkan."));
218
+ console.log(import_chalk.default.red("\nLogin dibatalkan.\n"));
215
219
  return;
216
220
  }
217
221
  saveConfig({ apiKey: res.key.trim() });
218
- console.log(import_chalk.default.green("\u2714 API Key berhasil disimpan di ~/.sarangairc"));
222
+ console.log(import_chalk.default.green("\n\u2714 Berhasil! API Key tersimpan di ~/.sarangairc\n"));
223
+ });
224
+ program.command("set-url [url]").description("Atur Base URL Gateway SarangAI").action(async (url) => {
225
+ let target = url;
226
+ if (!target) {
227
+ const res = await (0, import_prompts.default)({
228
+ type: "text",
229
+ name: "url",
230
+ message: "Masukkan URL Gateway:"
231
+ });
232
+ target = res.url;
233
+ }
234
+ if (!target) return;
235
+ saveConfig({ baseUrl: target.trim().replace(/\/+$/, "") });
236
+ console.log(import_chalk.default.green(`\u2714 Base URL diatur ke: ${target.trim()}`));
219
237
  });
220
238
  program.command("balance").description("Cek sisa saldo kredit akun SarangAI Anda").action(async () => {
221
239
  const cfg = getConfig();
222
240
  if (!cfg.apiKey) {
223
- console.log(import_chalk.default.yellow("Anda belum login. Jalankan: sarang login"));
241
+ console.log(import_chalk.default.yellow("\nAnda belum login. Jalankan: sarang login\n"));
224
242
  return;
225
243
  }
226
244
  const baseUrl = resolveBaseUrl();
@@ -234,7 +252,7 @@ program.command("balance").description("Cek sisa saldo kredit akun SarangAI Anda
234
252
  try {
235
253
  data = JSON.parse(rawText);
236
254
  } catch {
237
- throw new Error(`Endpoint mengembalikan respons non-JSON (${res.status}): ${rawText.slice(0, 120)}...`);
255
+ throw new Error(`Respons server non-JSON (${res.status}): ${rawText.slice(0, 100)}`);
238
256
  }
239
257
  spinner.stop();
240
258
  if (!res.ok) throw new Error(data.error || `HTTP ${res.status}`);
@@ -246,11 +264,11 @@ program.command("balance").description("Cek sisa saldo kredit akun SarangAI Anda
246
264
  spinner.fail(import_chalk.default.red(err.message));
247
265
  }
248
266
  });
249
- program.command("models").option("-s, --search <keyword>", "Filter nama model (contoh: claude, deepseek, free)").description("Daftar model AI yang tersedia di SarangAI Gateway").action(async (cmd) => {
267
+ program.command("models").option("-s, --search <keyword>", "Filter nama model").description("Daftar model AI yang tersedia").action(async (cmd) => {
250
268
  var _a;
251
269
  const cfg = getConfig();
252
270
  if (!cfg.apiKey) {
253
- console.log(import_chalk.default.yellow("Anda belum login. Jalankan: sarang login"));
271
+ console.log(import_chalk.default.yellow("\nAnda belum login. Jalankan: sarang login\n"));
254
272
  return;
255
273
  }
256
274
  const baseUrl = resolveBaseUrl();
@@ -270,34 +288,22 @@ program.command("models").option("-s, --search <keyword>", "Filter nama model (c
270
288
  if (!res.ok) throw new Error(((_a = data.error) == null ? void 0 : _a.message) || data.error || `HTTP ${res.status}`);
271
289
  let list = Array.isArray(data) ? data : data.data || [];
272
290
  if (list.length === 0) {
273
- console.log(import_chalk.default.yellow("Tidak ada model aktif yang ditemukan."));
291
+ console.log(import_chalk.default.yellow("Tidak ada model yang ditemukan."));
274
292
  return;
275
293
  }
276
294
  if (cmd.search) {
277
- const query = cmd.search.toLowerCase();
278
- list = list.filter((m) => {
279
- const id = (m.id || m.modelId || m.name || "").toLowerCase();
280
- return id.includes(query);
281
- });
282
- }
283
- if (list.length === 0) {
284
- console.log(import_chalk.default.yellow(`
285
- Tidak ada model yang cocok dengan kata kunci "${cmd.search}".
286
- `));
287
- return;
295
+ const q = cmd.search.toLowerCase();
296
+ list = list.filter((m) => (m.id || m.modelId || m.name || "").toLowerCase().includes(q));
288
297
  }
289
298
  console.log(import_chalk.default.bold(`
290
- Model Tersedia (${list.length}${cmd.search ? ` cocok dengan "${cmd.search}"` : ""}):`));
299
+ Model Tersedia (${list.length}):`));
291
300
  console.log(import_chalk.default.gray("---------------------------------------------------------"));
292
301
  list.forEach((m) => {
293
302
  const id = m.id || m.modelId || m.name;
294
303
  const isCurrent = id === cfg.defaultModel;
295
- const prefix = isCurrent ? import_chalk.default.green("\u2714 [Aktif] ") : " ";
296
- console.log(`${prefix}${import_chalk.default.cyan(id)}`);
304
+ console.log(`${isCurrent ? import_chalk.default.green("\u2714 [Aktif] ") : " "}${import_chalk.default.cyan(id)}`);
297
305
  });
298
- console.log(import_chalk.default.gray("---------------------------------------------------------"));
299
- console.log(import_chalk.default.dim("Ganti model default : sarang set-model <model-id>"));
300
- console.log(import_chalk.default.dim('Chat model tertentu : sarang chat -m <model-id> "..."\n'));
306
+ console.log(import_chalk.default.gray("---------------------------------------------------------\n"));
301
307
  } catch (err) {
302
308
  spinner.fail(import_chalk.default.red(err.message));
303
309
  }
@@ -308,7 +314,7 @@ program.command("set-model [modelId]").description("Atur model default untuk cha
308
314
  const res = await (0, import_prompts.default)({
309
315
  type: "text",
310
316
  name: "model",
311
- message: "Masukkan Model ID default baru (contoh: minimax/minimax-m2.7):"
317
+ message: "Masukkan Model ID default baru:"
312
318
  });
313
319
  target = res.model;
314
320
  }
@@ -316,7 +322,7 @@ program.command("set-model [modelId]").description("Atur model default untuk cha
316
322
  saveConfig({ defaultModel: target.trim() });
317
323
  console.log(import_chalk.default.green(`\u2714 Default model berhasil diubah ke: ${target.trim()}`));
318
324
  });
319
- program.command("chat [prompt...]").option("-m, --model <modelId>", "Pilih model AI spesifik").description("Kirim instruksi / chat ke AI (Mendukung streaming teks atau Unix Pipe)").action(async (promptArr, cmd) => {
325
+ program.command("chat [prompt...]").option("-m, --model <modelId>", "Pilih model spesifik").description("Kirim instruksi / chat (Mendukung streaming teks atau Unix Pipe)").action(async (promptArr, cmd) => {
320
326
  var _a, _b, _c, _d, _e;
321
327
  let prompt = promptArr == null ? void 0 : promptArr.join(" ");
322
328
  if (!process.stdin.isTTY) {
@@ -335,7 +341,7 @@ ${pipedData}` : pipedData;
335
341
  }
336
342
  const cfg = getConfig();
337
343
  if (!cfg.apiKey) {
338
- console.log(import_chalk.default.yellow("Silakan login terlebih dahulu: sarang login"));
344
+ console.log(import_chalk.default.yellow("\nSilakan login terlebih dahulu: sarang login\n"));
339
345
  return;
340
346
  }
341
347
  const baseUrl = resolveBaseUrl();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sarangai-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "CLI resmi SarangAI — Gateway multi-model AI langsung dari terminal Anda",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {