@kodizm/acp 0.5.2 → 0.5.3

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.
Files changed (2) hide show
  1. package/dist/index.js +39 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4928,6 +4928,17 @@ class ClaudeDriver {
4928
4928
  });
4929
4929
  return { sessionId };
4930
4930
  }
4931
+ async compact(request, emit) {
4932
+ const state = this.sessions.get(request.sessionId);
4933
+ if (state === undefined) {
4934
+ throw new SessionNotFoundError(request.sessionId);
4935
+ }
4936
+ state.pendingManualCompact = true;
4937
+ await this.prompt(request.sessionId, {
4938
+ sessionId: request.sessionId,
4939
+ prompt: [{ type: "text", text: "/compact" }]
4940
+ }, emit);
4941
+ }
4931
4942
  async prompt(sessionId, params, emit) {
4932
4943
  const state = this.sessions.get(sessionId);
4933
4944
  if (state === undefined) {
@@ -5074,7 +5085,8 @@ class ClaudeDriver {
5074
5085
  }
5075
5086
  }
5076
5087
  tracker.observe(message);
5077
- const events = tracker.rewrite(mapSdkMessage(sessionId, message));
5088
+ const rawEvents = tracker.rewrite(mapSdkMessage(sessionId, message));
5089
+ const events = this.applyManualCompactLatch(state, rawEvents);
5078
5090
  for (const event of events) {
5079
5091
  emit.send(event);
5080
5092
  }
@@ -5271,6 +5283,21 @@ class ClaudeDriver {
5271
5283
  return text.join(`
5272
5284
  `);
5273
5285
  }
5286
+ applyManualCompactLatch(state, events) {
5287
+ if (state.pendingManualCompact !== true) {
5288
+ return events;
5289
+ }
5290
+ return events.map((event) => {
5291
+ if (event.type === "compaction_started") {
5292
+ return { ...event, trigger: "manual" };
5293
+ }
5294
+ if (event.type === "compaction_completed") {
5295
+ state.pendingManualCompact = false;
5296
+ return { ...event, trigger: "manual" };
5297
+ }
5298
+ return event;
5299
+ });
5300
+ }
5274
5301
  }
5275
5302
  var FULL_CAPABILITIES;
5276
5303
  var init_driver = __esm(() => {
@@ -28775,6 +28802,9 @@ var LoadSessionRequestSchema = exports_external.object({
28775
28802
  mcpServers: exports_external.array(McpServerSchema),
28776
28803
  _meta: MetaSchema.optional()
28777
28804
  }).refine(metaCarriesNoCanonicalFields, { message: META_SMUGGLE_MESSAGE, path: ["_meta"] });
28805
+ var CompactSessionRequestSchema = exports_external.object({
28806
+ sessionId: exports_external.string().min(1)
28807
+ });
28778
28808
  var ForkSessionRequestSchema = exports_external.object({
28779
28809
  sourceSessionId: exports_external.string().min(1),
28780
28810
  cwd: AbsolutePathSchema,
@@ -28839,6 +28869,14 @@ function wireBackendHandlers(server, backend) {
28839
28869
  const validated = validateOrThrow(ForkSessionRequestSchema, params);
28840
28870
  return await backend.forkSession(validated);
28841
28871
  });
28872
+ server.on("session/compact", async (params) => {
28873
+ const validated = validateOrThrow(CompactSessionRequestSchema, params);
28874
+ const emit = {
28875
+ send: (event) => server.notify("sessionUpdate", event)
28876
+ };
28877
+ await backend.compact(validated, emit);
28878
+ return {};
28879
+ });
28842
28880
  }
28843
28881
  function createAcpServer(options) {
28844
28882
  const { transport, backend, debugSink } = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodizm/acp",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Custom ACP server bridging Claude Code, codex, and opencode CLIs through a single Kodizm-flavored protocol surface.",
5
5
  "type": "module",
6
6
  "bin": {