@kodizm/acp 0.5.1 → 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 +43 -3
  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;
@@ -29194,9 +29232,10 @@ function pickClaudeCredentials(env) {
29194
29232
  async function buildClaudeBackend() {
29195
29233
  const { ClaudeDriver: ClaudeDriver2 } = await Promise.resolve().then(() => (init_driver(), exports_driver));
29196
29234
  const sdk = await Promise.resolve().then(() => (init_sdk(), exports_sdk));
29235
+ const claudePath = process.env.CLAUDE_CODE_PATH ?? "/usr/local/bin/claude";
29197
29236
  const driver = new ClaudeDriver2({
29198
29237
  credentials: pickClaudeCredentials(process.env),
29199
- agentInfo: { version: "0.5.1" },
29238
+ agentInfo: { version: "0.5.2" },
29200
29239
  sdk: {
29201
29240
  async* query(args) {
29202
29241
  const optsIn = args.options;
@@ -29204,7 +29243,8 @@ async function buildClaudeBackend() {
29204
29243
  prompt: args.prompt,
29205
29244
  options: {
29206
29245
  ...optsIn ?? {},
29207
- settingSources: []
29246
+ settingSources: [],
29247
+ pathToClaudeCodeExecutable: claudePath
29208
29248
  }
29209
29249
  };
29210
29250
  for await (const message of sdk.query(isolated)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodizm/acp",
3
- "version": "0.5.1",
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": {