chatnus 0.0.0-stage → 1.0.0
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/.env.example +16 -0
- package/README.md +385 -3
- package/dist/agentcfg.js +243 -0
- package/dist/agents.js +159 -0
- package/dist/catalog.js +33 -0
- package/dist/config.js +46 -0
- package/dist/gateway.js +335 -0
- package/dist/hub.js +318 -0
- package/dist/logs.js +69 -0
- package/dist/meter.js +104 -0
- package/dist/platform.js +139 -0
- package/dist/quota.js +82 -0
- package/dist/server.js +505 -0
- package/dist/sidecar.js +76 -0
- package/dist/skills.js +166 -0
- package/dist/store.js +43 -0
- package/dist/terminal.js +289 -0
- package/dist/tokensaver.js +76 -0
- package/dist/util.js +56 -0
- package/package.json +33 -6
- package/public/index.html +1 -0
- package/scripts/build-go.js +24 -0
- package/scripts/dev.js +10 -0
- package/sidecar/go.mod +3 -0
- package/sidecar/main.go +45 -0
- package/sidecar/main_test.go +118 -0
- package/sidecar/meter.go +114 -0
- package/sidecar/relay.go +433 -0
- package/sidecar/tokens.go +42 -0
- package/skills/ringkas-kode/SKILL.md +9 -0
- package/skills/ringkas-kode/run.js +5 -0
package/dist/skills.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.toggle = exports.remove = exports.safeName = exports.validName = void 0;
|
|
7
|
+
exports.list = list;
|
|
8
|
+
exports.read = read;
|
|
9
|
+
exports.write = write;
|
|
10
|
+
exports.install = install;
|
|
11
|
+
exports.run = run;
|
|
12
|
+
exports.prompt = prompt;
|
|
13
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
+
const node_child_process_1 = require("node:child_process");
|
|
16
|
+
const config_1 = require("./config");
|
|
17
|
+
const store_1 = require("./store");
|
|
18
|
+
const logs_1 = require("./logs");
|
|
19
|
+
const util_1 = require("./util");
|
|
20
|
+
const state = (0, store_1.open)('skills.json', { enabled: {} });
|
|
21
|
+
const NAME = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
22
|
+
const RUNNERS = { js: 'node', mjs: 'node', py: 'python', sh: 'bash', ps1: 'powershell', cmd: 'cmd' };
|
|
23
|
+
const validName = (n) => NAME.test(n);
|
|
24
|
+
exports.validName = validName;
|
|
25
|
+
const safeName = (n) => String(n).toLowerCase().replace(/[^a-z0-9_-]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 63);
|
|
26
|
+
exports.safeName = safeName;
|
|
27
|
+
const dirOf = (n) => (NAME.test(n) ? node_path_1.default.join(config_1.SKILLS_DIR, n) : null);
|
|
28
|
+
function parse(md) {
|
|
29
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(md);
|
|
30
|
+
if (!m)
|
|
31
|
+
return { meta: {}, body: md };
|
|
32
|
+
const meta = {};
|
|
33
|
+
for (const l of m[1].split(/\r?\n/)) {
|
|
34
|
+
const k = /^([\w-]+)\s*:\s*(.*)$/.exec(l);
|
|
35
|
+
if (k)
|
|
36
|
+
meta[k[1]] = k[2].replace(/^["']|["']$/g, '');
|
|
37
|
+
}
|
|
38
|
+
return { meta, body: m[2] };
|
|
39
|
+
}
|
|
40
|
+
const runnerFile = (d) => {
|
|
41
|
+
try {
|
|
42
|
+
return node_fs_1.default.readdirSync(d).find(f => /^run\.(js|mjs|py|sh|ps1|cmd)$/.test(f)) || null;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function list() {
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const n of node_fs_1.default.readdirSync(config_1.SKILLS_DIR)) {
|
|
51
|
+
const d = node_path_1.default.join(config_1.SKILLS_DIR, n), f = node_path_1.default.join(d, 'SKILL.md');
|
|
52
|
+
if (!NAME.test(n) || !node_fs_1.default.existsSync(f))
|
|
53
|
+
continue;
|
|
54
|
+
const { meta } = parse(node_fs_1.default.readFileSync(f, 'utf8'));
|
|
55
|
+
let source = null;
|
|
56
|
+
try {
|
|
57
|
+
source = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(d, '.nus-source.json'), 'utf8'));
|
|
58
|
+
}
|
|
59
|
+
catch { /* lokal */ }
|
|
60
|
+
out.push({ name: n, description: meta.description || '', enabled: state.data.enabled[n] !== false, runner: runnerFile(d), source: source ? { repo: source.repo, dir: source.dir, branch: source.branch, installedAt: source.installedAt } : null });
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
function read(n) {
|
|
65
|
+
const d = dirOf(n);
|
|
66
|
+
if (!d)
|
|
67
|
+
return null;
|
|
68
|
+
try {
|
|
69
|
+
const { meta, body } = parse(node_fs_1.default.readFileSync(node_path_1.default.join(d, 'SKILL.md'), 'utf8'));
|
|
70
|
+
const rf = runnerFile(d);
|
|
71
|
+
return { name: n, description: meta.description || '', body, enabled: state.data.enabled[n] !== false, runner: rf, code: rf ? node_fs_1.default.readFileSync(node_path_1.default.join(d, rf), 'utf8') : '' };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function write(n, description, body, runner) {
|
|
78
|
+
const d = dirOf(n);
|
|
79
|
+
if (!d)
|
|
80
|
+
return 'Nama skill harus huruf kecil/angka/-/_ (maks 63 karakter)';
|
|
81
|
+
node_fs_1.default.mkdirSync(d, { recursive: true });
|
|
82
|
+
const desc = String(description || '').replace(/[\r\n]+/g, ' ').trim();
|
|
83
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(d, 'SKILL.md'), `---\nname: ${n}\ndescription: ${desc}\n---\n${String(body || '').trim()}\n`);
|
|
84
|
+
if (runner && runner.code != null) {
|
|
85
|
+
if (!RUNNERS[runner.ext])
|
|
86
|
+
return 'Jenis runner tidak didukung: ' + runner.ext;
|
|
87
|
+
for (const f of node_fs_1.default.readdirSync(d))
|
|
88
|
+
if (/^run\./.test(f))
|
|
89
|
+
node_fs_1.default.rmSync(node_path_1.default.join(d, f));
|
|
90
|
+
if (runner.code.trim())
|
|
91
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(d, 'run.' + runner.ext), runner.code);
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const remove = (n) => { const d = dirOf(n); if (!d || !node_fs_1.default.existsSync(d))
|
|
96
|
+
return false; node_fs_1.default.rmSync(d, { recursive: true, force: true }); delete state.data.enabled[n]; state.save(); return true; };
|
|
97
|
+
exports.remove = remove;
|
|
98
|
+
const toggle = (n, on) => { state.data.enabled[n] = on; state.save(); };
|
|
99
|
+
exports.toggle = toggle;
|
|
100
|
+
/** Impor SKILL.md dari URL https (github/raw/gist saja, maks 200 KB). */
|
|
101
|
+
async function install(url, as) {
|
|
102
|
+
let u;
|
|
103
|
+
try {
|
|
104
|
+
u = new URL(url);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return { error: 'URL tidak valid' };
|
|
108
|
+
}
|
|
109
|
+
if (u.protocol !== 'https:' || !/^(raw\.githubusercontent\.com|github\.com|gist\.githubusercontent\.com)$/.test(u.host))
|
|
110
|
+
return { error: 'Hanya github.com / raw.githubusercontent.com / gist' };
|
|
111
|
+
if (u.host === 'github.com')
|
|
112
|
+
u = new URL(u.href.replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/'));
|
|
113
|
+
const r = await fetch(u, { signal: AbortSignal.timeout(15000) });
|
|
114
|
+
if (!r.ok)
|
|
115
|
+
return { error: 'Gagal mengunduh: HTTP ' + r.status };
|
|
116
|
+
const md = (await r.text()).slice(0, 200000), { meta, body } = parse(md);
|
|
117
|
+
const name = (as || meta.name || node_path_1.default.basename(u.pathname, '.md')).toLowerCase().replace(/[^a-z0-9_-]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 63);
|
|
118
|
+
const err = write(name, meta.description || '', body);
|
|
119
|
+
return err ? { error: err } : { name };
|
|
120
|
+
}
|
|
121
|
+
/** Eksekusi skill (tanpa shell): jalankan run.* dengan interpreter yang sesuai. */
|
|
122
|
+
function run(n, args = [], input = '') {
|
|
123
|
+
return new Promise(ok => {
|
|
124
|
+
const d = dirOf(n), rf = d && runnerFile(d);
|
|
125
|
+
if (!d || !rf)
|
|
126
|
+
return ok({ error: 'Skill tidak punya skrip run.* (hanya instruksi)' });
|
|
127
|
+
const ext = rf.split('.').pop();
|
|
128
|
+
let bin = RUNNERS[ext];
|
|
129
|
+
const a = args.map(String).slice(0, 20);
|
|
130
|
+
let argv = [node_path_1.default.join(d, rf), ...a];
|
|
131
|
+
if (ext === 'js' || ext === 'mjs')
|
|
132
|
+
bin = process.execPath;
|
|
133
|
+
if (ext === 'py' && process.platform !== 'win32')
|
|
134
|
+
bin = 'python3';
|
|
135
|
+
if (ext === 'ps1')
|
|
136
|
+
argv = ['-NoLogo', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', ...argv];
|
|
137
|
+
if (ext === 'cmd')
|
|
138
|
+
argv = ['/d', '/c', ...argv];
|
|
139
|
+
const env = { ...process.env, SKILL_NAME: n, SKILL_DIR: d, SKILL_INPUT: input, SKILL_ARGS_JSON: JSON.stringify(a) };
|
|
140
|
+
delete env.IB_TOKEN;
|
|
141
|
+
const t0 = Date.now();
|
|
142
|
+
let so = '', se = '', done = false;
|
|
143
|
+
(0, logs_1.clog)('I', 'skill:' + n, '$ ' + bin + ' ' + rf + (a.length ? ' ' + a.join(' ') : ''));
|
|
144
|
+
const p = (0, node_child_process_1.spawn)(bin, argv, { cwd: d, env, windowsHide: true });
|
|
145
|
+
const tm = setTimeout(() => { p.kill('SIGKILL'); se += '\n[dihentikan: melewati batas waktu]'; }, Math.min(config_1.JOB_MS, 120000));
|
|
146
|
+
const fin = (code) => {
|
|
147
|
+
if (done)
|
|
148
|
+
return;
|
|
149
|
+
done = true;
|
|
150
|
+
clearTimeout(tm);
|
|
151
|
+
(0, logs_1.clog)(code === 0 ? 'OK' : 'E', 'skill:' + n, 'selesai kode ' + code + ' (' + (Date.now() - t0) + ' ms)');
|
|
152
|
+
ok({ stdout: (0, util_1.stripAnsi)(so).slice(-1e6), stderr: (0, util_1.stripAnsi)(se).slice(-2e5), code, ms: Date.now() - t0 });
|
|
153
|
+
};
|
|
154
|
+
p.stdout.on('data', c => (so += c));
|
|
155
|
+
p.stderr.on('data', c => (se += c));
|
|
156
|
+
p.on('error', e => { se += e.message; fin(127); });
|
|
157
|
+
p.on('close', fin);
|
|
158
|
+
p.stdin.on('error', () => { });
|
|
159
|
+
p.stdin.end(input);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/** Teks instruksi gabungan skill aktif (untuk disuntik ke system prompt gateway). */
|
|
163
|
+
function prompt(names) {
|
|
164
|
+
const sel = list().filter(s => s.enabled && (Array.isArray(names) ? names.includes(s.name) : true));
|
|
165
|
+
return sel.map(s => `## Skill: ${s.name}\n${(read(s.name)?.body || '').trim().slice(0, 6000)}`).join('\n\n');
|
|
166
|
+
}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.flushAll = exports.open = exports.JsonFile = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const config_1 = require("./config");
|
|
10
|
+
/** File JSON persisten: tulis atomik (tmp + rename), izin 0600, ditunda 300 ms agar tidak boros I/O. */
|
|
11
|
+
class JsonFile {
|
|
12
|
+
data;
|
|
13
|
+
file;
|
|
14
|
+
timer = null;
|
|
15
|
+
constructor(name, defaults) {
|
|
16
|
+
this.file = node_path_1.default.join(config_1.DATA_DIR, name);
|
|
17
|
+
this.data = defaults;
|
|
18
|
+
try {
|
|
19
|
+
this.data = { ...defaults, ...JSON.parse(node_fs_1.default.readFileSync(this.file, 'utf8')) };
|
|
20
|
+
}
|
|
21
|
+
catch { /* pakai default */ }
|
|
22
|
+
}
|
|
23
|
+
save() {
|
|
24
|
+
if (this.timer)
|
|
25
|
+
return;
|
|
26
|
+
this.timer = setTimeout(() => { this.timer = null; this.flush(); }, 300);
|
|
27
|
+
this.timer.unref?.();
|
|
28
|
+
}
|
|
29
|
+
flush() {
|
|
30
|
+
try {
|
|
31
|
+
const tmp = this.file + '.tmp';
|
|
32
|
+
node_fs_1.default.writeFileSync(tmp, JSON.stringify(this.data, null, 2), { mode: 0o600 });
|
|
33
|
+
node_fs_1.default.renameSync(tmp, this.file);
|
|
34
|
+
}
|
|
35
|
+
catch { /* disk penuh / read-only: abaikan, jangan matikan server */ }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.JsonFile = JsonFile;
|
|
39
|
+
const all = [];
|
|
40
|
+
const open = (name, d) => { const f = new JsonFile(name, d); all.push(f); return f; };
|
|
41
|
+
exports.open = open;
|
|
42
|
+
const flushAll = () => all.forEach(f => f.flush());
|
|
43
|
+
exports.flushAll = flushAll;
|
package/dist/terminal.js
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.changeDir = exports.list = exports.view = exports.get = void 0;
|
|
7
|
+
exports.redact = redact;
|
|
8
|
+
exports.peekDownloads = peekDownloads;
|
|
9
|
+
exports.guard = guard;
|
|
10
|
+
exports.killTree = killTree;
|
|
11
|
+
exports.start = start;
|
|
12
|
+
exports.runOnce = runOnce;
|
|
13
|
+
exports.agentRun = agentRun;
|
|
14
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
15
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
17
|
+
const node_child_process_1 = require("node:child_process");
|
|
18
|
+
const config_1 = require("./config");
|
|
19
|
+
const logs_1 = require("./logs");
|
|
20
|
+
const JOBS = new Map();
|
|
21
|
+
const MAX_JOBS = 8;
|
|
22
|
+
/** Samarkan rahasia (API key / token) sebelum perintah masuk Console Log atau riwayat. */
|
|
23
|
+
function redact(s) {
|
|
24
|
+
const sec = /KEY|TOKEN|SECRET|PASS|AUTH|CREDENTIAL/i;
|
|
25
|
+
return String(s)
|
|
26
|
+
.replace(/(\bset\s+"?)([A-Za-z_][A-Za-z0-9_]*)=([^"&\r\n]*)/gi, (m, a, n) => (sec.test(n) ? a + n + '=***' : m))
|
|
27
|
+
.replace(/(\bexport\s+)([A-Za-z_][A-Za-z0-9_]*)=('[^']*'|"[^"]*"|\S+)/g, (m, a, n) => (sec.test(n) ? a + n + '=***' : m))
|
|
28
|
+
.replace(/\b(sk-[A-Za-z0-9_-]{3,}|nus-|ib_|ghp_|gsk_|xai-|AIza)[A-Za-z0-9_-]{10,}/g, '$1***');
|
|
29
|
+
}
|
|
30
|
+
// Ukuran + umur folder unduhan/clone sementara milik installer: bukti nyata apakah proses masih bergerak.
|
|
31
|
+
const walkDir = (d, depth = 0) => {
|
|
32
|
+
let bytes = 0, newest = 0;
|
|
33
|
+
try {
|
|
34
|
+
newest = node_fs_1.default.statSync(d).mtimeMs;
|
|
35
|
+
}
|
|
36
|
+
catch { /* hilang */ }
|
|
37
|
+
try {
|
|
38
|
+
for (const e of node_fs_1.default.readdirSync(d, { withFileTypes: true })) {
|
|
39
|
+
const f = node_path_1.default.join(d, e.name);
|
|
40
|
+
if (e.isDirectory()) {
|
|
41
|
+
if (depth < 6) {
|
|
42
|
+
const w = walkDir(f, depth + 1);
|
|
43
|
+
bytes += w.bytes;
|
|
44
|
+
newest = Math.max(newest, w.newest);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
try {
|
|
49
|
+
const s = node_fs_1.default.statSync(f);
|
|
50
|
+
bytes += s.size;
|
|
51
|
+
newest = Math.max(newest, s.mtimeMs);
|
|
52
|
+
}
|
|
53
|
+
catch { /* hilang */ }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch { /* tidak ada */ }
|
|
58
|
+
return { bytes, newest };
|
|
59
|
+
};
|
|
60
|
+
function peekDownloads() {
|
|
61
|
+
const la = process.env.LOCALAPPDATA, roots = [node_os_1.default.tmpdir()];
|
|
62
|
+
if (la)
|
|
63
|
+
roots.push(node_path_1.default.join(la, 'hermes'), node_path_1.default.join(la, 'hermes', 'tools'));
|
|
64
|
+
const out = [];
|
|
65
|
+
for (const r of roots) {
|
|
66
|
+
try {
|
|
67
|
+
for (const e of node_fs_1.default.readdirSync(r, { withFileTypes: true })) {
|
|
68
|
+
if (!e.isDirectory() || !/^(hermes-[a-z]+-bootstrap-|\.hermes-clone-|\.staging-git-bootstrap-)/.test(e.name))
|
|
69
|
+
continue;
|
|
70
|
+
const w = walkDir(node_path_1.default.join(r, e.name));
|
|
71
|
+
out.push({ key: node_path_1.default.join(r, e.name), label: e.name.replace(/^\.?(hermes-)?/, '').replace(/-\d+(-\d+)?$/, ''), bytes: w.bytes, idle: Math.round((Date.now() - w.newest) / 1000) });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch { /* folder belum ada */ }
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
/** Proses git/ekstraktor yang sedang berjalan + waktu CPU-nya (naik = bekerja). Hanya Windows. */
|
|
79
|
+
function gitProcs() {
|
|
80
|
+
return new Promise(ok => {
|
|
81
|
+
if (process.platform !== 'win32')
|
|
82
|
+
return ok('');
|
|
83
|
+
let out = '';
|
|
84
|
+
const p = (0, node_child_process_1.spawn)('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
|
|
85
|
+
"(Get-Process -Name git,git-remote-https,PortableGit* -ErrorAction SilentlyContinue | ForEach-Object { $_.ProcessName + ' ' + [math]::Round($_.CPU,1) + 's' }) -join ', '"], { windowsHide: true });
|
|
86
|
+
const tm = setTimeout(() => { try {
|
|
87
|
+
p.kill();
|
|
88
|
+
}
|
|
89
|
+
catch { /* ok */ } ok(''); }, 6000);
|
|
90
|
+
p.stdout.on('data', c => (out += c));
|
|
91
|
+
p.on('error', () => { clearTimeout(tm); ok(''); });
|
|
92
|
+
p.on('close', () => { clearTimeout(tm); ok(out.trim()); });
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const cap = (s, c, n = 1e6) => (s + c).slice(-n);
|
|
96
|
+
// Pola bahaya yang jelas. BUKAN sandbox: perlindungan utama tetap token + HOST=127.0.0.1.
|
|
97
|
+
const DENY = [
|
|
98
|
+
/\brm\s+(-[a-z]*r[a-z]*f|-[a-z]*f[a-z]*r)[a-z]*\s+(--no-preserve-root\s+)?(\/|~|\$HOME|\*)(\s|$)/i,
|
|
99
|
+
/\bmkfs(\.\w+)?\b/i, /\bdd\s+if=.*\bof=\/dev\//i, />\s*\/dev\/(sd|nvme|mmcblk)/i,
|
|
100
|
+
/:\(\)\s*\{\s*:\|:&\s*\};:/, /\b(shutdown|poweroff|halt)\b(?!\s*-c)/i, /\breboot\b/i,
|
|
101
|
+
/\bformat\s+[a-z]:/i, /\bdel\s+(\/[a-z]\s+)*[a-z]:\\\s*$/i, /\brd\s+\/s\s+\/q\s+[a-z]:\\\s*$/i,
|
|
102
|
+
/\bchmod\s+-R\s+777\s+\/(\s|$)/i
|
|
103
|
+
];
|
|
104
|
+
function guard(cmd) {
|
|
105
|
+
if (!config_1.TERMINAL_ON)
|
|
106
|
+
return 'Terminal dimatikan (IB_TERMINAL=0)';
|
|
107
|
+
if (config_1.SAFE_MODE && DENY.some(r => r.test(cmd)))
|
|
108
|
+
return 'Diblokir mode aman (IB_SAFE_MODE=1): perintah terlihat merusak sistem';
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const childEnv = (extra) => {
|
|
112
|
+
const e = { ...process.env, ...(extra || {}) };
|
|
113
|
+
delete e.IB_TOKEN; // proses anak tidak boleh membaca token admin
|
|
114
|
+
return e;
|
|
115
|
+
};
|
|
116
|
+
function killTree(p) {
|
|
117
|
+
try {
|
|
118
|
+
if (process.platform === 'win32' && p.pid)
|
|
119
|
+
(0, node_child_process_1.spawn)('taskkill', ['/pid', String(p.pid), '/T', '/F'], { windowsHide: true });
|
|
120
|
+
else if (p.pid)
|
|
121
|
+
process.kill(-p.pid, 'SIGKILL');
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
try {
|
|
125
|
+
p.kill('SIGKILL');
|
|
126
|
+
}
|
|
127
|
+
catch { /* sudah mati */ }
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function spawnShell(cmd, cwd, env, shell) {
|
|
131
|
+
const win = process.platform === 'win32';
|
|
132
|
+
if (win && shell === 'powershell')
|
|
133
|
+
return (0, node_child_process_1.spawn)('powershell.exe', ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command', cmd], { cwd, env, windowsHide: true });
|
|
134
|
+
return (0, node_child_process_1.spawn)(cmd, { shell: true, cwd, env, detached: !win, windowsHide: true });
|
|
135
|
+
}
|
|
136
|
+
const resolveCwd = (c) => { if (c) {
|
|
137
|
+
try {
|
|
138
|
+
const r = node_path_1.default.resolve(String(c));
|
|
139
|
+
if (node_fs_1.default.statSync(r).isDirectory())
|
|
140
|
+
return r;
|
|
141
|
+
}
|
|
142
|
+
catch { /* pakai ROOT */ }
|
|
143
|
+
} return config_1.ROOT; };
|
|
144
|
+
function start(o) {
|
|
145
|
+
const cmd = String(o.cmd || '');
|
|
146
|
+
const bad = guard(cmd);
|
|
147
|
+
if (bad)
|
|
148
|
+
return { error: bad };
|
|
149
|
+
if ([...JOBS.values()].filter(j => !j.done).length >= MAX_JOBS)
|
|
150
|
+
return { error: 'Terlalu banyak tugas berjalan (maks ' + MAX_JOBS + ')' };
|
|
151
|
+
const id = Date.now().toString(36) + Math.random().toString(36).slice(2, 8), cwd = resolveCwd(o.cwd), tg = 'job:' + id.slice(-4);
|
|
152
|
+
const j = { id, cmd: redact(cmd).slice(0, 300), cwd, src: String(o.src || 'app'), so: '', se: '', code: null, done: false, t0: Date.now(), t1: 0, kill() { }, write: () => false };
|
|
153
|
+
JOBS.set(id, j);
|
|
154
|
+
(0, logs_1.clog)('I', tg, '$ ' + j.cmd + (cwd !== config_1.ROOT ? ' (di ' + cwd + ')' : ''));
|
|
155
|
+
const p = spawnShell(cmd, cwd, childEnv(o.env), o.shell);
|
|
156
|
+
j.child = p;
|
|
157
|
+
j.kill = () => killTree(p);
|
|
158
|
+
j.write = s => { try {
|
|
159
|
+
return p.stdin.write(s);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return false;
|
|
163
|
+
} };
|
|
164
|
+
p.stdin?.on('error', () => { });
|
|
165
|
+
const lb = { o: '', e: '' };
|
|
166
|
+
const feed = (k, dv, c) => { lb[k] += c; const ps = lb[k].split(/\r?\n|\r/); lb[k] = ps.pop() || ''; ps.forEach(l => (0, logs_1.clog)((0, logs_1.lvOf)(l, dv), tg, l)); };
|
|
167
|
+
p.stdout?.on('data', c => { j.so = cap(j.so, c); feed('o', 'I', c); });
|
|
168
|
+
p.stderr?.on('data', c => { j.se = cap(j.se, c); feed('e', 'W', c); });
|
|
169
|
+
// Windows tidak meneruskan progress bar download ke pipe; beri tanda hidup agar tidak terlihat macet.
|
|
170
|
+
let lastOut = Date.now();
|
|
171
|
+
p.stdout?.on('data', () => (lastOut = Date.now()));
|
|
172
|
+
p.stderr?.on('data', () => (lastOut = Date.now()));
|
|
173
|
+
const mb = (n) => (n / 1048576).toFixed(1) + ' MB';
|
|
174
|
+
const prev = new Map();
|
|
175
|
+
const watch = /hermes/i.test(cmd);
|
|
176
|
+
let busyHb = false;
|
|
177
|
+
const hb = /\b(install|npm\s+i\b|pip\b|irm\b|curl\b|wget\b|winget\b|pkg\b|apt(-get)?\b|brew\b|git\s+clone)/i.test(cmd)
|
|
178
|
+
? setInterval(async () => {
|
|
179
|
+
if (busyHb || Date.now() - lastOut < 9000)
|
|
180
|
+
return;
|
|
181
|
+
busyHb = true;
|
|
182
|
+
try {
|
|
183
|
+
const s = Math.round((Date.now() - j.t0) / 1000);
|
|
184
|
+
let line = '… masih berjalan (' + s + ' dtk), sedang mengunduh/memasang, harap tunggu';
|
|
185
|
+
if (watch) {
|
|
186
|
+
const parts = peekDownloads().map(d => {
|
|
187
|
+
const p = prev.get(d.key), delta = p ? d.bytes - p.b : 0, still = p && delta === 0 ? p.still + 1 : 0;
|
|
188
|
+
prev.set(d.key, { b: d.bytes, still });
|
|
189
|
+
let note = '';
|
|
190
|
+
if (d.idle > 120)
|
|
191
|
+
note = ' (tidak berubah ' + Math.round(d.idle / 60) + ' mnt: kemungkinan SISA proses lama, hapus folder ini)';
|
|
192
|
+
else if (p)
|
|
193
|
+
note = delta > 0 ? ' (+' + mb(delta) + '/10 dtk)' : still >= 3 ? ' (tidak bertambah ' + still * 10 + ' dtk)' : ' (tetap)';
|
|
194
|
+
return d.label + ': ' + mb(d.bytes) + note;
|
|
195
|
+
});
|
|
196
|
+
const pr = await gitProcs();
|
|
197
|
+
if (parts.length || pr)
|
|
198
|
+
line = '… [' + s + ' dtk] ' + (parts.join(' | ') || 'belum ada unduhan') + (process.platform === 'win32' ? ' | proses: ' + (pr || 'tidak ada git berjalan') : '');
|
|
199
|
+
}
|
|
200
|
+
j.so = cap(j.so, '\n' + line + '\n');
|
|
201
|
+
(0, logs_1.clog)('I', tg, line);
|
|
202
|
+
lastOut = Date.now();
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
busyHb = false;
|
|
206
|
+
}
|
|
207
|
+
}, 10000) : null;
|
|
208
|
+
const tm = setTimeout(() => { j.se += '\n[dihentikan: melewati ' + Math.round(config_1.JOB_MS / 60000) + ' menit]'; j.kill(); }, config_1.JOB_MS);
|
|
209
|
+
const fin = (code) => {
|
|
210
|
+
if (j.done)
|
|
211
|
+
return;
|
|
212
|
+
j.done = true;
|
|
213
|
+
j.code = code;
|
|
214
|
+
j.t1 = Date.now();
|
|
215
|
+
clearTimeout(tm);
|
|
216
|
+
if (hb)
|
|
217
|
+
clearInterval(hb);
|
|
218
|
+
if (lb.o)
|
|
219
|
+
(0, logs_1.clog)((0, logs_1.lvOf)(lb.o, 'I'), tg, lb.o);
|
|
220
|
+
if (lb.e)
|
|
221
|
+
(0, logs_1.clog)((0, logs_1.lvOf)(lb.e, 'W'), tg, lb.e);
|
|
222
|
+
(0, logs_1.clog)(code === 0 ? 'OK' : 'E', tg, (code === 0 ? 'selesai' : 'berhenti dengan kode ' + code) + ' (' + ((j.t1 - j.t0) / 1000).toFixed(1) + ' dtk)');
|
|
223
|
+
setTimeout(() => JOBS.delete(id), 15 * 60000).unref?.();
|
|
224
|
+
};
|
|
225
|
+
p.on('close', fin);
|
|
226
|
+
p.on('error', e => { j.se += String(e.message); fin(127); });
|
|
227
|
+
return { job: id };
|
|
228
|
+
}
|
|
229
|
+
const get = (id) => JOBS.get(id);
|
|
230
|
+
exports.get = get;
|
|
231
|
+
const view = (j) => j.done
|
|
232
|
+
? { done: true, stdout: j.so, stderr: j.se, code: j.code, ms: j.t1 - j.t0 }
|
|
233
|
+
: { done: false, size: j.so.length + j.se.length, ms: Date.now() - j.t0, stdout: j.so.slice(-20000), stderr: j.se.slice(-20000) };
|
|
234
|
+
exports.view = view;
|
|
235
|
+
const list = () => [...JOBS].map(([id, j]) => ({ id, cmd: j.cmd, src: j.src, done: j.done, code: j.code, ms: (j.t1 || Date.now()) - j.t0 }));
|
|
236
|
+
exports.list = list;
|
|
237
|
+
/** Jalankan sekali, tunggu hasil (kompatibel /exec lama, batas 120 dtk). */
|
|
238
|
+
function runOnce(cmd, cwd, ms = 120000) {
|
|
239
|
+
return new Promise(ok => {
|
|
240
|
+
const bad = guard(cmd);
|
|
241
|
+
if (bad)
|
|
242
|
+
return ok({ error: bad });
|
|
243
|
+
const p = spawnShell(String(cmd), resolveCwd(cwd), childEnv());
|
|
244
|
+
let so = '', se = '', done = false;
|
|
245
|
+
const kill = setTimeout(() => { killTree(p); se += '\n[dihentikan: melewati ' + ms / 1000 + ' detik]'; }, ms);
|
|
246
|
+
const fin = (code) => { if (done)
|
|
247
|
+
return; done = true; clearTimeout(kill); ok({ stdout: so, stderr: se, code }); };
|
|
248
|
+
p.stdout?.on('data', c => (so = cap(so, c)));
|
|
249
|
+
p.stderr?.on('data', c => (se = cap(se, c)));
|
|
250
|
+
p.on('close', fin);
|
|
251
|
+
p.on('error', e => { se += String(e.message); fin(127); });
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/** Jalankan agent CLI dengan prompt lewat env NUS_GOAL (aman dari masalah tanda kutip). */
|
|
255
|
+
function agentRun(cmdTpl, prompt, cwd, env, viaWsl = false) {
|
|
256
|
+
return new Promise((ok, no) => {
|
|
257
|
+
const win = process.platform === 'win32';
|
|
258
|
+
if (win)
|
|
259
|
+
prompt = prompt.replace(/\r?\n/g, ' ').replace(/"/g, "'");
|
|
260
|
+
let cmd = String(cmdTpl).replace(/\{goal\}/g, win ? '"%NUS_GOAL%"' : '"$NUS_GOAL"');
|
|
261
|
+
const e2 = { ...(env || {}), NUS_GOAL: prompt };
|
|
262
|
+
if (win && viaWsl) { // agent terpasang di WSL: kirim prompt & env lewat WSLENV
|
|
263
|
+
cmd = 'wsl.exe -e bash -lc "' + String(cmdTpl).replace(/\{goal\}/g, '"$NUS_GOAL"').replace(/"/g, '\\"') + '"';
|
|
264
|
+
e2.WSLENV = [...Object.keys(e2), ...(process.env.WSLENV ? [process.env.WSLENV] : [])].join(':');
|
|
265
|
+
}
|
|
266
|
+
const bad = guard(cmd);
|
|
267
|
+
if (bad)
|
|
268
|
+
return no(new Error(bad));
|
|
269
|
+
const p = spawnShell(cmd, resolveCwd(cwd), childEnv(e2));
|
|
270
|
+
let so = '', se = '';
|
|
271
|
+
const tm = setTimeout(() => { killTree(p); no(new Error('agent melewati batas waktu')); }, config_1.JOB_MS);
|
|
272
|
+
p.stdout?.on('data', c => (so = cap(so, c)));
|
|
273
|
+
p.stderr?.on('data', c => (se = cap(se, c, 2e5)));
|
|
274
|
+
p.on('error', e => { clearTimeout(tm); no(e); });
|
|
275
|
+
p.on('close', code => { clearTimeout(tm); code === 0 || so.trim() ? ok(so) : no(new Error('kode ' + code + ' ' + se.slice(-200))); });
|
|
276
|
+
p.stdin?.on('error', () => { });
|
|
277
|
+
p.stdin?.end();
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
const changeDir = (from, to, home) => {
|
|
281
|
+
const t = node_path_1.default.resolve(node_path_1.default.resolve(from || config_1.ROOT), String(to || '.').replace(/^~(?=$|[\\/])/, home));
|
|
282
|
+
try {
|
|
283
|
+
return node_fs_1.default.statSync(t).isDirectory() ? t : null;
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
exports.changeDir = changeDir;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stats = void 0;
|
|
4
|
+
exports.clean = clean;
|
|
5
|
+
exports.apply = apply;
|
|
6
|
+
exports.record = record;
|
|
7
|
+
const store_1 = require("./store");
|
|
8
|
+
const util_1 = require("./util");
|
|
9
|
+
exports.stats = (0, store_1.open)('tokensaver.json', { req: 0, saved: 0, orig: 0 });
|
|
10
|
+
/** RTK: bersihkan output tool (ANSI, spasi, baris berulang) dan pangkas yang terlalu panjang. */
|
|
11
|
+
function clean(t, max) {
|
|
12
|
+
let o = (0, util_1.stripAnsi)(t).replace(/\r\n/g, '\n').replace(/[ \t]+$/gm, '').replace(/\n{3,}/g, '\n\n');
|
|
13
|
+
const R = [];
|
|
14
|
+
let p = null, c = 0;
|
|
15
|
+
const fl = () => { if (p !== null)
|
|
16
|
+
R.push(c > 2 ? p + ' [x' + c + ']' : Array(c).fill(p).join('\n')); };
|
|
17
|
+
for (const l of o.split('\n')) {
|
|
18
|
+
if (l === p && l.trim())
|
|
19
|
+
c++;
|
|
20
|
+
else {
|
|
21
|
+
fl();
|
|
22
|
+
p = l;
|
|
23
|
+
c = 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
fl();
|
|
27
|
+
o = R.join('\n');
|
|
28
|
+
if (max && o.length > max) {
|
|
29
|
+
const h = Math.floor(max * 0.65);
|
|
30
|
+
o = o.slice(0, h) + '\n... [' + (o.length - max) + ' karakter dipangkas] ...\n' + o.slice(o.length - (max - h));
|
|
31
|
+
}
|
|
32
|
+
return o;
|
|
33
|
+
}
|
|
34
|
+
const text = (t, max) => { try {
|
|
35
|
+
const o = clean(t, max);
|
|
36
|
+
return o.length < t.length ? o : t;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return t;
|
|
40
|
+
} };
|
|
41
|
+
const CM = {
|
|
42
|
+
lite: 'Gaya jawaban: ringkas dan langsung. Tanpa basa-basi, tanpa mengulang pertanyaan, tanpa kalimat penutup. Pakai bahasa yang sama dengan pengguna. Kode, perintah, dan istilah teknis harus tetap utuh dan akurat.',
|
|
43
|
+
full: 'Gaya jawaban caveman: kalimat pendek dan padat, buang kata sambung, sapaan, dan penjelasan berlebih. Contoh: "Bug di loop. Index mulai 1, harusnya 0. Perbaiki:" lalu kode. Pakai bahasa yang sama dengan pengguna. Kode, perintah, path, dan istilah teknis tetap persis dan lengkap.',
|
|
44
|
+
ultra: 'Gaya jawaban ultra singkat: bentuk telegram, singkatan umum, simbol (→, =, ≠). Hanya inti. Kode dan perintah tetap lengkap dan benar, jangan dipotong. Bahasa sama dengan pengguna. Jika pengguna meminta penjelasan panjang, ikuti permintaannya.'
|
|
45
|
+
};
|
|
46
|
+
const PT = 'Tulis kode seminimal mungkin (YAGNI): hanya yang diminta, tanpa abstraksi, fitur, atau penanganan error spekulatif. Utamakan menghapus atau menyederhanakan daripada menambah. Jelaskan seperlunya.';
|
|
47
|
+
function apply(msgs, cfg) {
|
|
48
|
+
let saved = 0, orig = 0;
|
|
49
|
+
const tx = (s) => { if (typeof s !== 'string')
|
|
50
|
+
return s; orig += s.length; const n = text(s, cfg.max); saved += s.length - n.length; return n; };
|
|
51
|
+
const part = (x) => (x && x.type === 'text' ? { ...x, text: tx(x.text) } : x);
|
|
52
|
+
const fix = (c) => (typeof c === 'string' ? tx(c) : Array.isArray(c) ? c.map(part) : c);
|
|
53
|
+
const out = (msgs || []).map(m => {
|
|
54
|
+
if (!cfg.rtk || !m)
|
|
55
|
+
return m;
|
|
56
|
+
if (m.role === 'tool')
|
|
57
|
+
return { ...m, content: fix(m.content) };
|
|
58
|
+
if (Array.isArray(m.content) && m.content.some((x) => x && x.type === 'tool_result'))
|
|
59
|
+
return { ...m, content: m.content.map((x) => (x && x.type === 'tool_result' ? { ...x, content: fix(x.content) } : x)) };
|
|
60
|
+
return m;
|
|
61
|
+
});
|
|
62
|
+
const add = [];
|
|
63
|
+
if (cfg.caveman && CM[cfg.caveman])
|
|
64
|
+
add.push(CM[cfg.caveman]);
|
|
65
|
+
if (cfg.ponytail)
|
|
66
|
+
add.push(PT);
|
|
67
|
+
if (add.length) {
|
|
68
|
+
const sys = add.join('\n\n'), i = out.findIndex(m => m && m.role === 'system');
|
|
69
|
+
if (i >= 0 && typeof out[i].content === 'string')
|
|
70
|
+
out[i] = { ...out[i], content: out[i].content + '\n\n' + sys };
|
|
71
|
+
else
|
|
72
|
+
out.unshift({ role: 'system', content: sys });
|
|
73
|
+
}
|
|
74
|
+
return { messages: out, saved, orig };
|
|
75
|
+
}
|
|
76
|
+
function record(saved, orig) { exports.stats.data.req++; exports.stats.data.saved += saved; exports.stats.data.orig += orig; exports.stats.save(); }
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isLoopback = exports.errMsg = exports.today = exports.mask = exports.stripAnsi = exports.bearer = exports.safeEq = exports.cors = void 0;
|
|
7
|
+
exports.send = send;
|
|
8
|
+
exports.readBody = readBody;
|
|
9
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
10
|
+
const config_1 = require("./config");
|
|
11
|
+
exports.cors = {
|
|
12
|
+
'Access-Control-Allow-Origin': config_1.CORS_ORIGIN,
|
|
13
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
14
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
|
15
|
+
'Access-Control-Allow-Private-Network': 'true',
|
|
16
|
+
'Access-Control-Max-Age': '86400',
|
|
17
|
+
'Access-Control-Expose-Headers': 'Content-Disposition, Content-Length, X-Nus-Model'
|
|
18
|
+
};
|
|
19
|
+
function send(res, code, obj, extra = {}) {
|
|
20
|
+
if (res.headersSent)
|
|
21
|
+
return;
|
|
22
|
+
res.writeHead(code, { ...exports.cors, 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store', ...extra });
|
|
23
|
+
res.end(JSON.stringify(obj));
|
|
24
|
+
}
|
|
25
|
+
function readBody(req, limit = 30e6) {
|
|
26
|
+
return new Promise(ok => {
|
|
27
|
+
let b = '';
|
|
28
|
+
req.on('data', c => { b += c; if (b.length > limit)
|
|
29
|
+
req.destroy(); });
|
|
30
|
+
req.on('end', () => { try {
|
|
31
|
+
ok(JSON.parse(b || '{}'));
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
ok({});
|
|
35
|
+
} });
|
|
36
|
+
req.on('error', () => ok({}));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const safeEq = (a, b) => {
|
|
40
|
+
const x = node_crypto_1.default.createHash('sha256').update(String(a)).digest();
|
|
41
|
+
const y = node_crypto_1.default.createHash('sha256').update(String(b)).digest();
|
|
42
|
+
return node_crypto_1.default.timingSafeEqual(x, y);
|
|
43
|
+
};
|
|
44
|
+
exports.safeEq = safeEq;
|
|
45
|
+
const bearer = (req) => String(req.headers.authorization || '').replace(/^Bearer\s+/i, '');
|
|
46
|
+
exports.bearer = bearer;
|
|
47
|
+
const stripAnsi = (s) => String(s).replace(/\x1b\[[0-9;?]*[A-Za-z]/g, '').replace(/\x1b\][^\x07]*\x07/g, '');
|
|
48
|
+
exports.stripAnsi = stripAnsi;
|
|
49
|
+
const mask = (k) => (k.length <= 8 ? '••••' : k.slice(0, 3) + '…' + k.slice(-4));
|
|
50
|
+
exports.mask = mask;
|
|
51
|
+
const today = () => new Date().toISOString().slice(0, 10);
|
|
52
|
+
exports.today = today;
|
|
53
|
+
const errMsg = (e) => (e instanceof Error ? e.message : String(e));
|
|
54
|
+
exports.errMsg = errMsg;
|
|
55
|
+
const isLoopback = (a) => !!a && /^(::1|127\.\d+\.\d+\.\d+|::ffff:127\.\d+\.\d+\.\d+)$/.test(a);
|
|
56
|
+
exports.isLoopback = isLoopback;
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "chatnus",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "chatnus",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ChatNUS: antarmuka web + backend lokal (Console Log, Combo, Quota Tracker, Token Saver, Endpoint & Key, Skill, Terminal)",
|
|
5
|
+
"main": "dist/server.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"chatnus": "./dist/server.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"public/",
|
|
12
|
+
"skills/",
|
|
13
|
+
"sidecar/",
|
|
14
|
+
"scripts/",
|
|
15
|
+
".env.example",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18.17"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"start": "npm run build && node dist/server.js",
|
|
25
|
+
"dev": "node scripts/dev.js",
|
|
26
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
27
|
+
"prepublishOnly": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.14.0",
|
|
31
|
+
"typescript": "^5.5.0"
|
|
32
|
+
}
|
|
33
|
+
}
|