@nextclaw/server 0.12.22 → 0.12.23

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
@@ -1091,6 +1091,7 @@ type UiNcpSessionMessagesView = {
1091
1091
  sessionId: string;
1092
1092
  status: NcpSessionStatus;
1093
1093
  messages: NcpMessage[];
1094
+ contextWindow?: NcpSessionSummary["contextWindow"];
1094
1095
  total: number;
1095
1096
  };
1096
1097
  type SessionTypeDescribeParams = {
@@ -1481,7 +1482,7 @@ type UiPluginHost = {
1481
1482
  getChannelBindings: () => PluginChannelBinding[];
1482
1483
  getUiMetadata: () => PluginUiMetadata[];
1483
1484
  };
1484
- type UiKernelHost = Pick<NextclawKernel, "agentRuntimeManager" | "assetStore" | "ingress" | "llmProviders" | "ncpSessionApi" | "sessionRunManager">;
1485
+ type UiKernelHost = Pick<NextclawKernel, "agentRuntimeManager" | "assetStore" | "ingress" | "llmProviders" | "ncpSessionManager" | "sessionRunManager">;
1485
1486
  type UiCronHost = {
1486
1487
  listJobs: (includeDisabled?: boolean) => CronJobEntry[];
1487
1488
  addJob: (params: {
package/dist/index.js CHANGED
@@ -456,6 +456,7 @@ const eventKeys = {
456
456
  channelConfigApplyStatus: createAppEventKey("channel.config.apply-status"),
457
457
  sessionUpdated: createAppEventKey("session.updated"),
458
458
  sessionRunStatus: createAppEventKey("session.run-status"),
459
+ sessionMetadataChanged: createAppEventKey("session.metadata.changed"),
459
460
  ncpEvent: createAppEventKey("ncp.event"),
460
461
  sessionSummaryUpsert: createAppEventKey("session.summary.upsert"),
461
462
  sessionSummaryDelete: createAppEventKey("session.summary.delete"),
@@ -4188,15 +4189,12 @@ var NcpSessionRoutesController = class {
4188
4189
  this.options = options;
4189
4190
  this.sessionSkillsViewBuilder = new SessionSkillsViewBuilder(options);
4190
4191
  }
4191
- getSessionApi = () => this.options.kernel.ncpSessionApi;
4192
4192
  getSessionTypes = async (c) => {
4193
4193
  const payload = await this.options.kernel.agentRuntimeManager.listSessionTypes({ describeMode: "observation" });
4194
4194
  return c.json(ok(payload));
4195
4195
  };
4196
4196
  listSessions = async (c) => {
4197
- const sessionApi = this.getSessionApi();
4198
- if (!sessionApi) return c.json(err("NOT_AVAILABLE", "ncp session api unavailable"), 503);
4199
- const sessions = await sessionApi.listSessions({ limit: readPositiveInt(c.req.query("limit")) });
4197
+ const sessions = await this.options.kernel.ncpSessionManager.listSessions({ limit: readPositiveInt(c.req.query("limit")) });
4200
4198
  const payload = {
4201
4199
  sessions,
4202
4200
  total: sessions.length
@@ -4204,20 +4202,18 @@ var NcpSessionRoutesController = class {
4204
4202
  return c.json(ok(payload));
4205
4203
  };
4206
4204
  getSession = async (c) => {
4207
- const sessionApi = this.getSessionApi();
4208
- if (!sessionApi) return c.json(err("NOT_AVAILABLE", "ncp session api unavailable"), 503);
4205
+ const sessionManager = this.options.kernel.ncpSessionManager;
4209
4206
  const sessionId = decodeURIComponent(c.req.param("sessionId"));
4210
- const session = await sessionApi.getSession(sessionId);
4207
+ const session = await sessionManager.getSession(sessionId);
4211
4208
  if (!session) return c.json(err("NOT_FOUND", `ncp session not found: ${sessionId}`), 404);
4212
4209
  return c.json(ok(session));
4213
4210
  };
4214
4211
  listSessionMessages = async (c) => {
4215
- const sessionApi = this.getSessionApi();
4216
- if (!sessionApi) return c.json(err("NOT_AVAILABLE", "ncp session api unavailable"), 503);
4212
+ const sessionManager = this.options.kernel.ncpSessionManager;
4217
4213
  const sessionId = decodeURIComponent(c.req.param("sessionId"));
4218
- const session = await sessionApi.getSession(sessionId);
4214
+ const session = await sessionManager.getSession(sessionId);
4219
4215
  if (!session) return c.json(err("NOT_FOUND", `ncp session not found: ${sessionId}`), 404);
4220
- const messages = await sessionApi.listSessionMessages(sessionId, { limit: readPositiveInt(c.req.query("limit")) });
4216
+ const messages = await sessionManager.listSessionMessages(sessionId, { limit: readPositiveInt(c.req.query("limit")) });
4221
4217
  const payload = {
4222
4218
  sessionId,
4223
4219
  status: session.status ?? "idle",
@@ -4228,12 +4224,11 @@ var NcpSessionRoutesController = class {
4228
4224
  return c.json(ok(payload));
4229
4225
  };
4230
4226
  getSessionSkills = async (c) => {
4231
- const sessionApi = this.getSessionApi();
4232
- if (!sessionApi) return c.json(err("NOT_AVAILABLE", "ncp session api unavailable"), 503);
4227
+ const sessionManager = this.options.kernel.ncpSessionManager;
4233
4228
  const sessionId = decodeURIComponent(c.req.param("sessionId"));
4234
4229
  const query = c.req.query();
4235
4230
  const hasProjectRootOverride = Object.prototype.hasOwnProperty.call(query, "projectRoot");
4236
- const metadata = readSessionMetadata((await sessionApi.getSession(sessionId))?.metadata);
4231
+ const metadata = readSessionMetadata((await sessionManager.getSession(sessionId))?.metadata);
4237
4232
  if (hasProjectRootOverride) try {
4238
4233
  const projectRoot = await normalizeSessionProjectRoot(query.projectRoot);
4239
4234
  if (projectRoot) metadata.project_root = projectRoot;
@@ -4251,8 +4246,7 @@ var NcpSessionRoutesController = class {
4251
4246
  })));
4252
4247
  };
4253
4248
  patchSession = async (c) => {
4254
- const sessionApi = this.getSessionApi();
4255
- if (!sessionApi) return c.json(err("NOT_AVAILABLE", "ncp session api unavailable"), 503);
4249
+ const sessionManager = this.options.kernel.ncpSessionManager;
4256
4250
  const sessionId = decodeURIComponent(c.req.param("sessionId"));
4257
4251
  const body = await readJson(c.req.raw);
4258
4252
  if (!body.ok || !body.data || typeof body.data !== "object") return c.json(err("INVALID_BODY", "invalid json body"), 400);
@@ -4261,23 +4255,24 @@ var NcpSessionRoutesController = class {
4261
4255
  let patched;
4262
4256
  try {
4263
4257
  const projectRootPatch = Object.prototype.hasOwnProperty.call(patch, "projectRoot") ? await normalizeSessionProjectRoot(patch.projectRoot) : void 0;
4264
- patched = await this.options.kernel.sessionRunManager.patchSessionMetadata(sessionId, (metadata) => buildPatchedSessionMetadata(metadata, patch, projectRootPatch));
4258
+ const existing = await sessionManager.getSessionRecord(sessionId);
4259
+ const metadata = buildPatchedSessionMetadata(readSessionMetadata(existing?.metadata), patch, projectRootPatch);
4260
+ patched = existing ? await sessionManager.setSessionMetadata(sessionId, metadata) : Boolean(await sessionManager.updateSession(sessionId, { metadata }));
4265
4261
  } catch (error) {
4266
4262
  if (error instanceof Error && error.message === "PREFERRED_THINKING_INVALID") return c.json(err("PREFERRED_THINKING_INVALID", "preferredThinking must be a supported thinking level"), 400);
4267
4263
  if (isSessionProjectRootValidationError(error)) return c.json(err(error.code, error.message), 400);
4268
4264
  throw error;
4269
4265
  }
4270
4266
  if (!patched) return c.json(err("NOT_FOUND", `ncp session not found: ${sessionId}`), 404);
4271
- const updated = await sessionApi.getSession(sessionId);
4267
+ const updated = await sessionManager.getSession(sessionId);
4272
4268
  if (!updated) return c.json(err("NOT_FOUND", `ncp session not found: ${sessionId}`), 404);
4273
4269
  return c.json(ok(updated));
4274
4270
  };
4275
4271
  deleteSession = async (c) => {
4276
- const sessionApi = this.getSessionApi();
4277
- if (!sessionApi) return c.json(err("NOT_AVAILABLE", "ncp session api unavailable"), 503);
4272
+ const sessionManager = this.options.kernel.ncpSessionManager;
4278
4273
  const sessionId = decodeURIComponent(c.req.param("sessionId"));
4279
- if (!await sessionApi.getSession(sessionId)) return c.json(err("NOT_FOUND", `ncp session not found: ${sessionId}`), 404);
4280
- await sessionApi.deleteSession(sessionId);
4274
+ if (!await sessionManager.getSession(sessionId)) return c.json(err("NOT_FOUND", `ncp session not found: ${sessionId}`), 404);
4275
+ await sessionManager.deleteSession(sessionId);
4281
4276
  return c.json(ok({
4282
4277
  deleted: true,
4283
4278
  sessionId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/server",
3
- "version": "0.12.22",
3
+ "version": "0.12.23",
4
4
  "private": false,
5
5
  "description": "Nextclaw UI/API server.",
6
6
  "type": "module",
@@ -18,12 +18,12 @@
18
18
  "@hono/node-server": "^1.13.3",
19
19
  "hono": "^4.6.2",
20
20
  "ws": "^8.18.0",
21
- "@nextclaw/kernel": "0.1.11",
22
- "@nextclaw/openclaw-compat": "1.0.21",
23
- "@nextclaw/mcp": "0.1.86",
24
- "@nextclaw/core": "0.12.21",
25
- "@nextclaw/runtime": "0.2.53",
26
- "@nextclaw/ncp": "0.5.14"
21
+ "@nextclaw/core": "0.12.22",
22
+ "@nextclaw/mcp": "0.1.87",
23
+ "@nextclaw/ncp": "0.5.15",
24
+ "@nextclaw/kernel": "0.1.12",
25
+ "@nextclaw/openclaw-compat": "1.0.22",
26
+ "@nextclaw/runtime": "0.2.54"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^20.17.6",