nextclaw 0.4.6 → 0.4.8
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/cli/index.js +13 -68
- package/package.json +5 -4
- package/ui-dist/assets/index-JpepB1WI.js +225 -0
- package/ui-dist/index.html +1 -1
- package/ui-dist/assets/index-BivRvIey.js +0 -225
package/dist/cli/index.js
CHANGED
|
@@ -54,7 +54,9 @@ import chokidar from "chokidar";
|
|
|
54
54
|
import { createHash } from "crypto";
|
|
55
55
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
56
56
|
import {
|
|
57
|
-
|
|
57
|
+
buildConfigSchema,
|
|
58
|
+
ConfigSchema,
|
|
59
|
+
redactConfigObject
|
|
58
60
|
} from "nextclaw-core";
|
|
59
61
|
|
|
60
62
|
// src/cli/utils.ts
|
|
@@ -63,7 +65,7 @@ import { join, resolve } from "path";
|
|
|
63
65
|
import { spawn } from "child_process";
|
|
64
66
|
import { createServer } from "net";
|
|
65
67
|
import { fileURLToPath } from "url";
|
|
66
|
-
import { getDataDir } from "nextclaw-core";
|
|
68
|
+
import { getDataDir, getPackageVersion } from "nextclaw-core";
|
|
67
69
|
function resolveUiConfig(config, overrides) {
|
|
68
70
|
const base = config.ui ?? { enabled: false, host: "127.0.0.1", port: 18791, open: false };
|
|
69
71
|
return { ...base, ...overrides ?? {} };
|
|
@@ -204,17 +206,6 @@ function openBrowser(url) {
|
|
|
204
206
|
const child = spawn(command, args, { stdio: "ignore", detached: true });
|
|
205
207
|
child.unref();
|
|
206
208
|
}
|
|
207
|
-
function getPackageVersion() {
|
|
208
|
-
try {
|
|
209
|
-
const cliDir = resolve(fileURLToPath(new URL(".", import.meta.url)));
|
|
210
|
-
const pkgPath = resolve(cliDir, "..", "..", "package.json");
|
|
211
|
-
const raw = readFileSync(pkgPath, "utf-8");
|
|
212
|
-
const parsed = JSON.parse(raw);
|
|
213
|
-
return typeof parsed.version === "string" ? parsed.version : "0.0.0";
|
|
214
|
-
} catch {
|
|
215
|
-
return "0.0.0";
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
209
|
function which(binary) {
|
|
219
210
|
const paths = (process.env.PATH ?? "").split(":");
|
|
220
211
|
for (const dir of paths) {
|
|
@@ -340,24 +331,6 @@ function runSelfUpdate(options = {}) {
|
|
|
340
331
|
|
|
341
332
|
// src/cli/gateway/controller.ts
|
|
342
333
|
var hashRaw = (raw) => createHash("sha256").update(raw).digest("hex");
|
|
343
|
-
var redactConfig = (value) => {
|
|
344
|
-
if (Array.isArray(value)) {
|
|
345
|
-
return value.map((entry) => redactConfig(entry));
|
|
346
|
-
}
|
|
347
|
-
if (!value || typeof value !== "object") {
|
|
348
|
-
return value;
|
|
349
|
-
}
|
|
350
|
-
const entries = value;
|
|
351
|
-
const output = {};
|
|
352
|
-
for (const [key, val] of Object.entries(entries)) {
|
|
353
|
-
if (/apiKey|token|secret|password|appId|clientSecret|accessKey/i.test(key)) {
|
|
354
|
-
output[key] = val ? "***" : val;
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
output[key] = redactConfig(val);
|
|
358
|
-
}
|
|
359
|
-
return output;
|
|
360
|
-
};
|
|
361
334
|
var readConfigSnapshot = (getConfigPath2) => {
|
|
362
335
|
const path = getConfigPath2();
|
|
363
336
|
let raw = "";
|
|
@@ -382,9 +355,14 @@ var readConfigSnapshot = (getConfigPath2) => {
|
|
|
382
355
|
raw = JSON.stringify(config, null, 2);
|
|
383
356
|
}
|
|
384
357
|
const hash = hashRaw(raw);
|
|
385
|
-
const
|
|
358
|
+
const schema = buildConfigSchema({ version: getPackageVersion() });
|
|
359
|
+
const redacted = redactConfigObject(config, schema.uiHints);
|
|
386
360
|
return { raw: valid ? JSON.stringify(redacted, null, 2) : null, hash: valid ? hash : null, config, redacted, valid };
|
|
387
361
|
};
|
|
362
|
+
var redactValue = (value) => {
|
|
363
|
+
const schema = buildConfigSchema({ version: getPackageVersion() });
|
|
364
|
+
return redactConfigObject(value, schema.uiHints);
|
|
365
|
+
};
|
|
388
366
|
var mergeDeep = (base, patch) => {
|
|
389
367
|
const next = { ...base };
|
|
390
368
|
for (const [key, value] of Object.entries(patch)) {
|
|
@@ -401,29 +379,6 @@ var mergeDeep = (base, patch) => {
|
|
|
401
379
|
}
|
|
402
380
|
return next;
|
|
403
381
|
};
|
|
404
|
-
var buildSchemaFromValue = (value) => {
|
|
405
|
-
if (Array.isArray(value)) {
|
|
406
|
-
const item = value.length ? buildSchemaFromValue(value[0]) : { type: "string" };
|
|
407
|
-
return { type: "array", items: item };
|
|
408
|
-
}
|
|
409
|
-
if (value && typeof value === "object") {
|
|
410
|
-
const props = {};
|
|
411
|
-
for (const [key, val] of Object.entries(value)) {
|
|
412
|
-
props[key] = buildSchemaFromValue(val);
|
|
413
|
-
}
|
|
414
|
-
return { type: "object", properties: props };
|
|
415
|
-
}
|
|
416
|
-
if (typeof value === "number") {
|
|
417
|
-
return { type: "number" };
|
|
418
|
-
}
|
|
419
|
-
if (typeof value === "boolean") {
|
|
420
|
-
return { type: "boolean" };
|
|
421
|
-
}
|
|
422
|
-
if (value === null) {
|
|
423
|
-
return { type: ["null", "string"] };
|
|
424
|
-
}
|
|
425
|
-
return { type: "string" };
|
|
426
|
-
};
|
|
427
382
|
var scheduleRestart = (delayMs, reason) => {
|
|
428
383
|
const delay = typeof delayMs === "number" && Number.isFinite(delayMs) ? Math.max(0, delayMs) : 100;
|
|
429
384
|
console.log(`Gateway restart requested via tool${reason ? ` (${reason})` : ""}.`);
|
|
@@ -462,17 +417,7 @@ var GatewayControllerImpl = class {
|
|
|
462
417
|
};
|
|
463
418
|
}
|
|
464
419
|
async getConfigSchema() {
|
|
465
|
-
|
|
466
|
-
return {
|
|
467
|
-
schema: {
|
|
468
|
-
...buildSchemaFromValue(base),
|
|
469
|
-
title: "NextClawConfig",
|
|
470
|
-
description: "NextClaw config schema (simplified)"
|
|
471
|
-
},
|
|
472
|
-
uiHints: {},
|
|
473
|
-
version: getPackageVersion(),
|
|
474
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
475
|
-
};
|
|
420
|
+
return buildConfigSchema({ version: getPackageVersion() });
|
|
476
421
|
}
|
|
477
422
|
async applyConfig(params) {
|
|
478
423
|
const snapshot = readConfigSnapshot(this.deps.getConfigPath);
|
|
@@ -504,7 +449,7 @@ var GatewayControllerImpl = class {
|
|
|
504
449
|
ok: true,
|
|
505
450
|
note: params.note ?? null,
|
|
506
451
|
path: this.deps.getConfigPath(),
|
|
507
|
-
config:
|
|
452
|
+
config: redactValue(validated),
|
|
508
453
|
restart: { scheduled: true, delayMs }
|
|
509
454
|
};
|
|
510
455
|
}
|
|
@@ -539,7 +484,7 @@ var GatewayControllerImpl = class {
|
|
|
539
484
|
ok: true,
|
|
540
485
|
note: params.note ?? null,
|
|
541
486
|
path: this.deps.getConfigPath(),
|
|
542
|
-
config:
|
|
487
|
+
config: redactValue(validated),
|
|
543
488
|
restart: { scheduled: true, delayMs }
|
|
544
489
|
};
|
|
545
490
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextclaw",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"chokidar": "^3.6.0",
|
|
40
40
|
"commander": "^12.1.0",
|
|
41
|
-
"nextclaw-core": "^0.4.
|
|
42
|
-
"nextclaw-server": "^0.3.
|
|
41
|
+
"nextclaw-core": "^0.4.6",
|
|
42
|
+
"nextclaw-server": "^0.3.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^20.17.6",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"vitest": "^2.1.2"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
|
-
"dev": "
|
|
57
|
+
"dev": "tsx watch --tsconfig tsconfig.json src/cli/index.ts",
|
|
58
|
+
"dev:build": "pnpm -C ../nextclaw-core build && pnpm -C ../nextclaw-server build && tsx src/cli/index.ts",
|
|
58
59
|
"build": "pnpm -C ../nextclaw-core build && pnpm -C ../nextclaw-server build && tsup src/index.ts src/cli/index.ts --format esm --dts --out-dir dist && node scripts/copy-ui-dist.mjs",
|
|
59
60
|
"start": "node dist/cli.js",
|
|
60
61
|
"lint": "eslint .",
|