@nextclaw/server 0.4.7 → 0.4.9

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 CHANGED
@@ -26,6 +26,39 @@ type ProviderConfigUpdate = {
26
26
  extraHeaders?: Record<string, string> | null;
27
27
  wireApi?: "auto" | "chat" | "responses" | null;
28
28
  };
29
+ type AgentProfileView = {
30
+ id: string;
31
+ default?: boolean;
32
+ workspace?: string;
33
+ model?: string;
34
+ maxTokens?: number;
35
+ maxToolIterations?: number;
36
+ };
37
+ type BindingPeerView = {
38
+ kind: "direct" | "group" | "channel";
39
+ id: string;
40
+ };
41
+ type AgentBindingView = {
42
+ agentId: string;
43
+ match: {
44
+ channel: string;
45
+ accountId?: string;
46
+ peer?: BindingPeerView;
47
+ };
48
+ };
49
+ type SessionConfigView = {
50
+ dmScope?: "main" | "per-peer" | "per-channel-peer" | "per-account-channel-peer";
51
+ agentToAgent?: {
52
+ maxPingPongTurns?: number;
53
+ };
54
+ };
55
+ type RuntimeConfigUpdate = {
56
+ agents?: {
57
+ list?: AgentProfileView[];
58
+ };
59
+ bindings?: AgentBindingView[];
60
+ session?: SessionConfigView;
61
+ };
29
62
  type ConfigView = {
30
63
  agents: {
31
64
  defaults: {
@@ -34,6 +67,7 @@ type ConfigView = {
34
67
  maxTokens?: number;
35
68
  maxToolIterations?: number;
36
69
  };
70
+ list?: AgentProfileView[];
37
71
  context?: {
38
72
  bootstrap?: {
39
73
  files?: string[];
@@ -50,6 +84,8 @@ type ConfigView = {
50
84
  };
51
85
  providers: Record<string, ProviderConfigView>;
52
86
  channels: Record<string, Record<string, unknown>>;
87
+ bindings?: AgentBindingView[];
88
+ session?: SessionConfigView;
53
89
  tools?: Record<string, unknown>;
54
90
  gateway?: Record<string, unknown>;
55
91
  ui?: Record<string, unknown>;
@@ -198,5 +234,6 @@ declare function loadConfigOrDefault(configPath: string): Config;
198
234
  declare function updateModel(configPath: string, model: string): ConfigView;
199
235
  declare function updateProvider(configPath: string, providerName: string, patch: ProviderConfigUpdate): ProviderConfigView | null;
200
236
  declare function updateChannel(configPath: string, channelName: string, patch: Record<string, unknown>): Record<string, unknown> | null;
237
+ declare function updateRuntime(configPath: string, patch: RuntimeConfigUpdate): Pick<ConfigView, "agents" | "bindings" | "session">;
201
238
 
202
- export { type ApiError, type ApiResponse, type ChannelSpecView, type ConfigActionExecuteRequest, type ConfigActionExecuteResult, type ConfigActionManifest, type ConfigActionType, type ConfigMetaView, type ConfigSchemaResponse, type ConfigUiHint, type ConfigUiHints, type ConfigView, type ProviderConfigUpdate, type ProviderConfigView, type ProviderSpecView, type UiServerEvent, type UiServerHandle, type UiServerOptions, buildConfigMeta, buildConfigSchemaView, buildConfigView, createUiRouter, executeConfigAction, loadConfigOrDefault, startUiServer, updateChannel, updateModel, updateProvider };
239
+ export { type AgentBindingView, type AgentProfileView, type ApiError, type ApiResponse, type BindingPeerView, type ChannelSpecView, type ConfigActionExecuteRequest, type ConfigActionExecuteResult, type ConfigActionManifest, type ConfigActionType, type ConfigMetaView, type ConfigSchemaResponse, type ConfigUiHint, type ConfigUiHints, type ConfigView, type ProviderConfigUpdate, type ProviderConfigView, type ProviderSpecView, type RuntimeConfigUpdate, type SessionConfigView, type UiServerEvent, type UiServerHandle, type UiServerOptions, buildConfigMeta, buildConfigSchemaView, buildConfigView, createUiRouter, executeConfigAction, loadConfigOrDefault, startUiServer, updateChannel, updateModel, updateProvider, updateRuntime };
package/dist/index.js CHANGED
@@ -25,6 +25,9 @@ import {
25
25
  var MASK_MIN_LENGTH = 8;
26
26
  var EXTRA_SENSITIVE_PATH_PATTERNS = [/authorization/i, /cookie/i, /session/i, /bearer/i];
27
27
  function matchesExtraSensitivePath(path) {
28
+ if (path === "session" || path.startsWith("session.")) {
29
+ return false;
30
+ }
28
31
  return EXTRA_SENSITIVE_PATH_PATTERNS.some((pattern) => pattern.test(path));
29
32
  }
30
33
  function matchHint(path, hints) {
@@ -255,6 +258,8 @@ function buildConfigView(config) {
255
258
  "channels",
256
259
  uiHints
257
260
  ),
261
+ bindings: sanitizePublicConfigValue(config.bindings, "bindings", uiHints),
262
+ session: sanitizePublicConfigValue(config.session, "session", uiHints),
258
263
  tools: sanitizePublicConfigValue(config.tools, "tools", uiHints),
259
264
  gateway: sanitizePublicConfigValue(config.gateway, "gateway", uiHints),
260
265
  ui: sanitizePublicConfigValue(config.ui, "ui", uiHints)
@@ -386,6 +391,37 @@ function updateChannel(configPath, channelName, patch) {
386
391
  uiHints
387
392
  );
388
393
  }
394
+ function updateRuntime(configPath, patch) {
395
+ const config = loadConfigOrDefault(configPath);
396
+ if (patch.agents && Object.prototype.hasOwnProperty.call(patch.agents, "list")) {
397
+ config.agents.list = (patch.agents.list ?? []).map((entry) => ({
398
+ ...entry,
399
+ default: Boolean(entry.default)
400
+ }));
401
+ }
402
+ if (Object.prototype.hasOwnProperty.call(patch, "bindings")) {
403
+ config.bindings = patch.bindings ?? [];
404
+ }
405
+ if (patch.session) {
406
+ const nextAgentToAgent = {
407
+ ...config.session.agentToAgent,
408
+ ...patch.session.agentToAgent ?? {}
409
+ };
410
+ config.session = {
411
+ ...config.session,
412
+ ...patch.session,
413
+ agentToAgent: nextAgentToAgent
414
+ };
415
+ }
416
+ const next = ConfigSchema.parse(config);
417
+ saveConfig(next, configPath);
418
+ const view = buildConfigView(next);
419
+ return {
420
+ agents: view.agents,
421
+ bindings: view.bindings ?? [],
422
+ session: view.session ?? {}
423
+ };
424
+ }
389
425
 
390
426
  // src/ui/router.ts
391
427
  function ok(data) {
@@ -453,6 +489,17 @@ function createUiRouter(options) {
453
489
  options.publish({ type: "config.updated", payload: { path: `channels.${channel}` } });
454
490
  return c.json(ok(result));
455
491
  });
492
+ app.put("/api/config/runtime", async (c) => {
493
+ const body = await readJson(c.req.raw);
494
+ if (!body.ok || !body.data || typeof body.data !== "object") {
495
+ return c.json(err("INVALID_BODY", "invalid json body"), 400);
496
+ }
497
+ const result = updateRuntime(options.configPath, body.data);
498
+ options.publish({ type: "config.updated", payload: { path: "agents.list" } });
499
+ options.publish({ type: "config.updated", payload: { path: "bindings" } });
500
+ options.publish({ type: "config.updated", payload: { path: "session" } });
501
+ return c.json(ok(result));
502
+ });
456
503
  app.post("/api/config/actions/:actionId/execute", async (c) => {
457
504
  const actionId = c.req.param("actionId");
458
505
  const body = await readJson(c.req.raw);
@@ -565,5 +612,6 @@ export {
565
612
  startUiServer,
566
613
  updateChannel,
567
614
  updateModel,
568
- updateProvider
615
+ updateProvider,
616
+ updateRuntime
569
617
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/server",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
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.22"
20
+ "@nextclaw/core": "^0.6.23"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "^20.17.6",