kiosapi 0.1.1 → 0.1.2

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.
package/dist/api.js CHANGED
@@ -21,6 +21,22 @@ export async function fetchModels() {
21
21
  const body = (await res.json());
22
22
  return body.data ?? [];
23
23
  }
24
+ /** Latest published version of the CLI on npm (best-effort; null on failure/offline). */
25
+ export async function fetchLatestVersion(timeoutMs = 2500) {
26
+ try {
27
+ const ctrl = new AbortController();
28
+ const timer = setTimeout(() => ctrl.abort(), timeoutMs);
29
+ const res = await fetch('https://registry.npmjs.org/kiosapi/latest', { signal: ctrl.signal });
30
+ clearTimeout(timer);
31
+ if (!res.ok)
32
+ return null;
33
+ const body = (await res.json());
34
+ return body.version ?? null;
35
+ }
36
+ catch {
37
+ return null;
38
+ }
39
+ }
24
40
  /** Best-effort: does a model support tool calling? Defaults to true if unknown/offline. */
25
41
  export async function modelSupportsTools(id) {
26
42
  try {
package/dist/commands.js CHANGED
@@ -5,8 +5,9 @@ import { createInterface } from 'node:readline/promises';
5
5
  import { parseArgs } from 'node:util';
6
6
  import { runAgent } from './agent/run.js';
7
7
  import { runTeam } from './agent/team.js';
8
- import { createTopup, fetchBytesAuthed, fetchModels, fetchPemakaian, fetchSaldo, generateImage, modelSupportsTools, pollJob, resolveMediaModel, resolveModel, streamChat, streamVision, submitVideo, } from './api.js';
8
+ import { createTopup, fetchBytesAuthed, fetchLatestVersion, fetchModels, fetchPemakaian, fetchSaldo, generateImage, modelSupportsTools, pollJob, resolveMediaModel, resolveModel, streamChat, streamVision, submitVideo, } from './api.js';
9
9
  import { clearKey, fileConfig, loadConfig, saveConfig } from './config.js';
10
+ import { VERSION } from './help.js';
10
11
  import { bold, cyan, dim, green, idn, prompt, promptHidden, readStdin, red, rupiah, sleep, thinking, yellow, } from './ui.js';
11
12
  const IMAGE_MIME = {
12
13
  '.png': 'image/png',
@@ -48,6 +49,64 @@ export async function cmdPeriksa() {
48
49
  catch {
49
50
  console.log(red('tidak terhubung'));
50
51
  }
52
+ const latest = await fetchLatestVersion();
53
+ const upd = latest && isNewerVersion(latest, VERSION)
54
+ ? yellow(` → versi ${latest} tersedia (kiosapi perbarui)`)
55
+ : latest
56
+ ? green(' ✓ terbaru')
57
+ : '';
58
+ console.log(` Versi : ${VERSION}${upd}`);
59
+ }
60
+ /** Compare two dotted versions; true if `latest` is strictly newer than `current`. */
61
+ function isNewerVersion(latest, current) {
62
+ const a = latest.split('.').map((n) => Number(n) || 0);
63
+ const b = current.split('.').map((n) => Number(n) || 0);
64
+ for (let i = 0; i < 3; i++) {
65
+ if ((a[i] ?? 0) !== (b[i] ?? 0))
66
+ return (a[i] ?? 0) > (b[i] ?? 0);
67
+ }
68
+ return false;
69
+ }
70
+ /** perbarui — update the CLI to the latest npm version (or print the manual command). */
71
+ export async function cmdPerbarui() {
72
+ const latest = await fetchLatestVersion();
73
+ if (!latest) {
74
+ console.log(dim('Tak bisa cek versi terbaru (offline?).'));
75
+ console.log(`Update manual: ${cyan('npm i -g kiosapi@latest')}`);
76
+ return;
77
+ }
78
+ if (!isNewerVersion(latest, VERSION)) {
79
+ console.log(green(`✓ Sudah versi terbaru (${VERSION}).`));
80
+ return;
81
+ }
82
+ console.log(`Versi baru ${green(latest)} (sekarang ${VERSION}). Memperbarui…`);
83
+ const res = spawnSync('npm', ['i', '-g', `kiosapi@${latest}`], {
84
+ stdio: 'inherit',
85
+ shell: process.platform === 'win32',
86
+ });
87
+ if (res.status === 0) {
88
+ console.log(green(`✓ Terpasang kiosapi ${latest}.`));
89
+ }
90
+ else {
91
+ console.log(yellow('Gagal update otomatis. Jalankan manual:'));
92
+ console.log(` ${cyan('npm i -g kiosapi@latest')}`);
93
+ }
94
+ }
95
+ /** Once-a-day best-effort "versi baru tersedia" nudge (TTY only; cached in config). */
96
+ export async function maybeNotifyUpdate() {
97
+ if (!process.stdout.isTTY)
98
+ return;
99
+ const cfg = fileConfig();
100
+ const now = Date.now();
101
+ const DAY = 24 * 3_600_000;
102
+ let latest = cfg.latestVersion;
103
+ if (!cfg.updateCheckedAt || now - cfg.updateCheckedAt > DAY) {
104
+ latest = (await fetchLatestVersion(1500)) ?? undefined;
105
+ saveConfig({ updateCheckedAt: now, latestVersion: latest });
106
+ }
107
+ if (latest && isNewerVersion(latest, VERSION)) {
108
+ console.log(yellow(`Versi baru kiosapi ${latest} tersedia (sekarang ${VERSION}). Jalankan: kiosapi perbarui`));
109
+ }
51
110
  }
52
111
  /** model — list available models. `--cari q` filters; `--tools` shows only tool-capable models. */
53
112
  export async function cmdModel(args) {
package/dist/help.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { bold, dim } from './ui.js';
2
- export const VERSION = '0.1.1';
2
+ export const VERSION = '0.1.2';
3
3
  export function printVersion() {
4
4
  console.log(`kiosapi ${VERSION}`);
5
5
  }
@@ -12,7 +12,8 @@ ${bold('Penggunaan:')} kiosapi [perintah] [opsi]
12
12
  ${bold('Perintah:')}
13
13
  masuk Simpan API key (kios_live_…)
14
14
  keluar Hapus API key tersimpan
15
- periksa Cek konektivitas, key, & setelan
15
+ periksa Cek konektivitas, key, versi & setelan
16
+ perbarui Update CLI ke versi npm terbaru
16
17
  model [--cari q] Daftar model (--tools = hanya yang mendukung tool/agen; 🔧)
17
18
  tanya "…" Tanya sekali (streaming); dukung pipe stdin
18
19
  ngobrol Mode percakapan interaktif (REPL)
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { cmdBuat, cmdEdit, cmdGambar, cmdIsi, cmdKeluar, cmdLihat, cmdMasuk, cmdModel, cmdNgobrol, cmdPakai, cmdPeriksa, cmdRencana, cmdSaldo, cmdSambung, cmdSetel, cmdTanya, cmdTim, cmdVideo, } from './commands.js';
2
+ import { cmdBuat, cmdEdit, cmdGambar, cmdIsi, cmdKeluar, cmdLihat, cmdMasuk, cmdModel, cmdNgobrol, cmdPakai, cmdPerbarui, cmdPeriksa, cmdRencana, cmdSaldo, cmdSambung, cmdSetel, cmdTanya, cmdTim, cmdVideo, } from './commands.js';
3
3
  import { printHelp, printVersion } from './help.js';
4
4
  import { startSession } from './session.js';
5
5
  import { red } from './ui.js';
@@ -11,6 +11,8 @@ const COMMANDS = {
11
11
  logout: cmdKeluar,
12
12
  periksa: cmdPeriksa,
13
13
  doctor: cmdPeriksa,
14
+ perbarui: cmdPerbarui,
15
+ update: cmdPerbarui,
14
16
  model: cmdModel,
15
17
  models: cmdModel,
16
18
  tanya: cmdTanya,
package/dist/session.js CHANGED
@@ -2,7 +2,7 @@ import { createInterface } from 'node:readline/promises';
2
2
  import { newSession, resetSession, runTurn } from './agent/run.js';
3
3
  import { runTeam } from './agent/team.js';
4
4
  import { resolveModel } from './api.js';
5
- import { cmdGambar, cmdIsi, cmdLihat, cmdMasuk, cmdPakai, cmdSaldo, cmdVideo, pickModel, warnIfNoTools, } from './commands.js';
5
+ import { cmdGambar, cmdIsi, cmdLihat, cmdMasuk, cmdPakai, cmdSaldo, cmdVideo, maybeNotifyUpdate, pickModel, warnIfNoTools, } from './commands.js';
6
6
  import { loadConfig } from './config.js';
7
7
  import { bold, cyan, dim, green, red } from './ui.js';
8
8
  const MODES = ['rencana', 'edit', 'buat'];
@@ -134,6 +134,7 @@ export async function startSession() {
134
134
  if (!loadConfig().apiKey)
135
135
  return;
136
136
  }
137
+ await maybeNotifyUpdate();
137
138
  const model = await resolveModel(undefined);
138
139
  const s = newSession(model, 'buat', false);
139
140
  banner(s);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiosapi",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "CLI Kiosapi.id berbahasa Indonesia — bangun aplikasimu pakai API key Kiosapi (agen + multimodal).",
6
6
  "keywords": [