@nextclaw/server 0.4.12 → 0.4.14
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/index.d.ts +4 -1
- package/dist/index.js +28 -7
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -268,7 +268,10 @@ declare function buildConfigMeta(config: Config): ConfigMetaView;
|
|
|
268
268
|
declare function buildConfigSchemaView(_config: Config): ConfigSchemaResponse;
|
|
269
269
|
declare function executeConfigAction(configPath: string, actionId: string, request: ConfigActionExecuteRequest$1): Promise<ExecuteActionResult>;
|
|
270
270
|
declare function loadConfigOrDefault(configPath: string): Config;
|
|
271
|
-
declare function updateModel(configPath: string,
|
|
271
|
+
declare function updateModel(configPath: string, patch: {
|
|
272
|
+
model?: string;
|
|
273
|
+
maxTokens?: number;
|
|
274
|
+
}): ConfigView;
|
|
272
275
|
declare function updateProvider(configPath: string, providerName: string, patch: ProviderConfigUpdate): ProviderConfigView | null;
|
|
273
276
|
declare function updateChannel(configPath: string, channelName: string, patch: Record<string, unknown>): Record<string, unknown> | null;
|
|
274
277
|
declare function listSessions(configPath: string, query?: {
|
package/dist/index.js
CHANGED
|
@@ -345,9 +345,14 @@ async function executeConfigAction(configPath, actionId, request) {
|
|
|
345
345
|
function loadConfigOrDefault(configPath) {
|
|
346
346
|
return loadConfig(configPath);
|
|
347
347
|
}
|
|
348
|
-
function updateModel(configPath,
|
|
348
|
+
function updateModel(configPath, patch) {
|
|
349
349
|
const config = loadConfigOrDefault(configPath);
|
|
350
|
-
|
|
350
|
+
if (typeof patch.model === "string") {
|
|
351
|
+
config.agents.defaults.model = patch.model;
|
|
352
|
+
}
|
|
353
|
+
if (typeof patch.maxTokens === "number" && Number.isFinite(patch.maxTokens)) {
|
|
354
|
+
config.agents.defaults.maxTokens = Math.max(1, Math.trunc(patch.maxTokens));
|
|
355
|
+
}
|
|
351
356
|
const next = ConfigSchema.parse(config);
|
|
352
357
|
saveConfig(next, configPath);
|
|
353
358
|
return buildConfigView(next);
|
|
@@ -595,12 +600,28 @@ function createUiRouter(options) {
|
|
|
595
600
|
});
|
|
596
601
|
app.put("/api/config/model", async (c) => {
|
|
597
602
|
const body = await readJson(c.req.raw);
|
|
598
|
-
if (!body.ok
|
|
599
|
-
return c.json(err("INVALID_BODY", "
|
|
603
|
+
if (!body.ok) {
|
|
604
|
+
return c.json(err("INVALID_BODY", "invalid json body"), 400);
|
|
605
|
+
}
|
|
606
|
+
const hasModel = typeof body.data.model === "string";
|
|
607
|
+
const hasMaxTokens = typeof body.data.maxTokens === "number";
|
|
608
|
+
if (!hasModel && !hasMaxTokens) {
|
|
609
|
+
return c.json(err("INVALID_BODY", "model or maxTokens is required"), 400);
|
|
600
610
|
}
|
|
601
|
-
const view = updateModel(options.configPath,
|
|
602
|
-
|
|
603
|
-
|
|
611
|
+
const view = updateModel(options.configPath, {
|
|
612
|
+
model: hasModel ? body.data.model : void 0,
|
|
613
|
+
maxTokens: hasMaxTokens ? body.data.maxTokens : void 0
|
|
614
|
+
});
|
|
615
|
+
if (hasModel) {
|
|
616
|
+
options.publish({ type: "config.updated", payload: { path: "agents.defaults.model" } });
|
|
617
|
+
}
|
|
618
|
+
if (hasMaxTokens) {
|
|
619
|
+
options.publish({ type: "config.updated", payload: { path: "agents.defaults.maxTokens" } });
|
|
620
|
+
}
|
|
621
|
+
return c.json(ok({
|
|
622
|
+
model: view.agents.defaults.model,
|
|
623
|
+
maxTokens: view.agents.defaults.maxTokens
|
|
624
|
+
}));
|
|
604
625
|
});
|
|
605
626
|
app.put("/api/config/providers/:provider", async (c) => {
|
|
606
627
|
const provider = c.req.param("provider");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/server",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nextclaw UI/API server.",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@hono/node-server": "^1.13.3",
|
|
18
18
|
"hono": "^4.6.2",
|
|
19
19
|
"ws": "^8.18.0",
|
|
20
|
-
"@nextclaw/core": "^0.6.
|
|
20
|
+
"@nextclaw/core": "^0.6.25"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^20.17.6",
|